4 require_once
"Services/ADT/classes/class.ilADTFactory.php";
45 $this->
read($a_field_id);
61 $set = $ilDB->query(
"SELECT field_type".
62 " FROM adv_mdf_definition".
63 " WHERE field_id = ".$ilDB->quote($a_field_id,
"integer"));
64 $a_type = $ilDB->fetchAssoc($set);
70 $class =
"ilAdvancedMDFieldDefinition".self::getTypeString(
$a_type);
71 require_once
"Services/AdvancedMetaData/classes/Types/class.".$class.
".php";
72 return new $class($a_field_id);
88 self::TYPE_TEXT =>
"Text",
89 self::TYPE_SELECT =>
"Select",
90 self::TYPE_DATE =>
"Date",
91 self::TYPE_DATETIME =>
"DateTime",
92 self::TYPE_FLOAT =>
"Float",
93 self::TYPE_LOCATION =>
"Location",
94 self::TYPE_INTEGER =>
"Integer",
95 self::TYPE_SELECT_MULTI =>
"SelectMulti" 97 $map = array_flip($map);
98 if(array_key_exists(
$a_type, $map))
100 return self::getInstance(null, $map[
$a_type]);
117 $query =
"SELECT * FROM adv_mdf_definition".
118 " WHERE record_id = ".$ilDB->quote($a_record_id,
"integer");
119 if($a_only_searchable)
121 $query .=
" AND searchable = ".$ilDB->quote(1,
"integer");
123 $query .=
" ORDER BY position";
124 $set = $ilDB->query(
$query);
125 while(
$row = $ilDB->fetchAssoc($set))
127 $field = self::getInstance(null,
$row[
"field_type"]);
128 $field->import(
$row);
129 $defs[
$row[
"field_id"]] = $field;
141 $query =
"SELECT amf.* FROM adv_md_record_objs aro".
142 " JOIN adv_md_record amr ON aro.record_id = amr.record_id".
143 " JOIN adv_mdf_definition amf ON aro.record_id = amf.record_id".
144 " WHERE obj_type = ".$ilDB->quote($a_obj_type,
'text');
145 if((
bool)$a_active_only)
147 $query .=
" AND active = ".$ilDB->quote(1,
"integer");
149 $query .=
" ORDER BY aro.record_id,position";
151 while(
$row = $ilDB->fetchAssoc(
$res))
153 $field = self::getInstance(null,
$row[
"field_type"]);
154 $field->import(
$row);
155 $defs[
$row[
"field_id"]] = $field;
170 $query =
"SELECT field_id, field_type FROM adv_mdf_definition".
171 " WHERE import_id = ".$ilDB->quote($a_import_id,
'text');
172 $set = $ilDB->query(
$query);
173 if($ilDB->numRows($set))
175 $row = $ilDB->fetchAssoc($set);
176 return self::getInstance(
$row[
"field_id"],
$row[
"field_type"]);
189 $field_ids =
array();
191 $query =
"SELECT field_id FROM adv_md_record amr".
192 " JOIN adv_mdf_definition amfd ON (amr.record_id = amfd.record_id)".
193 " WHERE active = ".$ilDB->quote(1,
"integer").
194 " AND searchable = ".$ilDB->quote(1,
"integer");
195 $set = $ilDB->query(
$query);
196 while(
$row = $ilDB->fetchAssoc($set))
198 $field_ids[] =
$row[
"field_id"];
212 $group_def = $factory->getDefinitionInstanceByType(
"Group");
213 foreach($a_defs as $def)
215 $group_def->addElement($def->getFieldId(), $def->getADTDefinition());
217 $group = $factory->getInstanceByDefinition($group_def);
220 foreach($group->getElements() as $element_id => $element)
222 $a_defs[$element_id]->setADT($element);
249 return array(self::TYPE_TEXT, self::TYPE_DATE, self::TYPE_DATETIME,
250 self::TYPE_SELECT, self::TYPE_INTEGER, self::TYPE_FLOAT,
251 self::TYPE_LOCATION, self::TYPE_SELECT_MULTI);
262 return in_array((
int)
$a_type, self::getValidTypes());
270 abstract public function getType();
283 self::TYPE_TEXT =>
"Text",
284 self::TYPE_SELECT =>
"Select",
285 self::TYPE_DATE =>
"Date",
286 self::TYPE_DATETIME =>
"DateTime",
287 self::TYPE_FLOAT =>
"Float",
288 self::TYPE_LOCATION =>
"Location",
289 self::TYPE_INTEGER =>
"Integer",
290 self::TYPE_SELECT_MULTI =>
"SelectMulti" 304 return "udf_type_".strtolower(self::getTypeString($this->
getType()));
341 if(!$this->adt instanceof
ilADT)
356 if(!$this->adt instanceof
ilADT)
373 $this->field_id = (int)$a_id;
393 $this->record_id = (int)$a_id;
413 if($a_id_string !== null)
415 $a_id_string = trim($a_id_string);
417 $this->import_id = $a_id_string;
437 $this->position = (int)$a_pos;
457 if($a_title !== null)
459 $a_title = trim($a_title);
461 $this->title = $a_title;
483 $a_desc = trim($a_desc);
485 $this->description = $a_desc;
530 $this->searchable = (bool)$a_status;
550 $this->required = (bool)$a_status;
638 $title->setRequired(
true);
643 $title->setDisabled(
true);
655 $desc->setDisabled(
true);
667 $check->setDisabled(
true);
742 $hidden->setValue(1);
763 $sql =
"SELECT max(position) pos".
764 " FROM adv_mdf_definition".
765 " WHERE record_id = ".$ilDB->quote($this->
getRecordId(),
"integer");
766 $set = $ilDB->query($sql);
767 if($ilDB->numRows($set))
769 $pos = $ilDB->fetchAssoc($set);
770 return (
int)$pos[
"pos"];
784 return 'il_'.IL_INST_ID.
'_adv_md_field_'.$a_field_id;
808 $fields[
"field_values"] =
array(
"text", serialize($def));
819 protected function import(
array $a_data)
831 if($a_data[
"field_values"])
840 protected function read($a_field_id)
844 if(!(
int)$a_field_id)
849 $sql =
"SELECT * FROM adv_mdf_definition".
850 " WHERE field_id = ".$ilDB->quote($a_field_id,
"integer");
851 $set = $ilDB->query($sql);
852 if($ilDB->numRows($set))
854 $row = $ilDB->fetchAssoc($set);
862 public function save($a_keep_pos =
false)
871 $next_id = $ilDB->nextId(
"adv_mdf_definition");
886 $fields[
"field_id"] =
array(
"integer", $next_id);
888 $ilDB->insert(
"adv_mdf_definition", $fields);
902 return $this->
save();
905 $ilDB->update(
"adv_mdf_definition",
913 public function delete()
923 include_once(
"Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php");
926 $query =
"DELETE FROM adv_mdf_definition".
927 " WHERE field_id = ".$ilDB->quote($this->
getFieldId(),
"integer");
928 $ilDB->manipulate(
$query);
948 'fieldType' => self::getTypeString($this->
getType())));
1075 foreach($a_records as $record)
1077 if($record[
"sub_type"] ==
"-")
1079 $obj_ids[] = $record[
"obj_id"];
1083 $sql =
"SELECT obj_id,type".
1084 " FROM object_data".
1085 " WHERE ".$ilDB->in(
"obj_id", $obj_ids,
"",
"integer").
1086 " AND ".$ilDB->in(
"type", $a_object_types,
"",
"text");
1087 $set = $ilDB->query($sql);
1088 while(
$row = $ilDB->fetchAssoc($set))
1098 include_once(
'Services/ADT/classes/ActiveRecord/class.ilADTActiveRecordByType.php');
1104 $element_id =
"loc";
1111 if(
sizeof($objects))
1114 foreach($objects as $item)
1116 if($item[
"obj_id"] == $a_obj_id &&
1117 $item[
"sub_type"] == $sub_obj_type)
1119 $res[] = $item[
"sub_id"];
1143 include_once(
'Services/ADT/classes/ActiveRecord/class.ilADTActiveRecordByType.php');
1148 if(
sizeof($objects))
1185 $class = get_class($this);
1186 $obj =
new $class();
1187 $obj->setRecordId($a_new_record_id);
isSearchable()
Is searchable.
getDescription()
Get description.
setPosition($a_pos)
Set position.
parseSearchObjects(array $a_records, array $a_object_types)
Add object-data needed for global search to AMD search results.
toXML(ilXmlWriter $a_writer)
To Xml.
isFilterSupported()
Is search by filter supported.
Base class for ILIAS Exception handling.
const SUBACTION_FIELD_PROPERTIES
setSearchValueSerialized(ilADTSearchBridge $a_adt_search, $a_value)
Set value from search persistence.
save($a_keep_pos=false)
Create new field entry.
hasPermissions($a_context_type, $a_context_id, array $a_action_ids)
Check permissions.
getADTDefinition()
Get ADT definition instance.
setTitle($a_title)
Get title.
isRequired()
Is required field.
AMD field abstract base class.
importValueFromXML($a_cdata)
Import value from xml.
addCustomFieldToDefinitionForm(ilPropertyFormGUI $a_form, $a_disabled=false)
Add custom input elements to definition form.
setImportId($a_id_string)
Set import id.
importDefinitionFormPostValues(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions)
Import post values from definition form.
getADT()
Get ADT instance.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
setValue($a_value)
Set Value.
searchSubObjects(ilADTSearchBridge $a_adt_search, $a_obj_id, $sub_obj_type)
static getADTGroupForDefinitions(array $a_defs)
Init ADTGroup for definitions.
setSerializedValue($a_value)
Set current value(s) in serialized form (for easy persisting)
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
static _deleteByFieldId($a_field_id, ilADT $a_adt)
Delete values by field_id.
getImportId()
Get import id.
const ACTION_FIELD_EDIT_PROPERTY
update()
Update field entry.
importFromECS($a_ecs_type, $a_value, $a_sub_id)
Import meta data from ECS.
static getInstance()
Get singleton.
static getInstanceByImportId($a_import_id)
Get definition instance by import id.
xmlEndTag($tag)
Writes an endtag.
static getTypeString($a_type)
Get type string.
const SUBACTION_FIELD_SEARCHABLE
getDBProperties()
Get all definition properties for DB.
hasPermission($a_context_type, $a_context_id, $a_action_id, $a_action_sub_id=null)
Check permission.
prepareCustomDefinitionFormConfirmation(ilPropertyFormGUI $a_form)
getFieldDefinitionForTableGUI()
Parse properties for table gui.
setDescription($a_desc)
Set description.
importCustomDefinitionFormPostValues(ilPropertyFormGUI $a_form)
Import custom post values from definition form.
getSerializedValue()
Get current value(s) in serialized form (for easy persisting)
static find($a_table, $a_type, $a_field_id, $a_condition, $a_additional_fields=null)
Find entries.
getSearchQueryParserValue(ilADTSearchBridge $a_adt_search)
Get value for search query parser.
Advanced metadata permission helper.
getSearchValueSerialized(ilADTSearchBridge $a_adt_search)
Get value for search persistence.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
const SUBACTION_FIELD_TITLE
static getSearchableDefinitionIds()
Get searchable definition ids (performance is key)
static getInstancesByObjType($a_obj_type, $a_active_only=true)
static getInstance($a_field_id, $a_type=null)
Get definition instance by type.
addToFieldDefinitionForm(ilPropertyFormGUI $a_form, ilAdvancedMDPermissionHelper $a_permissions)
Add input elements to definition form.
setSearchable($a_status)
Toggle searchable.
setRequired($a_status)
Toggle required.
This class represents a text property in a property form.
importDefinitionFormPostValuesNeedsConfirmation()
generateImportId($a_field_id)
Generate unique record id.
getLastPosition()
Get last position of record.
__construct($a_field_id=null)
Constructor.
importXMLProperty($a_key, $a_value)
Import property from XML.
prepareElementForSearch(ilADTSearchBridge $a_bridge)
Prepare search form elements.
static getValidTypes()
Get all valid types.
Create styles array
The data for the language used.
prepareElementForEditor(ilADTFormBridge $a_bridge)
Prepare editor form elements.
getLuceneSearchString($a_value)
Get search string in lucene syntax.
ADT search bridge base class.
getFieldDefinition()
Get (type-specific) field definition.
setADT(ilADT $a_adt)
Set ADT instance.
addPropertiesToXML(ilXmlWriter $a_writer)
Add (type-specific) properties to xml export.
getValueForXML(ilADT $element)
Parse ADT value for xml (export)
read($a_field_id)
Read field definition.
_clone($a_new_record_id)
Clone field definition.
importFieldDefinition(array $a_def)
Import (type-specific) field definition from DB.
This class represents a text area property in a property form.
getPosition()
Get position.
const SUBACTION_FIELD_DESCRIPTION
searchObjects(ilADTSearchBridge $a_adt_search, ilQueryParser $a_parser, array $a_object_types, $a_locate, $a_search_type)
Search objects.
initADTDefinition()
Init adt instance.
getTypeTitle()
Get type title (lang id)
ADT definition base class.
isSearchSupported()
Is search supported at all.
getSQLCondition($a_element_id)
Get SQL condition for current value(s)
getRecordId()
Get record id.
getFieldId()
Get field_id.
setRecordId($a_id)
Set record id.
static getInstanceByTypeString($a_type)
Get instance by type string (used by import)
static isValidType($a_type)
Is given type valid.
prepareDefinitionFormConfirmation(ilPropertyFormGUI $a_form)
setFieldId($a_id)
Set field_id.