ILIAS  trunk Revision v11.0_alpha-1871-gde1fee8db3d
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilADTExternalLinkSearchBridgeSingle Class Reference

external link search bridge More...

+ Inheritance diagram for ilADTExternalLinkSearchBridgeSingle:
+ Collaboration diagram for ilADTExternalLinkSearchBridgeSingle:

Public Member Functions

 loadFilter ()
 Load from filter. More...
 
 addToForm ()
 add external link property to form More...
 
 importFromPost (?array $a_post=null)
 
 getSQLCondition (string $a_element_id, int $mode=self::SQL_LIKE, array $quotedWords=[])
 Get sql condition. More...
 
 isInCondition (ilADT $a_adt)
 Is in condition. More...
 
 getSerializedValue ()
 get serialized value More...
 
 setSerializedValue (string $a_value)
 Set serialized value. More...
 
- 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...
 
 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)
 Is valid type. More...
 
- 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 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

external link search bridge

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Member Function Documentation

◆ addToForm()

ilADTExternalLinkSearchBridgeSingle::addToForm ( )

add external link property to form

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

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

52  : void
53  {
54  $url = new ilTextInputGUI($this->getTitle(), $this->getElementId());
55  $url->setSize(255);
56  $url->setValue($this->getADT()->getUrl());
57  $this->addToParentElement($url);
58  }
$url
Definition: shib_logout.php:66
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
+ Here is the call graph for this function:

◆ getSerializedValue()

ilADTExternalLinkSearchBridgeSingle::getSerializedValue ( )

get serialized value

Returns
string

Definition at line 163 of file class.ilADTExternalLinkSearchBridgeSingle.php.

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

163  : string
164  {
165  if (!$this->isNull() && $this->isValid()) {
166  return serialize(array($this->getADT()->getUrl()));
167  }
168  return '';
169  }
+ Here is the call graph for this function:

◆ getSQLCondition()

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

Get sql condition.

Parameters
string$a_element_id
int$mode
array$quotedWords
Returns
string

Definition at line 92 of file class.ilADTExternalLinkSearchBridgeSingle.php.

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

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

◆ importFromPost()

ilADTExternalLinkSearchBridgeSingle::importFromPost ( ?array  $a_post = null)

Definition at line 60 of file class.ilADTExternalLinkSearchBridgeSingle.php.

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

60  : bool
61  {
62  $post = $this->extractPostValues($a_post);
63 
64  if ($post && $this->shouldBeImportedFromPost($post)) {
65  if ($this->getForm() instanceof ilPropertyFormGUI) {
66  $item = $this->getForm()->getItemByPostVar($this->getElementId());
67  $item->setValue($post);
68  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
69  $this->table_filter_fields[$this->getElementId()]->setValue($post);
70  $this->writeFilter($post);
71  }
72 
73  $this->getADT()->setUrl($post);
74  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
75  $this->table_filter_fields[$this->getElementId()]->setValue($post);
76  $this->writeFilter($post);
77  $this->getADT()->setUrl($post);
78  } else {
79  $this->writeFilter();
80  $this->getADT()->setUrl(null);
81  }
82  return true;
83  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
shouldBeImportedFromPost($a_post)
Check if incoming values should be imported at all.
extractPostValues(?array $a_post=null)
Extract data from (post) values.
writeFilter($a_value=null)
Write value(s) to filter store (in session)
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:

◆ isInCondition()

ilADTExternalLinkSearchBridgeSingle::isInCondition ( ilADT  $a_adt)

Is in condition.

Parameters
ilADT$a_adt
Returns
bool

Definition at line 146 of file class.ilADTExternalLinkSearchBridgeSingle.php.

References ilADTSearchBridge\$title, $url, and ilADTSearchBridgeSingle\getADT().

146  : bool
147  {
148  if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
149  $search_term = strtolower(trim((string) $this->getADT()->getUrl()));
150  $title = strtolower(trim((string) $a_adt->getTitle()));
151  $url = strtolower(trim((string) $a_adt->getUrl()));
152  return
153  str_contains($title, $search_term) ||
154  str_contains($url, $search_term);
155  }
156  return false;
157  }
$url
Definition: shib_logout.php:66
+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTExternalLinkSearchBridgeSingle::isValidADTDefinition ( \ilADTDefinition  $a_adt_def)
protected

Is valid type.

Parameters
ilADT$a_adt
Returns
bool

Definition at line 33 of file class.ilADTExternalLinkSearchBridgeSingle.php.

33  : bool
34  {
35  return $a_adt_def instanceof ilADTExternalLinkDefinition;
36  }

◆ loadFilter()

ilADTExternalLinkSearchBridgeSingle::loadFilter ( )

Load from filter.

Definition at line 41 of file class.ilADTExternalLinkSearchBridgeSingle.php.

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

41  : void
42  {
43  $value = $this->readFilter();
44  if ($value !== null) {
45  $this->getADT()->setUrl($value);
46  }
47  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
readFilter()
Load value(s) from filter store (in session)
+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTExternalLinkSearchBridgeSingle::setSerializedValue ( string  $a_value)

Set serialized value.

Parameters
string$a_value

Definition at line 175 of file class.ilADTExternalLinkSearchBridgeSingle.php.

References ilADTSearchBridgeSingle\getADT().

175  : void
176  {
177  $a_value = unserialize($a_value);
178  if (is_array($a_value)) {
179  $this->getADT()->setUrl($a_value[0]);
180  }
181  }
+ Here is the call graph for this function:

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