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

Services/COPage/classes/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("./Services/COPage/classes/class.ilPCListItem.php");
00025 require_once("./Services/COPage/classes/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("./Modules/File/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->setFileSize($_FILES["Fobject"]["size"]["file"]);
00083                 $fileObj->setMode("filelist");
00084                 $fileObj->create();
00085                 $fileObj->raiseUploadError(false);
00086                 // upload file to filesystem
00087                 $fileObj->createDirectory();
00088                 $fileObj->getUploadFile($_FILES["Fobject"]["tmp_name"]["file"],
00089                         $_FILES["Fobject"]["name"]["file"]);
00090 
00091                 $this->file_object =& $fileObj;
00092         }
00093 
00094 
00098         function newItemAfter()
00099         {
00100                 $this->setTabs();
00101 
00102                 // new file list form
00103                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.file_item_edit.html", "Services/COPage");
00104                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_file_item"));
00105                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00106 
00107                 $this->displayValidationError();
00108 
00109                 // file
00110                 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("file"));
00111 
00112                 $this->tpl->parseCurrentBlock();
00113 
00114                 // operations
00115                 $this->tpl->setCurrentBlock("commands");
00116                 $this->tpl->setVariable("BTN_NAME", "insertNewItemAfter");
00117                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00118                 $this->tpl->parseCurrentBlock();
00119 
00120         }
00121 
00125         function insertNewItemAfter()
00126         {
00127                 $this->newFileItem();
00128                 $this->content_obj->newItemAfter($this->file_object->getId(),
00129                         $this->file_object->getFileName(), $this->file_object->getFileType());
00130                 $this->updated = $this->pg_obj->update();
00131                 if ($this->updated === true)
00132                 {
00133                         $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00134                 }
00135                 else
00136                 {
00137                         $this->newItemAfter();
00138                 }
00139         }
00140 
00144         function newItemBefore()
00145         {
00146                 $this->setTabs();
00147 
00148                 // new file list form
00149                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.file_item_edit.html", "Services/COPage");
00150                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_file_item"));
00151                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00152 
00153                 $this->displayValidationError();
00154 
00155                 // file
00156                 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("file"));
00157 
00158                 $this->tpl->parseCurrentBlock();
00159 
00160                 // operations
00161                 $this->tpl->setCurrentBlock("commands");
00162                 $this->tpl->setVariable("BTN_NAME", "insertNewItemBefore");
00163                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00164                 $this->tpl->parseCurrentBlock();
00165 
00166         }
00167 
00171         function insertNewItemBefore()
00172         {
00173                 $this->newFileItem();
00174                 $this->content_obj->newItemBefore($this->file_object->getId(),
00175                         $this->file_object->getFileName(), $this->file_object->getFileType());
00176                 $this->updated = $this->pg_obj->update();
00177                 if ($this->updated === true)
00178                 {
00179                         $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00180                 }
00181                 else
00182                 {
00183                         $this->newItemBefore();
00184                 }
00185         }
00186 
00190         function deleteItem()
00191         {
00192                 $this->content_obj->deleteItem();
00193                 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00194                 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00195         }
00196 
00200         function setTabs()
00201         {
00202                 global $ilTabs;
00203                 // catch feedback message
00204                 #include_once("classes/class.ilTabsGUI.php");
00205                 #$tabs_gui =& new ilTabsGUI();
00206                 $this->getTabs($ilTabs);
00207                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00208         }
00209 
00215         function getTabs(&$tabs_gui)
00216         {
00217                 // back to upper context
00218                 $tabs_gui->addTarget("cont_back",
00219                         $this->ctrl->getParentReturn($this), "",
00220                         "");
00221         }
00222         
00226         function moveItemDown()
00227         {
00228                 $this->content_obj->moveItemDown();
00229                 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00230                 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00231         }
00232 
00236         function moveItemUp()
00237         {
00238                 $this->content_obj->moveItemUp();
00239                 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00240                 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00241         }
00242 
00243 
00244 }
00245 ?>

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