24 include_once
'./Services/Container/classes/class.ilContainer.php';
58 $this->obj_id = $a_obj_id;
71 if(self::$instances[$a_obj_id])
73 return self::$instances[$a_obj_id];
75 return self::$instances[$a_obj_id] =
new self($a_obj_id);
90 $inherited = clone $this;
98 $inherited->setSortMode($effective_settings->getSortMode());
99 $inherited->setSortNewItemsOrder($effective_settings->getSortNewItemsOrder());
100 $inherited->setSortNewItemsPosition($effective_settings->getSortNewItemsPosition());
115 if(!$a_container_obj_id)
123 if($cont_ref_id = $tree->checkForParentType(
$ref_id,
'grp',
true))
126 $parent_settings = self::getInstanceByObjId($parent_obj_id);
132 return $parent_settings;
135 if($cont_ref_id = $tree->checkForParentType(
$ref_id,
'crs',
true))
138 $parent_settings = self::getInstanceByObjId($parent_obj_id);
139 return $parent_settings;
150 $query =
"SELECT * FROM container_sorting_set ".
151 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
156 return $row->sort_mode;
172 global $tree,
$ilDB, $objDefinition;
175 $query =
"SELECT * FROM container_sorting_set ".
176 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
183 return $row->sort_mode;
186 return self::lookupSortModeFromParentContainer($a_obj_id);
196 $settings = self::getInstanceByObjId($a_obj_id);
197 $inherited_settings = $settings->getInheritedSettings($a_obj_id);
198 return $inherited_settings->getSortMode();
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').
" ";
218 while(
$row = $ilDB->fetchAssoc(
$res))
220 $query =
"DELETE FROM container_sorting_set ".
221 "WHERE obj_id = ".$ilDB->quote($a_new_id).
" ";
222 $ilDB->manipulate(
$query);
224 $query =
"INSERT INTO container_sorting_set ".
225 "(obj_id,sort_mode, sort_direction, new_items_position, new_items_order) ".
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').
' '.
233 $ilDB->manipulate(
$query);
246 return $this->sort_mode ? $this->sort_mode : 0;
285 $this->sort_mode = (int) $a_mode;
294 $this->sort_direction = (int) $a_direction;
303 $this->new_items_position = (int)$a_position;
312 $this->new_items_order = (int)$a_order;
325 $query =
"DELETE FROM container_sorting_set ".
326 "WHERE obj_id = ".$ilDB->quote($this->obj_id,
'integer');
342 $query =
"INSERT INTO container_sorting_set ".
343 "(obj_id,sort_mode, sort_direction, new_items_position, new_items_order) ".
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').
' '.
358 public function delete()
362 $query =
'DELETE FROM container_sorting_set WHERE obj_id = '.$ilDB->quote($this->obj_id,
'integer');
380 $query =
"SELECT * FROM container_sorting_set ".
381 "WHERE obj_id = ".$this->db->quote($this->obj_id ,
'integer').
" ";
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;
403 $lng->loadLanguageModule(
'crs');
407 return $lng->txt(
'crs_sort_activation');
410 return $lng->txt(
'crs_sort_manual');
413 return $lng->txt(
'crs_sort_title');
416 return $lng->txt(
'sorting_creation_header');
429 $settings = self::getInstanceByObjId(
$obj_id);
432 switch($settings->getSortMode())
435 switch($settings->getSortNewItemsOrder())
438 $order =
'Activation';
473 'type' =>
'Activation' 492 $settings = self::getInstanceByObjId(
$obj_id);
494 switch($attibs[
'type'])
510 switch($attibs[
'direction'])
520 switch($attibs[
'position'])
530 switch($attibs[
'order'])
setSortDirection($a_direction)
Set sort direction.
setSortMode($a_mode)
set sort mode
const SORT_NEW_ITEMS_POSITION_TOP
loadEffectiveSettings()
Load inherited settings.
static _readSortMode($a_obj_id)
getInheritedSettings($a_container_obj_id)
Read inherited settings of course/group ilTree $tree.
static _importContainerSortingSettings($attibs, $obj_id)
sorting import for all container objects
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
setSortNewItemsPosition($a_position)
SET new item position.
static _cloneSettings($a_old_id, $a_new_id)
Clone settings.
static _getAllReferences($a_id)
get all reference ids of object
getSortNewItemsOrder()
GET new item order.
getSortMode()
get sort mode
const SORT_NEW_ITEMS_POSITION_BOTTOM
const SORT_NEW_ITEMS_ORDER_CREATION
static _lookupObjId($a_id)
static lookupSortModeFromParentContainer($a_obj_id)
Lookup sort mode from parent container.
Create styles array
The data for the language used.
static sortModeToString($a_sort_mode)
get String representation of sort mode
const SORT_NEW_ITEMS_ORDER_ACTIVATION
getSortNewItemsPosition()
GET new item position.
const SORT_DIRECTION_DESC
static _exportContainerSortingSettings(ilXmlWriter $xml, $obj_id)
sorting XML-export for all container objects
setSortNewItemsOrder($a_order)
SET new item order.
static _lookupSortMode($a_obj_id)
lookup sort mode
static getInstanceByObjId($a_obj_id)
Get singleton instance.
const SORT_NEW_ITEMS_ORDER_TITLE
getSortDirection()
Get sort direction.
__construct($a_obj_id=0)
Constructor.