ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilContainerSorting Class Reference
+ Collaboration diagram for ilContainerSorting:

Public Member Functions

 getSortMode ()
 get sort mode
 sortItems ($a_items)
 sort subitems
 sortSubItems ($a_parent_type, $a_parent_id, $a_items)
 sort subitems (items of sessions or learning objectives)
 isManualSortingEnabled ()
 is manual sorting enabled
 savePost ($a_type_positions)
 Save post.

Static Public Member Functions

static _getInstance ($a_obj_id)
 get instance by obj_id
 cloneSorting ($a_target_id, $a_copy_id)
 clone sorting

Protected Member Functions

 saveItems ($a_parent_type, $a_parent_id, $a_items)
 save items

Protected Attributes

 $obj_id
 $db
 $manual_sort_enabled = false
 $sorting_mode = 0

Static Protected Attributes

static $instances = array()

Private Member Functions

 __construct ($a_obj_id)
 Constructor.
 read ()
 Read.

Detailed Description

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
$Id$

Definition at line 32 of file class.ilContainerSorting.php.

Constructor & Destructor Documentation

ilContainerSorting::__construct (   $a_obj_id)
private

Constructor.

private

Parameters
intobj_id

Definition at line 49 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:

Member Function Documentation

static ilContainerSorting::_getInstance (   $a_obj_id)
static

get instance by obj_id

public

Parameters
intobj_id
Returns

Definition at line 80 of file class.ilContainerSorting.php.

Referenced by ilContainer\cloneDependencies(), cloneSorting(), ilContainer\getSubItems(), ilContainerContentGUI\renderItem(), ilContainerObjectiveGUI\renderObjective(), ilContainerGUI\saveSortingObject(), and ilRepositoryExplorer\sortNodes().

{
if(isset(self::$instances[$a_obj_id]))
{
return self::$instances[$a_obj_id];
}
return self::$instances[$a_obj_id] = new ilContainerSorting($a_obj_id);
}

+ Here is the caller graph for this function:

ilContainerSorting::cloneSorting (   $a_target_id,
  $a_copy_id 
)
static

clone sorting

Returns

Definition at line 95 of file class.ilContainerSorting.php.

References $ilLog, $res, _getInstance(), ilObject\_lookupObjId(), and DB_FETCHMODE_OBJECT.

{
global $ilDB;
global $ilLog;
$ilLog->write(__METHOD__.': Cloning container sorting.');
$target_obj_id = ilObject::_lookupObjId($a_target_id);
include_once('./Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
$mappings = ilCopyWizardOptions::_getInstance($a_copy_id)->getMappings();
$query = "SELECT * FROM container_sorting ".
"WHERE obj_id = ".$ilDB->quote($this->obj_id);
$res = $ilDB->query($query);
#$ilLog->write(__METHOD__.': Query is: '.$query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if(!isset($mappings[$row->child_id]) or !$mappings[$row->child_id])
{
#$ilLog->write(__METHOD__.': No mapping found for:'.$row->child_id);
continue;
}
// Add new value
$query = "REPLACE INTO container_sorting ".
"SET obj_id = ".$ilDB->quote($target_obj_id).", ".
"parent_type = '', ".
"parent_id = 0, ".
"child_id = ".$ilDB->quote($mappings[$row->child_id]).", ".
"position = ".$ilDB->quote($row->position);
$ilDB->query($query);
#$ilLog->write(__METHOD__.': Query is: '.$query);
}
return true;
}

+ Here is the call graph for this function:

ilContainerSorting::getSortMode ( )

get sort mode

public

Parameters
@return

Definition at line 66 of file class.ilContainerSorting.php.

References $sorting_mode.

Referenced by sortItems(), and sortSubItems().

{
}

+ Here is the caller graph for this function:

ilContainerSorting::isManualSortingEnabled ( )

is manual sorting enabled

public

Returns
bool

Definition at line 236 of file class.ilContainerSorting.php.

References $manual_sort_enabled.

{
}
ilContainerSorting::read ( )
private

Read.

private

Definition at line 303 of file class.ilContainerSorting.php.

References $res, ilContainerSortingSettings\_isManualSortingEnabled(), ilContainerSortingSettings\_lookupSortMode(), and DB_FETCHMODE_OBJECT.

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);
$this->sorting_mode = ilContainerSortingSettings::_lookupSortMode($this->obj_id);
$query = "SELECT * FROM container_sorting ".
"WHERE obj_id = ".$this->db->quote($this->obj_id)." ORDER BY position";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if($row->parent_type)
{
$this->sorting[$row->parent_type][$row->parent_id][$row->child_id] = $row->position;
}
else
{
$this->sorting['all'][$row->child_id] = $row->position;
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilContainerSorting::saveItems (   $a_parent_type,
  $a_parent_id,
  $a_items 
)
protected

save items

protected

Parameters
stringparent_type only used for sessions and objectives in the moment. Otherwise empty
intparent id
arrayarray of items
Returns

Definition at line 281 of file class.ilContainerSorting.php.

References $res.

Referenced by savePost().

{
foreach($a_items as $child_id => $position)
{
$query = "REPLACE INTO container_sorting SET ".
"obj_id = ".$this->db->quote($this->obj_id).", ".
"parent_type = ".$this->db->quote($a_parent_type).", ".
"parent_id = ".$this->db->quote($a_parent_id).", ".
"child_id = ".$this->db->quote($child_id).", ".
"position = ".$this->db->quote($position);
$res = $this->db->query($query);
}
return true;
}

+ Here is the caller graph for this function:

ilContainerSorting::savePost (   $a_type_positions)

Save post.

public

Parameters
arrayof positions e.g array(crs => array(1,2,3),'lres' => array(3,5,6))

Definition at line 248 of file class.ilContainerSorting.php.

References saveItems().

{
if(!is_array($a_type_positions))
{
return false;
}
foreach($a_type_positions as $key => $position)
{
if(!is_array($position))
{
$items[$key] = (float) $position;
}
else
{
foreach($position as $parent_id => $items)
{
$this->saveItems($key,$parent_id,$items ? $items : array());
}
}
}
$this->saveItems('',0,$items ? $items : array());
}

+ Here is the call graph for this function:

ilContainerSorting::sortItems (   $a_items)

sort subitems

public

Parameters
arrayitem data
Returns
array sorted item data

Definition at line 141 of file class.ilContainerSorting.php.

References $data, getSortMode(), ilContainer\SORT_ACTIVATION, ilContainer\SORT_TITLE, and ilUtil\sortArray().

{
$sorted = array();
if(!$this->manual_sort_enabled)
{
switch($this->getSortMode())
{
foreach((array) $a_items as $type => $data)
{
// $sorted[$type] = ilUtil::sortArray((array) $data,'title','asc',true);
$sorted[$type] = $data;
}
return $sorted ? $sorted : array();
foreach((array) $a_items as $type => $data)
{
$sorted[$type] = ilUtil::sortArray((array) $data,'start','asc',true);
}
return $sorted ? $sorted : array();
}
return $a_items;
}
if(!count($a_items))
{
return $a_items;
}
foreach($a_items as $type => $data)
{
// Add position
$items = array();
foreach($data as $key => $item)
{
$items[$key] = $item;
$items[$key]['position'] = isset($this->sorting['all'][$item['child']]) ? $this->sorting['all'][$item['child']] : 9999;
}
switch($type)
{
case '_all':
$sorted[$type] = ilUtil::sortArray((array) $items,'position','asc',true);
break;
case '_non_sess':
$sorted[$type] = ilUtil::sortArray((array) $items,'position','asc',true);
break;
default:
$sorted[$type] = ilUtil::sortArray((array) $items,'position','asc',true);
break;
}
}
return $sorted ? $sorted : array();
}

+ Here is the call graph for this function:

ilContainerSorting::sortSubItems (   $a_parent_type,
  $a_parent_id,
  $a_items 
)

sort subitems (items of sessions or learning objectives)

public

Parameters
@return

Definition at line 204 of file class.ilContainerSorting.php.

References getSortMode(), ilContainer\SORT_MANUAL, ilContainer\SORT_TITLE, and ilUtil\sortArray().

{
switch($this->getSortMode())
{
// Add position
$items = array();
foreach($a_items as $key => $item)
{
$items[$key] = $item;
$items[$key]['position'] = isset($this->sorting[$a_parent_type][$a_parent_id][$item['child']]) ?
$this->sorting[$a_parent_type][$a_parent_id][$item['child']] : 9999;
}
return ilUtil::sortArray((array) $items,'position','asc',true);
default:
return ilUtil::sortArray((array) $a_items,'title','asc',true);
}
}

+ Here is the call graph for this function:

Field Documentation

ilContainerSorting::$db
protected

Definition at line 37 of file class.ilContainerSorting.php.

ilContainerSorting::$instances = array()
staticprotected

Definition at line 34 of file class.ilContainerSorting.php.

ilContainerSorting::$manual_sort_enabled = false
protected

Definition at line 39 of file class.ilContainerSorting.php.

Referenced by isManualSortingEnabled().

ilContainerSorting::$obj_id
protected

Definition at line 36 of file class.ilContainerSorting.php.

ilContainerSorting::$sorting_mode = 0
protected

Definition at line 40 of file class.ilContainerSorting.php.

Referenced by getSortMode().


The documentation for this class was generated from the following file: