ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
24 protected function isValidADTDefinition(\ilADTDefinition $a_adt_def)
25 {
26 return $a_adt_def instanceof ilADTInternalLinkDefinition;
27 }
28
29
30 /*
31 * Add search property to form
32 */
33 public function addToForm()
34 {
35 $title = new ilTextInputGUI($this->getTitle(), $this->getElementId());
36 $title->setSize(255);
38 }
39
40
47 public function loadFilter()
48 {
49 $value = $this->readFilter();
50 if ($value !== null) {
51 $this->getADT()->setTargetRefId($value);
52 }
53 }
54
59 public function importFromPost(array $a_post = null)
60 {
61 $post = $this->extractPostValues($a_post);
62
63 if ($post && $this->shouldBeImportedFromPost($post)) {
64 $item = $this->getForm()->getItemByPostVar($this->getElementId());
65 $item->setValue($post);
66 $this->getADT()->setTargetRefId($post);
67 } else {
68 $this->getADT()->setTargetRefId(null);
69 }
70 }
71
77 public function getSQLCondition($a_element_id, $a_mode = self::SQL_LIKE, $a_value = null)
78 {
79 $db = $GLOBALS['DIC']->database();
80
81 if (!$a_value) {
82 if ($this->isNull() || !$this->isValid()) {
83 return;
84 }
85 $a_value = $this->getADT()->getTargetRefId();
86 }
87
88 $subselect = $a_element_id . ' IN ' .
89 '( select ref_id from object_reference obr join object_data obd on obr.obj_id = obd.obj_id ' .
90 'where ' . $db->like('title', 'text', $a_value . '%') . ' ' .
91 ')';
92 return $subselect;
93 }
94
100 public function isInCondition(ilADT $a_adt)
101 {
102 if ($this->isValidADT($a_adt)) {
103 return $this->getADT()->equals($a_adt);
104 }
105 // @todo throw exception
106 }
107
112 public function getSerializedValue()
113 {
114 if (!$this->isNull() && $this->isValid()) {
115 return serialize(array($this->getADT()->getTargetRefId()));
116 }
117 }
118
123 public function setSerializedValue($a_value)
124 {
125 $a_value = unserialize($a_value);
126 if (is_array($a_value)) {
127 $this->getADT()->setTargetRefId($a_value[0]);
128 }
129 }
130}
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.
ADT base class.
Definition: class.ilADT.php:12
This class represents a text property in a property form.