ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilADTTextSearchBridgeSingle Class Reference
+ Inheritance diagram for ilADTTextSearchBridgeSingle:
+ Collaboration diagram for ilADTTextSearchBridgeSingle:

Public Member Functions

 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)
 
 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...
 
- 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...
 

Data Fields

const SQL_STRICT = 1
 
const SQL_LIKE = 2
 
const SQL_LIKE_END = 3
 
const SQL_LIKE_START = 4
 
- 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 Member Functions

 isValidADTDefinition (ilADTDefinition $a_adt_def)
 
 addTextInputToForm (bool $submit_on_enter)
 
- 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

- 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

Definition at line 21 of file class.ilADTTextSearchBridgeSingle.php.

Member Function Documentation

◆ addTextInputToForm()

ilADTTextSearchBridgeSingle::addTextInputToForm ( bool  $submit_on_enter)
protected

Definition at line 55 of file class.ilADTTextSearchBridgeSingle.php.

55 : void
56 {
57 $text = new ilTextInputGUI($this->getTitle(), $this->getElementId());
58 $text->setSize(20);
59 $text->setMaxLength(512);
60 $text->setSubmitFormOnEnter($submit_on_enter);
61
62 $text->setValue($this->getADT()->getText());
63
64 $this->addToParentElement($text);
65 }
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
This class represents a text property in a property form.

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

Referenced by ilADTLocalizedTextSearchBridgeSingle\addToFilterForm(), addToFilterForm(), ilADTLocalizedTextSearchBridgeSingle\addToForm(), and addToForm().

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

◆ addToFilterForm()

ilADTTextSearchBridgeSingle::addToFilterForm ( )

Add ADT-specific fields to filter.

This needs to be separated from other forms to avoid weird js interactions, but can probably be dropped when moving to KS (see #39225).

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

Definition at line 50 of file class.ilADTTextSearchBridgeSingle.php.

50 : void
51 {
52 $this->addTextInputToForm(false);
53 }

References addTextInputToForm().

+ Here is the call graph for this function:

◆ addToForm()

ilADTTextSearchBridgeSingle::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

Definition at line 45 of file class.ilADTTextSearchBridgeSingle.php.

45 : void
46 {
47 $this->addTextInputToForm(true);
48 }

References addTextInputToForm().

+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTTextSearchBridgeSingle::getSerializedValue ( )

Get current value(s) in serialized form (for easy persisting)

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

Definition at line 151 of file class.ilADTTextSearchBridgeSingle.php.

151 : string
152 {
153 if (!$this->isNull() && $this->isValid()) {
154 return serialize(array($this->getADT()->getText()));
155 }
156 return '';
157 }

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

+ Here is the call graph for this function:

◆ getSQLCondition()

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

Get SQL condition for current value(s)

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

Definition at line 90 of file class.ilADTTextSearchBridgeSingle.php.

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

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

+ Here is the call graph for this function:

◆ importFromPost()

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

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

Definition at line 67 of file class.ilADTTextSearchBridgeSingle.php.

67 : bool
68 {
69 $post = $this->extractPostValues($a_post);
70
71 if ($post && $this->shouldBeImportedFromPost($post)) {
72 if ($this->getForm() instanceof ilPropertyFormGUI) {
73 $item = $this->getForm()->getItemByPostVar($this->getElementId());
74 $item->setValue($post);
75 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
76 $this->table_filter_fields[$this->getElementId()]->setValue($post);
77 $this->writeFilter($post);
78 }
79
80 $this->getADT()->setText($post);
81 } else {
82 $this->writeFilter();
83 $this->getADT()->setText();
84 }
85 return true;
86 }
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()

ilADTTextSearchBridgeSingle::isInCondition ( ilADT  $a_adt)

Compare directly against ADT.

This is currently only used in ilAdvancedMDValues::queryForRecords, e.g. in the filter of mediapools. Other filter/search use cases use instead getSQLCondition.

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

Definition at line 139 of file class.ilADTTextSearchBridgeSingle.php.

139 : bool
140 {
141 if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
142 $search_term = strtolower(trim((string) $this->getADT()->getText()));
143 $text = strtolower(trim((string) $a_adt->getText()));
144 return str_contains($text, $search_term);
145 }
146 return false;
147 }

References ilADTSearchBridgeSingle\getADT().

+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTTextSearchBridgeSingle::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

Definition at line 28 of file class.ilADTTextSearchBridgeSingle.php.

28 : bool
29 {
30 return ($a_adt_def instanceof ilADTTextDefinition);
31 }

◆ loadFilter()

ilADTTextSearchBridgeSingle::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

Definition at line 35 of file class.ilADTTextSearchBridgeSingle.php.

35 : void
36 {
37 $value = $this->readFilter();
38 if ($value !== null) {
39 $this->getADT()->setText($value);
40 }
41 }
readFilter()
Load value(s) from filter store (in session)

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

+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTTextSearchBridgeSingle::setSerializedValue ( string  $a_value)

Set current value(s) in serialized form (for easy persisting)

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

Definition at line 159 of file class.ilADTTextSearchBridgeSingle.php.

159 : void
160 {
161 $a_value = unserialize($a_value);
162 if (is_array($a_value)) {
163 $this->getADT()->setText($a_value[0]);
164 }
165 }

References ilADTSearchBridgeSingle\getADT().

+ Here is the call graph for this function:

Field Documentation

◆ SQL_LIKE

const ilADTTextSearchBridgeSingle::SQL_LIKE = 2

◆ SQL_LIKE_END

const ilADTTextSearchBridgeSingle::SQL_LIKE_END = 3

◆ SQL_LIKE_START

const ilADTTextSearchBridgeSingle::SQL_LIKE_START = 4

◆ SQL_STRICT

const ilADTTextSearchBridgeSingle::SQL_STRICT = 1

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