ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
BaseCommands.php
Go to the documentation of this file.
1 <?php
2 
4 
10 abstract 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_DELETE = "delete";
20  const CMD_CANCEL = "cancel";
21  const AR_ID = "arid";
25  protected $parent_gui = null;
26 
27 
31  public function getParentGui()
32  {
33  return $this->parent_gui;
34  }
35 
36 
40  public function setParentGui($parent_gui)
41  {
42  $this->parent_gui = $parent_gui;
43  }
44 
45 
46  abstract protected function index();
47 
48 
52  protected function getPossibleNextClasses()
53  {
54  return array();
55  }
56 
57 
61  protected function getActiveTabId()
62  {
63  return null;
64  }
65 
66 
67  protected function cancel()
68  {
69  $this->ctrl()->redirect($this, self::CMD_INDEX);
70  }
71 
72 
73  /***
74  * @param $html
75  */
76  protected function setContent($html)
77  {
78  $this->tpl()->setContent($html);
79  }
80 
81 
82  public function executeCommand()
83  {
84  $this->dic()->language()->loadLanguageModule("orgu");
85  $cmd = $this->dic()->ctrl()->getCmd(self::CMD_INDEX);
86  $next_class = $this->dic()->ctrl()->getNextClass();
87  if ($next_class) {
88  foreach ($this->getPossibleNextClasses() as $class) {
89  if (strtolower($class) === $next_class) {
90  $instance = new $class();
91  if ($instance instanceof BaseCommands) {
92  $instance->setParentGui($this);
93  $this->ctrl()->forwardCommand($instance);
94  }
95 
96  return;
97  }
98  }
99  }
100 
101  if ($this->getActiveTabId()) {
102  $this->dic()->tabs()->activateTab($this->getActiveTabId());
103  }
104 
105  switch ($cmd) {
106  default:
107  if ($this->checkRequestReferenceId()) {
108  $this->{$cmd}();
109  }
110  break;
111  }
112  }
113 
114 
119  protected function pushSubTab($subtab_id, $url)
120  {
121  $this->dic()->tabs()->addSubTab($subtab_id, $this->txt($subtab_id), $url);
122  }
123 
124 
128  protected function activeSubTab($subtab_id)
129  {
130  $this->dic()->tabs()->activateSubTab($subtab_id);
131  }
132 
133 
134  protected function checkRequestReferenceId()
135  {
139  $ref_id = $this->getParentRefId();
140  if ($ref_id) {
141  return $this->dic()->access()->checkAccess("read", "", $ref_id);
142  }
143 
144  return true;
145  }
146 
147 
151  protected function getParentRefId()
152  {
153  $http = $this->dic()->http();
154  $ref_id = $http->request()->getQueryParams()["ref_id"];
155 
156  return $ref_id;
157  }
158 
159 
160  public function addSubTabs()
161  {
162  }
163 }
$http
Definition: raiseError.php:7
Create styles array
The data for the language used.
$url
$html
Definition: example_001.php:87