58 if (!empty(self::$record_field_cache[$field->
getId()][$record->
getId()])) {
59 return self::$record_field_cache[$field->
getId()][$record->
getId()];
62 $path = self::getClassPathByInstance($field, self::$record_field_class_patter);
63 if (file_exists(
$path)) {
65 $class = self::getClassByInstance($field, self::$record_field_class_patter);
66 $instance =
new $class($record, $field);
68 if (!$instance->getFieldRepresentation()) {
69 $instance->setFieldRepresentation(self::getFieldRepresentationInstance($field));
72 if (!$instance->getRecordRepresentation()) {
73 $instance->setRecordRepresentation(self::getRecordRepresentationInstance($instance));
75 self::$record_field_cache[$field->
getId()][$record->
getId()] = $instance;
99 if (!empty(self::$field_class_cache[$datatype . $class_pattern])) {
100 return self::$field_class_cache[$datatype . $class_pattern];
103 $fieldtype = $datatype;
105 $class = sprintf($class_pattern, $fieldtype);
106 self::$field_class_cache[$datatype . $class_pattern] = $class;
122 return "class." . self::getFieldClass($datatype, $class_pattern) .
".php";
143 if ($field->
getId() != null && !empty(self::$field_representation_cache[$field->
getId()])) {
144 return self::$field_representation_cache[$field->
getId()];
147 $class_path = self::getClassPathByInstance($field, self::$field_representation_class_pattern);
150 if (file_exists($class_path)) {
151 require_once($class_path);
152 $class = self::getClassByInstance($field, self::$field_representation_class_pattern);
153 $instance =
new $class($field);
155 throw new ilDclException(
"Path for FieldRepresentation with file " . $class_path .
" does not exists!");
158 if ($instance == null) {
159 throw new ilDclException(
"Could not create FieldRepresentation of " . $class .
" with file " . $class_path);
162 if ($field->
getId() != null) {
163 self::$field_representation_cache[$field->
getId()] = $instance;
187 if ($record_field->
getId() != null && !empty(self::$record_representation_cache[$record_field->
getId()])) {
188 return self::$record_representation_cache[$record_field->
getId()];
191 $class_path = self::getClassPathByInstance($record_field->
getField(), self::$record_representation_class_pattern);
194 if (file_exists($class_path)) {
195 require_once($class_path);
196 $class = self::getClassByInstance($record_field->
getField(), self::$record_representation_class_pattern);
198 $class = self::getFieldClass(self::$default_prefix .
"Base", self::$record_representation_class_pattern);
201 $instance =
new $class($record_field);
203 if ($instance == null) {
204 throw new ilDclException(
"Could not create RecordRepresentation of " . $class_path .
" " . $record_field->
getField()->getDatatype()->getTitle());
207 if ($record_field->
getId() != null) {
208 self::$record_representation_cache[$record_field->
getId()] = $instance;
227 if ($datatype != null) {
228 $base->setDatatypeId($datatype);
231 $ilDclBaseFieldModel = self::getFieldModelInstanceByClass(
$base, $field_id);
233 return $ilDclBaseFieldModel;
255 if ($field->
getId() != null && !empty(self::$field_model_cache[$field->
getId()])) {
256 return self::$field_model_cache[$field->
getId()];
259 $path_type = self::getClassPathByInstance($field, self::$field_class_patter);
261 if (file_exists($path_type)) {
262 require_once($path_type);
263 $class = self::getClassByInstance($field, self::$field_class_patter);
265 $class = self::getFieldClass(self::$default_prefix .
"Base", self::$field_class_patter);
269 $instance =
new $class($field_id);
271 $instance =
new $class();
274 if ($instance == null) {
275 throw new ilDclException(
"Could not create FieldModel of " . $class);
278 if ($field->
getId() != null) {
279 self::$field_model_cache[$field->
getId()] = $instance;
302 if (!empty(self::$field_type_cache[$datatype->getId()])) {
304 if (!empty(self::$field_type_cache[$datatype->getId()][$field->
getId()])) {
305 return self::$field_type_cache[$datatype->getId()][$field->
getId()];
308 return self::$field_type_cache[$datatype->getId()];
315 $fieldtype = $plugin_data->getPluginClassPrefix() . ucfirst($plugin_data->getPluginName());
317 $fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle()));
319 self::$field_type_cache[$datatype->getId()][$field->
getId()] = $fieldtype;
321 $fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle()));
322 self::$field_type_cache[$datatype->getId()] = $fieldtype;
337 $fieldtype = self::getFieldTypeByInstance($field);
339 return self::getFieldClass($fieldtype, $class_pattern);
360 if ($field->
getId() != null && !empty(self::$class_path_cache[$field->
getId()][$class_pattern])) {
361 return self::$class_path_cache[$field->
getId()][$class_pattern];
367 if ($plugin_data == null) {
368 throw new ilDclException(
"Something went wrong by initializing the FieldHook-Plugin '" 374 $class_path = $plugin_data->getDirectory() .
"/classes/";
376 $class_path = sprintf(self::$field_base_path_patter, ucfirst(self::parseDatatypeTitle($datatype->getTitle())));
379 $class_path = sprintf(self::$field_base_path_patter, ucfirst(self::parseDatatypeTitle($datatype->getTitle())));
382 $return = $class_path . self::getFieldClassFile(self::getFieldTypeByInstance($field), $class_pattern);
384 if ($field->
getId() != null) {
385 self::$class_path_cache[$field->
getId()][$class_pattern] = $return;
402 $parts = explode(
"_",
$title);
403 $func =
function ($value) {
404 return ucfirst($value);
407 $parts = array_map($func, $parts);
408 $title = implode(
"", $parts);
436 $class_name = get_class($object);
437 $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.