ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilPathGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
34{
35 private $startnode = ROOT_FOLDER_ID;
36 private $endnode = ROOT_FOLDER_ID;
37
38 private $textOnly = true;
39 private $useImages = false;
40 private $hide_leaf = true;
41 private $display_cut = false;
42
43 protected $lng = null;
44 protected $tree = null;
45
49 public function __construct()
50 {
51 global $tree,$lng;
52
53 $this->tree = $tree;
54 $this->lng = $lng;
55
56 }
57
64 public function getPath($a_startnode,$a_endnode)
65 {
66 $this->startnode = $a_startnode;
67 $this->endnode = $a_endnode;
68
69 return $this->getHTML();
70 }
71
77 public function enableTextOnly($a_status)
78 {
79 $this->textOnly = $a_status;
80 }
81
86 public function textOnly()
87 {
88 return $this->textOnly;
89 }
90
95 public function enableHideLeaf($a_status)
96 {
97 $this->hide_leaf = $a_status;
98 }
99
100 public function hideLeaf()
101 {
102 return $this->hide_leaf;
103 }
109 public function setUseImages($a_status)
110 {
111 $this->useImages = $a_status;
112 }
113
118 public function getUseImages()
119 {
120 return $this->useImages;
121 }
122
127 public function enableDisplayCut($a_status)
128 {
129 $this->display_cut = $a_status;
130 }
131
136 public function displayCut()
137 {
138 return $this->display_cut;
139 }
140
145 protected function getHTML()
146 {
147 if($this->textOnly())
148 {
149 $tpl = new ilTemplate('tpl.locator_text_only.html',true,true, "Services/Locator");
150
151 $first = true;
152
153 // Display cut
154 if($this->displayCut() && $this->startnode != ROOT_FOLDER_ID)
155 {
156 $tpl->setCurrentBlock('locator_item');
157 $tpl->setVariable('ITEM',"...");
158 $tpl->parseCurrentBlock();
159
160 $first = false;
161 }
162
163 foreach($this->getPathIds() as $ref_id)
164 {
166 $title = ilObject::_lookupTitle($obj_id);
167
168 if($first)
169 {
170 if($ref_id == ROOT_FOLDER_ID)
171 {
172 $title = $this->lng->txt('repository');
173 }
174 }
175 else
176 {
177 $tpl->touchBlock('locator_separator_prefix');
178 }
179
180 $tpl->setCurrentBlock('locator_item');
181 $tpl->setVariable('ITEM',$title);
182 $tpl->parseCurrentBlock();
183 $first = false;
184 }
185 return $tpl->get();
186 }
187 else
188 {
189 // With images and links
190 include_once './Services/Link/classes/class.ilLink.php';
191
192 $tpl = new ilTemplate('tpl.locator.html',true,true,'Services/Locator');
193
194 $first = true;
195
196 // Display cut
197 if($this->displayCut() && $this->startnode != ROOT_FOLDER_ID)
198 {
199 $tpl->setCurrentBlock('locator_item');
200 $tpl->setVariable('ITEM',"...");
201 $tpl->parseCurrentBlock();
202
203 $first = false;
204 }
205
206 foreach($this->getPathIds() as $ref_id)
207 {
209 $title = ilObject::_lookupTitle($obj_id);
210 $type = ilObject::_lookupType($obj_id);
211
212 if($first)
213 {
214 if($ref_id == ROOT_FOLDER_ID)
215 {
216 $title = $this->lng->txt('repository');
217 }
218 }
219 else
220 {
221 $tpl->touchBlock('locator_separator_prefix');
222 }
223 if($this->getUseImages())
224 {
225 $tpl->setCurrentBlock('locator_img');
226 $tpl->setVariable('IMG_SRC',ilUtil::getTypeIconPath($type,$obj_id));
227 $tpl->setVariable('IMG_ALT',$this->lng->txt('obj_'.$type));
228 $tpl->parseCurrentBlock();
229 }
230 $tpl->setCurrentBlock('locator_item');
231 $tpl->setVariable('LINK_ITEM',ilLink::_getLink($ref_id,$type));
232 $tpl->setVariable('ITEM',$title);
233 $tpl->parseCurrentBlock();
234 $first = false;
235 }
236 return $tpl->get();
237 }
238 }
239
245 protected function getPathIds()
246 {
247 $path = $this->tree->getPathId($this->endnode,$this->startnode);
248 if($this->hideLeaf())
249 {
250 unset($path[count($path) - 1]);
251 }
252 return $path ? $path : array();
253 }
254}
255?>
global $tpl
Definition: ilias.php:8
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
Creates a path for a start and endnode.
getUseImages()
get use images
setUseImages($a_status)
set use images
getHTML()
get html
displayCut()
Display a cut with "...".
__construct()
Constructor.
getPath($a_startnode, $a_endnode)
get path
textOnly()
show text only
enableDisplayCut($a_status)
Display a cut with "...".
enableHideLeaf($a_status)
Hide leaf node in path.
enableTextOnly($a_status)
render path as text only
special template class to simplify handling of ITX/PEAR
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
$ref_id
Definition: sahs_server.php:39
$path
Definition: index.php:22