ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
6 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
7 include_once './Services/Container/classes/class.ilContainerSorting.php';
8 include_once './Services/Container/classes/class.ilContainer.php';
9 include_once './Services/Container/classes/class.ilContainerSorting.php';
10 include_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 }
TableGUI class for search results.
enableLinkSorting($a_status)
Enable sorting of links.
global $DIC
Definition: saml.php:7
isLinkSortingEnabled()
Check if link sorting is enabled.
setEnableNumInfo($a_val)
Set enable num info.
getParentObject()
Get parent object.
isEditable()
Check if links are editable.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
static isInternalLink($a_value)
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
$rows
Definition: xhr_table.php:10
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
getWebResourceItems()
Get Web resource items object.
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.
Class ilObjLinkResourceGUI.
setEnableHeader($a_enableheader)
Set Enable Header.
__construct($a_parent_obj, $a_parent_cmd, $a_sorting=false)
Constructor.
static _lookupSortMode($a_obj_id)
lookup sort mode
setEnableTitle($a_enabletitle)
Set Enable Title.
setLimit($a_limit=0, $a_default_limit=0)