ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
42  $this->editable = true;
43  }
44 
45  $this->enableLinkSorting($a_sorting);
46  $this->web_res = new ilLinkResourceItems($this->getParentObject()->object->getId());
47 
48 
49  $this->setTitle($lng->txt('web_resources'));
50 
51  if($this->isEditable())
52  {
53  if($this->isLinkSortingEnabled())
54  {
55  $this->setLimit(9999);
56  $this->addColumn($lng->txt('position'),'','10px');
57  $this->addColumn($lng->txt('title'),'','90%');
58  $this->addColumn('','','10%');
59 
60  $this->addMultiCommand('saveSorting', $this->lng->txt('sorting_save'));
61  }
62  else
63  {
64  $this->addColumn($lng->txt('title'),'','90%');
65  $this->addColumn('','','10%');
66  }
67 
68  }
69  else
70  {
71  $this->addColumn($lng->txt('title'),'','100%');
72  }
73 
74  $this->initSorting();
75 
76  $this->setEnableHeader(true);
77  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
78  $this->setRowTemplate("tpl.webr_link_row.html", 'Modules/WebResource');
79  $this->setEnableTitle(true);
80  $this->setEnableNumInfo(false);
81 
82  }
83 
89  public function enableLinkSorting($a_status)
90  {
91  $this->link_sort_enabled = $a_status;
92  }
93 
98  public function isLinkSortingEnabled()
99  {
100  return (bool) $this->link_sort_enabled;
101  }
102 
107  public function parse()
108  {
109 
110  $rows = array();
111 
112  $items = $this->getWebResourceItems()->getActivatedItems();
113  $items = $this->getWebResourceItems()->sortItems($items);
114 
115  include_once "Services/Form/classes/class.ilFormPropertyGUI.php";
116  include_once "Services/Form/classes/class.ilLinkInputGUI.php";
117 
118  $counter = 1;
119  foreach($items as $link)
120  {
121  /* now done in ObjLinkRessourceGUI::callLink()
122  if(ilParameterAppender::_isEnabled())
123  {
124  $link = ilParameterAppender::_append($link);
125  }
126  */
127  $tmp['position'] = ($counter++) * 10;
128  $tmp['title'] = $link['title'];
129  $tmp['description'] = $link['description'];
130  $tmp['target'] = $link['target'];
131  $tmp['link_id'] = $link['link_id'];
132  $tmp['internal'] = ilLinkInputGUI::isInternalLink($link["target"]);
133 
134  $rows[] = $tmp;
135  }
136  $this->setData($rows);
137  }
138 
142  protected function fillRow($a_set)
143  {
144  global $ilCtrl,$lng;
145 
146  $ilCtrl->setParameterByClass(get_class($this->getParentObject()), 'link_id', $a_set['link_id']);
147 
148  $this->tpl->setVariable('TITLE',$a_set['title']);
149  if(strlen($a_set['description']))
150  {
151  $this->tpl->setVariable('DESCRIPTION',$a_set['description']);
152  }
153  // $this->tpl->setVariable('TARGET',$a_set['target']);
154  $this->tpl->setVariable('TARGET',
155  $ilCtrl->getLinkTarget($this->parent_obj, "callLink"));
156 
157  if(!$a_set['internal'])
158  {
159  $this->tpl->setVariable('FRAME', ' target="_blank"');
160  $this->tpl->touchBlock('noopener');
161  }
162 
163  if(!$this->isEditable())
164  {
165  return;
166  }
167 
168  if($this->isLinkSortingEnabled())
169  {
170  $this->tpl->setVariable('VAL_POS',$a_set['position']);
171  $this->tpl->setVariable('VAL_ITEM',$a_set['link_id']);
172  }
173 
174  $actions = new ilAdvancedSelectionListGUI();
175  $actions->setSelectionHeaderClass("small");
176  $actions->setItemLinkClass("xsmall");
177 
178  $actions->setListTitle($lng->txt('actions'));
179  $actions->setId($a_set['link_id']);
180 
181  $actions->addItem(
182  $lng->txt('edit'),
183  '',
184  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'editLink')
185  );
186  $actions->addItem(
187  $lng->txt('webr_deactivate'),
188  '',
189  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'deactivateLink')
190  );
191  $actions->addItem(
192  $lng->txt('delete'),
193  '',
194  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'confirmDeleteLink')
195  );
196  $this->tpl->setVariable('ACTION_HTML',$actions->getHTML());
197  }
198 
199 
200 
201 
206  protected function getWebResourceItems()
207  {
208  return $this->web_res;
209  }
210 
211 
216  protected function isEditable()
217  {
218  return (bool) $this->editable;
219  }
220 
221  protected function initSorting()
222  {
223  $this->link_sort_mode = ilContainerSortingSettings::_lookupSortMode(
224  $this->getParentObject()->object->getId()
225  );
226  }
227 }
228 ?>
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.
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
global $lng
Definition: privfeed.php:17
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.
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.
setLimit($a_limit=0, $a_default_limit=0)