ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjExternalToolsSettingsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(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 {
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 {
94
95 $this->initSubTabs("editMaps");
96 $form = $this->getMapsForm();
97 $tpl->setContent($form->getHTML());
98 }
99
101 {
102 $ilAccess = $this->access;
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");
121 $types->setOptions(ilMapUtil::getAvailableMapTypes());
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 "wopi_settings",
208 $this->ctrl->getLinkTargetByClass(ilWOPIAdministrationGUI::class),
209 "",
210 "",
211 "",
212 $wopi
213 );
214 }
215
216 public function executeCommand(): void
217 {
218 $next_class = $this->ctrl->getNextClass($this);
219 $cmd = $this->ctrl->getCmd();
220 $this->prepareOutput();
221
222 if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
223 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
224 }
225
226 switch ($next_class) {
227 case 'ilecssettingsgui':
228 $this->tabs_gui->setTabActive('ecs_server_settings');
229 $this->ctrl->forwardCommand(new ilECSSettingsGUI());
230 break;
231
232 case strtolower(ilWOPIAdministrationGUI::class):
233 $this->initSubTabs(self::EDIT_WOPI);
234 $this->ctrl->forwardCommand(new ilWOPIAdministrationGUI());
235 break;
236
237 case 'ilpermissiongui':
238 $perm_gui = new ilPermissionGUI($this);
239 $this->ctrl->forwardCommand($perm_gui);
240 $this->tabs_gui->setTabActive('perm_settings');
241 break;
242
243 default:
244 $this->tabs_gui->setTabActive('settings');
245 if (!$cmd || $cmd === 'view') {
246 $cmd = "editMaps";
247 }
248 $cmd .= "Object";
249 $this->$cmd();
250
251 break;
252 }
253 }
254}
$location
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()
Class ilObjExternalToolsSettingsGUI.
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
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.
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ilObjForumAdministration.
global $DIC
Definition: shib_login.php:26