4 require_once
"Services/ADT/classes/class.ilADTFactory.php";
47 $this->
read($a_field_id);
64 $set =
$ilDB->query(
"SELECT field_type" .
65 " FROM adv_mdf_definition" .
66 " WHERE field_id = " .
$ilDB->quote($a_field_id,
"integer"));
71 if (self::isValidType(
$a_type)) {
72 $class =
"ilAdvancedMDFieldDefinition" . self::getTypeString(
$a_type);
73 require_once
"Services/AdvancedMetaData/classes/Types/class." . $class .
".php";
74 return new $class($a_field_id);
90 self::TYPE_TEXT =>
"Text",
91 self::TYPE_SELECT =>
"Select",
92 self::TYPE_DATE =>
"Date",
93 self::TYPE_DATETIME =>
"DateTime",
94 self::TYPE_FLOAT =>
"Float",
95 self::TYPE_LOCATION =>
"Location",
96 self::TYPE_INTEGER =>
"Integer",
97 self::TYPE_SELECT_MULTI =>
"SelectMulti" ,
98 self::TYPE_EXTERNAL_LINK =>
'ExternalLink',
99 self::TYPE_INTERNAL_LINK =>
'InternalLink' 118 $ilDB = $DIC[
'ilDB'];
122 $query =
"SELECT * FROM adv_mdf_definition" .
123 " WHERE record_id = " .
$ilDB->quote($a_record_id,
"integer");
124 if ($a_only_searchable) {
125 $query .=
" AND searchable = " .
$ilDB->quote(1,
"integer");
127 $query .=
" ORDER BY position";
130 $field = self::getInstance(null,
$row[
"field_type"]);
131 $field->import(
$row);
132 $defs[
$row[
"field_id"]] = $field;
142 $ilDB = $DIC[
'ilDB'];
146 $query =
"SELECT amf.* FROM adv_md_record_objs aro" .
147 " JOIN adv_md_record amr ON aro.record_id = amr.record_id" .
148 " JOIN adv_mdf_definition amf ON aro.record_id = amf.record_id" .
149 " WHERE obj_type = " .
$ilDB->quote($a_obj_type,
'text');
150 if ((
bool) $a_active_only) {
151 $query .=
" AND active = " .
$ilDB->quote(1,
"integer");
153 $query .=
" ORDER BY aro.record_id,position";
156 $field = self::getInstance(null,
$row[
"field_type"]);
157 $field->import(
$row);
158 $defs[
$row[
"field_id"]] = $field;
173 $ilDB = $DIC[
'ilDB'];
175 $query =
"SELECT field_id, field_type FROM adv_mdf_definition" .
176 " WHERE import_id = " .
$ilDB->quote($a_import_id,
'text');
178 if (
$ilDB->numRows($set)) {
180 return self::getInstance(
$row[
"field_id"],
$row[
"field_type"]);
193 $ilDB = $DIC[
'ilDB'];
195 $field_ids = array();
197 $query =
"SELECT field_id FROM adv_md_record amr" .
198 " JOIN adv_mdf_definition amfd ON (amr.record_id = amfd.record_id)" .
199 " WHERE active = " .
$ilDB->quote(1,
"integer") .
200 " AND searchable = " .
$ilDB->quote(1,
"integer");
203 $field_ids[] =
$row[
"field_id"];
217 $group_def =
$factory->getDefinitionInstanceByType(
"Group");
218 foreach ($a_defs as
$def) {
219 $group_def->addElement($def->getFieldId(), $def->getADTDefinition());
221 $group =
$factory->getInstanceByDefinition($group_def);
224 foreach ($group->getElements() as $element_id => $element) {
225 $a_defs[$element_id]->setADT($element);
260 self::TYPE_SELECT_MULTI,
261 self::TYPE_EXTERNAL_LINK,
262 self::TYPE_INTERNAL_LINK
274 return in_array((
int)
$a_type, self::getValidTypes());
282 abstract public function getType();
292 if (self::isValidType(
$a_type)) {
294 self::TYPE_TEXT =>
"Text",
295 self::TYPE_SELECT =>
"Select",
296 self::TYPE_DATE =>
"Date",
297 self::TYPE_DATETIME =>
"DateTime",
298 self::TYPE_FLOAT =>
"Float",
299 self::TYPE_LOCATION =>
"Location",
300 self::TYPE_INTEGER =>
"Integer",
301 self::TYPE_SELECT_MULTI =>
"SelectMulti" ,
302 self::TYPE_EXTERNAL_LINK =>
'ExternalLink',
303 self::TYPE_INTERNAL_LINK =>
'InternalLink' 317 return "udf_type_" . strtolower(self::getTypeString($this->
getType()));
353 if (!$this->adt instanceof
ilADT) {
367 if (!$this->adt instanceof
ilADT) {
383 $this->field_id = (int) $a_id;
403 $this->record_id = (int) $a_id;
423 if ($a_id_string !== null) {
424 $a_id_string = trim($a_id_string);
426 $this->import_id = $a_id_string;
446 $this->position = (int) $a_pos;
466 if ($a_title !== null) {
467 $a_title = trim($a_title);
469 $this->title = $a_title;
489 if ($a_desc !== null) {
490 $a_desc = trim($a_desc);
492 $this->description = $a_desc;
536 $this->searchable = (bool) $a_status;
556 $this->required = (bool) $a_status;
646 $title->setRequired(
true);
650 $title->setDisabled(
true);
661 $desc->setDisabled(
true);
672 $check->setDisabled(
true);
743 if ($a_form->
getInput(
"searchable")) {
745 $hidden->setValue(1);
766 $ilDB = $DIC[
'ilDB'];
768 $sql =
"SELECT max(position) pos" .
769 " FROM adv_mdf_definition" .
771 $set =
$ilDB->query($sql);
772 if (
$ilDB->numRows($set)) {
773 $pos =
$ilDB->fetchAssoc($set);
774 return (
int) $pos[
"pos"];
788 return 'il_' . IL_INST_ID .
'_adv_md_field_' . $a_field_id;
799 "field_type" => array(
"integer", $this->
getType()),
800 "record_id" => array(
"integer", $this->
getRecordId()),
801 "import_id" => array(
"text", $this->
getImportId()),
802 "title" => array(
"text", $this->
getTitle()),
804 "position" => array(
"integer", $this->
getPosition()),
805 "searchable" => array(
"integer", $this->
isSearchable()),
806 "required" => array(
"integer", $this->
isRequired())
810 if (is_array(
$def)) {
811 $fields[
"field_values"] = array(
"text", serialize(
$def));
822 protected function import(array $a_data)
833 if ($a_data[
"field_values"]) {
841 protected function read($a_field_id)
845 $ilDB = $DIC[
'ilDB'];
847 if (!(
int) $a_field_id) {
851 $sql =
"SELECT * FROM adv_mdf_definition" .
852 " WHERE field_id = " .
$ilDB->quote($a_field_id,
"integer");
853 $set =
$ilDB->query($sql);
854 if (
$ilDB->numRows($set)) {
863 public function save($a_keep_pos =
false)
867 $ilDB = $DIC[
'ilDB'];
873 $next_id =
$ilDB->nextId(
"adv_mdf_definition");
886 $fields[
"field_id"] = array(
"integer", $next_id);
888 $ilDB->insert(
"adv_mdf_definition", $fields);
900 $ilDB = $DIC[
'ilDB'];
903 return $this->
save();
907 "adv_mdf_definition",
909 array(
"field_id" => array(
"integer", $this->
getFieldId()))
916 public function delete()
920 $ilDB = $DIC[
'ilDB'];
927 include_once(
"Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php");
930 $query =
"DELETE FROM adv_mdf_definition" .
952 'fieldType' => self::getTypeString($this->
getType())));
1075 $ilDB = $DIC[
'ilDB'];
1080 foreach ($a_records as $record) {
1081 if ($record[
"sub_type"] ==
"-") {
1082 $obj_ids[] = $record[
"obj_id"];
1086 $sql =
"SELECT obj_id,type" .
1087 " FROM object_data" .
1088 " WHERE " .
$ilDB->in(
"obj_id", $obj_ids,
"",
"integer") .
1089 " AND " .
$ilDB->in(
"type", $a_object_types,
"",
"text");
1090 $set =
$ilDB->query($sql);
1091 while (
$row =
$ilDB->fetchAssoc($set)) {
1100 include_once(
'Services/ADT/classes/ActiveRecord/class.ilADTActiveRecordByType.php');
1105 $element_id =
"loc";
1111 if (
sizeof($objects)) {
1113 foreach ($objects as $item) {
1114 if ($item[
"obj_id"] == $a_obj_id &&
1115 $item[
"sub_type"] == $sub_obj_type) {
1116 $res[] = $item[
"sub_id"];
1140 include_once(
'Services/ADT/classes/ActiveRecord/class.ilADTActiveRecordByType.php');
1144 if (
sizeof($objects)) {
1180 $class = get_class($this);
1181 $obj =
new $class();
1182 $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.
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
isFilterSupported()
Is search by filter supported.
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.
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)
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.
foreach($_POST as $key=> $value) $res
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.
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.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
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.