ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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{
24 function __construct($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
25 {
26 global $lng;
27
28 $this->type = "extt";
29 parent::__construct($a_data,$a_id,$a_call_by_reference,false);
30
31 $lng->loadLanguageModule("delic");
32 $lng->loadLanguageModule("maps");
33 $lng->loadLanguageModule("mathjax");
34 }
35
36 function getAdminTabs()
37 {
38 $this->getTabs();
39 }
40
46 function getTabs()
47 {
48 global $rbacsystem;
49
50 $this->ctrl->setParameter($this,"ref_id",$this->object->getRefId());
51
52 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
53 {
54 $this->tabs_gui->addTarget("settings",
55 $this->ctrl->getLinkTarget($this, "view"),
56 array("editMaps", "editMathJax", ""), "", "");
57 $this->lng->loadLanguageModule('ecs');
58 }
59
60 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
61 {
62 $this->tabs_gui->addTarget("perm_settings",
63 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
64 }
65 }
66
71 {
72 global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl;
73
74 $mathJaxSetting = new ilSetting("MathJax");
75 $path_to_mathjax = $mathJaxSetting->get("path_to_mathjax");
76
77 $this->__initSubTabs("editMathJax");
78
79 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
80 $form = new ilPropertyFormGUI();
81 $form->setFormAction($ilCtrl->getFormAction($this));
82 $form->setTitle($lng->txt("mathjax_settings"));
83
84 // Enable MathJax
85 $enable = new ilCheckboxInputGUI($lng->txt("mathjax_enable_client"), "enable");
86 $enable->setChecked($mathJaxSetting->get("enable"));
87 $enable->setInfo($lng->txt("mathjax_enable_mathjax_info")." <a target='blank' href='http://www.mathjax.org/'>"
88 .$lng->txt("mathjax_home_link")."</a>");
89 $form->addItem($enable);
90
91 // Path to mathjax
92 $text_prop = new ilTextInputGUI($lng->txt("mathjax_path_to_mathjax"), "path_to_mathjax");
93 $text_prop->setInfo($lng->txt("mathjax_path_to_mathjax_desc"));
94 $text_prop->setValue($path_to_mathjax);
95 $text_prop->setRequired(true);
96 $text_prop->setMaxLength(400);
97 $text_prop->setSize(100);
98 $enable->addSubItem($text_prop);
99
100 // mathjax limiter
101 $options = array(
102 0 => '\&#8203;(...\&#8203;)',
103 1 => '[tex]...[/tex]',
104 2 => '&lt;span class="math"&gt;...&lt;/span&gt;'
105 );
106 $si = new ilSelectInputGUI($this->lng->txt("mathjax_limiter"), "limiter");
107 $si->setOptions($options);
108 $si->setValue($mathJaxSetting->get("limiter"));
109 $si->setInfo($this->lng->txt("mathjax_limiter_info"));
110 $enable->addSubItem($si);
111
112 include_once './Services/MathJax/classes/class.ilMathJax.php';
113 $install_link = ' <a target="_blank" href="Services/MathJax/docs/Install-MathJax-Server.txt">'
114 .$lng->txt("mathjax_server_installation").'</a>';
115 $clear_cache_link = ' <a href="'.$this->ctrl->getLinkTarget($this,'clearMathJaxCache').'"">'
116 .$lng->txt("mathjax_server_clear_cache").'</a>';
117
118 // Enable Server MathJax
119 $server = new ilCheckboxInputGUI($lng->txt("mathjax_enable_server"), "enable_server");
120 $server->setChecked($mathJaxSetting->get("enable_server"));
121 $server->setInfo($lng->txt("mathjax_enable_server_info").$install_link);
122
123 $form->addItem($server);
124
125 // Path to Server MathJax
126 $text_prop = new ilTextInputGUI($lng->txt("mathjax_server_address"), "server_address");
127 $text_prop->setInfo($lng->txt("mathjax_server_address_info"));
128 $text_prop->setValue($mathJaxSetting->get("server_address"));
129 $text_prop->setRequired(true);
130 $text_prop->setMaxLength(400);
131 $text_prop->setSize(100);
132 $server->addSubItem($text_prop);
133
134 // Server Timeout
135 $number_prop = new ilNumberInputGUI($lng->txt("mathjax_server_timeout"), "server_timeout");
136 $number_prop->setInfo($lng->txt("mathjax_server_timeout_info"));
137 $number_prop->setValue($mathJaxSetting->get("server_timeout") ? (int) $mathJaxSetting->get("server_timeout") : 5);
138 $number_prop->setRequired(true);
139 $number_prop->setSize(3);
140 $server->addSubItem($number_prop);
141
142 // Server for Browser
143 $checkbox = new ilCheckboxInputGUI($lng->txt("mathjax_server_for_browser"),"server_for_browser");
144 $checkbox->setInfo($lng->txt("mathjax_server_for_browser_info"));
145 $checkbox->setChecked((bool) $mathJaxSetting->get("server_for_browser"));
146 $server->addSubItem($checkbox);
147
148 // Server for HTML Export
149 $checkbox = new ilCheckboxInputGUI($lng->txt("mathjax_server_for_export"),"server_for_export");
150 $checkbox->setInfo($lng->txt("mathjax_server_for_export_info"));
151 $checkbox->setChecked((bool) $mathJaxSetting->get("server_for_export"));
152 $server->addSubItem($checkbox);
153
154 // Server for PDF
155 $checkbox = new ilCheckboxInputGUI($lng->txt("mathjax_server_for_pdf"),"server_for_pdf");
156 $checkbox->setInfo($lng->txt("mathjax_server_for_pdf_info"));
157 $checkbox->setChecked((bool) $mathJaxSetting->get("server_for_pdf"));
158 $server->addSubItem($checkbox);
159
160 // Cache Size / Clear Cache
161 $size = new ilNonEditableValueGUI($lng->txt("mathjax_server_cache_size"));
162 $size->setInfo($lng->txt("mathjax_server_cache_size_info") . $clear_cache_link);
163 $size->setValue(ilMathJax::getInstance()->getCacheSize());
164 $server->addSubItem($size);
165
166 // Test expression
167 $test = new ilCustomInputGUI($lng->txt("mathjax_test_expression"));
168 include_once './Services/MathJax/classes/class.ilMathJax.php';
169 $html = ilMathJax::getInstance()->insertLatexImages('[tex]f(x)=\int_{-\infty}^x e^{-t^2}dt[/tex]');
170 $test->setHtml($html);
171 $test->setInfo($lng->txt('mathjax_test_expression_info'));
172 $form->addItem($test);
173
174 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
175 {
176 $form->addCommandButton("saveMathJax", $lng->txt("save"));
177 }
178
179 $tpl->setVariable("ADM_CONTENT", $form->getHTML());
180 }
181
186 {
187 global $ilCtrl, $lng, $ilAccess;
188
189 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
190 {
191 $mathJaxSetting = new ilSetting("MathJax");
192 // Client settings
193 $path_to_mathjax = ilUtil::stripSlashes($_POST["path_to_mathjax"]);
194 if ($_POST["enable"])
195 {
196 $mathJaxSetting->set("path_to_mathjax", $path_to_mathjax);
197 $mathJaxSetting->set("limiter", (int) $_POST["limiter"]);
198 }
199 $mathJaxSetting->set("enable", ilUtil::stripSlashes($_POST["enable"]));
200
201 // Server settings
202 if ($_POST["enable_server"])
203 {
204 $mathJaxSetting->set("server_address",ilUtil::stripSlashes($_POST["server_address"]));
205 $mathJaxSetting->set("server_timeout", (int) ilUtil::stripSlashes($_POST["server_timeout"]));
206 $mathJaxSetting->set("server_for_browser", (bool) ilUtil::stripSlashes($_POST["server_for_browser"]));
207 $mathJaxSetting->set("server_for_export", (bool) ilUtil::stripSlashes($_POST["server_for_export"]));
208 $mathJaxSetting->set("server_for_pdf", (bool) ilUtil::stripSlashes($_POST["server_for_pdf"]));
209 }
210 $mathJaxSetting->set("enable_server", (bool) ilUtil::stripSlashes($_POST["enable_server"]));
211
212 ilUtil::sendInfo($lng->txt("msg_obj_modified"));
213 }
214 $ilCtrl->redirect($this, "editMathJax");
215 }
216
221 {
222 global $lng;
223
224 include_once './Services/MathJax/classes/class.ilMathJax.php';
225 ilMathJax::getInstance()->clearCache();
226
227 ilUtil::sendSuccess($lng->txt('mathjax_server_cache_cleared'), true);
228 $this->ctrl->redirect($this, 'editMathJax');
229 }
230
236 function editMapsObject()
237 {
238 require_once("Services/Maps/classes/class.ilMapUtil.php");
239
240 global $ilAccess, $lng, $ilCtrl, $tpl;
241
242 $this->__initSubTabs("editMaps");
243 $std_latitude = ilMapUtil::getStdLatitude();
244 $std_longitude = ilMapUtil::getStdLongitude();
245 $std_zoom = ilMapUtil::getStdZoom();
246 $type = ilMapUtil::getType();
247
248 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
249 include_once("./Services/Form/classes/class.ilCheckboxOption.php");
250 $form = new ilPropertyFormGUI();
251 $form->setFormAction($ilCtrl->getFormAction($this));
252 $form->setTitle($lng->txt("maps_settings"));
253
254 // Enable Maps
255 $enable = new ilCheckboxInputGUI($lng->txt("maps_enable_maps"), "enable");
256 $enable->setChecked(ilMapUtil::isActivated());
257 $enable->setInfo($lng->txt("maps_enable_maps_info"));
258 $form->addItem($enable);
259
260 // Select type
261 $types = new ilSelectInputGUI($lng->txt("maps_map_type"), "type");
262 $types->setOptions(ilMapUtil::getAvailableMapTypes());
263 $types->setValue($type);
264 $form->addItem($types);
265
266 // map data server property
267 if($type == "openlayers") {
268 $tile = new ilTextInputGUI($lng->txt("maps_tile_server"),"tile");
269 $tile->setValue(ilMapUtil::getStdTileServers());
270 $tile->setInfo(sprintf($lng->txt("maps_custom_tile_server_info"),ilMapUtil::DEFAULT_TILE));
271 $geolocation = new ilTextInputGUI($lng->txt("maps_geolocation_server"),"geolocation");
272 $geolocation->setValue(ilMapUtil::getStdGeolocationServer());
273 $geolocation->setInfo($lng->txt("maps_custom_geolocation_server_info"));
274
275 $form->addItem($tile);
276 $form->addItem($geolocation);
277 } else {
278 // api key for google
279 $key = new ilTextInputGUI("Google API Key", "api_key");
280 $key->setMaxLength(200);
281 $key->setValue(ilMapUtil::getApiKey());
282 $form->addItem($key);
283 }
284
285 // location property
286 $loc_prop = new ilLocationInputGUI($lng->txt("maps_std_location"),
287 "std_location");
288
289 $loc_prop->setLatitude($std_latitude);
290 $loc_prop->setLongitude($std_longitude);
291 $loc_prop->setZoom($std_zoom);
292 $form->addItem($loc_prop);
293
294 if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
295 {
296 $form->addCommandButton("saveMaps", $lng->txt("save"));
297 $form->addCommandButton("view", $lng->txt("cancel"));
298 }
299
300 $tpl->setVariable("ADM_CONTENT", $form->getHTML());
301 }
302
303
307 function saveMapsObject()
308 {
309 require_once("Services/Maps/classes/class.ilMapUtil.php");
310
311 global $ilCtrl;
312 if(ilUtil::stripSlashes($_POST["type"]) == 'openlayers' && 'openlayers' == ilMapUtil::getType()) {
315 } else {
317 }
318
321 ilMapUtil::setStdLatitude(ilUtil::stripSlashes($_POST["std_location"]["latitude"]));
322 ilMapUtil::setStdLongitude(ilUtil::stripSlashes($_POST["std_location"]["longitude"]));
323 ilMapUtil::setStdZoom(ilUtil::stripSlashes($_POST["std_location"]["zoom"]));
324 $ilCtrl->redirect($this, "editMaps");
325 }
326
327 // init sub tabs
328 function __initSubTabs($a_cmd)
329 {
330 $maps = ($a_cmd == 'editMaps') ? true : false;
331 $mathjax = ($a_cmd == 'editMathJax') ? true : false;
332
333 $this->tabs_gui->addSubTabTarget("maps_extt_maps", $this->ctrl->getLinkTarget($this, "editMaps"),
334 "", "", "", $maps);
335 $this->tabs_gui->addSubTabTarget("mathjax_mathjax", $this->ctrl->getLinkTarget($this, "editMathJax"),
336 "", "", "", $mathjax);
337 }
338
339 function executeCommand()
340 {
341 global $ilAccess;
342
343 $next_class = $this->ctrl->getNextClass($this);
344 $cmd = $this->ctrl->getCmd();
345 $this->prepareOutput();
346
347 if (!$ilAccess->checkAccess("read", "", $this->object->getRefId()))
348 {
349 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
350 }
351
352 switch($next_class)
353 {
354 case 'ilecssettingsgui':
355 $this->tabs_gui->setTabActive('ecs_server_settings');
356 include_once('./Services/WebServices/ECS/classes/class.ilECSSettingsGUI.php');
357 $this->ctrl->forwardCommand(new ilECSSettingsGUI());
358 break;
359
360 case 'ilpermissiongui':
361 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
362 $perm_gui = new ilPermissionGUI($this);
363 $ret =& $this->ctrl->forwardCommand($perm_gui);
364 $this->tabs_gui->setTabActive('perm_settings');
365 break;
366
367 default:
368 $this->tabs_gui->setTabActive('settings');
369 if(!$cmd || $cmd == 'view')
370 {
371 $cmd = "editMaps";
372 }
373 $cmd .= "Object";
374 $this->$cmd();
375
376 break;
377 }
378 return true;
379 }
380
381} // END class.ilObjExternalToolsSettingsGUI
382?>
sprintf('%.4f', $callTime)
$size
Definition: RandomTest.php:79
if(strpos( $jquery_path, './')===0) else if(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:36
$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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options