ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilContainerSortingSettings Class Reference

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

+ Collaboration diagram for ilContainerSortingSettings:

Public Member Functions

 __construct (int $a_obj_id=0)
 
 loadEffectiveSettings ()
 Load inherited settings. More...
 
 getInheritedSettings (int $a_container_obj_id)
 
 getSortMode ()
 
 getSortDirection ()
 
 getSortNewItemsPosition ()
 
 getSortNewItemsOrder ()
 
 setSortMode (int $a_mode)
 
 setSortDirection (int $a_direction)
 
 setSortNewItemsPosition (int $a_position)
 
 setSortNewItemsOrder (int $a_order)
 
 update ()
 
 save ()
 
 delete ()
 

Static Public Member Functions

static getInstanceByObjId (int $a_obj_id)
 
static _readSortMode (int $a_obj_id)
 
static _lookupSortMode (int $a_obj_id)
 
static lookupSortModeFromParentContainer (int $a_obj_id)
 
static _cloneSettings (int $a_old_id, int $a_new_id)
 
static sortModeToString (int $a_sort_mode)
 Get string representation of sort mode. More...
 
static _exportContainerSortingSettings (ilXmlWriter $xml, int $obj_id)
 sorting XML-export for all container objects More...
 
static _importContainerSortingSettings (array $attibs, int $obj_id)
 sorting import for all container objects More...
 

Protected Member Functions

 read ()
 

Protected Attributes

ilTree $tree
 
int $obj_id
 
int $sort_mode = ilContainer::SORT_TITLE
 
int $sort_direction = ilContainer::SORT_DIRECTION_ASC
 
int $new_items_position = ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM
 
int $new_items_order = ilContainer::SORT_NEW_ITEMS_ORDER_TITLE
 
ilDBInterface $db
 

Static Private Attributes

static array $instances = []
 

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

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

Definition at line 22 of file class.ilContainerSortingSettings.php.

Constructor & Destructor Documentation

◆ __construct()

ilContainerSortingSettings::__construct ( int  $a_obj_id = 0)

Definition at line 34 of file class.ilContainerSortingSettings.php.

35 {
36 global $DIC;
37
38 $this->tree = $DIC->repositoryTree();
39 $ilDB = $DIC->database();
40
41 $this->obj_id = $a_obj_id;
42 $this->db = $ilDB;
43
44 $this->read();
45 }
global $DIC
Definition: shib_login.php:26

References $DIC, $ilDB, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ _cloneSettings()

static ilContainerSortingSettings::_cloneSettings ( int  $a_old_id,
int  $a_new_id 
)
static

Definition at line 148 of file class.ilContainerSortingSettings.php.

151 : void {
152 global $DIC;
153
154 $ilDB = $DIC->database();
155
156 $query = "SELECT sort_mode,sort_direction,new_items_position,new_items_order " .
157 "FROM container_sorting_set " .
158 "WHERE obj_id = " . $ilDB->quote($a_old_id, 'integer') . " ";
159 $res = $ilDB->query($query);
160 while ($row = $ilDB->fetchAssoc($res)) {
161 $query = "DELETE FROM container_sorting_set " .
162 "WHERE obj_id = " . $ilDB->quote($a_new_id) . " ";
163 $ilDB->manipulate($query);
164
165 $query = "INSERT INTO container_sorting_set " .
166 "(obj_id,sort_mode, sort_direction, new_items_position, new_items_order) " .
167 "VALUES( " .
168 $ilDB->quote($a_new_id, 'integer') . ", " .
169 $ilDB->quote($row["sort_mode"], 'integer') . ", " .
170 $ilDB->quote($row["sort_direction"], 'integer') . ', ' .
171 $ilDB->quote($row["new_items_position"], 'integer') . ', ' .
172 $ilDB->quote($row["new_items_order"], 'integer') . ' ' .
173 ")";
174 $ilDB->manipulate($query);
175 }
176 }
$res
Definition: ltiservices.php:69

References $ilDB.

◆ _exportContainerSortingSettings()

static ilContainerSortingSettings::_exportContainerSortingSettings ( ilXmlWriter  $xml,
int  $obj_id 
)
static

sorting XML-export for all container objects

Definition at line 304 of file class.ilContainerSortingSettings.php.

307 : void {
309
310 $attr = [];
311 switch ($settings->getSortMode()) {
313 $order = 'Title';
314 switch ($settings->getSortNewItemsOrder()) {
316 $order = 'Activation';
317 break;
319 $order = 'Creation';
320 break;
322 $order = 'Title';
323 break;
324 }
325
326 $attr = [
327 'direction' => $settings->getSortDirection() === ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
328 'position' => $settings->getSortNewItemsPosition() === ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM ? "Bottom" : "Top",
329 'order' => $order,
330 'type' => 'Manual'
331 ];
332
333 break;
334
336 $attr = [
337 'direction' => $settings->getSortDirection() === ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
338 'type' => 'Creation'
339 ];
340 break;
341
343 $attr = [
344 'direction' => $settings->getSortDirection() === ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
345 'type' => 'Title'
346 ];
347 break;
349 $attr = [
350 'direction' => $settings->getSortDirection() === ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
351 'type' => 'Activation'
352 ];
353 break;
355 $attr = [
356 'type' => 'Inherit'
357 ];
358 }
359 $xml->xmlElement('Sort', $attr);
360 }
const SORT_NEW_ITEMS_ORDER_ACTIVATION
const SORT_NEW_ITEMS_ORDER_TITLE
const SORT_NEW_ITEMS_ORDER_CREATION
const SORT_NEW_ITEMS_POSITION_BOTTOM
const SORT_DIRECTION_ASC
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)

References ilContainer\SORT_ACTIVATION, ilContainer\SORT_CREATION, ilContainer\SORT_DIRECTION_ASC, ilContainer\SORT_INHERIT, ilContainer\SORT_MANUAL, ilContainer\SORT_NEW_ITEMS_ORDER_ACTIVATION, ilContainer\SORT_NEW_ITEMS_ORDER_CREATION, ilContainer\SORT_NEW_ITEMS_ORDER_TITLE, ilContainer\SORT_NEW_ITEMS_POSITION_BOTTOM, and ilContainer\SORT_TITLE.

Referenced by ilCategoryXmlWriter\export(), ilCourseXMLWriter\start(), ilGroupXMLWriter\start(), and ilFolderXmlWriter\write().

+ Here is the caller graph for this function:

◆ _importContainerSortingSettings()

static ilContainerSortingSettings::_importContainerSortingSettings ( array  $attibs,
int  $obj_id 
)
static

sorting import for all container objects

Definition at line 365 of file class.ilContainerSortingSettings.php.

368 : void {
370
371 switch ($attibs['type'] ?? '') {
372 case 'Manual':
373 $settings->setSortMode(ilContainer::SORT_MANUAL);
374 break;
375 case 'Creation':
376 $settings->setSortMode(ilContainer::SORT_CREATION);
377 break;
378 case 'Title':
379 $settings->setSortMode(ilContainer::SORT_TITLE);
380 break;
381 case 'Activation':
382 $settings->setSortMode(ilContainer::SORT_ACTIVATION);
383 break;
384 }
385
386 switch ($attibs['direction'] ?? '') {
387 case 'ASC':
388 $settings->setSortDirection(ilContainer::SORT_DIRECTION_ASC);
389 break;
390 case 'DESC':
391 $settings->setSortDirection(ilContainer::SORT_DIRECTION_DESC);
392 break;
393 }
394
395 switch ($attibs['position'] ?? "") {
396 case "Top":
397 $settings->setSortNewItemsPosition(ilContainer::SORT_NEW_ITEMS_POSITION_TOP);
398 break;
399 case "Bottom":
400 $settings->setSortNewItemsPosition(ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM);
401 break;
402 }
403
404 switch ($attibs['order'] ?? "") {
405 case 'Creation':
406 $settings->setSortNewItemsOrder(ilContainer::SORT_NEW_ITEMS_ORDER_CREATION);
407 break;
408 case 'Title':
409 $settings->setSortNewItemsOrder(ilContainer::SORT_NEW_ITEMS_ORDER_TITLE);
410 break;
411 case 'Activation':
412 $settings->setSortNewItemsOrder(ilContainer::SORT_NEW_ITEMS_ORDER_ACTIVATION);
413 }
414
415 $settings->update();
416 }
const SORT_DIRECTION_DESC
const SORT_NEW_ITEMS_POSITION_TOP

References ilContainer\SORT_ACTIVATION, ilContainer\SORT_CREATION, ilContainer\SORT_MANUAL, and ilContainer\SORT_TITLE.

Referenced by ilCategoryXmlParser\handlerBeginTag(), ilCourseXMLParser\handlerBeginTag(), ilFolderXmlParser\handlerBeginTag(), and ilGroupXMLParser\initContainerSorting().

+ Here is the caller graph for this function:

◆ _lookupSortMode()

static ilContainerSortingSettings::_lookupSortMode ( int  $a_obj_id)
static

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

122 : int
123 {
124 global $DIC;
125
126 $ilDB = $DIC->database();
127
128 // Try to read from table
129 $query = "SELECT sort_mode FROM container_sorting_set " .
130 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
131 $res = $ilDB->query($query);
132
133 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
134 if ((int) $row->sort_mode !== ilContainer::SORT_INHERIT) {
135 return (int) $row->sort_mode;
136 }
137 }
139 }
static lookupSortModeFromParentContainer(int $a_obj_id)

References $DIC, $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, lookupSortModeFromParentContainer(), and ilContainer\SORT_INHERIT.

Referenced by ilObjLinkResourceGUI\activateTabs(), ILIAS\Container\Content\ItemPresentationManager\canOrderItems(), ilObjLinkResourceGUI\initFormSettings(), ilContainerGUI\isActiveItemOrdering(), ILIAS\Container\Content\ModeManager\isActiveItemOrdering(), ilWebLinkItemsContainer\lookupSortMode(), ilContainer\read(), ilObjCourse\read(), ilObjFolder\read(), ilObjGroup\read(), ilObjLinkResource\toXML(), and ilObjLinkResourceGUI\view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _readSortMode()

static ilContainerSortingSettings::_readSortMode ( int  $a_obj_id)
static

Definition at line 106 of file class.ilContainerSortingSettings.php.

106 : int
107 {
108 global $DIC;
109
110 $ilDB = $DIC->database();
111
112 $query = "SELECT sort_mode FROM container_sorting_set " .
113 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
114 $res = $ilDB->query($query);
115
116 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
117 return (int) $row->sort_mode;
118 }
120 }

References $DIC, $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, and ilContainer\SORT_INHERIT.

◆ delete()

ilContainerSortingSettings::delete ( )

Definition at line 248 of file class.ilContainerSortingSettings.php.

248 : void
249 {
251
252 $query = 'DELETE FROM container_sorting_set WHERE obj_id = ' . $ilDB->quote($this->obj_id, 'integer');
253 $ilDB->query($query);
254 }

References $ilDB.

◆ getInheritedSettings()

ilContainerSortingSettings::getInheritedSettings ( int  $a_container_obj_id)

Definition at line 75 of file class.ilContainerSortingSettings.php.

75 : self
76 {
78
79 if (!$a_container_obj_id) {
80 $a_container_obj_id = $this->obj_id;
81 }
82
83 $ref_ids = ilObject::_getAllReferences($a_container_obj_id);
84 $ref_id = current($ref_ids);
85
86 if ($cont_ref_id = $tree->checkForParentType($ref_id, 'grp', true)) {
87 $parent_obj_id = ilObject::_lookupObjId($cont_ref_id);
88 $parent_settings = self::getInstanceByObjId($parent_obj_id);
89
90 if ($parent_settings->getSortMode() === ilContainer::SORT_INHERIT) {
91 return $this->getInheritedSettings($parent_obj_id);
92 }
93 return $parent_settings;
94 }
95
96 if ($cont_ref_id = $tree->checkForParentType($ref_id, 'crs', true)) {
97 $parent_obj_id = ilObject::_lookupObjId($cont_ref_id);
98 $parent_settings = self::getInstanceByObjId($parent_obj_id);
99 return $parent_settings;
100 }
101 // no parent settings found => return current settings
102 return $this;
103 }
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
$ref_id
Definition: ltiauth.php:66

References $obj_id, $ref_id, $tree, ilObject\_getAllReferences(), ilObject\_lookupObjId(), ilTree\checkForParentType(), getInheritedSettings(), getInstanceByObjId(), and ilContainer\SORT_INHERIT.

Referenced by getInheritedSettings(), and loadEffectiveSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstanceByObjId()

static ilContainerSortingSettings::getInstanceByObjId ( int  $a_obj_id)
static

Definition at line 47 of file class.ilContainerSortingSettings.php.

47 : self
48 {
49 return self::$instances[$a_obj_id] ?? (self::$instances[$a_obj_id] = new self($a_obj_id));
50 }

Referenced by getInheritedSettings(), ilCourseXMLParser\handlerBeginTag(), lookupSortModeFromParentContainer(), and ilContainerSorting\read().

+ Here is the caller graph for this function:

◆ getSortDirection()

ilContainerSortingSettings::getSortDirection ( )

Definition at line 183 of file class.ilContainerSortingSettings.php.

183 : int
184 {
185 return $this->sort_direction ?: ilContainer::SORT_DIRECTION_ASC;
186 }

References ilContainer\SORT_DIRECTION_ASC.

◆ getSortMode()

ilContainerSortingSettings::getSortMode ( )

Definition at line 178 of file class.ilContainerSortingSettings.php.

178 : int
179 {
180 return $this->sort_mode ?: 0;
181 }

Referenced by loadEffectiveSettings().

+ Here is the caller graph for this function:

◆ getSortNewItemsOrder()

ilContainerSortingSettings::getSortNewItemsOrder ( )

Definition at line 193 of file class.ilContainerSortingSettings.php.

◆ getSortNewItemsPosition()

ilContainerSortingSettings::getSortNewItemsPosition ( )

Definition at line 188 of file class.ilContainerSortingSettings.php.

◆ loadEffectiveSettings()

ilContainerSortingSettings::loadEffectiveSettings ( )

Load inherited settings.

Definition at line 55 of file class.ilContainerSortingSettings.php.

55 : self
56 {
57 if ($this->getSortMode() !== ilContainer::SORT_INHERIT) {
58 return $this;
59 }
60
61 $effective_settings = $this->getInheritedSettings($this->obj_id);
62 $inherited = clone $this;
63
64 if ($effective_settings->getSortMode() === ilContainer::SORT_INHERIT) {
65 $inherited->setSortMode(ilContainer::SORT_TITLE);
66 } else {
67 $inherited->setSortMode($effective_settings->getSortMode());
68 $inherited->setSortNewItemsOrder($effective_settings->getSortNewItemsOrder());
69 $inherited->setSortNewItemsPosition($effective_settings->getSortNewItemsPosition());
70 }
71 return $inherited;
72 }

References getInheritedSettings(), getSortMode(), ilContainer\SORT_INHERIT, and ilContainer\SORT_TITLE.

Referenced by ilContainerSorting\read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupSortModeFromParentContainer()

static ilContainerSortingSettings::lookupSortModeFromParentContainer ( int  $a_obj_id)
static

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

141 : int
142 {
143 $settings = self::getInstanceByObjId($a_obj_id);
144 $inherited_settings = $settings->getInheritedSettings($a_obj_id);
145 return $inherited_settings->getSortMode();
146 }

References getInstanceByObjId().

Referenced by _lookupSortMode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilContainerSortingSettings::read ( )
protected

Definition at line 256 of file class.ilContainerSortingSettings.php.

256 : void
257 {
258 if (!$this->obj_id) {
259 return;
260 }
261
262 $query = "SELECT * FROM container_sorting_set " .
263 "WHERE obj_id = " . $this->db->quote($this->obj_id, 'integer') . " ";
264
265 $res = $this->db->query($query);
266 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
267 $this->sort_mode = (int) $row->sort_mode;
268 $this->sort_direction = (int) $row->sort_direction;
269 $this->new_items_position = (int) $row->new_items_position;
270 $this->new_items_order = (int) $row->new_items_order;
271 return;
272 }
273 }

References $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilContainerSortingSettings::save ( )

Definition at line 232 of file class.ilContainerSortingSettings.php.

232 : void
233 {
235
236 $query = "INSERT INTO container_sorting_set " .
237 "(obj_id,sort_mode, sort_direction, new_items_position, new_items_order) " .
238 "VALUES ( " .
239 $this->db->quote($this->obj_id, 'integer') . ", " .
240 $this->db->quote($this->sort_mode, 'integer') . ", " .
241 $this->db->quote($this->sort_direction, 'integer') . ', ' .
242 $this->db->quote($this->new_items_position, 'integer') . ', ' .
243 $this->db->quote($this->new_items_order, 'integer') . ' ' .
244 ")";
245 $ilDB->manipulate($query);
246 }
quote($value, string $type)

References $ilDB.

◆ setSortDirection()

ilContainerSortingSettings::setSortDirection ( int  $a_direction)

Definition at line 206 of file class.ilContainerSortingSettings.php.

206 : void
207 {
208 $this->sort_direction = $a_direction;
209 }

Referenced by ilContainerGUI\saveSortingSettings().

+ Here is the caller graph for this function:

◆ setSortMode()

ilContainerSortingSettings::setSortMode ( int  $a_mode)
Parameters
int$a_modeMODE_TITLE | MODE_MANUAL | MODE_ACTIVATION

Definition at line 201 of file class.ilContainerSortingSettings.php.

201 : void
202 {
203 $this->sort_mode = $a_mode;
204 }

Referenced by ilContainerGUI\saveSortingSettings().

+ Here is the caller graph for this function:

◆ setSortNewItemsOrder()

ilContainerSortingSettings::setSortNewItemsOrder ( int  $a_order)

Definition at line 216 of file class.ilContainerSortingSettings.php.

216 : void
217 {
218 $this->new_items_order = $a_order;
219 }

Referenced by ilContainerGUI\saveSortingSettings().

+ Here is the caller graph for this function:

◆ setSortNewItemsPosition()

ilContainerSortingSettings::setSortNewItemsPosition ( int  $a_position)

Definition at line 211 of file class.ilContainerSortingSettings.php.

211 : void
212 {
213 $this->new_items_position = $a_position;
214 }

Referenced by ilContainerGUI\saveSortingSettings().

+ Here is the caller graph for this function:

◆ sortModeToString()

static ilContainerSortingSettings::sortModeToString ( int  $a_sort_mode)
static

Get string representation of sort mode.

Definition at line 278 of file class.ilContainerSortingSettings.php.

278 : string
279 {
280 global $DIC;
281
282 $lng = $DIC->language();
283
284 $lng->loadLanguageModule('crs');
285 switch ($a_sort_mode) {
287 return $lng->txt('crs_sort_activation');
288
290 return $lng->txt('crs_sort_manual');
291
293 return $lng->txt('crs_sort_title');
294
296 return $lng->txt('sorting_creation_header');
297 }
298 return '';
299 }
global $lng
Definition: privfeed.php:31

References $DIC, $lng, ilContainer\SORT_ACTIVATION, ilContainer\SORT_CREATION, ilContainer\SORT_MANUAL, and ilContainer\SORT_TITLE.

◆ update()

ilContainerSortingSettings::update ( )

Definition at line 221 of file class.ilContainerSortingSettings.php.

221 : void
222 {
224
225 $query = "DELETE FROM container_sorting_set " .
226 "WHERE obj_id = " . $ilDB->quote($this->obj_id, 'integer');
227 $ilDB->manipulate($query);
228
229 $this->save();
230 }

References $ilDB.

Referenced by ilContainerGUI\saveSortingSettings().

+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilContainerSortingSettings::$db
protected

Definition at line 32 of file class.ilContainerSortingSettings.php.

◆ $instances

array ilContainerSortingSettings::$instances = []
staticprivate

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

◆ $new_items_order

int ilContainerSortingSettings::$new_items_order = ilContainer::SORT_NEW_ITEMS_ORDER_TITLE
protected

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

◆ $new_items_position

int ilContainerSortingSettings::$new_items_position = ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM
protected

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

◆ $obj_id

int ilContainerSortingSettings::$obj_id
protected

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

Referenced by getInheritedSettings().

◆ $sort_direction

int ilContainerSortingSettings::$sort_direction = ilContainer::SORT_DIRECTION_ASC
protected

Definition at line 29 of file class.ilContainerSortingSettings.php.

◆ $sort_mode

int ilContainerSortingSettings::$sort_mode = ilContainer::SORT_TITLE
protected

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

◆ $tree

ilTree ilContainerSortingSettings::$tree
protected

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

Referenced by getInheritedSettings().


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