ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilContainerContentGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
16 abstract class ilContainerContentGUI
17 {
19  const DETAILS_TITLE = 1;
20  const DETAILS_ALL = 2;
21 
22 
24 
27 
32  function __construct(&$container_gui_obj)
33  {
34  $this->container_gui = $container_gui_obj;
35  $this->container_obj = $this->container_gui->object;
36  }
37 
45  protected function getDetailsLevel($a_item_id)
46  {
47  return $this->details_level;
48  }
49 
55  public function getContainerObject()
56  {
57  return $this->container_obj;
58  }
59 
65  public function getContainerGUI()
66  {
67  return $this->container_gui;
68  }
69 
76  public function setOutput()
77  {
78  global $tpl;
79 
80  // BEGIN ChangeEvent: record read event.
81  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
82  global $ilUser;
83  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
85  $this->getContainerObject()->getType(),
86  $this->getContainerObject()->getRefId(),
87  $obj_id, $ilUser->getId());
88  // END ChangeEvent: record read event.
89 
90  $tpl->setContent($this->getCenterColumnHTML());
91  $tpl->setRightContent($this->getRightColumnHTML());
92  }
93 
97  protected function getRightColumnHTML()
98  {
99  global $ilUser, $lng, $ilCtrl, $ilAccess;
100 
101  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
102 
103  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
104  $obj_type = ilObject::_lookupType($obj_id);
105 
106  include_once("Services/Block/classes/class.ilColumnGUI.php");
107  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
108 
109  if ($column_gui->getScreenMode() == IL_SCREEN_FULL)
110  {
111  return "";
112  }
113 
114  $this->getContainerGUI()->setColumnSettings($column_gui);
115 
116  if ($ilCtrl->getNextClass() == "ilcolumngui" &&
117  $column_gui->getCmdSide() == IL_COL_RIGHT &&
118  $column_gui->getScreenMode() == IL_SCREEN_SIDE)
119  {
120 
121  $html = $ilCtrl->forwardCommand($column_gui);
122  }
123  else
124  {
125  if (!$ilCtrl->isAsynch())
126  {
127  $html = $ilCtrl->getHTML($column_gui);
128  }
129  }
130 
131  return $html;
132  }
133 
137  protected function getCenterColumnHTML()
138  {
139  global $ilCtrl, $tpl;
140 
141  $ilCtrl->saveParameterByClass("ilcolumngui", "col_return");
142 
143  $tpl->addOnLoadCode("ilObject.setRedrawListItemUrl('".
144  $ilCtrl->getLinkTarget($this->container_gui, "redrawListItem", "", true)."');");
145 
146  switch ($ilCtrl->getNextClass())
147  {
148  case "ilcolumngui":
149  $ilCtrl->setReturn($this->container_gui, "");
150  $html = $this->__forwardToColumnGUI();
151  break;
152 
153  default:
154  $html = $this->getMainContent();
155  break;
156  }
157 
158  return $html;
159  }
160 
165  abstract function getMainContent();
166 
170  final private function __forwardToColumnGUI()
171  {
172  global $ilCtrl, $ilAccess;
173 
174  include_once("Services/Block/classes/class.ilColumnGUI.php");
175 
176  // this gets us the subitems we need in setColumnSettings()
177  // todo: this should be done in ilCourseGUI->getSubItems
178  //$this->course_obj->initCourseItemObject($this->getContainerObject()->getRefId());
179 
180  $obj_id = ilObject::_lookupObjId($this->getContainerObject()->getRefId());
181  $obj_type = ilObject::_lookupType($obj_id);
182 
183  if (!$ilCtrl->isAsynch())
184  {
185  //if ($column_gui->getScreenMode() != IL_SCREEN_SIDE)
187  {
188  // right column wants center
190  {
191  $column_gui = new ilColumnGUI($obj_type, IL_COL_RIGHT);
192  $this->getContainerGUI()->setColumnSettings($column_gui);
193  $html = $ilCtrl->forwardCommand($column_gui);
194  }
195  // left column wants center
197  {
198  $column_gui = new ilColumnGUI($obj_type, IL_COL_LEFT);
199  $this->getContainerGUI()->setColumnSettings($column_gui);
200  $html = $ilCtrl->forwardCommand($column_gui);
201  }
202  }
203  else
204  {
205  $html = $this->getMainContent();
206  }
207  }
208 
209  return $html;
210  }
211 
215  protected function clearAdminCommandsDetermination()
216  {
217  $this->adminCommands = false;
218  }
219 
223  protected function determineAdminCommands($a_ref_id, $a_admin_com_included_in_list = false)
224  {
225  global $rbacsystem;
226 
227 //echo "-".$a_admin_com_included_in_list."-";
228 
229  if (!$this->adminCommands)
230  {
231  if (!$this->getContainerGUI()->isActiveAdministrationPanel())
232  {
233  if ($rbacsystem->checkAccess("delete", $a_ref_id))
234  {
235  $this->adminCommands = true;
236  }
237  }
238  else
239  {
240  $this->adminCommands = $a_admin_com_included_in_list;
241  }
242  }
243  }
244 
248  protected function getItemGUI($item_data,$a_show_path = false)
249  {
250  include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
251 
252  // get item list gui object
253  if (!is_object ($this->list_gui[$item_data["type"]]))
254  {
255  $item_list_gui =& ilObjectListGUIFactory::_getListGUIByType($item_data["type"]);
256  $item_list_gui->setContainerObject($this->getContainerGUI());
257  $this->list_gui[$item_data["type"]] =& $item_list_gui;
258  }
259  else
260  {
261  $item_list_gui =& $this->list_gui[$item_data["type"]];
262  }
263 
264  // show administration command buttons (or not)
265  if (!$this->getContainerGUI()->isActiveAdministrationPanel())
266  {
267 // $item_list_gui->enableDelete(false);
268 // $item_list_gui->enableLink(false);
269 // $item_list_gui->enableCut(false);
270  }
271 
272  // activate common social commands
273  $item_list_gui->enableComments(true);
274  $item_list_gui->enableNotes(true);
275  $item_list_gui->enableTags(true);
276 
277  // container specific modifications
278  $this->getContainerGUI()->modifyItemGUI($item_list_gui, $item_data, $a_show_path);
279 
280  return $item_list_gui;
281  }
282 
286  function determinePageEmbeddedBlocks($a_container_page_html)
287  {
288  $type_grps = $this->getGroupedObjTypes();
289 
290  // iterate all types
291  foreach ($type_grps as $type => $v)
292  {
293  // set template (overall or type specific)
294  if (is_int(strpos($a_container_page_html, "[list-".$type."]")))
295  {
296  $this->addEmbeddedBlock("type", $type);
297  }
298  }
299  }
300 
306  function addEmbeddedBlock($block_type, $block_parameter)
307  {
308  $this->embedded_block[$block_type][] = $block_parameter;
309  }
310 
314  function getEmbeddedBlocks()
315  {
316  return $this->embedded_block;
317  }
318 
323  {
324  global $lng;
325 
326  // first all type specific blocks
327  if (is_array($this->embedded_block["type"]))
328  {
329  // all embedded typed blocks
330  foreach ($this->embedded_block["type"] as $k => $type)
331  {
332  if ($this->rendered_block["type"][$type] == "")
333  {
334  if (is_array($this->items[$type]))
335  {
336  $tpl = $this->newBlockTemplate();
337 
338  // the header
339  $this->addHeaderRow($tpl, $type);
340 
341  // all rows
342  $item_rendered = false;
343  $position = 1;
344 
345  if($type == 'sess')
346  {
347  $this->items['sess'] = ilUtil::sortArray($this->items['sess'],'start','ASC',true,true);
348  }
349 
350  foreach($this->items[$type] as $k => $item_data)
351  {
352  $html = $this->renderItem($item_data,$position++);
353  if ($html != "")
354  {
355  $this->addStandardRow($tpl, $html, $item_data["child"]);
356  $item_rendered = true;
357  $this->rendered_items[$item_data["child"]] = true;
358  }
359  }
360 
361  // if no item has been rendered, add message
362  if (!$item_rendered)
363  {
364  //$this->addMessageRow($tpl, $lng->txt("msg_no_type_accessible"), $type);
365  $this->rendered_block["type"][$type] = "";
366  }
367  else
368  {
369  $this->rendered_block["type"][$type] = $tpl->get();
370  }
371  }
372  }
373  }
374  }
375  }
376 
384  function renderItem($a_item_data,$a_position = 0,$a_force_icon = false)
385  {
386  global $ilSetting,$ilAccess,$ilCtrl;
387 
388  // Pass type, obj_id and tree to checkAccess method to improve performance
389  if(!$ilAccess->checkAccess('visible','',$a_item_data['ref_id'],$a_item_data['type'],$a_item_data['obj_id'],$a_item_data['tree']))
390  {
391  return '';
392  }
393 
394  $item_list_gui = $this->getItemGUI($a_item_data);
395  if ($ilSetting->get("icon_position_in_lists") == "item_rows" ||
396  $a_item_data["type"] == "sess" || $a_force_icon)
397  {
398  $item_list_gui->enableIcon(true);
399  }
400  if ($this->getContainerGUI()->isActiveAdministrationPanel() && !$_SESSION["clipboard"])
401  {
402  $item_list_gui->enableCheckbox(true);
403  }
404  if ($this->getContainerGUI()->isActiveOrdering() && ($a_item_data['type'] != 'sess' || get_class($this) != 'ilContainerSessionsContentGUI'))
405  {
406  $item_list_gui->setPositionInputField("[".$a_item_data["ref_id"]."]",
407  sprintf('%.1f', $a_position));
408  }
409  if($a_item_data['type'] == 'sess' and get_class($this) != 'ilContainerObjectiveGUI')
410  {
411  switch($this->getDetailsLevel($a_item_data['obj_id']))
412  {
413  case self::DETAILS_TITLE:
414  $item_list_gui->setDetailsLevel(ilObjectListGUI::DETAILS_MINIMAL);
415  $item_list_gui->enableExpand(true);
416  $item_list_gui->setExpanded(false);
417  $item_list_gui->enableDescription(false);
418  $item_list_gui->enableProperties(true);
419  break;
420 
421  case self::DETAILS_ALL:
422  $item_list_gui->setDetailsLevel(ilObjectListGUI::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->setDetailsLevel(ilObjectListGUI::DETAILS_ALL);
431  $item_list_gui->enableExpand(true);
432  $item_list_gui->enableDescription(true);
433  $item_list_gui->enableProperties(true);
434  break;
435  }
436  }
437 
438  // show subitems
439  if($a_item_data['type'] == 'sess' and (
440  $this->getDetailsLevel($a_item_data['obj_id']) != self::DETAILS_TITLE or
441  $this->getContainerGUI()->isActiveAdministrationPanel() or
442  $this->getContainerGUI()->isActiveOrdering()
443  )
444  )
445  {
446  $pos = 1;
447 
448  include_once('./Services/Container/classes/class.ilContainerSorting.php');
449  $items = $this->getContainerObject()->items_obj->getItemsByEvent($a_item_data['obj_id']);
450  $items = ilContainerSorting::_getInstance($this->getContainerObject()->getId())->sortSubItems('sess',$a_item_data['obj_id'],$items);
451 
452 
453  $item_readable = $ilAccess->checkAccess('read','',$a_item_data['ref_id']);
454 
455  foreach($items as $item)
456  {
457  // TODO: this should be removed and be handled by if(strlen($sub_item_html))
458  // see mantis: 0003944
459  if(!$ilAccess->checkAccess('visible','',$item['ref_id']))
460  {
461  continue;
462  }
463 
464  $item_list_gui2 = $this->getItemGUI($item);
465  $item_list_gui2->enableIcon(true);
466  $item_list_gui2->enableItemDetailLinks(false);
467 
468  // @see mantis 10488
469  if(!$item_readable and !$ilAccess->checkAccess('write','',$item['ref_id']))
470  {
471  $item_list_gui2->forceVisibleOnly(true);
472  }
473 
474  if ($this->getContainerGUI()->isActiveAdministrationPanel() && !$_SESSION["clipboard"])
475  {
476  $item_list_gui2->enableCheckbox(true);
477  }
478  if ($this->getContainerGUI()->isActiveOrdering())
479  {
480  if ($this->getContainerObject()->getOrderType() == ilContainer::SORT_MANUAL)
481  {
482  $item_list_gui2->setPositionInputField("[sess][".$a_item_data['obj_id']."][".$item["ref_id"]."]",
483  sprintf('%.1f', $pos));
484  $pos++;
485  }
486 
487  }
488  $sub_item_html = $item_list_gui2->getListItemHTML($item['ref_id'],
489  $item['obj_id'], $item['title'], $item['description']);
490 
491 
492  $this->determineAdminCommands($item["ref_id"],$item_list_gui2->adminCommandsIncluded());
493  if(strlen($sub_item_html))
494  {
495  $item_list_gui->addSubItemHTML($sub_item_html);
496  }
497  }
498  }
499 
500  if ($ilSetting->get("item_cmd_asynch"))
501  {
502  $asynch = true;
503  $ilCtrl->setParameter($this->container_gui, "cmdrefid", $a_item_data['ref_id']);
504  $asynch_url = $ilCtrl->getLinkTarget($this->container_gui,
505  "getAsynchItemList", "", true, false);
506  $ilCtrl->setParameter($this->container_gui, "cmdrefid", "");
507  }
508 
509  $html = $item_list_gui->getListItemHTML($a_item_data['ref_id'],
510  $a_item_data['obj_id'], $a_item_data['title'], $a_item_data['description'],
511  $asynch, false, $asynch_url);
512  $this->determineAdminCommands($a_item_data["ref_id"],
513  $item_list_gui->adminCommandsIncluded());
514 
515 
516  return $html;
517  }
518 
525  function newBlockTemplate()
526  {
527  $tpl = new ilTemplate ("tpl.container_list_block.html", true, true,
528  "Services/Container");
529  $this->cur_row_type = "row_type_1";
530  return $tpl;
531  }
532 
536  function addStandardRow(&$a_tpl, $a_html, $a_ref_id = 0)
537  {
538  global $ilSetting, $lng;
539 
540  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
541  ? "row_type_2"
542  : "row_type_1";
543 
544  if ($a_ref_id > 0)
545  {
546  $a_tpl->setCurrentBlock($this->cur_row_type);
547  $a_tpl->setVariable("ROW_ID", 'id="item_row_'.$a_ref_id.'"');
548  $a_tpl->parseCurrentBlock();
549  }
550  else
551  {
552  $a_tpl->touchBlock($this->cur_row_type);
553  }
554 
555  $a_tpl->setCurrentBlock("container_standard_row");
556  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
557  $a_tpl->parseCurrentBlock();
558  $a_tpl->touchBlock("container_row");
559  }
560 
564  function addHeaderRow($a_tpl, $a_type = "", $a_text = "")
565  {
566  global $lng, $ilSetting, $objDefinition;
567 
568  $a_tpl->setVariable("CB_ID", ' id="bl_cntr_'.$this->bl_cnt.'"');
569  if ($this->getContainerGUI()->isActiveAdministrationPanel() && !$_SESSION["clipboard"])
570  {
571  $a_tpl->setCurrentBlock("select_all_row");
572  $a_tpl->setVariable("CHECKBOXNAME", "bl_cb_".$this->bl_cnt);
573  $a_tpl->setVariable("SEL_ALL_PARENT", "bl_cntr_".$this->bl_cnt);
574  $a_tpl->setVariable("SEL_ALL_PARENT", "bl_cntr_".$this->bl_cnt);
575  $a_tpl->setVariable("TXT_SELECT_ALL", $lng->txt("select_all"));
576  $a_tpl->parseCurrentBlock();
577  $this->bl_cnt++;
578  }
579 
580  if ($a_text == "" && $a_type != "")
581  {
582  if (!$objDefinition->isPlugin($a_type))
583  {
584  $title = $lng->txt("objs_".$a_type);
585  }
586  else
587  {
588  include_once("./Services/Component/classes/class.ilPlugin.php");
589  $title = ilPlugin::lookupTxt("rep_robj", $a_type, "objs_".$a_type);
590  }
591  }
592  else
593  {
594  $title = $a_text;
595  }
596 
597  if ($ilSetting->get("icon_position_in_lists") != "item_rows" &&
598  $a_type != "")
599  {
600  $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
601 
602  $a_tpl->setCurrentBlock("container_header_row_image");
603  $a_tpl->setVariable("HEADER_IMG", $icon);
604  $a_tpl->setVariable("HEADER_ALT", $title);
605  }
606  else
607  {
608  $a_tpl->setCurrentBlock("container_header_row");
609  }
610 
611  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
612  $a_tpl->parseCurrentBlock();
613  $a_tpl->touchBlock("container_row");
614 
615  $this->resetRowType();
616  }
617 
618 
622  function resetRowType()
623  {
624  $this->cur_row_type = "";
625  }
626 
630  function insertPageEmbeddedBlocks($a_output_html)
631  {
632  $this->determinePageEmbeddedBlocks($a_output_html);
633  $this->renderPageEmbeddedBlocks($this->items);
634 
635  $type_grps = $this->getGroupedObjTypes();
636 
637  // iterate all types
638  foreach ($type_grps as $type => $v)
639  {
640  // set template (overall or type specific)
641  if (is_int(strpos($a_output_html, "[list-".$type."]")))
642  {
643  $a_output_html = eregi_replace("\[list-".$type."\]",
644  $this->rendered_block["type"][$type], $a_output_html);
645  }
646  }
647 
648  return $a_output_html;
649  }
650 
654  function addMessageRow(&$a_tpl, $a_message, $a_type)
655  {
656  global $lng, $objDefinition;
657 
658  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
659  ? "row_type_2"
660  : "row_type_1";
661 
662  $a_tpl->touchBlock($this->cur_row_type);
663 
664  if (!$objDefinition->isPlugin($type))
665  {
666  $type = $lng->txt("obj_".$a_type);
667  }
668  else
669  {
670  include_once("./Services/Component/classes/class.ilPlugin.php");
671  $title = ilPlugin::lookupTxt("rep_robj", $a_type, "objs_".$a_type);
672  }
673  $a_message = str_replace("[type]", $type, $a_message);
674 
675  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
676 
677  $a_tpl->setCurrentBlock("container_standard_row");
678  $a_tpl->setVariable("BLOCK_ROW_CONTENT",
679  $a_message);
680  $a_tpl->parseCurrentBlock();
681  $a_tpl->touchBlock("container_row");
682  }
683 
687  function addSeparatorRow(&$a_tpl)
688  {
689  global $lng;
690 
691  $a_tpl->setCurrentBlock("container_block");
692  $a_tpl->parseCurrentBlock();
693  }
694 
701  {
702  global $objDefinition;
703 
704  if (empty($this->type_grps))
705  {
706  $this->type_grps =
707  $objDefinition->getGroupedRepositoryObjectTypes($this->getContainerObject()->getType());
708  }
709  return $this->type_grps;
710  }
711 
715  function getIntroduction()
716  {
717  global $ilUser, $lng, $ilCtrl;
718 
719  $lng->loadLanguageModule("rep");
720 
721  $tpl = new ilTemplate("tpl.rep_intro.html", true, true, "Services/Repository");
722  $tpl->setVariable("IMG_REP_LARGE", ilUtil::getImagePath("icon_root_xxl.gif"));
723  $tpl->setVariable("TXT_WELCOME", $lng->txt("rep_intro"));
724  $tpl->setVariable("TXT_INTRO_1", $lng->txt("rep_intro1"));
725  $tpl->setVariable("TXT_INTRO_2", $lng->txt("rep_intro2"));
726  $tpl->setVariable("TXT_INTRO_3", sprintf($lng->txt("rep_intro3"), $lng->txt("add")));
727  $tpl->setVariable("TXT_INTRO_4", sprintf($lng->txt("rep_intro4"), $lng->txt("cat_add")));
728  $tpl->setVariable("TXT_INTRO_5", $lng->txt("rep_intro5"));
729  $tpl->setVariable("TXT_INTRO_6", $lng->txt("rep_intro6"));
730 
731  return $tpl->get();
732  }
733 
734 } // END class.ilContainerContentGUI
735 ?>