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

content/classes/Pages/class.ilPCFileListGUI.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.ilPCFileList.php");
00025 require_once("./content/classes/Pages/class.ilPageContentGUI.php");
00026 
00037 class ilPCFileListGUI extends ilPageContentGUI
00038 {
00039 
00044         function ilPCFileListGUI(&$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 insert()
00074         {
00075                 global $ilUser;
00076 
00077                 $this->setTabs();
00078 
00079                 // new file list form
00080                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.file_list_new.html", "content");
00081                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_file_list"));
00082                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00083 
00084                 $this->displayValidationError();
00085 
00086                 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00087                 {
00088                         $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00089                 }
00090                 else
00091                 {
00092                         $s_lang = $ilUser->getLanguage();
00093                 }
00094 
00095 
00096                 // select fields for number of columns
00097                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00098                 $this->tpl->setVariable("INPUT_TITLE", "flst_title");
00099                 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("file"));
00100 
00101                 // language
00102                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00103                 $lang = ilMetaData::getLanguages();
00104                 $select_lang = ilUtil::formSelect ($s_lang, "flst_language",$lang,false,true);
00105                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00106 
00107 
00108                 $this->tpl->parseCurrentBlock();
00109 
00110                 // operations
00111                 $this->tpl->setCurrentBlock("commands");
00112                 $this->tpl->setVariable("BTN_NAME", "create_flst");
00113                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00114                 $this->tpl->setVariable("BTN_CANCEL", "cancelCreate");
00115                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00116                 $this->tpl->parseCurrentBlock();
00117 
00118         }
00119 
00120 
00124         function create()
00125         {
00126                 include_once("classes/class.ilObjFile.php");
00127                 $fileObj = new ilObjFile();
00128                 $fileObj->setType("file");
00129                 $fileObj->setTitle($_FILES["Fobject"]["name"]["file"]);
00130                 $fileObj->setDescription("");
00131                 $fileObj->setFileName($_FILES["Fobject"]["name"]["file"]);
00132                 $fileObj->setFileType($_FILES["Fobject"]["type"]["file"]);
00133                 $fileObj->setMode("filelist");
00134                 $fileObj->create();
00135                 // upload file to filesystem
00136                 $fileObj->createDirectory();
00137                 $fileObj->raiseUploadError(false);
00138                 $fileObj->getUploadFile($_FILES["Fobject"]["tmp_name"]["file"],
00139                         $_FILES["Fobject"]["name"]["file"]);
00140 
00141                 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["flst_language"];
00142 
00143 //echo "::".is_object($this->dom).":";
00144                 $this->content_obj = new ilPCFileList($this->dom);
00145                 $this->content_obj->create($this->pg_obj, $this->hier_id);
00146                 $this->content_obj->setListTitle(ilUtil::stripSlashes($_POST["flst_title"]), $_POST["flst_language"]);
00147                 $this->content_obj->appendItem($fileObj->getId(), $fileObj->getFileName(),
00148                         $fileObj->getFileType());
00149                 $this->updated = $this->pg_obj->update();
00150                 if ($this->updated === true)
00151                 {
00152                         $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00153                 }
00154                 else
00155                 {
00156                         $this->insert();
00157                 }
00158         }
00159 
00163         function edit()
00164         {
00165                 $this->setTabs();
00166 
00167                 // add paragraph edit template
00168                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.file_list_edit.html", "content");
00169                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_file_list_properties"));
00170                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00171 
00172                 $this->displayValidationError();
00173 
00174                 // select fields for number of columns
00175                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00176                 $this->tpl->setVariable("INPUT_TITLE", "flst_title");
00177 
00178                 // todo: this doesnt work if title contains " quotes
00179                 // ... addslashes doesnt work
00180                 $this->tpl->setVariable("VALUE_TITLE", $this->content_obj->getListTitle());
00181 
00182                 // language
00183                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00184                 $lang = ilMetaData::getLanguages();
00185                 $select_lang = ilUtil::formSelect ($this->content_obj->getLanguage(),"flst_language",$lang,false,true);
00186                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00187 
00188 
00189                 $this->tpl->parseCurrentBlock();
00190 
00191                 // operations
00192                 $this->tpl->setCurrentBlock("commands");
00193                 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00194                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00195                 $this->tpl->setVariable("BTN_CANCEL", "cancelUpdate");
00196                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00197                 $this->tpl->parseCurrentBlock();
00198 
00199         }
00200 
00201 
00205         function saveProperties()
00206         {
00207                 $this->content_obj->setListTitle(ilUtil::stripSlashes($_POST["flst_title"]),
00208                         $_POST["flst_language"]);
00209                 $this->updated = $this->pg_obj->update();
00210                 if ($this->updated === true)
00211                 {
00212                         $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00213                 }
00214                 else
00215                 {
00216                         $this->pg_obj->addHierIDs();
00217                         $this->edit();
00218                 }
00219         }
00220 
00224         function setTabs()
00225         {
00226                 global $ilTabs;
00227 
00228                 // catch feedback message
00229                 #include_once("classes/class.ilTabsGUI.php");
00230                 #$tabs_gui =& new ilTabsGUI();
00231                 $this->getTabs($ilTabs);
00232                 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00233         }
00234 
00240         function getTabs(&$tabs_gui)
00241         {
00242                 // back to upper context
00243                 /*
00244                 $tabs_gui->addTarget("cont_back",
00245                         $this->ctrl->getParentReturn($this), "",
00246                         "");
00247                 */
00248         }
00249 
00250 }
00251 ?>

Generated on Fri Dec 13 2013 13:52:10 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1