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

Modules/LearningModule/classes/class.ilEditClipboardGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
00025 
00037 class ilEditClipboardGUI
00038 {
00039         var $ilias;
00040         var $tpl;
00041         var $lng;
00042         var $ctrl;
00043 
00048         function ilEditClipboardGUI()
00049         {
00050                 global $ilias, $tpl, $lng, $ilCtrl;
00051 
00052                 $this->ctrl =& $ilCtrl;
00053                 $this->ilias =& $ilias;
00054                 $this->tpl =& $tpl;
00055                 $this->lng =& $lng;
00056                 $this->multiple = false;
00057                 $this->page_back_title = $lng->txt("cont_back");
00058                 if ($_GET["returnCommand"] != "")
00059                 {
00060                         $this->mode = "getObject";
00061                 }
00062                 else
00063                 {
00064                         $this->mode = "";
00065                 }
00066 
00067                 $this->ctrl->saveParameter($this, array("clip_mob_id", "returnCommand"));
00068         }
00069 
00075         function _forwards()
00076         {
00077                 return array("ilObjMediaObjectGUI");
00078         }
00079 
00083         function &executeCommand()
00084         {
00085                 // get next class that processes or forwards current command
00086                 $next_class = $this->ctrl->getNextClass($this);
00087 
00088                 // get current command
00089                 $cmd = $this->ctrl->getCmd();
00090 
00091                 switch($next_class)
00092                 {
00093                         case "ilobjmediaobjectgui":
00094 //echo "<br>calling objmediaomjgui";
00095                                 $this->ctrl->setReturn($this, "view");
00096                                 require_once("classes/class.ilTabsGUI.php");
00097                                 #$tabs_gui =& new ilTabsGUI();
00098                                 $mob_gui =& new ilObjMediaObjectGUI("", $_GET["clip_mob_id"],false, false);
00099                                 //$mob_gui->getTabs($tabs_gui);
00100                                 $mob_gui->setAdminTabs();
00101                                 //$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00102                                 //$ret =& $mob_gui->executeCommand();
00103                                 $ret =& $this->ctrl->forwardCommand($mob_gui);
00104                                 switch($cmd)
00105                                 {
00106                                         case "save":
00107                                                 $this->ilias->account->addObjectToClipboard($ret->getId(), "mob", $ret->getTitle());
00108                                                 $this->ctrl->redirect($this, "view");
00109                                                 break;
00110                                 }
00111                                 break;
00112 
00113 
00114                         default:
00115                                 $ret =& $this->$cmd();
00116                                 break;
00117                 }
00118 
00119                 return $ret;
00120         }
00121         
00125         function setMultipleSelections($a_multiple = true)
00126         {
00127                 $this->multiple = $a_multiple;
00128         }
00129 
00133         function getMultipleSelections()
00134         {
00135                 return $this->multiple;
00136         }
00137 
00138         /*
00139         * display clipboard content
00140         */
00141         function view()
00142         {
00143                 global $tree;
00144 
00145                 $this->setTabs();
00146                 
00147                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00148 //echo "HH";
00149                 // create mob form button
00150                 if ($this->mode != "getObject")
00151                 {
00152                         $this->tpl->setCurrentBlock("btn_cell");
00153                         $this->tpl->setVariable("BTN_LINK",
00154                                 $this->ctrl->getLinkTargetByClass("ilobjmediaobjectgui", "create"));
00155                         $this->tpl->setVariable("BTN_TXT",$this->lng->txt("cont_create_mob"));
00156                         $this->tpl->parseCurrentBlock();
00157                 }
00158 
00159 
00160                 include_once "./Services/Table/classes/class.ilTableGUI.php";           
00161                 
00162 //echo ":".$_GET["returnCommand"].":";
00163                 // load template for table
00164                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00165 
00166                 // load template for table content data
00167                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.clipboard_tbl_row.html", "Modules/LearningModule");
00168 
00169                 $num = 0;
00170 
00171                 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
00172                 if ($this->mode == "getObject")
00173                 {
00174                         $this->ctrl->setParameter($this, "returnCommand",
00175                                 rawurlencode($_GET["returnCommand"]));
00176                 }
00177                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00178 
00179                 // create table
00180                 $tbl = new ilTableGUI();
00181 
00182                 // title & header columns
00183                 $tbl->setTitle($this->lng->txt("objs_mob"));
00184                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00185 
00186                 $tbl->setHeaderNames(array("", "", $this->lng->txt("cont_object")));
00187                 $tbl->disable("sort");
00188 
00189                 $cols = array("", "", "title");
00190                 $header_params = $this->ctrl->getParameterArray($this, "view");
00191                 $tbl->setHeaderVars($cols, $header_params);
00192                 $tbl->setColumnWidth(array("1%","1%","98%"));
00193 
00194                 // control
00195                 $tbl->setOrderColumn($_GET["sort_by"]);
00196                 $tbl->setOrderDirection($_GET["sort_order"]);
00197                 $tbl->setLimit($_GET["limit"]);
00198                 $tbl->setOffset($_GET["offset"]);
00199                 $tbl->setMaxCount($this->maxcount);             // ???
00200                 //$tbl->setMaxCount(30);                // ???
00201 
00202                 $this->tpl->setVariable("COLUMN_COUNTS", 3);
00203 
00204                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00205                 if ($this->mode != "getObject")
00206                 {
00207                         // delete button
00208                         $this->tpl->setCurrentBlock("tbl_action_btn");
00209                         $this->tpl->setVariable("BTN_NAME", "remove");
00210                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("remove"));
00211                         $this->tpl->parseCurrentBlock();
00212 
00213                         // add list
00214                         /*
00215                         $opts = ilUtil::formSelect("","new_type",array("mob" => "mob"));
00216                         $this->tpl->setCurrentBlock("add_object");
00217                         $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
00218                         $this->tpl->setVariable("BTN_NAME", "createMediaInClipboard");
00219                         $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
00220                         $this->tpl->parseCurrentBlock();*/
00221                 }
00222                 else
00223                 {
00224                         // insert button
00225                         $this->tpl->setCurrentBlock("tbl_action_btn");
00226                         $this->tpl->setVariable("BTN_NAME", "insert");
00227                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("insert"));
00228                         $this->tpl->parseCurrentBlock();
00229                 }
00230 
00231                 // footer
00232                 //
00233                 //$tbl->disable("footer");
00234 
00235                 $objs = $this->ilias->account->getClipboardObjects("mob");
00236                 $objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
00237                 $tbl->setMaxCount(count($objs));
00238                 $objs = array_slice($objs, $_GET["offset"], $_GET["limit"]);
00239                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00240 
00241                 $tbl->render();
00242                 if(count($objs) > 0)
00243                 {
00244                         $i=0;
00245                         foreach($objs as $obj)
00246                         {
00247                                 // output thumbnail
00248                                 $mob =& new ilObjMediaObject($obj["id"]);
00249                                 $med =& $mob->getMediaItem("Standard");
00250                                 $target = $med->getThumbnailTarget();
00251                                 if ($target != "")
00252                                 {
00253                                         $this->tpl->setCurrentBlock("thumbnail");
00254                                         $this->tpl->setVariable("IMG_THUMB", $target);
00255                                         $this->tpl->parseCurrentBlock();
00256                                 }
00257 
00258                                 // allow editing of media objects
00259                                 if ($this->mode != "getObject")
00260                                 {                                       
00261                                         // output edit link
00262                                         $this->tpl->setCurrentBlock("edit");
00263                                         $this->ctrl->setParameter($this, "clip_mob_id", $obj["id"]);
00264                                         $this->tpl->setVariable("EDIT_LINK",
00265                                                 $this->ctrl->getLinkTargetByClass("ilObjMediaObjectGUI", "edit",
00266                                                         array("ilEditClipboardGUI")));
00267                                         $this->tpl->setVariable("TEXT_OBJECT", $obj["title"].
00268                                                 " [".$obj["id"]."]");
00269                                         $this->tpl->parseCurrentBlock();
00270                                 }
00271                                 else            // just list elements for selection
00272                                 {
00273                                         $this->tpl->setCurrentBlock("show");
00274                                         $this->tpl->setVariable("TEXT_OBJECT2", $obj["title"].
00275                                                 " [".$obj["id"]."]");
00276                                         $this->tpl->parseCurrentBlock();
00277                                 }
00278                                 
00279                                 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
00280                                 $this->tpl->setVariable("MEDIA_INFO",
00281                                         ilObjMediaObjectGUI::_getMediaInfoHTML($mob));
00282 
00283                                 $this->tpl->setCurrentBlock("tbl_content");
00284                                 $css_row = ilUtil::switchColor($i++,"tblrow1","tblrow2");
00285                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00286                                 $this->tpl->setVariable("CHECKBOX_ID", $obj["id"]);
00287                                 $this->tpl->parseCurrentBlock();
00288                         }
00289                 } //if is_array
00290                 else
00291                 {
00292                         $this->tpl->setCurrentBlock("notfound");
00293                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00294                         $this->tpl->setVariable("NUM_COLS", $num);
00295                         $this->tpl->parseCurrentBlock();
00296                 }
00297 
00298         }
00299 
00300 
00304         function getObject()
00305         {
00306                 $this->mode = "getObject";
00307                 $this->view();
00308         }
00309 
00310 
00314         function remove()
00315         {
00316                 // check number of objects
00317                 if (!isset($_POST["id"]))
00318                 {
00319                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00320                 }
00321 
00322                 foreach($_POST["id"] AS $obj_id)
00323                 {
00324                         $this->ilias->account->removeObjectFromClipboard($obj_id, "mob");
00325                         include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
00326                         $mob = new ilObjMediaObject($obj_id);
00327                         $mob->delete();                 // this method don't delete, if mob is used elsewhere
00328                 }
00329                 $this->ctrl->redirect($this, "view");
00330         }
00331 
00335         function insert()
00336         {
00337                 // check number of objects
00338                 if (!isset($_POST["id"]))
00339                 {
00340                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00341                 }
00342                 
00343                 if (!$this->getMultipleSelections())
00344                 {
00345                         if(count($_POST["id"]) > 1)
00346                         {
00347                                 $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
00348                         }
00349                 }
00350 
00351                 $_SESSION["ilEditClipboard_mob_id"] = $_POST["id"];
00352                 ilUtil::redirect(ilUtil::appendUrlParameterString(
00353                         $_GET["returnCommand"], "clip_obj_type=mob&clip_obj_id=".$_POST["id"][0]));
00354         }
00355         
00356         function _getSelectedIDs()
00357         {
00358                 return $_SESSION["ilEditClipboard_mob_id"];
00359         }
00360 
00364         function setTabs()
00365         {
00366                 global $ilTabs;
00367 
00368                 //$this->tpl->setCurrentBlock("header_image");
00369                 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_clip_b.gif"));
00370                 //$this->tpl->parseCurrentBlock();
00371                 $this->tpl->setTitle($this->lng->txt("clipboard"));
00372                 $this->tpl->stopTitleFloating();
00373 
00374                 // catch feedback message
00375                 #include_once("classes/class.ilTabsGUI.php");
00376                 #$tabs_gui =& new ilTabsGUI();
00377                 $this->getTabs($ilTabs);
00378                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00379         }
00380         
00381         function setPageBackTitle($a_title)
00382         {
00383                 $this->page_back_title = $a_title;
00384         }
00385 
00391         function getTabs(&$tabs_gui)
00392         {
00393                 if ($this->mode == "getObject")
00394                 {
00395                         // back to upper context
00396                         $tabs_gui->setBackTarget($this->page_back_title,
00397                                 $_GET["returnCommand"]);
00398                 }
00399                 else
00400                 {
00401                         // back to upper context
00402                         $tabs_gui->setBackTarget($this->page_back_title,
00403                                 $this->ctrl->getParentReturn($this));
00404                 }
00405         }
00406 
00407 }
00408 ?>

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