ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilBookmarkAdministrationGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once ("./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
6require_once ("./Services/Bookmarks/classes/class.ilBookmark.php");
7require_once ("./Services/Table/classes/class.ilTableGUI.php");
8
20{
27
33 var $ilias;
34 var $tpl;
35 var $lng;
36
37 var $tree;
38 var $id;
39 var $data;
40 var $textwidth = 100;
41
48 {
49 global $ilias, $tpl, $lng, $ilCtrl, $ilUser;
50
51// $tpl->enableAdvancedColumnLayout(true, false);
52
53 $tpl->getStandardTemplate();
54
55 //print_r($_SESSION["error_post_vars"]);
56 // if no bookmark folder id is given, take dummy root node id (that is 1)
57 $this->id = (empty($_GET["bmf_id"]))
58 ? 1
59 : $_GET["bmf_id"];
60
61 // initiate variables
62 $this->ilias = $ilias;
63 $this->tpl = $tpl;
64 $this->lng = $lng;
65 $this->ctrl = $ilCtrl;
66 $this->ctrl->setParameter($this, "bmf_id", $this->id);
67 $this->user_id = $ilUser->getId();
68
69 $this->tree = new ilTree($this->user_id);
70 $this->tree->setTableNames('bookmark_tree', 'bookmark_data');
71 $this->root_id = $this->tree->readRootId();
72
73 $this->lng->loadLanguageModule("bkm");
74
75 $this->mode = "tree";
76 }
77
81 function &executeCommand()
82 {
83 $next_class = $this->ctrl->getNextClass();
84
85 switch($next_class)
86 {
87 default:
88 $cmd = $this->ctrl->getCmd("view");
89 $this->displayHeader();
90 $this->$cmd();
91 if($this->getMode() == 'tree')
92 {
93 $this->explorer();
94 }
95 break;
96 }
97 $this->tpl->show(true);
98 return true;
99 }
100
101 function executeAction()
102 {
103 switch($_POST["selected_cmd"])
104 {
105 case "delete":
106 $this->delete();
107 break;
108 case "export":
109 $this->export();
110 break;
111 case "sendmail":
112 $this->sendmail();
113 break;
114 default:
115 $this->view();
116 break;
117 }
118 return true;
119 }
120
125 function getMode()
126 {
127 return $this->mode;
128 }
129
133 function explorer()
134 {
135 global $tpl;
136
137 include_once("./Services/Bookmarks/classes/class.ilBookmarkExplorerGUI.php");
138 $exp = new ilBookmarkExplorerGUI($this, "explorer");
139 if (!$exp->handleCommand())
140 {
141 $tpl->setLeftNavContent($exp->getHTML());
142 }
143 }
144
145
149 function displayHeader()
150 {
151 // output locator
152 $this->displayLocator();
153
154 // output message
155 if($this->message)
156 {
157 ilUtil::sendInfo($this->message);
158 }
160
161 $this->tpl->setTitle($this->lng->txt("bookmarks"));
162 }
163
164 /*
165 * display content of bookmark folder
166 */
167 function view()
168 {
169 global $ilToolbar;
170
171 if($this->id > 0 && !$this->tree->isInTree($this->id))
172 {
173 $this->ctrl->setParameter($this, 'bmf_id', '');
174 $this->ctrl->redirect($this);
175 }
176
177 $ilToolbar->addButton($this->lng->txt("bookmark_new"),
178 $this->ctrl->getLinkTarget($this, "newFormBookmark"));
179 $ilToolbar->addButton($this->lng->txt("bookmark_folder_new"),
180 $this->ctrl->getLinkTarget($this, "newFormBookmarkFolder"));
181
182 $objects = ilBookmarkFolder::getObjects($this->id);
183
184 include_once 'Services/Bookmarks/classes/class.ilBookmarkAdministrationTableGUI.php';
185 $table = new ilBookmarkAdministrationTableGUI($this);
186 $table->setId('bookmark_adm_table');
187 $table->setData($objects);
188 $this->tpl->setVariable("ADM_CONTENT", $table->getHTML());
189 }
190
194 function add_cell($val, $link = "")
195 {
196 if(!empty($link))
197 {
198 $this->tpl->setCurrentBlock("begin_link");
199 $this->tpl->setVariable("LINK_TARGET", $link);
200 $this->tpl->parseCurrentBlock();
201 $this->tpl->touchBlock("end_link");
202 }
203
204 $this->tpl->setCurrentBlock("text");
205 $this->tpl->setVariable("TEXT_CONTENT", $val);
206 $this->tpl->parseCurrentBlock();
207 $this->tpl->setCurrentBlock("table_cell");
208 $this->tpl->parseCurrentBlock();
209 }
210
214 function displayLocator()
215 {
216 global $lng;
217
218 if(empty($this->id))
219 {
220 return;
221 }
222
223 if(!$this->tree->isInTree($this->id))
224 {
225 return;
226 }
227
228 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html", "Services/Locator");
229
230 $path = $this->tree->getPathFull($this->id);
231//print_r($path);
232 $modifier = 1;
233
234 return;
235 $this->tpl->setVariable("TXT_LOCATOR", $this->lng->txt("locator"));
236 $this->tpl->touchBlock("locator_separator");
237 $this->tpl->touchBlock("locator_item");
238 //$this->tpl->setCurrentBlock("locator_item");
239 //$this->tpl->setVariable("ITEM", $this->lng->txt("personal_desktop"));
240 //$this->tpl->setVariable("LINK_ITEM", $this->ctrl->getLinkTargetByClass("ilpersonaldesktopgui"));
241 //$this->tpl->setVariable("LINK_TARGET","target=\"".
242 // ilFrameTargetInfo::_getFrame("MainContent")."\"");
243 //$this->tpl->parseCurrentBlock();
244
245 foreach($path as $key => $row)
246 {
247 if($key < count($path) - $modifier)
248 {
249 $this->tpl->touchBlock("locator_separator");
250 }
251
252 $this->tpl->setCurrentBlock("locator_item");
253 $title = ($row["child"] == 1) ?
254 $lng->txt("bookmarks") :
255 $row["title"];
256 $this->tpl->setVariable("ITEM", $title);
257 $this->ctrl->setParameter($this, "bmf_id", $row["child"]);
258 $this->tpl->setVariable("LINK_ITEM",
259 $this->ctrl->getLinkTarget($this));
260 $this->tpl->parseCurrentBlock();
261 }
262
263 $this->tpl->setCurrentBlock("locator");
264
265 $this->tpl->parseCurrentBlock();
266 }
267
271 function newForm($type)
272 {
273 if(!$type)
274 $type = $_POST["type"];
275 switch($type)
276 {
277 case "bmf":
278 $this->newFormBookmarkFolder();
279 break;
280
281 case "bm":
282 $this->newFormBookmark();
283 break;
284 }
285 }
286
291 {
292 if(!$this->tree->isInTree($this->id))
293 {
294 $this->ctrl->setParameter($this, 'bmf_id', '');
295 $this->ctrl->redirect($this);
296 }
297
298 $form = $this->initFormBookmarkFolder();
299 $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
300 }
301
306 private function initFormBookmarkFolder($action = 'createBookmarkFolder')
307 {
308 global $lng, $ilCtrl, $ilUser;
309
310 if(!$this->tree->isInTree($this->id))
311 {
312 $this->ctrl->setParameter($this, 'bmf_id', '');
313 $this->ctrl->redirect($this);
314 }
315
316 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
317 $form = new ilPropertyFormGUI();
318 $form->setTopAnchor("bookmark_top");
319
320 $form->setTitle($lng->txt("bookmark_folder_new"));
321
322 if($action == 'updateBookmarkFolder')
323 {
324 $ilCtrl->setParameter($this, 'bmf_id', $this->id);
325 $ilCtrl->setParameter($this, 'obj_id', $_GET["obj_id"]);
326 }
327
328 $hash = ($ilUser->prefs["screen_reader_optimization"])
329 ? "bookmark_top"
330 : "";
331
332 $form->setFormAction($ilCtrl->getFormAction($this, $action, $hash));
333
334 $ilCtrl->clearParameters($this);
335
336 // title
337 $prop = new ilTextInputGUI($lng->txt("title"), "title");
338 $prop->setRequired(true);
339 $form->addItem($prop);
340
341 // buttons
342 $form->addCommandButton($action, $lng->txt('save'));
343 $form->addCommandButton('cancel', $lng->txt('cancel'));
344 return $form;
345 }
346
351 {
352 if(!$this->tree->isInTree($_GET["obj_id"]))
353 {
354 $this->ctrl->setParameter($this, 'bmf_id', '');
355 $this->ctrl->setParameter($this, 'obj_id', '');
356 $this->ctrl->redirect($this);
357 }
358
359 $bmf = new ilBookmarkFolder($_GET["obj_id"]);
360 $form = $this->initFormBookmarkFolder('updateBookmarkFolder', $this->id);
361 $form->setValuesByArray
362 (
363 array
364 (
365 "title" => $this->get_last("title", $bmf->getTitle()),
366 "obj_id" => $_GET["obj_id"],
367 )
368 );
369 $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
370 }
371
372
377 private function initFormBookmark($action = 'createBookmark')
378 {
379 global $lng, $ilCtrl, $ilUser;
380
381 if(!$this->tree->isInTree($this->id))
382 {
383 $this->ctrl->setParameter($this, 'bmf_id', '');
384 $this->ctrl->redirect($this);
385 }
386
387 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
388 $form = new ilPropertyFormGUI();
389 $form->setTopAnchor("bookmark_top");
390
391 $form->setTitle($lng->txt("bookmark_new"));
392
393 if($action == 'updateBookmark')
394 {
395 $ilCtrl->setParameter($this, 'bmf_id', $this->id);
396 $ilCtrl->setParameter($this, 'obj_id', $_GET["obj_id"]);
397 }
398
399 $hash = ($ilUser->prefs["screen_reader_optimization"])
400 ? "bookmark_top"
401 : "";
402
403 $form->setFormAction($ilCtrl->getFormAction($this, $action, $hash));
404 $ilCtrl->clearParameters($this);
405 // title
406 $prop = new ilTextInputGUI($lng->txt("title"), "title");
407 $prop->setValue($_GET['bm_title']);
408 $prop->setRequired(true);
409 $form->addItem($prop);
410
411 // description
412 $prop = new ilTextAreaInputGUI($lng->txt('description'), 'description');
413 $form->addItem($prop);
414
415 // target link
416 $prop = new ilTextInputGUI($lng->txt('bookmark_target'), 'target');
417 $prop->setValue($_GET['bm_link']);
418 $prop->setRequired(true);
419 $form->addItem($prop);
420
421 // hidden redirect field
422 if($_GET['return_to'])
423 {
424 $prop = new ilHiddenInputGUI('return_to');
425 $prop->setValue($_GET['return_to']);
426 $form->addItem($prop);
427
428 $prop = new ilHiddenInputGUI('return_to_url');
429 if($_GET['return_to_url'])
430 $prop->setValue($_GET['return_to_url']);
431 else
432 $prop->setValue($_GET['bm_link']);
433 $form->addItem($prop);
434 }
435
436 // buttons
437 $form->addCommandButton($action, $lng->txt('save'));
438 $form->addCommandButton('cancel', $lng->txt('cancel'));
439
440 // keep imports?
441 /*
442 $this->tpl->setCurrentBlock('bkm_import');
443 $this->tpl->setVariable("TXT_IMPORT_BKM", $this->lng->txt("bkm_import"));
444 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("file_add"));
445 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
446 $this->tpl->parseCurrentBlock();
447 //vd($_POST);
448 */
449
450 return $form;
451 }
452
457 private function initImportBookmarksForm()
458 {
459 global $lng, $ilCtrl, $ilUser;
460
461 if(!$this->tree->isInTree($this->id))
462 {
463 $this->ctrl->setParameter($this, 'bmf_id', '');
464 $this->ctrl->redirect($this);
465 }
466
467 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
468 $form = new ilPropertyFormGUI();
469 $form->setFormAction($ilCtrl->getFormAction($this, "importFile")); // #16133
470 $form->setTopAnchor("bookmark_top");
471 $form->setTitle($lng->txt("bkm_import"));
472
473 $fi = new ilFileInputGUI($lng->txt("file_add"), "bkmfile");
474 $fi->setRequired(true);
475 $form->addItem($fi);
476
477 $form->addCommandButton("importFile", $lng->txt('import'));
478 $form->addCommandButton('cancel', $lng->txt('cancel'));
479
480 return $form;
481 }
482
487 {
488 $form = $this->initFormBookmark();
489 $html1 = $form->getHTML();
490 $html2 = '';
491 if(!$_REQUEST["bm_link"])
492 {
493 $form2 = $this->initImportBookmarksForm();
494 $html2 = "<br />" . $form2->getHTML();
495 }
496 $this->tpl->setVariable("ADM_CONTENT", $html1 . $html2);
497 }
498
499
503 function get_last($a_var, $a_value)
504 {
505 return (!empty($_POST[$a_var])) ?
506 ilUtil::prepareFormOutput(($_POST[$a_var]), true) :
508 }
509
514 {
515 global $lng, $ilCtrl;
516
517 if(!$this->tree->isInTree($_GET["obj_id"]))
518 {
519 $this->ctrl->setParameter($this, 'obj_id', '');
520 $this->ctrl->setParameter($this, 'bmf_id', '');
521 $this->ctrl->redirect($this);
522 }
523
524 $form = $this->initFormBookmark('updateBookmark');
525 $bookmark = new ilBookmark($_GET["obj_id"]);
526 $form->setValuesByArray
527 (
528 array
529 (
530 "title" => $bookmark->getTitle(),
531 "target" => $bookmark->getTarget(),
532 "description" => $bookmark->getDescription(),
533 "obj_id" => $_GET["obj_id"],
534 )
535 );
536 $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
537 }
538
539
544 {
545 if(!$this->tree->isInTree($this->id))
546 {
547 $this->ctrl->setParameter($this, 'bmf_id', '');
548 $this->ctrl->redirect($this);
549 }
550
551 // check title
552 if(empty($_POST["title"]))
553 {
554 ilUtil::sendFailure($this->lng->txt("please_enter_title"));
555 $this->newFormBookmarkFolder();
556 }
557 else
558 {
559 // create bookmark folder
560 $bmf = new ilBookmarkFolder();
561 $bmf->setTitle(ilUtil::stripSlashes($_POST["title"]));
562 $bmf->setParent($this->id);
563 $bmf->create();
564
565 ilUtil::sendSuccess($this->lng->txt("bkm_fold_created"), true);
566
567 global $ilCtrl;
568 $ilCtrl->saveParameter($this, 'bmf_id');
569 $ilCtrl->redirect($this, 'view');
570 }
571 }
572
573
578 {
579 if(!$this->tree->isInTree($_GET["obj_id"]))
580 {
581 $this->ctrl->setParameter($this, 'obj_id', '');
582 $this->ctrl->setParameter($this, 'bmf_id', '');
583 $this->ctrl->redirect($this);
584 }
585
586 // check title
587 if(empty($_POST["title"]))
588 {
589 ilUtil::sendFailure($this->lng->txt("please_enter_title"));
590 $this->editFormBookmarkFolder();
591 }
592 else
593 {
594 // update bookmark folder
595 $bmf = new ilBookmarkFolder($_GET["obj_id"]);
596 $bmf->setTitle(ilUtil::stripSlashes($_POST["title"]));
597 $bmf->update();
598
599 global $ilCtrl;
600 $ilCtrl->saveParameter($this, 'bmf_id');
601 $ilCtrl->redirect($this, 'view');
602 }
603 }
604
605
609 function createBookmark()
610 {
611 global $lng, $ilCtrl;
612
613 if(!$this->tree->isInTree($this->id))
614 {
615 $this->ctrl->setParameter($this, 'bmf_id', '');
616 $this->ctrl->redirect($this);
617 }
618
619 // check title and target
620 if(empty($_POST["title"]))
621 {
622 ilUtil::sendFailure($this->lng->txt("please_enter_title"));
623 $this->newFormBookmark();
624 }
625 else if(empty($_POST["target"]))
626 {
627 ilUtil::sendFailure($this->lng->txt("please_enter_target"));
628 $this->newFormBookmark();
629 }
630 else
631 {
632 // create bookmark
633 $bm = new ilBookmark();
634 $bm->setTitle(ilUtil::stripSlashes($_POST["title"]));
635 $bm->setDescription(ilUtil::stripSlashes($_POST["description"]));
636 $bm->setTarget(ilUtil::stripSlashes($_POST["target"]));
637 $bm->setParent($this->id);
638 $bm->create();
639
640 ilUtil::sendInfo($lng->txt('bookmark_added'), true);
641
642 $ilCtrl->saveParameter($this, 'bmf_id');
643 $ilCtrl->redirect($this, 'view');
644 }
645 }
646
650 function updateBookmark()
651 {
652 if(!$this->tree->isInTree($_GET["obj_id"]))
653 {
654 $this->ctrl->setParameter($this, 'obj_id', '');
655 $this->ctrl->setParameter($this, 'bmf_id', '');
656 $this->ctrl->redirect($this);
657 }
658
659 // check title and target
660 if(empty($_POST["title"]))
661 {
662 ilUtil::sendFailure($this->lng->txt("please_enter_title"));
663 $this->editFormBookmark();
664 }
665 else if(empty($_POST["target"]))
666 {
667 ilUtil::sendFailure($this->lng->txt("please_enter_target"));
668 $this->editFormBookmark();
669 }
670 else
671 {
672 // update bookmark
673 $bm = new ilBookmark($_GET["obj_id"]);
674 $bm->setTitle(ilUtil::stripSlashes($_POST["title"]));
675 $bm->setTarget(ilUtil::stripSlashes($_POST["target"]));
676 $bm->setDescription(ilUtil::stripSlashes($_POST["description"]));
677 $bm->update();
678
679 $this->view();
680 }
681 }
682
686 function export($deliver = true)
687 {
688 $bm_ids = $_GET['bm_id'] ? array($_GET['bm_id']) : $_POST['bm_id'];
689 if(!$bm_ids)
690 {
691 $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
692 }
693 $export_ids = array();
694 foreach($bm_ids as $id)
695 {
696 if($this->tree->isInTree($id))
697 {
698 //list($type, $obj_id) = explode(":", $id);
699 //$export_ids[]=$obj_id;
700 $export_ids[] = $id;
701 }
702 }
703
704 require_once ("./Services/Bookmarks/classes/class.ilBookmarkImportExport.php");
705 $html_content = ilBookmarkImportExport::_exportBookmark($export_ids, true,
706 $this->lng->txt("bookmarks_of") . " " . $this->ilias->account->getFullname());
707
708 if($deliver)
709 {
710 ilUtil::deliverData($html_content, 'bookmarks.html', "application/save", $charset = "");
711 }
712 else
713 {
714 return $html_content;
715 }
716 }
717
721 function sendmail()
722 {
723 global $ilUser;
724 include_once './Services/Mail/classes/class.ilFileDataMail.php';
725 require_once "Services/Mail/classes/class.ilFormatMail.php";
726 $mfile = new ilFileDataMail($ilUser->getId());
727 $umail = new ilFormatMail($ilUser->getId());
728
729 $html_content = $this->export(false);
730 $tempfile = ilUtil::ilTempnam();
731 $fp = fopen($tempfile, 'w');
732 fwrite($fp, $html_content);
733 fclose($fp);
734 $filename = 'bookmarks.html';
735 $mfile->copyAttachmentFile($tempfile, $filename);
736 $umail->savePostData($ilUser->getId(), array($filename),
737 '', '', '', '', '',
738 '',
739 '', 0);
740
741 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
742 ilUtil::redirect(ilMailFormCall::getRedirectTarget($this, '', array(), array('type' => 'attach')));
743 }
744
748 function delete()
749 {
750 $bm_ids = $_GET['bm_id'] ? array($_GET['bm_id']) : $_POST['bm_id'];
751 if(!$bm_ids)
752 {
753 $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
754 }
755
756 $this->ctrl->setParameter($this, "bmf_id", $this->id);
757
758 // display confirmation message
759 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
760 $cgui = new ilConfirmationGUI();
761 $cgui->setFormAction($this->ctrl->getFormAction($this));
762 $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
763 $cgui->setCancel($this->lng->txt("cancel"), "cancel");
764 $cgui->setConfirm($this->lng->txt("confirm"), "confirm");
765
766 foreach($bm_ids as $obj_id)
767 {
768 $type = ilBookmark::_getTypeOfId($obj_id);
769
770 if(!$this->tree->isInTree($obj_id))
771 {
772 continue;
773 }
774
775 switch($type)
776 {
777 case "bmf":
778 $BookmarkFolder = new ilBookmarkFolder($obj_id);
779 $title = $BookmarkFolder->getTitle();
780 $target = "";
781 unset($BookmarkFolder);
782 break;
783
784 case "bm":
785 $Bookmark = new ilBookmark($obj_id);
786 $title = $Bookmark->getTitle();
787 $target = $Bookmark->getTarget();
788 unset($Bookmark);
789 break;
790 }
791
792 $caption = ilUtil::getImageTagByType($type, $this->tpl->tplPath) .
793 " " . $title;
794 if($target)
795 {
796 $caption .= " (" . ilUtil::shortenText($target, $this->textwidth, true) . ")";
797 }
798
799 $cgui->addItem("id[]", $obj_id, $caption);
800 }
801
802 $this->tpl->setContent($cgui->getHTML());
803 }
804
808 function cancel()
809 {
810 $this->view();
811 }
812
816 function confirm()
817 {
818 global $tree, $rbacsystem, $rbacadmin;
819 // AT LEAST ONE OBJECT HAS TO BE CHOSEN.
820 if(!$_POST["id"])
821 {
822 $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
823 }
824
825 // FOR ALL SELECTED OBJECTS
826 foreach($_POST["id"] as $id)
827 {
829
830 // get node data and subtree nodes
831 if($this->tree->isInTree($id))
832 {
833 $node_data = $this->tree->getNodeData($id);
834 $subtree_nodes = $this->tree->getSubTree($node_data);
835 }
836 else
837 {
838 continue;
839 }
840
841 // delete tree
842 $this->tree->deleteTree($node_data);
843
844 // delete objects of subtree nodes
845 foreach($subtree_nodes as $node)
846 {
847 switch($node["type"])
848 {
849 case "bmf":
850 $BookmarkFolder = new ilBookmarkFolder($node["obj_id"]);
851 $BookmarkFolder->delete();
852 break;
853
854 case "bm":
855 $Bookmark = new ilBookmark($node["obj_id"]);
856 $Bookmark->delete();
857 break;
858 }
859 }
860 }
861
862 // Feedback
863 ilUtil::sendSuccess($this->lng->txt("info_deleted"), true);
864
865 $this->view();
866 }
867
868
873 {
874 $actions = array(
875 "delete" => $this->lng->txt("delete"),
876 "export" => $this->lng->txt("export"),
877 "sendmail"=> $this->lng->txt("bkm_sendmail"),
878 );
879
880 $subobj = array("bm", "bmf");
881
882 if(is_array($subobj))
883 {
884 //build form
885 $opts = ilUtil::formSelect("", "type", $subobj);
886
887 $this->tpl->setCurrentBlock("add_object");
888 $this->tpl->setVariable("COLUMN_COUNTS", 7);
889 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
890 $this->tpl->setVariable("BTN_NAME", "newForm");
891 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
892 $this->tpl->parseCurrentBlock();
893 }
894
895 $this->tpl->setVariable("TPLPATH", $this->tpl->tplPath);
896
897 $this->tpl->setCurrentBlock("tbl_action_select");
898 $this->tpl->setVariable("SELECT_ACTION", ilUtil::formSelect($_SESSION["error_post_vars"]['action'], "action", $actions, false, true));
899 $this->tpl->setVariable("BTN_NAME", "executeAction");
900 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("execute"));
901
902 /*
903 $this->tpl->setVariable("BTN_NAME","delete");
904 $this->tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
905 $this->tpl->parseCurrentBlock();
906
907 $this->tpl->setVariable("BTN_NAME","export");
908 $this->tpl->setVariable("BTN_VALUE",$this->lng->txt("export"));
909 $this->tpl->parseCurrentBlock();
910 */
911 $this->tpl->parseCurrentBlock();
912
913 }
914
918 function getHTML()
919 {
920 include_once("./Services/Bookmarks/classes/class.ilBookmarkBlockGUI.php");
921 $bookmark_block_gui = new ilBookmarkBlockGUI("ilpersonaldesktopgui", "show");
922
923 return $bookmark_block_gui->getHTML();
924 }
925
932 function importFile()
933 {
934 if(!$this->tree->isInTree($this->id))
935 {
936 $this->ctrl->setParameter($this, 'bmf_id', '');
937 $this->ctrl->redirect($this);
938 }
939
940 if($_FILES["bkmfile"]["error"] > UPLOAD_ERR_OK)
941 {
942 ilUtil::sendFailure($this->lng->txt("import_file_not_valid"));
943 $this->newFormBookmark();
944 return;
945 }
946 require_once ("./Services/Bookmarks/classes/class.ilBookmarkImportExport.php");
947 $objects = ilBookmarkImportExport::_parseFile($_FILES["bkmfile"]['tmp_name']);
948 if($objects === false)
949 {
950 ilUtil::sendFailure($this->lng->txt("import_file_not_valid"));
951 $this->newFormBookmark();
952 return;
953 }
954 // holds the number of created objects
955 $num_create = array('bm'=> 0, 'bmf'=> 0);
956 $this->__importBookmarks($objects, $num_create, $this->id, 0);
957
958 ilUtil::sendSuccess(sprintf($this->lng->txt("bkm_import_ok"), $num_create['bm'],
959 $num_create['bmf']));
960 $this->view();
961
962
963 }
964
973 function __importBookmarks(&$objects, &$num_create, $folder_id, $start_key = 0)
974 {
975 if(is_array($objects[$start_key]))
976 {
977 foreach($objects[$start_key] as $obj_key=> $object)
978 {
979 switch($object['type'])
980 {
981 case 'bm':
982 if(!$object["title"]) continue;
983 if(!$object["target"]) continue;
984 $bm = new ilBookmark();
985 $bm->setTitle($object["title"]);
986 $bm->setDescription($object["description"]);
987 $bm->setTarget($object["target"]);
988 $bm->setParent($folder_id);
989 $bm->create();
990 $num_create['bm']++;
991 break;
992 case 'bmf':
993 if(!$object["title"]) continue;
994 $bmf = new ilBookmarkFolder();
995 $bmf->setTitle($object["title"]);
996 $bmf->setParent($folder_id);
997 $bmf->create();
998 $num_create['bmf']++;
999 if(is_array($objects[$obj_key]))
1000 {
1001 $this->__importBookmarks($objects, $num_create,
1002 $bmf->getId(), $obj_key);
1003 }
1004 break;
1005 }
1006 }
1007 }
1008 }
1009
1010 function move()
1011 {
1012 global $ilUser, $ilTabs, $tpl;
1013
1014 $bm_ids = $_REQUEST['bm_id'];
1015 if(!$bm_ids && $_GET["bm_id_tgt"] == "")
1016 {
1017 ilUtil::sendFailure($this->lng->txt("no_checkbox"));
1018 return $this->view();
1019 }
1020
1021 $ilTabs->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this));
1022
1023 $this->ctrl->setParameter($this, "bm_id_tgt", $_GET["bm_id_tgt"] ? $_GET["bm_id_tgt"] : implode(";", $bm_ids));
1024 ilUtil::sendInfo($this->lng->txt("bookmark_select_target"));
1025 include_once("./Services/Bookmarks/classes/class.ilBookmarkMoveExplorerGUI.php");
1026 $exp = new ilBookmarkMoveExplorerGUI($this, "move");
1027 if (!$exp->handleCommand())
1028 {
1029 $this->mode = "flat";
1030 $this->tpl->setContent($exp->getHTML());
1031 }
1032 }
1033
1034 function confirmedMove()
1035 {
1036 global $ilUser;
1037
1038 $tgt = (int)$_REQUEST["bmfmv_id"];
1039 $bm_ids = explode(";", $_REQUEST['bm_id_tgt']);
1040 if(!$bm_ids || !$tgt)
1041 {
1042 ilUtil::sendFailure($this->lng->txt("no_checkbox"));
1043 return $this->view();
1044 }
1045
1046 $tree = new ilTree($ilUser->getId());
1047 $tree->setTableNames('bookmark_tree', 'bookmark_data');
1048
1049 $tgt_node = $tree->getNodeData($tgt);
1050
1051 // sanity check
1052 foreach($bm_ids as $node_id)
1053 {
1054 if($tree->isGrandChild($node_id, $tgt))
1055 {
1056 ilUtil::sendFailure($this->lng->txt("error"), true);
1057 $this->ctrl->redirect($this, "view");
1058 }
1059
1060 $node = $tree->getNodeData($node_id);
1061
1062 // already at correct position
1063 if($node["parent"] == $tgt)
1064 {
1065 continue;
1066 }
1067
1068 $tree->moveTree($node_id, $tgt);
1069 }
1070
1071 ilUtil::sendSuccess($this->lng->txt("bookmark_moved_ok"), true);
1072 $this->ctrl->setParameter($this, "bmf_id", $tgt);
1073 $this->ctrl->redirect($this, "view");
1074 }
1075}
$filename
Definition: buildRTE.php:89
$_GET["client_id"]
$_SESSION["AccountId"]
GUI class for personal bookmark administration.
showPossibleSubObjects()
display subobject addition selection
explorer()
output explorer tree with bookmark folders
__importBookmarks(&$objects, &$num_create, $folder_id, $start_key=0)
creates the bookmarks and folders
getMode()
return display mode flat or tree
newFormBookmarkFolder()
display new bookmark folder form
editFormBookmarkFolder()
display edit bookmark folder form
importFile()
imports a bookmark file into database display status information or report errors messages in case of...
createBookmarkFolder()
create new bookmark folder in db
confirm()
deletion confirmed -> delete folders / bookmarks
initFormBookmarkFolder($action='createBookmarkFolder')
init bookmark folder create/edit form
initFormBookmark($action='createBookmark')
init Bookmark create/edit form
ilBookmarkAdministrationGUI()
Constructor @access public.
cancel()
cancel deletion,insert, update
get_last($a_var, $a_value)
get stored post var in case of an error/warning otherwise return passed value
initImportBookmarksForm()
Init import bookmark form.
getHTML()
Get Bookmark list for personal desktop.
add_cell($val, $link="")
output a cell in object list
BlockGUI class for Bookmarks block.
Bookmark explorer GUI class.
bookmark folder (note: this class handles personal bookmarks folders only)
_parseFile($file)
parse Bookmark file static method returns 3 dimensional array of bookmarks and folders
_exportBookmark($obj_ids, $recursive=true, $title='')
export bookmarks static method return html string
Class Bookmarks Bookmark management.
static _getTypeOfId($a_id)
get type of a given id
Confirmation screen class.
This class handles all operations on files (attachments) in directory ilias_data/mail.
This class represents a file property in a property form.
Class UserMail this class handles user mails.
This class represents a hidden form property in a property form.
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
This class represents a property form user interface.
This class represents a text area property in a property form.
This class represents a text property in a property form.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static getImageTagByType($a_type, $a_path, $a_big=false)
Builds an html image tag TODO: function still in use, but in future use getImagePath and move HTML-Co...
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
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.
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static infoPanel($a_keep=true)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$_POST['username']
Definition: cron.php:12
$html1
$html2
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
$cmd
Definition: sahs_server.php:35
$path
Definition: index.php:22
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
global $ilUser
Definition: imgupload.php:15