// Suchi & Berg GmbH // +---------------------------------------------------------------------------+ // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or any later version. // +---------------------------------------------------------------------------+ // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // +---------------------------------------------------------------------------+ /** * class to print out the seminar tree * * This class prints out a html representation a part of the tree * * @access public * @author André Noack * @package */ class StudipSemTreeViewSimple { var $tree; var $show_entries; var $start_item_id; var $root_content; /** * constructor * */ public function __construct($start_item_id = 'root', $sem_number = false, $sem_status = false, $visible_only = false) { $this->start_item_id = ($start_item_id) ? $start_item_id : "root"; $this->root_content = $GLOBALS['UNI_INFO']; $args = null; if ($sem_number !== false){ $args['sem_number'] = $sem_number; } if ($sem_status !== false){ $args['sem_status'] = $sem_status; } $args['visible_only'] = $visible_only; $this->tree = TreeAbstract::GetInstance("StudipSemTree",$args); $this->tree->enable_lonely_sem = false; if (!$this->tree->tree_data[$this->start_item_id]){ $this->start_item_id = "root"; } } public function showSemTree($start_id = null) { echo '
'. '
'. $this->getSemPath($start_id); echo '
'. formatReady($this->tree->getValue($this->start_item_id, 'name')). '
'; if ($this->tree->getValue($this->start_item_id, 'info')) { echo formatReady($this->tree->getValue($this->start_item_id, 'info')); }else{ echo _("Keine weitere Info vorhanden"); } echo'
'; echo '
'; if ($this->start_item_id != 'root') { echo ' ' . Icon::create('arr_2left', 'clickable')->asImg(['class' => 'text-top', 'title' =>_('eine Ebene zurück')]) . ''; } else { echo ' '; } echo '
'; $num_all_entries = $this->showKids($this->start_item_id); echo '
'; $this->showContent($this->start_item_id, $num_all_entries); echo '
'; } public function showKids($item_id) { $num_kids = $this->tree->getNumKids($item_id); $all_kids = $this->tree->getKids($item_id); $kids = []; if(!$GLOBALS['perm']->have_perm(Config::GetInstance()->getValue('SEM_TREE_SHOW_EMPTY_AREAS_PERM')) && $num_kids){ foreach($all_kids as $kid){ if($this->tree->getNumKids($kid) || $this->tree->getNumEntries($kid,true)) $kids[] = $kid; } $num_kids = count($kids); } else { $kids = $all_kids; } $num_all_entries = 0; $kids_table = '
    '; } } if (!$num_kids){ $kids_table .= "
  • "; $kids_table .= _("Auf dieser Ebene existieren keine weiteren Unterebenen."); $kids_table .= "
  • "; } $kids_table .= "
"; echo $kids_table; return $num_all_entries; } public function getInfoIcon($item_id) { if ($item_id === 'root') { $info = $this->root_content; } $ret = $info ? tooltipicon(kill_format($info)) : ''; return $ret; } public function showContent($item_id, $num_all_entries = 0) { echo "\n
"; if ($item_id != "root"){ if ($num_entries = $this->tree->getNumEntries($item_id)){ if ($this->show_entries != "level"){ echo "getSelf("cmd=show_sem_range&item_id=$item_id")) ."\">"; } printf(_("%s Einträge auf dieser Ebene. "),$num_entries); if ($this->show_entries != "level"){ echo ""; } } else { echo _("Keine Einträge auf dieser Ebene vorhanden!"); } if ($this->tree->hasKids($item_id) && $num_all_entries){ echo "  /  "; if ($this->show_entries != "sublevels"){ if ($num_all_entries <= 100) echo "getSelf("cmd=show_sem_range&item_id={$this->start_item_id}_withkids")) ."\">"; } printf(_("%s Einträge in allen Unterebenen vorhanden"), $num_all_entries); if ($this->show_entries != "sublevels"){ echo ""; } } } echo "\n
"; } public function getSemPath($start_id = null) { $parents = $this->tree->getParents($this->start_item_id); if ($parents) { $add_item = false; $start_id = $start_id === null ? 'root' : $start_id; for($i = count($parents) - 1; $i >= 0; --$i){ if ($add_item || $start_id == $parents[$i]) { $ret .= ($add_item === TRUE ? ' / ' : '') . "getSelf("start_item_id={$parents[$i]}", false)). "\">". htmlReady($this->tree->getValue($parents[$i], "name")).""; $add_item = true; } } } if ($this->start_item_id == "root") { $ret = "getSelf("start_item_id=root",false)) . "\">" . $this->tree->root_name . ""; } else { $ret .= " / getSelf("start_item_id={$this->start_item_id}",false)) . "\">" . htmlReady($this->tree->getValue($this->start_item_id, "name")) . ""; $ret .= " /  "; } return $ret; } /** * @return string url NOT escaped */ public function getSelf($param = "", $with_start_item = true) { $url_params = (($with_start_item) ? "start_item_id=" . $this->start_item_id . "&" : "") . $param ; return URLHelper::getURL('?' . $url_params); } } ?>