ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilWebResourceLinkTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Table/classes/class.ilTable2GUI.php';
5include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
6include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
7include_once './Services/Container/classes/class.ilContainerSorting.php';
8include_once './Services/Container/classes/class.ilContainer.php';
9include_once './Services/Container/classes/class.ilContainerSorting.php';
10include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
11
12
23{
24 protected $editable = false;
25 protected $web_res = null;
26
27 protected $link_sort_mode = null;
28 protected $link_sort_enabled = false;
29
33 public function __construct($a_parent_obj, $a_parent_cmd, $a_sorting = false)
34 {
35 global $DIC;
36
37 $lng = $DIC['lng'];
38 $ilAccess = $DIC['ilAccess'];
39 $ilCtrl = $DIC['ilCtrl'];
40
41 parent::__construct($a_parent_obj, $a_parent_cmd);
42
43 // Initialize
44 if ($ilAccess->checkAccess('write', '', $this->getParentObject()->object->getRefId())) {
45 $this->editable = true;
46 }
47
48 $this->enableLinkSorting($a_sorting);
49 $this->web_res = new ilLinkResourceItems($this->getParentObject()->object->getId());
50
51
52 $this->setTitle($lng->txt('web_resources'));
53
54 if ($this->isEditable()) {
55 if ($this->isLinkSortingEnabled()) {
56 $this->setLimit(9999);
57 $this->addColumn($lng->txt('position'), '', '10px');
58 $this->addColumn($lng->txt('title'), '', '90%');
59 $this->addColumn('', '', '10%');
60
61 $this->addMultiCommand('saveSorting', $this->lng->txt('sorting_save'));
62 } else {
63 $this->addColumn($lng->txt('title'), '', '90%');
64 $this->addColumn('', '', '10%');
65 }
66 } else {
67 $this->addColumn($lng->txt('title'), '', '100%');
68 }
69
70 $this->initSorting();
71
72 $this->setEnableHeader(true);
73 $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
74 $this->setRowTemplate("tpl.webr_link_row.html", 'Modules/WebResource');
75 $this->setEnableTitle(true);
76 $this->setEnableNumInfo(false);
77 }
78
84 public function enableLinkSorting($a_status)
85 {
86 $this->link_sort_enabled = $a_status;
87 }
88
93 public function isLinkSortingEnabled()
94 {
95 return (bool) $this->link_sort_enabled;
96 }
97
102 public function parse()
103 {
104 $rows = array();
105
106 $items = $this->getWebResourceItems()->getActivatedItems();
107 $items = $this->getWebResourceItems()->sortItems($items);
108
109 include_once "Services/Form/classes/class.ilFormPropertyGUI.php";
110 include_once "Services/Form/classes/class.ilLinkInputGUI.php";
111
112 $counter = 1;
113 foreach ($items as $link) {
114 /* now done in ObjLinkRessourceGUI::callLink()
115 if(ilParameterAppender::_isEnabled())
116 {
117 $link = ilParameterAppender::_append($link);
118 }
119 */
120 $tmp['position'] = ($counter++) * 10;
121 $tmp['title'] = $link['title'];
122 $tmp['description'] = $link['description'];
123 $tmp['target'] = $link['target'];
124 $tmp['link_id'] = $link['link_id'];
125 $tmp['internal'] = ilLinkInputGUI::isInternalLink($link["target"]);
126
127 $rows[] = $tmp;
128 }
129 $this->setData($rows);
130 }
131
135 protected function fillRow($a_set)
136 {
137 global $DIC;
138
139 $ilCtrl = $DIC['ilCtrl'];
140 $lng = $DIC['lng'];
141
142 $ilCtrl->setParameterByClass(get_class($this->getParentObject()), 'link_id', $a_set['link_id']);
143
144 $this->tpl->setVariable('TITLE', $a_set['title']);
145 if (strlen($a_set['description'])) {
146 $this->tpl->setVariable('DESCRIPTION', $a_set['description']);
147 }
148 // $this->tpl->setVariable('TARGET',$a_set['target']);
149 $this->tpl->setVariable(
150 'TARGET',
151 $ilCtrl->getLinkTarget($this->parent_obj, "callLink")
152 );
153
154 if (!$a_set['internal']) {
155 $this->tpl->setVariable('FRAME', ' target="_blank"');
156 $this->tpl->touchBlock('noopener');
157 }
158
159 if (!$this->isEditable()) {
160 return;
161 }
162
163 if ($this->isLinkSortingEnabled()) {
164 $this->tpl->setVariable('VAL_POS', $a_set['position']);
165 $this->tpl->setVariable('VAL_ITEM', $a_set['link_id']);
166 }
167
168 $actions = new ilAdvancedSelectionListGUI();
169 $actions->setSelectionHeaderClass("small");
170 $actions->setItemLinkClass("xsmall");
171
172 $actions->setListTitle($lng->txt('actions'));
173 $actions->setId($a_set['link_id']);
174
175 $actions->addItem(
176 $lng->txt('edit'),
177 '',
178 $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'editLink')
179 );
180 $actions->addItem(
181 $lng->txt('webr_deactivate'),
182 '',
183 $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'deactivateLink')
184 );
185 $actions->addItem(
186 $lng->txt('delete'),
187 '',
188 $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'confirmDeleteLink')
189 );
190 $this->tpl->setVariable('ACTION_HTML', $actions->getHTML());
191 }
192
193
194
195
200 protected function getWebResourceItems()
201 {
202 return $this->web_res;
203 }
204
205
210 protected function isEditable()
211 {
212 return (bool) $this->editable;
213 }
214
215 protected function initSorting()
216 {
217 $this->link_sort_mode = ilContainerSortingSettings::_lookupSortMode(
218 $this->getParentObject()->object->getId()
219 );
220 }
221}
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
static _lookupSortMode($a_obj_id)
lookup sort mode
static isInternalLink($a_value)
Class ilObjLinkResourceGUI.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setEnableNumInfo($a_val)
Set enable num info.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command button.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
TableGUI class for search results.
__construct($a_parent_obj, $a_parent_cmd, $a_sorting=false)
Constructor.
isLinkSortingEnabled()
Check if link sorting is enabled.
enableLinkSorting($a_status)
Enable sorting of links.
getWebResourceItems()
Get Web resource items object.
isEditable()
Check if links are editable.
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46
$rows
Definition: xhr_table.php:10