ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContainerContentGUI.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 
35 abstract class ilContainerContentGUI
36 {
38  const DETAILS_TITLE = 1;
39  const DETAILS_ALL = 2;
40 
41 
43 
46 
51  function __construct(&$container_gui_obj)
52  {
53  $this->container_gui = $container_gui_obj;
54  $this->container_obj = $this->container_gui->object;
55  }
56 
64  protected function getDetailsLevel($a_item_id)
65  {
66  return $this->details_level;
67  }
68 
74  public function getContainerObject()
75  {
76  return $this->container_obj;
77  }
78 
84  public function getContainerGUI()
85  {
86  return $this->container_gui;
87  }
88 
95  public function setOutput()
96  {
97  global $tpl;
98 
99  // BEGIN ChangeEvent: record read event.
100  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
102  {
103  global $ilUser;
104  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
105  ilChangeEvent::_recordReadEvent($obj_id, $ilUser->getId());
106  }
107  // END ChangeEvent: record read event.
108 
109  $tpl->setContent($this->getCenterColumnHTML());
110  $tpl->setRightContent($this->getRightColumnHTML());
111  }
112 
116  protected function getRightColumnHTML()
117  {
118  global $ilUser, $lng, $ilCtrl, $ilAccess;
119 
120  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
121 
122  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
123  $obj_type = ilObject::_lookupType($obj_id);
124 
125  include_once("Services/Block/classes/class.ilColumnGUI.php");
126  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
127 
128  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
129  {
130  return "";
131  }
132 
133  $this->getContainerGUI()->setColumnSettings($column_gui);
134 
135  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
136  $column_gui->getCmdSide() == IL_COL_RIGHT &&
137  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
138  {
139 
140  $html = $ilCtrl->forwardCommand($column_gui);
141  }
142  else
143  {
144  if (!$ilCtrl->isAsynch())
145  {
146  $html = $ilCtrl->getHTML($column_gui);
147  }
148  }
149 
150  return $html;
151  }
152 
156  protected function getCenterColumnHTML()
157  {
158  global $ilCtrl, $tpl;
159 
160  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
161 
162  switch ($ilCtrl->getNextClass())
163  {
164  case "ilcolumngui":
165  $ilCtrl->setReturn($this->container_gui, "");
166  $html = $this->__forwardToColumnGUI();
167  break;
168 
169  default:
170  $html = $this->getMainContent();
171  break;
172  }
173 
174  return $html;
175  }
176 
181  abstract function getMainContent();
182 
186  final private function __forwardToColumnGUI()
187  {
188  global $ilCtrl, $ilAccess;
189 
190  include_once("Services/Block/classes/class.ilColumnGUI.php");
191 
192  // this gets us the subitems we need in setColumnSettings()
193  // todo: this should be done in ilCourseGUI->getSubItems
194  //$this->course_obj->initCourseItemObject($this->getContainerObject()->getRefId());
195 
196  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
197  $obj_type = ilObject::_lookupType($obj_id);
198 
199  if (!$ilCtrl->isAsynch())
200  {
201  //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
203  {
204  // right column wants center
206  {
207  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
208  $this->getContainerGUI()->setColumnSettings($column_gui);
209  $html = $ilCtrl->forwardCommand($column_gui);
210  }
211  // left column wants center
213  {
214  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
215  $this->getContainerGUI()->setColumnSettings($column_gui);
216  $html = $ilCtrl->forwardCommand($column_gui);
217  }
218  }
219  else
220  {
221  $html = $this->getMainContent();
222  }
223  }
224 
225  return $html;
226  }
227 
231  protected function clearAdminCommandsDetermination()
232  {
233  $this->adminCommands = false;
234  }
235 
239  protected function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
240  {
241  global $rbacsystem;
242 
243 //echo "-".$a_admin_com_included_in_list."-";
244 
245  if (!$this->adminCommands)
246  {
247  if (!$this->getContainerGUI()->isActiveAdministrationPanel())
248  {
249  if ($rbacsystem->checkAccess("delete", $a_ref_id))
250  {
251  $this->adminCommands = true;
252  }
253  }
254  else
255  {
256  $this->adminCommands = $a_admin_com_included_in_list;
257  }
258  }
259  }
260 
264  protected function getItemGUI($item_data,$a_show_path = false)
265  {
266  include_once './classes/class.ilObjectListGUIFactory.php';
267 
268  // get item list gui object
269  if (!is_object ($this->list_gui[$item_data["type"]]))
270  {
271  $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($item_data["type"]);
272  $item_list_gui->setContainerObject($this->getContainerGUI());
273  $this->list_gui[$item_data["type"]] =& $item_list_gui;
274  }
275  else
276  {
277  $item_list_gui =& $this->list_gui[$item_data["type"]];
278  }
279 
280  // show administration command buttons (or not)
281  if (!$this->getContainerGUI()->isActiveAdministrationPanel())
282  {
283  $item_list_gui->enableDelete(false);
284  $item_list_gui->enableLink(false);
285  $item_list_gui->enableCut(false);
286  }
287 
288  // container specific modifications
289  $this->getContainerGUI()->modifyItemGUI($item_list_gui, $item_data, $a_show_path);
290 
291  return $item_list_gui;
292  }
293 
297  function determinePageEmbeddedBlocks($a_container_page_html)
298  {
299  $type_grps = $this->getGroupedObjTypes();
300 
301  // iterate all types
302  foreach ($type_grps as $type => $v)
303  {
304  // set template (overall or type specific)
305  if (is_int(strpos($a_container_page_html, "[list-".$type."]")))
306  {
307  $this->addEmbeddedBlock("type", $type);
308  }
309  }
310  }
311 
317  function addEmbeddedBlock($block_type, $block_parameter)
318  {
319  $this->embedded_block[$block_type][] = $block_parameter;
320  }
321 
325  function getEmbeddedBlocks()
326  {
327  return $this->embedded_block;
328  }
329 
334  {
335  global $lng;
336 
337  // first all type specific blocks
338  if (is_array($this->embedded_block["type"]))
339  {
340  // all embedded typed blocks
341  foreach ($this->embedded_block["type"] as $k => $type)
342  {
343  if ($this->rendered_block["type"][$type] == "")
344  {
345  if (is_array($this->items[$type]))
346  {
347  $tpl = $this->newBlockTemplate();
348 
349  // the header
350  $this->addHeaderRow($tpl, $type);
351 
352  // all rows
353  $item_rendered = false;
354  $position = 1;
355  foreach($this->items[$type] as $k => $item_data)
356  {
357  $html = $this->renderItem($item_data,$position++);
358  if ($html != "")
359  {
360  $this->addStandardRow($tpl, $html);
361  $item_rendered = true;
362  $this->rendered_items[$item_data["child"]] = true;
363  }
364  }
365 
366  // if no item has been rendered, add message
367  if (!$item_rendered)
368  {
369  $this->addMessageRow($tpl, $lng->txt("msg_no_type_accessible"), $type);
370  }
371 
372  $this->rendered_block["type"][$type] = $tpl->get();
373  }
374  }
375  }
376  }
377  }
378 
386  function renderItem($a_item_data,$a_position = 0,$a_force_icon = false)
387  {
388  global $ilSetting,$ilAccess;
389 
390  // Pass type, obj_id and tree to checkAccess method to improve performance
391  if(!$ilAccess->checkAccess('visible','',$a_item_data['ref_id'],$a_item_data['type'],$a_item_data['obj_id'],$a_item_data['tree']))
392  {
393  return '';
394  }
395 
396  $item_list_gui = $this->getItemGUI($a_item_data);
397  if ($ilSetting->get("icon_position_in_lists") == "item_rows" ||
398  $a_item_data["type"] == "sess" || $a_force_icon)
399  {
400  $item_list_gui->enableIcon(true);
401  }
402  if ($this->getContainerGUI()->isActiveAdministrationPanel())
403  {
404  $item_list_gui->enableCheckbox(true);
405  if ($this->getContainerObject()->getOrderType() == ilContainer::SORT_MANUAL)
406  {
407  $item_list_gui->setPositionInputField("[".$a_item_data["ref_id"]."]",
408  sprintf('%.1f', $a_position));
409  }
410  }
411  if($a_item_data['type'] == 'sess' and get_class($this) != 'ilContainerObjectiveGUI')
412  {
413  switch($this->getDetailsLevel($a_item_data['obj_id']))
414  {
415  case self::DETAILS_TITLE:
416  $item_list_gui->enableExpand(true);
417  $item_list_gui->setExpanded(false);
418  $item_list_gui->enableDescription(false);
419  $item_list_gui->enableProperties(false);
420  break;
421 
422  case self::DETAILS_ALL:
423  $item_list_gui->enableExpand(true);
424  $item_list_gui->setExpanded(true);
425  $item_list_gui->enableDescription(true);
426  $item_list_gui->enableProperties(true);
427  break;
428 
429  default:
430  $item_list_gui->enableExpand(false);
431  $item_list_gui->enableDescription(true);
432  $item_list_gui->enableProperties(true);
433  break;
434  }
435  }
436 
437  // show subitems
438  if ($a_item_data['type'] == 'sess' and $this->getDetailsLevel($a_item_data['obj_id']) != self::DETAILS_TITLE)
439  {
440  $pos = 1;
441 
442  include_once('./Services/Container/classes/class.ilContainerSorting.php');
443  $items = $this->getContainerObject()->items_obj->getItemsByEvent($a_item_data['obj_id']);
444  $items = ilContainerSorting::_getInstance($this->getContainerObject()->getId())->sortSubItems('sess',$a_item_data['obj_id'],$items);
445 
446  foreach($items as $item)
447  {
448  // TODO: this should be removed and be handled by if(strlen($sub_item_html))
449  // see mantis: 0003944
450  if(!$ilAccess->checkAccess('visible','',$item['ref_id']))
451  {
452  continue;
453  }
454 
455  $item_list_gui2 = $this->getItemGUI($item);
456  $item_list_gui2->enableIcon(true);
457  $item_list_gui2->enableItemDetailLinks(false);
458  if ($this->getContainerGUI()->isActiveAdministrationPanel())
459  {
460  $item_list_gui2->enableCheckbox(true);
461  if ($this->getContainerObject()->getOrderType() == ilContainer::SORT_MANUAL)
462  {
463  $item_list_gui2->setPositionInputField("[sess][".$a_item_data['obj_id']."][".$item["ref_id"]."]",
464  sprintf('%.1f', $pos));
465  $pos++;
466  }
467 
468  }
469  $sub_item_html = $item_list_gui2->getListItemHTML($item['ref_id'],
470  $item['obj_id'], $item['title'], $item['description']);
471 
472 
473  $this->determineAdminCommands($item["ref_id"],$item_list_gui2->adminCommandsIncluded());
474  if(strlen($sub_item_html))
475  {
476  $item_list_gui->addSubItemHTML($sub_item_html);
477  }
478  }
479  }
480 
481  $html = $item_list_gui->getListItemHTML($a_item_data['ref_id'],
482  $a_item_data['obj_id'], $a_item_data['title'], $a_item_data['description']);
483  $this->determineAdminCommands($a_item_data["ref_id"],
484  $item_list_gui->adminCommandsIncluded());
485 
486 
487  return $html;
488  }
489 
496  function &newBlockTemplate()
497  {
498  $tpl = new ilTemplate ("tpl.container_list_block.html", true, true,
499  "Services/Container");
500  $this->cur_row_type = "row_type_1";
501  return $tpl;
502  }
503 
507  function addStandardRow(&$a_tpl, $a_html)
508  {
509  global $ilSetting, $lng;
510 
511  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
512  ? "row_type_2"
513  : "row_type_1";
514 
515  $a_tpl->touchBlock($this->cur_row_type);
516 
517  $a_tpl->setCurrentBlock("container_standard_row");
518  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
519  $a_tpl->parseCurrentBlock();
520  $a_tpl->touchBlock("container_row");
521  }
522 
526  function addHeaderRow($a_tpl, $a_type = "", $a_text = "")
527  {
528  global $lng, $ilSetting;
529 
530  if ($a_text == "" && $a_type != "")
531  {
532  $title = $lng->txt("objs_".$a_type);
533  }
534  else
535  {
536  $title = $a_text;
537  }
538 
539  if ($ilSetting->get("icon_position_in_lists") != "item_rows" &&
540  $a_type != "")
541  {
542  $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
543 
544  $a_tpl->setCurrentBlock("container_header_row_image");
545  $a_tpl->setVariable("HEADER_IMG", $icon);
546  $a_tpl->setVariable("HEADER_ALT", $title);
547  }
548  else
549  {
550  $a_tpl->setCurrentBlock("container_header_row");
551  }
552 
553  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
554  $a_tpl->parseCurrentBlock();
555  $a_tpl->touchBlock("container_row");
556 
557  $this->resetRowType();
558  }
559 
560 
564  function resetRowType()
565  {
566  $this->cur_row_type = "";
567  }
568 
572  function insertPageEmbeddedBlocks($a_output_html)
573  {
574  $this->determinePageEmbeddedBlocks($a_output_html);
575  $this->renderPageEmbeddedBlocks($this->items);
576 
577  $type_grps = $this->getGroupedObjTypes();
578 
579  // iterate all types
580  foreach ($type_grps as $type => $v)
581  {
582  // set template (overall or type specific)
583  if (is_int(strpos($a_output_html, "[list-".$type."]")))
584  {
585  $a_output_html = eregi_replace("\[list-".$type."\]",
586  $this->rendered_block["type"][$type], $a_output_html);
587  }
588  }
589 
590  return $a_output_html;
591  }
592 
596  function addMessageRow(&$a_tpl, $a_message, $a_type)
597  {
598  global $lng;
599 
600  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
601  ? "row_type_2"
602  : "row_type_1";
603 
604  $a_tpl->touchBlock($this->cur_row_type);
605 
606  $type = $lng->txt("obj_".$a_type);
607  $a_message = str_replace("[type]", $type, $a_message);
608 
609  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
610 
611  $a_tpl->setCurrentBlock("container_standard_row");
612  $a_tpl->setVariable("BLOCK_ROW_CONTENT",
613  $a_message);
614  $a_tpl->parseCurrentBlock();
615  $a_tpl->touchBlock("container_row");
616  }
617 
621  function addSeparatorRow(&$a_tpl)
622  {
623  $a_tpl->touchBlock("separator_row");
624  $a_tpl->touchBlock("container_row");
625  }
626 
633  {
634  global $objDefinition;
635 
636  if (empty($this->type_grps))
637  {
638  $this->type_grps =
639  $objDefinition->getGroupedRepositoryObjectTypes($this->getContainerObject()->getType());
640  }
641  return $this->type_grps;
642  }
643 
647  function getIntroduction()
648  {
649  global $ilUser, $lng, $ilCtrl;
650 
651  $lng->loadLanguageModule("rep");
652 
653  $tpl = new ilTemplate("tpl.rep_intro.html", true, true, "Services/Repository");
654  $tpl->setVariable("IMG_REP_LARGE", ilUtil::getImagePath("icon_root_xxl.gif"));
655  $tpl->setVariable("TXT_WELCOME", $lng->txt("rep_intro"));
656  $tpl->setVariable("TXT_INTRO_1", $lng->txt("rep_intro1"));
657  $tpl->setVariable("TXT_INTRO_2", $lng->txt("rep_intro2"));
658  $tpl->setVariable("TXT_INTRO_3", sprintf($lng->txt("rep_intro3"), $lng->txt("add")));
659  $tpl->setVariable("TXT_INTRO_4", sprintf($lng->txt("rep_intro4"), $lng->txt("cat_add")));
660  $tpl->setVariable("TXT_INTRO_5", $lng->txt("rep_intro5"));
661  $tpl->setVariable("TXT_INTRO_6", $lng->txt("rep_intro6"));
662 
663  return $tpl->get();
664  }
665 
666 } // END class.ilContainerContentGUI
667 ?>