ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilADTExternalLinkSearchBridgeSingle.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 ilADTExternalLinkDefinition;
27 }
28
29
33 public function loadFilter()
34 {
35 $value = $this->readFilter();
36 if ($value !== null) {
37 $this->getADT()->setUrl($value);
38 }
39 }
40
44 public function addToForm()
45 {
46 $def = $this->getADT()->getCopyOfDefinition();
47
48 $url = new ilTextInputGUI($this->getTitle(), $this->getElementId());
49 $url->setSize(255);
50 $url->setValue($this->getADT()->getUrl());
52 }
53
58 public function importFromPost(array $a_post = null)
59 {
60 $post = $this->extractPostValues($a_post);
61
62 if ($post && $this->shouldBeImportedFromPost($post)) {
63 $item = $this->getForm()->getItemByPostVar($this->getElementId());
64 $item->setValue($post);
65 $this->getADT()->setUrl($post);
66 } else {
67 $this->getADT()->setUrl();
68 }
69 }
70
76 public function getSQLCondition($a_element_id, $a_mode = self::SQL_LIKE, $a_value = null)
77 {
78 $db = $GLOBALS['DIC']->database();
79
80 if (!$a_value) {
81 if ($this->isNull() || !$this->isValid()) {
82 return;
83 }
84 $a_value = $this->getADT()->getUrl();
85 }
86
87 switch ($a_mode) {
89 if (!is_array($a_value)) {
90 return $a_element_id . " = " . $db->quote($a_value, "text");
91 } else {
92 return $db->in($a_element_id, $a_value, "", "text");
93 }
94 break;
95
96 case self::SQL_LIKE:
97 if (!is_array($a_value)) {
98 return $db->like($a_element_id, "text", "%" . $a_value . "%");
99 } else {
100 $tmp = array();
101 foreach ($a_value as $word) {
102 if ($word) {
103 $tmp[] = $db->like($a_element_id, "text", "%" . $word . "%");
104 }
105 }
106 if (sizeof($tmp)) {
107 return "(" . implode(" OR ", $tmp) . ")";
108 }
109 }
110 break;
111
113 if (!is_array($a_value)) {
114 return $db->like($a_element_id, "text", $a_value . "%");
115 }
116 break;
117
119 if (!is_array($a_value)) {
120 return $db->like($a_element_id, "text", "%" . $a_value);
121 }
122 break;
123 }
124 }
125
131 public function isInCondition(ilADT $a_adt)
132 {
133 if ($this->isValidADT($a_adt)) {
134 return $this->getADT()->equals($a_adt);
135 }
136 // @todo throw exception
137 }
138
143 public function getSerializedValue()
144 {
145 if (!$this->isNull() && $this->isValid()) {
146 return serialize(array($this->getADT()->getUrl()));
147 }
148 }
149
154 public function setSerializedValue($a_value)
155 {
156 $a_value = unserialize($a_value);
157 if (is_array($a_value)) {
158 $this->getADT()->setUrl($a_value[0]);
159 }
160 }
161}
An exception for terminatinating execution or to throw for unit testing.
ADT definition base class.
isValidADTDefinition(\ilADTDefinition $a_adt_def)
Is valid type.
getSQLCondition($a_element_id, $a_mode=self::SQL_LIKE, $a_value=null)
Get sql condition.
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.
$def
Definition: croninfo.php:21
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
$post
Definition: post.php:34
$url