ILIAS  release_7 Revision v7.30-3-g800a261c036
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...
 
 importFromPost (array $a_post=null)
 Import values from (search) form request POST data. More...
 
 getSQLCondition ($a_element_id, $a_mode=self::SQL_LIKE, $a_value=null)
 
 isInCondition (ilADT $a_adt)
 Compare directly against ADT. More...
 
 getSerializedValue ()
 Get current value(s) in serialized form (for easy persisting) More...
 
 setSerializedValue ($a_value)
 Set current value(s) in serialized form (for easy persisting) More...
 
- Public Member Functions inherited from ilADTSearchBridgeSingle
 getADT ()
 Get ADT. More...
 
 isNull ()
 Is null ? More...
 
 isValid ()
 
 validate ()
 Validate current data. More...
 
- Public Member Functions inherited from ilADTSearchBridge
 __construct (ilADTDefinition $a_adt_def)
 Constructor. More...
 
 isNull ()
 Is null ? More...
 
 setForm (ilPropertyFormGUI $a_form)
 Set form. More...
 
 getForm ()
 Get form. More...
 
 setElementId ($a_value)
 Set element id (aka form field) More...
 
 getElementId ()
 Get element id. More...
 
 setTitle ($a_value)
 Set title (aka form field caption) More...
 
 getTitle ()
 Get title. More...
 
 getSearchColumn ()
 
 setTableGUI (ilTable2GUI $a_table)
 Set table gui (for filter mode) More...
 
 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)
 Import values from (search) form request POST data. More...
 
 validate ()
 Validate current data. More...
 
 getSQLCondition ($a_element_id)
 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 ($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 DEFAULT_SEARCH_COLUMN = 'value'
 

Protected Member Functions

 isValidADTDefinition (ilADTDefinition $a_adt_def)
 Check if given ADT definition is valid. More...
 
- Protected Member Functions inherited from ilADTSearchBridgeSingle
 setDefinition (ilADTDefinition $a_adt_def)
 Set ADT definition. More...
 
- Protected Member Functions inherited from ilADTSearchBridge
 isValidADTDefinition (ilADTDefinition $a_adt_def)
 Check if given ADT definition is valid. More...
 
 setDefinition (ilADTDefinition $a_adt_def)
 Set ADT definition. More...
 
 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 ($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
 $adt
 
- Protected Attributes inherited from ilADTSearchBridge
 $form
 
 $table_gui
 
 $table_filter_fields = []
 
 $id
 
 $title
 
 $info
 

Detailed Description

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

Member Function Documentation

◆ addToForm()

ilADTTextSearchBridgeSingle::addToForm ( )

Add ADT-specific fields to form.

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

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

31 {
32 $text = new ilTextInputGUI($this->getTitle(), $this->getElementId());
33 $text->setSize(20);
34 $text->setMaxLength(512);
35 $text->setSubmitFormOnEnter(true);
36
37 $text->setValue($this->getADT()->getText());
38
39 $this->addToParentElement($text);
40 }
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
getElementId()
Get element id.
This class represents a text property in a property form.

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

+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTTextSearchBridgeSingle::getSerializedValue ( )

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

Returns
string

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

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

129 {
130 if (!$this->isNull() && $this->isValid()) {
131 return serialize(array($this->getADT()->getText()));
132 }
133 }

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

+ Here is the call graph for this function:

◆ getSQLCondition()

ilADTTextSearchBridgeSingle::getSQLCondition (   $a_element_id,
  $a_mode = self::SQL_LIKE,
  $a_value = null 
)

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

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

66 {
67 global $DIC;
68
69 $ilDB = $DIC['ilDB'];
70
71 if (!$a_value) {
72 if ($this->isNull() || !$this->isValid()) {
73 return;
74 }
75 $a_value = $this->getADT()->getText();
76 }
77
78 switch ($a_mode) {
80 if (!is_array($a_value)) {
81 return $a_element_id . " = " . $ilDB->quote($a_value, "text");
82 } else {
83 return $ilDB->in($a_element_id, $a_value, "", "text");
84 }
85 break;
86
87 case self::SQL_LIKE:
88 if (!is_array($a_value)) {
89 return $ilDB->like($a_element_id, "text", "%" . $a_value . "%");
90 } else {
91 $tmp = array();
92 foreach ($a_value as $word) {
93 if ($word) {
94 $tmp[] = $ilDB->like($a_element_id, "text", "%" . $word . "%");
95 }
96 }
97 if (sizeof($tmp)) {
98 return "(" . implode(" OR ", $tmp) . ")";
99 }
100 }
101 break;
102
104 if (!is_array($a_value)) {
105 return $ilDB->like($a_element_id, "text", $a_value . "%");
106 }
107 break;
108
110 if (!is_array($a_value)) {
111 return $ilDB->like($a_element_id, "text", "%" . $a_value);
112 }
113 break;
114 }
115 }
global $DIC
Definition: goto.php:24
global $ilDB

References $DIC, $ilDB, 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)

Import values from (search) form request POST data.

Returns
bool

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

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

43 {
44 $post = $this->extractPostValues($a_post);
45
46 if ($post && $this->shouldBeImportedFromPost($post)) {
47 if ($this->getForm() instanceof ilPropertyFormGUI) {
48 $item = $this->getForm()->getItemByPostVar($this->getElementId());
49 $item->setValue($post);
50 } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
51 $this->table_filter_fields[$this->getElementId()]->setValue($post);
52 $this->writeFilter($post);
53 }
54
55 $this->getADT()->setText($post);
56 } else {
57 $this->writeFilter();
58 $this->getADT()->setText();
59 }
60 }
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.

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

Parameters
ilADT$a_adt
Returns
bool

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

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

118 {
119 if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
120 return $this->getADT()->equals($a_adt);
121 }
122 return false;
123 }

References ilADTSearchBridgeSingle\getADT().

+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTTextSearchBridgeSingle::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

Check if given ADT definition is valid.

:TODO: This could be avoided with type-specifc constructors :TODO: bridge base class?

Parameters
ilADTDefinition$a_adt_def

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

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

13 {
14 return ($a_adt_def instanceof ilADTTextDefinition);
15 }

◆ loadFilter()

ilADTTextSearchBridgeSingle::loadFilter ( )

Load filter value(s) into ADT.

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

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

20 {
21 $value = $this->readFilter();
22 if ($value !== null) {
23 $this->getADT()->setText($value);
24 }
25 }
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 (   $a_value)

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

Parameters
string

Reimplemented from ilADTSearchBridge.

Reimplemented in ilADTLocalizedTextSearchBridgeSingle.

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

136 {
137 $a_value = unserialize($a_value);
138 if (is_array($a_value)) {
139 $this->getADT()->setText($a_value[0]);
140 }
141 }

References ilADTSearchBridgeSingle\getADT().

+ Here is the call graph for this function:

Field Documentation

◆ SQL_LIKE

◆ 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: