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