ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
BaseCommands.php
Go to the documentation of this file.
1<?php
2
4
10abstract class BaseCommands
11{
12 use DIC;
13 const CMD_INDEX = "index";
14 const CMD_ADD = "add";
15 const CMD_CREATE = "create";
16 const CMD_EDIT = "edit";
17 const CMD_UPDATE = "update";
18 const CMD_CONFIRM = "confirm";
19 const CMD_CONFIRM_RECURSIVE = "confirmRecursive";
20 const CMD_DELETE = "delete";
21 const CMD_DELETE_RECURSIVE = "deleteRecursive";
22 const CMD_CANCEL = "cancel";
23 const AR_ID = "arid";
27 protected $parent_gui = null;
28
29
33 public function getParentGui()
34 {
35 return $this->parent_gui;
36 }
37
38
42 public function setParentGui($parent_gui)
43 {
44 $this->parent_gui = $parent_gui;
45 }
46
47
48 abstract protected function index();
49
50
54 protected function getPossibleNextClasses()
55 {
56 return array();
57 }
58
59
63 protected function getActiveTabId()
64 {
65 return null;
66 }
67
68
69 protected function cancel()
70 {
71 $this->ctrl()->redirect($this, self::CMD_INDEX);
72 }
73
74
75 /***
76 * @param $html
77 */
78 protected function setContent($html)
79 {
80 $this->tpl()->setContent($html);
81 }
82
83
84 public function executeCommand()
85 {
86 $this->dic()->language()->loadLanguageModule("orgu");
87 $cmd = $this->dic()->ctrl()->getCmd(self::CMD_INDEX);
88 $next_class = $this->dic()->ctrl()->getNextClass();
89 if ($next_class) {
90 foreach ($this->getPossibleNextClasses() as $class) {
91 if (strtolower($class) === $next_class) {
92 $instance = new $class();
93 if ($instance instanceof BaseCommands) {
94 $instance->setParentGui($this);
95 $this->ctrl()->forwardCommand($instance);
96 }
97
98 return;
99 }
100 }
101 }
102
103 if ($this->getActiveTabId()) {
104 $this->dic()->tabs()->activateTab($this->getActiveTabId());
105 }
106
107 switch ($cmd) {
108 default:
109 if ($this->checkRequestReferenceId()) {
110 $this->{$cmd}();
111 }
112 break;
113 }
114 }
115
116
121 protected function pushSubTab($subtab_id, $url)
122 {
123 $this->dic()->tabs()->addSubTab($subtab_id, $this->txt($subtab_id), $url);
124 }
125
126
130 protected function activeSubTab($subtab_id)
131 {
132 $this->dic()->tabs()->activateSubTab($subtab_id);
133 }
134
135
136 protected function checkRequestReferenceId()
137 {
141 $ref_id = $this->getParentRefId();
142 if ($ref_id) {
143 return $this->dic()->access()->checkAccess("read", "", $ref_id);
144 }
145
146 return true;
147 }
148
149
153 protected function getParentRefId()
154 {
155 $http = $this->dic()->http();
156 $ref_id = $http->request()->getQueryParams()["ref_id"];
157
158 return $ref_id;
159 }
160
161
162 public function addSubTabs()
163 {
164 }
165}
An exception for terminatinating execution or to throw for unit testing.
$url
$http
Definition: raiseError.php:7