ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 $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 $counter = 1;
116 foreach($items as $link)
117 {
118 /* now done in ObjLinkRessourceGUI::callLink()
119 if(ilParameterAppender::_isEnabled())
120 {
121 $link = ilParameterAppender::_append($link);
122 }
123 */
124 $tmp['position'] = ($counter++) * 10;
125 $tmp['title'] = $link['title'];
126 $tmp['description'] = $link['description'];
127 $tmp['target'] = $link['target'];
128 $tmp['link_id'] = $link['link_id'];
129
130 $rows[] = $tmp;
131 }
132 $this->setData($rows);
133 }
134
138 protected function fillRow($a_set)
139 {
140 global $ilCtrl,$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 {
147 $this->tpl->setVariable('DESCRIPTION',$a_set['description']);
148 }
149 // $this->tpl->setVariable('TARGET',$a_set['target']);
150 $this->tpl->setVariable('TARGET',
151 $ilCtrl->getLinkTarget($this->parent_obj, "callLink"));
152
153 if(!$this->isEditable())
154 {
155 return;
156 }
157
158 if($this->isLinkSortingEnabled())
159 {
160 $this->tpl->setVariable('VAL_POS',$a_set['position']);
161 $this->tpl->setVariable('VAL_ITEM',$a_set['link_id']);
162 }
163
164 $actions = new ilAdvancedSelectionListGUI();
165 $actions->setSelectionHeaderClass("small");
166 $actions->setItemLinkClass("xsmall");
167
168 $actions->setListTitle($lng->txt('actions'));
169 $actions->setId($a_set['link_id']);
170
171 $actions->addItem(
172 $lng->txt('edit'),
173 '',
174 $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'editLink')
175 );
176 $actions->addItem(
177 $lng->txt('webr_deactivate'),
178 '',
179 $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'deactivateLink')
180 );
181 $actions->addItem(
182 $lng->txt('delete'),
183 '',
184 $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'confirmDeleteLink')
185 );
186 $this->tpl->setVariable('ACTION_HTML',$actions->getHTML());
187 }
188
189
190
191
196 protected function getWebResourceItems()
197 {
198 return $this->web_res;
199 }
200
201
206 protected function isEditable()
207 {
208 return (bool) $this->editable;
209 }
210
211 protected function initSorting()
212 {
213 $this->link_sort_mode = ilContainerSortingSettings::_lookupSortMode(
214 $this->getParentObject()->object->getId()
215 );
216 }
217}
218?>
User interface class for advanced drop-down selection lists.
static _lookupSortMode($a_obj_id)
lookup sort mode
Class ilObjLinkResourceGUI.
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
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.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setLimit($a_limit=0, $a_default_limit=0)
set max.
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
global $lng
Definition: privfeed.php:40