本文整理汇总了PHP中ilTree::getSubtree方法的典型用法代码示例。如果您正苦于以下问题:PHP ilTree::getSubtree方法的具体用法?PHP ilTree::getSubtree怎么用?PHP ilTree::getSubtree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilTree
的用法示例。
在下文中一共展示了ilTree::getSubtree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getChapterList
/**
* export (sub)structure objects of structure object (see ilias_co.dtd)
*
* @param object $a_xml_writer ilXmlWriter object that receives the
* xml data
*/
static function getChapterList($a_lm_id)
{
$tree = new ilTree($a_lm_id);
$tree->setTableNames('lm_tree', 'lm_data');
$tree->setTreeTablePK("lm_id");
$chapters = array();
$ndata = $tree->getNodeData($tree->readRootId());
$childs = $tree->getSubtree($ndata);
foreach ($childs as $child) {
if ($child["type"] == "st") {
$chapters[] = $child;
}
}
return $chapters;
}
示例2: executeDragDrop
/**
* Execute Drag Drop Action
*
* @param string $source_id Source element ID
* @param string $target_id Target element ID
* @param string $first_child Insert as first child of target
* @param string $movecopy Position ("move" | "copy")
*/
function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
{
$lmtree = new ilTree($this->getId());
$lmtree->setTableNames('lm_tree', 'lm_data');
$lmtree->setTreeTablePK("lm_id");
//echo "-".$source_id."-".$target_id."-".$first_child."-".$as_subitem."-";
$source_obj = ilLMObjectFactory::getInstance($this, $source_id, true);
$source_obj->setLMId($this->getId());
if (!$first_child) {
$target_obj = ilLMObjectFactory::getInstance($this, $target_id, true);
$target_obj->setLMId($this->getId());
$target_parent = $lmtree->getParentId($target_id);
}
// handle pages
if ($source_obj->getType() == "pg") {
//echo "1";
if ($lmtree->isInTree($source_obj->getId())) {
$node_data = $lmtree->getNodeData($source_obj->getId());
// cut on move
if ($movecopy == "move") {
$parent_id = $lmtree->getParentId($source_obj->getId());
$lmtree->deleteTree($node_data);
// write history entry
require_once "./Services/History/classes/class.ilHistory.php";
ilHistory::_createEntry($source_obj->getId(), "cut", array(ilLMObject::_lookupTitle($parent_id), $parent_id), $this->getType() . ":pg");
ilHistory::_createEntry($parent_id, "cut_page", array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()), $this->getType() . ":st");
} else {
// copy page
$new_page =& $source_obj->copy();
$source_id = $new_page->getId();
$source_obj =& $new_page;
}
// paste page
if (!$lmtree->isInTree($source_obj->getId())) {
if ($first_child) {
$target_pos = IL_FIRST_NODE;
$parent = $target_id;
} else {
if ($as_subitem) {
$parent = $target_id;
$target_pos = IL_FIRST_NODE;
$pg_childs =& $lmtree->getChildsByType($parent, "pg");
if (count($pg_childs) != 0) {
$target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
}
} else {
$target_pos = $target_id;
$parent = $target_parent;
}
}
// insert page into tree
$lmtree->insertNode($source_obj->getId(), $parent, $target_pos);
// write history entry
if ($movecopy == "move") {
// write history comments
include_once "./Services/History/classes/class.ilHistory.php";
ilHistory::_createEntry($source_obj->getId(), "paste", array(ilLMObject::_lookupTitle($parent), $parent), $this->getType() . ":pg");
ilHistory::_createEntry($parent, "paste_page", array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()), $this->getType() . ":st");
}
}
}
}
// handle chapters
if ($source_obj->getType() == "st") {
//echo "2";
$source_node = $lmtree->getNodeData($source_id);
$subnodes = $lmtree->getSubtree($source_node);
// check, if target is within subtree
foreach ($subnodes as $subnode) {
if ($subnode["obj_id"] == $target_id) {
return;
}
}
$target_pos = $target_id;
if ($first_child) {
$target_pos = IL_FIRST_NODE;
$target_parent = $target_id;
$pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
if (count($pg_childs) != 0) {
$target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
}
} else {
if ($as_subitem) {
$target_parent = $target_id;
$target_pos = IL_FIRST_NODE;
$childs =& $lmtree->getChilds($target_parent);
if (count($childs) != 0) {
$target_pos = $childs[count($childs) - 1]["obj_id"];
}
}
}
// insert into
//.........这里部分代码省略.........