ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilADTInternalLinkSearchBridgeSingle.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
13 const SQL_STRICT = 1;
14 const SQL_LIKE = 2;
15 const SQL_LIKE_END = 3;
16 const SQL_LIKE_START = 4;
17
18 private $title_query = '';
19
25 protected function isValidADTDefinition(\ilADTDefinition $a_adt_def)
26 {
27 return $a_adt_def instanceof ilADTInternalLinkDefinition;
28 }
29
30
31 /*
32 * Add search property to form
33 */
34 public function addToForm()
35 {
36 $title = new ilTextInputGUI($this->getTitle(), $this->getElementId());
37 $title->setSize(255);
39 }
40
41 public function setTitleQuery(string $query) : void
42 {
43 $this->title_query = $query;
44 }
45
46 public function getTitleQuery() : string
47 {
48 return $this->title_query;
49 }
50
57 public function loadFilter()
58 {
59 $value = $this->readFilter();
60 if ($value !== null) {
61 $this->getADT()->setTargetRefId(1);
62 $this->setTitleQuery($value);
63 }
64 }
65
70 public function importFromPost(array $a_post = null)
71 {
72 $post = $this->extractPostValues($a_post);
73
74 if ($post && $this->shouldBeImportedFromPost($post)) {
75 if ($this->getForm() instanceof ilPropertyFormGUI) {
76 $item = $this->getForm()->getItemByPostVar($this->getElementId());
77 $item->setValue($post);
78 $this->setTitleQuery($post);
79 $this->getADT()->setTargetRefId(1);
80 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
81 $this->table_filter_fields[$this->getElementId()]->setValue($post);
82 $this->writeFilter($post);
83 $this->setTitleQuery($post);
84 $this->getADT()->setTargetRefId(1);
85 }
86 } else {
87 $this->writeFilter();
88 $this->setTitleQuery('');
89 $this->getADT()->setTargetRefId(null);
90 }
91 return true;
92 }
93
99 public function getSQLCondition($a_element_id, $a_mode = self::SQL_LIKE, $a_value = null)
100 {
101 $db = $GLOBALS['DIC']->database();
102
103 if (!$a_value) {
104 if ($this->isNull() || !$this->isValid()) {
105 return;
106 }
107 $a_value = $this->getADT()->getTargetRefId();
108 }
109
110 $subselect = $a_element_id . ' IN ' .
111 '( select ref_id from object_reference obr join object_data obd on obr.obj_id = obd.obj_id ' .
112 'where ' . $db->like('title', 'text', $a_value . '%') . ' ' .
113 ')';
114 return $subselect;
115 }
116
122 public function isInCondition(ilADT $a_adt)
123 {
124 if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
125 $ref_id = $a_adt->getTargetRefId();
127 return strcasecmp($title, $this->getTitleQuery()) === 0;
128 }
129 return false;
130 }
131
136 public function getSerializedValue()
137 {
138 if (!$this->isNull() && $this->isValid()) {
139 return serialize(array($this->getADT()->getTargetRefId()));
140 }
141 }
142
147 public function setSerializedValue($a_value)
148 {
149 $a_value = unserialize($a_value);
150 if (is_array($a_value)) {
151 $this->getADT()->setTargetRefId($a_value[0]);
152 }
153 }
154}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
ADT definition base class.
getSQLCondition($a_element_id, $a_mode=self::SQL_LIKE, $a_value=null)
Get sql condition.
isValidADTDefinition(\ilADTDefinition $a_adt_def)
Is valid type.
readFilter()
Load value(s) from filter store (in session)
extractPostValues(array $a_post=null)
Extract data from (post) values.
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
getElementId()
Get element id.
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
writeFilter($a_value=null)
Write value(s) to filter store (in session)
ADT base class.
Definition: class.ilADT.php:12
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
This class represents a property form user interface.
This class represents a text property in a property form.
$query