ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjExternalToolsSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once "./Services/Object/classes/class.ilObjectGUI.php";
6
7
19{
23 protected $rbacsystem;
24
28 protected $access;
29
33 protected $rbacreview;
34
39 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
40 {
41 global $DIC;
42
43 $this->lng = $DIC->language();
44 $this->rbacsystem = $DIC->rbac()->system();
45 $this->access = $DIC->access();
46 $this->rbacreview = $DIC->rbac()->review();
47 $this->ctrl = $DIC->ctrl();
48 $this->tpl = $DIC["tpl"];
49 $lng = $DIC->language();
50
51 $this->type = "extt";
52 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
53
54 $lng->loadLanguageModule("delic");
55 $lng->loadLanguageModule("maps");
56 $lng->loadLanguageModule("mathjax");
57 }
58
59 public function getAdminTabs()
60 {
61 $this->getTabs();
62 }
63
69 public function getTabs()
70 {
72
73 $this->ctrl->setParameter($this, "ref_id", $this->object->getRefId());
74
75 if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
76 $this->tabs_gui->addTarget(
77 "settings",
78 $this->ctrl->getLinkTarget($this, "view"),
79 array("editMaps", "editMathJax", ""),
80 "",
81 ""
82 );
83 $this->lng->loadLanguageModule('ecs');
84 }
85
86 if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
87 $this->tabs_gui->addTarget(
88 "perm_settings",
89 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
90 array("perm","info","owner"),
91 'ilpermissiongui'
92 );
93 }
94 }
95
99 public function editMathJaxObject()
100 {
101 $ilAccess = $this->access;
104 $ilCtrl = $this->ctrl;
106
107 $mathJaxSetting = new ilSetting("MathJax");
108 $path_to_mathjax = $mathJaxSetting->get("path_to_mathjax");
109
110 $this->__initSubTabs("editMathJax");
111
112 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
113 $form = new ilPropertyFormGUI();
114 $form->setFormAction($ilCtrl->getFormAction($this));
115 $form->setTitle($lng->txt("mathjax_settings"));
116
117 // Enable MathJax
118 $enable = new ilCheckboxInputGUI($lng->txt("mathjax_enable_client"), "enable");
119 $enable->setChecked($mathJaxSetting->get("enable"));
120 $enable->setInfo($lng->txt("mathjax_enable_mathjax_info") . " <a target='blank' href='http://www.mathjax.org/'>"
121 . $lng->txt("mathjax_home_link") . "</a>");
122 $form->addItem($enable);
123
124 // Path to mathjax
125 $text_prop = new ilTextInputGUI($lng->txt("mathjax_path_to_mathjax"), "path_to_mathjax");
126 $text_prop->setInfo($lng->txt("mathjax_path_to_mathjax_desc"));
127 $text_prop->setValue($path_to_mathjax);
128 $text_prop->setRequired(true);
129 $text_prop->setMaxLength(400);
130 $text_prop->setSize(100);
131 $enable->addSubItem($text_prop);
132
133 // mathjax limiter
134 $options = array(
135 0 => '\&#8203;(...\&#8203;)',
136 1 => '[tex]...[/tex]',
137 2 => '&lt;span class="math"&gt;...&lt;/span&gt;'
138 );
139 $si = new ilSelectInputGUI($this->lng->txt("mathjax_limiter"), "limiter");
140 $si->setOptions($options);
141 $si->setValue($mathJaxSetting->get("limiter"));
142 $si->setInfo($this->lng->txt("mathjax_limiter_info"));
143 $enable->addSubItem($si);
144
145 include_once './Services/MathJax/classes/class.ilMathJax.php';
146 $install_link = ' <a target="_blank" href="Services/MathJax/docs/Install-MathJax-Server.txt">'
147 . $lng->txt("mathjax_server_installation") . '</a>';
148 $clear_cache_link = ' <a href="' . $this->ctrl->getLinkTarget($this, 'clearMathJaxCache') . '"">'
149 . $lng->txt("mathjax_server_clear_cache") . '</a>';
150
151 // Enable Server MathJax
152 $server = new ilCheckboxInputGUI($lng->txt("mathjax_enable_server"), "enable_server");
153 $server->setChecked($mathJaxSetting->get("enable_server"));
154 $server->setInfo($lng->txt("mathjax_enable_server_info") . $install_link);
155
156 $form->addItem($server);
157
158 // Path to Server MathJax
159 $text_prop = new ilTextInputGUI($lng->txt("mathjax_server_address"), "server_address");
160 $text_prop->setInfo($lng->txt("mathjax_server_address_info"));
161 $text_prop->setValue($mathJaxSetting->get("server_address"));
162 $text_prop->setRequired(true);
163 $text_prop->setMaxLength(400);
164 $text_prop->setSize(100);
165 $server->addSubItem($text_prop);
166
167 // Server Timeout
168 $number_prop = new ilNumberInputGUI($lng->txt("mathjax_server_timeout"), "server_timeout");
169 $number_prop->setInfo($lng->txt("mathjax_server_timeout_info"));
170 $number_prop->setValue($mathJaxSetting->get("server_timeout") ? (int) $mathJaxSetting->get("server_timeout") : 5);
171 $number_prop->setRequired(true);
172 $number_prop->setSize(3);
173 $server->addSubItem($number_prop);
174
175 // Server for Browser
176 $checkbox = new ilCheckboxInputGUI($lng->txt("mathjax_server_for_browser"), "server_for_browser");
177 $checkbox->setInfo($lng->txt("mathjax_server_for_browser_info"));
178 $checkbox->setChecked((bool) $mathJaxSetting->get("server_for_browser"));
179 $server->addSubItem($checkbox);
180
181 // Server for HTML Export
182 $checkbox = new ilCheckboxInputGUI($lng->txt("mathjax_server_for_export"), "server_for_export");
183 $checkbox->setInfo($lng->txt("mathjax_server_for_export_info"));
184 $checkbox->setChecked((bool) $mathJaxSetting->get("server_for_export"));
185 $server->addSubItem($checkbox);
186
187 // Server for PDF
188 $checkbox = new ilCheckboxInputGUI($lng->txt("mathjax_server_for_pdf"), "server_for_pdf");
189 $checkbox->setInfo($lng->txt("mathjax_server_for_pdf_info"));
190 $checkbox->setChecked((bool) $mathJaxSetting->get("server_for_pdf"));
191 $server->addSubItem($checkbox);
192
193 // Cache Size / Clear Cache
194 $size = new ilNonEditableValueGUI($lng->txt("mathjax_server_cache_size"));
195 $size->setInfo($lng->txt("mathjax_server_cache_size_info") . $clear_cache_link);
196 $size->setValue(ilMathJax::getInstance()->getCacheSize());
197 $server->addSubItem($size);
198
199 // Test expression
200 $test = new ilCustomInputGUI($lng->txt("mathjax_test_expression"));
201 include_once './Services/MathJax/classes/class.ilMathJax.php';
202 $html = ilMathJax::getInstance()->insertLatexImages('[tex]f(x)=\int_{-\infty}^x e^{-t^2}dt[/tex]');
203 $test->setHtml($html);
204 $test->setInfo($lng->txt('mathjax_test_expression_info'));
205 $form->addItem($test);
206
207 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
208 $form->addCommandButton("saveMathJax", $lng->txt("save"));
209 }
210
211 $tpl->setVariable("ADM_CONTENT", $form->getHTML());
212 }
213
217 public function saveMathJaxObject()
218 {
219 $ilCtrl = $this->ctrl;
221 $ilAccess = $this->access;
222
223 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
224 $mathJaxSetting = new ilSetting("MathJax");
225 // Client settings
226 $path_to_mathjax = ilUtil::stripSlashes($_POST["path_to_mathjax"]);
227 if ($_POST["enable"]) {
228 $mathJaxSetting->set("path_to_mathjax", $path_to_mathjax);
229 $mathJaxSetting->set("limiter", (int) $_POST["limiter"]);
230 }
231 $mathJaxSetting->set("enable", ilUtil::stripSlashes($_POST["enable"]));
232
233 // Server settings
234 if ($_POST["enable_server"]) {
235 $mathJaxSetting->set("server_address", ilUtil::stripSlashes($_POST["server_address"]));
236 $mathJaxSetting->set("server_timeout", (int) ilUtil::stripSlashes($_POST["server_timeout"]));
237 $mathJaxSetting->set("server_for_browser", (bool) ilUtil::stripSlashes($_POST["server_for_browser"]));
238 $mathJaxSetting->set("server_for_export", (bool) ilUtil::stripSlashes($_POST["server_for_export"]));
239 $mathJaxSetting->set("server_for_pdf", (bool) ilUtil::stripSlashes($_POST["server_for_pdf"]));
240 }
241 $mathJaxSetting->set("enable_server", (bool) ilUtil::stripSlashes($_POST["enable_server"]));
242
243 ilUtil::sendInfo($lng->txt("msg_obj_modified"));
244 }
245 $ilCtrl->redirect($this, "editMathJax");
246 }
247
251 public function clearMathJaxCacheObject()
252 {
254
255 include_once './Services/MathJax/classes/class.ilMathJax.php';
256 ilMathJax::getInstance()->clearCache();
257
258 ilUtil::sendSuccess($lng->txt('mathjax_server_cache_cleared'), true);
259 $this->ctrl->redirect($this, 'editMathJax');
260 }
261
267 public function editMapsObject()
268 {
269 require_once("Services/Maps/classes/class.ilMapUtil.php");
270
271 $ilAccess = $this->access;
273 $ilCtrl = $this->ctrl;
275
276 $this->__initSubTabs("editMaps");
277 $std_latitude = ilMapUtil::getStdLatitude();
278 $std_longitude = ilMapUtil::getStdLongitude();
279 $std_zoom = ilMapUtil::getStdZoom();
281
282 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
283 include_once("./Services/Form/classes/class.ilCheckboxOption.php");
284 $form = new ilPropertyFormGUI();
285 $form->setFormAction($ilCtrl->getFormAction($this));
286 $form->setTitle($lng->txt("maps_settings"));
287
288 // Enable Maps
289 $enable = new ilCheckboxInputGUI($lng->txt("maps_enable_maps"), "enable");
290 $enable->setChecked(ilMapUtil::isActivated());
291 $enable->setInfo($lng->txt("maps_enable_maps_info"));
292 $form->addItem($enable);
293
294 // Select type
295 $types = new ilSelectInputGUI($lng->txt("maps_map_type"), "type");
296 $types->setOptions(ilMapUtil::getAvailableMapTypes());
297 $types->setValue($type);
298 $form->addItem($types);
299
300 // map data server property
301 if ($type == "openlayers") {
302 $tile = new ilTextInputGUI($lng->txt("maps_tile_server"), "tile");
303 $tile->setValue(ilMapUtil::getStdTileServers());
304 $tile->setInfo(sprintf($lng->txt("maps_custom_tile_server_info"), ilMapUtil::DEFAULT_TILE));
305 $geolocation = new ilTextInputGUI($lng->txt("maps_geolocation_server"), "geolocation");
306 $geolocation->setValue(ilMapUtil::getStdGeolocationServer());
307 $geolocation->setInfo($lng->txt("maps_custom_geolocation_server_info"));
308
309 $form->addItem($tile);
310 $form->addItem($geolocation);
311 } else {
312 // api key for google
313 $key = new ilTextInputGUI("Google API Key", "api_key");
314 $key->setMaxLength(200);
315 $key->setValue(ilMapUtil::getApiKey());
316 $form->addItem($key);
317 }
318
319 // location property
320 $loc_prop = new ilLocationInputGUI(
321 $lng->txt("maps_std_location"),
322 "std_location"
323 );
324
325 $loc_prop->setLatitude($std_latitude);
326 $loc_prop->setLongitude($std_longitude);
327 $loc_prop->setZoom($std_zoom);
328 $form->addItem($loc_prop);
329
330 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
331 $form->addCommandButton("saveMaps", $lng->txt("save"));
332 $form->addCommandButton("view", $lng->txt("cancel"));
333 }
334
335 $tpl->setVariable("ADM_CONTENT", $form->getHTML());
336 }
337
338
342 public function saveMapsObject()
343 {
344 require_once("Services/Maps/classes/class.ilMapUtil.php");
345
346 $ilCtrl = $this->ctrl;
347 if (ilUtil::stripSlashes($_POST["type"]) == 'openlayers' && 'openlayers' == ilMapUtil::getType()) {
350 } else {
352 }
353
356 ilMapUtil::setStdLatitude(ilUtil::stripSlashes($_POST["std_location"]["latitude"]));
357 ilMapUtil::setStdLongitude(ilUtil::stripSlashes($_POST["std_location"]["longitude"]));
358 ilMapUtil::setStdZoom(ilUtil::stripSlashes($_POST["std_location"]["zoom"]));
359 $ilCtrl->redirect($this, "editMaps");
360 }
361
362 // init sub tabs
363 public function __initSubTabs($a_cmd)
364 {
365 $maps = ($a_cmd == 'editMaps') ? true : false;
366 $mathjax = ($a_cmd == 'editMathJax') ? true : false;
367
368 $this->tabs_gui->addSubTabTarget(
369 "maps_extt_maps",
370 $this->ctrl->getLinkTarget($this, "editMaps"),
371 "",
372 "",
373 "",
374 $maps
375 );
376 $this->tabs_gui->addSubTabTarget(
377 "mathjax_mathjax",
378 $this->ctrl->getLinkTarget($this, "editMathJax"),
379 "",
380 "",
381 "",
382 $mathjax
383 );
384 }
385
386 public function executeCommand()
387 {
388 $ilAccess = $this->access;
389
390 $next_class = $this->ctrl->getNextClass($this);
391 $cmd = $this->ctrl->getCmd();
392 $this->prepareOutput();
393
394 if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
395 $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
396 }
397
398 switch ($next_class) {
399 case 'ilecssettingsgui':
400 $this->tabs_gui->setTabActive('ecs_server_settings');
401 include_once('./Services/WebServices/ECS/classes/class.ilECSSettingsGUI.php');
402 $this->ctrl->forwardCommand(new ilECSSettingsGUI());
403 break;
404
405 case 'ilpermissiongui':
406 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
407 $perm_gui = new ilPermissionGUI($this);
408 $ret = &$this->ctrl->forwardCommand($perm_gui);
409 $this->tabs_gui->setTabActive('perm_settings');
410 break;
411
412 default:
413 $this->tabs_gui->setTabActive('settings');
414 if (!$cmd || $cmd == 'view') {
415 $cmd = "editMaps";
416 }
417 $cmd .= "Object";
418 $this->$cmd();
419
420 break;
421 }
422 return true;
423 }
424} // END class.ilObjExternalToolsSettingsGUI
$size
Definition: RandomTest.php:84
$test
Definition: Utf8Test.php:84
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
This class represents a custom property in a property form.
This class represents a location property in a property form.
static getApiKey()
static getStdGeolocationServer()
Returns the reverse geolocation server to be used in the installation.
static getStdLatitude()
static getStdTileServers()
Returns the tile server to be used in the installation.
static getStdLongitude()
static setApiKey($a_api_key)
static setActivated($a_activated)
static getStdZoom()
static setStdLatitude($a_lat)
const DEFAULT_TILE
static isActivated()
Checks whether Map feature is activated.
static setStdZoom($a_zoom)
static setStdGeolocationServer($a_geolocation)
static setStdLongitude($a_lon)
static getAvailableMapTypes()
Get a dict { $id => $name } for available maps services.
static setStdTileServers($a_tile)
static setType($a_type)
static getType()
static getInstance()
Singleton: get instance.
This class represents a non editable value in a property form.
This class represents a number property in a property form.
Class ilObjExternalToolsSettingsGUI.
clearMathJaxCacheObject()
Clear the directory with cached LaTeX graphics.
getAdminTabs()
administration tabs show only permissions and trash folder
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor @access public.
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a selection list property in a property form.
ILIAS Setting Class.
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$server
global $DIC
Definition: goto.php:24
if(strpos( $jquery_path, './')===0) elseif(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:54
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
redirection script todo: (a better solution should control the processing via a xml file)
$ret
Definition: parser.php:6
$type