ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilECSCmsTreeSynchronizer Class Reference

Description of class. More...

+ Collaboration diagram for ilECSCmsTreeSynchronizer:

Public Member Functions

 __construct (ilECSSetting $server, $mid, $tree_id)
 Constructor.
 getServer ()
 Get server.
 getTree ()
 getDefaultSettings ()
 Get default settings.
 getGlobalSettings ()
 get global settings
 sync ()
 Synchronize tree.

Protected Member Functions

 checkTreeUpdates ($a_root_obj_id)
 Start tree update check.
 handleTreeUpdate ($a_parent_ref_id, $a_tnode_id)
 Handle tree update (recursively)
 syncNode ($tree_obj_id, $parent_id, $a_mapped=false)
 Sync node.
 syncCategory (ilECSNodeMappingAssignment $ass, $parent_id)
 Sync category.

Private Attributes

 $server = null
 $mid = null
 $tree_id = null
 $tree = null
 $default_settings = array()
 $global_settings = null

Detailed Description

Description of class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 15 of file class.ilECSCmsTreeSynchronizer.php.

Constructor & Destructor Documentation

ilECSCmsTreeSynchronizer::__construct ( ilECSSetting  $server,
  $mid,
  $tree_id 
)

Constructor.

Definition at line 29 of file class.ilECSCmsTreeSynchronizer.php.

References $mid, $server, $tree_id, ilECSNodeMappingSettings\getInstanceByServerMid(), and getServer().

{
$this->server = $server;
$this->mid = $mid;
$this->tree = new ilECSCmsTree($tree_id);
$this->tree_id = $tree_id;
include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
$this->global_settings = ilECSNodeMappingSettings::getInstanceByServerMid($this->getServer()->getServerId(),$this->mid);
}

+ Here is the call graph for this function:

Member Function Documentation

ilECSCmsTreeSynchronizer::checkTreeUpdates (   $a_root_obj_id)
protected

Start tree update check.

Parameters
type$a_root_obj_id
Returns
bool

Definition at line 113 of file class.ilECSCmsTreeSynchronizer.php.

References $GLOBALS, getServer(), and handleTreeUpdate().

Referenced by sync().

{
if($this->default_settings['tree_update'] == false)
{
$GLOBALS['ilLog']->write(__METHOD__.': Tree update disabled for tree with id '. $this->getTree()->getTreeId());
return false;
}
// Start recursion
include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignment.php';
$this->getServer()->getServerId(),
$this->mid,
$this->tree_id,
$a_root_obj_id
);
$a_root_ref_id = $mapping->getRefId();
if($a_root_ref_id)
{
$this->handleTreeUpdate($a_root_ref_id, $a_root_obj_id);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCmsTreeSynchronizer::getDefaultSettings ( )

Get default settings.

Returns
type

Definition at line 61 of file class.ilECSCmsTreeSynchronizer.php.

References $default_settings.

Referenced by sync().

{
return (array) $this->default_settings;
}

+ Here is the caller graph for this function:

ilECSCmsTreeSynchronizer::getGlobalSettings ( )

get global settings

Returns
ilECSNodeMappingSettings

Definition at line 70 of file class.ilECSCmsTreeSynchronizer.php.

References $global_settings.

Referenced by syncCategory().

+ Here is the caller graph for this function:

ilECSCmsTreeSynchronizer::getServer ( )

Get server.

Returns
ilECSSetting

Definition at line 44 of file class.ilECSCmsTreeSynchronizer.php.

References $server.

Referenced by __construct(), checkTreeUpdates(), handleTreeUpdate(), sync(), syncCategory(), and syncNode().

{
return $this->server;
}

+ Here is the caller graph for this function:

ilECSCmsTreeSynchronizer::getTree ( )
Returns
ilECSCmsTree

Definition at line 52 of file class.ilECSCmsTreeSynchronizer.php.

References $tree.

Referenced by handleTreeUpdate(), and syncNode().

{
return $this->tree;
}

+ Here is the caller graph for this function:

ilECSCmsTreeSynchronizer::handleTreeUpdate (   $a_parent_ref_id,
  $a_tnode_id 
)
protected

Handle tree update (recursively)

Parameters
type$a_parent_ref_id
type$tnode_id

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

References $GLOBALS, $tree, ilObject\_getAllReferences(), getServer(), getTree(), and ilECSImport\lookupObjIdByContentId().

Referenced by checkTreeUpdates().

{
global $tree;
// Check if node is already imported at location "parent_ref_id"
// If not => move it
$cms_data = new ilECSCmsData($a_tnode_id);
include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
$this->getServer()->getServerId(),
$this->mid,
$cms_data->getCmsId());
if(!$import_obj_id)
{
$GLOBALS['ilLog']->write(__METHOD__.': cms tree node not imported. tnode_id: '. $a_tnode_id);
return false;
}
$GLOBALS['ilLog']->write(__METHOD__.' parent ref:'.$a_parent_ref_id.' tnode:'. $a_tnode_id);
$ref_ids = ilObject::_getAllReferences($import_obj_id);
$import_ref_id = end($ref_ids);
$import_ref_id_parent = $tree->getParentId($import_ref_id);
if($a_parent_ref_id != $import_ref_id_parent)
{
// move node
$GLOBALS['ilLog']->write(__METHOD__.': Moving node '.$a_parent_ref_id.' to '.$import_ref_id);
$tree->moveTree($import_ref_id,$a_parent_ref_id);
}
// iterate through childs
$childs = $this->getTree()->getChilds($a_tnode_id);
foreach((array) $childs as $node)
{
$this->handleTreeUpdate($import_ref_id, $node['child']);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCmsTreeSynchronizer::sync ( )

Synchronize tree.

Returns
boolean

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

References $GLOBALS, checkTreeUpdates(), getDefaultSettings(), getServer(), ilECSCmsTree\lookupRootId(), ilECSNodeMappingAssignments\lookupSettings(), and syncNode().

{
include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
$this->getServer()->getServerId(),
$this->mid,
$this->tree_id,
0
);
// return if setting is false => no configuration done
if(!$this->getDefaultSettings())
{
$GLOBALS['ilLog']->write(__METHOD__.': No directory allocation settings. Aborting');
return true;
}
// lookup obj id of root node
include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
$root_obj_id = ilECSCmsTree::lookupRootId($this->tree_id);
$this->syncNode($root_obj_id,0);
// Tree structure is up to date, now check node movements
$this->checkTreeUpdates($root_obj_id);
return true;
}

+ Here is the call graph for this function:

ilECSCmsTreeSynchronizer::syncCategory ( ilECSNodeMappingAssignment  $ass,
  $parent_id 
)
protected

Sync category.

Parameters
ilECSNodeMappingAssignment$ass

Definition at line 228 of file class.ilECSCmsTreeSynchronizer.php.

References $GLOBALS, $ref_id, ilObject\_getAllReferences(), ilECSNodeMappingAssignment\getCSId(), getGlobalSettings(), ilObjectFactory\getInstanceByRefId(), getServer(), ilECSImport\lookupObjIdByContentId(), and ilECSImport\setMID().

Referenced by syncNode().

{
include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
$data = new ilECSCmsData($ass->getCSId());
// Check if node is imported => create
// perform title update
// perform position update
include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
$this->getServer()->getServerId(),
$this->mid,
$data->getCmsId());
if($obj_id)
{
$refs = ilObject::_getAllReferences($obj_id);
$ref_id = end($refs);
if(($cat instanceof ilObject) and $this->default_settings['title_update'])
{
$GLOBALS['ilLog']->write(__METHOD__.': Updating cms category ');
$GLOBALS['ilLog']->write(__METHOD__.': Title is '. $data->getTitle());
$cat->deleteTranslation($GLOBALS['lng']->getDefaultLanguage());
$cat->addTranslation(
$data->getTitle(),
$cat->getLongDescription(),
$GLOBALS['lng']->getDefaultLanguage(),
1
);
$cat->setTitle($data->getTitle());
$cat->update();
}
else
{
$GLOBALS['ilLog']->write(__METHOD__.': Updating cms category -> nothing to do');
}
return $ref_id;
}
elseif($this->getGlobalSettings()->isEmptyContainerCreationEnabled())
{
$GLOBALS['ilLog']->write(__METHOD__.': Creating new cms category');
// Create category
include_once './Modules/Category/classes/class.ilObjCategory.php';
$cat = new ilObjCategory();
$cat->setTitle($data->getTitle());
$cat->create(); // true for upload
$cat->createReference();
$cat->putInTree($parent_id);
$cat->setPermissions($parent_id);
$cat->deleteTranslation($GLOBALS['lng']->getDEfaultLanguage());
$cat->addTranslation(
$data->getTitle(),
$cat->getLongDescription(),
$GLOBALS['lng']->getDefaultLanguage(),
1
);
// set imported
$import = new ilECSImport(
$this->getServer()->getServerId(),
$cat->getId()
);
$import->setMID($this->mid);
$import->setContentId($data->getCmsId());
$import->setImported(true);
$import->save();
return $cat->getRefId();
}
else
{
$GLOBALS['ilLog']->write(__METHOD__.': Creation of empty containers is disabled.');
return 0;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCmsTreeSynchronizer::syncNode (   $tree_obj_id,
  $parent_id,
  $a_mapped = false 
)
protected

Sync node.

Parameters
type$cs_id
type$setting

Definition at line 186 of file class.ilECSCmsTreeSynchronizer.php.

References getServer(), getTree(), and syncCategory().

Referenced by sync().

{
$childs = $this->getTree()->getChilds($tree_obj_id);
$assignment = new ilECSNodeMappingAssignment(
$this->getServer()->getServerId(),
$this->mid,
$this->tree_id,
$tree_obj_id);
if($assignment->getRefId())
{
$parent_id = $assignment->getRefId();
}
// information for deeper levels
if($assignment->isMapped())
{
$a_mapped = true;
}
if($a_mapped)
{
$parent_id = $this->syncCategory($assignment,$parent_id);
}
// this is not necessary
#if($parent_id)
{
// iterate through childs
foreach($childs as $node)
{
$this->syncNode($node['child'],$parent_id,$a_mapped);
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilECSCmsTreeSynchronizer::$default_settings = array()
private

Definition at line 22 of file class.ilECSCmsTreeSynchronizer.php.

Referenced by getDefaultSettings().

ilECSCmsTreeSynchronizer::$global_settings = null
private

Definition at line 23 of file class.ilECSCmsTreeSynchronizer.php.

Referenced by getGlobalSettings().

ilECSCmsTreeSynchronizer::$mid = null
private

Definition at line 18 of file class.ilECSCmsTreeSynchronizer.php.

Referenced by __construct().

ilECSCmsTreeSynchronizer::$server = null
private

Definition at line 17 of file class.ilECSCmsTreeSynchronizer.php.

Referenced by __construct(), and getServer().

ilECSCmsTreeSynchronizer::$tree = null
private

Definition at line 20 of file class.ilECSCmsTreeSynchronizer.php.

Referenced by getTree(), and handleTreeUpdate().

ilECSCmsTreeSynchronizer::$tree_id = null
private

Definition at line 19 of file class.ilECSCmsTreeSynchronizer.php.

Referenced by __construct().


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