ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
48 protected $tree = null;
49
53 public function __construct()
54 {
55 global $DIC;
56
57 $tree = $DIC['tree'];
58 $lng = $DIC['lng'];
59
60 $this->tree = $tree;
61 $this->lng = $lng;
62 }
63
70 public function getPath($a_startnode, $a_endnode)
71 {
72 $this->startnode = $a_startnode;
73 $this->endnode = $a_endnode;
74
75 return $this->getHTML();
76 }
77
83 public function enableTextOnly($a_status)
84 {
85 $this->textOnly = $a_status;
86 }
87
92 public function textOnly()
93 {
94 return $this->textOnly;
95 }
96
101 public function enableHideLeaf($a_status)
102 {
103 $this->hide_leaf = $a_status;
104 }
105
106 public function hideLeaf()
107 {
108 return $this->hide_leaf;
109 }
115 public function setUseImages($a_status)
116 {
117 $this->useImages = $a_status;
118 }
119
124 public function getUseImages()
125 {
126 return $this->useImages;
127 }
128
133 public function enableDisplayCut($a_status)
134 {
135 $this->display_cut = $a_status;
136 }
137
142 public function displayCut()
143 {
144 return $this->display_cut;
145 }
146
151 protected function getHTML()
152 {
153 if ($this->textOnly()) {
154 $tpl = new ilTemplate('tpl.locator_text_only.html', true, true, "Services/Locator");
155
156 $first = true;
157
158 // Display cut
159 if ($this->displayCut() && $this->startnode != ROOT_FOLDER_ID) {
160 $tpl->setCurrentBlock('locator_item');
161 $tpl->setVariable('ITEM', "...");
162 $tpl->parseCurrentBlock();
163
164 $first = false;
165 }
166
167 foreach ($this->getPathIds() as $ref_id) {
168 $obj_id = ilObject::_lookupObjId($ref_id);
169 $title = $this->buildTitle($obj_id);
170
171 if ($first) {
172 if ($ref_id == ROOT_FOLDER_ID) {
173 $title = $this->lng->txt('repository');
174 }
175 } else {
176 $tpl->touchBlock('locator_separator_prefix');
177 }
178
179 $tpl->setCurrentBlock('locator_item');
180 $tpl->setVariable('ITEM', $title);
181 $tpl->parseCurrentBlock();
182 $first = false;
183 }
184 return $tpl->get();
185 } else {
186 // With images and links
187 include_once './Services/Link/classes/class.ilLink.php';
188
189 $tpl = new ilTemplate('tpl.locator.html', true, true, 'Services/Locator');
190
191 $first = true;
192
193 // Display cut
194 if ($this->displayCut() && $this->startnode != ROOT_FOLDER_ID) {
195 $tpl->setCurrentBlock('locator_item');
196 $tpl->setVariable('ITEM', "...");
197 $tpl->parseCurrentBlock();
198
199 $first = false;
200 }
201
202 foreach ($this->getPathIds() as $ref_id) {
203 $obj_id = ilObject::_lookupObjId($ref_id);
204 $title = $this->buildTitle($obj_id);
205 $type = ilObject::_lookupType($obj_id);
206
207 if ($first) {
208 if ($ref_id == ROOT_FOLDER_ID) {
209 $title = $this->lng->txt('repository');
210 }
211 } else {
212 $tpl->touchBlock('locator_separator_prefix');
213 }
214 if ($this->getUseImages()) {
215 $tpl->setCurrentBlock('locator_img');
216 $tpl->setVariable('IMG_SRC', ilUtil::getTypeIconPath($type, $obj_id));
217 $tpl->setVariable('IMG_ALT', $this->lng->txt('obj_' . $type));
218 $tpl->parseCurrentBlock();
219 }
220
221 if (!$this->tree->isDeleted($ref_id)) {
222 $tpl->setCurrentBlock('locator_item');
223 $tpl->setVariable('LINK_ITEM', ilUtil::secureLink(ilLink::_getLink($ref_id, $type)));
224 $tpl->setVariable('ITEM', $title);
225 $tpl->parseCurrentBlock();
226 } else {
227 $tpl->setCurrentBlock('locator_item');
228 $tpl->setVariable('ITEM_READ_ONLY', $title);
229 $tpl->parseCurrentBlock();
230 }
231
232 $first = false;
233 }
234 $tpl->setVariable("TXT_BREADCRUMBS", $this->lng->txt("breadcrumb_navigation"));
235 return $tpl->get();
236 }
237 }
238
243 protected function buildTitle($a_obj_id)
244 {
245 return ilObject::_lookupTitle($a_obj_id);
246 }
247
253 protected function getPathIds()
254 {
255 $path = $this->tree->getPathId($this->endnode, $this->startnode);
256
257 \ilLoggerFactory::getLogger('tree')->dump($path);
258 \ilLoggerFactory::getLogger('tree')->dump($this->endnode);
259 \ilLoggerFactory::getLogger('tree')->dump($this->startnode);
260
261 if ($this->hideLeaf()) {
262 unset($path[count($path) - 1]);
263 }
264 return $path ? $path : array();
265 }
266}
An exception for terminatinating execution or to throw for unit testing.
static getLogger($a_component_id)
Get component logger.
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 "...".
buildTitle($a_obj_id)
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 secureLink($a_str)
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...
$type
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$DIC
Definition: xapitoken.php:46