* @package */ class ExternRangeLectureTree { var $tree; var $config; var $param; var $root_id; var $start_item_id; /** * constructor * * @access public */ function __construct(&$config, $start_item_id, $sem_number = false, $sem_status = false) { $this->config = $config; $query = "SELECT item_id FROM range_tree WHERE studip_object_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute([$this->config->range_id]); $this->root_id = $statement->fetchColumn(); $this->start_item_id = $start_item_id ?: $this->root_id; $args = NULL; if ($sem_number !== false) { $args['sem_number'] = $sem_number; } if ($sem_status !== false) { $args['sem_status'] = $sem_status; } $this->param = "range_id={$this->config->range_id}&module=Rangelecturetree&config_id={$this->config->id}&"; $this->tree = TreeAbstract::GetInstance("StudipRangeTree",$args); } function showSemRangeTree () { echo "\nconfig->getAttributes("Main", "table") . ">"; echo "\n". $this->getSemPath() . "\n"; $this->showContent($this->start_item_id); echo "\n"; if ($this->tree->getNumKids($this->start_item_id)) { echo "\n"; echo $this->showKids($this->start_item_id); echo "\n"; } if ($this->config->getAttributes("TreeBackLink", "image") || $this->config->getAttributes("TreeBackLink", "linktext")) { echo "\n"; echo $this->backLink($this->start_item_id) . "\n"; } echo "\n"; } function showKids ($item_id) { $num_kids = $this->tree->getNumKids($item_id); $kids = $this->tree->getKids($item_id); $attributes_a = $this->config->getAttributes("TreeKids", "a"); $attributes_font = $this->config->getAttributes("TreeKids", "font"); $attributes_td = $this->config->getAttributes("TreeKids", "td"); echo "\nconfig->getAttributes("TreeKids", "table") . ">"; for ($i = 0; $i < $num_kids; ++$i){ $num_entries = $this->tree->getNumEntries($kids[$i],true); echo "\n"; echo "getSelf("{$this->param}start_item_id={$kids[$i]}", false)); echo "\"$attributes_a>"; echo htmlReady($this->tree->tree_data[$kids[$i]]['name']); echo " ($num_entries)"; echo ""; echo "\n"; } echo "
\n"; } function backLink ($item_id) { if ($item_id != $this->root_id){ echo "config->getAttributes("TreeBackLink", "table") . ">\n"; echo "config->getAttributes("TreeBackLink", "td") . ">"; if ($image = $this->config->getValue("TreeBackLink", "image")) { echo "getSelf("{$this->param}start_item_id={$this->tree->tree_data[$item_id]['parent_id']}", false)) . "\">"; echo " "; } if ($link_text = $this->config->getValue("TreeBackLink", "linktext")) { echo "getSelf("{$this->param}start_item_id={$this->tree->tree_data[$item_id]['parent_id']}", false)) . "\">"; echo "config->getAttributes("TreeBackLink", "font"); echo ">" . htmlReady($link_text) . ""; } echo "
\n"; } } function showContent ($item_id) { echo "config->getAttributes("RangeTreeLevelName", "table"); echo ">\nconfig->getAttributes("RangeTreeLevelName", "td") . ">"; echo "config->getAttributes("RangeTreeLevelName", "font") . ">"; $alias_names = $this->config->getValue("RangeTreeLevelName", "aliases"); $range_object = RangeTreeObject::GetInstance($item_id); if ($range_object->item_data['type']) $name = $alias_names[$range_object->item_data['type_num'] - 1] . " "; $name .= $range_object->item_data['name']; echo htmlReady($name) ."\n\n"; if (is_array($range_object->item_data_mapping)) { echo "\n"; echo "config->getAttributes("RangeTreeLevelContent", "table"); echo ">\nconfig->getAttributes("RangeTreeLevelContent", "td") . ">"; $alias_mapping = $this->config->getValue("RangeTreeLevelContent", "mapping"); $aliases = $this->config->getValue("RangeTreeLevelContent", "aliases"); foreach ($alias_mapping as $position => $key) { if ($range_object->item_data[$key]) { echo "config->getAttributes("RangeTreeLevelContent", "fontalias") . ">"; echo htmlReady($aliases[$position]) . " "; echo "config->getAttributes("RangeTreeLevelContent", "fontdata") . ">"; echo formatLinks($range_object->item_data[$key]) . "  "; } } echo "\n"; } } function getSemPath () { $delimiter = $this->config->getValue("TreePath", "delimiter"); $attributes_a = $this->config->getAttributes("TreePath", "a"); $ret = "config->getAttributes("TreePath", "table") . ">\n"; $ret .= "config->getAttributes("TreePath", "td") . ">"; $ret .= "config->getAttributes("TreePath", "td") . ">"; $parents = $this->tree->getParents($this->start_item_id); $parents_root = $this->tree->getParents($this->root_id); if (is_array($parents)) { $parents = array_diff($parents, $parents_root); while ($parent = array_pop($parents)) { $ret .= $delimiter; $ret .= "getSelf("{$this->param}start_item_id=".$parent,false)); $ret .= "\"$attributes_a>" . htmlReady($this->tree->tree_data[$parent]["name"]) . ""; } } if ($this->start_item_id != $this->root_id) $ret .= $delimiter; $ret .= htmlReady($this->tree->tree_data[$this->start_item_id]["name"]); $ret .= "
\n"; return $ret; } function getSelf ($param = "", $with_start_item = true) { if ($param) $url = $_SERVER['PHP_SELF'] . (($with_start_item) ? "?start_item_id=" . $this->start_item_id . "&" : "?") . $param ; else $url = $_SERVER['PHP_SELF'] . (($with_start_item) ? "?start_item_id=" . $this->start_item_id : "") ; return $url; } }