2 require_once(
'./Modules/DataCollection/classes/Fields/Base/class.ilDclBaseRecordRepresentation.php');
3 require_once(
'./Modules/DataCollection/classes/Fields/Base/class.ilDclBaseFieldModel.php');
4 require_once(
'./Modules/DataCollection/classes/Fields/Plugin/class.ilDclFieldTypePlugin.php');
5 require_once(
'./Modules/DataCollection/exceptions/class.ilDclException.php');
60 if (!empty(self::$record_field_cache[$field->
getId()][$record->
getId()])) {
61 return self::$record_field_cache[$field->
getId()][$record->
getId()];
64 $path = self::getClassPathByInstance($field, self::$record_field_class_patter);
65 if (file_exists(
$path)) {
67 $class = self::getClassByInstance($field, self::$record_field_class_patter);
68 $instance =
new $class($record, $field);
70 if (!$instance->getFieldRepresentation()) {
71 $instance->setFieldRepresentation(self::getFieldRepresentationInstance($field));
74 if (!$instance->getRecordRepresentation()) {
75 $instance->setRecordRepresentation(self::getRecordRepresentationInstance($instance));
77 self::$record_field_cache[$field->
getId()][$record->
getId()] = $instance;
100 if (!empty(self::$field_class_cache[$datatype . $class_pattern])) {
101 return self::$field_class_cache[$datatype . $class_pattern];
104 $fieldtype = $datatype;
106 $class = sprintf($class_pattern, $fieldtype);
107 self::$field_class_cache[$datatype . $class_pattern] = $class;
122 return "class." . self::getFieldClass($datatype, $class_pattern) .
".php";
142 if ($field->
getId() != null && !empty(self::$field_representation_cache[$field->
getId()])) {
143 return self::$field_representation_cache[$field->
getId()];
146 $class_path = self::getClassPathByInstance($field, self::$field_representation_class_pattern);
149 if (file_exists($class_path)) {
150 require_once($class_path);
151 $class = self::getClassByInstance($field, self::$field_representation_class_pattern);
152 $instance =
new $class($field);
154 throw new ilDclException(
"Path for FieldRepresentation with file " . $class_path .
" does not exists!");
157 if ($instance == null) {
158 throw new ilDclException(
"Could not create FieldRepresentation of " . $class .
" with file " . $class_path);
161 if($field->
getId() != null) {
162 self::$field_representation_cache[$field->
getId()] = $instance;
185 if ($record_field->
getId() != null && !empty(self::$record_representation_cache[$record_field->
getId()])) {
186 return self::$record_representation_cache[$record_field->
getId()];
189 $class_path = self::getClassPathByInstance($record_field->
getField(), self::$record_representation_class_pattern);
192 if (file_exists($class_path)) {
193 require_once($class_path);
194 $class = self::getClassByInstance($record_field->
getField(), self::$record_representation_class_pattern);
196 $class = self::getFieldClass(self::$default_prefix .
"Base", self::$record_representation_class_pattern);
199 $instance =
new $class($record_field);
201 if ($instance == null) {
202 throw new ilDclException(
"Could not create RecordRepresentation of " . $class_path .
" " . $record_field->
getField()->getDatatype()->getTitle());
205 if($record_field->
getId() != null) {
206 self::$record_representation_cache[$record_field->
getId()] = $instance;
224 if ($datatype != null) {
225 $base->setDatatypeId($datatype);
228 $ilDclBaseFieldModel = self::getFieldModelInstanceByClass($base, $field_id);
230 return $ilDclBaseFieldModel;
251 if ($field->
getId() != null && !empty(self::$field_model_cache[$field->
getId()])) {
252 return self::$field_model_cache[$field->
getId()];
255 $path_type = self::getClassPathByInstance($field, self::$field_class_patter);
257 if (file_exists($path_type)) {
258 require_once($path_type);
259 $class = self::getClassByInstance($field, self::$field_class_patter);
261 $class = self::getFieldClass(self::$default_prefix .
"Base", self::$field_class_patter);
265 $instance =
new $class($field_id);
267 $instance =
new $class();
270 if ($instance == null) {
271 throw new ilDclException(
"Could not create FieldModel of " . $class);
274 if($field->
getId() != null) {
275 self::$field_model_cache[$field->
getId()] = $instance;
297 if (!empty(self::$field_type_cache[$datatype->getId()])) {
299 if(!empty(self::$field_type_cache[$datatype->getId()][$field->
getId()])) {
300 return self::$field_type_cache[$datatype->getId()][$field->
getId()];
303 return self::$field_type_cache[$datatype->getId()];
310 $fieldtype = $plugin_data->getPluginClassPrefix() . ucfirst($plugin_data->getPluginName());
312 $fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle()));
314 self::$field_type_cache[$datatype->getId()][$field->
getId()] = $fieldtype;
316 $fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle()));
317 self::$field_type_cache[$datatype->getId()] = $fieldtype;
331 $fieldtype = self::getFieldTypeByInstance($field);
333 return self::getFieldClass($fieldtype, $class_pattern);
353 if ($field->
getId() != null && !empty(self::$class_path_cache[$field->
getId()][$class_pattern])) {
354 return self::$class_path_cache[$field->
getId()][$class_pattern];
360 if ($plugin_data == null) {
361 throw new ilDclException(
"Something went wrong by initializing the FieldHook-Plugin '" 367 $class_path = $plugin_data->getDirectory() .
"/classes/";
369 $class_path = sprintf(self::$field_base_path_patter, ucfirst(self::parseDatatypeTitle($datatype->getTitle())));
372 $class_path = sprintf(self::$field_base_path_patter, ucfirst(self::parseDatatypeTitle($datatype->getTitle())));
375 $return = $class_path . self::getFieldClassFile(self::getFieldTypeByInstance($field), $class_pattern);
377 if($field->
getId() != null) {
378 self::$class_path_cache[$field->
getId()][$class_pattern] = $return;
394 $parts = explode(
"_",
$title);
395 $func =
function ($value) {
396 return ucfirst($value);
399 $parts = array_map($func, $parts);
400 $title = implode(
"", $parts);
426 $class_name = get_class($object);
427 $class_name = substr($class_name, 2, - (strlen(self::$field_class_patter) - 2));
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
Class ilDclBaseFieldModel.
static $field_representation_cache
static $field_class_patter
Class ilDclBaseFieldModel.
static $record_field_class_patter
static getFieldTypeByInstance(ilDclBaseFieldModel $field)
static $field_class_cache
static $field_model_cache
static getFieldRepresentationInstance(ilDclBaseFieldModel $field)
Returns FieldRepresentation from BaseFieldModel.
static $record_class_patter
static $record_representation_cache
static $record_representation_class_pattern
static parseDatatypeTitle($title)
Parse string to FieldClass format Replaces _ with camelcase-notation.
const PROP_PLUGIN_HOOK_NAME
static $field_representation_class_pattern
static getRecordFieldInstance(ilDclBaseFieldModel $field, ilDclBaseRecordModel $record)
Creates a RecordField instance and loads the field and record representation.
static getFieldClass($datatype, $class_pattern)
Concatenates Classname from datatype and pattern.
static getClassByInstance(ilDclBaseFieldModel $field, $class_pattern)
static getFieldModelInstance($field_id, $datatype=null)
Get FieldModel from field-id and datatype.
hasProperty($key)
Checks if a certain property for a field is set.
static $record_field_cache
static getFieldClassFile($datatype, $class_pattern)
Get Filename from datatype and pattern.
Create styles array
The data for the language used.
Class ilDclFieldFactory This Class handles the creation of all field-classes.
static getRecordRepresentationInstance(ilDclBaseRecordFieldModel $record_field)
Get RecordRepresentation from RecordFieldModel.
static $field_base_path_patter
static getFieldModelInstanceByClass(ilDclBaseFieldModel $field, $field_id=null)
Gets the correct instance of a fieldModel class Checks if a field is a plugin a replaces the fieldMod...
Class ilDclBaseRecordModel.
getProperty($key)
Returns a certain property of a field.
static getClassPathByInstance(ilDclBaseFieldModel $field, $class_pattern)
static getPluginNameFromFieldModel(ilDclBaseFieldModel $object)
Get plugin-name from FieldModel.
static getRecordModelInstance($record_id)
Creates a RecordModel instance.