56 $this->obj_id = $a_obj_id;
84 if(isset(self::$instances[$a_obj_id]))
86 return self::$instances[$a_obj_id];
100 $query =
"SELECT * FROM container_sorting WHERE ".
101 "obj_id = ".$ilDB->quote($a_obj_id,
'integer');
105 $sorted[
$row->child_id] =
$row->position;
107 return $sorted ? $sorted : array();
121 $ilLog->write(__METHOD__.
': Cloning container sorting.');
125 include_once(
'./Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
128 $query =
"SELECT * FROM container_sorting ".
129 "WHERE obj_id = ".$ilDB->quote($this->obj_id,
'integer');
135 if(!isset($mappings[
$row->child_id]) or !$mappings[
$row->child_id])
137 #$ilLog->write(__METHOD__.': No mapping found for:'.$row->child_id);
141 if(
$row->parent_id and (!isset($mappings[
$row->parent_id]) or !$mappings[
$row->parent_id]))
146 $query =
"DELETE FROM container_sorting ".
147 "WHERE obj_id = ".$ilDB->quote($target_obj_id,
'integer').
" ".
148 "AND child_id = ".$ilDB->quote($mappings[
$row->child_id],
'integer').
" ".
149 "AND parent_type = ".$ilDB->quote(
$row->parent_type,
'text').
' '.
150 "AND parent_id = ".$ilDB->quote((
int) $mappings[
$row->parent_id],
'integer');
151 $ilDB->manipulate(
$query);
154 $query =
"INSERT INTO container_sorting (obj_id,child_id,position,parent_type,parent_id) ".
156 $ilDB->quote($target_obj_id ,
'integer').
", ".
157 $ilDB->quote($mappings[
$row->child_id] ,
'integer').
", ".
158 $ilDB->quote(
$row->position,
'integer').
", ".
159 $ilDB->quote(
$row->parent_type,
'text').
", ".
160 $ilDB->quote((
int) $mappings[
$row->parent_id],
'integer').
162 $ilDB->manipulate(
$query);
179 if(!$this->manual_sort_enabled)
184 foreach((array) $a_items as $type =>
$data)
187 $sorted[$type] =
$data;
189 return $sorted ? $sorted : array();
192 foreach((array) $a_items as $type =>
$data)
196 return $sorted ? $sorted : array();
204 foreach((array) $a_items as $type =>
$data)
208 foreach((array)
$data as $key => $item)
210 $items[$key] = $item;
211 if(is_array($this->sorting[
'all']) and isset($this->sorting[
'all'][$item[
'child']]))
213 $items[$key][
'position'] = $this->sorting[
'all'][$item[
'child']];
236 return $sorted ? $sorted : array();
253 foreach($a_items as $key => $item)
255 $items[$key] = $item;
256 $items[$key][
'position'] = isset($this->sorting[$a_parent_type][$a_parent_id][$item[
'child']]) ?
294 if(!is_array($a_type_positions))
298 foreach($a_type_positions as $key => $position)
300 if(!is_array($position))
302 $items[$key] = $position * 100;
306 $ilLog->write(__METHOD__.
': Deprecated call');
307 foreach($position as $parent_id => $sub_items)
309 $this->
saveSubItems($key,$parent_id,$sub_items ? $sub_items : array());
313 $this->
saveItems($items ? $items : array());
330 foreach($a_items as $child_id => $position)
335 'obj_id' => array(
'integer',$this->obj_id),
336 'child_id' => array(
'integer',$child_id),
337 'parent_id' => array(
'integer',0)
340 'parent_type' => array(
'text',
''),
341 'position' => array(
'integer',$position)
359 foreach($a_items as $child_id => $position)
364 'obj_id' => array(
'integer',$this->obj_id),
365 'child_id' => array(
'integer',$child_id),
366 'parent_id' => array(
'integer',$a_parent_id)
369 'parent_type' => array(
'text',$a_parent_type),
370 'position' => array(
'integer',$position)
392 include_once(
'Services/Container/classes/class.ilContainerSortingSettings.php');
396 $query =
"SELECT * FROM container_sorting ".
397 "WHERE obj_id = ".$this->db->quote($this->obj_id ,
'integer').
" ORDER BY position";
403 $this->sorting[
$row->parent_type][
$row->parent_id][
$row->child_id] =
$row->position;
407 $this->sorting[
'all'][
$row->child_id] =
$row->position;