ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilADTExternalLinkSearchBridgeSingle Class Reference

external link search bridge More...

+ Inheritance diagram for ilADTExternalLinkSearchBridgeSingle:
+ Collaboration diagram for ilADTExternalLinkSearchBridgeSingle:

Public Member Functions

 loadFilter ()
 Load from filter. More...
 
 addToForm ()
 add external link property to form More...
 
 importFromPost (?array $a_post=null)
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 Get sql condition. More...
 
 isInCondition (ilADT $a_adt)
 Is in condition. More...
 
 getSerializedValue ()
 get serialized value More...
 
 setSerializedValue (string $a_value)
 Set serialized value. More...
 
- Public Member Functions inherited from ilADTSearchBridgeSingle
 getADT ()
 Get ADT. More...
 
 isNull ()
 
 isValid ()
 
 validate ()
 Validate current data. More...
 
- Public Member Functions inherited from ilADTSearchBridge
 __construct (ilADTDefinition $a_adt_def)
 
 isNull ()
 
 setForm (ilPropertyFormGUI $a_form)
 
 getForm ()
 
 setElementId (string $a_value)
 
 getElementId ()
 
 setTitle (string $a_value)
 
 getTitle ()
 
 getSearchColumn ()
 
 setTableGUI (ilTable2GUI $a_table)
 
 getTableGUI ()
 Get table gui. More...
 
 loadFilter ()
 Load filter value(s) into ADT. More...
 
 addToForm ()
 Add ADT-specific fields to form. More...
 
 addToFilterForm ()
 Add ADT-specific fields to filter. More...
 
 importFromPost (?array $a_post=null)
 
 validate ()
 Validate current data. More...
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 Get SQL condition for current value(s) More...
 
 isInCondition (ilADT $a_adt)
 Compare directly against ADT. More...
 
 getSerializedValue ()
 Get current value(s) in serialized form (for easy persisting) More...
 
 setSerializedValue (string $a_value)
 Set current value(s) in serialized form (for easy persisting) More...
 

Protected Member Functions

 isValidADTDefinition (\ilADTDefinition $a_adt_def)
 Is valid type. More...
 
 buildSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 
- Protected Member Functions inherited from ilADTSearchBridgeSingle
 setDefinition (ilADTDefinition $a_adt_def)
 
- Protected Member Functions inherited from ilADTSearchBridge
 isValidADTDefinition (ilADTDefinition $a_adt_def)
 
 setDefinition (ilADTDefinition $a_adt_def)
 
 writeFilter ($a_value=null)
 Write value(s) to filter store (in session) More...
 
 readFilter ()
 Load value(s) from filter store (in session) More...
 
 addToParentElement (ilFormPropertyGUI $a_field)
 Add form field to parent element. More...
 
 addToElementId (string $a_add)
 Add sub-element. More...
 
 shouldBeImportedFromPost ($a_post)
 Check if incoming values should be imported at all. More...
 
 extractPostValues (?array $a_post=null)
 Extract data from (post) values. More...
 

Additional Inherited Members

- Data Fields inherited from ilADTSearchBridge
const SQL_STRICT = 1
 
const SQL_LIKE = 2
 
const SQL_LIKE_END = 3
 
const SQL_LIKE_START = 4
 
const DEFAULT_SEARCH_COLUMN = 'value'
 
- Protected Attributes inherited from ilADTSearchBridgeSingle
ilADT $adt
 
- Protected Attributes inherited from ilADTSearchBridge
ilPropertyFormGUI $form = null
 
ilTable2GUI $table_gui = null
 
array $table_filter_fields = []
 
string $id = ''
 
string $title = ''
 
string $info = ''
 
ilLanguage $lng
 
ilDBInterface $db
 
HttpServices $http
 

Detailed Description

external link search bridge

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 26 of file class.ilADTExternalLinkSearchBridgeSingle.php.

Member Function Documentation

◆ addToForm()

ilADTExternalLinkSearchBridgeSingle::addToForm ( )

add external link property to form

Reimplemented from ilADTSearchBridge.

Definition at line 52 of file class.ilADTExternalLinkSearchBridgeSingle.php.

52 : void
53 {
54 $url = new ilTextInputGUI($this->getTitle(), $this->getElementId());
55 $url->setSize(255);
56 $url->setValue($this->getADT()->getUrl());
58 }
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
This class represents a text property in a property form.
$url
Definition: shib_logout.php:68

References $url, ilADTSearchBridge\addToParentElement(), ilADTSearchBridgeSingle\getADT(), ilADTSearchBridge\getElementId(), and ilADTSearchBridge\getTitle().

+ Here is the call graph for this function:

◆ buildSQLCondition()

ilADTExternalLinkSearchBridgeSingle::buildSQLCondition ( string  $a_element_id,
int  $mode = self::SQL_LIKE,
array  $quotedWords = [] 
)
protected

Definition at line 98 of file class.ilADTExternalLinkSearchBridgeSingle.php.

98 : string
99 {
100 if (!$quotedWords) {
101 if ($this->isNull() || !$this->isValid()) {
102 return '';
103 }
104 $quotedWords = $this->getADT()->getUrl();
105 }
106
107 switch ($mode) {
108 case self::SQL_STRICT:
109 if (!is_array($quotedWords)) {
110 return $a_element_id . " = " . $this->db->quote($quotedWords, "text");
111 } else {
112 return $this->db->in($a_element_id, $quotedWords, false, "text");
113 }
114
115 // no break
116 case self::SQL_LIKE:
117 if (!is_array($quotedWords)) {
118 return $this->db->like($a_element_id, "text", "%" . $quotedWords . "%");
119 } else {
120 $tmp = array();
121 foreach ($quotedWords as $word) {
122 if ($word) {
123 $tmp[] = $this->db->like($a_element_id, "text", "%" . $word . "%");
124 }
125 }
126 if (count($tmp)) {
127 return "(" . implode(" OR ", $tmp) . ")";
128 }
129 }
130 break;
131
133 if (!is_array($quotedWords)) {
134 return $this->db->like($a_element_id, "text", $quotedWords . "%");
135 }
136 break;
137
139 if (!is_array($quotedWords)) {
140 return $this->db->like($a_element_id, "text", "%" . $quotedWords);
141 }
142 break;
143 }
144 return '';
145 }

References ilADTSearchBridgeSingle\getADT(), ilADTSearchBridgeSingle\isNull(), ilADTSearchBridgeSingle\isValid(), ilADTSearchBridge\SQL_LIKE, ilADTSearchBridge\SQL_LIKE_END, ilADTSearchBridge\SQL_LIKE_START, and ilADTSearchBridge\SQL_STRICT.

Referenced by getSQLCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSerializedValue()

ilADTExternalLinkSearchBridgeSingle::getSerializedValue ( )

get serialized value

Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 169 of file class.ilADTExternalLinkSearchBridgeSingle.php.

169 : string
170 {
171 if (!$this->isNull() && $this->isValid()) {
172 return serialize(array($this->getADT()->getUrl()));
173 }
174 return '';
175 }

References ilADTSearchBridgeSingle\getADT(), ilADTSearchBridgeSingle\isNull(), and ilADTSearchBridgeSingle\isValid().

+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTExternalLinkSearchBridgeSingle::getSQLCondition ( string  $a_element_id,
int  $mode = self::SQL_LIKE,
array  $quotedWords = [] 
)

Get sql condition.

Parameters
string$a_element_id
int$mode
array$quotedWords
Returns
string

Reimplemented from ilADTSearchBridge.

Definition at line 92 of file class.ilADTExternalLinkSearchBridgeSingle.php.

92 : string
93 {
94 return $this->buildSQLCondition($a_element_id, $mode, $quotedWords) . ' OR ' .
95 $this->buildSQLCondition('title', $mode, $quotedWords);
96 }
buildSQLCondition(string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])

References buildSQLCondition().

+ Here is the call graph for this function:

◆ importFromPost()

ilADTExternalLinkSearchBridgeSingle::importFromPost ( ?array  $a_post = null)
Todo:
make post required

Reimplemented from ilADTSearchBridge.

Definition at line 60 of file class.ilADTExternalLinkSearchBridgeSingle.php.

60 : bool
61 {
62 $post = $this->extractPostValues($a_post);
63
64 if ($post && $this->shouldBeImportedFromPost($post)) {
65 if ($this->getForm() instanceof ilPropertyFormGUI) {
66 $item = $this->getForm()->getItemByPostVar($this->getElementId());
67 $item->setValue($post);
68 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
69 $this->table_filter_fields[$this->getElementId()]->setValue($post);
70 $this->writeFilter($post);
71 }
72
73 $this->getADT()->setUrl($post);
74 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
75 $this->table_filter_fields[$this->getElementId()]->setValue($post);
76 $this->writeFilter($post);
77 $this->getADT()->setUrl($post);
78 } else {
79 $this->writeFilter();
80 $this->getADT()->setUrl(null);
81 }
82 return true;
83 }
extractPostValues(?array $a_post=null)
Extract data from (post) values.
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
writeFilter($a_value=null)
Write value(s) to filter store (in session)
This class represents a property form user interface.
$post
Definition: ltitoken.php:46

References $post, ilADTSearchBridge\extractPostValues(), ilADTSearchBridgeSingle\getADT(), ilADTSearchBridge\getElementId(), ilADTSearchBridge\getForm(), ilADTSearchBridge\shouldBeImportedFromPost(), and ilADTSearchBridge\writeFilter().

+ Here is the call graph for this function:

◆ isInCondition()

ilADTExternalLinkSearchBridgeSingle::isInCondition ( ilADT  $a_adt)

Is in condition.

Parameters
ilADT$a_adt
Returns
bool

Reimplemented from ilADTSearchBridge.

Definition at line 152 of file class.ilADTExternalLinkSearchBridgeSingle.php.

152 : bool
153 {
154 if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
155 $search_term = strtolower(trim((string) $this->getADT()->getUrl()));
156 $title = strtolower(trim((string) $a_adt->getTitle()));
157 $url = strtolower(trim((string) $a_adt->getUrl()));
158 return
159 str_contains($title, $search_term) ||
160 str_contains($url, $search_term);
161 }
162 return false;
163 }

References ilADTSearchBridge\$title, $url, and ilADTSearchBridgeSingle\getADT().

+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTExternalLinkSearchBridgeSingle::isValidADTDefinition ( \ilADTDefinition  $a_adt_def)
protected

Is valid type.

Parameters
ilADT$a_adt
Returns
bool

Definition at line 33 of file class.ilADTExternalLinkSearchBridgeSingle.php.

33 : bool
34 {
35 return $a_adt_def instanceof ilADTExternalLinkDefinition;
36 }

◆ loadFilter()

ilADTExternalLinkSearchBridgeSingle::loadFilter ( )

Load from filter.

Reimplemented from ilADTSearchBridge.

Definition at line 41 of file class.ilADTExternalLinkSearchBridgeSingle.php.

41 : void
42 {
43 $value = $this->readFilter();
44 if ($value !== null) {
45 $this->getADT()->setUrl($value);
46 }
47 }
readFilter()
Load value(s) from filter store (in session)

References ilADTSearchBridgeSingle\getADT(), and ilADTSearchBridge\readFilter().

+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTExternalLinkSearchBridgeSingle::setSerializedValue ( string  $a_value)

Set serialized value.

Parameters
string$a_value

Reimplemented from ilADTSearchBridge.

Definition at line 181 of file class.ilADTExternalLinkSearchBridgeSingle.php.

181 : void
182 {
183 $a_value = unserialize($a_value);
184 if (is_array($a_value)) {
185 $this->getADT()->setUrl($a_value[0]);
186 }
187 }

References ilADTSearchBridgeSingle\getADT().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: