-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
326 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,6 @@ | |
* | ||
*********************************************************************/ | ||
|
||
/** | ||
* Class ilDclBaseFieldModel | ||
* @author Michael Herren <[email protected]> | ||
* @author Martin Studer <[email protected]> | ||
* @author Marcel Raimann <[email protected]> | ||
* @author Fabian Schmid <[email protected]> | ||
* @author Oskar Truffer <[email protected]> | ||
* @ingroup ModulesDataCollection | ||
*/ | ||
class ilDclBaseFieldModel | ||
{ | ||
protected string $id = ""; | ||
|
@@ -716,11 +707,17 @@ public function checkFieldCreationInput(ilPropertyFormGUI $form): bool | |
return true; | ||
} | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
public function getStorageLocationOverride(): ?int | ||
{ | ||
return $this->storage_location_override; | ||
} | ||
|
||
/** | ||
* @deprecated override ilDclFieldTypePlugin::getStorageLocation() instead | ||
*/ | ||
public function setStorageLocationOverride(?int $storage_location_override): void | ||
{ | ||
$this->storage_location_override = $storage_location_override; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,6 @@ | |
* | ||
*********************************************************************/ | ||
|
||
/** | ||
* Class ilDclBaseFieldRepresentation | ||
* @author Michael Herren <[email protected]> | ||
* @version 1.0.0 | ||
*/ | ||
abstract class ilDclBaseFieldRepresentation | ||
{ | ||
protected ilDclBaseFieldModel $field; | ||
|
@@ -142,7 +137,7 @@ public function addFieldCreationForm( | |
): void { | ||
$opt = $this->buildFieldCreationInput($dcl, $mode); | ||
if ($opt !== null) { | ||
if ($mode != 'create' && $this->getField()->getDatatypeId() == ilDclDatatype::INPUTFORMAT_PLUGIN) { | ||
if ($mode != 'create' && ilDclFieldTypePlugin::isPluginDatatype($this->getField()->getDatatype()->getTitle())) { | ||
$new_plugin_title = $opt->getTitle(); | ||
$plugin_name = ilDclFieldFactory::getPluginNameFromFieldModel($this->getField()); | ||
if ($plugin_name !== "DclBase") { | ||
|
@@ -160,11 +155,15 @@ public function addFieldCreationForm( | |
*/ | ||
protected function buildFieldCreationInput(ilObjDataCollection $dcl, string $mode = 'create'): ?ilRadioOption | ||
{ | ||
$opt = new ilRadioOption( | ||
$this->lng->txt('dcl_' . $this->getField()->getDatatype()->getTitle()), | ||
$this->getField()->getDatatypeId() | ||
); | ||
$opt->setInfo($this->lng->txt('dcl_' . $this->getField()->getDatatype()->getTitle() . '_desc')); | ||
$title = $this->lng->txt('dcl_' . $this->getField()->getDatatype()->getTitle()); | ||
$info = $this->lng->txt('dcl_' . $this->getField()->getDatatype()->getTitle() . '_desc'); | ||
if (ilDclFieldTypePlugin::isPluginDatatype($this->field->getDatatype()->getTitle())) { | ||
$plugin = $this->component_factory->getPlugin(ilDclFieldTypePlugin::getPluginId($this->field->getDatatype()->getTitle())); | ||
$title = (!str_ends_with($plugin->txt('field_type_name'), 'field_type_name-')) ? $plugin->txt('field_type_name') : $plugin->getPluginName(); | ||
$info = (!str_ends_with($plugin->txt('field_type_info'), 'field_type_info-')) ? $plugin->txt('field_type_info') : ''; | ||
} | ||
$opt = new ilRadioOption($title, $this->getField()->getDatatypeId()); | ||
$opt->setInfo($info); | ||
|
||
return $opt; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
|
@@ -13,19 +14,8 @@ | |
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
******************************************************************** | ||
*/ | ||
*********************************************************************/ | ||
|
||
/** | ||
* Class ilDclDatatype | ||
* @author Martin Studer <[email protected]> | ||
* @author Marcel Raimann <[email protected]> | ||
* @author Fabian Schmid <[email protected]> | ||
* @author Oskar Truffer <[email protected]> | ||
* @author Stefan Wanzenried <[email protected]> | ||
* @version $Id: | ||
* @ingroup ModulesDataCollection | ||
*/ | ||
class ilDclDatatype | ||
{ | ||
public const INPUTFORMAT_NONE = 0; | ||
|
@@ -40,6 +30,7 @@ class ilDclDatatype | |
public const INPUTFORMAT_MOB = 9; | ||
public const INPUTFORMAT_REFERENCELIST = 10; | ||
public const INPUTFORMAT_FORMULA = 11; | ||
/** @deprecated */ | ||
public const INPUTFORMAT_PLUGIN = 12; | ||
public const INPUTFORMAT_TEXT_SELECTION = 14; | ||
public const INPUTFORMAT_DATE_SELECTION = 15; | ||
|
@@ -122,7 +113,7 @@ public function doRead(): void | |
/** | ||
* Get all possible Datatypes | ||
*/ | ||
public static function getAllDatatype(): array | ||
public static function getAllDatatype(bool $force = false): array | ||
{ | ||
global $DIC; | ||
$ilDB = $DIC['ilDB']; | ||
|
@@ -137,7 +128,14 @@ public static function getAllDatatype(): array | |
$instance = new ilDclDatatype(); | ||
$instance->loadDatatype($rec); | ||
|
||
self::$datatype_cache[$rec['id']] = $instance; | ||
if ( | ||
$force || | ||
!ilDclFieldTypePlugin::isPluginDatatype($instance->getTitle()) || | ||
$DIC['component.repository']->hasActivatedPlugin(ilDclFieldTypePlugin::getPluginId($instance->getTitle())) | ||
) { | ||
self::$datatype_cache[$rec['id']] = $instance; | ||
} | ||
|
||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
|
@@ -13,18 +14,8 @@ | |
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
******************************************************************** | ||
*/ | ||
*********************************************************************/ | ||
|
||
/** | ||
* Class ilDclFieldEditGUI | ||
* @author Martin Studer <[email protected]> | ||
* @author Marcel Raimann <[email protected]> | ||
* @author Fabian Schmid <[email protected]> | ||
* @author Oskar Truffer <[email protected]> | ||
* @version $Id: | ||
* @ingroup ModulesDataCollection | ||
*/ | ||
class ilDclFieldEditGUI | ||
{ | ||
protected int $obj_id; | ||
|
@@ -261,7 +252,7 @@ public function initForm(string $a_mode = "create"): void | |
$model = new ilDclBaseFieldModel(); | ||
$model->setDatatypeId($datatype->getId()); | ||
|
||
if ($a_mode == 'edit' && $datatype->getId() == $this->field_obj->getDatatypeId()) { | ||
if ($a_mode == 'edit' && $datatype->getId() === $this->field_obj->getDatatypeId()) { | ||
$model = $this->field_obj; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,6 @@ | |
* | ||
*********************************************************************/ | ||
|
||
/** | ||
* Class ilDclFieldFactory | ||
* This Class handles the creation of all field-classes | ||
* @author Michael Herren <[email protected]> | ||
* @version 1.0.0 | ||
*/ | ||
class ilDclFieldFactory | ||
{ | ||
public static string $field_base_path_patter = "./Modules/DataCollection/classes/Fields/%s/"; | ||
|
@@ -39,10 +33,8 @@ class ilDclFieldFactory | |
* @throws ilDclException | ||
* @throws Exception | ||
*/ | ||
public static function getRecordFieldInstance( | ||
object $field, //object|ilDclBaseFieldModel | ||
object $record //object|ilDclBaseRecordModel | ||
): ?ilDclBaseRecordFieldModel { | ||
public static function getRecordFieldInstance(object $field, object $record): ilDclBaseRecordFieldModel | ||
{ | ||
if (!empty(self::$record_field_cache[$field->getId()][$record->getId()])) { | ||
return self::$record_field_cache[$field->getId()][$record->getId()]; | ||
} | ||
|
@@ -66,7 +58,6 @@ public static function getRecordFieldInstance( | |
} | ||
|
||
throw new RuntimeException("file not found " . $path); | ||
return null; | ||
} | ||
|
||
protected static array $field_class_cache = array(); | ||
|
@@ -223,34 +214,23 @@ public static function getFieldModelInstanceByClass( | |
public static function getFieldTypeByInstance(ilDclBaseFieldModel $field): string | ||
{ | ||
global $DIC; | ||
$component_factory = $DIC["component.factory"]; | ||
$component_repository = $DIC["component.repository"]; | ||
$datatype = $field->getDatatype(); | ||
|
||
if (!empty(self::$field_type_cache[$datatype->getId()])) { | ||
if ($datatype->getId() == ilDclDatatype::INPUTFORMAT_PLUGIN) { | ||
if (!empty(self::$field_type_cache[$datatype->getId()][$field->getId()])) { | ||
return self::$field_type_cache[$datatype->getId()][$field->getId()]; | ||
} | ||
} else { | ||
return self::$field_type_cache[$datatype->getId()]; | ||
} | ||
return self::$field_type_cache[$datatype->getId()]; | ||
} | ||
|
||
if ($datatype->getId() == ilDclDatatype::INPUTFORMAT_PLUGIN) { | ||
if ($field->hasProperty(ilDclBaseFieldModel::PROP_PLUGIN_HOOK_NAME)) { | ||
$pd = $component_repository->getPluginByName($field->getProperty(ilDclBaseFieldModel::PROP_PLUGIN_HOOK_NAME)); | ||
$plugin_data = $component_factory->getPlugin($pd->getId()); | ||
$fieldtype = $plugin_data->getPluginClassPrefix() . ucfirst($plugin_data->getPluginName()); | ||
if (ilDclFieldTypePlugin::isPluginDatatype($datatype->getTitle())) { | ||
$plugin_id = ilDclFieldTypePlugin::getPluginId($datatype->getTitle()); | ||
if ($DIC["component.repository"]->hasActivatedPlugin($plugin_id)) { | ||
$fieldtype = 'il' . $DIC["component.repository"]->getPluginById($plugin_id)->getName(); | ||
} else { | ||
$fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle())); | ||
$fieldtype = ''; | ||
} | ||
self::$field_type_cache[$datatype->getId()][$field->getId()] = $fieldtype; | ||
} else { | ||
$fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle())); | ||
self::$field_type_cache[$datatype->getId()] = $fieldtype; | ||
} | ||
|
||
self::$field_type_cache[$datatype->getId()] = $fieldtype; | ||
return $fieldtype; | ||
} | ||
|
||
|
@@ -269,33 +249,18 @@ public static function getClassByInstance(ilDclBaseFieldModel $field, string $cl | |
public static function getClassPathByInstance(ilDclBaseFieldModel $field, string $class_pattern): string | ||
{ | ||
global $DIC; | ||
$component_factory = $DIC["component.factory"]; | ||
$component_repository = $DIC["component.repository"]; | ||
$datatype = $field->getDatatype(); | ||
|
||
if ($field->getId() != null && !empty(self::$class_path_cache[$field->getId()][$class_pattern])) { | ||
return self::$class_path_cache[$field->getId()][$class_pattern]; | ||
} | ||
|
||
if ($datatype->getId() == ilDclDatatype::INPUTFORMAT_PLUGIN) { | ||
if ($field->hasProperty(ilDclBaseFieldModel::PROP_PLUGIN_HOOK_NAME)) { | ||
if (!$component_repository->getPluginSlotById(ilDclFieldTypePlugin::SLOT_ID)->hasPluginName($field->getProperty(ilDclBaseFieldModel::PROP_PLUGIN_HOOK_NAME))) { | ||
throw new ilDclException( | ||
"Something went wrong by initializing the FieldHook-Plugin '" | ||
. $field->getProperty(ilDclBaseFieldModel::PROP_PLUGIN_HOOK_NAME) . "' on Component '" | ||
. ilDclFieldTypePlugin::COMPONENT_NAME . "' with slot '" . ilDclFieldTypePlugin::SLOT_ID . "' on field: " | ||
. $field->getTitle() | ||
); | ||
} | ||
$pd = $component_repository->getPluginByName($field->getProperty(ilDclBaseFieldModel::PROP_PLUGIN_HOOK_NAME)); | ||
$plugin_data = $component_factory->getPlugin($pd->getId()); | ||
|
||
$class_path = $plugin_data->getDirectory() . "/classes/"; | ||
if (ilDclFieldTypePlugin::isPluginDatatype($datatype->getTitle())) { | ||
$plugin_id = ilDclFieldTypePlugin::getPluginId($datatype->getTitle()); | ||
if ($DIC["component.repository"]->hasActivatedPlugin($plugin_id)) { | ||
$class_path = $DIC["component.repository"]->getPluginById($plugin_id)->getPath() . '/classes/'; | ||
} else { | ||
$class_path = sprintf( | ||
self::$field_base_path_patter, | ||
ucfirst(self::parseDatatypeTitle($datatype->getTitle())) | ||
); | ||
return ''; | ||
} | ||
} else { | ||
$class_path = sprintf( | ||
|
Oops, something went wrong.