1<?php 2 3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */ 4 5/** 6 * TableGUI class for all pages of a learning module 7 * 8 * @author Alex Killing <alex.killing@gmx.de> 9 * @version $Id$ 10 * 11 * @ingroup Services 12 */ 13class ilLMPagesTableGUI extends ilTable2GUI 14{ 15 /** 16 * @var ilAccessHandler 17 */ 18 protected $access; 19 20 /** 21 * Constructor 22 */ 23 public function __construct($a_parent_obj, $a_parent_cmd, $a_lm) 24 { 25 global $DIC; 26 27 $this->ctrl = $DIC->ctrl(); 28 $this->lng = $DIC->language(); 29 $this->access = $DIC->access(); 30 $ilCtrl = $DIC->ctrl(); 31 $lng = $DIC->language(); 32 $ilAccess = $DIC->access(); 33 $lng = $DIC->language(); 34 35 $this->lm = $a_lm; 36 $this->lm_set = new ilSetting("lm"); 37 parent::__construct($a_parent_obj, $a_parent_cmd); 38 $this->setData(ilLMPageObject::getPageList($this->lm->getId())); 39 $this->setTitle($lng->txt("cont_pages")); 40 41 $this->addColumn($this->lng->txt(""), "", "1"); 42 $this->addColumn($this->lng->txt("type"), "", "1"); 43 $this->addColumn($this->lng->txt("title")); 44 $this->addColumn($this->lng->txt("cont_usage")); 45 46 $this->setSelectAllCheckbox("id[]"); 47 48 if ($this->lm->getLayoutPerPage()) { 49 $this->addColumn($this->lng->txt("cont_layout")); 50 } 51 52 $this->setLimit(9999); 53 54 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); 55 $this->setRowTemplate("tpl.page_list_row.html", "Modules/LearningModule"); 56 57 if (ilEditClipboard::getContentObjectType() == "pg" && 58 ilEditClipboard::getAction() == "copy") { 59 $this->addMultiCommand("pastePage", $lng->txt("pastePage")); 60 } 61 62 if ($this->lm->getLayoutPerPage()) { 63 $this->addMultiCommand("setPageLayout", $lng->txt("cont_set_layout")); 64 } 65 66 $this->addMultiCommand("activatePages", $lng->txt("cont_de_activate")); 67 $this->addMultiCommand("movePage", $lng->txt("movePage")); 68 $this->addMultiCommand("copyPage", $lng->txt("copyPage")); 69 $this->addMultiCommand("delete", $lng->txt("delete")); 70 $this->addMultiCommand("selectHeader", $lng->txt("selectHeader")); 71 $this->addMultiCommand("selectFooter", $lng->txt("selectFooter")); 72 73 // $this->addCommandButton("", $lng->txt("")); 74 } 75 76 /** 77 * Fill table row 78 */ 79 protected function fillRow($a_set) 80 { 81 $lng = $this->lng; 82 $ilCtrl = $this->ctrl; 83 //var_dump($a_set); 84 85 // icon... 86 87 // check activation 88 $active = ilLMPage::_lookupActive( 89 $a_set["obj_id"], 90 $this->lm->getType(), 91 $this->lm_set->get("time_scheduled_page_activation") 92 ); 93 94 // is page scheduled? 95 $img_sc = ($this->lm_set->get("time_scheduled_page_activation") && 96 ilLMPage::_isScheduledActivation($a_set["obj_id"], $this->lm->getType())) 97 ? "_sc" 98 : ""; 99 100 if (!$active) { 101 $img = "icon_pg_d" . $img_sc . ".svg"; 102 $alt = $lng->txt("cont_page_deactivated"); 103 } else { 104 if (ilLMPage::_lookupContainsDeactivatedElements( 105 $a_set["obj_id"], 106 $this->lm->getType() 107 )) { 108 $img = "icon_pg_del" . $img_sc . ".svg"; 109 $alt = $lng->txt("cont_page_deactivated_elements"); 110 } else { 111 $img = "icon_pg" . $img_sc . ".svg"; 112 $alt = $this->lng->txt("pg"); 113 } 114 } 115 $this->tpl->setVariable("ICON", ilUtil::img(ilUtil::getImagePath($img), $alt)); 116 117 // title/link 118 $ilCtrl->setParameter($this, "backcmd", ""); 119 $ilCtrl->setParameterByClass("ilLMPageObjectGUI", "obj_id", $a_set["obj_id"]); 120 $this->tpl->setVariable( 121 "HREF_TITLE", 122 $ilCtrl->getLinkTargetByClass("ilLMPageObjectGUI", "edit") 123 ); 124 $this->tpl->setVariable("TITLE", $a_set["title"]); 125 $this->tpl->setVariable("ID", $a_set["obj_id"]); 126 127 // context 128 if ($this->lm->lm_tree->isInTree($a_set["obj_id"])) { 129 $path_str = $this->parent_obj->getContextPath($a_set["obj_id"]); 130 } else { 131 $path_str = "---"; 132 } 133 134 // check whether page is header or footer 135 $add_str = ""; 136 if ($a_set["obj_id"] == $this->lm->getHeaderPage()) { 137 $add_str = " <b>(" . $lng->txt("cont_header") . ")</b>"; 138 } 139 if ($a_set["obj_id"] == $this->lm->getFooterPage()) { 140 $add_str .= " <b>(" . $lng->txt("cont_footer") . ")</b>"; 141 } 142 143 $this->tpl->setVariable("USAGE", $path_str . $add_str); 144 145 // layout 146 if ($this->lm->getLayoutPerPage()) { 147 if (($l = ilLMObject::lookupLayout($a_set["obj_id"])) != "") { 148 $this->tpl->setVariable( 149 "LAYOUT", 150 $lng->txt("cont_layout_" . $l) 151 ); 152 } 153 } 154 } 155} 156