ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
33 class ilPathGUI
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 
42  protected $lng = null;
43  protected $tree = null;
44 
48  public function __construct()
49  {
50  global $tree,$lng;
51 
52  $this->tree = $tree;
53  $this->lng = $lng;
54 
55  }
56 
63  public function getPath($a_startnode,$a_endnode)
64  {
65  $this->startnode = $a_startnode;
66  $this->endnode = $a_endnode;
67 
68  return $this->getHTML();
69  }
70 
76  public function enableTextOnly($a_status)
77  {
78  $this->textOnly = $a_status;
79  }
80 
85  public function textOnly()
86  {
87  return $this->textOnly;
88  }
89 
94  public function enableHideLeaf($a_status)
95  {
96  $this->hide_leaf = $a_status;
97  }
98 
99  public function hideLeaf()
100  {
101  return $this->hide_leaf;
102  }
108  public function setUseImages($a_status)
109  {
110  $this->useImages = $a_status;
111  }
112 
117  public function getUseImages()
118  {
119  return $this->useImages;
120  }
121 
126  protected function getHTML()
127  {
128  if($this->textOnly())
129  {
130  $tpl = new ilTemplate('tpl.locator_text_only.html',true,true, "Services/Locator");
131 
132  $first = true;
133  foreach($this->getPathIds() as $ref_id)
134  {
135  $obj_id = ilObject::_lookupObjId($ref_id);
136  $title = ilObject::_lookupTitle($obj_id);
137 
138  if($first)
139  {
140  if($ref_id == ROOT_FOLDER_ID)
141  {
142  $title = $this->lng->txt('repository');
143  }
144  }
145  else
146  {
147  $tpl->touchBlock('locator_separator_prefix');
148  }
149 
150  $tpl->setCurrentBlock('locator_item');
151  $tpl->setVariable('ITEM',$title);
152  $tpl->parseCurrentBlock();
153  $first = false;
154  }
155  return $tpl->get();
156  }
157  else
158  {
159  // With images and links
160  include_once './Services/Link/classes/class.ilLink.php';
161 
162  $tpl = new ilTemplate('tpl.locator.html',true,true,'Services/Locator');
163 
164  $first = true;
165  foreach($this->getPathIds() as $ref_id)
166  {
167  $obj_id = ilObject::_lookupObjId($ref_id);
168  $title = ilObject::_lookupTitle($obj_id);
169  $type = ilObject::_lookupType($obj_id);
170 
171  if($first)
172  {
173  if($ref_id == ROOT_FOLDER_ID)
174  {
175  $title = $this->lng->txt('repository');
176  }
177  }
178  else
179  {
180  $tpl->touchBlock('locator_separator_prefix');
181  }
182  if($this->getUseImages())
183  {
184  $tpl->setCurrentBlock('locator_img');
185  $tpl->setVariable('IMG_SRC',ilUtil::getTypeIconPath($type,$obj_id));
186  $tpl->setVariable('IMG_ALT',$this->lng->txt('obj_'.$type));
187  $tpl->parseCurrentBlock();
188  }
189  $tpl->setCurrentBlock('locator_item');
190  $tpl->setVariable('LINK_ITEM',ilLink::_getLink($ref_id,$type));
191  $tpl->setVariable('ITEM',$title);
192  $tpl->parseCurrentBlock();
193  $first = false;
194  }
195  return $tpl->get();
196  }
197  }
198 
204  protected function getPathIds()
205  {
206  $path = $this->tree->getPathId($this->endnode,$this->startnode);
207  if($this->hideLeaf())
208  {
209  unset($path[count($path) - 1]);
210  }
211  return $path ? $path : array();
212  }
213 }
214 ?>