24 include_once
'./Services/Container/classes/class.ilContainer.php';
25 include_once(
'Services/Container/classes/class.ilContainerSortingSettings.php');
57 $this->obj_id = $a_obj_id;
81 if(isset(self::$instances[$a_obj_id]))
83 return self::$instances[$a_obj_id];
97 $query =
"SELECT * FROM container_sorting WHERE ".
98 "obj_id = ".$ilDB->quote($a_obj_id,
'integer');
102 $sorted[
$row->child_id] =
$row->position;
104 return $sorted ? $sorted : array();
118 $ilLog->write(__METHOD__.
': Cloning container sorting.');
122 include_once(
'./Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
125 $query =
"SELECT * FROM container_sorting ".
126 "WHERE obj_id = ".$ilDB->quote($this->obj_id,
'integer');
132 if(!isset($mappings[
$row->child_id]) or !$mappings[
$row->child_id])
134 #$ilLog->write(__METHOD__.': No mapping found for:'.$row->child_id); 138 if(
$row->parent_id and (!isset($mappings[
$row->parent_id]) or !$mappings[
$row->parent_id]))
143 $query =
"DELETE FROM container_sorting ".
144 "WHERE obj_id = ".$ilDB->quote($target_obj_id,
'integer').
" ".
145 "AND child_id = ".$ilDB->quote($mappings[
$row->child_id],
'integer').
" ".
146 "AND parent_type = ".$ilDB->quote(
$row->parent_type,
'text').
' '.
147 "AND parent_id = ".$ilDB->quote((
int) $mappings[
$row->parent_id],
'integer');
148 $ilDB->manipulate(
$query);
151 $query =
"INSERT INTO container_sorting (obj_id,child_id,position,parent_type,parent_id) ".
153 $ilDB->quote($target_obj_id ,
'integer').
", ".
154 $ilDB->quote($mappings[
$row->child_id] ,
'integer').
", ".
155 $ilDB->quote(
$row->position,
'integer').
", ".
156 $ilDB->quote(
$row->parent_type,
'text').
", ".
157 $ilDB->quote((
int) $mappings[
$row->parent_id],
'integer').
159 $ilDB->manipulate(
$query);
181 foreach((array) $a_items as $type =>
$data)
184 if($type ==
'sess_link')
186 $sorted[$type] =
$data;
206 return $sorted ? $sorted : array();
209 foreach((array) $a_items as $type =>
$data)
212 if($type ==
'sess_link')
214 $sorted[$type] =
$data;
226 return $sorted ? $sorted : array();
230 foreach((array) $a_items as $type =>
$data)
233 if($type ==
'sess_link')
235 $sorted[$type] =
$data;
246 return $sorted ? $sorted : array();
255 foreach((array) $a_items as $type =>
$data)
257 if($type ==
'sess_link')
259 $sorted[$type] =
$data;
265 foreach((array)
$data as $key => $item)
267 $items[$key] = $item;
268 if(is_array($this->sorting[
'all']) and isset($this->sorting[
'all'][$item[
'child']]))
270 $items[$key][
'position'] = $this->sorting[
'all'][$item[
'child']];
274 $items[$key][
'position'] = self::ORDER_DEFAULT;
295 return $sorted ? $sorted : array();
311 foreach($a_items as $key => $item)
313 $items[$key] = $item;
314 $items[$key][
'position'] = isset($this->sorting[$a_parent_type][$a_parent_id][$item[
'child']]) ?
315 $this->sorting[$a_parent_type][$a_parent_id][$item[
'child']] : self::ORDER_DEFAULT;
361 if(!is_array($a_type_positions))
365 foreach($a_type_positions as $key => $position)
371 else if(!is_array($position))
373 $items[$key] = $position * 100;
377 $ilLog->write(__METHOD__.
': Deprecated call');
378 foreach($position as $parent_id => $sub_items)
380 $this->
saveSubItems($key,$parent_id,$sub_items ? $sub_items : array());
384 $this->
saveItems($items ? $items : array());
401 foreach($a_items as $child_id => $position)
406 'obj_id' => array(
'integer',$this->obj_id),
407 'child_id' => array(
'integer',$child_id),
408 'parent_id' => array(
'integer',0)
411 'parent_type' => array(
'text',
''),
412 'position' => array(
'integer',$position)
430 foreach($a_items as $child_id => $position)
435 'obj_id' => array(
'integer',$this->obj_id),
436 'child_id' => array(
'integer',$child_id),
437 'parent_id' => array(
'integer',$a_parent_id)
440 'parent_type' => array(
'text',$a_parent_type),
441 'position' => array(
'integer',$position)
461 'container_sorting_bl',
463 'obj_id' => array(
'integer',$this->obj_id)
466 'block_ids' => array(
'text', implode(
";", array_keys($a_values)))
480 $set = $ilDB->query(
"SELECT block_ids".
481 " FROM container_sorting_bl".
482 " WHERE obj_id = ".$ilDB->quote($this->obj_id,
"integer"));
483 $row = $ilDB->fetchAssoc($set);
484 if(
$row[
"block_ids"])
486 return explode(
";",
$row[
"block_ids"]);
513 $crs_ref_id = $tree->checkForParentType(
$ref_id,
'crs');
517 $this->sorting_settings = clone $crs_settings;
520 $query =
"SELECT * FROM container_sorting ".
521 "WHERE obj_id = ".$this->db->quote($this->obj_id ,
'integer').
" ORDER BY position";
527 $this->sorting[
$row->parent_type][
$row->parent_id][
$row->child_id] =
$row->position;
531 $this->sorting[
'all'][
$row->child_id] =
$row->position;
545 $no_position = array();
547 foreach($items as $key => $item)
549 if($item[
"position"] == self::ORDER_DEFAULT)
551 $no_position[]= array(
"key" => $key,
"title" => $item[
"title"],
"create_date" => $item[
"create_date"],
552 "start" => $item[
"start"]);
557 if(!count($no_position))
586 foreach($no_position as $values)
588 $items[$values[
"key"]][
"position"] = $count;
saveItems($a_items)
save items
const SORT_NEW_ITEMS_POSITION_TOP
saveBlockPositions(array $a_values)
Save block custom positions (for current object id)
sortOrderDefault($items)
Position and order sort order for new object without position in manual sorting type.
savePost($a_type_positions)
Save post.
getBlockPositions()
Read block custom positions (for current object id)
sortSubItems($a_parent_type, $a_parent_id, $a_items)
sort subitems (items of sessions or learning objectives)
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _getAllReferences($a_id)
get all reference ids of object
const DB_FETCHMODE_OBJECT
getSortingSettings()
Get sorting settings.
sortItems($a_items)
sort subitems
__construct($a_obj_id)
Constructor.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
saveSubItems($a_parent_type, $a_parent_id, $a_items)
Save subitem ordering (sessions, learning objectives)
const SORT_NEW_ITEMS_ORDER_CREATION
static _lookupObjId($a_id)
const SORT_NEW_ITEMS_ORDER_ACTIVATION
static getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getInstance($a_obj_id)
get instance by obj_id
static lookupPositions($a_obj_id)
Get positions of subitems.
const SORT_NEW_ITEMS_ORDER_TITLE
cloneSorting($a_target_id, $a_copy_id)
clone sorting