• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/PersonalDesktop/classes/class.ilBookmarkAdministrationGUI.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004         +-----------------------------------------------------------------------------+
00005         | ILIAS open source                                                           |
00006         +-----------------------------------------------------------------------------+
00007         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00008         |                                                                             |
00009         | This program is free software; you can redistribute it and/or               |
00010         | modify it under the terms of the GNU General Public License                 |
00011         | as published by the Free Software Foundation; either version 2              |
00012         | of the License, or (at your option) any later version.                      |
00013         |                                                                             |
00014         | This program is distributed in the hope that it will be useful,             |
00015         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00016         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00017         | GNU General Public License for more details.                                |
00018         |                                                                             |
00019         | You should have received a copy of the GNU General Public License           |
00020         | along with this program; if not, write to the Free Software                 |
00021         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00022         +-----------------------------------------------------------------------------+
00023 */
00024 
00037 require_once ("./Services/PersonalDesktop/classes/class.ilBookmarkExplorer.php");
00038 require_once ("./Services/PersonalDesktop/classes/class.ilBookmarkFolder.php");
00039 require_once ("./Services/PersonalDesktop/classes/class.ilBookmark.php");
00040 require_once ("./Services/Table/classes/class.ilTableGUI.php");
00041 
00042 class ilBookmarkAdministrationGUI
00043 {
00049         var $user_id;
00050 
00056         var $ilias;
00057         var $tpl;
00058         var $lng;
00059 
00060         var $tree;
00061         var $id;
00062         var $data;
00063         var $textwidth=100;
00064 
00070         function ilBookmarkAdministrationGUI()
00071         {
00072                 global $ilias, $tpl, $lng, $ilCtrl;
00073                 //print_r($_SESSION["error_post_vars"]);
00074                 // if no bookmark folder id is given, take dummy root node id (that is 1)
00075                 $this->id = (empty($_GET["bmf_id"]))
00076                         ? $bmf_id = 1
00077                         : $_GET["bmf_id"];
00078 
00079                 // initiate variables
00080                 $this->ilias =& $ilias;
00081                 $this->tpl =& $tpl;
00082                 $this->lng =& $lng;
00083                 $this->ctrl =& $ilCtrl;
00084                 $this->ctrl->setParameter($this, "bmf_id", $this->id);
00085                 $this->user_id = $_SESSION["AccountId"];
00086 
00087                 $this->tree = new ilTree($_SESSION["AccountId"]);
00088                 $this->tree->setTableNames('bookmark_tree','bookmark_data');
00089                 $this->root_id = $this->tree->readRootId();
00090                 // set current bookmark view mode
00091                 if (!empty($_GET["set_mode"]))
00092                 {
00093                         $this->ilias->account->writePref("il_bkm_mode", $_GET["set_mode"]);
00094                 }
00095                 $this->mode = $this->ilias->account->getPref("il_bkm_mode");
00096         }
00097 
00101         function &executeCommand()
00102         {
00103                 $next_class = $this->ctrl->getNextClass();
00104 
00105                 switch($next_class)
00106                 {
00107                         default:
00108                                 $cmd = $this->ctrl->getCmd("view");
00109                                 $this->displayHeader();
00110                                 $this->$cmd();
00111                                 if ($this->getMode() == 'tree')
00112                                 {
00113                                         $this->explorer();
00114                                 }
00115                                 break;
00116                 }
00117                 $this->tpl->show(true);
00118                 return true;
00119         }
00120         function executeAction()
00121         {
00122                 switch($_POST["action"])
00123                 {
00124                         case "delete":
00125                                 $this->delete();
00126                                 break;
00127                         case "export":
00128                                 $this->export();
00129                                 break;
00130                         case "sendmail":
00131                                 $this->sendmail();
00132                                 break;
00133                         default:
00134                                 $this->view();
00135                                 break;
00136                 }
00137                 return true;
00138         }
00139 
00144         function getMode() {
00145                 return $this->mode;
00146         }
00147 
00151         function explorer()
00152         {
00153                 $this->tpl->setCurrentBlock("left_column");
00154                 $this->tpl->addBlockFile("LEFT_CONTENT", "adm_tree_content", "tpl.bookmark_explorer.html");
00155                 $exp = new ilBookmarkExplorer($this->ctrl->getLinkTarget($this),$_SESSION["AccountId"]);
00156                 $exp->setAllowedTypes(array('dum','bmf'));
00157                 $exp->setTargetGet("bmf_id");
00158                 $exp->setSessionExpandVariable('mexpand');
00159                 $this->ctrl->setParameter($this, "bmf_id", $this->id);
00160                 $exp->setExpandTarget($this->ctrl->getLinkTarget($this));
00161                 if ($_GET["mexpand"] == "")
00162                 {
00163                         $mtree = new ilTree($_SESSION["AccountId"]);
00164                         $mtree->setTableNames('bookmark_tree','bookmark_data');
00165                         $expanded = $mtree->readRootId();
00166                 }
00167                 else
00168                 {
00169                         $expanded = $_GET["mexpand"];
00170                 }
00171 
00172                 $exp->setExpand($expanded);
00173 
00174                 // build html-output
00175                 $exp->setOutput(0);
00176                 $output = $exp->getOutput();
00177 
00178                 $this->tpl->setCurrentBlock("adm_tree_content");
00179                 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("bookmarks"));
00180                 $this->ctrl->setParameter($this, "bmf_id", 1);
00181                 $this->tpl->setVariable("LINK_EXPLORER_HEADER",$this->ctrl->getLinkTarget($this));
00182 
00183                 $this->tpl->setVariable("EXPLORER",$output);
00184                 $this->tpl->parseCurrentBlock();
00185         }
00186 
00187 
00191         function displayHeader()
00192         {
00193                 // output locator
00194                 $this->displayLocator();
00195 
00196                 // output message
00197                 if($this->message)
00198                 {
00199                         ilUtil::sendInfo($this->message);
00200                 }
00201                 ilUtil::infoPanel();
00202 
00203                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"),
00204                         $this->lng->txt("personal_desktop"));
00205                 $this->tpl->setTitle($this->lng->txt("personal_desktop"));
00206         }
00207 
00208         /*
00209         * display content of bookmark folder
00210         */
00211         function view()
00212         {
00213                 global $tree;
00214 
00215                 include_once("classes/class.ilFrameTargetInfo.php");
00216                 
00217                 if ($this->id > 0 && !$this->tree->isInTree($this->id))
00218                 {
00219                         return;
00220                 }
00221                 
00222                 $mtree = new ilTree($_SESSION["AccountId"]);
00223                 $mtree->setTableNames('bookmark_tree','bookmark_data');
00224 
00225                 $this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.table.html");
00226 
00227                 $this->ctrl->setParameter($this, "bmf_id", $this->id);
00228                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00229 
00230                 $objects = ilBookmarkFolder::getObjects($this->id);
00231 
00232                 $s_mode = ($this->mode == "tree")
00233                                 ? "flat"
00234                                 : "tree";
00235                 $this->tpl->setCurrentBlock("tree_mode");
00236                 $this->ctrl->setParameter($this, "bmf_id", $this->id);
00237                 $this->tpl->setTreeFlatIcon($this->ctrl->getLinkTarget($this)."&set_mode=".$s_mode,
00238                         $s_mode);
00239                 $this->tpl->parseCurrentBlock();
00240 
00241 
00242                 $this->tpl->setCurrentBlock("objects");
00243                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.bookmark_row.html");
00244                 $cnt = 0;
00245 
00246                 // return to parent folder
00247                 if ($this->id != $mtree->readRootId() || $this->id =="")
00248                 {
00249                         $this->tpl->setCurrentBlock("tbl_content");
00250 
00251                         // color changing
00252                         $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
00253 
00254                         $this->tpl->setVariable("CHECKBOX", "&nbsp;");
00255                         $this->tpl->setVariable("ROWCOL", $css_row);
00256 
00257                         $val = ilUtil::getImagePath("icon_cat.gif");
00258                         $this->tpl->setVariable("IMG", $val);
00259                         $this->tpl->setVariable("ALT_IMG", $this->lng->txt("bmf"));
00260 
00261                         // title
00262                         $this->ctrl->setParameter($this, "bmf_id", $mtree->getParentId($this->id));
00263                         $link = $this->ctrl->getLinkTarget($this);
00264                         $this->tpl->setVariable("TXT_TITLE", "..");
00265                         $this->tpl->setVariable("LINK_TARGET", $link);
00266                         $this->tpl->setVariable("FRAME_TARGET", ilFrameTargetInfo::_getFrame("MainContent"));
00267 
00268                         $this->tpl->parseCurrentBlock();
00269                 }
00270                 // all checkbox ids
00271                 $a_ids=array();
00272                 foreach ($objects as $key => $object)
00273                 {
00274                         $a_ids[]=$object["type"].":".$object["obj_id"];
00275                         // type icon
00276                         $this->ctrl->setParameter($this, "bmf_id", $this->id);
00277                         $this->ctrl->setParameter($this, "obj_id", $object["obj_id"]);
00278                         $link = ($object["type"] == "bmf")
00279                                 ? $this->ctrl->getLinkTarget($this, "editFormBookmarkFolder")
00280                                 : $this->ctrl->getLinkTarget($this, "editFormBookmark");
00281 
00282 
00283 
00284                         // edit link
00285                         $this->tpl->setCurrentBlock("edit");
00286                         $this->tpl->setVariable("TXT_EDIT", $this->lng->txt("edit"));
00287                         $this->tpl->setVariable("LINK_EDIT", $link);
00288                         $this->tpl->parseCurrentBlock();
00289                         // target
00290                         if (!empty($object["target"]))
00291                         {
00292                                 $this->tpl->setCurrentBlock("target");
00293                                 $this->tpl->setVariable("TXT_TARGET",
00294                                         ilUtil::prepareFormOutput(ilUtil::shortenText(
00295                                                 $object["target"],$this->textwidth, true)));
00296                                 $this->tpl->setVariable("LINK_TARGET", $object["target"]);
00297                                 $this->tpl->parseCurrentBlock();
00298                         }
00299                         // description
00300                         if (!empty($object["description"]))
00301                         {
00302                                 $this->tpl->setCurrentBlock("description");
00303                                 $this->tpl->setVariable("TXT_DESCRIPTION",
00304                                         ilUtil::prepareFormOutput($object["description"]));
00305                                 $this->tpl->parseCurrentBlock();
00306                         }
00307 
00308                         $this->tpl->setCurrentBlock("tbl_content");
00309                         // color changing
00310                         $css_row = ilUtil::switchColor($cnt++,"tblrow1","tblrow2");
00311 
00312                         // surpress checkbox for particular object types
00313                         //$this->tpl->setVariable("CHECKBOX_ID", $object["type"].":".$object["obj_id"]);
00314                         $this->tpl->setVariable("CHECKBOX",
00315                                 ilUtil::formCheckBox("", "id[]", $object["type"].":".$object["obj_id"]));
00316                         $this->tpl->setVariable("ROWCOL", $css_row);
00317 
00318                         $img_type = ($object["type"] == "bmf") ? "cat" : $object["type"];
00319                         $val = ilUtil::getImagePath("icon_".$img_type.".gif");
00320                         $this->tpl->setVariable("IMG", $val);
00321                         $this->tpl->setVariable("ALT_IMG", $this->lng->txt($object["type"]));
00322 
00323                         // title
00324                         $this->ctrl->setParameter($this, "bmf_id", $object["obj_id"]);
00325                         $link = ($object["type"] == "bmf") ?
00326                                 $this->ctrl->getLinkTarget($this) :
00327                                 $object["target"];
00328                         $this->tpl->setVariable("TXT_TITLE", ilUtil::prepareFormOutput($object["title"]));
00329                         $this->tpl->setVariable("LINK_TARGET", $link);
00330 
00331                         if ($object["type"] == "bmf")
00332                         {
00333                                 $this->tpl->setVariable("FRAME_TARGET", ilFrameTargetInfo::_getFrame("MainContent"));
00334                         }
00335                         else
00336                         {
00337                                 $this->tpl->setVariable("FRAME_TARGET", ilFrameTargetInfo::_getFrame("ExternalContent"));
00338                         }
00339 
00340 
00341                         $this->tpl->parseCurrentBlock();
00342                 }
00343 
00344                 $tbl = new ilTableGUI();
00345 
00346                 if (!empty($this->id) && $this->id != 1)
00347                 {
00348                         $BookmarkFolder = new ilBookmarkFolder($this->id);
00349                         $addstr = " ".$this->lng->txt("in")." ".$BookmarkFolder->getTitle();
00350                 }
00351                 else
00352                 {
00353                         $addstr = "";
00354                 }
00355 
00356                 // title & header columns
00357                 $tbl->setTitle($this->lng->txt("bookmarks").$addstr,
00358                         "icon_bm.gif", $this->lng->txt("bookmarks"));
00359                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00360                 $tbl->setHeaderNames(array("", $this->lng->txt("type"), $this->lng->txt("title"),""));
00361                 $tbl->setHeaderVars(array("", "type", "title","commands"),
00362                         array("bmf_id" => $this->id));
00363                 $tbl->setColumnWidth(array("1%", "1%", "100%", ""));
00364 
00365                 //$tbl->setOrderColumn($_GET["sort_by"]);
00366                 //$tbl->setOrderDirection($_GET["sort_order"]);
00367                 $tbl->setLimit($limit);
00368                 $tbl->setOffset($offset);
00369                 $tbl->setMaxCount($maxcount);
00370 
00371                 $tbl->enable("select_all");
00372                 $tbl->setFormName("cmd");
00373                 $tbl->setSelectAllCheckbox("id");
00374                 
00375                 // footer
00376                 $tbl->setFooter("tblfooter", $this->lng->txt("previous"),$this->lng->txt("next"));
00377                 //$tbl->disable("content");
00378                 $tbl->disable("footer");
00379                 $tbl->disable("header");
00380 
00381                 // render table
00382                 $tbl->render();
00383 
00384                 // SHOW POSSIBLE SUB OBJECTS
00385                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00386                 $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
00387                 $this->tpl->setVariable("NUM_COLS", 5);
00388                 $this->showPossibleSubObjects();
00389 
00390                 $this->tpl->setCurrentBlock("tbl_action_row");
00391                 $this->tpl->setVariable("COLUMN_COUNTS",4);
00392                 $this->tpl->parseCurrentBlock();
00393 
00394         }
00395 
00399         function add_cell($val, $link = "")
00400         {
00401                 if (!empty($link))
00402                 {
00403                         $this->tpl->setCurrentBlock("begin_link");
00404                         $this->tpl->setVariable("LINK_TARGET", $link);
00405                         $this->tpl->parseCurrentBlock();
00406                         $this->tpl->touchBlock("end_link");
00407                 }
00408 
00409                 $this->tpl->setCurrentBlock("text");
00410                 $this->tpl->setVariable("TEXT_CONTENT", $val);
00411                 $this->tpl->parseCurrentBlock();
00412                 $this->tpl->setCurrentBlock("table_cell");
00413                 $this->tpl->parseCurrentBlock();
00414         }
00415 
00419         function displayLocator()
00420         {
00421                 global $lng;
00422 
00423                 if (empty($this->id))
00424                 {
00425                         return;
00426                 }
00427                 
00428                 if (!$this->tree->isInTree($this->id))
00429                 {
00430                         return;
00431                 }
00432 
00433                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00434 
00435                 $path = $this->tree->getPathFull($this->id);
00436 //print_r($path);
00437                 $modifier = 1;
00438 
00439 return;
00440                 $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
00441                 $this->tpl->touchBlock("locator_separator");
00442                 $this->tpl->touchBlock("locator_item");
00443                 //$this->tpl->setCurrentBlock("locator_item");
00444                 //$this->tpl->setVariable("ITEM", $this->lng->txt("personal_desktop"));
00445                 //$this->tpl->setVariable("LINK_ITEM", $this->ctrl->getLinkTargetByClass("ilpersonaldesktopgui"));
00446                 //$this->tpl->setVariable("LINK_TARGET","target=\"".
00447                 //      ilFrameTargetInfo::_getFrame("MainContent")."\"");
00448                 //$this->tpl->parseCurrentBlock();
00449 
00450                 foreach ($path as $key => $row)
00451                 {
00452                         if ($key < count($path)-$modifier)
00453                         {
00454                                 $this->tpl->touchBlock("locator_separator");
00455                         }
00456 
00457                         $this->tpl->setCurrentBlock("locator_item");
00458                         $title = ($row["child"] == 1) ?
00459                                 $lng->txt("bookmarks") :
00460                                 $row["title"];
00461                         $this->tpl->setVariable("ITEM", $title);
00462                         $this->ctrl->setParameter($this, "bmf_id", $row["child"]);
00463                         $this->tpl->setVariable("LINK_ITEM",
00464                                 $this->ctrl->getLinkTarget($this));
00465                         $this->tpl->parseCurrentBlock();
00466                 }
00467 
00468                 $this->tpl->setCurrentBlock("locator");
00469 
00470                 $this->tpl->parseCurrentBlock();
00471         }
00472 
00476         function newForm()
00477         {
00478                 switch($_POST["type"])
00479                 {
00480                         case "bmf":
00481                                 $this->newFormBookmarkFolder();
00482                                 break;
00483 
00484                         case "bm":
00485                                 $this->newFormBookmark();
00486                                 break;
00487                 }
00488         }
00489 
00493         function newFormBookmarkFolder()
00494         {
00495                 global $lng;
00496 
00497                 if (!$this->tree->isInTree($this->id))
00498                 {
00499                         return;
00500                 }
00501 
00502                 $this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.bookmark_newfolder.html");
00503                 $this->tpl->setVariable("TITLE", $this->get_last("title", ""));
00504                 $this->tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00505                 $this->tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00506                 $this->tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
00507                 $this->tpl->setVariable("TXT_FOLDER_NEW", $lng->txt("bookmark_folder_new"));
00508                 $this->ctrl->setParameter($this, "bmf_id", $this->id);
00509                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00510                 $this->tpl->setVariable("VAL_CMD", "createBookmarkFolder");
00511                 $this->tpl->parseCurrentBlock();
00512         }
00513 
00514 
00518         function editFormBookmarkFolder()
00519         {
00520                 global $lng;
00521                 
00522                 if (!$this->tree->isInTree($_GET["obj_id"]))
00523                 {
00524                         return;
00525                 }
00526 
00527                 $this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.bookmark_newfolder.html");
00528 
00529                 $bmf = new ilBookmarkFolder($_GET["obj_id"]);
00530 
00531                 $this->tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00532                 $this->tpl->setVariable("TITLE", $this->get_last("title", $bmf->getTitle()));
00533                 $this->tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00534                 $this->tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
00535                 $this->tpl->setVariable("TXT_FOLDER_NEW", $lng->txt("bookmark_folder_edit"));
00536                 $this->tpl->setVariable("VAL_CMD", "updateBookmarkFolder");
00537                 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
00538                 $this->ctrl->setParameter($this, "bmf_id", $this->id);
00539                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00540 
00541         }
00542 
00543 
00547         function newFormBookmark()
00548         {
00549                 global $lng;
00550                 
00551                 if (!$this->tree->isInTree($this->id))
00552                 {
00553                         return;
00554                 }
00555 
00556 
00557                 $this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.bookmark_new.html");
00558                 $this->tpl->setVariable("TXT_BOOKMARK_NEW", $lng->txt("bookmark_new"));
00559                 $this->tpl->setVariable("TXT_TARGET", $lng->txt("bookmark_target"));
00560                 $this->tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00561                 $this->tpl->setVariable("TXT_DESCRIPTION", $lng->txt("description"));
00562 
00563                 $this->tpl->setVariable("TITLE", $this->get_last("title", ""));
00564                 $this->tpl->setVariable("TARGET", $this->get_last("target", "http://"));
00565                 $this->tpl->setVariable("DESCRIPTION",$this->get_last("description", ""));
00566                 $this->tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00567                 $this->tpl->setVariable("VAL_CMD", "createBookmark");
00568                 $this->tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
00569 
00570                 $this->ctrl->setParameter($this, "bmf_id", $this->id);
00571                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00572                 $this->tpl->parseCurrentBlock();
00573 
00574 
00575                 $this->tpl->setCurrentBlock('bkm_import');
00576                 $this->tpl->setVariable("TXT_IMPORT_BKM", $this->lng->txt("bkm_import"));
00577                 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("file_add"));
00578                 $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
00579                 $this->tpl->parseCurrentBlock();
00580                 //vd($_POST);
00581         }
00582 
00583 
00587         function get_last($a_var, $a_value)
00588         {
00589                         return  (!empty($_POST[$a_var])) ?
00590                                 ilUtil::prepareFormOutput(($_POST[$a_var]),true) :
00591                                 ilUtil::prepareFormOutput($a_value);
00592         }
00593 
00597         function editFormBookmark()
00598         {
00599                 global $lng;
00600 
00601                 if (!$this->tree->isInTree($_GET["obj_id"]))
00602                 {
00603                         return;
00604                 }
00605                 $this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.bookmark_new.html");
00606 
00607                 $this->tpl->setVariable("TXT_BOOKMARK_NEW", $lng->txt("bookmark_edit"));
00608                 $this->tpl->setVariable("TXT_TARGET", $lng->txt("bookmark_target"));
00609                 $this->tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00610                 $this->tpl->setVariable("TXT_DESCRIPTION", $lng->txt("description"));
00611 
00612                 $Bookmark = new ilBookmark($_GET["obj_id"]);
00613                 $this->tpl->setVariable("TITLE", $this->get_last("title", $Bookmark->getTitle()));
00614                 $this->tpl->setVariable("TARGET", $this->get_last("target", $Bookmark->getTarget()));
00615                 $this->tpl->setVariable("DESCRIPTION", $this->get_last("description", $Bookmark->getDescription()));
00616 
00617                 $this->tpl->setVariable("TXT_SAVE", $lng->txt("save"));
00618                 $this->tpl->setVariable("VAL_CMD", "updateBookmark");
00619                 $this->tpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
00620                 $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
00621                 $this->ctrl->setParameter($this, "bmf_id", $this->id);
00622                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00623 
00624                 $this->tpl->parseCurrentBlock();
00625         }
00626 
00627 
00631         function createBookmarkFolder()
00632         {
00633                 if (!$this->tree->isInTree($this->id))
00634                 {
00635                         return;
00636                 }
00637 
00638                 // check title
00639                 if (empty($_POST["title"]))
00640                 {
00641                         ilUtil::sendInfo($this->lng->txt("please_enter_title"));
00642                         $this->newFormBookmarkFolder();
00643                 }
00644                 else
00645                 {
00646                         // create bookmark folder
00647                         $bmf = new ilBookmarkFolder();
00648                         $bmf->setTitle(ilUtil::stripSlashes($_POST["title"]));
00649                         $bmf->setParent($this->id);
00650                         $bmf->create();
00651 
00652                         $this->view();
00653                 }
00654         }
00655 
00656 
00660         function updateBookmarkFolder()
00661         {
00662                 if (!$this->tree->isInTree($_GET["obj_id"]))
00663                 {
00664                         return;
00665                 }
00666 
00667                 // check title
00668                 if (empty($_POST["title"]))
00669                 {
00670                         ilUtil::sendInfo($this->lng->txt("please_enter_title"));
00671                         $this->editFormBookmarkFolder();
00672                 }
00673                 else
00674                 {
00675                         // update bookmark folder
00676                         $bmf = new ilBookmarkFolder($_GET["obj_id"]);
00677                         $bmf->setTitle(ilUtil::stripSlashes($_POST["title"]));
00678                         $bmf->update();
00679 
00680                         $this->view();
00681                 }
00682         }
00683 
00684 
00688         function createBookmark()
00689         {
00690                 if (!$this->tree->isInTree($this->id))
00691                 {
00692                         return;
00693                 }
00694 
00695                 // check title and target
00696                 if (empty($_POST["title"]))
00697                 {
00698                         ilUtil::sendInfo($this->lng->txt("please_enter_title"));
00699                         $this->newFormBookmark();
00700                 }
00701                 else if (empty($_POST["target"]))
00702                 {
00703                         ilUtil::sendInfo($this->lng->txt("please_enter_target"));
00704                         $this->newFormBookmark();
00705                 }
00706                 else
00707                 {
00708                         // create bookmark
00709                         $bm = new ilBookmark();
00710                         $bm->setTitle(ilUtil::stripSlashes($_POST["title"]));
00711                         $bm->setDescription(ilUtil::stripSlashes($_POST["description"]));
00712                         $bm->setTarget(ilUtil::stripSlashes($_POST["target"]));
00713                         $bm->setParent($this->id);
00714                         $bm->create();
00715 
00716                         $this->view();
00717                 }
00718         }
00719 
00723         function updateBookmark()
00724         {
00725                 if (!$this->tree->isInTree($_GET["obj_id"]))
00726                 {
00727                         return;
00728                 }
00729 
00730                 // check title and target
00731                 if (empty($_POST["title"]))
00732                 {
00733                         ilUtil::sendInfo($this->lng->txt("please_enter_title"));
00734                         $this->editFormBookmark();
00735                 }
00736                 else if (empty($_POST["target"]))
00737                 {
00738                         ilUtil::sendInfo($this->lng->txt("please_enter_target"));
00739                         $this->editFormBookmark();
00740                 }
00741                 else
00742                 {
00743                         // update bookmark
00744                         $bm = new ilBookmark($_GET["obj_id"]);
00745                         $bm->setTitle(ilUtil::stripSlashes($_POST["title"]));
00746                         $bm->setTarget(ilUtil::stripSlashes($_POST["target"]));
00747                         $bm->setDescription(ilUtil::stripSlashes($_POST["description"]));
00748                         $bm->update();
00749 
00750                         $this->view();
00751                 }
00752         }
00753 
00757         function export($deliver=true)
00758         {
00759                 if (!isset($_POST["id"]))
00760                 {
00761                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00762                 }
00763                 $export_ids=array();
00764                 foreach($_POST["id"] as $id)
00765                 {
00766                         if ($this->tree->isInTree($id))
00767                         {
00768                                 list($type, $obj_id) = explode(":", $id);
00769                                 $export_ids[]=$obj_id;
00770                         }
00771                 }
00772                 require_once ("./Services/PersonalDesktop/classes/class.ilBookmarkImportExport.php");
00773                 $html_content=ilBookmarkImportExport::_exportBookmark ($export_ids,true,
00774                         $this->lng->txt("bookmarks_of")." ".$this->ilias->account->getFullname());
00775                 if ($deliver)
00776                 {
00777                         ilUtil::deliverData($html_content, 'bookmarks.html', "application/save", $charset = "");
00778                 }
00779                 else
00780                 {
00781                         return $html_content;
00782                 }
00783         }
00787         function sendmail()
00788         {
00789                 global $ilUser;
00790                 include_once 'classes/class.ilFileDataMail.php';
00791                 require_once "Services/Mail/classes/class.ilFormatMail.php";
00792                 $mfile = new ilFileDataMail($ilUser->getId());
00793                 $umail = new ilFormatMail($ilUser->getId());
00794 
00795 
00796                 $html_content=$this->export(false);
00797                 $tempfile=ilUtil::ilTempnam();
00798                 $fp=fopen($tempfile,'w');
00799                 fwrite($fp, $html_content);
00800                 fclose($fp);
00801                 $filename='bookmarks.html';
00802                 $mfile->copyAttachmentFile($tempfile,$filename);
00803                 $umail->savePostData($ilUser->getId(),array($filename),
00804                                                  '','','','','',
00805                                                  '',
00806                                                  '', 0);
00807                 ilUtil::redirect('ilias.php?baseClass=ilMailGUI&type=attach');
00808         }
00812         function delete()
00813         {
00814                 if (!isset($_POST["id"]))
00815                 {
00816                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00817                 }
00818 
00819                 $this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.obj_confirm.html");
00820 
00821                 ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
00822                 $this->ctrl->setParameter($this, "bmf_id", $this->id);
00823                 $this->tpl->setVariable("FORMACTION",
00824                         $this->ctrl->getFormAction($this));
00825 
00826                 // output table header
00827                 $cols = array("type", "title");
00828                 foreach ($cols as $key)
00829                 {
00830                         $this->tpl->setCurrentBlock("table_header");
00831                         $this->tpl->setVariable("TEXT",$this->lng->txt($key));
00832                         $this->tpl->parseCurrentBlock();
00833                 }
00834 
00835                 $_SESSION["saved_post"] = $_POST["id"];
00836 
00837                 foreach($_POST["id"] as $id)
00838                 {
00839 
00840                         list($type, $obj_id) = explode(":", $id);
00841                         if (!$this->tree->isInTree($obj_id))
00842                         {
00843                                 continue;
00844                         }
00845                         switch($type)
00846                         {
00847                                 case "bmf":
00848                                         $BookmarkFolder = new ilBookmarkFolder($obj_id);
00849                                         $title = $BookmarkFolder->getTitle();
00850                                         $target = "";
00851                                         unset($BookmarkFolder);
00852                                         break;
00853 
00854                                 case "bm":
00855                                         $Bookmark = new ilBookmark($obj_id);
00856                                         $title = $Bookmark->getTitle();
00857                                         $target = $Bookmark->getTarget();
00858                                         unset($Bookmark);
00859                                         break;
00860                         }
00861 
00862                         // output type icon
00863                         $this->tpl->setCurrentBlock("table_cell");
00864                         $this->tpl->setVariable("TEXT_CONTENT",ilUtil::getImageTagByType($type, $this->tpl->tplPath));
00865                         $this->tpl->parseCurrentBlock();
00866 
00867                         // output title
00868                         $this->tpl->setCurrentBlock("table_cell");
00869                         $this->tpl->setVariable("TEXT_CONTENT",ilUtil::prepareFormOutput($title));
00870 
00871                         // output target
00872                         if ($target)
00873                         {
00874                                 $this->tpl->setVariable("DESC",ilUtil::prepareFormOutput(ilUtil::shortenText(
00875                                         $target,$this->textwidth, true)));
00876                         }
00877                         $this->tpl->parseCurrentBlock();
00878 
00879                         // output table row
00880                         $this->tpl->setCurrentBlock("table_row");
00881                         $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
00882                         $this->tpl->parseCurrentBlock();
00883                 }
00884 
00885                 // cancel and confirm button
00886                 $buttons = array( "cancel"  => $this->lng->txt("cancel"),
00887                         "confirm"  => $this->lng->txt("confirm"));
00888 
00889                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00890                 foreach($buttons as $name => $value)
00891                 {
00892                         $this->tpl->setCurrentBlock("operation_btn");
00893                         $this->tpl->setVariable("BTN_NAME",$name);
00894                         $this->tpl->setVariable("BTN_VALUE",$value);
00895                         $this->tpl->parseCurrentBlock();
00896                 }
00897         }
00898 
00902         function cancel()
00903         {
00904                 session_unregister("saved_post");
00905                 $this->view();
00906         }
00907 
00911         function confirm()
00912         {
00913                 global $tree, $rbacsystem, $rbacadmin, $objDefinition;
00914 
00915                 // AT LEAST ONE OBJECT HAS TO BE CHOSEN.
00916                 if (!isset($_SESSION["saved_post"]))
00917                 {
00918                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00919                 }
00920 
00921                 // FOR ALL SELECTED OBJECTS
00922                 foreach ($_SESSION["saved_post"] as $id)
00923                 {
00924                         list($type, $id) = explode(":", $id);
00925 
00926                         // get node data and subtree nodes
00927                         if ($this->tree->isInTree($id))
00928                         {
00929                                 $node_data = $this->tree->getNodeData($id);
00930                                 $subtree_nodes = $this->tree->getSubTree($node_data);
00931                         }
00932                         else
00933                         {
00934                                 continue;
00935                         }
00936 
00937                         // delete tree
00938                         $this->tree->deleteTree($node_data);
00939 
00940                         // delete objects of subtree nodes
00941                         foreach ($subtree_nodes as $node)
00942                         {
00943                                 switch ($node["type"])
00944                                 {
00945                                         case "bmf":
00946                                                 $BookmarkFolder = new ilBookmarkFolder($node["obj_id"]);
00947                                                 $BookmarkFolder->delete();
00948                                                 break;
00949 
00950                                         case "bm":
00951                                                 $Bookmark = new ilBookmark($node["obj_id"]);
00952                                                 $Bookmark->delete();
00953                                                 break;
00954                                 }
00955                         }
00956                 }
00957 
00958                 // Feedback
00959                 ilUtil::sendInfo($this->lng->txt("info_deleted"),true);
00960 
00961                 $this->view();
00962         }
00963 
00964 
00965 
00969         function showActions()
00970         {
00971                 global $objDefinition;
00972 
00973                 $notoperations = array();
00974                 // NO PASTE AND CLEAR IF CLIPBOARD IS EMPTY
00975                 if (empty($_SESSION["clipboard"]))
00976                 {
00977                         $notoperations[] = "paste";
00978                         $notoperations[] = "clear";
00979                 }
00980                 // CUT COPY PASTE LINK DELETE IS NOT POSSIBLE IF CLIPBOARD IS FILLED
00981                 if ($_SESSION["clipboard"])
00982                 {
00983                         $notoperations[] = "cut";
00984                         $notoperations[] = "copy";
00985                         $notoperations[] = "link";
00986                 }
00987 
00988                 $operations = array();
00989 
00990                 $d = $objDefinition->getActions("bmf");
00991 
00992                 foreach ($d as $row)
00993                 {
00994                         if (!in_array($row["name"], $notoperations))
00995                         {
00996                                 $operations[] = $row;
00997                         }
00998                 }
00999 
01000                 if (count($operations)>0)
01001                 {
01002                         foreach ($operations as $val)
01003                         {
01004                                 $this->tpl->setCurrentBlock("operation_btn");
01005                                 $this->tpl->setVariable("BTN_NAME", $val["lng"]);
01006                                 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
01007                                 $this->tpl->parseCurrentBlock();
01008                         }
01009 
01010                         $this->tpl->setCurrentBlock("operation");
01011                         $this->tpl->parseCurrentBlock();
01012                 }
01013         }
01014 
01018         function showPossibleSubObjects()
01019         {
01020                 global $objDefinition;
01021                 $d = $objDefinition->getCreatableSubObjects("bmf");
01022                 $actions = array(
01023                                 "delete"=>$this->lng->txt("delete"),
01024                                 "export"=>$this->lng->txt("export"),
01025                                 "sendmail"=>$this->lng->txt("bkm_sendmail"),
01026                 );
01027 
01028                 if (count($d) > 0)
01029                 {
01030                         foreach ($d as $row)
01031                         {
01032                                 $count = 0;
01033                                 if ($row["max"] > 0)
01034                                 {
01035                                         //how many elements are present?
01036                                         for ($i=0; $i<count($this->data["ctrl"]); $i++)
01037                                         {
01038                                                 if ($this->data["ctrl"][$i]["type"] == $row["name"])
01039                                                 {
01040                                                         $count++;
01041                                                 }
01042                                         }
01043                                 }
01044                                 if ($row["max"] == "" || $count < $row["max"])
01045                                 {
01046                                         $subobj[] = $row["name"];
01047                                 }
01048                         }
01049                 }
01050 
01051                 if (is_array($subobj))
01052                 {
01053                         //build form
01054                         $opts = ilUtil::formSelect("","type",$subobj);
01055 
01056                         $this->tpl->setCurrentBlock("add_object");
01057                         $this->tpl->setVariable("COLUMN_COUNTS", 7);
01058                         $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
01059                         $this->tpl->setVariable("BTN_NAME", "newForm");
01060                         $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
01061                         $this->tpl->parseCurrentBlock();
01062                 }
01063 
01064                 $this->tpl->setVariable("TPLPATH",$this->tpl->tplPath);
01065 
01066                 $this->tpl->setCurrentBlock("tbl_action_select");
01067                 $this->tpl->setVariable("SELECT_ACTION",ilUtil::formSelect($_SESSION["error_post_vars"]['action'],"action",$actions,false,true));
01068                 $this->tpl->setVariable("BTN_NAME","executeAction");
01069                 $this->tpl->setVariable("BTN_VALUE",$this->lng->txt("execute"));
01070 
01071                 /*
01072                 $this->tpl->setVariable("BTN_NAME","delete");
01073                 $this->tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
01074                 $this->tpl->parseCurrentBlock();
01075 
01076                 $this->tpl->setVariable("BTN_NAME","export");
01077                 $this->tpl->setVariable("BTN_VALUE",$this->lng->txt("export"));
01078                 $this->tpl->parseCurrentBlock();
01079                 */
01080                 $this->tpl->parseCurrentBlock();
01081 
01082         }
01083 
01087         function &getHTML()
01088         {
01089                 include_once("./Services/PersonalDesktop/classes/class.ilBookmarkBlockGUI.php");
01090                 $bookmark_block_gui = new ilBookmarkBlockGUI("ilpersonaldesktopgui", "show");
01091                 
01092                 return $bookmark_block_gui->getHTML();
01093         }
01094 
01102         function importFile()
01103         {
01104                 if (!$this->tree->isInTree($this->id))
01105                 {
01106                         return;
01107                 }
01108 
01109                 if ($_FILES["bkmfile"]["error"] > UPLOAD_ERR_OK)
01110                 {
01111                         ilUtil::sendInfo($this->lng->txt("import_file_not_valid"));
01112                         $this->newFormBookmark();
01113                         return;
01114                 }
01115                 require_once ("./Services/PersonalDesktop/classes/class.ilBookmarkImportExport.php");
01116                 $objects=ilBookmarkImportExport::_parseFile ($_FILES["bkmfile"]['tmp_name']);
01117                 if ($objects===false)
01118                 {
01119                         ilUtil::sendInfo($this->lng->txt("import_file_not_valid"));
01120                         $this->newFormBookmark();
01121                         return;
01122                 }
01123                 // holds the number of created objects
01124                 $num_create=array('bm'=>0,'bmf'=>0);
01125                 $this->__importBookmarks($objects,$num_create,$this->id,0);
01126 
01127                 ilUtil::sendInfo(sprintf($this->lng->txt("bkm_import_ok"),$num_create['bm'],
01128                         $num_create[ 'bmf']));
01129                 $this->view();
01130 
01131 
01132         }
01141         function __importBookmarks(&$objects,&$num_create,$folder_id,$start_key=0)
01142         {
01143                 if (is_array($objects[$start_key]))
01144                 {
01145                         foreach ($objects[$start_key] as $obj_key=>$object)
01146                         {
01147                                 switch ($object['type'])
01148                                 {
01149                                         case 'bm':
01150                                                 if (!$object["title"]) continue;
01151                                                 if (!$object["target"]) continue;
01152                                                 $bm = new ilBookmark();
01153                                                 $bm->setTitle($object["title"]);
01154                                                 $bm->setDescription($object["description"]);
01155                                                 $bm->setTarget($object["target"]);
01156                                                 $bm->setParent($folder_id);
01157                                                 $bm->create();
01158                                                 $num_create['bm']++;
01159                                         break;
01160                                         case 'bmf':
01161                                                 if (!$object["title"]) continue;
01162                                                 $bmf = new ilBookmarkFolder();
01163                                                 $bmf->setTitle($object["title"]);
01164                                                 $bmf->setParent($folder_id);
01165                                                 $bmf->create();
01166                                                 $num_create['bmf']++;
01167                                                 if (is_array($objects[$obj_key]))
01168                                                 {
01169                                                         $this->__importBookmarks($objects,$num_create,
01170                                                                 $bmf->getId(),$obj_key);
01171                                                 }
01172                                         break;
01173                                 }
01174                         }
01175                 }
01176         }
01177 
01178 }
01179 ?>

Generated on Fri Dec 13 2013 17:57:00 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1