ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilADTLocalizedTextSearchBridgeSingle Class Reference
+ Inheritance diagram for ilADTLocalizedTextSearchBridgeSingle:
+ Collaboration diagram for ilADTLocalizedTextSearchBridgeSingle:

Public Member Functions

 loadFilter ()
 
 addToForm ()
 
 importFromPost (array $a_post=null)
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 
 isInCondition (ilADT $a_adt)
 
 getSerializedValue ()
 
 setSerializedValue (string $a_value)
 
- Public Member Functions inherited from ilADTTextSearchBridgeSingle
 loadFilter ()
 
 addToForm ()
 
 importFromPost (array $a_post=null)
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 
 isInCondition (ilADT $a_adt)
 
 getSerializedValue ()
 
 setSerializedValue (string $a_value)
 
- Public Member Functions inherited from ilADTSearchBridgeSingle
 getADT ()
 Get ADT. More...
 
 isNull ()
 
 isValid ()
 
 validate ()
 
- 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...
 
 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)
 
- 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

◆ addToForm()

ilADTLocalizedTextSearchBridgeSingle::addToForm ( )

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

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

40  : void
41  {
42  $text = new ilTextInputGUI($this->getTitle(), $this->getElementId());
43  $text->setSize(20);
44  $text->setMaxLength(512);
45  $text->setSubmitFormOnEnter(true);
46 
47  $text->setValue($this->getADT()->getText());
48 
49  $this->addToParentElement($text);
50  }
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTLocalizedTextSearchBridgeSingle::getSerializedValue ( )

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

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

137  : string
138  {
139  if (!$this->isNull() && $this->isValid()) {
140  return serialize(array($this->getADT()->getText()));
141  }
142  return '';
143  }
+ Here is the call graph for this function:

◆ getSQLCondition()

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

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

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

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

◆ importFromPost()

ilADTLocalizedTextSearchBridgeSingle::importFromPost ( array  $a_post = null)

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

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

52  : bool
53  {
54  $post = $this->extractPostValues($a_post);
55 
56  if ($post && $this->shouldBeImportedFromPost($post)) {
57  if ($this->getForm() instanceof ilPropertyFormGUI) {
58  $item = $this->getForm()->getItemByPostVar($this->getElementId());
59  $item->setValue($post);
60  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
61  $this->table_filter_fields[$this->getElementId()]->setValue($post);
62  $this->writeFilter($post);
63  }
64  $this->getADT()->setText($post);
65  } else {
66  $this->writeFilter();
67  $this->getADT()->setText();
68  }
69  return true;
70  }
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)
$post
Definition: ltitoken.php:49
+ Here is the call graph for this function:

◆ isInCondition()

ilADTLocalizedTextSearchBridgeSingle::isInCondition ( ilADT  $a_adt)

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

References ilADTSearchBridgeSingle\getADT().

121  : bool
122  {
123  if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
124  foreach ($a_adt->getTranslations() as $language => $text) {
125  $search_term = strtolower(trim((string) $this->getADT()->getText()));
126  $text = strtolower(trim((string) $text));
127  if (str_contains($text, $search_term)) {
128  return true;
129  }
130  }
131  }
132  return false;
133  }
+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTLocalizedTextSearchBridgeSingle::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

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

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

◆ loadFilter()

ilADTLocalizedTextSearchBridgeSingle::loadFilter ( )

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

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

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)
+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTLocalizedTextSearchBridgeSingle::setSerializedValue ( string  $a_value)

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

References ilADTSearchBridgeSingle\getADT().

145  : void
146  {
147  $a_value = unserialize($a_value);
148  if (is_array($a_value)) {
149  $this->getADT()->setText($a_value[0]);
150  }
151  }
+ Here is the call graph for this function:

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