ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  $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++;
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',sprintf('%.2f',$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 ?>