ILIAS  Release_4_4_x_branch Revision 61816
 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  $lng->loadLanguageModule("delic");
32  $lng->loadLanguageModule("gmaps");
33  $lng->loadLanguageModule("mathjax");
34  }
35 
36  function getAdminTabs(&$tabs_gui)
37  {
38  $this->getTabs($tabs_gui);
39  }
40 
46  function getTabs(&$tabs_gui)
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  $tabs_gui->addTarget("settings",
55 // $this->ctrl->getLinkTarget($this, "view"),
56 // array("view","editDelicious", "editGoogleMaps","editMathJax", ""), "", "");
57 
58  $this->ctrl->getLinkTarget($this, "editSocialBookmarks"),
59  array("editDelicious", "editGoogleMaps","editMathJax", ""), "", "");
60  $this->lng->loadLanguageModule('ecs');
61  }
62 
63  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
64  {
65  $tabs_gui->addTarget("perm_settings",
66  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
67  }
68  }
69 
71  {
72  global $ilAccess, $rbacreview, $lng, $ilCtrl;
73 
74  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
75  {
76  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
77  }
78 
79  $this->__initSubTabs("editSocialBookmarks");
80 
81  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
82  $form = ilSocialBookmarks::_initForm($this, 'create');
83  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
84  }
85 
87  {
88  global $ilAccess, $rbacreview, $lng, $ilCtrl;
89 
90  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
91  {
92  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
93  }
94 
95  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
96  $form = ilSocialBookmarks::_initForm($this, 'create');
97  if ($form->checkInput())
98  {
99  $title = $form->getInput('title');
100  $link = $form->getInput('link');
101  $file = $form->getInput('image_file');
102  $active = $form->getInput('activate');
103 
104  $extension = pathinfo($file['name'], PATHINFO_EXTENSION);
105  $icon_path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons' . DIRECTORY_SEPARATOR . time() . '.' . $extension;
106 
107  $path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons';
108  if (!is_dir($path))
110 
111  ilSocialBookmarks::_insertSocialBookmark($title, $link, $active, $icon_path);
112 
113  ilUtil::moveUploadedFile($file['tmp_name'], $file['name'], $icon_path);
114 
115  $this->editSocialBookmarksObject();
116  }
117  else
118  {
119  $this->__initSubTabs("editSocialBookmarks");
120  $form->setValuesByPost();
121  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
122  }
123  }
124 
126  {
127  global $ilAccess, $rbacreview, $lng, $ilCtrl;
128 
129  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
130  {
131  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
132  }
133 
134  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
135  $form = ilSocialBookmarks::_initForm($this, 'update');
136  if ($form->checkInput())
137  {
138  $title = $form->getInput('title');
139  $link = $form->getInput('link');
140  $file = $form->getInput('image_file');
141  $active = $form->getInput('activate');
142  $id = $form->getInput('sbm_id');
143 
144  if (!$file['name'])
145  ilSocialBookmarks::_updateSocialBookmark($id, $title, $link, $active);
146  else
147  {
148  $extension = pathinfo($file['name'], PATHINFO_EXTENSION);
149  $icon_path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons' . DIRECTORY_SEPARATOR . time() . '.' . $extension;
150 
151  $path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons';
152  if (!is_dir($path))
154 
156  ilSocialBookmarks::_updateSocialBookmark($id, $title, $link, $active, $icon_path);
157  ilUtil::moveUploadedFile($file['tmp_name'], $file['name'], $icon_path);
158  }
159 
160  $this->editSocialBookmarksObject();
161  }
162  else
163  {
164  $this->__initSubTabs("editSocialBookmarks");
165  $form->setValuesByPost();
166  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
167  }
168  }
169 
176  {
177  global $ilAccess, $rbacreview, $lng, $ilCtrl;
178 
179  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
180  {
181  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
182  }
183 
184  $this->__initSubTabs("editSocialBookmarks");
185 
186  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
188  $dset = array
189  (
190  'sbm_id' => $row->sbm_id,
191  'title' => $row->sbm_title,
192  'link' => $row->sbm_link,
193  'activate' => $row->sbm_active
194  );
195 
196  $form = ilSocialBookmarks::_initForm($this, 'update');
197  $form->setValuesByArray($dset);
198  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
199  }
200 
202  {
203  global $ilAccess, $rbacreview, $lng, $ilCtrl;
204 
205  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
206  {
207  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
208  }
209 
210  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
211  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
212  ilSocialBookmarks::_setActive($ids, true);
213  $this->editSocialBookmarksObject();
214  }
215 
217  {
218  global $ilAccess, $rbacreview, $lng, $ilCtrl;
219 
220  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
221  {
222  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
223 
224  }
225  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
226  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
227  ilSocialBookmarks::_setActive($ids, false);
228  $this->editSocialBookmarksObject();
229  }
230 
232  {
233  global $ilAccess, $rbacreview, $lng, $ilCtrl;
234 
235  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
236  {
237  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
238 
239  }
240 
241  $this->__initSubTabs("editSocialBookmarks");
242 
243  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
244  $c_gui = new ilConfirmationGUI();
245 
246  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
247 
248  // set confirm/cancel commands
249  $c_gui->setFormAction($ilCtrl->getFormAction($this, "confirmDeleteSocialBookmarks"));
250  $c_gui->setHeaderText($lng->txt("socialbm_sure_delete_entry"));
251  $c_gui->setCancel($lng->txt("cancel"), "editSocialBookmarks");
252  $c_gui->setConfirm($lng->txt("confirm"), "confirmDeleteSocialBookmarks");
253 
254  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
255  // add items to delete
256  foreach($ids as $id)
257  {
258  $entry = ilSocialBookmarks::_getEntry($id);
259  $c_gui->addItem("sbm_id[]", $id, $entry->sbm_title . ' (' . str_replace('{', '&#123;', $entry->sbm_link) . ')');
260  }
261 
262  $this->tpl->setVariable('ADM_CONTENT', $c_gui->getHTML());
263  }
264 
266  {
267  global $ilAccess, $rbacreview, $lng, $ilCtrl;
268 
269  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
270  {
271  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
272  }
273 
274 
275  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
276  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
277  ilSocialBookmarks::_delete($ids, false);
278  $this->editSocialBookmarksObject();
279  }
280 
287  {
288  global $ilAccess, $rbacreview, $lng, $ilCtrl;
289 
290  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
291  {
292  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
293  }
294 
295  $this->__initSubTabs("editSocialBookmarks");
296 
297 
298 
299  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
300 
301  include_once './Services/Administration/classes/class.ilSocialBookmarks.php';
303 
304  $counter = 0;
305  foreach($rset as $row)
306  {
307  $current_selection_list = new ilAdvancedSelectionListGUI();
308  $current_selection_list->setListTitle($lng->txt("actions"));
309  $current_selection_list->setId("act_".$counter++);
310 
311  $ilCtrl->setParameter($this, 'sbm_id', $row->sbm_id);
312 
313  $current_selection_list->addItem($lng->txt("edit"), '', $ilCtrl->getLinkTarget($this, "editSocialBookmark"));
314  $current_selection_list->addItem($lng->txt("delete"), '', $ilCtrl->getLinkTarget($this, "deleteSocialBookmarks"));
315 
316  $toggle_action = '';
317  if ($row->sbm_active)
318  {
319  $current_selection_list->addItem($lng->txt("socialbm_disable"), '', $toggle_action = $ilCtrl->getLinkTarget($this, "disableSocialBookmarks"));
320  }
321  else
322  {
323  $current_selection_list->addItem($lng->txt("socialbm_enable"), '', $toggle_action = $ilCtrl->getLinkTarget($this, "enableSocialBookmarks"));
324  }
325 
326 
327 
328  $dset[] = array
329  (
330  'CHECK' => ilUtil::formCheckbox(0, 'sbm_id[]', $row->sbm_id),
331  'ID' => $row->sbm_id,
332  'TITLE' => $row->sbm_title,
333  'LINK' => str_replace('{', '&#123;', $row->sbm_link),
334  'ICON' => $row->sbm_icon,
335  'ACTIVE' => $row->sbm_active ? $lng->txt('enabled') : $lng->txt('disabled'),
336  'ACTIONS' => $current_selection_list->getHTML(),
337  'TOGGLE_LINK' => $toggle_action
338  );
339  $ilCtrl->clearParameters($this);
340  }
341 
342  require_once 'Services/Table/classes/class.ilTable2GUI.php';
343  $table = new ilTable2GUI($this, 'editSocialBookmarks');
344  $table->setFormName('smtable');
345  $table->setId('smtable');
346  $table->setPrefix('sm');
347  $table->setFormAction($ilCtrl->getFormAction($this, 'saveSocialBookmarks'));
348  $table->addColumn('', 'check', '', true);
349  $table->addColumn($lng->txt('icon'), '');
350  $table->addColumn($lng->txt('title'), 'TITLE');
351  $table->addColumn($lng->txt('link'), 'LINK');
352  $table->addColumn($lng->txt('active'), 'ACTIVE');
353  $table->addColumn($lng->txt('actions'), '');
354  $table->setTitle($lng->txt('bm_manage_social_bm'));
355  $table->setData($dset);
356  $table->setRowTemplate('tpl.social_bookmarking_row.html', 'Services/Administration');
357  $table->setSelectAllCheckbox('sbm_id');
358 
359  $table->setDefaultOrderField("title");
360  $table->setDefaultOrderDirection("asc");
361 
362  $table->addMultiCommand('enableSocialBookmarks', $lng->txt('socialbm_enable'));
363  $table->addMultiCommand('disableSocialBookmarks', $lng->txt('socialbm_disable'));
364  $table->addMultiCommand('deleteSocialBookmarks', $lng->txt('delete'));
365 
366  $table->addCommandButton('addSocialBookmark', $lng->txt('create'));
367 
368  $this->tpl->setVariable('ADM_CONTENT', $table->getHTML());
369  }
370 
371 
375  function editMathJaxObject()
376  {
377  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl;
378 
379  $mathJaxSetting = new ilSetting("MathJax");
380  $path_to_mathjax = $mathJaxSetting->get("path_to_mathjax");
381 
382  $this->__initSubTabs("editMathJax");
383 
384  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
385  $form = new ilPropertyFormGUI();
386  $form->setFormAction($ilCtrl->getFormAction($this));
387  $form->setTitle($lng->txt("mathjax_settings"));
388 
389  // Enable MathJax
390  $enable = new ilCheckboxInputGUI($lng->txt("mathjax_enable_mathjax"), "enable");
391  $enable->setChecked($mathJaxSetting->get("enable"));
392  $enable->setInfo($lng->txt("mathjax_enable_mathjax_info")." <a target='blank' href='http://www.mathjax.org/'>MathJax</a>");
393  $form->addItem($enable);
394 
395  // Path to mathjax
396  $text_prop = new ilTextInputGUI($lng->txt("mathjax_path_to_mathjax"), "path_to_mathjax");
397  $text_prop->setInfo($lng->txt("mathjax_path_to_mathjax_desc"));
398  $text_prop->setValue($path_to_mathjax);
399  $text_prop->setRequired(true);
400  $text_prop->setMaxLength(400);
401  $text_prop->setSize(100);
402  $enable->addSubItem($text_prop);
403 
404  // mathjax limiter
405  $options = array(
406  0 => '\(...\)',
407  1 => '[tex]...[/tex]',
408  2 => '&lt;span class="math"&gt;...&lt;/span&gt;'
409  );
410  $si = new ilSelectInputGUI($this->lng->txt("mathjax_limiter"), "limiter");
411  $si->setOptions($options);
412  $si->setValue($mathJaxSetting->get("limiter"));
413  $si->setInfo($this->lng->txt("mathjax_limiter_info"));
414  $enable->addSubItem($si);
415 
416  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
417  {
418  $form->addCommandButton("saveMathJax", $lng->txt("save"));
419  }
420 
421  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
422  }
423 
427  function saveMathJaxObject()
428  {
429  global $ilCtrl, $lng, $ilAccess;
430 
431  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
432  {
433  $path_to_mathjax = ilUtil::stripSlashes($_POST["path_to_mathjax"]);
434  $mathJaxSetting = new ilSetting("MathJax");
435  if ($_POST["enable"])
436  {
437  $mathJaxSetting->set("path_to_mathjax", $path_to_mathjax);
438  $mathJaxSetting->set("limiter", (int) $_POST["limiter"]);
439  }
440  $mathJaxSetting->set("enable", ilUtil::stripSlashes($_POST["enable"]));
441  ilUtil::sendInfo($lng->txt("msg_obj_modified"));
442  }
443  $ilCtrl->redirect($this, "editMathJax");
444  }
445 
452  {
453  global $ilAccess, $lng, $ilCtrl, $tpl;
454 
455  $gm_set = new ilSetting("google_maps");
456 
457  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
458  {
459  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
460  }
461 
462  $this->__initSubTabs("editGoogleMaps");
463 
464  $std_latitude = $gm_set->get("std_latitude");
465  $std_longitude = $gm_set->get("std_longitude");
466  $std_zoom = $gm_set->get("std_zoom");
467  $api_url = "http://www.google.com/apis/maps/signup.html";
468 
469  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
470  $form = new ilPropertyFormGUI();
471  $form->setFormAction($ilCtrl->getFormAction($this));
472  $form->setTitle($lng->txt("gmaps_settings"));
473 
474  // Enable Google Maps
475  $enable = new ilCheckboxInputGUI($lng->txt("gmaps_enable_gmaps"), "enable");
476  $enable->setChecked($gm_set->get("enable"));
477  $enable->setInfo($lng->txt("gmaps_enable_gmaps_info"));
478  $form->addItem($enable);
479 
480  // location property
481  $loc_prop = new ilLocationInputGUI($lng->txt("gmaps_std_location"),
482  "std_location");
483  $loc_prop->setLatitude($std_latitude);
484  $loc_prop->setLongitude($std_longitude);
485  $loc_prop->setZoom($std_zoom);
486  $form->addItem($loc_prop);
487 
488  $form->addCommandButton("saveGoogleMaps", $lng->txt("save"));
489  $form->addCommandButton("view", $lng->txt("cancel"));
490 
491  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
492  }
493 
494 
499  {
500  global $ilCtrl;
501 
502  $gm_set = new ilSetting("google_maps");
503 
504  $gm_set->set("enable", ilUtil::stripSlashes($_POST["enable"]));
505  $gm_set->set("std_latitude", ilUtil::stripSlashes($_POST["std_location"]["latitude"]));
506  $gm_set->set("std_longitude", ilUtil::stripSlashes($_POST["std_location"]["longitude"]));
507  $gm_set->set("std_zoom", ilUtil::stripSlashes($_POST["std_location"]["zoom"]));
508 
509  $ilCtrl->redirect($this, "editGoogleMaps");
510  }
511 
512  // init sub tabs
513  function __initSubTabs($a_cmd)
514  {
515 // $overview = ($a_cmd == 'view' or $a_cmd == '') ? true : false;
516  //$delicious = ($a_cmd == 'editDelicious') ? true : false;
517 
518  if($a_cmd == 'view' || $a_cmd == '')
519  {
520  $a_cmd = 'editSocialBookmarks';
521  }
522  $socialbookmarks = ($a_cmd == 'editSocialBookmarks') ? true : false;
523  $gmaps = ($a_cmd == 'editGoogleMaps') ? true : false;
524  $mathjax = ($a_cmd == 'editMathJax') ? true : false;
525 
526 // $this->tabs_gui->addSubTabTarget("overview", $this->ctrl->getLinkTarget($this, "view"),
527 // "", "", "", $overview);
528  /*$this->tabs_gui->addSubTabTarget("delic_extt_delicious", $this->ctrl->getLinkTarget($this, "editDelicious"),
529  "", "", "", $delicious);*/
530  $this->tabs_gui->addSubTabTarget("socialbm_extt_social_bookmarks", $this->ctrl->getLinkTarget($this, "editSocialBookmarks"),
531  "", "", "", $socialbookmarks);
532  $this->tabs_gui->addSubTabTarget("mathjax_mathjax", $this->ctrl->getLinkTarget($this, "editMathJax"),
533  "", "", "", $mathjax);
534  $this->tabs_gui->addSubTabTarget("gmaps_extt_gmaps", $this->ctrl->getLinkTarget($this, "editGoogleMaps"),
535  "", "", "", $gmaps);
536  }
537 
538  function &executeCommand()
539  {
540 
541  $next_class = $this->ctrl->getNextClass($this);
542  $cmd = $this->ctrl->getCmd();
543  $this->prepareOutput();
544 
545  switch($next_class)
546  {
547  case 'ilecssettingsgui':
548  $this->tabs_gui->setTabActive('ecs_server_settings');
549  include_once('./Services/WebServices/ECS/classes/class.ilECSSettingsGUI.php');
550  $this->ctrl->forwardCommand(new ilECSSettingsGUI());
551  break;
552 
553  case 'ilpermissiongui':
554  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
555  $perm_gui =& new ilPermissionGUI($this);
556  $ret =& $this->ctrl->forwardCommand($perm_gui);
557  $this->tabs_gui->setTabActive('perm_settings');
558  break;
559 
560  default:
561  $this->tabs_gui->setTabActive('settings');
562  if(!$cmd || $cmd == 'view')
563  {
564  $cmd = "editSocialBookmarks";
565  }
566  $cmd .= "Object";
567  $this->$cmd();
568 
569  break;
570  }
571  return true;
572  }
573 
574 } // END class.ilObjExternalToolsSettingsGUI
575 ?>