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

content/classes/Pages/class.ilPCFileItemGUI.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/Pages/class.ilPCListItem.php");
00025 require_once("./content/classes/Pages/class.ilPageContentGUI.php");
00026 
00037 class ilPCFileItemGUI extends ilPageContentGUI
00038 {
00039 
00044         function ilPCFileItemGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id)
00045         {
00046                 parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id);
00047         }
00048 
00052         function &executeCommand()
00053         {
00054                 // get next class that processes or forwards current command
00055                 $next_class = $this->ctrl->getNextClass($this);
00056 
00057                 // get current command
00058                 $cmd = $this->ctrl->getCmd();
00059 
00060                 switch($next_class)
00061                 {
00062                         default:
00063                                 $ret =& $this->$cmd();
00064                                 break;
00065                 }
00066 
00067                 return $ret;
00068         }
00069 
00073         function newFileItem()
00074         {
00075                 include_once("classes/class.ilObjFile.php");
00076                 $fileObj = new ilObjFile();
00077                 $fileObj->setType("file");
00078                 $fileObj->setTitle($_FILES["Fobject"]["name"]["file"]);
00079                 $fileObj->setDescription("");
00080                 $fileObj->setFileName($_FILES["Fobject"]["name"]["file"]);
00081                 $fileObj->setFileType($_FILES["Fobject"]["type"]["file"]);
00082                 $fileObj->create();
00083                 $fileObj->raiseUploadError(false);
00084                 // upload file to filesystem
00085                 $fileObj->createDirectory();
00086                 $fileObj->getUploadFile($_FILES["Fobject"]["tmp_name"]["file"],
00087                         $_FILES["Fobject"]["name"]["file"]);
00088 
00089                 $this->file_object =& $fileObj;
00090         }
00091 
00092 
00096         function newItemAfter()
00097         {
00098                 $this->setTabs();
00099 
00100                 // new file list form
00101                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.file_item_edit.html", "content");
00102                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_file_item"));
00103                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00104 
00105                 $this->displayValidationError();
00106 
00107                 // file
00108                 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("file"));
00109 
00110                 $this->tpl->parseCurrentBlock();
00111 
00112                 // operations
00113                 $this->tpl->setCurrentBlock("commands");
00114                 $this->tpl->setVariable("BTN_NAME", "insertNewItemAfter");
00115                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00116                 $this->tpl->parseCurrentBlock();
00117 
00118         }
00119 
00123         function insertNewItemAfter()
00124         {
00125                 $this->newFileItem();
00126                 $this->content_obj->newItemAfter($this->file_object->getId(),
00127                         $this->file_object->getFileName(), $this->file_object->getFileType());
00128                 $this->updated = $this->pg_obj->update();
00129                 if ($this->updated === true)
00130                 {
00131                         $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00132                 }
00133                 else
00134                 {
00135                         $this->newItemAfter();
00136                 }
00137         }
00138 
00142         function newItemBefore()
00143         {
00144                 $this->setTabs();
00145 
00146                 // new file list form
00147                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.file_item_edit.html", "content");
00148                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_file_item"));
00149                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00150 
00151                 $this->displayValidationError();
00152 
00153                 // file
00154                 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("file"));
00155 
00156                 $this->tpl->parseCurrentBlock();
00157 
00158                 // operations
00159                 $this->tpl->setCurrentBlock("commands");
00160                 $this->tpl->setVariable("BTN_NAME", "insertNewItemBefore");
00161                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00162                 $this->tpl->parseCurrentBlock();
00163 
00164         }
00165 
00169         function insertNewItemBefore()
00170         {
00171                 $this->newFileItem();
00172                 $this->content_obj->newItemBefore($this->file_object->getId(),
00173                         $this->file_object->getFileName(), $this->file_object->getFileType());
00174                 $this->updated = $this->pg_obj->update();
00175                 if ($this->updated === true)
00176                 {
00177                         $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00178                 }
00179                 else
00180                 {
00181                         $this->newItemBefore();
00182                 }
00183         }
00184 
00188         function deleteItem()
00189         {
00190                 $this->content_obj->deleteItem();
00191                 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00192                 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00193         }
00194 
00198         function setTabs()
00199         {
00200                 // catch feedback message
00201                 include_once("classes/class.ilTabsGUI.php");
00202                 $tabs_gui =& new ilTabsGUI();
00203                 $this->getTabs($tabs_gui);
00204                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00205         }
00206 
00212         function getTabs(&$tabs_gui)
00213         {
00214                 // back to upper context
00215                 $tabs_gui->addTarget("cont_back",
00216                         $this->ctrl->getParentReturn($this), "",
00217                         "");
00218         }
00219         
00223         function moveItemDown()
00224         {
00225                 $this->content_obj->moveItemDown();
00226                 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00227                 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00228         }
00229 
00233         function moveItemUp()
00234         {
00235                 $this->content_obj->moveItemUp();
00236                 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00237                 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00238         }
00239 
00240 
00241 }
00242 ?>

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