ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAdvancedMDFieldDefinition Class Reference

AMD field abstract base class. More...

+ Inheritance diagram for ilAdvancedMDFieldDefinition:
+ Collaboration diagram for ilAdvancedMDFieldDefinition:

Public Member Functions

 __construct (?int $a_field_id=null, string $language='')
 
 getType ()
 Get type. More...
 
 useDefaultLanguageMode (string $language)
 Check if default language mode has to be used: no language given or language equals default language. More...
 
 getTypeTitle ()
 
 getADTDefinition ()
 Get ADT definition instance. More...
 
 getADT ()
 
 getFieldId ()
 Get field_id. More...
 
 setRecordId (int $a_id)
 Set record id. More...
 
 getRecordId ()
 Get record id. More...
 
 setImportId (string $a_id_string)
 Set import id. More...
 
 getImportId ()
 Get import id. More...
 
 setPosition (int $a_pos)
 Set position. More...
 
 getPosition ()
 Get position. More...
 
 setTitle (string $a_title)
 Get title. More...
 
 getTitle ()
 Get title. More...
 
 setDescription (string $a_desc)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 isSearchSupported ()
 Is search supported at all. More...
 
 isFilterSupported ()
 Is search by filter supported. More...
 
 setSearchable (bool $a_status)
 Toggle searchable. More...
 
 isSearchable ()
 Is searchable. More...
 
 setRequired (bool $a_status)
 Toggle required. More...
 
 isRequired ()
 Is required field. More...
 
 getFieldDefinitionForTableGUI (string $content_language)
 Parse properties for table gui. More...
 
 addToFieldDefinitionForm (ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions, string $language='')
 Add input elements to definition form. More...
 
 importCustomDefinitionFormPostValues (ilPropertyFormGUI $a_form, string $language='')
 Import custom post values from definition form. More...
 
 importDefinitionFormPostValues (ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions, string $active_language)
 Import post values from definition form. More...
 
 importDefinitionFormPostValuesNeedsConfirmation ()
 
 prepareCustomDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 
 prepareDefinitionFormConfirmation (ilPropertyFormGUI $a_form)
 
 generateImportId (int $a_field_id)
 Generate unique record id. More...
 
 save (bool $a_keep_pos=false)
 Create new field entry. More...
 
 update ()
 Update field entry. More...
 
 delete ()
 Delete field entry. More...
 
 toXML (ilXmlWriter $a_writer)
 To Xml. More...
 
 importXMLProperty (string $a_key, string $a_value)
 Import property from XML. More...
 
 getValueForXML (ilADT $element)
 Parse ADT value for xml (export) More...
 
 importValueFromXML (string $a_cdata)
 Import value from xml. More...
 
 importFromECS (string $a_ecs_type, $a_value, string $a_sub_id)
 Import meta data from ECS. More...
 
 prepareElementForEditor (ilADTFormBridge $a_bridge)
 Prepare editor form elements. More...
 
 getSearchQueryParserValue (ilADTSearchBridge $a_adt_search)
 Get value for search query parser. More...
 
 getSearchValueSerialized (ilADTSearchBridge $a_adt_search)
 
 setSearchValueSerialized (ilADTSearchBridge $a_adt_search, $a_value)
 Set value from search persistence. More...
 
 searchSubObjects (ilADTSearchBridge $a_adt_search, int $a_obj_id, string $sub_obj_type)
 
 searchObjects (ilADTSearchBridge $a_adt_search, ilQueryParser $a_parser, array $a_object_types, string $a_locate, string $a_search_type)
 Search objects. More...
 
 getLuceneSearchString ($a_value)
 Get search string in lucene syntax. More...
 
 prepareElementForSearch (ilADTSearchBridge $a_bridge)
 Prepare search form elements. More...
 
 _clone (int $a_new_record_id)
 Clone field definition. More...
 
 hasComplexOptions ()
 
 getComplexOptionsOverview (object $a_parent_gui, string $parent_cmd)
 

Static Public Member Functions

static getInstance (?int $a_field_id, ?int $a_type=null, string $language='')
 
static exists (int $a_field_id)
 
static getInstanceByTypeString (string $a_type)
 Get instance by type string (used by import) More...
 
static getInstancesByRecordId ( $a_record_id, $a_only_searchable=false, string $language='')
 Get definitions by record id. More...
 
static getInstancesByObjType ($a_obj_type, $a_active_only=true)
 
static getInstanceByImportId (string $a_import_id)
 
static getSearchableDefinitionIds ()
 Get searchable definition ids (performance is key) More...
 
static getADTGroupForDefinitions (array $a_defs)
 Init ADTGroup for definitions. More...
 
static getValidTypes ()
 Get all valid types. More...
 
static isValidType (int $a_type)
 

Data Fields

const TYPE_SELECT = 1
 
const TYPE_TEXT = 2
 
const TYPE_DATE = 3
 
const TYPE_DATETIME = 4
 
const TYPE_INTEGER = 5
 
const TYPE_FLOAT = 6
 
const TYPE_LOCATION = 7
 
const TYPE_SELECT_MULTI = 8
 
const TYPE_ADDRESS = 99
 
const TYPE_EXTERNAL_LINK = 9
 
const TYPE_INTERNAL_LINK = 10
 

Protected Member Functions

 init ()
 
 initADTDefinition ()
 Init adt instance. More...
 
 setADT (ilADT $a_adt)
 Set ADT instance. More...
 
 setFieldId (int $a_id)
 Set field_id. More...
 
 importFieldDefinition (array $a_def)
 Import (type-specific) field definition from DB. More...
 
 getFieldDefinition ()
 Get (type-specific) field definition. More...
 
 addCustomFieldToDefinitionForm (ilPropertyFormGUI $a_form, bool $a_disabled=false, string $language='')
 Add custom input elements to definition form. More...
 
 getLastPosition ()
 Get last position of record. More...
 
 getDBProperties ()
 Get all definition properties for DB. More...
 
 import (array $a_data)
 Import from DB. More...
 
 read (?int $a_field_id)
 Read field definition. More...
 
 addPropertiesToXML (ilXmlWriter $a_writer)
 Add (type-specific) properties to xml export. More...
 
 parseSearchObjects (array $a_records, array $a_object_types)
 Add object-data needed for global search to AMD search results. More...
 

Static Protected Member Functions

static getTypeString (int $a_type)
 Get type as string. More...
 

Protected Attributes

int $field_id = null
 
int $record_id = 0
 
string $import_id = ''
 
int $position = 0
 
string $title = ''
 
string $description = ''
 
bool $searchable = false
 
bool $required = false
 
ilADTDefinition $adt_def = null
 
ilADT $adt = null
 
string $language = ''
 
ilDBInterface $db
 
ilLanguage $lng
 
ilLogger $logger
 
GlobalHttpState $http
 
RefineryFactory $refinery
 

Detailed Description

AMD field abstract base class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 30 of file class.ilAdvancedMDFieldDefinition.php.

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDFieldDefinition::__construct ( ?int  $a_field_id = null,
string  $language = '' 
)

PhpUndefinedMethodInspection

Definition at line 63 of file class.ilAdvancedMDFieldDefinition.php.

References $DIC, $language, ILIAS\FileDelivery\http(), init(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), read(), and ILIAS\Repository\refinery().

64  {
65  global $DIC;
66 
67  $this->lng = $DIC->language();
68  $this->language = $DIC->language()->getLangKey();
69  $this->refinery = $DIC->refinery();
70  $this->http = $DIC->http();
71 
72 
73  if ($language) {
74  $this->language = $language;
75  }
77  $this->logger = $DIC->logger()->amet();
78  $this->db = $DIC->database();
79 
80  $this->init();
81  $this->read($a_field_id);
82  }
read(?int $a_field_id)
Read field definition.
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

Member Function Documentation

◆ _clone()

ilAdvancedMDFieldDefinition::_clone ( int  $a_new_record_id)

Clone field definition.

Definition at line 1095 of file class.ilAdvancedMDFieldDefinition.php.

References getDescription(), getFieldDefinition(), getPosition(), getTitle(), isRequired(), and isSearchable().

Referenced by ilAdvancedMDFieldDefinitionSelect\import().

1095  : self
1096  {
1097  $class = get_class($this);
1098  $obj = new $class();
1099  $obj->setRecordId($a_new_record_id);
1100  $obj->setTitle($this->getTitle());
1101  $obj->setDescription($this->getDescription());
1102  $obj->setRequired($this->isRequired());
1103  $obj->setPosition($this->getPosition());
1104  $obj->setSearchable($this->isSearchable());
1105  $obj->importFieldDefinition($this->getFieldDefinition());
1106  $obj->save(true);
1107 
1108  return $obj;
1109  }
getFieldDefinition()
Get (type-specific) field definition.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addCustomFieldToDefinitionForm()

ilAdvancedMDFieldDefinition::addCustomFieldToDefinitionForm ( ilPropertyFormGUI  $a_form,
bool  $a_disabled = false,
string  $language = '' 
)
protected

Add custom input elements to definition form.

Definition at line 570 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by addToFieldDefinitionForm().

574  : void {
575  }
+ Here is the caller graph for this function:

◆ addPropertiesToXML()

ilAdvancedMDFieldDefinition::addPropertiesToXML ( ilXmlWriter  $a_writer)
protected

Add (type-specific) properties to xml export.

Definition at line 928 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by toXML().

928  : void
929  {
930  // type-specific properties
931  }
+ Here is the caller graph for this function:

◆ addToFieldDefinitionForm()

ilAdvancedMDFieldDefinition::addToFieldDefinitionForm ( ilPropertyFormGUI  $a_form,
ilAdvancedMDPermissionHelper  $a_permissions,
string  $language = '' 
)

Add input elements to definition form.

Definition at line 580 of file class.ilAdvancedMDFieldDefinition.php.

References $check, $DIC, ilAdvancedMDPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, addCustomFieldToDefinitionForm(), ilPropertyFormGUI\addItem(), ilAdvancedMDPermissionHelper\CONTEXT_FIELD, getDescription(), getFieldId(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), getRecordId(), getTitle(), ilClaimingPermissionHelper\hasPermissions(), isSearchable(), isSearchSupported(), ilTextAreaInputGUI\setValue(), ilAdvancedMDPermissionHelper\SUBACTION_FIELD_DESCRIPTION, ilAdvancedMDPermissionHelper\SUBACTION_FIELD_PROPERTIES, ilAdvancedMDPermissionHelper\SUBACTION_FIELD_SEARCHABLE, ilAdvancedMDPermissionHelper\SUBACTION_FIELD_TITLE, and ilLanguage\txt().

Referenced by ilAdvancedMDSettingsGUI\initFieldForm().

584  : void {
585  global $DIC;
586  $lng = $DIC['lng'];
587 
588  $perm = $a_permissions->hasPermissions(
590  (string) $this->getFieldId(),
591  array(
594  )
595  ,
598  )
599  ,
602  )
603  ,
606  )
607  )
608  );
609 
610  // title
612 
613  $title = new ilTextInputGUI($lng->txt('title'), 'title');
614  $title->setValue($this->getTitle());
615  $title->setSize(20);
616  $title->setMaxLength(70);
617  $title->setRequired(true);
618  if ($this->getFieldId()) {
619  $translations->modifyTranslationInfoForTitle($this->getFieldId(), $a_form, $title, $language);
620  } else {
621  $title->setValue($this->getTitle());
622  }
623 
624  $a_form->addItem($title);
625 
627  $title->setDisabled(true);
628  }
629 
630  // desc
631  $desc = new ilTextAreaInputGUI($lng->txt('description'), 'description');
632  $desc->setValue($this->getDescription());
633  $desc->setRows(3);
634  $desc->setCols(50);
635  if ($this->getFieldId()) {
636  $translations->modifyTranslationInfoForDescription($this->getFieldId(), $a_form, $desc, $language);
637  } else {
638  $desc->setValue($this->getDescription());
639  }
640 
641  $a_form->addItem($desc);
642 
644  $desc->setDisabled(true);
645  }
646 
647  // searchable
648  $check = new ilCheckboxInputGUI($lng->txt('md_adv_searchable'), 'searchable');
649  $check->setChecked($this->isSearchable());
650  $check->setValue("1");
651  $a_form->addItem($check);
652 
654  !$this->isSearchSupported()) {
655  $check->setDisabled(true);
656  }
657 
658  /* required
659  $check = new ilCheckboxInputGUI($lng->txt('md_adv_required'), 'required');
660  $check->setChecked($this->isRequired());
661  $check->setValue(1);
662  $a_form->addItem($check);
663  */
664 
666  $a_form,
668  $language
669  );
670  }
addCustomFieldToDefinitionForm(ilPropertyFormGUI $a_form, bool $a_disabled=false, string $language='')
Add custom input elements to definition form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This class represents a checkbox property in a property form.
hasPermissions(int $a_context_type, string $a_context_id, array $a_action_ids)
Check permissions.
global $DIC
Definition: feed.php:28
This class represents a text area property in a property form.
$check
Definition: buildRTE.php:81
isSearchSupported()
Is search supported at all.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilAdvancedMDFieldDefinition::delete ( )

Delete field entry.

Definition at line 871 of file class.ilAdvancedMDFieldDefinition.php.

References $query, ilAdvancedMDValues\_deleteByFieldId(), getADT(), and getFieldId().

871  : void
872  {
873  if (!$this->getFieldId()) {
874  return;
875  }
876 
877  // delete all values
879 
880  $query = "DELETE FROM adv_mdf_definition" .
881  " WHERE field_id = " . $this->db->quote($this->getFieldId(), "integer");
882  $this->db->manipulate($query);
883  }
static _deleteByFieldId(int $a_field_id, ilADT $a_adt)
Delete values by field_id.
$query
+ Here is the call graph for this function:

◆ exists()

static ilAdvancedMDFieldDefinition::exists ( int  $a_field_id)
static

Definition at line 108 of file class.ilAdvancedMDFieldDefinition.php.

References $DIC, ilDBInterface\fetchAssoc(), ilDBInterface\query(), and ilDBInterface\quote().

Referenced by ilContainerFilterFieldData\getFilterSetForRefId().

108  : bool
109  {
110  global $DIC;
111 
112  $db = $DIC['ilDB'];
113  $set = $db->query("SELECT field_type" .
114  " FROM adv_mdf_definition" .
115  " WHERE field_id = " . $db->quote($a_field_id, "integer"));
116  if ($db->fetchAssoc($set)) {
117  return true;
118  }
119  return false;
120  }
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
global $DIC
Definition: feed.php:28
query(string $query)
Run a (read-only) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateImportId()

ilAdvancedMDFieldDefinition::generateImportId ( int  $a_field_id)

Generate unique record id.

Definition at line 754 of file class.ilAdvancedMDFieldDefinition.php.

References IL_INST_ID.

Referenced by save(), and toXML().

754  : string
755  {
756  return 'il_' . IL_INST_ID . '_adv_md_field_' . $a_field_id;
757  }
const IL_INST_ID
Definition: constants.php:40
+ Here is the caller graph for this function:

◆ getADT()

ilAdvancedMDFieldDefinition::getADT ( )

Definition at line 368 of file class.ilAdvancedMDFieldDefinition.php.

References $adt, getADTDefinition(), and ilADTFactory\getInstance().

Referenced by delete(), ilAdvancedMDFieldDefinitionDate\importFromECS(), ilAdvancedMDFieldDefinitionDateTime\importFromECS(), ilAdvancedMDFieldDefinitionText\importFromECS(), ilAdvancedMDFieldDefinitionExternalLink\importValueFromXML(), ilAdvancedMDFieldDefinitionInternalLink\importValueFromXML(), ilAdvancedMDFieldDefinitionLocation\importValueFromXML(), ilAdvancedMDFieldDefinitionDate\importValueFromXML(), ilAdvancedMDFieldDefinitionDateTime\importValueFromXML(), ilAdvancedMDFieldDefinitionSelectMulti\importValueFromXML(), ilAdvancedMDFieldDefinitionGroupBased\importValueFromXML(), ilAdvancedMDFieldDefinitionText\importValueFromXML(), ilAdvancedMDFieldDefinitionInteger\importValueFromXML(), ilAdvancedMDFieldDefinitionSelect\importValueFromXML(), ilAdvancedMDFieldDefinitionInternalLink\searchObjects(), ilAdvancedMDFieldDefinitionText\searchObjects(), searchObjects(), and searchSubObjects().

368  : ilADT
369  {
370  if (!$this->adt instanceof ilADT) {
371  $this->adt = ilADTFactory::getInstance()->getInstanceByDefinition($this->getADTDefinition());
372  }
373  return $this->adt;
374  }
getADTDefinition()
Get ADT definition instance.
ADT base class.
Definition: class.ilADT.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getADTDefinition()

ilAdvancedMDFieldDefinition::getADTDefinition ( )

Get ADT definition instance.

Returns
ilADTDefinition

Definition at line 360 of file class.ilAdvancedMDFieldDefinition.php.

References $adt_def, and initADTDefinition().

Referenced by getADT(), ilAdvancedMDFieldDefinitionText\getADTGroup(), ilAdvancedMDFieldDefinitionSelect\importNewSelectOptions(), and ilAdvancedMDFieldDefinitionSelect\update().

361  {
362  if (!$this->adt_def instanceof ilADTDefinition) {
363  $this->adt_def = $this->initADTDefinition();
364  }
365  return $this->adt_def;
366  }
initADTDefinition()
Init adt instance.
ADT definition base class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getADTGroupForDefinitions()

static ilAdvancedMDFieldDefinition::getADTGroupForDefinitions ( array  $a_defs)
static

Init ADTGroup for definitions.

Parameters
array<int,ilADTDefinition>
Returns
ilADTGroup
Todo:
check return type array<string, ilADTDefinition> or array<string, ilADTDefinition>

Definition at line 254 of file class.ilAdvancedMDFieldDefinition.php.

References $factory, and ilADTFactory\getInstance().

Referenced by ilAdvancedMDValues\getADTGroup(), and ilAdvancedMDValues\queryForRecords().

254  : ilADT
255  {
257  $group_def = $factory->getDefinitionInstanceByType("Group");
258  foreach ($a_defs as $def) {
259  $group_def->addElement($def->getFieldId(), $def->getADTDefinition());
260  }
261  $group = $factory->getInstanceByDefinition($group_def);
262 
263  // bind adt instances to definition
264  foreach ($group->getElements() as $element_id => $element) {
265  $a_defs[$element_id]->setADT($element);
266  }
267  return $group;
268  }
ADT base class.
Definition: class.ilADT.php:11
$factory
Definition: metadata.php:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComplexOptionsOverview()

ilAdvancedMDFieldDefinition::getComplexOptionsOverview ( object  $a_parent_gui,
string  $parent_cmd 
)
Parameters
object$a_parent_gui
string$parent_cmd
Returns
null

Definition at line 1124 of file class.ilAdvancedMDFieldDefinition.php.

1124  : ?string
1125  {
1126  return null;
1127  }

◆ getDBProperties()

ilAdvancedMDFieldDefinition::getDBProperties ( )
protected

Get all definition properties for DB.

Definition at line 762 of file class.ilAdvancedMDFieldDefinition.php.

References getDescription(), getFieldDefinition(), getImportId(), getPosition(), getRecordId(), getTitle(), getType(), isRequired(), and isSearchable().

Referenced by save(), and update().

762  : array
763  {
764  $fields = array(
765  "field_type" => array("integer", $this->getType()),
766  "record_id" => array("integer", $this->getRecordId()),
767  "import_id" => array("text", $this->getImportId()),
768  "title" => array("text", $this->getTitle()),
769  "description" => array("text", $this->getDescription()),
770  "position" => array("integer", $this->getPosition()),
771  "searchable" => array("integer", $this->isSearchable()),
772  "required" => array("integer", $this->isRequired())
773  );
774 
775  $def = $this->getFieldDefinition();
776  if (is_array($def)) {
777  $fields["field_values"] = array("text", serialize($def));
778  }
779  return $fields;
780  }
getFieldDefinition()
Get (type-specific) field definition.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

ilAdvancedMDFieldDefinition::getDescription ( )

Get description.

Definition at line 487 of file class.ilAdvancedMDFieldDefinition.php.

References $description.

Referenced by _clone(), addToFieldDefinitionForm(), getDBProperties(), ilAdvancedMDSettingsGUI\initFieldForm(), and toXML().

487  : string
488  {
489  return $this->description;
490  }
+ Here is the caller graph for this function:

◆ getFieldDefinition()

ilAdvancedMDFieldDefinition::getFieldDefinition ( )
protected

Get (type-specific) field definition.

Definition at line 554 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by _clone(), and getDBProperties().

554  : array
555  {
556  return [];
557  }
+ Here is the caller graph for this function:

◆ getFieldDefinitionForTableGUI()

ilAdvancedMDFieldDefinition::getFieldDefinitionForTableGUI ( string  $content_language)

Parse properties for table gui.

Definition at line 562 of file class.ilAdvancedMDFieldDefinition.php.

562  : array
563  {
564  return [];
565  }

◆ getFieldId()

◆ getImportId()

ilAdvancedMDFieldDefinition::getImportId ( )

Get import id.

Definition at line 433 of file class.ilAdvancedMDFieldDefinition.php.

References $import_id.

Referenced by getDBProperties(), and save().

433  : string
434  {
435  return $this->import_id;
436  }
+ Here is the caller graph for this function:

◆ getInstance()

static ilAdvancedMDFieldDefinition::getInstance ( ?int  $a_field_id,
?int  $a_type = null,
string  $language = '' 
)
static

Definition at line 84 of file class.ilAdvancedMDFieldDefinition.php.

References $DIC, ilDBInterface\fetchAssoc(), ILIAS\Repository\int(), ilDBInterface\query(), and ilDBInterface\quote().

Referenced by ilContainer\applyContainerUserFilter(), ilAdvancedMDSettingsGUI\confirmDeleteFields(), ilAdvancedMDSettingsGUI\createField(), ilAdvancedMDSettingsGUI\deleteFields(), ilAdvancedMDSettingsGUI\editComplexOption(), ilAdvancedMDSettingsGUI\editField(), ilAdvancedMDSettingsGUI\editFields(), ilContainerFilterAdvMDAdapter\getAdvType(), ilContainerFilterUtil\getContainerFieldTitle(), ilLuceneAdvancedSearchFields\getFormElement(), ilContainerFilterAdvMDAdapter\getOptions(), ilContainerFilterAdvMDAdapter\getTitle(), ilLuceneAdvancedSearchFields\parseFieldQuery(), ilLuceneAdvancedSearchFields\readSections(), ilAdvancedMDSettingsGUI\saveField(), ilAdvancedSearchGUI\searchAdvancedMD(), ilAdvancedMDSettingsGUI\updateComplexOption(), and ilAdvancedMDSettingsGUI\updateField().

89  global $DIC;
90 
91  $db = $DIC->database();
92 
93  if (!$a_type) {
94  $set = $db->query("SELECT field_type" .
95  " FROM adv_mdf_definition" .
96  " WHERE field_id = " . $db->quote($a_field_id, "integer"));
97  $a_type = $db->fetchAssoc($set);
98  $a_type = (int) $a_type["field_type"];
99  }
100 
101  if (self::isValidType($a_type)) {
102  $class = "ilAdvancedMDFieldDefinition" . self::getTypeString($a_type);
103  return new $class($a_field_id, $language);
104  }
105  throw new ilException("unknown type " . $a_type);
106  }
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
global $DIC
Definition: feed.php:28
query(string $query)
Run a (read-only) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstanceByImportId()

static ilAdvancedMDFieldDefinition::getInstanceByImportId ( string  $a_import_id)
static

Definition at line 209 of file class.ilAdvancedMDFieldDefinition.php.

References $DIC, $ilDB, and $query.

Referenced by ilAdvancedMDParser\initValue().

210  {
211  global $DIC;
212 
213  $ilDB = $DIC['ilDB'];
214 
215  $query = "SELECT field_id, field_type FROM adv_mdf_definition" .
216  " WHERE import_id = " . $ilDB->quote($a_import_id, 'text');
217  $set = $ilDB->query($query);
218  if ($ilDB->numRows($set)) {
219  $row = $ilDB->fetchAssoc($set);
220  return self::getInstance((int) $row["field_id"], (int) $row["field_type"]);
221  }
222  return null;
223  }
global $DIC
Definition: feed.php:28
$query
+ Here is the caller graph for this function:

◆ getInstanceByTypeString()

static ilAdvancedMDFieldDefinition::getInstanceByTypeString ( string  $a_type)
static

Get instance by type string (used by import)

Definition at line 125 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by ilAdvancedMDRecordParser\initFieldObject().

126  {
127  // see self::getTypeString()
128  $map = array(
129  self::TYPE_TEXT => "Text",
130  self::TYPE_SELECT => "Select",
131  self::TYPE_DATE => "Date",
132  self::TYPE_DATETIME => "DateTime",
133  self::TYPE_FLOAT => "Float",
134  self::TYPE_LOCATION => "Location",
135  self::TYPE_INTEGER => "Integer",
136  self::TYPE_SELECT_MULTI => "SelectMulti",
137  self::TYPE_EXTERNAL_LINK => 'ExternalLink',
138  self::TYPE_INTERNAL_LINK => 'InternalLink',
139  self::TYPE_ADDRESS => "Address"
140  );
141  $map = array_flip($map);
142  if (array_key_exists($a_type, $map)) {
143  return self::getInstance(null, $map[$a_type]);
144  }
145  return null;
146  }
+ Here is the caller graph for this function:

◆ getInstancesByObjType()

static ilAdvancedMDFieldDefinition::getInstancesByObjType (   $a_obj_type,
  $a_active_only = true 
)
static
Parameters
string$a_obj_type
bool$a_active_only
Returns
array<int, ilAdvancedMDFieldDefinition>

Definition at line 185 of file class.ilAdvancedMDFieldDefinition.php.

References $DIC, $ilDB, $query, $res, and ILIAS\Repository\int().

Referenced by ilECSSettingsGUI\exportMappings(), ilECSSettingsGUI\importMappings(), ilAdvancedMDSettingsGUI\initFormSubstitutions(), ilECSSettingsGUI\initMappingsForm(), ilAdvancedMDRecordGUI\parseAppointmentPresentationa(), and ilAdvancedMDSettingsGUI\updateSubstitutions().

185  : array
186  {
187  global $DIC;
188 
189  $ilDB = $DIC['ilDB'];
190 
191  $query = "SELECT amf.* FROM adv_md_record_objs aro" .
192  " JOIN adv_md_record amr ON aro.record_id = amr.record_id" .
193  " JOIN adv_mdf_definition amf ON aro.record_id = amf.record_id" .
194  " WHERE obj_type = " . $ilDB->quote($a_obj_type, 'text');
195  if ($a_active_only) {
196  $query .= " AND active = " . $ilDB->quote(1, "integer");
197  }
198  $query .= " ORDER BY aro.record_id,position";
199  $res = $ilDB->query($query);
200  $defs = [];
201  while ($row = $ilDB->fetchAssoc($res)) {
202  $field = self::getInstance(null, (int) $row["field_type"]);
203  $field->import($row);
204  $defs[(int) $row["field_id"]] = $field;
205  }
206  return $defs;
207  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstancesByRecordId()

static ilAdvancedMDFieldDefinition::getInstancesByRecordId (   $a_record_id,
  $a_only_searchable = false,
string  $language = '' 
)
static

Get definitions by record id.

Parameters
int$a_record_id
bool$a_only_searchable
string$language
Returns
array<int, ilAdvancedMDFieldDefinition>

Definition at line 155 of file class.ilAdvancedMDFieldDefinition.php.

References $DIC, $ilDB, $query, and ILIAS\Repository\int().

Referenced by ilAdvancedMDRecord\_clone(), ilGlossaryTerm\_copyTerm(), ilAdvancedMDRecord\_delete(), ilAdvancedMDSettingsGUI\editFields(), ilAdvancedMDRecordTableGUI\fillRow(), ilObjBookingPool\getAdvancedMDFields(), ilGlossaryAdvMetaDataAdapter\getAllFields(), ilContainerFilterAdvMDAdapter\getAvailableRecordSets(), ilAdvancedMDValues\getDefinitions(), ilLuceneAdvancedSearchFields\getFields(), ilPCAMDPageList\handleCopiedContent(), ilAdvancedMDRecordGUI\parseFilter(), ilAdvancedMDRecordGUI\parseSearch(), ilAdvancedMDRecordGUI\parseTableCells(), ilAdvancedMDRecordGUI\parseTableHead(), ilAdvancedMDValues\queryForRecords(), ilAdvancedMDFieldTranslations\read(), ilAdvancedMDRecord\toXML(), and ilAdvancedMDSettingsGUI\updateFields().

159  : array {
160  global $DIC;
161 
162  $ilDB = $DIC['ilDB'];
163 
164  $query = "SELECT * FROM adv_mdf_definition" .
165  " WHERE record_id = " . $ilDB->quote($a_record_id, "integer");
166  if ($a_only_searchable) {
167  $query .= " AND searchable = " . $ilDB->quote(1, "integer");
168  }
169  $query .= " ORDER BY position";
170  $set = $ilDB->query($query);
171  $defs = [];
172  while ($row = $ilDB->fetchAssoc($set)) {
173  $field = self::getInstance(null, (int) $row["field_type"], $language);
174  $field->import($row);
175  $defs[(int) $row["field_id"]] = $field;
176  }
177  return $defs;
178  }
global $DIC
Definition: feed.php:28
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastPosition()

ilAdvancedMDFieldDefinition::getLastPosition ( )
protected

Get last position of record.

Definition at line 738 of file class.ilAdvancedMDFieldDefinition.php.

References getRecordId().

Referenced by save().

738  : int
739  {
740  $sql = "SELECT max(position) pos" .
741  " FROM adv_mdf_definition" .
742  " WHERE record_id = " . $this->db->quote($this->getRecordId(), "integer");
743  $set = $this->db->query($sql);
744  if ($this->db->numRows($set)) {
745  $pos = $this->db->fetchAssoc($set);
746  return (int) $pos["pos"];
747  }
748  return 0;
749  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLuceneSearchString()

ilAdvancedMDFieldDefinition::getLuceneSearchString (   $a_value)

Get search string in lucene syntax.

Parameters
string| array
Returns
Todo:
with php 8 support change parameter to union type

Definition at line 1080 of file class.ilAdvancedMDFieldDefinition.php.

1081  {
1082  return $a_value;
1083  }

◆ getPosition()

ilAdvancedMDFieldDefinition::getPosition ( )

Get position.

Definition at line 449 of file class.ilAdvancedMDFieldDefinition.php.

References $position.

Referenced by _clone(), getDBProperties(), and toXML().

449  : int
450  {
451  return $this->position;
452  }
+ Here is the caller graph for this function:

◆ getRecordId()

ilAdvancedMDFieldDefinition::getRecordId ( )

◆ getSearchableDefinitionIds()

static ilAdvancedMDFieldDefinition::getSearchableDefinitionIds ( )
static

Get searchable definition ids (performance is key)

Returns
int[]

Definition at line 229 of file class.ilAdvancedMDFieldDefinition.php.

References $DIC, $ilDB, $query, and ILIAS\Repository\int().

Referenced by ilAdvancedSearchGUI\setSubTabs().

230  {
231  global $DIC;
232 
233  $ilDB = $DIC['ilDB'];
234 
235  $field_ids = array();
236 
237  $query = "SELECT field_id FROM adv_md_record amr" .
238  " JOIN adv_mdf_definition amfd ON (amr.record_id = amfd.record_id)" .
239  " WHERE active = " . $ilDB->quote(1, "integer") .
240  " AND searchable = " . $ilDB->quote(1, "integer");
241  $set = $ilDB->query($query);
242  while ($row = $ilDB->fetchAssoc($set)) {
243  $field_ids[] = (int) $row["field_id"];
244  }
245  return $field_ids;
246  }
global $DIC
Definition: feed.php:28
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSearchQueryParserValue()

ilAdvancedMDFieldDefinition::getSearchQueryParserValue ( ilADTSearchBridge  $a_adt_search)

Get value for search query parser.

Parameters
ilADTSearchBridge$a_adt_search
Returns
string
Todo:
check if string type is applicable

Definition at line 973 of file class.ilAdvancedMDFieldDefinition.php.

973  : string
974  {
975  return '';
976  }

◆ getSearchValueSerialized()

ilAdvancedMDFieldDefinition::getSearchValueSerialized ( ilADTSearchBridge  $a_adt_search)

Definition at line 978 of file class.ilAdvancedMDFieldDefinition.php.

References ilADTSearchBridge\getSerializedValue().

978  : string
979  {
980  return $a_adt_search->getSerializedValue();
981  }
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
+ Here is the call graph for this function:

◆ getTitle()

ilAdvancedMDFieldDefinition::getTitle ( )

Get title.

Definition at line 468 of file class.ilAdvancedMDFieldDefinition.php.

References $title.

Referenced by _clone(), addToFieldDefinitionForm(), getDBProperties(), and toXML().

468  : string
469  {
470  return $this->title;
471  }
+ Here is the caller graph for this function:

◆ getType()

ilAdvancedMDFieldDefinition::getType ( )
abstract

Get type.

Referenced by getDBProperties(), getTypeTitle(), isValidType(), searchObjects(), searchSubObjects(), and toXML().

+ Here is the caller graph for this function:

◆ getTypeString()

static ilAdvancedMDFieldDefinition::getTypeString ( int  $a_type)
staticprotected

Get type as string.

Definition at line 310 of file class.ilAdvancedMDFieldDefinition.php.

310  : string
311  {
312  if (self::isValidType($a_type)) {
313  $map = array(
314  self::TYPE_TEXT => "Text",
315  self::TYPE_SELECT => "Select",
316  self::TYPE_DATE => "Date",
317  self::TYPE_DATETIME => "DateTime",
318  self::TYPE_FLOAT => "Float",
319  self::TYPE_LOCATION => "Location",
320  self::TYPE_INTEGER => "Integer",
321  self::TYPE_SELECT_MULTI => "SelectMulti",
322  self::TYPE_EXTERNAL_LINK => 'ExternalLink',
323  self::TYPE_INTERNAL_LINK => 'InternalLink',
324  self::TYPE_ADDRESS => "Address"
325  );
326  return $map[$a_type];
327  }
328  return '';
329  }

◆ getTypeTitle()

ilAdvancedMDFieldDefinition::getTypeTitle ( )
Todo:
check udf usage

Definition at line 346 of file class.ilAdvancedMDFieldDefinition.php.

References getType(), and initADTDefinition().

Referenced by ilAdvancedMDSettingsGUI\initFieldForm().

346  : string
347  {
348  return "udf_type_" . strtolower(self::getTypeString($this->getType()));
349  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidTypes()

static ilAdvancedMDFieldDefinition::getValidTypes ( )
static

Get all valid types.

Returns
int[]

Definition at line 280 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by ilAdvancedMDSettingsGUI\editFields().

280  : array
281  {
282  return array(
283  self::TYPE_TEXT,
284  self::TYPE_DATE,
285  self::TYPE_DATETIME,
286  self::TYPE_SELECT,
287  self::TYPE_INTEGER,
288  self::TYPE_FLOAT,
289  self::TYPE_LOCATION,
290  self::TYPE_SELECT_MULTI,
291  self::TYPE_EXTERNAL_LINK,
292  self::TYPE_INTERNAL_LINK,
293  self::TYPE_ADDRESS
294  );
295  }
+ Here is the caller graph for this function:

◆ getValueForXML()

ilAdvancedMDFieldDefinition::getValueForXML ( ilADT  $element)
abstract

Parse ADT value for xml (export)

Referenced by importXMLProperty().

+ Here is the caller graph for this function:

◆ hasComplexOptions()

ilAdvancedMDFieldDefinition::hasComplexOptions ( )

Definition at line 1114 of file class.ilAdvancedMDFieldDefinition.php.

1114  : bool
1115  {
1116  return false;
1117  }

◆ import()

ilAdvancedMDFieldDefinition::import ( array  $a_data)
protected

Import from DB.

Definition at line 785 of file class.ilAdvancedMDFieldDefinition.php.

References importFieldDefinition(), setDescription(), setFieldId(), setImportId(), setPosition(), setRecordId(), setRequired(), setSearchable(), and setTitle().

785  : void
786  {
787  $this->setFieldId((int) $a_data["field_id"]);
788  $this->setRecordId((int) $a_data["record_id"]);
789  $this->setImportId((string) $a_data["import_id"]);
790  $this->setTitle((string) $a_data["title"]);
791  $this->setDescription((string) $a_data["description"]);
792  $this->setPosition((int) $a_data["position"]);
793  $this->setSearchable((bool) $a_data["searchable"]);
794  $this->setRequired((bool) $a_data["required"]);
795  if (isset($a_data['field_values'])) {
796  $field_values = unserialize($a_data['field_values']);
797  if (is_array($field_values)) {
798  $this->importFieldDefinition($field_values);
799  }
800  }
801  }
setRequired(bool $a_status)
Toggle required.
setDescription(string $a_desc)
Set description.
importFieldDefinition(array $a_def)
Import (type-specific) field definition from DB.
setImportId(string $a_id_string)
Set import id.
setSearchable(bool $a_status)
Toggle searchable.
+ Here is the call graph for this function:

◆ importCustomDefinitionFormPostValues()

ilAdvancedMDFieldDefinition::importCustomDefinitionFormPostValues ( ilPropertyFormGUI  $a_form,
string  $language = '' 
)

Import custom post values from definition form.

Definition at line 675 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by importDefinitionFormPostValues().

675  : void
676  {
677  // type-specific
678  }
+ Here is the caller graph for this function:

◆ importDefinitionFormPostValues()

ilAdvancedMDFieldDefinition::importDefinitionFormPostValues ( ilPropertyFormGUI  $a_form,
ilAdvancedMDPermissionHelper  $a_permissions,
string  $active_language 
)

Import post values from definition form.

Definition at line 683 of file class.ilAdvancedMDFieldDefinition.php.

References ilAdvancedMDRecord\_getInstanceByRecordId(), ilAdvancedMDPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, ilAdvancedMDPermissionHelper\CONTEXT_FIELD, ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), ilClaimingPermissionHelper\hasPermission(), importCustomDefinitionFormPostValues(), setDescription(), setSearchable(), setTitle(), and ilAdvancedMDPermissionHelper\SUBACTION_FIELD_PROPERTIES.

687  : void {
688  $record = ilAdvancedMDRecord::_getInstanceByRecordId($this->record_id);
689  $is_translation = (($active_language !== '') && ($active_language != $record->getDefaultLanguage()));
690  if (!$a_form->getItemByPostVar("title")->getDisabled() && !$is_translation) {
691  $this->setTitle($a_form->getInput("title"));
692  }
693  if (!$a_form->getItemByPostVar("description")->getDisabled() && !$is_translation) {
694  $this->setDescription($a_form->getInput("description"));
695  }
696  if (!$a_form->getItemByPostVar("searchable")->getDisabled()) {
697  $this->setSearchable((bool) $a_form->getInput("searchable"));
698  }
699 
700  if ($a_permissions->hasPermission(
702  (string) $this->getFieldId(),
705  )) {
706  $this->importCustomDefinitionFormPostValues($a_form, $active_language);
707  }
708  }
getItemByPostVar(string $a_post_var)
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
importCustomDefinitionFormPostValues(ilPropertyFormGUI $a_form, string $language='')
Import custom post values from definition form.
static _getInstanceByRecordId(int $a_record_id)
hasPermission(int $a_context_type, string $a_context_id, int $a_action_id, ?int $a_action_sub_id=null)
Check permission.
setDescription(string $a_desc)
Set description.
setSearchable(bool $a_status)
Toggle searchable.
+ Here is the call graph for this function:

◆ importDefinitionFormPostValuesNeedsConfirmation()

ilAdvancedMDFieldDefinition::importDefinitionFormPostValuesNeedsConfirmation ( )

Definition at line 710 of file class.ilAdvancedMDFieldDefinition.php.

710  : bool
711  {
712  return false;
713  }

◆ importFieldDefinition()

ilAdvancedMDFieldDefinition::importFieldDefinition ( array  $a_def)
protected

Import (type-specific) field definition from DB.

Definition at line 547 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by import().

547  : void
548  {
549  }
+ Here is the caller graph for this function:

◆ importFromECS()

ilAdvancedMDFieldDefinition::importFromECS ( string  $a_ecs_type,
  $a_value,
string  $a_sub_id 
)

Import meta data from ECS.

Definition at line 954 of file class.ilAdvancedMDFieldDefinition.php.

954  : bool
955  {
956  return false;
957  }

◆ importValueFromXML()

ilAdvancedMDFieldDefinition::importValueFromXML ( string  $a_cdata)
abstract

Import value from xml.

Parameters
string$a_cdata

Referenced by importXMLProperty().

+ Here is the caller graph for this function:

◆ importXMLProperty()

ilAdvancedMDFieldDefinition::importXMLProperty ( string  $a_key,
string  $a_value 
)

Import property from XML.

Definition at line 936 of file class.ilAdvancedMDFieldDefinition.php.

References getValueForXML(), and importValueFromXML().

936  : void
937  {
938  }
+ Here is the call graph for this function:

◆ init()

ilAdvancedMDFieldDefinition::init ( )
protected

Definition at line 270 of file class.ilAdvancedMDFieldDefinition.php.

References setRequired(), and setSearchable().

Referenced by __construct().

270  : void
271  {
272  $this->setRequired(false);
273  $this->setSearchable(false);
274  }
setRequired(bool $a_status)
Toggle required.
setSearchable(bool $a_status)
Toggle searchable.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initADTDefinition()

ilAdvancedMDFieldDefinition::initADTDefinition ( )
abstractprotected

Init adt instance.

Referenced by getADTDefinition(), and getTypeTitle().

+ Here is the caller graph for this function:

◆ isFilterSupported()

ilAdvancedMDFieldDefinition::isFilterSupported ( )

Is search by filter supported.

Definition at line 503 of file class.ilAdvancedMDFieldDefinition.php.

503  : bool
504  {
505  return true;
506  }

◆ isRequired()

ilAdvancedMDFieldDefinition::isRequired ( )

Is required field.

Definition at line 539 of file class.ilAdvancedMDFieldDefinition.php.

References $required.

Referenced by _clone(), and getDBProperties().

539  : bool
540  {
541  return $this->required;
542  }
+ Here is the caller graph for this function:

◆ isSearchable()

ilAdvancedMDFieldDefinition::isSearchable ( )

Is searchable.

Definition at line 523 of file class.ilAdvancedMDFieldDefinition.php.

References $searchable.

Referenced by _clone(), addToFieldDefinitionForm(), getDBProperties(), and toXML().

523  : bool
524  {
525  return $this->searchable;
526  }
+ Here is the caller graph for this function:

◆ isSearchSupported()

ilAdvancedMDFieldDefinition::isSearchSupported ( )

Is search supported at all.

Definition at line 495 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by addToFieldDefinitionForm(), and setSearchable().

495  : bool
496  {
497  return true;
498  }
+ Here is the caller graph for this function:

◆ isValidType()

static ilAdvancedMDFieldDefinition::isValidType ( int  $a_type)
static

Definition at line 297 of file class.ilAdvancedMDFieldDefinition.php.

References getType(), and ILIAS\Repository\int().

Referenced by ilAdvancedMDClaimingPlugin\createDBField().

297  : bool
298  {
299  return in_array($a_type, self::getValidTypes());
300  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseSearchObjects()

ilAdvancedMDFieldDefinition::parseSearchObjects ( array  $a_records,
array  $a_object_types 
)
protected

Add object-data needed for global search to AMD search results.

Definition at line 994 of file class.ilAdvancedMDFieldDefinition.php.

References $res.

Referenced by ilAdvancedMDFieldDefinitionInternalLink\searchObjects(), and searchObjects().

994  : array
995  {
996  $res = [];
997  $obj_ids = [];
998  foreach ($a_records as $record) {
999  if ($record["sub_type"] == "-") {
1000  $obj_ids[] = $record["obj_id"];
1001  }
1002  }
1003 
1004  $sql = "SELECT obj_id,type" .
1005  " FROM object_data" .
1006  " WHERE " . $this->db->in("obj_id", $obj_ids, false, "integer") .
1007  " AND " . $this->db->in("type", $a_object_types, false, "text");
1008  $set = $this->db->query($sql);
1009  while ($row = $this->db->fetchAssoc($set)) {
1010  $res[] = $row;
1011  }
1012  return $res;
1013  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ prepareCustomDefinitionFormConfirmation()

ilAdvancedMDFieldDefinition::prepareCustomDefinitionFormConfirmation ( ilPropertyFormGUI  $a_form)

Definition at line 715 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by prepareDefinitionFormConfirmation().

715  : void
716  {
717  }
+ Here is the caller graph for this function:

◆ prepareDefinitionFormConfirmation()

ilAdvancedMDFieldDefinition::prepareDefinitionFormConfirmation ( ilPropertyFormGUI  $a_form)

Definition at line 719 of file class.ilAdvancedMDFieldDefinition.php.

References ilPropertyFormGUI\addItem(), ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), and prepareCustomDefinitionFormConfirmation().

719  : void
720  {
721  $a_form->getItemByPostVar("title")->setDisabled(true);
722  $a_form->getItemByPostVar("description")->setDisabled(true);
723  $a_form->getItemByPostVar("searchable")->setDisabled(true);
724 
725  // checkboxes have no hidden on disabled
726  if ($a_form->getInput("searchable")) {
727  $hidden = new ilHiddenInputGUI("searchable");
728  $hidden->setValue("1");
729  $a_form->addItem($hidden);
730  }
731 
733  }
getItemByPostVar(string $a_post_var)
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
prepareCustomDefinitionFormConfirmation(ilPropertyFormGUI $a_form)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ prepareElementForEditor()

ilAdvancedMDFieldDefinition::prepareElementForEditor ( ilADTFormBridge  $a_bridge)

Prepare editor form elements.

Definition at line 962 of file class.ilAdvancedMDFieldDefinition.php.

962  : void
963  {
964  // type-specific
965  }

◆ prepareElementForSearch()

ilAdvancedMDFieldDefinition::prepareElementForSearch ( ilADTSearchBridge  $a_bridge)

Prepare search form elements.

Definition at line 1088 of file class.ilAdvancedMDFieldDefinition.php.

1088  : void
1089  {
1090  }

◆ read()

ilAdvancedMDFieldDefinition::read ( ?int  $a_field_id)
protected

Read field definition.

Definition at line 806 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by __construct().

806  : void
807  {
808  if (!(int) $a_field_id) {
809  return;
810  }
811 
812  $sql = "SELECT * FROM adv_mdf_definition" .
813  " WHERE field_id = " . $this->db->quote($a_field_id, "integer");
814  $set = $this->db->query($sql);
815  if ($this->db->numRows($set)) {
816  $row = $this->db->fetchAssoc($set);
817  $this->import($row);
818  }
819  }
+ Here is the caller graph for this function:

◆ save()

ilAdvancedMDFieldDefinition::save ( bool  $a_keep_pos = false)

Create new field entry.

Definition at line 824 of file class.ilAdvancedMDFieldDefinition.php.

References generateImportId(), getDBProperties(), getFieldId(), getImportId(), getLastPosition(), setFieldId(), setImportId(), setPosition(), and update().

Referenced by update().

824  : void
825  {
826  if ($this->getFieldId()) {
827  $this->update();
828  return;
829  }
830 
831  $next_id = $this->db->nextId("adv_mdf_definition");
832 
833  // append
834  if (!$a_keep_pos) {
835  $this->setPosition($this->getLastPosition() + 1);
836  }
837 
838  // needs unique import id
839  if (!$this->getImportId()) {
840  $this->setImportId($this->generateImportId($next_id));
841  }
842 
843  $fields = $this->getDBProperties();
844  $fields["field_id"] = array("integer", $next_id);
845 
846  $this->db->insert("adv_mdf_definition", $fields);
847 
848  $this->setFieldId($next_id);
849  }
getDBProperties()
Get all definition properties for DB.
generateImportId(int $a_field_id)
Generate unique record id.
getLastPosition()
Get last position of record.
setImportId(string $a_id_string)
Set import id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ searchObjects()

ilAdvancedMDFieldDefinition::searchObjects ( ilADTSearchBridge  $a_adt_search,
ilQueryParser  $a_parser,
array  $a_object_types,
string  $a_locate,
string  $a_search_type 
)

Search objects.

Definition at line 1050 of file class.ilAdvancedMDFieldDefinition.php.

References ilADTActiveRecordByType\find(), getADT(), getFieldId(), ilADTSearchBridge\getSQLCondition(), getType(), parseSearchObjects(), and ilADTActiveRecordByType\SINGLE_COLUMN_NAME.

1056  : array {
1057  // search type only supported/needed for text
1058  $condition = $a_adt_search->getSQLCondition(ilADTActiveRecordByType::SINGLE_COLUMN_NAME);
1059  if ($condition) {
1060  $objects = ilADTActiveRecordByType::find(
1061  "adv_md_values",
1062  $this->getADT()->getType(),
1063  $this->getFieldId(),
1064  $condition,
1065  $a_locate
1066  );
1067  if (sizeof($objects)) {
1068  return $this->parseSearchObjects($objects, $a_object_types);
1069  }
1070  }
1071  return [];
1072  }
parseSearchObjects(array $a_records, array $a_object_types)
Add object-data needed for global search to AMD search results.
getSQLCondition(string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
Get SQL condition for current value(s)
static find(string $a_table, string $a_type, int $a_field_id, string $a_condition, ?string $a_additional_fields=null)
Find entries.
+ Here is the call graph for this function:

◆ searchSubObjects()

ilAdvancedMDFieldDefinition::searchSubObjects ( ilADTSearchBridge  $a_adt_search,
int  $a_obj_id,
string  $sub_obj_type 
)

Definition at line 1015 of file class.ilAdvancedMDFieldDefinition.php.

References $res, ilADTActiveRecordByType\find(), getADT(), getFieldId(), ilADTSearchBridge\getSQLCondition(), getType(), and ilADTActiveRecordByType\SINGLE_COLUMN_NAME.

1015  : array
1016  {
1018 
1019  // :TODO:
1020  if ($a_adt_search instanceof ilADTLocationSearchBridgeSingle) {
1021  $element_id = "loc";
1022  }
1023 
1024  $condition = $a_adt_search->getSQLCondition($element_id);
1025  if ($condition) {
1026  $objects = ilADTActiveRecordByType::find(
1027  "adv_md_values",
1028  $this->getADT()->getType(),
1029  $this->getFieldId(),
1030  $condition
1031  );
1032  if (sizeof($objects)) {
1033  $res = array();
1034  foreach ($objects as $item) {
1035  if ($item["obj_id"] == $a_obj_id &&
1036  $item["sub_type"] == $sub_obj_type) {
1037  $res[] = $item["sub_id"];
1038  }
1039  }
1040  return $res;
1041  }
1042  }
1043 
1044  return array();
1045  }
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getSQLCondition(string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
Get SQL condition for current value(s)
static find(string $a_table, string $a_type, int $a_field_id, string $a_condition, ?string $a_additional_fields=null)
Find entries.
+ Here is the call graph for this function:

◆ setADT()

ilAdvancedMDFieldDefinition::setADT ( ilADT  $a_adt)
protected

Set ADT instance.

See also
self::getADTGroupForDefinitions()

Definition at line 380 of file class.ilAdvancedMDFieldDefinition.php.

380  : void
381  {
382  if (!$this->adt instanceof ilADT) {
383  $this->adt = $a_adt;
384  }
385  }
ADT base class.
Definition: class.ilADT.php:11

◆ setDescription()

ilAdvancedMDFieldDefinition::setDescription ( string  $a_desc)

Set description.

Definition at line 476 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by import(), and importDefinitionFormPostValues().

476  : void
477  {
478  if ($a_desc !== null) {
479  $a_desc = trim($a_desc);
480  }
481  $this->description = $a_desc;
482  }
+ Here is the caller graph for this function:

◆ setFieldId()

ilAdvancedMDFieldDefinition::setFieldId ( int  $a_id)
protected

Set field_id.

Definition at line 390 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by import(), and save().

390  : void
391  {
392  $this->field_id = $a_id;
393  }
+ Here is the caller graph for this function:

◆ setImportId()

ilAdvancedMDFieldDefinition::setImportId ( string  $a_id_string)

Set import id.

Definition at line 422 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by import(), and save().

422  : void
423  {
424  if ($a_id_string !== null) {
425  $a_id_string = trim($a_id_string);
426  }
427  $this->import_id = $a_id_string;
428  }
+ Here is the caller graph for this function:

◆ setPosition()

ilAdvancedMDFieldDefinition::setPosition ( int  $a_pos)

Set position.

Definition at line 441 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by import(), and save().

441  : void
442  {
443  $this->position = $a_pos;
444  }
+ Here is the caller graph for this function:

◆ setRecordId()

ilAdvancedMDFieldDefinition::setRecordId ( int  $a_id)

Set record id.

Definition at line 406 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by import().

406  : void
407  {
408  $this->record_id = $a_id;
409  }
+ Here is the caller graph for this function:

◆ setRequired()

ilAdvancedMDFieldDefinition::setRequired ( bool  $a_status)

Toggle required.

Definition at line 531 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by import(), and init().

531  : void
532  {
533  $this->required = $a_status;
534  }
+ Here is the caller graph for this function:

◆ setSearchable()

ilAdvancedMDFieldDefinition::setSearchable ( bool  $a_status)

Toggle searchable.

Definition at line 511 of file class.ilAdvancedMDFieldDefinition.php.

References isSearchSupported().

Referenced by import(), importDefinitionFormPostValues(), and init().

511  : void
512  {
513  // see above
514  if (!$this->isSearchSupported()) {
515  $a_status = false;
516  }
517  $this->searchable = (bool) $a_status;
518  }
isSearchSupported()
Is search supported at all.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSearchValueSerialized()

ilAdvancedMDFieldDefinition::setSearchValueSerialized ( ilADTSearchBridge  $a_adt_search,
  $a_value 
)

Set value from search persistence.

Definition at line 986 of file class.ilAdvancedMDFieldDefinition.php.

References ilADTSearchBridge\setSerializedValue().

986  : void
987  {
988  $a_adt_search->setSerializedValue($a_value);
989  }
setSerializedValue(string $a_value)
Set current value(s) in serialized form (for easy persisting)
+ Here is the call graph for this function:

◆ setTitle()

ilAdvancedMDFieldDefinition::setTitle ( string  $a_title)

Get title.

Definition at line 457 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by import(), and importDefinitionFormPostValues().

457  : void
458  {
459  if ($a_title !== null) {
460  $a_title = trim($a_title);
461  }
462  $this->title = $a_title;
463  }
+ Here is the caller graph for this function:

◆ toXML()

ilAdvancedMDFieldDefinition::toXML ( ilXmlWriter  $a_writer)

To Xml.

This method writes only the subset Field Use class.ilAdvancedMDRecordXMLWriter to generate a complete xml presentation.

Definition at line 890 of file class.ilAdvancedMDFieldDefinition.php.

References addPropertiesToXML(), generateImportId(), getDescription(), getFieldId(), ilAdvancedMDFieldTranslations\getInstanceByRecordId(), getPosition(), getRecordId(), getTitle(), getType(), isSearchable(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

890  : void
891  {
892  $a_writer->xmlStartTag('Field', array(
893  'id' => $this->generateImportId($this->getFieldId()),
894  'searchable' => ($this->isSearchable() ? 'Yes' : 'No'),
895  'fieldType' => self::getTypeString($this->getType())
896  ));
897 
898  $a_writer->xmlElement('FieldTitle', null, $this->getTitle());
899  $a_writer->xmlElement('FieldDescription', null, $this->getDescription());
900 
902  $a_writer->xmlStartTag('FieldTranslations');
903  foreach ($translations->getTranslations($this->getFieldId()) as $translation) {
904  $a_writer->xmlStartTag('FieldTranslation', ['language' => $translation->getLangKey()]);
905  $a_writer->xmlElement(
906  'FieldTranslationTitle',
907  [],
908  $translation->getTitle()
909  );
910  $a_writer->xmlElement(
911  'FieldTranslationDescription',
912  [],
913  $translation->getDescription()
914  );
915  $a_writer->xmlEndTag('FieldTranslation');
916  }
917  $a_writer->xmlEndTag('FieldTranslations');
918  $a_writer->xmlElement('FieldPosition', null, $this->getPosition());
919 
920  $this->addPropertiesToXML($a_writer);
921 
922  $a_writer->xmlEndTag('Field');
923  }
xmlEndTag(string $tag)
Writes an endtag.
generateImportId(int $a_field_id)
Generate unique record id.
addPropertiesToXML(ilXmlWriter $a_writer)
Add (type-specific) properties to xml export.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:

◆ update()

ilAdvancedMDFieldDefinition::update ( )

Update field entry.

Definition at line 854 of file class.ilAdvancedMDFieldDefinition.php.

References getDBProperties(), getFieldId(), and save().

Referenced by save().

854  : void
855  {
856  if (!$this->getFieldId()) {
857  $this->save();
858  return;
859  }
860 
861  $this->db->update(
862  "adv_mdf_definition",
863  $this->getDBProperties(),
864  array("field_id" => array("integer", $this->getFieldId()))
865  );
866  }
save(bool $a_keep_pos=false)
Create new field entry.
getDBProperties()
Get all definition properties for DB.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ useDefaultLanguageMode()

ilAdvancedMDFieldDefinition::useDefaultLanguageMode ( string  $language)

Check if default language mode has to be used: no language given or language equals default language.

Definition at line 334 of file class.ilAdvancedMDFieldDefinition.php.

References $language, and ilAdvancedMDRecord\_getInstanceByRecordId().

Referenced by ilAdvancedMDFieldDefinitionSelect\addCustomFieldToDefinitionForm(), ilAdvancedMDFieldDefinitionInteger\addCustomFieldToDefinitionForm(), ilAdvancedMDFieldDefinitionInteger\getFieldDefinitionForTableGUI(), ilAdvancedMDFieldDefinitionInteger\importCustomDefinitionFormPostValues(), and ilAdvancedMDFieldDefinitionSelect\importNewSelectOptions().

334  : bool
335  {
336  if (!strlen($language)) {
337  return true;
338  }
339  $record = ilAdvancedMDRecord::_getInstanceByRecordId($this->record_id);
340  return strcmp($record->getDefaultLanguage(), $language) === 0;
341  }
static _getInstanceByRecordId(int $a_record_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $adt

◆ $adt_def

ilADTDefinition ilAdvancedMDFieldDefinition::$adt_def = null
protected

Definition at line 52 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by getADTDefinition().

◆ $db

ilDBInterface ilAdvancedMDFieldDefinition::$db
protected

Definition at line 57 of file class.ilAdvancedMDFieldDefinition.php.

◆ $description

string ilAdvancedMDFieldDefinition::$description = ''
protected

Definition at line 49 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by getDescription().

◆ $field_id

int ilAdvancedMDFieldDefinition::$field_id = null
protected

Definition at line 44 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by getFieldId().

◆ $http

GlobalHttpState ilAdvancedMDFieldDefinition::$http
protected

Definition at line 60 of file class.ilAdvancedMDFieldDefinition.php.

◆ $import_id

string ilAdvancedMDFieldDefinition::$import_id = ''
protected

Definition at line 46 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by getImportId().

◆ $language

◆ $lng

◆ $logger

ilLogger ilAdvancedMDFieldDefinition::$logger
protected

Definition at line 59 of file class.ilAdvancedMDFieldDefinition.php.

◆ $position

int ilAdvancedMDFieldDefinition::$position = 0
protected

◆ $record_id

int ilAdvancedMDFieldDefinition::$record_id = 0
protected

Definition at line 45 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by getRecordId().

◆ $refinery

RefineryFactory ilAdvancedMDFieldDefinition::$refinery
protected

Definition at line 61 of file class.ilAdvancedMDFieldDefinition.php.

◆ $required

bool ilAdvancedMDFieldDefinition::$required = false
protected

Definition at line 51 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by isRequired().

◆ $searchable

bool ilAdvancedMDFieldDefinition::$searchable = false
protected

Definition at line 50 of file class.ilAdvancedMDFieldDefinition.php.

Referenced by isSearchable().

◆ $title

◆ TYPE_ADDRESS

const ilAdvancedMDFieldDefinition::TYPE_ADDRESS = 99

Definition at line 40 of file class.ilAdvancedMDFieldDefinition.php.

◆ TYPE_DATE

◆ TYPE_DATETIME

const ilAdvancedMDFieldDefinition::TYPE_DATETIME = 4

Definition at line 35 of file class.ilAdvancedMDFieldDefinition.php.

◆ TYPE_EXTERNAL_LINK

const ilAdvancedMDFieldDefinition::TYPE_EXTERNAL_LINK = 9

Definition at line 41 of file class.ilAdvancedMDFieldDefinition.php.

◆ TYPE_FLOAT

const ilAdvancedMDFieldDefinition::TYPE_FLOAT = 6

Definition at line 37 of file class.ilAdvancedMDFieldDefinition.php.

◆ TYPE_INTEGER

const ilAdvancedMDFieldDefinition::TYPE_INTEGER = 5

◆ TYPE_INTERNAL_LINK

const ilAdvancedMDFieldDefinition::TYPE_INTERNAL_LINK = 10

Definition at line 42 of file class.ilAdvancedMDFieldDefinition.php.

◆ TYPE_LOCATION

const ilAdvancedMDFieldDefinition::TYPE_LOCATION = 7

Definition at line 38 of file class.ilAdvancedMDFieldDefinition.php.

◆ TYPE_SELECT

const ilAdvancedMDFieldDefinition::TYPE_SELECT = 1

◆ TYPE_SELECT_MULTI

const ilAdvancedMDFieldDefinition::TYPE_SELECT_MULTI = 8

◆ TYPE_TEXT

const ilAdvancedMDFieldDefinition::TYPE_TEXT = 2

The documentation for this class was generated from the following file: