Skip to content

Commit

Permalink
Merge branch 'release-15.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
shpran committed Aug 26, 2021
2 parents 88f0d9a + 57f680b commit 1bfc5ba
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 25 deletions.
15 changes: 15 additions & 0 deletions common/oatbox/user/UserLanguageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class UserLanguageService extends ConfigurableService implements UserLanguageSer
public const OPTION_LOCK_DATA_LANGUAGE = 'lock_data_language';
public const OPTION_AUTHORING_LANGUAGE = 'authoring_language';

/** @var ?string */
private $customInterfaceLanguage;

/**
* {@inheritDoc}
* @see \oat\oatbox\user\UserLanguageServiceInterface::getDefaultLanguage()
Expand Down Expand Up @@ -56,6 +59,10 @@ public function getDataLanguage(User $user)
*/
public function getInterfaceLanguage(User $user)
{
if (!empty($this->customInterfaceLanguage)) {
return $this->customInterfaceLanguage;
}

$lang = $user->getPropertyValues(GenerisRdf::PROPERTY_USER_UILG);
return empty($lang) ? $this->getDefaultLanguage() : (string)current($lang);
}
Expand All @@ -72,4 +79,12 @@ public function getAuthoringLanguage(): string
{
return $this->getOption(self::OPTION_AUTHORING_LANGUAGE, $this->getDefaultLanguage());
}

/**
* @inheritdoc
*/
public function setCustomInterfaceLanguage(?string $customInterfaceLanguage): void
{
$this->customInterfaceLanguage = $customInterfaceLanguage;
}
}
8 changes: 8 additions & 0 deletions common/oatbox/user/UserLanguageServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ public function getInterfaceLanguage(User $user);
* @return boolean
*/
public function isDataLanguageEnabled();

/**
* When a custom interface language is set, it overrides the interface language retrieved in the getInterfaceLanguage
* method.
*
* @param ?string $customInterfaceLanguage
*/
public function setCustomInterfaceLanguage(?string $customInterfaceLanguage): void;
}
17 changes: 15 additions & 2 deletions common/session/class.BasicSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2017 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
* Copyright (c) 2017-2021 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
*/

Expand Down Expand Up @@ -142,7 +142,20 @@ public function getDataLanguage()
*/
public function getInterfaceLanguage()
{
return $this->getServiceLocator()->get(UserLanguageServiceInterface::class)->getInterfaceLanguage($this->getUser());
/** @var PHPSession $session */
$session = PHPSession::singleton();

/** @var UserLanguageServiceInterface $userLanguageService */
$userLanguageService = $this->getServiceLocator()->get(UserLanguageServiceInterface::class);

if ($session->hasAttribute('overrideInterfaceLanguage')) {
$userLanguageService->setCustomInterfaceLanguage($session->getAttribute('overrideInterfaceLanguage'));
} else {
// Just to be sure the custom interface language is removed when the session attribute is gone
$userLanguageService->setCustomInterfaceLanguage(null);
}

return $userLanguageService->getInterfaceLanguage($this->getUser());
}

/**
Expand Down
1 change: 1 addition & 0 deletions core/GenerisRdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ interface GenerisRdf
public const PROPERTY_MASK_SUBJECT = 'http://www.tao.lu/Ontologies/generis.rdf#MaskSubject';
public const PROPERTY_MASK_PREDICATE = 'http://www.tao.lu/Ontologies/generis.rdf#MaskPredicate';
public const PROPERTY_MASK_OBJECT = 'http://www.tao.lu/Ontologies/generis.rdf#MaskObject';
public const PROPERTY_DEPENDS_ON_PROPERTY = 'http://www.tao.lu/Ontologies/generis.rdf#DependsOnProperty';
//@deprecated use UserRdf::CLASS_URI
public const CLASS_GENERIS_USER = 'http://www.tao.lu/Ontologies/generis.rdf#User';
//@deprecated use UserRdf::PROPERTY_LOGIN
Expand Down
59 changes: 48 additions & 11 deletions core/kernel/classes/class.Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
*
*/

use oat\generis\model\data\ModelManager;
declare(strict_types=1);

use oat\generis\model\WidgetRdf;
use oat\generis\model\GenerisRdf;
use oat\generis\model\OntologyRdfs;
use oat\generis\model\WidgetRdf;
use oat\generis\model\resource\DependsOnPropertyCollection;

/**
* uriProperty must be a valid property otherwis return false, add this as a
Expand Down Expand Up @@ -88,6 +90,9 @@ class core_kernel_classes_Property extends core_kernel_classes_Resource
*/
public $multiple = false;

/** @var DependsOnPropertyCollection */
private $dependsOnPropertyCollection;

// --- OPERATIONS ---
/**
* @return core_kernel_persistence_PropertyInterface
Expand All @@ -96,7 +101,7 @@ private function getImplementation()
{
return $this->getModel()->getRdfsInterface()->getPropertyImplementation();
}


/**
* constructor
Expand All @@ -109,10 +114,11 @@ private function getImplementation()
*/
public function __construct($uri, $debug = '')
{

parent::__construct($uri, $debug);

$this->lgDependent = null;
$this->multiple = null;
$this->dependsOnPropertyCollection = new DependsOnPropertyCollection();
}

/**
Expand Down Expand Up @@ -145,7 +151,7 @@ public function getDomain()
}
}
$returnValue = $this->domain;


return $returnValue;
}
Expand All @@ -161,7 +167,7 @@ public function getDomain()
public function setDomain(core_kernel_classes_Class $class)
{
$returnValue = (bool) false;

if (!is_null($class)) {
foreach ($this->getDomain()->getIterator() as $domainClass) {
if ($class->equals($domainClass)) {
Expand Down Expand Up @@ -190,7 +196,7 @@ public function setDomain(core_kernel_classes_Class $class)
public function getRange()
{
$returnValue = null;

if (is_null($this->range)) {
$rangeProperty = $this->getProperty(OntologyRdfs::RDFS_RANGE);
$rangeValues = $this->getPropertyValues($rangeProperty);
Expand Down Expand Up @@ -222,6 +228,37 @@ public function setRange(core_kernel_classes_Class $class)
return (bool) $returnValue;
}

/**
* @TODO Improve getter
*/
public function getDependsOnPropertyCollection(): DependsOnPropertyCollection
{
$dependsOnProperty = $this->getProperty(GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY);
$dependsOnPropertyValues = $this->getPropertyValues($dependsOnProperty);

foreach ($dependsOnPropertyValues as $dependsOnPropertyValue) {
if ($dependsOnPropertyValue !== GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY) {
$this->dependsOnPropertyCollection->append(
$this->getProperty($dependsOnPropertyValue)
);
}
}

return $this->dependsOnPropertyCollection;
}

/**
* @TODO Improve setter
*/
public function setDependsOnPropertyCollection(DependsOnPropertyCollection $dependsOnPropertyCollection): void
{
foreach ($dependsOnPropertyCollection as $dependsOnProperty) {
$this->getImplementation()->setDependsOnProperty($this, $dependsOnProperty);
}

$this->dependsOnPropertyCollection = $dependsOnPropertyCollection;
}

/**
* Get the Property object corresponding to the widget of this Property.
*
Expand All @@ -235,7 +272,7 @@ public function getWidget()
if ($this->widget === false) {
$this->widget = $this->getOnePropertyValue($this->getProperty(WidgetRdf::PROPERTY_WIDGET));
}

return $this->widget;
}

Expand Down Expand Up @@ -282,15 +319,15 @@ public function isMultiple()
if (is_null($this->multiple)) {
$multipleProperty = $this->getProperty(GenerisRdf::PROPERTY_MULTIPLE);
$multiple = $this->getOnePropertyValue($multipleProperty);

if (is_null($multiple)) {
$returnValue = false;
} else {
$returnValue = ($multiple->getUri() == GenerisRdf::GENERIS_TRUE);
}
$this->multiple = $returnValue;
}

$returnValue = $this->multiple;
return (bool) $returnValue;
}
Expand All @@ -306,7 +343,7 @@ public function isMultiple()
*/
public function setMultiple($isMultiple)
{

$this->getImplementation()->setMultiple($this, $isMultiple);
$this->multiple = $isMultiple;
}
Expand Down
21 changes: 13 additions & 8 deletions core/kernel/persistence/interface.PropertyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
interface core_kernel_persistence_PropertyInterface
{





/**
* Short description of method isLgDependent
*
Expand All @@ -41,7 +41,7 @@ interface core_kernel_persistence_PropertyInterface
* @return boolean
*/
public function isLgDependent(core_kernel_classes_Resource $resource);


/**
* Short description of method isMultiple
*
Expand All @@ -51,7 +51,7 @@ public function isLgDependent(core_kernel_classes_Resource $resource);
* @return boolean
*/
public function isMultiple(core_kernel_classes_Resource $resource);


/**
* Short description of method getRange
*
Expand All @@ -61,7 +61,7 @@ public function isMultiple(core_kernel_classes_Resource $resource);
* @return core_kernel_classes_Class
*/
public function getRange(core_kernel_classes_Resource $resource);


/**
* Short description of method delete
*
Expand All @@ -72,7 +72,7 @@ public function getRange(core_kernel_classes_Resource $resource);
* @return boolean
*/
public function delete(core_kernel_classes_Resource $resource, $deleteReference = false);


/**
* Short description of method setRange
*
Expand All @@ -83,7 +83,12 @@ public function delete(core_kernel_classes_Resource $resource, $deleteReference
* @return core_kernel_classes_Class
*/
public function setRange(core_kernel_classes_Resource $resource, core_kernel_classes_Class $class);


public function setDependsOnProperty(
core_kernel_classes_Resource $resource,
core_kernel_classes_Property $property
): void;

/**
* Short description of method setMultiple
*
Expand All @@ -94,7 +99,7 @@ public function setRange(core_kernel_classes_Resource $resource, core_kernel_cla
* @return void
*/
public function setMultiple(core_kernel_classes_Resource $resource, $isMultiple);


/**
* Short description of method setLgDependent
*
Expand Down
22 changes: 18 additions & 4 deletions core/kernel/persistence/smoothsql/class.Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
* 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
* 2017 (update and modification) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*/


declare(strict_types=1);

use oat\generis\model\GenerisRdf;
use oat\generis\model\OntologyRdfs;


/**
* Short description of class core_kernel_persistence_smoothsql_Property
*
Expand Down Expand Up @@ -139,6 +141,18 @@ public function setRange(core_kernel_classes_Resource $resource, core_kernel_cla
return $returnValue;
}

public function setDependsOnProperty(
core_kernel_classes_Resource $resource,
core_kernel_classes_Property $property
): void {
$dependsOnProperty = new core_kernel_classes_Property(
GenerisRdf::PROPERTY_DEPENDS_ON_PROPERTY,
__METHOD__
);

$this->setPropertyValue($resource, $dependsOnProperty, $property->getUri());
}

/**
* Short description of method setMultiple
*
Expand All @@ -150,7 +164,7 @@ public function setRange(core_kernel_classes_Resource $resource, core_kernel_cla
*/
public function setMultiple(core_kernel_classes_Resource $resource, $isMultiple)
{

$multipleProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_MULTIPLE);
$value = ((bool)$isMultiple) ? GenerisRdf::GENERIS_TRUE : GenerisRdf::GENERIS_FALSE ;
$this->removePropertyValues($resource, $multipleProperty);
Expand All @@ -168,7 +182,7 @@ public function setMultiple(core_kernel_classes_Resource $resource, $isMultiple)
*/
public function setLgDependent(core_kernel_classes_Resource $resource, $isLgDependent)
{

$lgDependentProperty = new core_kernel_classes_Property(GenerisRdf::PROPERTY_IS_LG_DEPENDENT, __METHOD__);
$value = ((bool)$isLgDependent) ? GenerisRdf::GENERIS_TRUE : GenerisRdf::GENERIS_FALSE ;
$this->removePropertyValues($resource, $lgDependentProperty);
Expand Down
7 changes: 7 additions & 0 deletions core/ontology/generis.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,11 @@
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#GenerisRole"/>
</rdf:Description>

<rdf:Description rdf:about="http://www.tao.lu/Ontologies/generis.rdf#DependsOnProperty">
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
<rdfs:label xml:lang="en-US"><![CDATA[Depends on property]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[Depends on property]]></rdfs:comment>
<rdfs:domain rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Property"/>
</rdf:Description>
</rdf:RDF>
Loading

0 comments on commit 1bfc5ba

Please sign in to comment.