ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilPortfolioPageTableGUI.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  protected \ILIAS\Portfolio\InternalGUIService $gui;
27  protected array $blogs;
28  protected ilObjUser $user;
30  protected bool $is_template;
31  protected string $page_gui;
32 
33  public function __construct(
34  ilObjPortfolioBaseGUI $a_parent_obj,
35  string $a_parent_cmd
36  ) {
37  global $DIC;
38 
39  $this->ctrl = $DIC->ctrl();
40  $this->lng = $DIC->language();
41  $this->user = $DIC->user();
42  $ilCtrl = $DIC->ctrl();
43  $lng = $DIC->language();
44  $this->gui = $DIC->portfolio()->internal()->gui();
45 
46  parent::__construct($a_parent_obj, $a_parent_cmd);
47  $this->disable("numinfo");
48  $this->setLimit(9999);
49 
51  $portfolio = $a_parent_obj->getObject();
52  $this->portfolio = $portfolio;
53  $this->page_gui = $this->parent_obj->getPageGUIClassName();
54  $this->is_template = ($this->portfolio->getType() === "prtt");
55 
56  $this->setTitle($lng->txt("content"));
57 
58  //$this->addColumn($this->lng->txt(""), "", "1");
59  $this->addColumn($this->lng->txt("user_order"));
60  $this->addColumn($this->lng->txt("title"));
61  $this->addColumn($this->lng->txt("type"));
62  $this->addColumn($this->lng->txt("actions"));
63 
64  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
65  $this->setRowTemplate("tpl.portfolio_page_row.html", "Modules/Portfolio");
66 
67  //$this->addMultiCommand("confirmPortfolioPageDeletion", $lng->txt("delete"));
68  //$this->addMultiCommand("copyPageForm", $lng->txt("prtf_copy_page"));
69 
70  $this->addCommandButton(
71  "savePortfolioPagesOrdering",
72  $lng->txt("user_save_ordering_and_titles")
73  );
74 
75  $this->getItems();
76 
77  $lng->loadLanguageModule("blog");
78  }
79 
80  public function getItems(): void
81  {
82  $ilUser = $this->user;
83 
84  $data = ilPortfolioPage::getAllPortfolioPages($this->portfolio->getId());
85  $this->setData($data);
86 
87  if (!$this->is_template) {
88  $this->blogs = array();
89  $tree = new ilWorkspaceTree($ilUser->getId());
90  $root = $tree->readRootId();
91  if ($root) {
92  $root = $tree->getNodeData($root);
93  foreach ($tree->getSubTree($root) as $node) {
94  if ($node["type"] == "blog") {
95  $this->blogs[$node["obj_id"]] = $node["wsp_id"];
96  }
97  }
98  }
99  }
100  }
101 
102  protected function fillRow(array $a_set): void
103  {
104  $f = $this->gui->ui()->factory();
105  $lng = $this->lng;
106  $ilCtrl = $this->ctrl;
107  $action_items = [];
108  switch ($a_set["type"]) {
110  $this->tpl->setCurrentBlock("title_field");
111  $this->tpl->setVariable("ID", $a_set["id"]);
112  $this->tpl->setVariable("VAL_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($a_set["title"]));
113  $this->tpl->parseCurrentBlock();
114 
115  $ilCtrl->setParameterByClass(
116  $this->page_gui,
117  "ppage",
118  $a_set["id"]
119  );
120  //$action_item = ilLinkButton::getInstance();
121  //$action_item->setCaption('edit_page');
122  //$action_item->setUrl($ilCtrl->getLinkTargetByClass($this->page_gui, "edit"));
123  $action_items[] = $f->button()->shy(
124  $lng->txt('edit_page'),
125  $ilCtrl->getLinkTargetByClass($this->page_gui, "edit")
126  );
127 
128 
129  $this->tpl->setVariable("TYPE", $lng->txt("page"));
130  break;
131 
133  if (!$this->is_template) {
134  $this->tpl->setCurrentBlock("title_static");
135  $this->tpl->setVariable("VAL_TITLE_STATIC", ilObjBlog::_lookupTitle($a_set["title"]));
136  $this->tpl->parseCurrentBlock();
137 
138  $obj_id = (int) $a_set["title"];
139  if (isset($this->blogs[$obj_id])) {
140  $node_id = $this->blogs[$obj_id];
141  $link = ilWorkspaceAccessHandler::getGotoLink($node_id, $obj_id);
142 
143  // #11519
144  $ilCtrl->setParameterByClass(
145  $this->page_gui,
146  "ppage",
147  $a_set["id"]
148  );
149  $link = $ilCtrl->getLinkTargetByClass(array($this->page_gui, "ilobjbloggui"), "render");
150 
151  /*$action_item = ilLinkButton::getInstance();
152  $action_item->setCaption('blog_edit');
153  $action_item->setUrl($link);
154  $action_items[] = $action_item;*/
155  $action_items[] = $f->button()->shy(
156  $lng->txt('blog_edit'),
157  $link
158  );
159  }
160  $this->tpl->setVariable("TYPE", $lng->txt("obj_blog"));
161  }
162  break;
163 
165  if ($this->is_template) {
166  $this->tpl->setCurrentBlock("title_field");
167  $this->tpl->setVariable("ID", $a_set["id"]);
168  $this->tpl->setVariable("VAL_TITLE", ilLegacyFormElementsUtil::prepareFormOutput($a_set["title"]));
169  $this->tpl->parseCurrentBlock();
170 
171  $this->tpl->setCurrentBlock("title_static");
172  //$this->tpl->setVariable("VAL_TITLE_STATIC", $lng->txt("obj_blog"));
173  $this->tpl->parseCurrentBlock();
174  $this->tpl->setVariable("TYPE", $lng->txt("obj_blog"));
175  }
176  break;
177  }
178 
179  $ilCtrl->setParameter($this->parent_obj, "prtf_page", $a_set["id"]);
180 
181  // copy
182  //$action_item = ilLinkButton::getInstance();
183  if ((int) $a_set["type"] === ilPortfolioPage::TYPE_PAGE) {
184  $txt = $lng->txt('prtf_copy_pg');
185  } else {
186  $txt = $lng->txt('prtf_copy_blog_pg');
187  }
188  //$action_item->setUrl($ilCtrl->getLinkTarget($this->parent_obj, "copyPageForm"));
189  //$action_items[] = $action_item;
190  $action_items[] = $f->button()->shy(
191  $txt,
192  $ilCtrl->getLinkTarget($this->parent_obj, "copyPageForm")
193  );
194 
195 
196  // delete
197  //$action_item = ilLinkButton::getInstance();
198  //$action_item->setCaption('delete');
199  //$action_item->setUrl($ilCtrl->getLinkTarget($this->parent_obj, "confirmPortfolioPageDeletion"));
200  //$action_items[] = $action_item;
201  $action_items[] = $f->button()->shy(
202  $lng->txt("delete"),
203  $ilCtrl->getLinkTarget($this->parent_obj, "confirmPortfolioPageDeletion")
204  );
205 
206 
207  $ilCtrl->setParameter($this->parent_obj, "prtf_page", "");
208 
209  $ks = [];
210  if (count($action_items) > 0) {
211  $first = array_shift($action_items);
212  $ks[] = $f->button()->standard(
213  $first->getLabel(),
214  $first->getAction()
215  );
216  /*$split_button = ilSplitButtonGUI::getInstance();
217  $i = 0;
218  foreach ($action_items as $item) {
219  if ($i++ === 0) {
220  $split_button->setDefaultButton($item);
221  } else {
222  $split_button->addMenuItem(new ilButtonToSplitButtonMenuItemAdapter($item));
223  }
224  }*/
225  if (count($action_items) > 0) {
226  $ks[] = $f->dropdown()->standard($action_items);
227  }
228  $this->tpl->setVariable(
229  "SPLIT_BUTTON",
230  $this->gui->ui()->renderer()->render([$ks])
231  );
232  }
233 
234 
235  $this->tpl->setVariable("ID", $a_set["id"]);
236  $this->tpl->setVariable("VAL_ORDER_NR", $a_set["order_nr"]);
237  }
238 }
setData(array $a_data)
static getAllPortfolioPages(int $a_portfolio_id)
Get pages of portfolio.
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setFormAction(string $a_form_action, bool $a_multipart=false)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
static getGotoLink(int $a_node_id, int $a_obj_id, string $a_additional="")
loadLanguageModule(string $a_module)
Load language module.
static prepareFormOutput($a_str, bool $a_strip=false)
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
static _lookupTitle(int $obj_id)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
ILIAS Portfolio InternalGUIService $gui
$txt
Definition: error.php:14
Portfolio view gui base class.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
disable(string $a_module_name)
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...