ILIAS  Release_4_0_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 
41  protected $lng = null;
42  protected $tree = null;
43 
47  public function __construct()
48  {
49  global $tree,$lng;
50 
51  $this->tree = $tree;
52  $this->lng = $lng;
53 
54  }
55 
62  public function getPath($a_startnode,$a_endnode)
63  {
64  $this->startnode = $a_startnode;
65  $this->endnode = $a_endnode;
66 
67  return $this->getHTML();
68  }
69 
75  public function enableTextOnly($a_status)
76  {
77  $this->textOnly = $a_status;
78  }
79 
84  public function textOnly()
85  {
86  return $this->textOnly;
87  }
88 
94  public function setUseImages($a_status)
95  {
96  $this->useImages = $a_status;
97  }
98 
103  public function getUseImages()
104  {
105  return $this->useImages;
106  }
107 
112  protected function getHTML()
113  {
114  if($this->textOnly())
115  {
116  $tpl = new ilTemplate('tpl.locator_text_only.html',true,true, "Services/Locator");
117 
118  $first = true;
119  foreach($this->getPathIds() as $ref_id)
120  {
121  $obj_id = ilObject::_lookupObjId($ref_id);
122  $title = ilObject::_lookupTitle($obj_id);
123 
124  if($first)
125  {
126  if($ref_id == ROOT_FOLDER_ID)
127  {
128  $title = $this->lng->txt('repository');
129  }
130  }
131  else
132  {
133  $tpl->touchBlock('locator_separator_prefix');
134  }
135 
136  $tpl->setCurrentBlock('locator_item');
137  $tpl->setVariable('ITEM',$title);
138  $tpl->parseCurrentBlock();
139  $first = false;
140  }
141  return $tpl->get();
142  }
143  else
144  {
145  // With images and links
146  include_once './classes/class.ilLink.php';
147 
148  $tpl = new ilTemplate('tpl.locator.html',true,true);
149 
150  $first = true;
151  foreach($this->getPathIds() as $ref_id)
152  {
153  $obj_id = ilObject::_lookupObjId($ref_id);
154  $title = ilObject::_lookupTitle($obj_id);
155  $type = ilObject::_lookupType($obj_id);
156 
157  if($first)
158  {
159  if($ref_id == ROOT_FOLDER_ID)
160  {
161  $title = $this->lng->txt('repository');
162  }
163  }
164  else
165  {
166  $tpl->touchBlock('locator_separator_prefix');
167  }
168  if($this->getUseImages())
169  {
170  $tpl->setCurrentBlock('locator_img');
171  $tpl->setVariable('IMG_SRC',ilUtil::getTypeIconPath($type,$obj_id));
172  $tpl->setVariable('IMG_ALT',$this->lng->txt('obj_'.$type));
173  $tpl->parseCurrentBlock();
174  }
175  $tpl->setCurrentBlock('locator_item');
176  $tpl->setVariable('LINK_ITEM',ilLink::_getLink($ref_id,$type));
177  $tpl->setVariable('ITEM',$title);
178  $tpl->parseCurrentBlock();
179  $first = false;
180  }
181  return $tpl->get();
182  }
183  }
184 
190  protected function getPathIds()
191  {
192  $path = $this->tree->getPathId($this->endnode,$this->startnode);
193  unset($path[count($path) - 1]);
194  return $path ? $path : array();
195  }
196 }
197 ?>