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

content/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("content/classes/Media/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                 if ($_GET["returnCommand"] != "")
00058                 {
00059                         $this->mode = "getObject";
00060                 }
00061                 else
00062                 {
00063                         $this->mode = "";
00064                 }
00065 
00066                 $this->ctrl->saveParameter($this, array("clip_mob_id", "returnCommand"));
00067         }
00068 
00074         function _forwards()
00075         {
00076                 return array("ilObjMediaObjectGUI");
00077         }
00078 
00082         function &executeCommand()
00083         {
00084                 // get next class that processes or forwards current command
00085                 $next_class = $this->ctrl->getNextClass($this);
00086 
00087                 // get current command
00088                 $cmd = $this->ctrl->getCmd();
00089 
00090                 switch($next_class)
00091                 {
00092                         case "ilobjmediaobjectgui":
00093 //echo "<br>calling objmediaomjgui";
00094                                 $this->ctrl->setReturn($this, "view");
00095                                 require_once("classes/class.ilTabsGUI.php");
00096                                 $tabs_gui =& new ilTabsGUI();
00097                                 $mob_gui =& new ilObjMediaObjectGUI("", $_GET["clip_mob_id"],false, false);
00098                                 //$mob_gui->getTabs($tabs_gui);
00099                                 $mob_gui->setAdminTabs();
00100                                 //$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00101                                 //$ret =& $mob_gui->executeCommand();
00102                                 $ret =& $this->ctrl->forwardCommand($mob_gui);
00103                                 switch($cmd)
00104                                 {
00105                                         case "save":
00106                                                 $this->ilias->account->addObjectToClipboard($ret->getId(), "mob", $ret->getTitle());
00107                                                 $this->ctrl->redirect($this, "view");
00108                                                 break;
00109                                 }
00110                                 break;
00111 
00112 
00113                         default:
00114                                 $ret =& $this->$cmd();
00115                                 break;
00116                 }
00117 
00118                 return $ret;
00119         }
00120         
00124         function setMultipleSelections($a_multiple = true)
00125         {
00126                 $this->multiple = $a_multiple;
00127         }
00128 
00132         function getMultipleSelections()
00133         {
00134                 return $this->multiple;
00135         }
00136 
00137         /*
00138         * display clipboard content
00139         */
00140         function view()
00141         {
00142                 global $tree;
00143 
00144                 $this->setTabs();
00145                 
00146                 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00147 //echo "HH";
00148                 // create mob form button
00149                 if ($this->mode != "getObject")
00150                 {
00151                         $this->tpl->setCurrentBlock("btn_cell");
00152                         $this->tpl->setVariable("BTN_LINK",
00153                                 $this->ctrl->getLinkTargetByClass("ilobjmediaobjectgui", "create"));
00154                         $this->tpl->setVariable("BTN_TXT",$this->lng->txt("cont_create_mob"));
00155                         $this->tpl->parseCurrentBlock();
00156                 }
00157 
00158 
00159                 include_once "./classes/class.ilTableGUI.php";          
00160                 
00161 //echo ":".$_GET["returnCommand"].":";
00162                 // load template for table
00163                 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00164 
00165                 // load template for table content data
00166                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.clipboard_tbl_row.html", "content");
00167 
00168                 $num = 0;
00169 
00170                 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
00171                 if ($this->mode == "getObject")
00172                 {
00173                         $this->ctrl->setParameter($this, "returnCommand",
00174                                 rawurlencode($_GET["returnCommand"]));
00175                 }
00176                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00177 
00178                 // create table
00179                 $tbl = new ilTableGUI();
00180 
00181                 // title & header columns
00182                 $tbl->setTitle($this->lng->txt("objs_mob"));
00183                 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
00184 
00185                 $tbl->setHeaderNames(array("", "", $this->lng->txt("cont_object")));
00186 
00187                 $cols = array("", "", "title");
00188                 $header_params = $this->ctrl->getParameterArray($this, "view");
00189                 $tbl->setHeaderVars($cols, $header_params);
00190                 $tbl->setColumnWidth(array("1%","1%","98%"));
00191 
00192                 // control
00193                 $tbl->setOrderColumn($_GET["sort_by"]);
00194                 $tbl->setOrderDirection($_GET["sort_order"]);
00195                 $tbl->setLimit($_GET["limit"]);
00196                 $tbl->setOffset($_GET["offset"]);
00197                 $tbl->setMaxCount($this->maxcount);             // ???
00198                 //$tbl->setMaxCount(30);                // ???
00199 
00200                 $this->tpl->setVariable("COLUMN_COUNTS", 3);
00201 
00202                 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00203                 if ($this->mode != "getObject")
00204                 {
00205                         // delete button
00206                         $this->tpl->setCurrentBlock("tbl_action_btn");
00207                         $this->tpl->setVariable("BTN_NAME", "remove");
00208                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("remove"));
00209                         $this->tpl->parseCurrentBlock();
00210 
00211                         // add list
00212                         /*
00213                         $opts = ilUtil::formSelect("","new_type",array("mob" => "mob"));
00214                         $this->tpl->setCurrentBlock("add_object");
00215                         $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
00216                         $this->tpl->setVariable("BTN_NAME", "createMediaInClipboard");
00217                         $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
00218                         $this->tpl->parseCurrentBlock();*/
00219                 }
00220                 else
00221                 {
00222                         // insert button
00223                         $this->tpl->setCurrentBlock("tbl_action_btn");
00224                         $this->tpl->setVariable("BTN_NAME", "insert");
00225                         $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("insert"));
00226                         $this->tpl->parseCurrentBlock();
00227                 }
00228 
00229                 // footer
00230                 //
00231                 //$tbl->disable("footer");
00232 
00233                 $objs = $this->ilias->account->getClipboardObjects("mob");
00234                 $objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
00235                 $tbl->setMaxCount(count($objs));
00236                 $objs = array_slice($objs, $_GET["offset"], $_GET["limit"]);
00237                 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00238 
00239                 $tbl->render();
00240                 if(count($objs) > 0)
00241                 {
00242                         $i=0;
00243                         foreach($objs as $obj)
00244                         {
00245                                 // output thumbnail
00246                                 $mob =& new ilObjMediaObject($obj["id"]);
00247                                 $med =& $mob->getMediaItem("Standard");
00248                                 $target = $med->getThumbnailTarget();
00249                                 if ($target != "")
00250                                 {
00251                                         $this->tpl->setCurrentBlock("thumbnail");
00252                                         $this->tpl->setVariable("IMG_THUMB", $target);
00253                                         $this->tpl->parseCurrentBlock();
00254                                 }
00255 
00256                                 // allow editing of media objects
00257                                 if ($this->mode != "getObject")
00258                                 {                                       
00259                                         // output edit link
00260                                         $this->tpl->setCurrentBlock("edit");
00261                                         $this->ctrl->setParameter($this, "clip_mob_id", $obj["id"]);
00262                                         $this->tpl->setVariable("EDIT_LINK",
00263                                                 $this->ctrl->getLinkTargetByClass("ilObjMediaObjectGUI", "edit",
00264                                                         array("ilEditClipboardGUI")));
00265                                         $this->tpl->setVariable("TEXT_OBJECT", $obj["title"].
00266                                                 " [".$obj["id"]."]");
00267                                         $this->tpl->parseCurrentBlock();
00268                                 }
00269                                 else            // just list elements for selection
00270                                 {
00271                                         $this->tpl->setCurrentBlock("show");
00272                                         $this->tpl->setVariable("TEXT_OBJECT2", $obj["title"].
00273                                                 " [".$obj["id"]."]");
00274                                         $this->tpl->parseCurrentBlock();
00275                                 }
00276                                 
00277                                 include_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00278                                 $this->tpl->setVariable("MEDIA_INFO",
00279                                         ilObjMediaObjectGUI::_getMediaInfoHTML($mob));
00280 
00281                                 $this->tpl->setCurrentBlock("tbl_content");
00282                                 $css_row = ilUtil::switchColor($i++,"tblrow1","tblrow2");
00283                                 $this->tpl->setVariable("CSS_ROW", $css_row);
00284                                 $this->tpl->setVariable("CHECKBOX_ID", $obj["id"]);
00285                                 $this->tpl->parseCurrentBlock();
00286                         }
00287                 } //if is_array
00288                 else
00289                 {
00290                         $this->tpl->setCurrentBlock("notfound");
00291                         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00292                         $this->tpl->setVariable("NUM_COLS", $num);
00293                         $this->tpl->parseCurrentBlock();
00294                 }
00295 
00296         }
00297 
00298 
00302         function getObject()
00303         {
00304                 $this->mode = "getObject";
00305                 $this->view();
00306         }
00307 
00308 
00312         function remove()
00313         {
00314                 // check number of objects
00315                 if (!isset($_POST["id"]))
00316                 {
00317                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00318                 }
00319 
00320                 foreach($_POST["id"] AS $obj_id)
00321                 {
00322                         $this->ilias->account->removeObjectFromClipboard($obj_id, "mob");
00323                         include_once("content/classes/Media/class.ilObjMediaObject.php");
00324                         $mob = new ilObjMediaObject($obj_id);
00325                         $mob->delete();                 // this method don't delete, if mob is used elsewhere
00326                 }
00327                 $this->ctrl->redirect($this, "view");
00328         }
00329 
00333         function insert()
00334         {
00335                 // check number of objects
00336                 if (!isset($_POST["id"]))
00337                 {
00338                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00339                 }
00340                 
00341                 if (!$this->getMultipleSelections())
00342                 {
00343                         if(count($_POST["id"]) > 1)
00344                         {
00345                                 $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
00346                         }
00347                 }
00348 
00349                 $_SESSION["ilEditClipboard_mob_id"] = $_POST["id"];
00350                 ilUtil::redirect(ilUtil::appendUrlParameterString(
00351                         $_GET["returnCommand"], "clip_obj_type=mob&clip_obj_id=".$_POST["id"][0]));
00352         }
00353         
00354         function _getSelectedIDs()
00355         {
00356                 return $_SESSION["ilEditClipboard_mob_id"];
00357         }
00358 
00362         function createMediaInClipboard()
00363         {
00364                 require_once ("content/classes/Pages/class.ilPCMediaObjectGUI.php");
00365                 $mob_gui =& new ilPCMediaObjectGUI($this->obj, $this->lm_obj);
00366                 $mob_gui->setTargetScript("lm_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]);
00367                 $mob_gui->insert("post", "saveMediaInClipboard");
00368         }
00369 
00373         function saveMediaInClipboard()
00374         {
00375                 require_once ("content/classes/Pages/class.ilPCMediaObjectGUI.php");
00376                 $mob_gui =& new ilPCMediaObjectGUI($this->obj, $this->lm_obj);
00377                 $mob =& $mob_gui->create(false);
00378                 $this->ilias->account->addObjectToClipboard($mob->getId(), "mob", $mob->getTitle());
00379                 $this->clipboard();
00380         }
00381 
00385         function setTabs()
00386         {
00387                 $this->tpl->setVariable("HEADER", $this->lng->txt("clipboard"));
00388 
00389                 // catch feedback message
00390                 include_once("classes/class.ilTabsGUI.php");
00391                 $tabs_gui =& new ilTabsGUI();
00392                 $this->getTabs($tabs_gui);
00393                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00394         }
00395 
00401         function getTabs(&$tabs_gui)
00402         {
00403                 if ($this->mode == "getObject")
00404                 {
00405                         // back to upper context
00406                         $tabs_gui->addTarget("cont_back",
00407                                 $_GET["returnCommand"], "",
00408                                 "");
00409                 }
00410                 else
00411                 {
00412                         // back to upper context
00413                         $tabs_gui->addTarget("cont_back",
00414                                 $this->ctrl->getParentReturn($this), "",
00415                                 "");
00416                 }
00417         }
00418 
00419 }
00420 ?>

Generated on Fri Dec 13 2013 09:06:35 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1