ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 @global ilTree $tree. 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

 $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 54 of file class.ilContainerSortingSettings.php.

55 {
56 global $ilDB;
57
58 $this->obj_id = $a_obj_id;
59 $this->db = $ilDB;
60
61 $this->read();
62 }
global $ilDB

References $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 210 of file class.ilContainerSortingSettings.php.

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

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

Referenced by ilContainer\cloneObject().

+ Here is the caller graph for this function:

◆ _exportContainerSortingSettings()

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

sorting XML-export for all container objects

Parameters
ilXmlWriter$xml
$obj_id

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

428 {
430
431 $attr = array();
432 switch($settings->getSortMode())
433 {
435 switch($settings->getSortNewItemsOrder())
436 {
438 $order = 'Activation';
439 break;
441 $order = 'Creation';
442 break;
444 $order = 'Title';
445 break;
446 }
447
448 $attr = array(
449 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
450 'position' => $settings->getSortNewItemsPosition() == ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM ? "Bottom" : "Top",
451 'order' => $order,
452 'type' => 'Manual'
453 );
454
455 break;
456
458 $attr = array(
459 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
460 'type' => 'Creation'
461 );
462 break;
463
465 $attr = array(
466 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
467 'type' => 'Title'
468 );
469 break;
471 $attr = array(
472 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
473 'type' => 'Activation'
474 );
475 break;
477 $attr = array(
478 'type' => 'Inherit'
479 );
480 }
481 $xml->xmlElement('Sort', $attr);
482 }
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
const SORT_DIRECTION_ASC
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)

References $obj_id, 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, ilContainer\SORT_TITLE, and ilXmlWriter\xmlElement().

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 490 of file class.ilContainerSortingSettings.php.

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

171 {
172 global $tree, $ilDB, $objDefinition;
173
174 // Try to read from table
175 $query = "SELECT * FROM container_sorting_set ".
176 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
177 $res = $ilDB->query($query);
178
179 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
180 {
181 if($row->sort_mode != ilContainer::SORT_INHERIT)
182 {
183 return $row->sort_mode;
184 }
185 }
187 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
static lookupSortModeFromParentContainer($a_obj_id)
Lookup sort mode from parent container.

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, lookupSortModeFromParentContainer(), and ilContainer\SORT_INHERIT.

Referenced by ilObjLinkResourceGUI\activateTabs(), ilContainerGUI\addStandardRow(), 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 146 of file class.ilContainerSortingSettings.php.

147 {
148 global $ilDB;
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(DB_FETCHMODE_OBJECT))
155 {
156 return $row->sort_mode;
157 }
159 }

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, and ilContainer\SORT_INHERIT.

◆ delete()

ilContainerSortingSettings::delete ( )

Delete setting.

Returns

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

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

References $ilDB, and $query.

◆ getInheritedSettings()

ilContainerSortingSettings::getInheritedSettings (   $a_container_obj_id)

Read inherited settings of course/group @global ilTree $tree.

Parameters
int$a_container_obj_id

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

112 {
113 global $tree;
114
115 if(!$a_container_obj_id)
116 {
117 $a_container_obj_id = $this->obj_id;
118 }
119
120 $ref_ids = ilObject::_getAllReferences($a_container_obj_id);
121 $ref_id = current($ref_ids);
122
123 if($cont_ref_id = $tree->checkForParentType($ref_id,'grp',true))
124 {
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 {
130 return $this->getInheritedSettings($parent_obj_id);
131 }
132 return $parent_settings;
133 }
134
135 if($cont_ref_id = $tree->checkForParentType($ref_id,'crs',true))
136 {
137 $parent_obj_id = ilObject::_lookupObjId($cont_ref_id);
138 $parent_settings = self::getInstanceByObjId($parent_obj_id);
139 return $parent_settings;
140 }
141 // no parent settings found => return current settings
142 return $this;
143 }
getInheritedSettings($a_container_obj_id)
Read inherited settings of course/group @global ilTree $tree.
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
$ref_id
Definition: sahs_server.php:39

References $obj_id, $ref_id, 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 69 of file class.ilContainerSortingSettings.php.

70 {
71 if(self::$instances[$a_obj_id])
72 {
73 return self::$instances[$a_obj_id];
74 }
75 return self::$instances[$a_obj_id] = new self($a_obj_id);
76 }

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 253 of file class.ilContainerSortingSettings.php.

254 {
255 return $this->sort_direction ? $this->sort_direction : ilContainer::SORT_DIRECTION_ASC;
256 }

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 244 of file class.ilContainerSortingSettings.php.

245 {
246 return $this->sort_mode ? $this->sort_mode : 0;
247 }

Referenced by loadEffectiveSettings().

+ Here is the caller graph for this function:

◆ getSortNewItemsOrder()

ilContainerSortingSettings::getSortNewItemsOrder ( )

GET new item order.

Returns
int position

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

References $new_items_order.

Referenced by ilContainerGUI\initManualSortingOptionForm().

+ Here is the caller graph for this function:

◆ getSortNewItemsPosition()

ilContainerSortingSettings::getSortNewItemsPosition ( )

GET new item position.

Returns
int position

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

References $new_items_position.

Referenced by ilContainerGUI\initManualSortingOptionForm().

+ Here is the caller graph for this function:

◆ loadEffectiveSettings()

ilContainerSortingSettings::loadEffectiveSettings ( )

Load inherited settings.

Returns
ilContainerSortingSettings

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

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

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 194 of file class.ilContainerSortingSettings.php.

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

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 373 of file class.ilContainerSortingSettings.php.

374 {
375 if(!$this->obj_id)
376 {
377 return TRUE;
378 }
379
380 $query = "SELECT * FROM container_sorting_set ".
381 "WHERE obj_id = ".$this->db->quote($this->obj_id ,'integer')." ";
382
383 $res = $this->db->query($query);
384 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
385 {
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 DB_FETCHMODE_OBJECT.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ save()

ilContainerSortingSettings::save ( )

save settings

@access public

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

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

References $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 292 of file class.ilContainerSortingSettings.php.

293 {
294 $this->sort_direction = (int) $a_direction;
295 }

◆ setSortMode()

ilContainerSortingSettings::setSortMode (   $a_mode)

set sort mode

@access public

Parameters
intMODE_TITLE | MODE_MANUAL | MODE_ACTIVATION

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

284 {
285 $this->sort_mode = (int) $a_mode;
286 }

◆ setSortNewItemsOrder()

ilContainerSortingSettings::setSortNewItemsOrder (   $a_order)

SET new item order.

Parameters
int$a_order

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

311 {
312 $this->new_items_order = (int)$a_order;
313 }

◆ setSortNewItemsPosition()

ilContainerSortingSettings::setSortNewItemsPosition (   $a_position)

SET new item position.

Parameters
int$a_position

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

302 {
303 $this->new_items_position = (int)$a_position;
304 }

◆ 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 $lng;
402
403 $lng->loadLanguageModule('crs');
404 switch($a_sort_mode)
405 {
407 return $lng->txt('crs_sort_activation');
408
410 return $lng->txt('crs_sort_manual');
411
413 return $lng->txt('crs_sort_title');
414
416 return $lng->txt('sorting_creation_header');
417 }
418 return '';
419 }
global $lng
Definition: privfeed.php:40

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

◆ update()

ilContainerSortingSettings::update ( )

Update.

@access public

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

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

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

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilContainerSortingSettings::$db
protected

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

◆ $instances

ilContainerSortingSettings::$instances = array()
staticprivate

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

◆ $new_items_order

ilContainerSortingSettings::$new_items_order = ilContainer::SORT_NEW_ITEMS_ORDER_TITLE
protected

Definition at line 43 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 42 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 41 of file class.ilContainerSortingSettings.php.

◆ $sort_mode

ilContainerSortingSettings::$sort_mode = ilContainer::SORT_TITLE
protected

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


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