ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAdvancedMDFieldDefinitionInternalLink.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
11 {
16  public function getType()
17  {
18  return self::TYPE_INTERNAL_LINK;
19  }
20 
21 
26  protected function initADTDefinition()
27  {
28  return ilADTFactory::getInstance()->getDefinitionInstanceByType("InternalLink");
29  }
30 
35  public function getValueForXML(\ilADT $element)
36  {
37  $type = ilObject::_lookupType($element->getTargetRefId(), true);
38 
39  if ($element->getTargetRefId() && strlen($type)) {
40  return 'il_' . IL_INST_ID . '_' . $type . '_' . $element->getTargetRefId();
41  }
42  return '';
43  }
44 
49  public function importValueFromXML($a_cdata)
50  {
51  $parsed_import_id = ilUtil::parseImportId($a_cdata);
52 
53  if (
54  (strcmp($parsed_import_id['inst_id'], IL_INST_ID) == 0) &&
55  ilObject::_exists($parsed_import_id['id'], true, $parsed_import_id['type'])
56  ) {
57  $this->getADT()->setTargetRefId($parsed_import_id['id']);
58  }
59  }
60 
61 
72  public function searchObjects(ilADTSearchBridge $a_adt_search, ilQueryParser $a_parser, array $a_object_types, $a_locate, $a_search_type)
73  {
75  if ($condition) {
76  $objects = ilADTActiveRecordByType::find("adv_md_values", $this->getADT()->getType(), $this->getFieldId(), $condition, $a_locate);
77  if (sizeof($objects)) {
78  return $this->parseSearchObjects($objects, $a_object_types);
79  }
80  return array();
81  }
82  }
83 
88  public function getLuceneSearchString($a_value)
89  {
90  $db = $GLOBALS['DIC']->database();
91 
92  $query = 'select ref_id from object_reference obr join object_data obd on obr.obj_id = obd.obj_id ' .
93  'where ' . $db->like('title', 'text', $a_value . '%');
94  $res = $db->query($query);
95  $ref_ids = [];
96  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
97  $ref_ids[] = $row->ref_id;
98  }
99  return $ref_ids;
100  }
101 }
parseSearchObjects(array $a_records, array $a_object_types)
Add object-data needed for global search to AMD search results.
$type
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static parseImportId($a_import_id)
Parse an ilias import id Typically of type il_[IL_INST_ID]_[OBJ_TYPE]_[OBJ_ID] returns array( &#39;orig&#39; ...
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static getInstance()
Get singleton.
ADT base class.
Definition: class.ilADT.php:11
static find($a_table, $a_type, $a_field_id, $a_condition, $a_additional_fields=null)
Find entries.
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
ADT search bridge base class.
getSQLCondition($a_element_id)
Get SQL condition for current value(s)