ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDclTableListGUI Class Reference

ilDclTableListGUI: ilDclFieldListGUI, ilDclFieldEditGUI, ilDclTableViewGUI, ilDclTableEditGUI More...

+ Collaboration diagram for ilDclTableListGUI:

Public Member Functions

 __construct (ilObjDataCollectionGUI $a_parent_obj)
 
 getObjId ()
 
 getRefId ()
 
 executeCommand ()
 execute command More...
 
 listTables ()
 
 confirmDeleteTables ()
 
 checkTablesLeft (int $delete_count)
 redirects if there are no tableviews left after deletion of {$delete_count} tableviews More...
 
 getDataCollectionObject ()
 

Protected Member Functions

 getItems ()
 
 getActions (ilDclTable $table)
 
 setTabs (string $active)
 
 save ()
 
 deleteTables ()
 
 checkAccess ()
 

Protected Attributes

ILIAS UI Factory $ui_factory
 
ILIAS UI Renderer $renderer
 
ilCtrl $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilTabsGUI $tabs
 
ilToolbarGUI $toolbar
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ilObjDataCollectionGUI $parent_obj
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDclTableListGUI::__construct ( ilObjDataCollectionGUI  $a_parent_obj)

Definition at line 39 of file class.ilDclTableListGUI.php.

References $DIC, checkAccess(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), renderer(), ILIAS\Repository\tabs(), and ILIAS\Repository\toolbar().

40  {
41  global $DIC;
42  $main_tpl = $DIC->ui()->mainTemplate();
43  $this->ctrl = $DIC->ctrl();
44  $this->lng = $DIC->language();
45  $this->tpl = $DIC->ui()->mainTemplate();
46  $this->tabs = $DIC->tabs();
47  $this->toolbar = $DIC->toolbar();
48  $this->http = $DIC->http();
49  $this->refinery = $DIC->refinery();
50  $this->ui_factory = $DIC->ui()->factory();
51  $this->renderer = $DIC->ui()->renderer();
52 
53  $this->tabs->setSetupMode(true);
54  $DIC->help()->setScreenId('dcl_tables');
55 
56  $this->parent_obj = $a_parent_obj;
57 
58  if (!$this->checkAccess()) {
59  $main_tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
60  $this->ctrl->redirectByClass(ilDclRecordListGUI::class, 'listRecords');
61  }
62  }
renderer()
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ checkAccess()

ilDclTableListGUI::checkAccess ( )
protected

Definition at line 348 of file class.ilDclTableListGUI.php.

References $ref_id, and ilObjDataCollectionAccess\hasWriteAccess().

Referenced by __construct().

348  : bool
349  {
350  $ref_id = $this->parent_obj->getRefId();
351 
353  }
$ref_id
Definition: ltiauth.php:65
static hasWriteAccess(int $ref, ?int $user_id=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkTablesLeft()

ilDclTableListGUI::checkTablesLeft ( int  $delete_count)

redirects if there are no tableviews left after deletion of {$delete_count} tableviews

Parameters
$delete_countnumber of tableviews to delete

Definition at line 340 of file class.ilDclTableListGUI.php.

References ILIAS\Repository\ctrl(), getDataCollectionObject(), and ILIAS\Repository\lng().

Referenced by confirmDeleteTables().

340  : void
341  {
342  if ($delete_count >= count($this->getDataCollectionObject()->getTables())) {
343  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('dcl_msg_tables_delete_all'), true);
344  $this->ctrl->redirect($this, 'listTables');
345  }
346  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteTables()

ilDclTableListGUI::confirmDeleteTables ( )

Definition at line 291 of file class.ilDclTableListGUI.php.

References checkTablesLeft(), ILIAS\Repository\ctrl(), ilDclCache\getTableCache(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\tabs().

291  : void
292  {
293  //at least one table must exist
294  $has_dcl_table_ids = $this->http->wrapper()->post()->has('dcl_table_ids');
295  if (!$has_dcl_table_ids) {
296  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('dcl_delete_tables_no_selection'), true);
297  $this->ctrl->redirect($this, 'listTables');
298  }
299 
300  $tables = $this->http->wrapper()->post()->retrieve(
301  'dcl_table_ids',
302  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
303  );
304  $this->checkTablesLeft(count($tables));
305 
306  $this->tabs->clearSubTabs();
307  $conf = new ilConfirmationGUI();
308  $conf->setFormAction($this->ctrl->getFormAction($this));
309  $conf->setHeaderText($this->lng->txt('dcl_tables_confirm_delete'));
310 
311  foreach ($tables as $table_id) {
312  $conf->addItem('dcl_table_ids[]', (string) $table_id, ilDclCache::getTableCache($table_id)->getTitle());
313  }
314  $conf->setConfirm($this->lng->txt('delete'), 'deleteTables');
315  $conf->setCancel($this->lng->txt('cancel'), 'listTables');
316  $this->tpl->setContent($conf->getHTML());
317  }
checkTablesLeft(int $delete_count)
redirects if there are no tableviews left after deletion of {$delete_count} tableviews ...
static http()
Fetches the global http state from ILIAS.
static getTableCache(?int $table_id=null)
+ Here is the call graph for this function:

◆ deleteTables()

ilDclTableListGUI::deleteTables ( )
protected

Definition at line 319 of file class.ilDclTableListGUI.php.

References ILIAS\Repository\ctrl(), ilDclCache\getTableCache(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

319  : void
320  {
321  $has_dcl_table_ids = $this->http->wrapper()->post()->has('dcl_table_ids');
322  if ($has_dcl_table_ids) {
323  $tables = $this->http->wrapper()->post()->retrieve(
324  'dcl_table_ids',
325  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
326  );
327  foreach ($tables as $table_id) {
328  ilDclCache::getTableCache($table_id)->doDelete();
329  }
330  }
331  $this->tpl->setOnScreenMessage('success', $this->lng->txt('dcl_msg_tables_deleted'), true);
332  $this->ctrl->clearParameterByClass("ilobjdatacollectiongui", "table_id");
333  $this->ctrl->redirect($this, 'listTables');
334  }
static http()
Fetches the global http state from ILIAS.
static getTableCache(?int $table_id=null)
+ Here is the call graph for this function:

◆ executeCommand()

ilDclTableListGUI::executeCommand ( )

execute command

Definition at line 77 of file class.ilDclTableListGUI.php.

References $DIC, $ref_id, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), setTabs(), and ILIAS\Repository\tabs().

77  : void
78  {
79  global $DIC;
80  $cmd = $this->ctrl->getCmd('listTables');
81 
82  $next_class = $this->ctrl->getNextClass($this);
83 
84  $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
85 
86  switch ($next_class) {
87  case 'ildcltableeditgui':
88  $this->tabs->clearTargets();
89  if ($cmd != 'create') {
90  $this->setTabs('settings');
91  } else {
92  $this->tabs->setBackTarget(
93  $this->lng->txt('back'),
94  $this->ctrl->getLinkTarget($this, 'listTables')
95  );
96  }
97  $ilDclTableEditGUI = new ilDclTableEditGUI($this);
98  $this->ctrl->forwardCommand($ilDclTableEditGUI);
99  break;
100 
101  case 'ildclfieldlistgui':
102  $this->tabs->clearTargets();
103  $this->setTabs('fields');
104  $ilDclFieldListGUI = new ilDclFieldListGUI($this);
105  $this->ctrl->forwardCommand($ilDclFieldListGUI);
106  break;
107 
108  case "ildclfieldeditgui":
109  $this->tabs->clearTargets();
110  $this->setTabs("fields");
111  $ilDclFieldEditGUI = new ilDclFieldEditGUI($this);
112  $this->ctrl->forwardCommand($ilDclFieldEditGUI);
113  break;
114 
115  case 'ildcltableviewgui':
116  $this->tabs->clearTargets();
117  $this->setTabs('tableviews');
118  $ilDclTableViewGUI = new ilDclTableViewGUI($this);
119  $this->ctrl->forwardCommand($ilDclTableViewGUI);
120  break;
121 
122  default:
123  $this->$cmd();
124  }
125  }
ilDclTableViewGUI: ilDclTableViewEditGUI
static http()
Fetches the global http state from ILIAS.
$ref_id
Definition: ltiauth.php:65
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ getActions()

ilDclTableListGUI::getActions ( ilDclTable  $table)
protected
Returns
Shy[]

Definition at line 180 of file class.ilDclTableListGUI.php.

References ILIAS\Repository\ctrl(), ilDclTable\getId(), ilDclTable\getIsVisible(), ilDclTable\getOrder(), ilDclTable\getPublicCommentsEnabled(), and ILIAS\Repository\lng().

Referenced by getItems().

180  : array
181  {
182  $this->ctrl->setParameterByClass(ilObjDataCollectionGUI::class, 'table_id', $table->getId());
183 
184  $actions = [];
185  $actions[] = $this->ui_factory->button()->shy(
186  $this->lng->txt('settings'),
187  $this->ctrl->getLinkTargetByClass(ilDclTableEditGUI::class, 'edit'),
188  );
189 
190  $actions[] = $this->ui_factory->button()->shy(
191  $this->lng->txt('dcl_list_fields'),
192  $this->ctrl->getLinkTargetByClass(ilDclFieldListGUI::class, 'listFields')
193  );
194 
195  $actions[] = $this->ui_factory->button()->shy(
196  $this->lng->txt('dcl_tableviews'),
197  $this->ctrl->getLinkTargetByClass(ilDclTableViewGUI::class, 'show')
198  );
199 
200  $actions[] = $this->ui_factory->button()->shy(
201  $this->lng->txt('delete'),
202  $this->ctrl->getLinkTargetByClass(ilDclTableEditGUI::class, 'confirmDelete')
203  );
204 
205  if ($table->getIsVisible()) {
206  $actions[] = $this->ui_factory->button()->shy(
207  $this->lng->txt('disable_visible'),
208  $this->ctrl->getLinkTargetByClass(ilDclTableEditGUI::class, 'disableVisible')
209  );
210  } else {
211  $actions[] = $this->ui_factory->button()->shy(
212  $this->lng->txt('enable_visible'),
213  $this->ctrl->getLinkTargetByClass(ilDclTableEditGUI::class, 'enableVisible')
214  );
215  }
216 
217  if ($table->getPublicCommentsEnabled()) {
218  $actions[] = $this->ui_factory->button()->shy(
219  $this->lng->txt('disable_comments'),
220  $this->ctrl->getLinkTargetByClass(ilDclTableEditGUI::class, 'disableComments')
221  );
222  } else {
223  $actions[] = $this->ui_factory->button()->shy(
224  $this->lng->txt('enable_comments'),
225  $this->ctrl->getLinkTargetByClass(ilDclTableEditGUI::class, 'enableComments')
226  );
227  }
228 
229  if ($table->getOrder() !== 10) {
230  $actions[] = $this->ui_factory->button()->shy(
231  $this->lng->txt('set_as_default'),
232  $this->ctrl->getLinkTargetByClass(ilDclTableEditGUI::class, 'setAsDefault')
233  );
234  }
235 
236  return $actions;
237  }
getId()
Get table id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDataCollectionObject()

ilDclTableListGUI::getDataCollectionObject ( )

Definition at line 355 of file class.ilDclTableListGUI.php.

Referenced by checkTablesLeft().

356  {
357  return $this->parent_obj->getDataCollectionObject();
358  }
+ Here is the caller graph for this function:

◆ getItems()

ilDclTableListGUI::getItems ( )
protected

Definition at line 146 of file class.ilDclTableListGUI.php.

References ILIAS\Repository\ctrl(), getActions(), and ILIAS\Repository\lng().

Referenced by listTables().

146  : array
147  {
148  $items = [];
149  foreach ($this->parent_obj->getDataCollectionObject()->getTables() as $table) {
150 
151  $this->ctrl->setParameterByClass(ilObjDataCollectionGUI::class, 'table_id', $table->getId());
152  $item = $this->ui_factory->item()->standard(
153  $this->ui_factory->link()->standard(
154  $table->getTitle(),
155  $this->ctrl->getLinkTargetByClass(ilDclFieldListGUI::class, 'listFields')
156  )
157  )
158  ->withProperties([
159  $this->lng->txt('visible') => $this->lng->txt($table->getIsVisible() ? 'yes' : 'no'),
160  $this->lng->txt('comments') => $this->lng->txt($table->getPublicCommentsEnabled() ? 'active' : 'inactive')
161  ])
162  ->withActions(
163  $this->ui_factory->dropdown()->standard(
164  $this->getActions($table)
165  )
166  );
167 
168  if ($table->getOrder() === 10) {
169  $item = $item->withDescription($this->lng->txt('default'));
170  }
171  $items[] = $item;
172  }
173  return $items;
174  }
getActions(ilDclTable $table)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjId()

ilDclTableListGUI::getObjId ( )

Definition at line 64 of file class.ilDclTableListGUI.php.

Referenced by ilDclFieldListGUI\__construct(), ilDclTableEditGUI\__construct(), and ilDclFieldEditGUI\__construct().

64  : int
65  {
66  return $this->parent_obj->getObjectId();
67  }
+ Here is the caller graph for this function:

◆ getRefId()

ilDclTableListGUI::getRefId ( )

Definition at line 69 of file class.ilDclTableListGUI.php.

69  : int
70  {
71  return $this->parent_obj->getRefId();
72  }

◆ listTables()

ilDclTableListGUI::listTables ( )

Definition at line 127 of file class.ilDclTableListGUI.php.

References ILIAS\Repository\ctrl(), getItems(), ILIAS\Repository\lng(), renderer(), and ILIAS\Repository\toolbar().

127  : void
128  {
129 
130  $add_new = $this->ui_factory->button()->primary(
131  $this->lng->txt("dcl_add_new_table"),
132  $this->ctrl->getLinkTargetByClass('ilDclTableEditGUI', 'create')
133  );
134  $this->toolbar->addStickyItem($add_new);
135 
136  $this->tpl->setContent(
137  $this->renderer->render(
138  $this->ui_factory->panel()->listing()->standard(
139  $this->lng->txt('dcl_tables'),
140  [$this->ui_factory->item()->group('', $this->getItems())]
141  )
142  )
143  );
144  }
renderer()
+ Here is the call graph for this function:

◆ save()

ilDclTableListGUI::save ( )
protected

Definition at line 260 of file class.ilDclTableListGUI.php.

References $comments, ILIAS\Repository\ctrl(), ilDclCache\getTableCache(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

260  : void
261  {
262  if ($this->http->wrapper()->post()->has("comments")) {
263  $comments = $this->http->wrapper()->post()->retrieve(
264  'comments',
265  $this->refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->string())
266  );
267  }
268  if ($this->http->wrapper()->post()->has("visible")) {
269  $visible = $this->http->wrapper()->post()->retrieve(
270  'visible',
271  $this->refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->string())
272  );
273  }
274  $orders = $this->http->wrapper()->post()->retrieve(
275  'order',
276  $this->refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->string())
277  );
278  asort($orders);
279  $order = 10;
280  foreach (array_keys($orders) as $table_id) {
281  $table = ilDclCache::getTableCache($table_id);
282  $table->setOrder($order);
283  $table->setPublicCommentsEnabled(isset($comments[$table_id]));
284  $table->setIsVisible(isset($visible[$table_id]));
285  $table->doUpdate();
286  $order += 10;
287  }
288  $this->ctrl->redirect($this);
289  }
static http()
Fetches the global http state from ILIAS.
$comments
static getTableCache(?int $table_id=null)
+ Here is the call graph for this function:

◆ setTabs()

ilDclTableListGUI::setTabs ( string  $active)
protected

Definition at line 239 of file class.ilDclTableListGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by executeCommand().

239  : void
240  {
241  $this->tabs->setBackTarget($this->lng->txt('dcl_tables'), $this->ctrl->getLinkTarget($this, 'listTables'));
242  $this->tabs->addTab(
243  'settings',
244  $this->lng->txt('settings'),
245  $this->ctrl->getLinkTargetByClass('ilDclTableEditGUI', 'edit')
246  );
247  $this->tabs->addTab(
248  'fields',
249  $this->lng->txt('dcl_list_fields'),
250  $this->ctrl->getLinkTargetByClass('ilDclFieldListGUI', 'listFields')
251  );
252  $this->tabs->addTab(
253  'tableviews',
254  $this->lng->txt('dcl_tableviews'),
255  $this->ctrl->getLinkTargetByClass('ilDclTableViewGUI')
256  );
257  $this->tabs->activateTab($active);
258  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilDclTableListGUI::$ctrl
protected

Definition at line 30 of file class.ilDclTableListGUI.php.

◆ $http

ILIAS HTTP Services ilDclTableListGUI::$http
protected

Definition at line 35 of file class.ilDclTableListGUI.php.

◆ $lng

ilLanguage ilDclTableListGUI::$lng
protected

Definition at line 31 of file class.ilDclTableListGUI.php.

◆ $parent_obj

ilObjDataCollectionGUI ilDclTableListGUI::$parent_obj
protected

Definition at line 37 of file class.ilDclTableListGUI.php.

◆ $refinery

ILIAS Refinery Factory ilDclTableListGUI::$refinery
protected

Definition at line 36 of file class.ilDclTableListGUI.php.

◆ $renderer

ILIAS UI Renderer ilDclTableListGUI::$renderer
protected

Definition at line 29 of file class.ilDclTableListGUI.php.

◆ $tabs

ilTabsGUI ilDclTableListGUI::$tabs
protected

Definition at line 33 of file class.ilDclTableListGUI.php.

◆ $toolbar

ilToolbarGUI ilDclTableListGUI::$toolbar
protected

Definition at line 34 of file class.ilDclTableListGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilDclTableListGUI::$tpl
protected

Definition at line 32 of file class.ilDclTableListGUI.php.

◆ $ui_factory

ILIAS UI Factory ilDclTableListGUI::$ui_factory
protected

Definition at line 28 of file class.ilDclTableListGUI.php.


The documentation for this class was generated from the following file: