24 include_once
'./Services/Container/classes/class.ilContainer.php';
63 $this->tree = $DIC->repositoryTree();
64 $ilDB = $DIC->database();
66 $this->obj_id = $a_obj_id;
79 if (self::$instances[$a_obj_id]) {
80 return self::$instances[$a_obj_id];
82 return self::$instances[$a_obj_id] =
new self($a_obj_id);
96 $inherited = clone $this;
101 $inherited->setSortMode($effective_settings->getSortMode());
102 $inherited->setSortNewItemsOrder($effective_settings->getSortNewItemsOrder());
103 $inherited->setSortNewItemsPosition($effective_settings->getSortNewItemsPosition());
117 if (!$a_container_obj_id) {
122 $ref_id = current($ref_ids);
124 if ($cont_ref_id =
$tree->checkForParentType($ref_id,
'grp',
true)) {
126 $parent_settings = self::getInstanceByObjId($parent_obj_id);
131 return $parent_settings;
134 if ($cont_ref_id =
$tree->checkForParentType($ref_id,
'crs',
true)) {
136 $parent_settings = self::getInstanceByObjId($parent_obj_id);
137 return $parent_settings;
148 $ilDB = $DIC->database();
150 $query =
"SELECT * FROM container_sorting_set " .
151 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" ";
155 return $row->sort_mode;
173 $tree = $DIC->repositoryTree();
174 $ilDB = $DIC->database();
175 $objDefinition = $DIC[
"objDefinition"];
178 $query =
"SELECT * FROM container_sorting_set " .
179 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer') .
" ";
184 return $row->sort_mode;
187 return self::lookupSortModeFromParentContainer($a_obj_id);
197 $settings = self::getInstanceByObjId($a_obj_id);
198 $inherited_settings = $settings->getInheritedSettings($a_obj_id);
199 return $inherited_settings->getSortMode();
215 $ilDB = $DIC->database();
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') .
" ";
222 $query =
"DELETE FROM container_sorting_set " .
223 "WHERE obj_id = " .
$ilDB->quote($a_new_id) .
" ";
226 $query =
"INSERT INTO container_sorting_set " .
227 "(obj_id,sort_mode, sort_direction, new_items_position, new_items_order) " .
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') .
' ' .
248 return $this->sort_mode ? $this->sort_mode : 0;
287 $this->sort_mode = (int) $a_mode;
296 $this->sort_direction = (int) $a_direction;
305 $this->new_items_position = (int) $a_position;
314 $this->new_items_order = (int) $a_order;
327 $query =
"DELETE FROM container_sorting_set " .
328 "WHERE obj_id = " .
$ilDB->quote($this->obj_id,
'integer');
344 $query =
"INSERT INTO container_sorting_set " .
345 "(obj_id,sort_mode, sort_direction, new_items_position, new_items_order) " .
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') .
' ' .
360 public function delete()
364 $query =
'DELETE FROM container_sorting_set WHERE obj_id = ' .
$ilDB->quote($this->obj_id,
'integer');
377 if (!$this->obj_id) {
381 $query =
"SELECT * FROM container_sorting_set " .
382 "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 = $DIC->language();
405 $lng->loadLanguageModule(
'crs');
406 switch ($a_sort_mode) {
408 return $lng->txt(
'crs_sort_activation');
411 return $lng->txt(
'crs_sort_manual');
414 return $lng->txt(
'crs_sort_title');
417 return $lng->txt(
'sorting_creation_header');
430 $settings = self::getInstanceByObjId(
$obj_id);
433 switch ($settings->getSortMode()) {
435 switch ($settings->getSortNewItemsOrder()) {
437 $order =
'Activation';
472 'type' =>
'Activation' 491 $settings = self::getInstanceByObjId(
$obj_id);
493 switch ($attibs[
'type']) {
508 switch ($attibs[
'direction']) {
517 switch ($attibs[
'position']) {
526 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.
static _importContainerSortingSettings($attibs, $obj_id)
sorting import for all container objects
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
foreach($_POST as $key=> $value) $res
const SORT_NEW_ITEMS_ORDER_CREATION
static _lookupObjId($a_id)
static lookupSortModeFromParentContainer($a_obj_id)
Lookup sort mode from parent container.
static sortModeToString($a_sort_mode)
get String representation of sort mode
const SORT_NEW_ITEMS_ORDER_ACTIVATION
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
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.