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

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

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

◆ addToForm()

ilADTTextSearchBridgeSingle::addToForm ( )

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

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

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

◆ getSerializedValue()

ilADTTextSearchBridgeSingle::getSerializedValue ( )

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

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

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

◆ getSQLCondition()

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

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

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

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

◆ importFromPost()

ilADTTextSearchBridgeSingle::importFromPost ( array  $a_post = null)

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

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

57  : bool
58  {
59  $post = $this->extractPostValues($a_post);
60 
61  if ($post && $this->shouldBeImportedFromPost($post)) {
62  if ($this->getForm() instanceof ilPropertyFormGUI) {
63  $item = $this->getForm()->getItemByPostVar($this->getElementId());
64  $item->setValue($post);
65  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
66  $this->table_filter_fields[$this->getElementId()]->setValue($post);
67  $this->writeFilter($post);
68  }
69 
70  $this->getADT()->setText($post);
71  } else {
72  $this->writeFilter();
73  $this->getADT()->setText();
74  }
75  return true;
76  }
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()

ilADTTextSearchBridgeSingle::isInCondition ( ilADT  $a_adt)

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

References ilADTSearchBridgeSingle\getADT().

129  : bool
130  {
131  if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
132  $search_term = strtolower(trim((string) $this->getADT()->getText()));
133  $text = strtolower(trim((string) $a_adt->getText()));
134  return str_contains($text, $search_term);
135  }
136  return false;
137  }
+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTTextSearchBridgeSingle::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

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

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

◆ loadFilter()

ilADTTextSearchBridgeSingle::loadFilter ( )

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

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

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

◆ setSerializedValue()

ilADTTextSearchBridgeSingle::setSerializedValue ( string  $a_value)

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

References ilADTSearchBridgeSingle\getADT().

149  : void
150  {
151  $a_value = unserialize($a_value);
152  if (is_array($a_value)) {
153  $this->getADT()->setText($a_value[0]);
154  }
155  }
+ 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

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

◆ SQL_LIKE_START

const ilADTTextSearchBridgeSingle::SQL_LIKE_START = 4

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

◆ SQL_STRICT

const ilADTTextSearchBridgeSingle::SQL_STRICT = 1

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


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