ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCFileItemGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/COPage/classes/class.ilPCListItem.php");
25 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
26 
38 {
39 
44  function ilPCFileItemGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
45  {
46  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
47  }
48 
52  function &executeCommand()
53  {
54  // get next class that processes or forwards current command
55  $next_class = $this->ctrl->getNextClass($this);
56 
57  // get current command
58  $cmd = $this->ctrl->getCmd();
59 
60  switch($next_class)
61  {
62  default:
63  $ret =& $this->$cmd();
64  break;
65  }
66 
67  return $ret;
68  }
69 
73  function newFileItem()
74  {
75  include_once("./Modules/File/classes/class.ilObjFile.php");
76  $fileObj = new ilObjFile();
77  $fileObj->setType("file");
78  $fileObj->setTitle($_FILES["Fobject"]["name"]["file"]);
79  $fileObj->setDescription("");
80  $fileObj->setFileName($_FILES["Fobject"]["name"]["file"]);
81  $fileObj->setFileType($_FILES["Fobject"]["type"]["file"]);
82  $fileObj->setFileSize($_FILES["Fobject"]["size"]["file"]);
83  $fileObj->setMode("filelist");
84  $fileObj->create();
85  $fileObj->raiseUploadError(false);
86  // upload file to filesystem
87  $fileObj->createDirectory();
88  $fileObj->getUploadFile($_FILES["Fobject"]["tmp_name"]["file"],
89  $_FILES["Fobject"]["name"]["file"]);
90 
91  $this->file_object =& $fileObj;
92  }
93 
94 
98  function newItemAfter()
99  {
100  // new file list form
101  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.file_item_edit.html", "Services/COPage");
102  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_file_item"));
103  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
104 
105  $this->displayValidationError();
106 
107  // file
108  $this->tpl->setVariable("TXT_FILE", $this->lng->txt("file"));
109 
110  $this->tpl->parseCurrentBlock();
111 
112  // operations
113  $this->tpl->setCurrentBlock("commands");
114  $this->tpl->setVariable("BTN_NAME", "insertNewItemAfter");
115  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
116  $this->tpl->parseCurrentBlock();
117 
118  }
119 
124  {
125  $this->newFileItem();
126  $this->content_obj->newItemAfter($this->file_object->getId(),
127  $this->file_object->getFileName(), $this->file_object->getFileType());
128  $this->updated = $this->pg_obj->update();
129  if ($this->updated === true)
130  {
131  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
132  }
133  else
134  {
135  $this->newItemAfter();
136  }
137  }
138 
142  function newItemBefore()
143  {
144  // new file list form
145  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.file_item_edit.html", "Services/COPage");
146  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_file_item"));
147  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
148 
149  $this->displayValidationError();
150 
151  // file
152  $this->tpl->setVariable("TXT_FILE", $this->lng->txt("file"));
153 
154  $this->tpl->parseCurrentBlock();
155 
156  // operations
157  $this->tpl->setCurrentBlock("commands");
158  $this->tpl->setVariable("BTN_NAME", "insertNewItemBefore");
159  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
160  $this->tpl->parseCurrentBlock();
161 
162  }
163 
168  {
169  $this->newFileItem();
170  $this->content_obj->newItemBefore($this->file_object->getId(),
171  $this->file_object->getFileName(), $this->file_object->getFileType());
172  $this->updated = $this->pg_obj->update();
173  if ($this->updated === true)
174  {
175  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
176  }
177  else
178  {
179  $this->newItemBefore();
180  }
181  }
182 
186  function deleteItem()
187  {
188  $this->content_obj->deleteItem();
189  $_SESSION["il_pg_error"] = $this->pg_obj->update();
190  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
191  }
192 
196  function moveItemDown()
197  {
198  $this->content_obj->moveItemDown();
199  $_SESSION["il_pg_error"] = $this->pg_obj->update();
200  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
201  }
202 
206  function moveItemUp()
207  {
208  $this->content_obj->moveItemUp();
209  $_SESSION["il_pg_error"] = $this->pg_obj->update();
210  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
211  }
212 
213 
214 }
215 ?>