ILIAS  Release_4_2_x_branch Revision 61807
 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  if (is_array($this->items["_all"]))
182  {
183  // all rows
184  $item_html = array();
185  $position = 1;
186  foreach($this->items["_all"] as $item_data)
187  {
188  if ($this->rendered_items[$item_data["child"]] !== true)
189  {
190  if ($item_data["type"] == "sess")
191  {
192  continue;
193  }
194  $html = $this->renderItem($item_data,$position++,true);
195  if ($html != "")
196  {
197  $item_html[] = $html;
198  }
199  }
200  }
201 
202  // if we have at least one item, output the block
203  if (count($item_html) > 0)
204  {
205  $this->addHeaderRow($tpl, "", $lng->txt("content"));
206  foreach($item_html as $h)
207  {
208  $this->addStandardRow($tpl, $h);
209  }
210  }
211  }
212 
213  $output_html .= $tpl->get();
214 
215  $a_tpl->setVariable("CONTAINER_PAGE_CONTENT", $output_html);
216  }
217 
222  protected function renderSessionLimitLink($a_previous = true)
223  {
224  global $lng, $ilUser, $ilCtrl;
225 
226  $lng->loadLanguageModule('crs');
227 
228  $tpl = new ilTemplate('tpl.container_list_item.html',true,true);
229  $tpl->setVariable('DIV_CLASS','ilContainerListItemOuter');
230  $tpl->setCurrentBlock('item_title_linked');
231 
232  if($a_previous)
233  {
234  $prefp = $ilUser->getPref('crs_sess_show_prev_'.$this->getContainerObject()->getId());
235 
236  if($prefp)
237  {
238  $tpl->setVariable('TXT_TITLE_LINKED',$lng->txt('crs_link_hide_prev_sessions'));
239  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()),'crs_prev_sess',(int) !$prefp);
240  $tpl->setVariable('HREF_TITLE_LINKED',$ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI())));
241  $ilCtrl->clearParametersByClass(get_class($this->getContainerGUI()));
242  }
243  else
244  {
245  $tpl->setVariable('TXT_TITLE_LINKED',$lng->txt('crs_link_show_all_prev_sessions'));
246  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()),'crs_prev_sess',(int) !$prefp);
247  $tpl->setVariable('HREF_TITLE_LINKED',$ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI())));
248  $ilCtrl->clearParametersByClass(get_class($this->getContainerGUI()));
249  }
250  }
251  else
252  {
253  $prefn = $ilUser->getPref('crs_sess_show_next_'.$this->getContainerObject()->getId());
254 
255  if($prefn)
256  {
257  $tpl->setVariable('TXT_TITLE_LINKED',$lng->txt('crs_link_hide_next_sessions'));
258  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()),'crs_next_sess',(int) !$prefn);
259  $tpl->setVariable('HREF_TITLE_LINKED',$ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI())));
260  $ilCtrl->clearParametersByClass(get_class($this->getContainerGUI()));
261  }
262  else
263  {
264  $tpl->setVariable('TXT_TITLE_LINKED',$lng->txt('crs_link_show_all_next_sessions'));
265  $ilCtrl->setParameterByClass(get_class($this->getContainerGUI()),'crs_next_sess',(int) !$prefn);
266  $tpl->setVariable('HREF_TITLE_LINKED',$ilCtrl->getLinkTargetByClass(get_class($this->getContainerGUI())));
267  $ilCtrl->clearParametersByClass(get_class($this->getContainerGUI()));
268  }
269  }
270  $tpl->parseCurrentBlock();
271 
272  return $tpl->get();
273  }
274 
275 
283  public function addFooterRow($tpl)
284  {
285  $tpl->setCurrentBlock('details_img');
286 
287  $append = $this->details_level == 1 ? 'off' : '';
288  $tpl->setCurrentBlock('details_img');
289  $tpl->setVariable('DETAILS_SRC',ilUtil::getImagePath('details1'.$append.'.gif'));
290  $tpl->setVariable('DETAILS_ALT',$this->lng->txt('details').' 1');
291  $tpl->setVariable('DETAILS_LINK','repository.php?ref_id='.$this->getContainerObject()->getRefId().'&details_level=1');
292  $tpl->parseCurrentBlock();
293 
294  $append = $this->details_level == 2 ? 'off' : '';
295  $tpl->setCurrentBlock('details_img');
296  $tpl->setVariable('DETAILS_SRC',ilUtil::getImagePath('details2'.$append.'.gif'));
297  $tpl->setVariable('DETAILS_ALT',$this->lng->txt('details').' 2');
298  $tpl->setVariable('DETAILS_LINK','repository.php?ref_id='.$this->getContainerObject()->getRefId().'&details_level=2');
299  $tpl->parseCurrentBlock();
300 
301  $append = $this->details_level == 3 ? 'off' : '';
302  $tpl->setCurrentBlock('details_img');
303  $tpl->setVariable('DETAILS_SRC',ilUtil::getImagePath('details3'.$append.'.gif'));
304  $tpl->setVariable('DETAILS_ALT',$this->lng->txt('details').' 3');
305  $tpl->setVariable('DETAILS_LINK','repository.php?ref_id='.$this->getContainerObject()->getRefId().'&details_level=3');
306  $tpl->parseCurrentBlock();
307 
308  $tpl->setCurrentBlock('container_details_row');
309  $tpl->setVariable('TXT_DETAILS',$this->lng->txt('details'));
310  $tpl->parseCurrentBlock();
311  }
312 
320  protected function initDetails()
321  {
322  global $ilUser;
323 
324  if($_GET['expand'])
325  {
326  if($_GET['expand'] > 0)
327  {
328  $_SESSION['sess']['expanded'][abs((int) $_GET['expand'])] = self::DETAILS_ALL;
329  }
330  else
331  {
332  $_SESSION['sess']['expanded'][abs((int) $_GET['expand'])] = self::DETAILS_TITLE;
333  }
334  }
335 
336  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
337  if($session = ilSessionAppointment::lookupNextSessionByCourse($this->getContainerObject()->getRefId()))
338  {
339  $this->force_details = $session;
340  }
341  elseif($session = ilSessionAppointment::lookupLastSessionByCourse($this->getContainerObject()->getRefId()))
342  {
343  $this->force_details = array($session);
344  }
345  }
346 
347 
348 
349 } // END class.ilContainerSessionsContentGUI
350 ?>