ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilObjExternalToolsSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 {
29  public const EDIT_WOPI = "editWopi";
32 
33  public function __construct(
34  $a_data,
35  int $a_id,
36  bool $a_call_by_reference,
37  bool $a_prepare_output = true
38  ) {
39  global $DIC;
40 
41  $this->lng = $DIC->language();
42  $this->rbacsystem = $DIC->rbac()->system();
43  $this->access = $DIC->access();
44  $this->rbacreview = $DIC->rbac()->review();
45  $this->ctrl = $DIC->ctrl();
46  $this->tpl = $DIC["tpl"];
47  $lng = $DIC->language();
48 
49  $this->type = "extt";
50  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
51 
52  $lng->loadLanguageModule("delic");
53  $lng->loadLanguageModule("maps");
54  $lng->loadLanguageModule("mathjax");
55  $lng->loadLanguageModule("wopi");
56  }
57 
58  public function getAdminTabs(): void
59  {
60  $this->getTabs();
61  }
62 
63  protected function getTabs(): void
64  {
65  $rbacsystem = $this->rbacsystem;
66 
67  $this->ctrl->setParameter($this, "ref_id", $this->object->getRefId());
68 
69  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
70  $this->tabs_gui->addTarget(
71  "settings",
72  $this->ctrl->getLinkTarget($this, "view"),
73  array("editMaps", "editMathJax", ""),
74  "",
75  ""
76  );
77  $this->lng->loadLanguageModule('ecs');
78  }
79 
80  if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
81  $this->tabs_gui->addTarget(
82  "perm_settings",
83  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
84  array("perm","info","owner"),
85  'ilpermissiongui'
86  );
87  }
88  }
89 
90 
91  public function editMapsObject(): void
92  {
93  $tpl = $this->tpl;
94 
95  $this->initSubTabs("editMaps");
96  $form = $this->getMapsForm();
97  $tpl->setContent($form->getHTML());
98  }
99 
100  public function getMapsForm(): ilPropertyFormGUI
101  {
102  $ilAccess = $this->access;
103  $lng = $this->lng;
104  $ilCtrl = $this->ctrl;
105  $std_latitude = (float) ilMapUtil::getStdLatitude();
106  $std_longitude = (float) ilMapUtil::getStdLongitude();
107  $std_zoom = ilMapUtil::getStdZoom();
109  $form = new ilPropertyFormGUI();
110  $form->setFormAction($ilCtrl->getFormAction($this));
111  $form->setTitle($lng->txt("maps_settings"));
112 
113  // Enable Maps
114  $enable = new ilCheckboxInputGUI($lng->txt("maps_enable_maps"), "enable");
115  $enable->setChecked(ilMapUtil::isActivated());
116  $enable->setInfo($lng->txt("maps_enable_maps_info"));
117  $form->addItem($enable);
118 
119  // Select type
120  $types = new ilSelectInputGUI($lng->txt("maps_map_type"), "type");
122  $types->setValue($type);
123  $form->addItem($types);
124 
125  // map data server property
126  if ($type === "openlayers") {
127  $tile = new ilTextInputGUI($lng->txt("maps_tile_server"), "tile");
128  $tile->setValue(ilMapUtil::getStdTileServers());
129  $tile->setInfo(sprintf($lng->txt("maps_custom_tile_server_info"), ilMapUtil::DEFAULT_TILE));
130  $geolocation = new ilTextInputGUI($lng->txt("maps_geolocation_server"), "geolocation");
131  $geolocation->setValue(ilMapUtil::getStdGeolocationServer());
132  $geolocation->setInfo($lng->txt("maps_custom_geolocation_server_info"));
133 
134  $form->addItem($tile);
135  $form->addItem($geolocation);
136  } else {
137  // api key for google
138  $key = new ilTextInputGUI("Google API Key", "api_key");
139  $key->setMaxLength(200);
140  $key->setValue(ilMapUtil::getApiKey());
141  $form->addItem($key);
142  }
143 
144  // location property
145  $loc_prop = new ilLocationInputGUI(
146  $lng->txt("maps_std_location"),
147  "std_location"
148  );
149 
150  $loc_prop->setLatitude($std_latitude);
151  $loc_prop->setLongitude($std_longitude);
152  $loc_prop->setZoom((int) $std_zoom);
153  $form->addItem($loc_prop);
154 
155  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
156  $form->addCommandButton("saveMaps", $lng->txt("save"));
157  $form->addCommandButton("view", $lng->txt("cancel"));
158  }
159 
160  return $form;
161  }
162 
166  public function saveMapsObject(): void
167  {
168  $ilCtrl = $this->ctrl;
169 
170  $form = $this->getMapsForm();
171  if ($form->checkInput()) {
172  if ($form->getInput("type") === 'openlayers' && 'openlayers' === ilMapUtil::getType()) {
173  ilMapUtil::setStdTileServers($form->getInput("tile"));
175  $form->getInput("geolocation")
176  );
177  } else {
178  ilMapUtil::setApiKey($form->getInput("api_key"));
179  }
180 
181  ilMapUtil::setActivated($form->getInput("enable") === "1");
182  ilMapUtil::setType($form->getInput("type"));
183  $location = $form->getInput("std_location");
184  ilMapUtil::setStdLatitude((string) $location["latitude"]);
185  ilMapUtil::setStdLongitude((string) $location["longitude"]);
186  ilMapUtil::setStdZoom((string) $location["zoom"]);
187  }
188  $ilCtrl->redirect($this, "editMaps");
189  }
190 
191  // init sub tabs
192  public function initSubTabs(string $a_cmd): void
193  {
194  $maps = $a_cmd === 'editMaps';
195  $mathjax = $a_cmd === 'editMathJax';
196  $wopi = $a_cmd === self::EDIT_WOPI;
197 
198  $this->tabs_gui->addSubTabTarget(
199  "maps_extt_maps",
200  $this->ctrl->getLinkTarget($this, "editMaps"),
201  "",
202  "",
203  "",
204  $maps
205  );
206  $this->tabs_gui->addSubTabTarget(
207  "mathjax_mathjax",
208  $this->ctrl->getLinkTargetByClass('ilMathJaxSettingsGUI'),
209  "",
210  "",
211  "",
212  $mathjax
213  );
214  $this->tabs_gui->addSubTabTarget(
215  "wopi_settings",
216  $this->ctrl->getLinkTargetByClass(ilWOPIAdministrationGUI::class),
217  "",
218  "",
219  "",
220  $wopi
221  );
222  }
223 
224  public function executeCommand(): void
225  {
226  $next_class = $this->ctrl->getNextClass($this);
227  $cmd = $this->ctrl->getCmd();
228  $this->prepareOutput();
229 
230  if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
231  $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
232  }
233 
234  switch ($next_class) {
235  case 'ilmathjaxsettingsgui':
236  $this->tabs_gui->setTabActive('settings');
237  $this->initSubTabs("editMathJax");
238  $this->ctrl->forwardCommand(new ilMathJaxSettingsGUI(
239  $this->rbacsystem->checkAccess('write', $this->object->getRefId())
240  ));
241  break;
242 
243  case 'ilecssettingsgui':
244  $this->tabs_gui->setTabActive('ecs_server_settings');
245  $this->ctrl->forwardCommand(new ilECSSettingsGUI());
246  break;
247 
248  case strtolower(ilWOPIAdministrationGUI::class):
249  $this->initSubTabs(self::EDIT_WOPI);
250  $this->ctrl->forwardCommand(new ilWOPIAdministrationGUI());
251  break;
252 
253  case 'ilpermissiongui':
254  $perm_gui = new ilPermissionGUI($this);
255  $this->ctrl->forwardCommand($perm_gui);
256  $this->tabs_gui->setTabActive('perm_settings');
257  break;
258 
259  default:
260  $this->tabs_gui->setTabActive('settings');
261  if (!$cmd || $cmd === 'view') {
262  $cmd = "editMaps";
263  }
264  $cmd .= "Object";
265  $this->$cmd();
266 
267  break;
268  }
269  }
270 }
static getType()
__construct( $a_data, int $a_id, bool $a_call_by_reference, bool $a_prepare_output=true)
const DEFAULT_TILE
This class represents a selection list property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static setType(string $type)
static setActivated(bool $activated)
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
prepareOutput(bool $show_sub_objects=true)
loadLanguageModule(string $a_module)
Load language module.
setOptions(array $a_options)
static getStdLongitude()
static getStdZoom()
static getApiKey()
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
ilLanguage $lng
static getStdLatitude()
static setStdTileServers(string $tile)
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.
GUI for MathJax Settings This GUI maintains the MathJax config stored in the ILIAS settings Since ILI...
Class ilObjectGUI Basic methods of all Output classes.
static setApiKey(string $api_key)
This class represents a location property in a property form.
global $DIC
Definition: shib_login.php:25
Class ilObjExternalToolsSettingsGUI.
static setStdLongitude(string $lon)
Class ilObjForumAdministration.
static getAvailableMapTypes()
Get a dict { $id => $name } for available maps services.
static isActivated()
Checks whether Map feature is activated.
static getStdGeolocationServer()
Returns the reverse geolocation server to be used in the installation.
setLatitude(?float $a_latitude)
__construct(Container $dic, ilPlugin $plugin)
ilAccessHandler $access
static setStdLatitude(string $lat)
static getStdTileServers()
Returns the tile server to be used in the installation.
static setStdGeolocationServer($geolocation)
static setStdZoom(string $zoom)