ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilContainerSortingSettings Class Reference
+ Collaboration diagram for ilContainerSortingSettings:

Public Member Functions

 __construct ($a_obj_id=0)
 Constructor. 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 170 of file class.ilContainerSortingSettings.php.

171 {
172 global $ilDB;
173
174 $query = "SELECT sort_mode,sort_direction,new_items_position,new_items_order ".
175 "FROM container_sorting_set ".
176 "WHERE obj_id = ".$ilDB->quote($a_old_id ,'integer')." ";
177 $res = $ilDB->query($query);
178 while($row = $ilDB->fetchAssoc($res))
179 {
180 $query = "DELETE FROM container_sorting_set ".
181 "WHERE obj_id = ".$ilDB->quote($a_new_id)." ";
182 $ilDB->manipulate($query);
183
184 $query = "INSERT INTO container_sorting_set ".
185 "(obj_id,sort_mode, sort_direction, new_items_position, new_items_order) ".
186 "VALUES( ".
187 $ilDB->quote($a_new_id ,'integer').", ".
188 $ilDB->quote($row["sort_mode"],'integer').", ".
189 $ilDB->quote($row["sort_direction"],'integer').', '.
190 $ilDB->quote($row["new_items_position"],'integer').', '.
191 $ilDB->quote($row["new_items_order"],'integer').' '.
192 ")";
193 $ilDB->manipulate($query);
194 }
195 return true;
196 }

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

388 {
390
391 $attr = array();
392 switch($settings->getSortMode())
393 {
395 switch($settings->getSortNewItemsOrder())
396 {
398 $order = 'Activation';
399 break;
401 $order = 'Creation';
402 break;
404 $order = 'Title';
405 break;
406 }
407
408 $attr = array(
409 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
410 'position' => $settings->getSortNewItemsPosition() == ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM ? "Bottom" : "Top",
411 'order' => $order,
412 'type' => 'Manual'
413 );
414
415 break;
416
418 $attr = array(
419 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
420 'type' => 'Creation'
421 );
422 break;
423
425 $attr = array(
426 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
427 'type' => 'Title'
428 );
429 break;
431 $attr = array(
432 'direction' => $settings->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? "ASC" : "DESC",
433 'type' => 'Activation'
434 );
435 break;
437 $attr = array(
438 'type' => 'Inherit'
439 );
440 }
441 $xml->xmlElement('Sort', $attr);
442 }
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 450 of file class.ilContainerSortingSettings.php.

451 {
453
454 switch($attibs['type'])
455 {
456 case 'Manual':
457 $settings->setSortMode(ilContainer::SORT_MANUAL);
458 break;
459 case 'Creation':
460 $settings->setSortMode(ilContainer::SORT_CREATION);
461 break;
462 case 'Title':
463 $settings->setSortMode(ilContainer::SORT_TITLE);
464 break;
465 case 'Activation':
466 $settings->setSortMode(ilContainer::SORT_ACTIVATION);
467 break;
468 }
469
470 switch($attibs['direction'])
471 {
472 case 'ASC':
473 $settings->setSortDirection(ilContainer::SORT_DIRECTION_ASC);
474 break;
475 case 'DESC':
476 $settings->setSortDirection(ilContainer::SORT_DIRECTION_DESC);
477 break;
478 }
479
480 switch($attibs['position'])
481 {
482 case "Top":
483 $settings->setSortNewItemsPosition(ilContainer::SORT_NEW_ITEMS_POSITION_TOP);
484 break;
485 case "Bottom":
486 $settings->setSortNewItemsPosition(ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM);
487 break;
488 }
489
490 switch($attibs['order'])
491 {
492 case 'Creation':
493 $settings->setSortNewItemsOrder(ilContainer::SORT_NEW_ITEMS_ORDER_CREATION);
494 break;
495 case 'Title':
496 $settings->setSortNewItemsOrder(ilContainer::SORT_NEW_ITEMS_ORDER_TITLE);
497 break;
498 case 'Activation':
499 $settings->setSortNewItemsOrder(ilContainer::SORT_NEW_ITEMS_ORDER_ACTIVATION);
500 }
501
502 $settings->update();
503 }
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 103 of file class.ilContainerSortingSettings.php.

104 {
105 global $tree, $ilDB, $objDefinition;
106
107 // Try to read from table
108 $query = "SELECT * FROM container_sorting_set ".
109 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
110 $res = $ilDB->query($query);
111
112 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
113 {
114 if($row->sort_mode != ilContainer::SORT_INHERIT)
115 {
116 return $row->sort_mode;
117 }
118 }
120 }
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 79 of file class.ilContainerSortingSettings.php.

80 {
81 global $ilDB;
82
83 $query = "SELECT * FROM container_sorting_set ".
84 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ";
85 $res = $ilDB->query($query);
86
87 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
88 {
89 return $row->sort_mode;
90 }
92 }

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

Referenced by lookupSortModeFromParentContainer().

+ Here is the caller graph for this function:

◆ delete()

ilContainerSortingSettings::delete ( )

Delete setting.

Returns

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

319 {
320 global $ilDB;
321
322 $query = 'DELETE FROM container_sorting_set WHERE obj_id = '.$ilDB->quote($this->obj_id,'integer');
323 $ilDB->query($query);
324 }

References $ilDB, and $query.

◆ 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(), ilCourseXMLParser\handlerBeginTag(), and ilContainerSorting\read().

+ Here is the caller graph for this function:

◆ getSortDirection()

ilContainerSortingSettings::getSortDirection ( )

Get sort direction.

Returns
type

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

214 {
215 return $this->sort_direction ? $this->sort_direction : ilContainer::SORT_DIRECTION_ASC;
216 }

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

205 {
206 return $this->sort_mode ? $this->sort_mode : 0;
207 }

◆ getSortNewItemsOrder()

ilContainerSortingSettings::getSortNewItemsOrder ( )

GET new item order.

Returns
int position

Definition at line 231 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 222 of file class.ilContainerSortingSettings.php.

References $new_items_position.

Referenced by ilContainerGUI\initManualSortingOptionForm().

+ Here is the caller 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 127 of file class.ilContainerSortingSettings.php.

128 {
129 global $tree, $ilDB, $objDefinition;
130
131 if(!$objDefinition->isContainer(ilObject::_lookupType($a_obj_id)))
132 {
134 }
135
136 $ref_ids = ilObject::_getAllReferences($a_obj_id);
137 $ref_id = current($ref_ids);
138
139
140 if($cont_ref_id = $tree->checkForParentType($ref_id,'grp'))
141 {
142 $a_obj_id = ilObject::_lookupObjId($cont_ref_id);
143 $sort_mode = self::_readSortMode($a_obj_id);
145 {
146 return $sort_mode;
147 }
148 }
149 if($cont_ref_id = $tree->checkForParentType($ref_id,'crs'))
150 {
151 $a_obj_id = ilObject::_lookupObjId($cont_ref_id);
152 $sort_mode = self::_readSortMode($a_obj_id);
154 {
155 return $sort_mode;
156 }
157 }
159 }
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
$ref_id
Definition: sahs_server.php:39

References $ilDB, $ref_id, $sort_mode, ilObject\_getAllReferences(), ilObject\_lookupObjId(), ilObject\_lookupType(), _readSortMode(), ilContainer\SORT_INHERIT, and ilContainer\SORT_TITLE.

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

334 {
335 if(!$this->obj_id)
336 {
337 return TRUE;
338 }
339
340 $query = "SELECT * FROM container_sorting_set ".
341 "WHERE obj_id = ".$this->db->quote($this->obj_id ,'integer')." ";
342
343 $res = $this->db->query($query);
344 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
345 {
346 $this->sort_mode = $row->sort_mode;
347 $this->sort_direction = $row->sort_direction;
348 $this->new_items_position = $row->new_items_position;
349 $this->new_items_order = $row->new_items_order;
350 return TRUE;
351 }
352 }

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

299 {
300 global $ilDB;
301
302 $query = "INSERT INTO container_sorting_set ".
303 "(obj_id,sort_mode, sort_direction, new_items_position, new_items_order) ".
304 "VALUES ( ".
305 $this->db->quote($this->obj_id ,'integer').", ".
306 $this->db->quote($this->sort_mode ,'integer').", ".
307 $this->db->quote($this->sort_direction,'integer').', '.
308 $this->db->quote($this->new_items_position,'integer').', '.
309 $this->db->quote($this->new_items_order,'integer').' '.
310 ")";
311 $res = $ilDB->manipulate($query);
312 }

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

253 {
254 $this->sort_direction = (int) $a_direction;
255 }

◆ setSortMode()

ilContainerSortingSettings::setSortMode (   $a_mode)

set sort mode

@access public

Parameters
intMODE_TITLE | MODE_MANUAL | MODE_ACTIVATION

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

244 {
245 $this->sort_mode = (int) $a_mode;
246 }

◆ setSortNewItemsOrder()

ilContainerSortingSettings::setSortNewItemsOrder (   $a_order)

SET new item order.

Parameters
int$a_order

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

271 {
272 $this->new_items_order = (int)$a_order;
273 }

◆ setSortNewItemsPosition()

ilContainerSortingSettings::setSortNewItemsPosition (   $a_position)

SET new item position.

Parameters
int$a_position

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

262 {
263 $this->new_items_position = (int)$a_position;
264 }

◆ sortModeToString()

static ilContainerSortingSettings::sortModeToString (   $a_sort_mode)
static

get String representation of sort mode

Parameters
int$a_sort_mode
Returns

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

360 {
361 global $lng;
362
363 $lng->loadLanguageModule('crs');
364 switch($a_sort_mode)
365 {
367 return $lng->txt('crs_sort_activation');
368
370 return $lng->txt('crs_sort_manual');
371
373 return $lng->txt('crs_sort_title');
374
376 return $lng->txt('sorting_creation_header');
377 }
378 return '';
379 }
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 281 of file class.ilContainerSortingSettings.php.

282 {
283 global $ilDB;
284
285 $query = "DELETE FROM container_sorting_set ".
286 "WHERE obj_id = ".$ilDB->quote($this->obj_id,'integer');
287 $res = $ilDB->manipulate($query);
288
289 $this->save();
290 }

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

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