ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $lng,$ilAccess,$ilCtrl;
36 
37  parent::__construct($a_parent_obj, $a_parent_cmd);
38 
39  // Initialize
40  if ($ilAccess->checkAccess('write', '', $this->getParentObject()->object->getRefId())) {
41  $this->editable = true;
42  }
43 
44  $this->enableLinkSorting($a_sorting);
45  $this->web_res = new ilLinkResourceItems($this->getParentObject()->object->getId());
46 
47 
48  $this->setTitle($lng->txt('web_resources'));
49 
50  if ($this->isEditable()) {
51  if ($this->isLinkSortingEnabled()) {
52  $this->setLimit(9999);
53  $this->addColumn($lng->txt('position'), '', '10px');
54  $this->addColumn($lng->txt('title'), '', '90%');
55  $this->addColumn('', '', '10%');
56 
57  $this->addMultiCommand('saveSorting', $this->lng->txt('sorting_save'));
58  } else {
59  $this->addColumn($lng->txt('title'), '', '90%');
60  $this->addColumn('', '', '10%');
61  }
62  } else {
63  $this->addColumn($lng->txt('title'), '', '100%');
64  }
65 
66  $this->initSorting();
67 
68  $this->setEnableHeader(true);
69  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
70  $this->setRowTemplate("tpl.webr_link_row.html", 'Modules/WebResource');
71  $this->setEnableTitle(true);
72  $this->setEnableNumInfo(false);
73  }
74 
80  public function enableLinkSorting($a_status)
81  {
82  $this->link_sort_enabled = $a_status;
83  }
84 
89  public function isLinkSortingEnabled()
90  {
91  return (bool) $this->link_sort_enabled;
92  }
93 
98  public function parse()
99  {
100  $rows = array();
101 
102  $items = $this->getWebResourceItems()->getActivatedItems();
103  $items = $this->getWebResourceItems()->sortItems($items);
104 
105  include_once "Services/Form/classes/class.ilFormPropertyGUI.php";
106  include_once "Services/Form/classes/class.ilLinkInputGUI.php";
107 
108  $counter = 1;
109  foreach ($items as $link) {
110  /* now done in ObjLinkRessourceGUI::callLink()
111  if(ilParameterAppender::_isEnabled())
112  {
113  $link = ilParameterAppender::_append($link);
114  }
115  */
116  $tmp['position'] = ($counter++) * 10;
117  $tmp['title'] = $link['title'];
118  $tmp['description'] = $link['description'];
119  $tmp['target'] = $link['target'];
120  $tmp['link_id'] = $link['link_id'];
121  $tmp['internal'] = ilLinkInputGUI::isInternalLink($link["target"]);
122 
123  $rows[] = $tmp;
124  }
125  $this->setData($rows);
126  }
127 
131  protected function fillRow($a_set)
132  {
133  global $ilCtrl,$lng;
134 
135  $ilCtrl->setParameterByClass(get_class($this->getParentObject()), 'link_id', $a_set['link_id']);
136 
137  $this->tpl->setVariable('TITLE', $a_set['title']);
138  if (strlen($a_set['description'])) {
139  $this->tpl->setVariable('DESCRIPTION', $a_set['description']);
140  }
141  // $this->tpl->setVariable('TARGET',$a_set['target']);
142  $this->tpl->setVariable(
143  'TARGET',
144  $ilCtrl->getLinkTarget($this->parent_obj, "callLink")
145  );
146 
147  if (!$a_set['internal']) {
148  $this->tpl->setVariable('FRAME', ' target="_blank"');
149  $this->tpl->touchBlock('noopener');
150  }
151 
152  if (!$this->isEditable()) {
153  return;
154  }
155 
156  if ($this->isLinkSortingEnabled()) {
157  $this->tpl->setVariable('VAL_POS', $a_set['position']);
158  $this->tpl->setVariable('VAL_ITEM', $a_set['link_id']);
159  }
160 
161  $actions = new ilAdvancedSelectionListGUI();
162  $actions->setSelectionHeaderClass("small");
163  $actions->setItemLinkClass("xsmall");
164 
165  $actions->setListTitle($lng->txt('actions'));
166  $actions->setId($a_set['link_id']);
167 
168  $actions->addItem(
169  $lng->txt('edit'),
170  '',
171  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'editLink')
172  );
173  $actions->addItem(
174  $lng->txt('webr_deactivate'),
175  '',
176  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'deactivateLink')
177  );
178  $actions->addItem(
179  $lng->txt('delete'),
180  '',
181  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'confirmDeleteLink')
182  );
183  $this->tpl->setVariable('ACTION_HTML', $actions->getHTML());
184  }
185 
186 
187 
188 
193  protected function getWebResourceItems()
194  {
195  return $this->web_res;
196  }
197 
198 
203  protected function isEditable()
204  {
205  return (bool) $this->editable;
206  }
207 
208  protected function initSorting()
209  {
210  $this->link_sort_mode = ilContainerSortingSettings::_lookupSortMode(
211  $this->getParentObject()->object->getId()
212  );
213  }
214 }
TableGUI class for search results.
enableLinkSorting($a_status)
Enable sorting of links.
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.
$counter
Class ilTable2GUI.
static isInternalLink($a_value)
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
$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.
Create new PHPExcel object
obj_idprivate
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)