ILIAS  trunk Revision v5.2.0beta1-34115-g3a2438be29
ilADTEnumSearchBridgeMulti Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilADTEnumSearchBridgeMulti:
+ Collaboration diagram for ilADTEnumSearchBridgeMulti:

Public Member Functions

 setSearchMode (int $a_mode)
 
 getSearchColumn ()
 
 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...
 
 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...
 

Data Fields

const ENUM_SEARCH_COLUMN = 'value_index'
 
const SEARCH_MODE_ALL = 1
 
const SEARCH_MODE_ANY = 2
 
- 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)
 
 convertADTDefinitionToMulti (ilADTDefinition $a_adt_def)
 
- Protected Member Functions inherited from ilADTSearchBridgeMulti
 setDefinition (ilADTDefinition $a_adt_def)
 
 convertADTDefinitionToMulti (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...
 

Protected Attributes

bool $multi_source
 
int $search_mode = self::SEARCH_MODE_ALL
 
- 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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilADTEnumSearchBridgeMulti

Definition at line 24 of file class.ilADTEnumSearchBridgeMulti.php.

Member Function Documentation

◆ addToForm()

ilADTEnumSearchBridgeMulti::addToForm ( )

Definition at line 76 of file class.ilADTEnumSearchBridgeMulti.php.

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

76  : void
77  {
78  $def = $this->getADT()->getCopyOfDefinition();
79 
80  $options = $def->getOptions();
81  asort($options); // ?
82 
83  $cbox = new ilCheckboxGroupInputGUI($this->getTitle(), $this->getElementId());
84  $cbox->setValue($this->getADT()->getSelections());
85 
86  foreach ($options as $value => $caption) {
87  $option = new ilCheckboxOption($caption, (string) $value);
88  $cbox->addOption($option);
89  }
90 
91  $this->addToParentElement($cbox);
92  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addToParentElement(ilFormPropertyGUI $a_field)
Add form field to parent element.
+ Here is the call graph for this function:

◆ convertADTDefinitionToMulti()

ilADTEnumSearchBridgeMulti::convertADTDefinitionToMulti ( ilADTDefinition  $a_adt_def)
protected

Definition at line 49 of file class.ilADTEnumSearchBridgeMulti.php.

References ilADTFactory\getInstance(), and ilADTDefinition\getType().

50  {
51  if ($a_adt_def->getType() == "Enum") {
52  $this->multi_source = false;
53  $def = ilADTFactory::getInstance()->getDefinitionInstanceByType("MultiEnum");
54  $def->setNumeric($a_adt_def->isNumeric());
55  $def->setOptions($a_adt_def->getOptions());
56  return $def;
57  } else {
58  $this->multi_source = true;
59  return $a_adt_def;
60  }
61  }
getType()
Get type (from class/instance)
ADT definition base class.
+ Here is the call graph for this function:

◆ getSearchColumn()

ilADTEnumSearchBridgeMulti::getSearchColumn ( )

Definition at line 38 of file class.ilADTEnumSearchBridgeMulti.php.

Referenced by getSQLCondition().

38  : string
39  {
40  return self::ENUM_SEARCH_COLUMN;
41  }
+ Here is the caller graph for this function:

◆ getSerializedValue()

ilADTEnumSearchBridgeMulti::getSerializedValue ( )

Definition at line 159 of file class.ilADTEnumSearchBridgeMulti.php.

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

159  : string
160  {
161  if (!$this->isNull() && $this->isValid()) {
162  return serialize($this->getADT()->getSelections());
163  }
164  return '';
165  }
+ Here is the call graph for this function:

◆ getSQLCondition()

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

Definition at line 122 of file class.ilADTEnumSearchBridgeMulti.php.

References ilADTSearchBridgeSingle\getADT(), getSearchColumn(), ilADTSearchBridgeSingle\isNull(), ilADTSearchBridgeSingle\isValid(), and ilDBConstants\T_INTEGER.

122  : string
123  {
124  if (!$this->isNull() && $this->isValid()) {
125  return $this->db->in(
126  $this->getSearchColumn(),
127  (array) $this->getADT()->getSelections(),
128  false,
130  );
131  }
132  return '';
133  }
+ Here is the call graph for this function:

◆ importFromPost()

ilADTEnumSearchBridgeMulti::importFromPost ( array  $a_post = null)

Definition at line 94 of file class.ilADTEnumSearchBridgeMulti.php.

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

94  : bool
95  {
96  $post = $this->extractPostValues($a_post);
97 
98  if ($post && $this->shouldBeImportedFromPost($post)) {
99  if ($this->getForm() instanceof ilPropertyFormGUI) {
100  $item = $this->getForm()->getItemByPostVar($this->getElementId());
101  $item->setValue($post);
102  } elseif (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
103  $this->table_filter_fields[$this->getElementId()]->setValue($post);
104  $this->writeFilter($post);
105  }
106 
107  if (is_array($post)) {
108  $this->getADT()->setSelections($post);
109  }
110  } else {
111  $this->getADT()->setSelections();
112  // BT 35593: multi enum filter should reset when nothing is selected
113  if (array_key_exists($this->getElementId(), $this->table_filter_fields)) {
114  $this->writeFilter();
115  }
116  }
117  return true;
118  }
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:47
+ Here is the call graph for this function:

◆ isInCondition()

ilADTEnumSearchBridgeMulti::isInCondition ( ilADT  $a_adt)

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

References ilADTSearchBridgeSingle\getADT().

135  : bool
136  {
137  assert($a_adt instanceof ilADTMultiEnum);
138 
139  $current = $this->getADT()->getSelections();
140  if (is_array($current) &&
141  count($current)) {
142  // #16827 / #17087
143  if ($this->search_mode == self::SEARCH_MODE_ANY) {
144  foreach ((array) $a_adt->getSelections() as $value) {
145  if (in_array($value, $current)) {
146  return true;
147  }
148  }
149  } else {
150  // #18028
151  return !count(array_diff($current, (array) $a_adt->getSelections()));
152  }
153  }
154  return false;
155  }
+ Here is the call graph for this function:

◆ isValidADTDefinition()

ilADTEnumSearchBridgeMulti::isValidADTDefinition ( ilADTDefinition  $a_adt_def)
protected

Definition at line 43 of file class.ilADTEnumSearchBridgeMulti.php.

43  : bool
44  {
45  return ($a_adt_def instanceof ilADTEnumDefinition ||
46  $a_adt_def instanceof ilADTMultiEnumDefinition);
47  }

◆ loadFilter()

ilADTEnumSearchBridgeMulti::loadFilter ( )

Definition at line 63 of file class.ilADTEnumSearchBridgeMulti.php.

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

63  : void
64  {
65  $value = $this->readFilter();
66  if ($value !== null) {
67  if (is_string($value)) {
68  $value = [$value];
69  }
70  $this->getADT()->setSelections($value);
71  }
72  }
readFilter()
Load value(s) from filter store (in session)
+ Here is the call graph for this function:

◆ setSearchMode()

ilADTEnumSearchBridgeMulti::setSearchMode ( int  $a_mode)

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

33  : void
34  {
35  $this->search_mode = $a_mode;
36  }

◆ setSerializedValue()

ilADTEnumSearchBridgeMulti::setSerializedValue ( string  $a_value)

Definition at line 167 of file class.ilADTEnumSearchBridgeMulti.php.

References ilADTSearchBridgeSingle\getADT().

167  : void
168  {
169  $a_value = unserialize($a_value);
170  if (is_array($a_value)) {
171  $this->getADT()->setSelections($a_value);
172  }
173  }
+ Here is the call graph for this function:

Field Documentation

◆ $multi_source

bool ilADTEnumSearchBridgeMulti::$multi_source
protected

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

◆ $search_mode

int ilADTEnumSearchBridgeMulti::$search_mode = self::SEARCH_MODE_ALL
protected

Definition at line 31 of file class.ilADTEnumSearchBridgeMulti.php.

◆ ENUM_SEARCH_COLUMN

const ilADTEnumSearchBridgeMulti::ENUM_SEARCH_COLUMN = 'value_index'

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

◆ SEARCH_MODE_ALL

const ilADTEnumSearchBridgeMulti::SEARCH_MODE_ALL = 1

Definition at line 27 of file class.ilADTEnumSearchBridgeMulti.php.

◆ SEARCH_MODE_ANY

const ilADTEnumSearchBridgeMulti::SEARCH_MODE_ANY = 2

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


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