Public Member Functions | |
| __construct ($a_obj_id) | |
| Constructor. | |
| sortTreeData ($a_tree_data) | |
| Sort tree data. | |
| sortTreeDataByType ($a_tree_data) | |
| Sort. | |
| isManualSortingEnabled () | |
| is manual sorting enabled | |
| savePost ($a_type_positions) | |
| Save post. | |
| saveByType ($a_type, $a_items) | |
| Save positions by type. | |
Protected Attributes | |
| $obj_id | |
| $db | |
| $manual_sort_enabled = false | |
Private Member Functions | |
| read () | |
| Read. | |
Definition at line 32 of file class.ilContainerSorting.php.
| ilContainerSorting::__construct | ( | $ | a_obj_id | ) |
Constructor.
public
| int | obj_id |
Definition at line 46 of file class.ilContainerSorting.php.
References read().
{
global $ilDB;
$this->db = $ilDB;
$this->obj_id = $a_obj_id;
$this->read();
}
Here is the call graph for this function:| ilContainerSorting::isManualSortingEnabled | ( | ) |
is manual sorting enabled
public
Definition at line 141 of file class.ilContainerSorting.php.
{
return (bool) $this->manual_sort_enabled;
}
| ilContainerSorting::read | ( | ) | [private] |
Read.
private
Definition at line 194 of file class.ilContainerSorting.php.
References $res, and ilContainerSortingSettings::_isManualSortingEnabled().
Referenced by __construct().
{
if(!$this->obj_id)
{
return true;
}
include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
$this->manual_sort_enabled = ilContainerSortingSettings::_isManualSortingEnabled($this->obj_id);
$query = "SELECT * FROM container_sorting ".
"WHERE obj_id = ".$this->db->quote($this->obj_id)." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->sorting[$row->type] = unserialize($row->items);
}
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilContainerSorting::saveByType | ( | $ | a_type, | |
| $ | a_items | |||
| ) |
Save positions by type.
public
| string | type e.g lres,crs | |
| array | items |
Definition at line 178 of file class.ilContainerSorting.php.
References $res.
Referenced by savePost().
{
$query = "REPLACE INTO container_sorting SET ".
"obj_id = ".$this->db->quote($this->obj_id).", ".
"type = ".$this->db->quote($a_type).", ".
"items = ".$this->db->quote(serialize($a_items))." ";
$res = $this->db->query($query);
}
Here is the caller graph for this function:| ilContainerSorting::savePost | ( | $ | a_type_positions | ) |
Save post.
public
| array | of positions e.g array(crs => array(1,2,3),'lres' => array(3,5,6)) |
Definition at line 153 of file class.ilContainerSorting.php.
References saveByType().
{
if(!is_array($a_type_positions))
{
return false;
}
foreach($a_type_positions as $type => $positions)
{
if(!is_array($positions))
{
continue;
}
asort($positions,SORT_NUMERIC);
$this->saveByType($type,$positions);
}
}
Here is the call graph for this function:| ilContainerSorting::sortTreeData | ( | $ | a_tree_data | ) |
Sort tree data.
public
| @return |
Definition at line 63 of file class.ilContainerSorting.php.
References sortTreeDataByType().
{
$nodes_by_type = array();
foreach($a_tree_data as $node)
{
$type = $node['type'];
$nodes_by_type[$type][] = $node;
}
$sorted = $this->sortTreeDataByType($nodes_by_type);
foreach($sorted as $type => $nodes)
{
foreach($nodes as $node)
{
$sorted_nodes[] = $node;
}
}
return $sorted_nodes ? $sorted_nodes : $a_tree_data;
}
Here is the call graph for this function:| ilContainerSorting::sortTreeDataByType | ( | $ | a_tree_data | ) |
Sort.
public
| array | of objects by type |
Definition at line 91 of file class.ilContainerSorting.php.
References $data, and $ref_id.
Referenced by sortTreeData().
{
if(!$this->manual_sort_enabled)
{
return $a_tree_data;
}
if(!count($a_tree_data))
{
return $a_tree_data;
}
foreach($a_tree_data as $type => $data)
{
$new_key = 0;
if(!is_array($this->sorting[$type]))
{
$sorted[$type] = $data;
continue;
}
$tmp_indexes = array();
foreach($data as $key => $obj)
{
$tmp_indexes[$obj['child']] = $key;
}
// First sort all items that have entries in sorting table
foreach($this->sorting[$type] as $ref_id => $pos)
{
if(is_array($data[$tmp_indexes[$ref_id]]))
{
$sorted[$type][$new_key++] = $data[$tmp_indexes[$ref_id]];
}
}
// No append all items that are not in sorting table
foreach($tmp_indexes as $ref_id => $key)
{
if(!isset($this->sorting[$type][$ref_id]))
{
$sorted[$type][$new_key++] = $data[$key];
}
}
}
return $sorted ? $sorted : array();
}
Here is the caller graph for this function:ilContainerSorting::$db [protected] |
Definition at line 35 of file class.ilContainerSorting.php.
ilContainerSorting::$manual_sort_enabled = false [protected] |
Definition at line 37 of file class.ilContainerSorting.php.
ilContainerSorting::$obj_id [protected] |
Definition at line 34 of file class.ilContainerSorting.php.
1.7.1