ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContainerSessionsContentGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 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 
24 include_once("./Services/Container/classes/class.ilContainerContentGUI.php");
25 
34 {
35  protected $force_details = array();
36 
41  function __construct($container_gui_obj)
42  {
43  global $lng;
44 
45  parent::__construct($container_gui_obj);
46  $this->lng = $lng;
47  $this->initDetails();
48  }
49 
50 
58  public function getDetailsLevel($a_session_id)
59  {
60  if($this->getContainerGUI()->isActiveAdministrationPanel())
61  {
63  }
64  if(isset($_SESSION['sess']['expanded'][$a_session_id]))
65  {
66  return $_SESSION['sess']['expanded'][$a_session_id];
67  }
68  if(in_array($a_session_id,$this->force_details))
69  {
70  return self::DETAILS_ALL;
71  }
72  else
73  {
74  return self::DETAILS_TITLE;
75  }
76  }
77 
78 
82  function getMainContent()
83  {
84  global $lng,$ilTabs;
85 
86  // see bug #7452
87 // $ilTabs->setSubTabActive($this->getContainerObject()->getType().'_content');
88 
89 
90  include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
91 
92  $tpl = new ilTemplate("tpl.container_page.html", true, true,
93  "Services/Container");
94 
95  // Feedback
96  // @todo
97 // $this->__showFeedBack();
98 
99  $this->__showMaterials($tpl);
100 
101  // @todo: Move this completely to GUI class?
102 /* $this->getContainerGUI()->adminCommands = $this->adminCommands;
103  $this->getContainerGUI()->showAdministrationPanel($tpl);
104  $this->getContainerGUI()->showPossibleSubObjects();
105  $this->getContainerGUI()->showPermanentLink($tpl);*/
106 
107  return $tpl->get();
108  }
109 
113  function __showMaterials($a_tpl)
114  {
115  global $ilAccess, $lng;
116 
117  $this->items = $this->getContainerObject()->getSubItems($this->getContainerGUI()->isActiveAdministrationPanel());
119 
120  $output_html = $this->getContainerGUI()->getContainerPageHTML();
121 
122  // get embedded blocks
123  if ($output_html != "")
124  {
125  $output_html = $this->insertPageEmbeddedBlocks($output_html);
126  }
127 
128  // sessions
129  $done_sessions = false;
130  $tpl = $this->newBlockTemplate();
131  if (
132  is_array($this->items["sess"]) or
133  $this->items['sess_link']['prev']['value'] or
134  $this->items['sess_link']['next']['value'])
135  {
136  $this->items['sess'] = ilUtil::sortArray($this->items['sess'],'start','ASC',true,true);
137 
138  // all rows
139  $item_html = array();
140  $position = 1;
141 
142  if($this->items['sess_link']['prev']['value'])
143  {
144  $item_html[] = $this->renderSessionLimitLink(true);
145  }
146 
147  foreach($this->items["sess"] as $item_data)
148  {
149  if ($this->rendered_items[$item_data["child"]] !== true)
150  {
151  $html = $this->renderItem($item_data,$position++,true);
152 
153  if ($html != "")
154  {
155  $item_html[] = $html;
156  }
157  }
158  }
159  if($this->items['sess_link']['next']['value'])
160  {
161  $item_html[] = $this->renderSessionLimitLink(false);
162  }
163 
164  // if we have at least one item, output the block
165  if (count($item_html) > 0)
166  {
167  $this->addHeaderRow($tpl, "", $lng->txt("objs_sess"));
168  foreach($item_html as $h)
169  {
170  $this->addStandardRow($tpl, $h);
171  }
172  $done_sessions = true;
173  }
174  }
175 
176  // all other items
177  if ($done_sessions)
178  {
179  $this->addSeparatorRow($tpl);
180  }
181 
182  // item groups
183  $this->getItemGroupsHTML($tpl);
184 
185 
186  if (is_array($this->items["_all"]))
187  {
188  // all rows
189  $item_html = array();
190  $position = 1;
191  foreach($this->items["_all"] as $item_data)
192  {
193  if ($this->rendered_items[$item_data["child"]] !== true)
194  {
195  if ($item_data["type"] == "sess" || $item_data["type"] == "itgr")
196  {
197  continue;
198  }
199  $html = $this->renderItem($item_data,$position++,true);
200  if ($html != "")
201  {
202  $item_html[] = $html;
203  }
204  }
205  }
206 
207  // if we have at least one item, output the block
208  if (count($item_html) > 0)
209  {
210  $this->addHeaderRow($tpl, "", $lng->txt("content"));
211  foreach($item_html as $h)
212  {
213  $this->addStandardRow($tpl, $h);
214  }
215  }
216  }
217 
218  $output_html .= $tpl->get();
219 
220  $a_tpl->setVariable("CONTAINER_PAGE_CONTENT", $output_html);
221  }
222 
227  protected function renderSessionLimitLink($a_previous = true)
228  {
229  global $lng, $ilUser, $ilCtrl;
230 
231  $lng->loadLanguageModule('crs');
232 
233  $tpl = new ilTemplate('tpl.container_list_item.html',true,true,
234  "Services/Container");
235  $tpl->setVariable('DIV_CLASS','ilContainerListItemOuter');
236  $tpl->setCurrentBlock('item_title_linked');
237 
238  if($a_previous)
239  {
240  $prefp = $ilUser->getPref('crs_sess_show_prev_'.$this->getContainerObject()->getId());
241 
242  if($prefp)
243  {
244  $tpl->setVariable('TXT_TITLE_LINKED',$lng->txt('crs_link_hide_prev_sessions'));
245  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()),'crs_prev_sess',(int) !$prefp);
246  $tpl->setVariable('HREF_TITLE_LINKED',$ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI())));
247  $ilCtrl->clearParametersByClass(get_class($this->getContainerGUI()));
248  }
249  else
250  {
251  $tpl->setVariable('TXT_TITLE_LINKED',$lng->txt('crs_link_show_all_prev_sessions'));
252  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()),'crs_prev_sess',(int) !$prefp);
253  $tpl->setVariable('HREF_TITLE_LINKED',$ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI())));
254  $ilCtrl->clearParametersByClass(get_class($this->getContainerGUI()));
255  }
256  }
257  else
258  {
259  $prefn = $ilUser->getPref('crs_sess_show_next_'.$this->getContainerObject()->getId());
260 
261  if($prefn)
262  {
263  $tpl->setVariable('TXT_TITLE_LINKED',$lng->txt('crs_link_hide_next_sessions'));
264  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()),'crs_next_sess',(int) !$prefn);
265  $tpl->setVariable('HREF_TITLE_LINKED',$ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI())));
266  $ilCtrl->clearParametersByClass(get_class($this->getContainerGUI()));
267  }
268  else
269  {
270  $tpl->setVariable('TXT_TITLE_LINKED',$lng->txt('crs_link_show_all_next_sessions'));
271  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()),'crs_next_sess',(int) !$prefn);
272  $tpl->setVariable('HREF_TITLE_LINKED',$ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI())));
273  $ilCtrl->clearParametersByClass(get_class($this->getContainerGUI()));
274  }
275  }
276  $tpl->parseCurrentBlock();
277 
278  return $tpl->get();
279  }
280 
281 
289  public function addFooterRow($tpl)
290  {
291  global $ilCtrl;
292 
293  $tpl->setCurrentBlock('details_img');
294 
295  $append = $this->details_level == 1 ? 'off' : '';
296  $tpl->setCurrentBlock('details_img');
297  $tpl->setVariable('DETAILS_SRC',ilUtil::getImagePath('details1'.$append.'.png'));
298  $tpl->setVariable('DETAILS_ALT',$this->lng->txt('details').' 1');
299  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getContainerObject()->getRefId());
300  $ilCtrl->setParameterByClass("ilrepositorygui", "details_level", "1");
301  $tpl->setVariable('DETAILS_LINK',
302  $ilCtrl->getLinkTargetByClass("ilrepositorygui", ""));
303  $tpl->parseCurrentBlock();
304 
305  $append = $this->details_level == 2 ? 'off' : '';
306  $tpl->setCurrentBlock('details_img');
307  $tpl->setVariable('DETAILS_SRC',ilUtil::getImagePath('details2'.$append.'.png'));
308  $tpl->setVariable('DETAILS_ALT',$this->lng->txt('details').' 2');
309  $ilCtrl->setParameterByClass("ilrepositorygui", "details_level", "2");
310  $tpl->setVariable('DETAILS_LINK',
311  $ilCtrl->getLinkTargetByClass("ilrepositorygui", ""));
312  $tpl->parseCurrentBlock();
313 
314  $append = $this->details_level == 3 ? 'off' : '';
315  $tpl->setCurrentBlock('details_img');
316  $tpl->setVariable('DETAILS_SRC',ilUtil::getImagePath('details3'.$append.'.png'));
317  $tpl->setVariable('DETAILS_ALT',$this->lng->txt('details').' 3');
318  $ilCtrl->setParameterByClass("ilrepositorygui", "details_level", "3");
319  $tpl->setVariable('DETAILS_LINK',
320  $ilCtrl->getLinkTargetByClass("ilrepositorygui", ""));
321  $tpl->parseCurrentBlock();
322 
323  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
324 
325  $tpl->setCurrentBlock('container_details_row');
326  $tpl->setVariable('TXT_DETAILS',$this->lng->txt('details'));
327  $tpl->parseCurrentBlock();
328  }
329 
337  protected function initDetails()
338  {
339  global $ilUser;
340 
341  if($_GET['expand'])
342  {
343  if($_GET['expand'] > 0)
344  {
345  $_SESSION['sess']['expanded'][abs((int) $_GET['expand'])] = self::DETAILS_ALL;
346  }
347  else
348  {
349  $_SESSION['sess']['expanded'][abs((int) $_GET['expand'])] = self::DETAILS_TITLE;
350  }
351  }
352 
353  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
354  if($session = ilSessionAppointment::lookupNextSessionByCourse($this->getContainerObject()->getRefId()))
355  {
356  $this->force_details = $session;
357  }
358  elseif($session = ilSessionAppointment::lookupLastSessionByCourse($this->getContainerObject()->getRefId()))
359  {
360  $this->force_details = array($session);
361  }
362  }
363 
364 
365 
366 } // END class.ilContainerSessionsContentGUI
367 ?>