ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
5 require_once "./Services/Object/classes/class.ilObjectGUI.php";
6 
7 
19 {
24  function ilObjExternalToolsSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
25  {
26  global $lng;
27 
28  $this->type = "extt";
29  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
30 
31  define ("ILINC_DEFAULT_HTTP_PORT",80);
32  define ("ILINC_DEFAULT_SSL_PORT",443);
33  define ("ILINC_DEFAULT_TIMEOUT",30);
34  $lng->loadLanguageModule("delic");
35  $lng->loadLanguageModule("gmaps");
36  $lng->loadLanguageModule("mathjax");
37  }
38 
44  function viewObject()
45  {
46  $this->editiLincObject();
47 
48 
49 // global $rbacsystem;
50 //
51 // if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
52 // {
53 // $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
54 // }
55 //
56 // $this->__initSubTabs("view");
57 //
58 // $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.extt_general.html",
59 // "Services/Administration");
60 //
61 // $this->tpl->setVariable("FORMACTION",
62 // $this->ctrl->getFormAction($this));
63 // $this->tpl->setVariable("TXT_EXTT_TITLE", $this->lng->txt("extt_title_configure"));
64 //
65 // $this->tpl->setVariable("TXT_EXTT_NAME", $this->lng->txt("extt_name"));
66 // $this->tpl->setVariable("TXT_EXTT_ACTIVE", $this->lng->txt("active")."?");
67 // $this->tpl->setVariable("TXT_EXTT_DESC", $this->lng->txt("description"));
68 //
69 // $this->tpl->setVariable("TXT_CONFIGURE", $this->lng->txt("extt_configure"));
70 // $this->tpl->setVariable("TXT_EXTT_REMARK", $this->lng->txt("extt_remark"));
71 //
72 // // ilinc
73 // $this->tpl->setVariable("TXT_EXTT_ILINC_NAME", $this->lng->txt("extt_ilinc"));
74 // $this->tpl->setVariable("TXT_EXTT_ILINC_DESC", $this->lng->txt("extt_ilinc_desc"));
75 //
76 //
77 // // icon handlers
78 // $icon_ok = "<img src=\"".ilUtil::getImagePath("icon_ok.png")."\" alt=\"".$this->lng->txt("enabled")."\" title=\"".$this->lng->txt("enabled")."\" border=\"0\" vspace=\"0\"/>";
79 // $icon_not_ok = "<img src=\"".ilUtil::getImagePath("icon_not_ok.png")."\" alt=\"".$this->lng->txt("disabled")."\" title=\"".$this->lng->txt("disabled")."\" border=\"0\" vspace=\"0\"/>";
80 //
81 // $this->tpl->setVariable("EXTT_ILINC_ACTIVE", $this->ilias->getSetting('ilinc_active') ? $icon_ok : $icon_not_ok);
82  }
83 
84  function cancelObject()
85  {
86  $this->ctrl->redirect($this, "editiLinc");
87  }
88 
89  function getAdminTabs(&$tabs_gui)
90  {
91  $this->getTabs($tabs_gui);
92  }
93 
99  function getTabs(&$tabs_gui)
100  {
101  global $rbacsystem;
102 
103  $this->ctrl->setParameter($this,"ref_id",$this->object->getRefId());
104 
105  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
106  {
107  $tabs_gui->addTarget("settings",
108 // $this->ctrl->getLinkTarget($this, "view"),
109 // array("view","editiLinc","editDelicious", "editGoogleMaps","editMathJax", ""), "", "");
110 
111  $this->ctrl->getLinkTarget($this, "editSocialBookmarks"),
112  array("editiLinc","editDelicious", "editGoogleMaps","editMathJax", ""), "", "");
113  $this->lng->loadLanguageModule('ecs');
114  }
115 
116  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
117  {
118  $tabs_gui->addTarget("perm_settings",
119  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
120  }
121  }
122 
128  function editiLincObject()
129  {
130  global $rbacsystem, $rbacreview;
131 
132  if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
133  {
134  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
135  }
136 
137  ilUtil::sendFailure($this->lng->txt('ilinc_abandoned_info'));
138 
139  $this->__initSubTabs("editiLinc");
140 
141  if ($_SESSION["error_post_vars"])
142  {
143  if ($_SESSION["error_post_vars"]["ilinc"]["active"] == "1")
144  {
145  $this->tpl->setVariable("CHK_ILINC_ACTIVE", "checked=\"checked\"");
146  }
147 
148  if ($_SESSION["error_post_vars"]["ilinc"]["akclassvalues_active"] == "1")
149  {
150  $this->tpl->setVariable("CHK_ILINC_AKCLASSVALUES_ACTIVE", "checked=\"checked\"");
151  }
152 
153  if ($_SESSION["error_post_vars"]["ilinc"]["akclassvalues_required"] == "1")
154  {
155  $this->tpl->setVariable("CHK_ILINC_AKCLASSVALUES_REQUIRED", "checked=\"checked\"");
156  }
157 
158  $this->tpl->setVariable("ILINC_SERVER", $_SESSION["error_post_vars"]["ilinc"]["server"]);
159  $this->tpl->setVariable("ILINC_REGISTRAR_LOGIN", $_SESSION["error_post_vars"]["ilinc"]["registrar_login"]);
160  $this->tpl->setVariable("ILINC_REGISTRAR_PASSWD", $_SESSION["error_post_vars"]["ilinc"]["registrar_passwd"]);
161  $this->tpl->setVariable("ILINC_CUSTOMER_ID", $_SESSION["error_post_vars"]["ilinc"]["customer_id"]);
162  }
163  else
164  {
165  // set already saved data or default value for port
166  $settings = $this->ilias->getAllSettings();
167 
168  if ($settings["ilinc_active"] == "1")
169  {
170  $this->tpl->setVariable("CHK_ILINC_ACTIVE", "checked=\"checked\"");
171  }
172 
173  $this->tpl->setVariable("ILINC_SERVER", $settings["ilinc_server"].$settings["ilinc_path"]);
174  $this->tpl->setVariable("ILINC_REGISTRAR_LOGIN", $settings["ilinc_registrar_login"]);
175  $this->tpl->setVariable("ILINC_REGISTRAR_PASSWD", $settings["ilinc_registrar_passwd"]);
176  $this->tpl->setVariable("ILINC_CUSTOMER_ID", $settings["ilinc_customer_id"]);
177 
178  if (empty($settings["ilinc_port"]))
179  {
180  $this->tpl->setVariable("ILINC_PORT", ILINC_DEFAULT_HTTP_PORT);
181  }
182  else
183  {
184  $this->tpl->setVariable("ILINC_PORT", $settings["ilinc_port"]);
185  }
186 
187  if ($settings["ilinc_protocol"] == "https")
188  {
189  $this->tpl->setVariable("ILINC_PROTOCOL_SSL_SEL", "selected=\"selected\"");
190  }
191  else
192  {
193  $this->tpl->setVariable("ILINC_PROTOCOL_HTTP_SEL", "selected=\"selected\"");
194  }
195 
196  if (empty($settings["ilinc_timeout"]))
197  {
198  $this->tpl->setVariable("ILINC_TIMEOUT", ILINC_DEFAULT_TIMEOUT);
199  }
200  else
201  {
202  $this->tpl->setVariable("ILINC_TIMEOUT", $settings["ilinc_timeout"]);
203  }
204 
205  if ($settings["ilinc_akclassvalues_active"] == "1")
206  {
207  $this->tpl->setVariable("CHK_ILINC_AKCLASSVALUES_ACTIVE", "checked=\"checked\"");
208  }
209 
210  if ($settings["ilinc_akclassvalues_required"] == "1")
211  {
212  $this->tpl->setVariable("CHK_ILINC_AKCLASSVALUES_REQUIRED", "checked=\"checked\"");
213  }
214  }
215 
216  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.extt_ilinc.html",
217  "Services/Administration");
218 
219  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
220  $this->tpl->setVariable("TXT_ILINC_TITLE", $this->lng->txt("extt_ilinc_configure"));
221  $this->tpl->setVariable("TXT_ILINC_ACTIVE", $this->lng->txt("extt_ilinc_enable"));
222  $this->tpl->setVariable("TXT_ILINC_CONNECTION_DATA", $this->lng->txt("extt_ilinc_connection_data"));
223  $this->tpl->setVariable("TXT_ILINC_ADDITIONAL_OPTIONS", $this->lng->txt("extt_ilinc_additional_options"));
224  $this->tpl->setVariable("TXT_ILINC_SERVER", $this->lng->txt("extt_ilinc_server"));
225  $this->tpl->setVariable("TXT_ILINC_PROTOCOL_PORT", $this->lng->txt("extt_ilinc_protocol_port"));
226  $this->tpl->setVariable("TXT_ILINC_TIMEOUT", $this->lng->txt("extt_ilinc_timeout"));
227  $this->tpl->setVariable("ILINC_DEFAULT_HTTP_PORT", ILINC_DEFAULT_HTTP_PORT);
228  $this->tpl->setVariable("ILINC_DEFAULT_SSL_PORT", ILINC_DEFAULT_SSL_PORT);
229  $this->tpl->setVariable("TXT_HTTP", $this->lng->txt('http'));
230  $this->tpl->setVariable("TXT_SSL", $this->lng->txt('ssl'));
231 
232  $this->tpl->setVariable("TXT_SECONDS", $this->lng->txt("seconds"));
233  $this->tpl->setVariable("TXT_ILINC_REGISTRAR_LOGIN", $this->lng->txt("extt_ilinc_registrar_login"));
234  $this->tpl->setVariable("TXT_ILINC_REGISTRAR_PASSWD", $this->lng->txt("extt_ilinc_registrar_passwd"));
235  $this->tpl->setVariable("TXT_ILINC_CUSTOMER_ID", $this->lng->txt("extt_ilinc_customer_id"));
236 
237  $this->tpl->setVariable("TXT_ILINC_AKCLASSVALUES_ACTIVE", $this->lng->txt("extt_ilinc_akclassvalues_active"));
238  $this->tpl->setVariable("TXT_ILINC_AKCLASSVALUES_ACTIVE_INFO", $this->lng->txt("extt_ilinc_akclassvalues_active_info"));
239  $this->tpl->setVariable("TXT_ILINC_AKCLASSVALUES_REQUIRED", $this->lng->txt("extt_ilinc_akclassvalues_required"));
240  $this->tpl->setVariable("TXT_ILINC_AKCLASSVALUES_REQUIRED_INFO", $this->lng->txt("extt_ilinc_akclassvalues_required_info"));
241 
242  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
243  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
244  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
245  $this->tpl->setVariable("CMD_SUBMIT", "saveiLinc");
246  }
247 
253  function saveiLincObject()
254  {
255  global $ilUser;
256 
257  // validate required data
258  if (!$_POST["ilinc"]["server"] or !$_POST["ilinc"]["port"] or !$_POST["ilinc"]["registrar_login"] or !$_POST["ilinc"]["registrar_passwd"] or !$_POST["ilinc"]["customer_id"])
259  {
260  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
261  }
262 
263  // validate port
264  if ((preg_match("/^[0-9]{0,5}$/",$_POST["ilinc"]["port"])) == false)
265  {
266  $this->ilias->raiseError($this->lng->txt("err_invalid_port"),$this->ilias->error_obj->MESSAGE);
267  }
268 
269  if (substr($_POST["ilinc"]["server"],0,8) != "https://" and substr($_POST["ilinc"]["server"],0,7) != "http://")
270  {
271  $_POST["ilinc"]["server"] = $_POST["ilinc"]["protocol"]."://".$_POST["ilinc"]["server"];
272  }
273 
274  $url = parse_url($_POST["ilinc"]["server"]);
275 
276  if (!ilUtil::isIPv4($url["host"]) and !ilUtil::isDN($url["host"]))
277  {
278  $this->ilias->raiseError($this->lng->txt("err_invalid_server"),$this->ilias->error_obj->MESSAGE);
279  }
280 
281  if (is_numeric($_POST["ilinc"]["timeout"]))
282  {
283  $this->ilias->setSetting("ilinc_timeout", $_POST["ilinc"]["timeout"]);
284  }
285 
286  // all ok. save settings
287  $this->ilias->setSetting("ilinc_server", $url["host"]);
288  $this->ilias->setSetting("ilinc_path", $url["path"]);
289  $this->ilias->setSetting("ilinc_protocol", $_POST["ilinc"]["protocol"]);
290  $this->ilias->setSetting("ilinc_port", $_POST["ilinc"]["port"]);
291  $this->ilias->setSetting("ilinc_active", $_POST["ilinc"]["active"]);
292  $this->ilias->setSetting("ilinc_registrar_login", $_POST["ilinc"]["registrar_login"]);
293  $this->ilias->setSetting("ilinc_registrar_passwd", $_POST["ilinc"]["registrar_passwd"]);
294  $this->ilias->setSetting("ilinc_customer_id", $_POST["ilinc"]["customer_id"]);
295 
296  $this->ilias->setSetting("ilinc_akclassvalues_active", $_POST["ilinc"]["akclassvalues_active"]);
297  $this->ilias->setSetting("ilinc_akclassvalues_required", $_POST["ilinc"]["akclassvalues_required"]);
298 
299  ilUtil::sendSuccess($this->lng->txt("extt_ilinc_settings_saved"),true);
300  $this->ctrl->redirect($this,'editiLinc');
301  }
302 
304  {
305  global $ilAccess, $rbacreview, $lng, $ilCtrl;
306 
307  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
308  {
309  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
310  }
311 
312  $this->__initSubTabs("editSocialBookmarks");
313 
314  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
315  $form = ilSocialBookmarks::_initForm($this, 'create');
316  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
317  }
318 
320  {
321  global $ilAccess, $rbacreview, $lng, $ilCtrl;
322 
323  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
324  {
325  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
326  }
327 
328  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
329  $form = ilSocialBookmarks::_initForm($this, 'create');
330  if ($form->checkInput())
331  {
332  $title = $form->getInput('title');
333  $link = $form->getInput('link');
334  $file = $form->getInput('image_file');
335  $active = $form->getInput('activate');
336 
337  $extension = pathinfo($file['name'], PATHINFO_EXTENSION);
338  $icon_path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons' . DIRECTORY_SEPARATOR . time() . '.' . $extension;
339 
340  $path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons';
341  if (!is_dir($path))
343 
344  ilSocialBookmarks::_insertSocialBookmark($title, $link, $active, $icon_path);
345 
346  ilUtil::moveUploadedFile($file['tmp_name'], $file['name'], $icon_path);
347 
348  $this->editSocialBookmarksObject();
349  }
350  else
351  {
352  $this->__initSubTabs("editSocialBookmarks");
353  $form->setValuesByPost();
354  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
355  }
356  }
357 
359  {
360  global $ilAccess, $rbacreview, $lng, $ilCtrl;
361 
362  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
363  {
364  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
365  }
366 
367  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
368  $form = ilSocialBookmarks::_initForm($this, 'update');
369  if ($form->checkInput())
370  {
371  $title = $form->getInput('title');
372  $link = $form->getInput('link');
373  $file = $form->getInput('image_file');
374  $active = $form->getInput('activate');
375  $id = $form->getInput('sbm_id');
376 
377  if (!$file['name'])
378  ilSocialBookmarks::_updateSocialBookmark($id, $title, $link, $active);
379  else
380  {
381  $extension = pathinfo($file['name'], PATHINFO_EXTENSION);
382  $icon_path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons' . DIRECTORY_SEPARATOR . time() . '.' . $extension;
383 
384  $path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons';
385  if (!is_dir($path))
387 
389  ilSocialBookmarks::_updateSocialBookmark($id, $title, $link, $active, $icon_path);
390  ilUtil::moveUploadedFile($file['tmp_name'], $file['name'], $icon_path);
391  }
392 
393  $this->editSocialBookmarksObject();
394  }
395  else
396  {
397  $this->__initSubTabs("editSocialBookmarks");
398  $form->setValuesByPost();
399  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
400  }
401  }
402 
409  {
410  global $ilAccess, $rbacreview, $lng, $ilCtrl;
411 
412  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
413  {
414  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
415  }
416 
417  $this->__initSubTabs("editSocialBookmarks");
418 
419  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
421  $dset = array
422  (
423  'sbm_id' => $row->sbm_id,
424  'title' => $row->sbm_title,
425  'link' => $row->sbm_link,
426  'activate' => $row->sbm_active
427  );
428 
429  $form = ilSocialBookmarks::_initForm($this, 'update');
430  $form->setValuesByArray($dset);
431  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
432  }
433 
435  {
436  global $ilAccess, $rbacreview, $lng, $ilCtrl;
437 
438  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
439  {
440  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
441  }
442 
443  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
444  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
445  ilSocialBookmarks::_setActive($ids, true);
446  $this->editSocialBookmarksObject();
447  }
448 
450  {
451  global $ilAccess, $rbacreview, $lng, $ilCtrl;
452 
453  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
454  {
455  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
456 
457  }
458  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
459  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
460  ilSocialBookmarks::_setActive($ids, false);
461  $this->editSocialBookmarksObject();
462  }
463 
465  {
466  global $ilAccess, $rbacreview, $lng, $ilCtrl;
467 
468  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
469  {
470  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
471 
472  }
473 
474  $this->__initSubTabs("editSocialBookmarks");
475 
476  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
477  $c_gui = new ilConfirmationGUI();
478 
479  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
480 
481  // set confirm/cancel commands
482  $c_gui->setFormAction($ilCtrl->getFormAction($this, "confirmDeleteSocialBookmarks"));
483  $c_gui->setHeaderText($lng->txt("socialbm_sure_delete_entry"));
484  $c_gui->setCancel($lng->txt("cancel"), "editSocialBookmarks");
485  $c_gui->setConfirm($lng->txt("confirm"), "confirmDeleteSocialBookmarks");
486 
487  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
488  // add items to delete
489  foreach($ids as $id)
490  {
491  $entry = ilSocialBookmarks::_getEntry($id);
492  $c_gui->addItem("sbm_id[]", $id, $entry->sbm_title . ' (' . str_replace('{', '&#123;', $entry->sbm_link) . ')');
493  }
494 
495  $this->tpl->setVariable('ADM_CONTENT', $c_gui->getHTML());
496  }
497 
499  {
500  global $ilAccess, $rbacreview, $lng, $ilCtrl;
501 
502  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
503  {
504  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
505  }
506 
507 
508  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
509  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
510  ilSocialBookmarks::_delete($ids, false);
511  $this->editSocialBookmarksObject();
512  }
513 
520  {
521  global $ilAccess, $rbacreview, $lng, $ilCtrl;
522 
523  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
524  {
525  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
526  }
527 
528  $this->__initSubTabs("editSocialBookmarks");
529 
530 
531 
532  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
533 
534  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
536 
537  $counter = 0;
538  foreach($rset as $row)
539  {
540  $current_selection_list = new ilAdvancedSelectionListGUI();
541  $current_selection_list->setListTitle($lng->txt("actions"));
542  $current_selection_list->setId("act_".$counter++);
543 
544  $ilCtrl->setParameter($this, 'sbm_id', $row->sbm_id);
545 
546  $current_selection_list->addItem($lng->txt("edit"), '', $ilCtrl->getLinkTarget($this, "editSocialBookmark"));
547  $current_selection_list->addItem($lng->txt("delete"), '', $ilCtrl->getLinkTarget($this, "deleteSocialBookmarks"));
548 
549  $toggle_action = '';
550  if ($row->sbm_active)
551  {
552  $current_selection_list->addItem($lng->txt("socialbm_disable"), '', $toggle_action = $ilCtrl->getLinkTarget($this, "disableSocialBookmarks"));
553  }
554  else
555  {
556  $current_selection_list->addItem($lng->txt("socialbm_enable"), '', $toggle_action = $ilCtrl->getLinkTarget($this, "enableSocialBookmarks"));
557  }
558 
559 
560 
561  $dset[] = array
562  (
563  'CHECK' => ilUtil::formCheckbox(0, 'sbm_id[]', $row->sbm_id),
564  'ID' => $row->sbm_id,
565  'TITLE' => $row->sbm_title,
566  'LINK' => str_replace('{', '&#123;', $row->sbm_link),
567  'ICON' => $row->sbm_icon,
568  'ACTIVE' => $row->sbm_active ? $lng->txt('enabled') : $lng->txt('disabled'),
569  'ACTIONS' => $current_selection_list->getHTML(),
570  'TOGGLE_LINK' => $toggle_action
571  );
572  $ilCtrl->clearParameters($this);
573  }
574 
575  require_once 'Services/Table/classes/class.ilTable2GUI.php';
576  $table = new ilTable2GUI($this, 'editSocialBookmarks');
577  $table->setFormName('smtable');
578  $table->setId('smtable');
579  $table->setPrefix('sm');
580  $table->setFormAction($ilCtrl->getFormAction($this, 'saveSocialBookmarks'));
581  $table->addColumn('', 'check', '', true);
582  $table->addColumn($lng->txt('icon'), '');
583  $table->addColumn($lng->txt('title'), 'TITLE');
584  $table->addColumn($lng->txt('link'), 'LINK');
585  $table->addColumn($lng->txt('active'), 'ACTIVE');
586  $table->addColumn($lng->txt('actions'), '');
587  $table->setTitle($lng->txt('bm_manage_social_bm'));
588  $table->setData($dset);
589  $table->setRowTemplate('tpl.social_bookmarking_row.html', 'Services/Administration');
590  $table->setSelectAllCheckbox('sbm_id');
591 
592  $table->setDefaultOrderField("title");
593  $table->setDefaultOrderDirection("asc");
594 
595  $table->addMultiCommand('enableSocialBookmarks', $lng->txt('socialbm_enable'));
596  $table->addMultiCommand('disableSocialBookmarks', $lng->txt('socialbm_disable'));
597  $table->addMultiCommand('deleteSocialBookmarks', $lng->txt('delete'));
598 
599  $table->addCommandButton('addSocialBookmark', $lng->txt('create'));
600 
601  $this->tpl->setVariable('ADM_CONTENT', $table->getHTML());
602  }
603 
604 
608  function editMathJaxObject()
609  {
610  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl;
611 
612  $mathJaxSetting = new ilSetting("MathJax");
613  $path_to_mathjax = $mathJaxSetting->get("path_to_mathjax");
614 
615  $this->__initSubTabs("editMathJax");
616 
617  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
618  $form = new ilPropertyFormGUI();
619  $form->setFormAction($ilCtrl->getFormAction($this));
620  $form->setTitle($lng->txt("mathjax_settings"));
621 
622  // Enable MathJax
623  $enable = new ilCheckboxInputGUI($lng->txt("mathjax_enable_mathjax"), "enable");
624  $enable->setChecked($mathJaxSetting->get("enable"));
625  $enable->setInfo($lng->txt("mathjax_enable_mathjax_info")." <a target='blank' href='http://www.mathjax.org/'>MathJax</a>");
626  $form->addItem($enable);
627 
628  // Path to mathjax
629  $text_prop = new ilTextInputGUI($lng->txt("mathjax_path_to_mathjax"), "path_to_mathjax");
630  $text_prop->setInfo($lng->txt("mathjax_path_to_mathjax_desc"));
631  $text_prop->setValue($path_to_mathjax);
632  $text_prop->setRequired(true);
633  $text_prop->setMaxLength(400);
634  $text_prop->setSize(100);
635  $enable->addSubItem($text_prop);
636 
637  // mathjax limiter
638  $options = array(
639  0 => '\(...\)',
640  1 => '[tex]...[/tex]',
641  2 => '&lt;span class="math"&gt;...&lt;/span&gt;'
642  );
643  $si = new ilSelectInputGUI($this->lng->txt("mathjax_limiter"), "limiter");
644  $si->setOptions($options);
645  $si->setValue($mathJaxSetting->get("limiter"));
646  $si->setInfo($this->lng->txt("mathjax_limiter_info"));
647  $enable->addSubItem($si);
648 
649  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
650  {
651  $form->addCommandButton("saveMathJax", $lng->txt("save"));
652  }
653 
654  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
655  }
656 
660  function saveMathJaxObject()
661  {
662  global $ilCtrl, $lng, $ilAccess;
663 
664  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
665  {
666  $path_to_mathjax = ilUtil::stripSlashes($_POST["path_to_mathjax"]);
667  $mathJaxSetting = new ilSetting("MathJax");
668  if ($_POST["enable"])
669  {
670  $mathJaxSetting->set("path_to_mathjax", $path_to_mathjax);
671  $mathJaxSetting->set("limiter", (int) $_POST["limiter"]);
672  }
673  $mathJaxSetting->set("enable", ilUtil::stripSlashes($_POST["enable"]));
674  ilUtil::sendInfo($lng->txt("msg_obj_modified"));
675  }
676  $ilCtrl->redirect($this, "editMathJax");
677  }
678 
685  {
686  global $ilAccess, $lng, $ilCtrl, $tpl;
687 
688  $gm_set = new ilSetting("google_maps");
689 
690  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
691  {
692  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
693  }
694 
695  $this->__initSubTabs("editGoogleMaps");
696 
697  $std_latitude = $gm_set->get("std_latitude");
698  $std_longitude = $gm_set->get("std_longitude");
699  $std_zoom = $gm_set->get("std_zoom");
700  $api_url = "http://www.google.com/apis/maps/signup.html";
701 
702  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
703  $form = new ilPropertyFormGUI();
704  $form->setFormAction($ilCtrl->getFormAction($this));
705  $form->setTitle($lng->txt("gmaps_settings"));
706 
707  // Enable Google Maps
708  $enable = new ilCheckboxInputGUI($lng->txt("gmaps_enable_gmaps"), "enable");
709  $enable->setChecked($gm_set->get("enable"));
710  $enable->setInfo($lng->txt("gmaps_enable_gmaps_info"));
711  $form->addItem($enable);
712 
713  // location property
714  $loc_prop = new ilLocationInputGUI($lng->txt("gmaps_std_location"),
715  "std_location");
716  $loc_prop->setLatitude($std_latitude);
717  $loc_prop->setLongitude($std_longitude);
718  $loc_prop->setZoom($std_zoom);
719  $form->addItem($loc_prop);
720 
721  $form->addCommandButton("saveGoogleMaps", $lng->txt("save"));
722  $form->addCommandButton("view", $lng->txt("cancel"));
723 
724  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
725  }
726 
727 
732  {
733  global $ilCtrl;
734 
735  $gm_set = new ilSetting("google_maps");
736 
737  $gm_set->set("enable", ilUtil::stripSlashes($_POST["enable"]));
738  $gm_set->set("std_latitude", ilUtil::stripSlashes($_POST["std_location"]["latitude"]));
739  $gm_set->set("std_longitude", ilUtil::stripSlashes($_POST["std_location"]["longitude"]));
740  $gm_set->set("std_zoom", ilUtil::stripSlashes($_POST["std_location"]["zoom"]));
741 
742  $ilCtrl->redirect($this, "editGoogleMaps");
743  }
744 
745  // init sub tabs
746  function __initSubTabs($a_cmd)
747  {
748  $ilinc = ($a_cmd == 'editiLinc') ? true : false;
749 // $overview = ($a_cmd == 'view' or $a_cmd == '') ? true : false;
750  //$delicious = ($a_cmd == 'editDelicious') ? true : false;
751 
752  if($a_cmd == 'view' || $a_cmd == '')
753  {
754  $a_cmd = 'editSocialBookmarks';
755  }
756  $socialbookmarks = ($a_cmd == 'editSocialBookmarks') ? true : false;
757  $gmaps = ($a_cmd == 'editGoogleMaps') ? true : false;
758  $mathjax = ($a_cmd == 'editMathJax') ? true : false;
759 
760 // $this->tabs_gui->addSubTabTarget("overview", $this->ctrl->getLinkTarget($this, "view"),
761 // "", "", "", $overview);
762  /*$this->tabs_gui->addSubTabTarget("delic_extt_delicious", $this->ctrl->getLinkTarget($this, "editDelicious"),
763  "", "", "", $delicious);*/
764  $this->tabs_gui->addSubTabTarget("socialbm_extt_social_bookmarks", $this->ctrl->getLinkTarget($this, "editSocialBookmarks"),
765  "", "", "", $socialbookmarks);
766  $this->tabs_gui->addSubTabTarget("mathjax_mathjax", $this->ctrl->getLinkTarget($this, "editMathJax"),
767  "", "", "", $mathjax);
768  $this->tabs_gui->addSubTabTarget("gmaps_extt_gmaps", $this->ctrl->getLinkTarget($this, "editGoogleMaps"),
769  "", "", "", $gmaps);
770  $this->tabs_gui->addSubTabTarget("extt_ilinc", $this->ctrl->getLinkTarget($this, "editiLinc"),
771  "", "", "", $ilinc);
772  }
773 
774  function &executeCommand()
775  {
776 
777  $next_class = $this->ctrl->getNextClass($this);
778  $cmd = $this->ctrl->getCmd();
779  $this->prepareOutput();
780 
781  switch($next_class)
782  {
783  case 'ilecssettingsgui':
784  $this->tabs_gui->setTabActive('ecs_server_settings');
785  include_once('./Services/WebServices/ECS/classes/class.ilECSSettingsGUI.php');
786  $this->ctrl->forwardCommand(new ilECSSettingsGUI());
787  break;
788 
789  case 'ilpermissiongui':
790  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
791  $perm_gui =& new ilPermissionGUI($this);
792  $ret =& $this->ctrl->forwardCommand($perm_gui);
793  $this->tabs_gui->setTabActive('perm_settings');
794  break;
795 
796  default:
797  $this->tabs_gui->setTabActive('settings');
798  if(!$cmd || $cmd == 'view')
799  {
800  $cmd = "editSocialBookmarks";
801  }
802  $cmd .= "Object";
803  $this->$cmd();
804 
805  break;
806  }
807  return true;
808  }
809 
810 } // END class.ilObjExternalToolsSettingsGUI
811 ?>