Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,25 @@
*/
abstract class ilDidacticTemplateAction
{
public const TYPE_LOCAL_POLICY = 1;
public const TYPE_LOCAL_ROLE = 2;
public const TYPE_BLOCK_ROLE = 3;
public const int TYPE_LOCAL_POLICY = 1;
public const int TYPE_LOCAL_ROLE = 2;
public const int TYPE_BLOCK_ROLE = 3;

public const FILTER_SOURCE_TITLE = 1;
public const FILTER_SOURCE_OBJ_ID = 2;
public const FILTER_PARENT_ROLES = 3;
public const FILTER_LOCAL_ROLES = 4;

public const PATTERN_PARENT_TYPE = 'action';
public const int FILTER_SOURCE_TITLE = 1;
public const int FILTER_SOURCE_OBJ_ID = 2;
public const int FILTER_PARENT_ROLES = 3;
public const int FILTER_LOCAL_ROLES = 4;
public const string PATTERN_PARENT_TYPE = 'action';

protected ilLogger $logger;
protected ilDBInterface $db;
protected ilRbacReview $review;
protected ilRbacAdmin $admin;

private int $action_id = 0;
private int $tpl_id = 0;
private int $type = 0;

private int $ref_id = 0;
protected int $action_id = 0;
protected int $tpl_id = 0;
protected int $type = 0;
protected int $ref_id = 0;

public function __construct(int $action_id = 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
*/
class ilDidacticTemplateLocalPolicyAction extends ilDidacticTemplateAction
{
public const TPL_ACTION_OVERWRITE = 1;
public const TPL_ACTION_INTERSECT = 2;
public const TPL_ACTION_ADD = 3;
public const TPL_ACTION_SUBTRACT = 4;
public const TPL_ACTION_UNION = 5;
public const int TPL_ACTION_OVERWRITE = 1;
public const int TPL_ACTION_INTERSECT = 2;
public const int TPL_ACTION_ADD = 3;
public const int TPL_ACTION_SUBTRACT = 4;
public const int TPL_ACTION_UNION = 5;

/** @var ilDidacticTemplateFilterPattern[] */
private array $pattern = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
*/
class ilDidacticTemplateIconHandler
{
protected const WEBDIR_PREFIX = 'ilDidacticTemplateIcons';

protected const string WEBDIR_PREFIX = 'ilDidacticTemplateIcons';
protected ilDidacticTemplateSetting $settings;
protected ilLogger $logger;
protected Filesystem $webDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=1);

/**
* Class handles translation mode for an object.
*
Expand Down Expand Up @@ -301,9 +303,9 @@ public function fromXML(SimpleXMLElement $root): void

foreach ($root->translation as $trans) {
$this->addLanguage(
trim($trans["language"]),
trim($trans->title),
trim($trans->description),
trim((string) $trans["language"]),
trim((string) $trans->title),
trim((string) $trans->description),
(int) $trans["default"] !== 0
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
*
*********************************************************************/

declare(strict_types=1);

use ILIAS\MetaData\Services\ServicesInterface as LOMServices;

/**
* GUI class for object translation handling.
* @author Alexander Killing <killing@leifos.de>
* @ilCtrl_IsCalledBy ilMultilingualismeGUI: ilDidacticTemplateSettingsGUI
* @ilCtrl_IsCalledBy ilMultilingualismGUI: ilDidacticTemplateSettingsGUI
*/
class ilMultilingualismGUI
{
Expand Down Expand Up @@ -52,7 +54,7 @@ public function __construct(
$this->lom_services = $DIC->learningObjectMetadata();

$this->obj_trans = ilMultilingualism::getInstance($a_obj_id, $a_type);
$this->request = new \ILIAS\Multilingualism\StandardGUIRequest(
$this->request = new \ILIAS\DidacticTemplate\Multilingualism\StandardGUIRequest(
$DIC->http(),
$DIC->refinery()
);
Expand All @@ -76,18 +78,12 @@ public function getTitleDescrOnlyMode(): bool

public function executeCommand(): void
{
$next_class = $this->ctrl->getNextClass($this);

switch ($next_class) {
default:
$cmd = $this->ctrl->getCmd("listTranslations");
if (in_array($cmd, array("listTranslations", "saveTranslations",
"addTranslation", "deleteTranslations", "activateContentMultilinguality",
"confirmRemoveLanguages", "removeLanguages", "confirmDeactivateContentMultiLang", "saveLanguages",
"saveContentTranslationActivation", "deactivateContentMultiLang", "addLanguages"))) {
$this->$cmd();
}
break;
$cmd = $this->ctrl->getCmd("listTranslations");
if (in_array($cmd, array("listTranslations", "saveTranslations",
"addTranslation", "deleteTranslations", "activateContentMultilinguality",
"confirmRemoveLanguages", "removeLanguages", "confirmDeactivateContentMultiLang", "saveLanguages",
"saveContentTranslationActivation", "deactivateContentMultiLang", "addLanguages"))) {
$this->$cmd();
}
}

Expand Down Expand Up @@ -391,8 +387,8 @@ public function removeLanguages(): void
if (count($post_langs) > 0) {
$langs = $this->obj_trans->getLanguages();
foreach ($langs as $k => $l) {
if (in_array($l, $post_langs)) {
$this->obj_trans->removeLanguage($l);
if (in_array($k, $post_langs)) {
$this->obj_trans->removeLanguage($k);
}
}
$this->obj_trans->save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=1);

use ILIAS\MetaData\Services\ServicesInterface as LOMServices;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ public function __construct(int $a_pattern_id = 0)
*/
public function valid(string $a_source): bool
{
$a_source = trim($a_source);
switch ($this->getPatternSubType()) {
case self::PATTERN_SUBTYPE_REGEX:
$this->logger->debug('Checking exclude pattern with ' . $a_source . ' against ' . $this->getPattern());
return preg_match('/' . $this->getPattern() . '/', $a_source) !== 1;
if ($this->getPatternSubType() === self::PATTERN_SUBTYPE_REGEX) {
$a_source = trim($a_source);
$this->logger->debug('Checking exclude pattern with ' . $a_source . ' against ' . $this->getPattern());
return preg_match('/' . $this->getPattern() . '/', $a_source) !== 1;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,15 @@
*/
abstract class ilDidacticTemplateFilterPattern
{
public const PATTERN_INCLUDE = 1;
public const PATTERN_EXCLUDE = 2;

public const PATTERN_SUBTYPE_REGEX = 1;

private int $pattern_id = 0;

private int $parent_id = 0;
private string $parent_type = '';

private string $pattern = '';
private int $pattern_type = 0;
private int $pattern_sub_type = 0;

public const int PATTERN_INCLUDE = 1;
public const int PATTERN_EXCLUDE = 2;
public const int PATTERN_SUBTYPE_REGEX = 1;
protected string $parent_type = '';
protected string $pattern = '';
protected int $pattern_id = 0;
protected int $parent_id = 0;
protected int $pattern_type = 0;
protected int $pattern_sub_type = 0;
protected ilDBInterface $db;
protected ilLogger $logger;

Expand Down Expand Up @@ -116,15 +111,11 @@ public function getPattern(): string

/**
* Check if pattern matches
* @param mixed
* @return bool
*/
abstract public function valid(string $a_source): bool;

/**
* Get xml representation of pattern
* @param ilXmlWriter $writer
* @return string
*/
abstract public function toXml(ilXmlWriter $writer): void;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ public function __construct(int $a_pattern_id = 0)

public function valid(string $a_source): bool
{
$a_source = trim($a_source);
switch ($this->getPatternSubType()) {
case self::PATTERN_SUBTYPE_REGEX:
$this->logger->debug('Checking include pattern with ' . $a_source . ' against ' . $this->getPattern());
return preg_match('/' . $this->getPattern() . '/', $a_source) === 1;
if ($this->getPatternSubType() === self::PATTERN_SUBTYPE_REGEX) {
$a_source = trim($a_source);
$this->logger->debug('Checking include pattern with ' . $a_source . ' against ' . $this->getPattern());
return preg_match('/' . $this->getPattern() . '/', $a_source) === 1;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
*/
class ilDidacticTemplateSetting
{
public const TYPE_CREATION = 1;

public const int TYPE_CREATION = 1;
private int $id = 0;
private bool $enabled = false;
private string $title = '';
Expand Down Expand Up @@ -474,12 +473,8 @@ protected function read(): bool

public function toXml(ilXmlWriter $writer): ilXmlWriter
{
$type = '';
switch ($this->getType()) {
case self::TYPE_CREATION:
$type = 'creation';
break;
}
$type = ($this->getType() === self::TYPE_CREATION) ? 'creation' : '';

$writer->xmlStartTag('didacticTemplate', ['type' => $type]);
$writer->xmlElement('title', [], $this->getTitle());
$writer->xmlElement('description', [], $this->getDescription());
Expand All @@ -489,8 +484,7 @@ public function toXml(ilXmlWriter $writer): ilXmlWriter
// info text with p-tags
if ($this->getInfo() !== '') {
$writer->xmlStartTag('info');

$info_lines = (array) explode("\n", $this->getInfo());
$info_lines = explode("\n", $this->getInfo());
foreach ($info_lines as $info) {
$trimmed_info = trim($info);
if ($trimmed_info !== '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ protected function initEditTemplate(ilDidacticTemplateSetting $set): ilPropertyF
}
}
$title->setInfo($this->lng->txt("language") . ": " . $language .
' <a href="' . $this->ctrl->getLinkTargetByClass("ilmultilingualismgui", "listTranslations") .
' <a href="' . $this->ctrl->getLinkTargetByClass(ilMultilingualismGUI::class, "listTranslations") .
'">&raquo; ' . $this->lng->txt("more_translations") . '</a>');
}
}
Expand Down Expand Up @@ -752,7 +752,7 @@ protected function setEditTabs(string $a_tab_active = "edit"): void
$this->tabs->addSubTab(
'settings_trans',
$this->lng->txt("obj_multilinguality"),
$this->ctrl->getLinkTargetByClass(["ilmultilingualismgui"], 'listTranslations')
$this->ctrl->getLinkTargetByClass(ilMultilingualismGUI::class, 'listTranslations')
);
$this->tabs->setTabActive('edit');
$this->tabs->setSubTabActive($a_tab_active);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@

class ilDidacticTemplateSettingsTableFilter
{
protected const FILTER_ID = 'otpl_templates_table';

protected const FILTER_NAME_ICON = 'icon';
protected const FILTER_NAME_TITLE = 'title';
protected const FILTER_NAME_TYPE = 'type';
protected const FILTER_NAME_SCOPE = 'scope';
protected const FILTER_NAME_ACTIVE = 'active';

protected const FILTER_ON = 1;
protected const FILTER_OFF = 2;
protected const FILTER_GLOBAL = 1;
protected const FILTER_LOCAL = 2;
protected const string FILTER_ID = 'otpl_templates_table';
protected const string FILTER_NAME_ICON = 'icon';
protected const string FILTER_NAME_TITLE = 'title';
protected const string FILTER_NAME_TYPE = 'type';
protected const string FILTER_NAME_SCOPE = 'scope';
protected const string FILTER_NAME_ACTIVE = 'active';
protected const int FILTER_ON = 1;
protected const int FILTER_OFF = 2;
protected const int FILTER_GLOBAL = 1;
protected const int FILTER_LOCAL = 2;

private array $input_activation_config = [
self::FILTER_NAME_ICON => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,8 @@ public function executeCommand(): void
{
$next_class = $this->ctrl->getNextClass($this);
$cmd = $this->ctrl->getCmd();

switch ($next_class) {
default:
if (!$cmd) {
$cmd = 'overview';
}
$this->$cmd();

break;
}
$cmd = !$cmd ? 'overview' : $cmd;
$this->$cmd();
}

public function appendToolbarSwitch(ilToolbarGUI $toolbar, string $a_obj_type, int $a_ref_id): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@
*/
class ilDidacticTemplateImport
{
protected const XML_ELEMENT_NAME_LOCAL_ROLE_ACTION = 'localRoleAction';
protected const XML_ELEMENT_NAME_BLOCK_ROLE_ACIONE = 'blockRoleAction';
protected const XML_ELEMENT_NAME_LOCAL_POLICY_ACTION = 'localPolicyAction';
public const IMPORT_FILE = 1;
protected const SCHEMA_TYPE = 'otpl';

protected const string XML_ELEMENT_NAME_LOCAL_ROLE_ACTION = 'localRoleAction';
protected const string XML_ELEMENT_NAME_BLOCK_ROLE_ACIONE = 'blockRoleAction';
protected const string XML_ELEMENT_NAME_LOCAL_POLICY_ACTION = 'localPolicyAction';
protected const string SCHEMA_TYPE = 'otpl';
public const int IMPORT_FILE = 1;
protected int $type = 0;
protected string $xmlfile = '';
protected ilLogger $logger;
Expand Down Expand Up @@ -71,13 +70,8 @@ public function getInputType(): int
*/
public function import(int $a_dtpl_id = 0): ilDidacticTemplateSetting
{
$root = null;
$use_internal_errors = libxml_use_internal_errors(true);
switch ($this->getInputType()) {
case self::IMPORT_FILE:
$root = simplexml_load_string(file_get_contents($this->getInputFile()));
break;
}
$root = ($this->getInputType() === self::IMPORT_FILE) ? simplexml_load_string(file_get_contents($this->getInputFile())) : null;
libxml_use_internal_errors($use_internal_errors);
if (!$root instanceof SimpleXMLElement) {
throw new ilDidacticTemplateImportException(
Expand Down Expand Up @@ -322,7 +316,6 @@ protected function parseActions(ilDidacticTemplateSetting $set, ?SimpleXMLElemen
}
if ($action->getName() === self::XML_ELEMENT_NAME_LOCAL_POLICY_ACTION) {
$this->parseLocalPolicyAction($set, $action);
continue;
}
}
}
Expand Down