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

Services/Block/classes/class.ilHtmlBlockGUIGen.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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 include_once("Services/Block/classes/class.ilBlockGUI.php");
00025 define("IL_FORM_EDIT", 0);
00026 define("IL_FORM_CREATE", 1);
00027 define("IL_FORM_RE_EDIT", 2);
00028 define("IL_FORM_RE_CREATE", 3);
00029 
00036 class ilHtmlBlockGUIGen extends ilBlockGUI
00037 {
00038 
00039         protected $form_edit_mode;
00040 
00045         public function __construct()
00046         {
00047                 global $ilCtrl;
00048                 
00049                 $this->ctrl = $ilCtrl;
00050                 
00051                 
00052                 include_once("Services/Block/classes/class.ilHtmlBlock.php");
00053                 if ($_GET["html_block_id"] > 0)
00054                 {
00055                         $this->html_block = new ilHtmlBlock($_GET["html_block_id"]);
00056                 }
00057                 
00058                 $this->ctrl->saveParameter($this, array("html_block_id"));
00059                 
00060 
00061         }
00062 
00067         public function &executeCommand()
00068         {
00069                 global $ilCtrl;
00070                 
00071                 // get next class and command
00072                 $next_class = $this->ctrl->getNextClass($this);
00073                 $cmd = $this->ctrl->getCmd();
00074                 
00075                 switch ($next_class)
00076                 {
00077                         default:
00078                                 $html = $this->$cmd();
00079                                 break;
00080                 }
00081                 
00082                 return $html;
00083 
00084         }
00085 
00091         public function setFormEditMode($a_form_edit_mode)
00092         {
00093                 $this->form_edit_mode = $a_form_edit_mode;
00094         }
00095 
00101         public function getFormEditMode()
00102         {
00103                 return $this->form_edit_mode;
00104         }
00105 
00110         public function outputFormHtmlBlock()
00111         {
00112                 global $lng;
00113                 
00114                 $lng->loadLanguageModule("block");
00115                 
00116                 include("Services/Form/classes/class.ilPropertyFormGUI.php");
00117                 
00118                 $form_gui = new ilPropertyFormGUI();
00119                 
00120                 $values = $this->getValuesHtmlBlock();
00121                 
00122                 // Property Title
00123                 $alert = ($this->form_check["HtmlBlock"]["Title"]["error"] != "")
00124                         ? $this->form_check["HtmlBlock"]["Title"]["error"]
00125                         : "";
00126                 $form_gui->addTextProperty($lng->txt("block_html_block_title"),
00127                         "block_title",
00128                         $values["Title"],
00129                         "", $alert, true
00130                         , "200");
00131                 
00132                 // Property Content
00133                 $alert = ($this->form_check["HtmlBlock"]["Content"]["error"] != "")
00134                         ? $this->form_check["HtmlBlock"]["Content"]["error"]
00135                         : "";
00136                 $form_gui->addTextAreaProperty($lng->txt("block_html_block_content"),
00137                         "block_content",
00138                         $values["Content"],
00139                         "", $alert, false
00140                         , "40", "8", true);
00141                 
00142                 // save and cancel commands
00143                 if (in_array($this->getFormEditMode(), array(IL_FORM_CREATE,IL_FORM_RE_CREATE)))
00144                 {
00145                         $form_gui->addCommandButton("saveHtmlBlock", $lng->txt("save"));
00146                         $form_gui->addCommandButton("cancelSaveHtmlBlock", $lng->txt("cancel"));
00147                 }
00148                 else
00149                 {
00150                         $form_gui->addCommandButton("updateHtmlBlock", $lng->txt("save"));
00151                         $form_gui->addCommandButton("cancelUpdateHtmlBlock", $lng->txt("cancel"));
00152                 }
00153                 
00154                 $form_gui->setTitle($lng->txt("block_html_block_head"));
00155                 $form_gui->setFormAction($this->ctrl->getFormAction($this));
00156                 
00157                 // individual preparation of form
00158                 $this->prepareFormHtmlBlock($form_gui);
00159                 
00160                 return $form_gui->getHTML();
00161 
00162         }
00163 
00168         public function editHtmlBlock()
00169         {
00170                 $this->setFormEditMode(IL_FORM_EDIT);
00171                 return $this->outputFormHtmlBlock();
00172 
00173         }
00174 
00179         public function createHtmlBlock()
00180         {
00181                 $this->setFormEditMode(IL_FORM_CREATE);
00182                 return $this->outputFormHtmlBlock();
00183 
00184         }
00185 
00190         public function saveHtmlBlock()
00191         {
00192                 include_once("./classes/class.ilObjAdvancedEditing.php");
00193                 if ($this->checkInputHtmlBlock())
00194                 {
00195                         $this->html_block = new ilHtmlBlock();
00196                         $this->html_block->setTitle(ilUtil::stripSlashes($_POST["block_title"]));
00197                         $this->html_block->setContent(ilUtil::stripSlashes($_POST["block_content"]
00198                                 ,true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString()));
00199                         $this->prepareSaveHtmlBlock($this->html_block);
00200                         $this->html_block->create();
00201                 }
00202                 else
00203                 {
00204                         $this->setFormEditMode(IL_FORM_RE_CREATE);
00205                         return $this->outputFormHtmlBlock();
00206                 }
00207 
00208         }
00209 
00214         public function updateHtmlBlock()
00215         {
00216                 include_once("./classes/class.ilObjAdvancedEditing.php");
00217                 if ($this->checkInputHtmlBlock())
00218                 {
00219                         
00220                         $this->html_block->setTitle(ilUtil::stripSlashes($_POST["block_title"]));
00221                         $this->html_block->setContent(ilUtil::stripSlashes($_POST["block_content"]
00222                                 ,true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString()));
00223                         $this->html_block->update();
00224                 }
00225                 else
00226                 {
00227                         $this->setFormEditMode(IL_FORM_RE_EDIT);
00228                         return $this->outputFormHtmlBlock();
00229                 }
00230 
00231         }
00232 
00237         public function getValuesHtmlBlock()
00238         {
00239                 $values = array();
00240                 
00241                 switch ($this->getFormEditMode())
00242                 {
00243                         case IL_FORM_CREATE:
00244                                 $values["Title"] = "";
00245                                 $values["Content"] = "";
00246                                 break;
00247                                 
00248                         case IL_FORM_EDIT:
00249                                 $values["Title"] = $this->html_block->getTitle();
00250                                 $values["Content"] = $this->html_block->getContent();
00251                                 break;
00252                                 
00253                         case IL_FORM_RE_EDIT:
00254                         case IL_FORM_RE_CREATE:
00255                                 $values["Title"] = ilUtil::stripSlashes($_POST["block_title"]);
00256                                 $values["Content"] = ilUtil::stripSlashes($_POST["block_content"]
00257                                 ,true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString());
00258                                 break;
00259                 }
00260                 
00261                 return $values;
00262 
00263         }
00264 
00269         public function checkInputHtmlBlock()
00270         {
00271                 
00272                 include_once("./Services/Utilities/classes/class.ilTypeCheck.php");
00273                 $ilTypeCheck = new ilTypeCheck();
00274                 
00275                 $this->form_check["HtmlBlock"] = array();
00276                 $this->form_check["HtmlBlock"]["Title"] =
00277                         ilTypeCheck::check("varchar", $_POST["block_title"], true);
00278                 $this->form_check["HtmlBlock"]["Content"] =
00279                         ilTypeCheck::check("text", $_POST["block_content"], false);
00280                 
00281                 foreach($this->form_check["HtmlBlock"] as $prop_check)
00282                 {
00283                         if (!$prop_check["ok"])
00284                         {
00285                                 return false;
00286                         }
00287                 }
00288                 return true;
00289 
00290         }
00291 
00297         public function prepareSaveHtmlBlock(&$a_html_block)
00298         {
00299 
00300         }
00301 
00307         public function prepareFormHtmlBlock(&$a_form_gui)
00308         {
00309 
00310         }
00311 
00312 
00313 }
00314 ?>

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