Example #1
0
 /**
  * get path ids (adjacenca and nested set)
  * @group IL_Init
  * @param
  * @return
  */
 public function testAllOthers()
 {
     $tree = new ilTree(ROOT_FOLDER_ID);
     $d = $tree->getDepth(24);
     $this->assertEquals($d, 4);
     $node = $tree->getNodeData(24);
     $this->assertEquals($node['title'], 'Public chat');
     $bool = $tree->isInTree(24);
     $this->assertEquals($bool, true);
     $bool = $tree->isInTree(24242424);
     $this->assertEquals($bool, false);
     /* ref_id 14 => obj_id 98 does not exist
     		$node = $tree->getParentNodeData(24);
     		$this->assertEquals($node['title'],'Chat-Server');
     		*/
     $bool = $tree->isGrandChild(9, 24);
     $this->assertEquals($bool, 1);
     /* see above
     		$node = $tree->getNodeDataByType('chac');
     		$this->assertEquals($node[0]['title'],'Chat-Server');
     		*/
     $bool = $tree->isDeleted(24);
     $this->assertEquals($bool, false);
     $id = $tree->getParentId(24);
     $this->assertEquals($id, 14);
     $lft = $tree->getLeftValue(24);
     $this->assertEquals($lft, 14);
     $seq = $tree->getChildSequenceNumber($tree->getNodeData(24));
     $this->assertEquals($seq, 1);
     $tree->getNodePath(9, 1);
     $max_depth = $tree->getMaximumDepth();
     // Round trip
     $tree = new ilTree(ROOT_FOLDER_ID);
     $suc = $tree->fetchSuccessorNode(16);
     // cals
     $cals = $tree->fetchPredecessorNode($suc['child']);
     $this->assertEquals($cals['child'], 16);
 }
 /**
  * presentation title doesn't have to be page title, it may be
  * chapter title + page title or chapter title only, depending on settings
  *
  * @param	string	$a_mode		IL_CHAPTER_TITLE | IL_PAGE_TITLE | IL_NO_HEADER
  */
 function _getPresentationTitle($a_pg_id, $a_mode = IL_CHAPTER_TITLE, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_force_content = false)
 {
     global $ilDB;
     // select
     $query = "SELECT * FROM lm_data WHERE obj_id = " . $ilDB->quote($a_pg_id, "integer");
     $pg_set = $ilDB->query($query);
     $pg_rec = $ilDB->fetchAssoc($pg_set);
     if ($a_mode == IL_NO_HEADER && !$a_force_content) {
         return "";
     }
     $tree = new ilTree($pg_rec["lm_id"]);
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     if ($a_mode == IL_PAGE_TITLE) {
         $nr = "";
         return $nr . $pg_rec["title"];
     }
     if ($tree->isInTree($pg_rec["obj_id"])) {
         $pred_node = $tree->fetchPredecessorNode($pg_rec["obj_id"], "st");
         $childs = $tree->getChildsByType($pred_node["obj_id"], "pg");
         $cnt_str = "";
         if (count($childs) > 1) {
             $cnt = 0;
             foreach ($childs as $child) {
                 include_once "./Services/COPage/classes/class.ilPageObject.php";
                 $active = ilPageObject::_lookupActive($child["obj_id"], ilObject::_lookupType($pg_rec["lm_id"]), $a_time_scheduled_activation);
                 if (!$active) {
                     $act_data = ilPageObject::_lookupActivationData((int) $child["obj_id"], ilObject::_lookupType($pg_rec["lm_id"]));
                     if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                         $active = true;
                     }
                 }
                 if ($child["type"] != "pg" || $active) {
                     $cnt++;
                 }
                 if ($child["obj_id"] == $pg_rec["obj_id"]) {
                     $cur_cnt = $cnt;
                 }
             }
             if ($cnt > 1) {
                 $cnt_str = " (" . $cur_cnt . "/" . $cnt . ")";
             }
         }
         require_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
         //$struct_obj =& new ilStructureObject($pred_node["obj_id"]);
         //return $struct_obj->getTitle();
         return ilStructureObject::_getPresentationTitle($pred_node["obj_id"], $a_include_numbers) . $cnt_str;
         //return $pred_node["title"].$cnt_str;
     } else {
         return $pg_rec["title"];
     }
 }