ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables 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)
 Import from post. More...
 
 getSQLCondition ($a_element_id, $a_mode=self::SQL_LIKE, $a_value=null)
 Get sql condition. More...
 
 isInCondition (ilADT $a_adt)
 Is in condition. More...
 
 getSerializedValue ()
 get serialized value More...
 
 setSerializedValue ($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)
 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)
 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)
 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

external link search bridge

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

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

Member Function Documentation

◆ addToForm()

ilADTExternalLinkSearchBridgeSingle::addToForm ( )

add external link property to form

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

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

45  {
46  $def = $this->getADT()->getCopyOfDefinition();
47 
48  $url = new ilTextInputGUI($this->getTitle(), $this->getElementId());
49  $url->setSize(255);
50  $url->setValue($this->getADT()->getUrl());
51  $this->addToParentElement($url);
52  }
$url
getElementId()
Get element id.
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
type

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

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

154  {
155  if (!$this->isNull() && $this->isValid()) {
156  return serialize(array($this->getADT()->getUrl()));
157  }
158  }
+ Here is the call graph for this function:

◆ getSQLCondition()

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

Get sql condition.

Parameters
int$a_element_id
Returns
string

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

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

85  {
86  $db = $GLOBALS['DIC']->database();
87 
88  if (!$a_value) {
89  if ($this->isNull() || !$this->isValid()) {
90  return;
91  }
92  $a_value = $this->getADT()->getUrl();
93  }
94 
95  switch ($a_mode) {
96  case self::SQL_STRICT:
97  if (!is_array($a_value)) {
98  return $a_element_id . " = " . $db->quote($a_value, "text");
99  } else {
100  return $db->in($a_element_id, $a_value, "", "text");
101  }
102  break;
103 
104  case self::SQL_LIKE:
105  if (!is_array($a_value)) {
106  return $db->like($a_element_id, "text", "%" . $a_value . "%");
107  } else {
108  $tmp = array();
109  foreach ($a_value as $word) {
110  if ($word) {
111  $tmp[] = $db->like($a_element_id, "text", "%" . $word . "%");
112  }
113  }
114  if (sizeof($tmp)) {
115  return "(" . implode(" OR ", $tmp) . ")";
116  }
117  }
118  break;
119 
120  case self::SQL_LIKE_END:
121  if (!is_array($a_value)) {
122  return $db->like($a_element_id, "text", $a_value . "%");
123  }
124  break;
125 
126  case self::SQL_LIKE_START:
127  if (!is_array($a_value)) {
128  return $db->like($a_element_id, "text", "%" . $a_value);
129  }
130  break;
131  }
132  }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
+ Here is the call graph for this function:

◆ importFromPost()

ilADTExternalLinkSearchBridgeSingle::importFromPost ( array  $a_post = null)

Import from post.

Parameters
array$a_post

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

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

59  {
60  $post = $this->extractPostValues($a_post);
61 
62  if ($post && $this->shouldBeImportedFromPost($post)) {
63 
64  if ($this->getForm() instanceof ilPropertyFormGUI) {
65  $item = $this->getForm()->getItemByPostVar($this->getElementId());
66  $item->setValue($post);
67  $this->getADT()->setUrl($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  $this->getADT()->setUrl($post);
72  }
73  } else {
74  $this->getADT()->setUrl(null);
75  $this->writeFilter();
76  }
77  }
This class represents a property form user interface.
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)
getElementId()
Get element id.
+ 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 139 of file class.ilADTExternalLinkSearchBridgeSingle.php.

References ilADTSearchBridgeSingle\getADT().

140  {
141  if ($this->getADT()->getCopyOfDefinition()->isComparableTo($a_adt)) {
142  return
143  strcasecmp(trim($this->getADT()->getUrl()), trim($a_adt->getUrl())) === 0 ||
144  strcasecmp(trim($this->getADT()->getUrl()), trim($a_adt->getTitle())) === 0;
145  }
146  return false;
147  }
+ 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 24 of file class.ilADTExternalLinkSearchBridgeSingle.php.

25  {
26  return $a_adt_def instanceof ilADTExternalLinkDefinition;
27  }

◆ loadFilter()

ilADTExternalLinkSearchBridgeSingle::loadFilter ( )

Load from filter.

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

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

34  {
35  $value = $this->readFilter();
36  if ($value !== null) {
37  $this->getADT()->setUrl($value);
38  }
39  }
readFilter()
Load value(s) from filter store (in session)
+ Here is the call graph for this function:

◆ setSerializedValue()

ilADTExternalLinkSearchBridgeSingle::setSerializedValue (   $a_value)

Set serialized value.

Parameters
string$a_value

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

References ilADTSearchBridgeSingle\getADT().

165  {
166  $a_value = unserialize($a_value);
167  if (is_array($a_value)) {
168  $this->getADT()->setUrl($a_value[0]);
169  }
170  }
+ Here is the call graph for this function:

Field Documentation

◆ SQL_LIKE

const ilADTExternalLinkSearchBridgeSingle::SQL_LIKE = 2

◆ SQL_LIKE_END

const ilADTExternalLinkSearchBridgeSingle::SQL_LIKE_END = 3

◆ SQL_LIKE_START

const ilADTExternalLinkSearchBridgeSingle::SQL_LIKE_START = 4

◆ SQL_STRICT

const ilADTExternalLinkSearchBridgeSingle::SQL_STRICT = 1

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