ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilContainerSortingSettings Class Reference
+ Collaboration diagram for ilContainerSortingSettings:

Public Member Functions

 __construct ($a_obj_id=0)
 Constructor. More...
 
 loadEffectiveSettings ()
 Load inherited settings. More...
 
 getInheritedSettings ($a_container_obj_id)
 Read inherited settings of course/group. More...
 
 getSortMode ()
 get sort mode More...
 
 getSortDirection ()
 Get sort direction. More...
 
 getSortNewItemsPosition ()
 GET new item position. More...
 
 getSortNewItemsOrder ()
 GET new item order. More...
 
 setSortMode ($a_mode)
 set sort mode More...
 
 setSortDirection ($a_direction)
 Set sort direction. More...
 
 setSortNewItemsPosition ($a_position)
 SET new item position. More...
 
 setSortNewItemsOrder ($a_order)
 SET new item order. More...
 
 update ()
 Update. More...
 
 save ()
 save settings More...
 
 delete ()
 Delete setting. More...
 

Static Public Member Functions

static getInstanceByObjId ($a_obj_id)
 Get singleton instance. More...
 
static _readSortMode ($a_obj_id)
 
static _lookupSortMode ($a_obj_id)
 lookup sort mode More...
 
static lookupSortModeFromParentContainer ($a_obj_id)
 Lookup sort mode from parent container. More...
 
static _cloneSettings ($a_old_id, $a_new_id)
 Clone settings. More...
 
static sortModeToString ($a_sort_mode)
 get String representation of sort mode More...
 
static _exportContainerSortingSettings (ilXmlWriter $xml, $obj_id)
 sorting XML-export for all container objects More...
 
static _importContainerSortingSettings ($attibs, $obj_id)
 sorting import for all container objects More...
 

Protected Member Functions

 read ()
 read settings More...
 

Protected Attributes

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

Static Private Attributes

static $instances = array()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilContainerSortingSettings::__construct (   $a_obj_id = 0)

Constructor.

@access public

Parameters

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

60 {
61 global $DIC;
62
63 $this->tree = $DIC->repositoryTree();
64 $ilDB = $DIC->database();
65
66 $this->obj_id = $a_obj_id;
67 $this->db = $ilDB;
68
69 $this->read();
70 }
global $DIC
Definition: saml.php:7
global $ilDB

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

+ Here is the call graph for this function:

Member Function Documentation

◆ _cloneSettings()

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

Clone settings.

@access public

Parameters
intorig obj_id @þaram int new obj_id

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

212 {
213 global $DIC;
214
215 $ilDB = $DIC->database();
216
217 $query = "SELECT sort_mode,sort_direction,new_items_position,new_items_order " .
218 "FROM container_sorting_set " .
219 "WHERE obj_id = " . $ilDB->quote($a_old_id, 'integer') . " ";
220 $res = $ilDB->query($query);
221 while ($row = $ilDB->fetchAssoc($res)) {
222 $query = "DELETE FROM container_sorting_set " .
223 "WHERE obj_id = " . $ilDB->quote($a_new_id) . " ";
224 $ilDB->manipulate($query);
225
226 $query = "INSERT INTO container_sorting_set " .
227 "(obj_id,sort_mode, sort_direction, new_items_position, new_items_order) " .
228 "VALUES( " .
229 $ilDB->quote($a_new_id, 'integer') . ", " .
230 $ilDB->quote($row["sort_mode"], 'integer') . ", " .
231 $ilDB->quote($row["sort_direction"], 'integer') . ', ' .
232 $ilDB->quote($row["new_items_position"], 'integer') . ', ' .
233 $ilDB->quote($row["new_items_order"], 'integer') . ' ' .
234 ")";
235 $ilDB->manipulate($query);
236 }
237 return true;
238 }
$row
$query
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $query, $res, and $row.

◆ _exportContainerSortingSettings()

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

sorting XML-export for all container objects

Parameters
ilXmlWriter$xml
$obj_id

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

429 {
431
432 $attr = array();
433 switch ($settings->getSortMode()) {
435 switch ($settings->getSortNewItemsOrder()) {
437 $order = 'Activation';
438 break;
440 $order = 'Creation';
441 break;
443 $order = 'Title';
444 break;
445 }
446
447 $attr = array(
448 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
449 'position' => $settings->getSortNewItemsPosition() == ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM ? "Bottom" : "Top",
450 'order' => $order,
451 'type' => 'Manual'
452 );
453
454 break;
455
457 $attr = array(
458 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
459 'type' => 'Creation'
460 );
461 break;
462
464 $attr = array(
465 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
466 'type' => 'Title'
467 );
468 break;
470 $attr = array(
471 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
472 'type' => 'Activation'
473 );
474 break;
476 $attr = array(
477 'type' => 'Inherit'
478 );
479 }
480 $xml->xmlElement('Sort', $attr);
481 }
static getInstanceByObjId($a_obj_id)
Get singleton instance.
const SORT_NEW_ITEMS_ORDER_ACTIVATION
const SORT_NEW_ITEMS_ORDER_TITLE
const SORT_NEW_ITEMS_ORDER_CREATION
const SORT_NEW_ITEMS_POSITION_BOTTOM

References $obj_id, $xml, getInstanceByObjId(), 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 call graph for this function:
+ Here is the caller graph for this function:

◆ _importContainerSortingSettings()

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

sorting import for all container objects

Parameters
$attibsarray (type, direction, position, order)
$obj_id

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

490 {
492
493 switch ($attibs['type']) {
494 case 'Manual':
495 $settings->setSortMode(ilContainer::SORT_MANUAL);
496 break;
497 case 'Creation':
498 $settings->setSortMode(ilContainer::SORT_CREATION);
499 break;
500 case 'Title':
501 $settings->setSortMode(ilContainer::SORT_TITLE);
502 break;
503 case 'Activation':
504 $settings->setSortMode(ilContainer::SORT_ACTIVATION);
505 break;
506 }
507
508 switch ($attibs['direction']) {
509 case 'ASC':
510 $settings->setSortDirection(ilContainer::SORT_DIRECTION_ASC);
511 break;
512 case 'DESC':
513 $settings->setSortDirection(ilContainer::SORT_DIRECTION_DESC);
514 break;
515 }
516
517 switch ($attibs['position']) {
518 case "Top":
519 $settings->setSortNewItemsPosition(ilContainer::SORT_NEW_ITEMS_POSITION_TOP);
520 break;
521 case "Bottom":
522 $settings->setSortNewItemsPosition(ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM);
523 break;
524 }
525
526 switch ($attibs['order']) {
527 case 'Creation':
528 $settings->setSortNewItemsOrder(ilContainer::SORT_NEW_ITEMS_ORDER_CREATION);
529 break;
530 case 'Title':
531 $settings->setSortNewItemsOrder(ilContainer::SORT_NEW_ITEMS_ORDER_TITLE);
532 break;
533 case 'Activation':
534 $settings->setSortNewItemsOrder(ilContainer::SORT_NEW_ITEMS_ORDER_ACTIVATION);
535 }
536
537 $settings->update();
538 }
const SORT_NEW_ITEMS_POSITION_TOP

References $obj_id, getInstanceByObjId(), ilContainer\SORT_ACTIVATION, ilContainer\SORT_CREATION, ilContainer\SORT_DIRECTION_ASC, ilContainer\SORT_DIRECTION_DESC, 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, ilContainer\SORT_NEW_ITEMS_POSITION_TOP, and ilContainer\SORT_TITLE.

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

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

◆ _lookupSortMode()

static ilContainerSortingSettings::_lookupSortMode (   $a_obj_id)
static

lookup sort mode

@access public

Parameters
intobj_id

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

170 {
171 global $DIC;
172
173 $tree = $DIC->repositoryTree();
174 $ilDB = $DIC->database();
175 $objDefinition = $DIC["objDefinition"];
176
177 // Try to read from table
178 $query = "SELECT * FROM container_sorting_set " .
179 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
180 $res = $ilDB->query($query);
181
182 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
183 if ($row->sort_mode != ilContainer::SORT_INHERIT) {
184 return $row->sort_mode;
185 }
186 }
188 }
static lookupSortModeFromParentContainer($a_obj_id)
Lookup sort mode from parent container.

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

Referenced by ilObjLinkResourceGUI\activateTabs(), ilObjLinkResourceGUI\initFormSettings(), ilWebResourceLinkTableGUI\initSorting(), ilContainerGUI\isActiveItemOrdering(), ilObjCourse\read(), ilObjFolder\read(), ilObjGroup\read(), ilContainer\read(), ilLinkResourceItems\sortItems(), 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 (   $a_obj_id)
static

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

145 {
146 global $DIC;
147
148 $ilDB = $DIC->database();
149
150 $query = "SELECT * FROM container_sorting_set " .
151 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
152 $res = $ilDB->query($query);
153
154 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
155 return $row->sort_mode;
156 }
158 }

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

◆ delete()

ilContainerSortingSettings::delete ( )

Delete setting.

Returns

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

361 {
363
364 $query = 'DELETE FROM container_sorting_set WHERE obj_id = ' . $ilDB->quote($this->obj_id, 'integer');
365 $ilDB->query($query);
366 }

References $db, $ilDB, and $query.

◆ getInheritedSettings()

ilContainerSortingSettings::getInheritedSettings (   $a_container_obj_id)

Read inherited settings of course/group.

Parameters
int$a_container_obj_id

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

114 {
116
117 if (!$a_container_obj_id) {
118 $a_container_obj_id = $this->obj_id;
119 }
120
121 $ref_ids = ilObject::_getAllReferences($a_container_obj_id);
122 $ref_id = current($ref_ids);
123
124 if ($cont_ref_id = $tree->checkForParentType($ref_id, 'grp', true)) {
125 $parent_obj_id = ilObject::_lookupObjId($cont_ref_id);
126 $parent_settings = self::getInstanceByObjId($parent_obj_id);
127
128 if ($parent_settings->getSortMode() == ilContainer::SORT_INHERIT) {
129 return $this->getInheritedSettings($parent_obj_id);
130 }
131 return $parent_settings;
132 }
133
134 if ($cont_ref_id = $tree->checkForParentType($ref_id, 'crs', true)) {
135 $parent_obj_id = ilObject::_lookupObjId($cont_ref_id);
136 $parent_settings = self::getInstanceByObjId($parent_obj_id);
137 return $parent_settings;
138 }
139 // no parent settings found => return current settings
140 return $this;
141 }
getInheritedSettings($a_container_obj_id)
Read inherited settings of course/group.
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object

References $obj_id, $tree, ilObject\_getAllReferences(), ilObject\_lookupObjId(), 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 (   $a_obj_id)
static

Get singleton instance.

Parameters
type$a_obj_id
Returns
ilContainerSortingSettings

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

78 {
79 if (self::$instances[$a_obj_id]) {
80 return self::$instances[$a_obj_id];
81 }
82 return self::$instances[$a_obj_id] = new self($a_obj_id);
83 }

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

+ Here is the caller graph for this function:

◆ getSortDirection()

ilContainerSortingSettings::getSortDirection ( )

Get sort direction.

Returns
type

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

256 {
257 return $this->sort_direction ? $this->sort_direction : ilContainer::SORT_DIRECTION_ASC;
258 }

References ilContainer\SORT_DIRECTION_ASC.

Referenced by ilContainerGUI\initSortingDirectionForm().

+ Here is the caller graph for this function:

◆ getSortMode()

ilContainerSortingSettings::getSortMode ( )

get sort mode

@access public

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

247 {
248 return $this->sort_mode ? $this->sort_mode : 0;
249 }

Referenced by loadEffectiveSettings().

+ Here is the caller graph for this function:

◆ getSortNewItemsOrder()

ilContainerSortingSettings::getSortNewItemsOrder ( )

GET new item order.

Returns
int position

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

References $new_items_order.

◆ getSortNewItemsPosition()

ilContainerSortingSettings::getSortNewItemsPosition ( )

GET new item position.

Returns
int position

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

References $new_items_position.

◆ loadEffectiveSettings()

ilContainerSortingSettings::loadEffectiveSettings ( )

Load inherited settings.

Returns
ilContainerSortingSettings

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

90 {
91 if ($this->getSortMode() != ilContainer::SORT_INHERIT) {
92 return $this;
93 }
94
95 $effective_settings = $this->getInheritedSettings($this->obj_id);
96 $inherited = clone $this;
97
98 if ($effective_settings->getSortMode() == ilContainer::SORT_INHERIT) {
99 $inherited->setSortMode(ilContainer::SORT_TITLE);
100 } else {
101 $inherited->setSortMode($effective_settings->getSortMode());
102 $inherited->setSortNewItemsOrder($effective_settings->getSortNewItemsOrder());
103 $inherited->setSortNewItemsPosition($effective_settings->getSortNewItemsPosition());
104 }
105 return $inherited;
106 }

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

+ Here is the call graph for this function:

◆ lookupSortModeFromParentContainer()

static ilContainerSortingSettings::lookupSortModeFromParentContainer (   $a_obj_id)
static

Lookup sort mode from parent container.

Parameters
object$a_obj_id
Returns

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

196 {
197 $settings = self::getInstanceByObjId($a_obj_id);
198 $inherited_settings = $settings->getInheritedSettings($a_obj_id);
199 return $inherited_settings->getSortMode();
200 }

References getInstanceByObjId().

Referenced by _lookupSortMode(), and ilContainerGUI\initSortingForm().

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

◆ read()

ilContainerSortingSettings::read ( )
protected

read settings

@access private

Parameters

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

376 {
377 if (!$this->obj_id) {
378 return true;
379 }
380
381 $query = "SELECT * FROM container_sorting_set " .
382 "WHERE obj_id = " . $this->db->quote($this->obj_id, 'integer') . " ";
383
384 $res = $this->db->query($query);
385 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
386 $this->sort_mode = $row->sort_mode;
387 $this->sort_direction = $row->sort_direction;
388 $this->new_items_position = $row->new_items_position;
389 $this->new_items_order = $row->new_items_order;
390 return true;
391 }
392 }

References $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ save()

ilContainerSortingSettings::save ( )

save settings

@access public

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

341 {
343
344 $query = "INSERT INTO container_sorting_set " .
345 "(obj_id,sort_mode, sort_direction, new_items_position, new_items_order) " .
346 "VALUES ( " .
347 $this->db->quote($this->obj_id, 'integer') . ", " .
348 $this->db->quote($this->sort_mode, 'integer') . ", " .
349 $this->db->quote($this->sort_direction, 'integer') . ', ' .
350 $this->db->quote($this->new_items_position, 'integer') . ', ' .
351 $this->db->quote($this->new_items_order, 'integer') . ' ' .
352 ")";
353 $res = $ilDB->manipulate($query);
354 }

References $db, $ilDB, $query, and $res.

Referenced by update().

+ Here is the caller graph for this function:

◆ setSortDirection()

ilContainerSortingSettings::setSortDirection (   $a_direction)

Set sort direction.

Parameters
type$a_direction

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

295 {
296 $this->sort_direction = (int) $a_direction;
297 }

◆ setSortMode()

ilContainerSortingSettings::setSortMode (   $a_mode)

set sort mode

@access public

Parameters
intMODE_TITLE | MODE_MANUAL | MODE_ACTIVATION

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

286 {
287 $this->sort_mode = (int) $a_mode;
288 }

◆ setSortNewItemsOrder()

ilContainerSortingSettings::setSortNewItemsOrder (   $a_order)

SET new item order.

Parameters
int$a_order

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

313 {
314 $this->new_items_order = (int) $a_order;
315 }

◆ setSortNewItemsPosition()

ilContainerSortingSettings::setSortNewItemsPosition (   $a_position)

SET new item position.

Parameters
int$a_position

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

304 {
305 $this->new_items_position = (int) $a_position;
306 }

◆ sortModeToString()

static ilContainerSortingSettings::sortModeToString (   $a_sort_mode)
static

get String representation of sort mode

Parameters
int$a_sort_mode
Returns

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

400 {
401 global $DIC;
402
403 $lng = $DIC->language();
404
405 $lng->loadLanguageModule('crs');
406 switch ($a_sort_mode) {
408 return $lng->txt('crs_sort_activation');
409
411 return $lng->txt('crs_sort_manual');
412
414 return $lng->txt('crs_sort_title');
415
417 return $lng->txt('sorting_creation_header');
418 }
419 return '';
420 }
$lng

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

Referenced by ilContainerGUI\initSortingForm().

+ Here is the caller graph for this function:

◆ update()

ilContainerSortingSettings::update ( )

Update.

@access public

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

324 {
326
327 $query = "DELETE FROM container_sorting_set " .
328 "WHERE obj_id = " . $ilDB->quote($this->obj_id, 'integer');
329 $res = $ilDB->manipulate($query);
330
331 $this->save();
332 }

References $db, $ilDB, $query, $res, and save().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilContainerSortingSettings::$db
protected

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

Referenced by delete(), save(), and update().

◆ $instances

ilContainerSortingSettings::$instances = array()
staticprivate

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

◆ $new_items_order

ilContainerSortingSettings::$new_items_order = ilContainer::SORT_NEW_ITEMS_ORDER_TITLE
protected

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

Referenced by getSortNewItemsOrder().

◆ $new_items_position

ilContainerSortingSettings::$new_items_position = ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM
protected

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

Referenced by getSortNewItemsPosition().

◆ $obj_id

ilContainerSortingSettings::$obj_id
protected

◆ $sort_direction

ilContainerSortingSettings::$sort_direction = ilContainer::SORT_DIRECTION_ASC
protected

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

◆ $sort_mode

ilContainerSortingSettings::$sort_mode = ilContainer::SORT_TITLE
protected

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

◆ $tree

ilContainerSortingSettings::$tree
protected

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

Referenced by _lookupSortMode(), and getInheritedSettings().


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