// 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 range tree * * This class prints out a html representation a part of the tree * * @access public * @author André Noack * @package */ class StudipSemRangeTreeViewSimple { var $tree; var $show_entries; var $start_item_id; var $root_content; /** * constructor * * @access 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("StudipRangeTree",$args); if (!$this->tree->tree_data[$this->start_item_id]){ $this->start_item_id = "root"; } } public function showSemRangeTree($start_id = null) { echo '
'. '
'. $this->getSemPath($start_id); echo '
'. formatReady($this->tree->getValue($this->start_item_id, 'name')). '
' . formatReady($this->getTooltip($this->start_item_id)) . '
'; 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 '
'; $this->showKids($this->start_item_id); echo '
'; $this->showContent($this->start_item_id); echo '
'; } function showKids($item_id){ $num_kids = $this->tree->getNumKids($item_id); $kids = $this->tree->getKids($item_id); $kids_table = '
    '; } } if (!$num_kids){ $kids_table .= "
  • "; $kids_table .= _("Auf dieser Ebene existieren keine weiteren Unterebenen."); $kids_table .= "
  • "; } $kids_table .= "
"; echo $kids_table; } function getTooltip($item_id){ if ($item_id == "root"){ $ret = ($this->root_content) ? $this->root_content : _("Keine weitere Info vorhanden"); } else { $range_object = RangeTreeObject::GetInstance($item_id); if (is_array($range_object->item_data_mapping)){ foreach ($range_object->item_data_mapping as $key => $value){ if ($range_object->item_data[$key]){ $info .= $value . ": "; $info .= $range_object->item_data[$key]. " "; } } } $ret = ($info) ? $info : _("Keine weitere Info vorhanden"); } return $ret; } public function getInfoIcon($item_id) { if ($item_id === 'root') { $info = $this->root_content; } $ret = $info ? tooltipicon(kill_format($info)) : ''; return $ret; } function showContent($item_id){ 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_tree&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_entries = $this->tree->getNumEntries($this->start_item_id,true))){ echo "  /  "; if ($this->show_entries != "sublevels"){ echo "getSelf("cmd=show_sem_range_tree&item_id={$this->start_item_id}_withkids")) ."\">"; } printf(_("%s Einträge in allen Unterebenen vorhanden"), $num_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 ? ' / ' : '') . '' . htmlReady($this->tree->tree_data[$parents[$i]]['name']) . ''; $add_item = true; } } } if ($this->start_item_id == 'root') { $ret = '' . $this->tree->root_name . ''; } else { $ret .= ' / '. htmlReady($this->tree->tree_data[$this->start_item_id]['name']). ''; $ret .= ' /  '; } return $ret; } function getSelf($param = '', $with_start_item = true){ $url_params = (($with_start_item) ? 'start_item_id=' . $this->start_item_id . '&' : '') . $param ; return '?' . $url_params; } } ?>