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

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

Protected Member Functions

 isValidADTDefinition (ilADTDefinition $a_adt_def)
 
- Protected Member Functions inherited from ilADTTextSearchBridgeSingle
 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

- Data Fields inherited from ilADTTextSearchBridgeSingle
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 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

Member Function Documentation

◆ addToFilterForm()

ilADTLocalizedTextSearchBridgeSingle::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 ilADTTextSearchBridgeSingle.

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

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

References ilADTTextSearchBridgeSingle\addTextInputToForm().

+ Here is the call graph for this function:

◆ addToForm()

ilADTLocalizedTextSearchBridgeSingle::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTTextSearchBridgeSingle.

Definition at line 40 of file class.ilADTLocalizedTextSearchBridgeSingle.php.

40 : void
41 {
42 $this->addTextInputToForm(true);
43 }

References ilADTTextSearchBridgeSingle\addTextInputToForm().

+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTLocalizedTextSearchBridgeSingle::getSerializedValue ( )

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

Reimplemented from ilADTTextSearchBridgeSingle.

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

139 : string
140 {
141 if (!$this->isNull() && $this->isValid()) {
142 return serialize(array($this->getADT()->getText()));
143 }
144 return '';
145 }

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

+ Here is the call graph for this function:

◆ getSQLCondition()

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

Get SQL condition for current value(s)

Reimplemented from ilADTTextSearchBridgeSingle.

Definition at line 70 of file class.ilADTLocalizedTextSearchBridgeSingle.php.

70 : string
71 {
72 if (!$quotedWords) {
73 if ($this->isNull() || !$this->isValid()) {
74 return '';
75 }
76 $quotedWords = $this->getADT()->getText();
77 }
78
79 switch ($mode) {
81 if (!is_array($quotedWords)) {
82 return $a_element_id . " = " . $this->db->quote($quotedWords, "text");
83 } else {
84 return $this->db->in($a_element_id, $quotedWords, false, "text");
85 }
86
87 // no break
88 case self::SQL_LIKE:
89 if (!is_array($quotedWords)) {
90 return $this->db->like($a_element_id, "text", "%" . $quotedWords . "%");
91 } else {
92 $tmp = array();
93 foreach ($quotedWords as $word) {
94 if ($word) {
95 $tmp[] = $this->db->like($a_element_id, "text", "%" . $word . "%");
96 }
97 }
98 if (count($tmp)) {
99 return "(" . implode(" OR ", $tmp) . ")";
100 }
101 }
102 break;
103
105 if (!is_array($quotedWords)) {
106 return $this->db->like($a_element_id, "text", $quotedWords . "%");
107 }
108 break;
109
111 if (!is_array($quotedWords)) {
112 return $this->db->like($a_element_id, "text", "%" . $quotedWords);
113 }
114 break;
115 }
116 return '';
117 }

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

+ Here is the call graph for this function:

◆ importFromPost()

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

Reimplemented from ilADTTextSearchBridgeSingle.

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

50 : bool
51 {
52 $post = $this->extractPostValues($a_post);
53
54 if ($post && $this->shouldBeImportedFromPost($post)) {
55 if ($this->getForm() instanceof ilPropertyFormGUI) {
56 $item = $this->getForm()->getItemByPostVar($this->getElementId());
57 $item->setValue($post);
58 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
59 $this->table_filter_fields[$this->getElementId()]->setValue($post);
60 $this->writeFilter($post);
61 }
62 $this->getADT()->setText($post);
63 } else {
64 $this->writeFilter();
65 $this->getADT()->setText();
66 }
67 return true;
68 }
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()

ilADTLocalizedTextSearchBridgeSingle::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 ilADTTextSearchBridgeSingle.

Definition at line 119 of file class.ilADTLocalizedTextSearchBridgeSingle.php.

119 : bool
120 {
121 if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
122 $relevant_translation = $a_adt->getCopyOfDefinition()->getMultilingualValueSupport() ?
123 $a_adt->getTranslations() :
124 [$a_adt->getTextForLanguage($a_adt->getCopyOfDefinition()->getDefaultLanguage())];
125
126 foreach ($relevant_translation as $text) {
127 $search_term = strtolower(trim((string) $this->getADT()->getText()));
128 $text = strtolower(trim((string) $text));
129 if (str_contains($text, $search_term)) {
130 return true;
131 }
132 }
133 }
134 return false;
135 }
getCopyOfDefinition()
Get copy of definition.

References ilADTSearchBridgeSingle\getADT(), and ilADT\getCopyOfDefinition().

+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTLocalizedTextSearchBridgeSingle::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

Reimplemented from ilADTTextSearchBridgeSingle.

Definition at line 23 of file class.ilADTLocalizedTextSearchBridgeSingle.php.

23 : bool
24 {
25 return ($a_adt_def instanceof ilADTLocalizedTextDefinition);
26 }

◆ loadFilter()

ilADTLocalizedTextSearchBridgeSingle::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTTextSearchBridgeSingle.

Definition at line 30 of file class.ilADTLocalizedTextSearchBridgeSingle.php.

30 : void
31 {
32 $value = $this->readFilter();
33 if ($value !== null) {
34 $this->getADT()->setText($value);
35 }
36 }
readFilter()
Load value(s) from filter store (in session)

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

+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTLocalizedTextSearchBridgeSingle::setSerializedValue ( string  $a_value)

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

Reimplemented from ilADTTextSearchBridgeSingle.

Definition at line 147 of file class.ilADTLocalizedTextSearchBridgeSingle.php.

147 : void
148 {
149 $a_value = unserialize($a_value);
150 if (is_array($a_value)) {
151 $this->getADT()->setText($a_value[0]);
152 }
153 }

References ilADTSearchBridgeSingle\getADT().

+ Here is the call graph for this function:

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