54 $this->obj_id = $a_obj_id;
82 if(isset(self::$instances[$a_obj_id]))
84 return self::$instances[$a_obj_id];
98 $query =
"SELECT * FROM container_sorting WHERE ".
99 "obj_id = ".$ilDB->quote($a_obj_id,
'integer');
103 $sorted[
$row->child_id] =
$row->position;
105 return $sorted ? $sorted : array();
119 $ilLog->write(__METHOD__.
': Cloning container sorting.');
123 include_once(
'./Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
126 $query =
"SELECT * FROM container_sorting ".
127 "WHERE obj_id = ".$ilDB->quote($this->obj_id,
'integer');
133 if(!isset($mappings[
$row->child_id]) or !$mappings[
$row->child_id])
135 #$ilLog->write(__METHOD__.': No mapping found for:'.$row->child_id);
139 if(
$row->parent_id and (!isset($mappings[
$row->parent_id]) or !$mappings[
$row->parent_id]))
144 $query =
"DELETE FROM container_sorting ".
145 "WHERE obj_id = ".$ilDB->quote($target_obj_id,
'integer').
" ".
146 "AND child_id = ".$ilDB->quote($mappings[
$row->child_id],
'integer').
" ".
147 "AND parent_type = ".$ilDB->quote(
$row->parent_type,
'text').
' '.
148 "AND parent_id = ".$ilDB->quote((
int) $mappings[
$row->parent_id],
'integer');
149 $ilDB->manipulate(
$query);
152 $query =
"INSERT INTO container_sorting (obj_id,child_id,position,parent_type,parent_id) ".
154 $ilDB->quote($target_obj_id ,
'integer').
", ".
155 $ilDB->quote($mappings[
$row->child_id] ,
'integer').
", ".
156 $ilDB->quote(
$row->position,
'integer').
", ".
157 $ilDB->quote(
$row->parent_type,
'text').
", ".
158 $ilDB->quote((
int) $mappings[
$row->parent_id],
'integer').
160 $ilDB->manipulate(
$query);
177 if(!$this->manual_sort_enabled)
187 return $sorted ? $sorted : array();
194 return $sorted ? $sorted : array();
206 foreach(
$data as $key => $item)
208 $items[$key] = $item;
209 $items[$key][
'position'] = isset($this->sorting[
'all'][$item[
'child']]) ? $this->sorting[
'all'][$item[
'child']] : 9999;
227 return $sorted ? $sorted : array();
244 foreach($a_items as $key => $item)
246 $items[$key] = $item;
247 $items[$key][
'position'] = isset($this->sorting[$a_parent_type][$a_parent_id][$item[
'child']]) ?
248 $this->sorting[$a_parent_type][$a_parent_id][$item[
'child']] : 9999;
285 if(!is_array($a_type_positions))
289 foreach($a_type_positions as $key => $position)
291 if(!is_array($position))
293 $items[$key] = $position * 100;
297 $ilLog->write(__METHOD__.
': Deprecated call');
298 foreach($position as $parent_id => $items)
300 $this->
saveSubItems($key,$parent_id,$items ? $items : array());
304 $this->
saveItems($items ? $items : array());
321 foreach($a_items as $child_id => $position)
326 'obj_id' => array(
'integer',$this->obj_id),
327 'child_id' => array(
'integer',$child_id),
328 'parent_id' => array(
'integer',0)
331 'parent_type' => array(
'text',
''),
332 'position' => array(
'integer',$position)
350 foreach($a_items as $child_id => $position)
355 'obj_id' => array(
'integer',$this->obj_id),
356 'child_id' => array(
'integer',$child_id),
357 'parent_id' => array(
'integer',$a_parent_id)
360 'parent_type' => array(
'text',$a_parent_type),
361 'position' => array(
'integer',$position)
383 include_once(
'Services/Container/classes/class.ilContainerSortingSettings.php');
387 $query =
"SELECT * FROM container_sorting ".
388 "WHERE obj_id = ".$this->db->quote($this->obj_id ,
'integer').
" ORDER BY position";
394 $this->sorting[
$row->parent_type][
$row->parent_id][
$row->child_id] =
$row->position;
398 $this->sorting[
'all'][
$row->child_id] =
$row->position;