ILIAS  eassessment Revision 61809
 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 (is_array($this->items["sess"]))
132  {
133  $this->items['sess'] = ilUtil::sortArray($this->items['sess'],'start','ASC',true,true);
134 
135  // all rows
136  $item_html = array();
137  $position = 1;
138  foreach($this->items["sess"] as $item_data)
139  {
140  if ($this->rendered_items[$item_data["child"]] !== true)
141  {
142  $html = $this->renderItem($item_data,$position++,true);
143  if ($html != "")
144  {
145  $item_html[] = $html;
146  }
147  }
148  }
149 
150  // if we have at least one item, output the block
151  if (count($item_html) > 0)
152  {
153  $this->addHeaderRow($tpl, "", $lng->txt("objs_sess"));
154  foreach($item_html as $h)
155  {
156  $this->addStandardRow($tpl, $h);
157  }
158  $done_sessions = true;
159  }
160  }
161 
162  // all other items
163  if ($done_sessions)
164  {
165  #$this->addFooterRow($tpl);
166  $this->addSeparatorRow($tpl);
167  }
168  if (is_array($this->items["_all"]))
169  {
170  // all rows
171  $item_html = array();
172  $position = 1;
173  foreach($this->items["_all"] as $item_data)
174  {
175  if ($this->rendered_items[$item_data["child"]] !== true)
176  {
177  if ($item_data["type"] == "sess")
178  {
179  continue;
180  }
181  $html = $this->renderItem($item_data,$position++,true);
182  if ($html != "")
183  {
184  $item_html[] = $html;
185  }
186  }
187  }
188 
189  // if we have at least one item, output the block
190  if (count($item_html) > 0)
191  {
192  $this->addHeaderRow($tpl, "", $lng->txt("content"));
193  foreach($item_html as $h)
194  {
195  $this->addStandardRow($tpl, $h);
196  }
197  }
198  }
199 
200  $output_html .= $tpl->get();
201 
202  $a_tpl->setVariable("CONTAINER_PAGE_CONTENT", $output_html);
203  }
204 
205 
213  public function addFooterRow($tpl)
214  {
215  $tpl->setCurrentBlock('details_img');
216 
217  $append = $this->details_level == 1 ? 'off' : '';
218  $tpl->setCurrentBlock('details_img');
219  $tpl->setVariable('DETAILS_SRC',ilUtil::getImagePath('details1'.$append.'.gif'));
220  $tpl->setVariable('DETAILS_ALT',$this->lng->txt('details').' 1');
221  $tpl->setVariable('DETAILS_LINK','repository.php?ref_id='.$this->getContainerObject()->getRefId().'&details_level=1');
222  $tpl->parseCurrentBlock();
223 
224  $append = $this->details_level == 2 ? 'off' : '';
225  $tpl->setCurrentBlock('details_img');
226  $tpl->setVariable('DETAILS_SRC',ilUtil::getImagePath('details2'.$append.'.gif'));
227  $tpl->setVariable('DETAILS_ALT',$this->lng->txt('details').' 2');
228  $tpl->setVariable('DETAILS_LINK','repository.php?ref_id='.$this->getContainerObject()->getRefId().'&details_level=2');
229  $tpl->parseCurrentBlock();
230 
231  $append = $this->details_level == 3 ? 'off' : '';
232  $tpl->setCurrentBlock('details_img');
233  $tpl->setVariable('DETAILS_SRC',ilUtil::getImagePath('details3'.$append.'.gif'));
234  $tpl->setVariable('DETAILS_ALT',$this->lng->txt('details').' 3');
235  $tpl->setVariable('DETAILS_LINK','repository.php?ref_id='.$this->getContainerObject()->getRefId().'&details_level=3');
236  $tpl->parseCurrentBlock();
237 
238  $tpl->setCurrentBlock('container_details_row');
239  $tpl->setVariable('TXT_DETAILS',$this->lng->txt('details'));
240  $tpl->parseCurrentBlock();
241  }
242 
250  protected function initDetails()
251  {
252  global $ilUser;
253 
254  if($_GET['expand'])
255  {
256  if($_GET['expand'] > 0)
257  {
258  $_SESSION['sess']['expanded'][abs((int) $_GET['expand'])] = self::DETAILS_ALL;
259  }
260  else
261  {
262  $_SESSION['sess']['expanded'][abs((int) $_GET['expand'])] = self::DETAILS_TITLE;
263  }
264  }
265 
266  include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
267  if($session = ilSessionAppointment::lookupNextSessionByCourse($this->getContainerObject()->getRefId()))
268  {
269  $this->force_details = $session;
270  }
271  elseif($session = ilSessionAppointment::lookupLastSessionByCourse($this->getContainerObject()->getRefId()))
272  {
273  $this->force_details = array($session);
274  }
275  }
276 
277 
278 
279 } // END class.ilContainerSessionsContentGUI
280 ?>