1<?php 2 3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */ 4 5/** 6 * Portfolio page table 7 * 8 * @author Jörg Lützenkirchen <luetzenkirchen@leifos.com> 9 */ 10class ilPortfolioPageTableGUI extends ilTable2GUI 11{ 12 /** 13 * @var ilObjUser 14 */ 15 protected $user; 16 17 protected $portfolio; // [ilObjPortfolio] 18 protected $is_template; // [bool] 19 protected $page_gui; // [string] 20 21 /** 22 * Constructor 23 */ 24 public function __construct(ilObjPortfolioBaseGUI $a_parent_obj, $a_parent_cmd) 25 { 26 global $DIC; 27 28 $this->ctrl = $DIC->ctrl(); 29 $this->lng = $DIC->language(); 30 $this->user = $DIC->user(); 31 $ilCtrl = $DIC->ctrl(); 32 $lng = $DIC->language(); 33 34 parent::__construct($a_parent_obj, $a_parent_cmd); 35 $this->disable("numinfo"); 36 $this->setLimit(9999); 37 38 $this->portfolio = $a_parent_obj->object; 39 $this->page_gui = $this->parent_obj->getPageGUIClassName(); 40 $this->is_template = ($this->portfolio->getType() == "prtt"); 41 42 $this->setTitle($lng->txt("tabs")); 43 44 //$this->addColumn($this->lng->txt(""), "", "1"); 45 $this->addColumn($this->lng->txt("user_order")); 46 $this->addColumn($this->lng->txt("title")); 47 $this->addColumn($this->lng->txt("type")); 48 $this->addColumn($this->lng->txt("actions")); 49 50 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); 51 $this->setRowTemplate("tpl.portfolio_page_row.html", "Modules/Portfolio"); 52 53 //$this->addMultiCommand("confirmPortfolioPageDeletion", $lng->txt("delete")); 54 //$this->addMultiCommand("copyPageForm", $lng->txt("prtf_copy_page")); 55 56 $this->addCommandButton( 57 "savePortfolioPagesOrdering", 58 $lng->txt("user_save_ordering_and_titles") 59 ); 60 61 $this->getItems(); 62 63 $lng->loadLanguageModule("blog"); 64 } 65 66 public function getItems() 67 { 68 $ilUser = $this->user; 69 70 $data = ilPortfolioPage::getAllPortfolioPages($this->portfolio->getId()); 71 $this->setData($data); 72 73 if (!$this->is_template) { 74 $this->blogs = array(); 75 $tree = new ilWorkspaceTree($ilUser->getId()); 76 $root = $tree->readRootId(); 77 if ($root) { 78 $root = $tree->getNodeData($root); 79 foreach ($tree->getSubTree($root) as $node) { 80 if ($node["type"] == "blog") { 81 $this->blogs[$node["obj_id"]] = $node["wsp_id"]; 82 } 83 } 84 } 85 } 86 } 87 88 /** 89 * Fill table row 90 */ 91 protected function fillRow($a_set) 92 { 93 $lng = $this->lng; 94 $lng = $this->lng; 95 $ilCtrl = $this->ctrl; 96 $action_items = []; 97 98 switch ($a_set["type"]) { 99 case ilPortfolioPage::TYPE_PAGE: 100 $this->tpl->setCurrentBlock("title_field"); 101 $this->tpl->setVariable("ID", $a_set["id"]); 102 $this->tpl->setVariable("VAL_TITLE", ilUtil::prepareFormOutput($a_set["title"])); 103 $this->tpl->parseCurrentBlock(); 104 105 $ilCtrl->setParameterByClass( 106 $this->page_gui, 107 "ppage", 108 $a_set["id"] 109 ); 110 $action_item = ilLinkButton::getInstance(); 111 $action_item->setCaption('edit_page'); 112 $action_item->setUrl($ilCtrl->getLinkTargetByClass($this->page_gui, "edit")); 113 $action_items[] = $action_item; 114 115 116 $this->tpl->setVariable("TYPE", $lng->txt("page")); 117 break; 118 119 case ilPortfolioPage::TYPE_BLOG: 120 if (!$this->is_template) { 121 $this->tpl->setCurrentBlock("title_static"); 122 $this->tpl->setVariable("VAL_TITLE_STATIC", ilObjBlog::_lookupTitle($a_set["title"])); 123 $this->tpl->parseCurrentBlock(); 124 125 $obj_id = (int) $a_set["title"]; 126 if (isset($this->blogs[$obj_id])) { 127 $node_id = $this->blogs[$obj_id]; 128 $link = ilWorkspaceAccessHandler::getGotoLink($node_id, $obj_id); 129 130 // #11519 131 $ilCtrl->setParameterByClass( 132 $this->page_gui, 133 "ppage", 134 $a_set["id"] 135 ); 136 $link = $ilCtrl->getLinkTargetByClass(array($this->page_gui, "ilobjbloggui"), "render"); 137 138 $action_item = ilLinkButton::getInstance(); 139 $action_item->setCaption('blog_edit'); 140 $action_item->setUrl($link); 141 $action_items[] = $action_item; 142 } 143 $this->tpl->setVariable("TYPE", $lng->txt("obj_blog")); 144 } 145 break; 146 147 case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE: 148 if ($this->is_template) { 149 $this->tpl->setCurrentBlock("title_field"); 150 $this->tpl->setVariable("ID", $a_set["id"]); 151 $this->tpl->setVariable("VAL_TITLE", ilUtil::prepareFormOutput($a_set["title"])); 152 $this->tpl->parseCurrentBlock(); 153 154 $this->tpl->setCurrentBlock("title_static"); 155 //$this->tpl->setVariable("VAL_TITLE_STATIC", $lng->txt("obj_blog")); 156 $this->tpl->parseCurrentBlock(); 157 $this->tpl->setVariable("TYPE", $lng->txt("obj_blog")); 158 } 159 break; 160 } 161 162 $ilCtrl->setParameter($this->parent_obj, "prtf_pages[]", $a_set["id"]); 163 164 // copy 165 $action_item = ilLinkButton::getInstance(); 166 $action_item->setCaption('prtf_copy_tab'); 167 $action_item->setUrl($ilCtrl->getLinkTarget($this->parent_obj, "copyPageForm")); 168 $action_items[] = $action_item; 169 170 // delete 171 $action_item = ilLinkButton::getInstance(); 172 $action_item->setCaption('delete'); 173 $action_item->setUrl($ilCtrl->getLinkTarget($this->parent_obj, "confirmPortfolioPageDeletion")); 174 $action_items[] = $action_item; 175 176 177 $ilCtrl->setParameter($this->parent_obj, "prtf_pages[]", ""); 178 179 if (count($action_items) > 0) { 180 $split_button = ilSplitButtonGUI::getInstance(); 181 $i = 0; 182 foreach ($action_items as $item) { 183 if ($i++ == 0) { 184 $split_button->setDefaultButton($item); 185 } else { 186 $split_button->addMenuItem(new ilButtonToSplitButtonMenuItemAdapter($item)); 187 } 188 } 189 $this->tpl->setVariable("SPLIT_BUTTON", $split_button->render()); 190 } 191 192 193 $this->tpl->setVariable("ID", $a_set["id"]); 194 $this->tpl->setVariable("VAL_ORDER_NR", $a_set["order_nr"]); 195 } 196} 197