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

content/classes/Pages/class.ilPageContentGUI.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.ilPageContent.php");
00025 
00034 class ilPageContentGUI
00035 {
00036         var $content_obj;
00037         var $ilias;
00038         var $tpl;
00039         var $lng;
00040         var $ctrl;
00041         var $pg_obj;
00042         var $hier_id;
00043         var $dom;
00044         var $updated;
00045         var $target_script;
00046         var $return_location;
00047 
00052         function ilPageContentGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id = 0)
00053         {
00054                 global $ilias, $tpl, $lng, $ilCtrl;
00055 
00056                 $this->ilias =& $ilias;
00057                 $this->tpl =& $tpl;
00058                 $this->lng =& $lng;
00059                 $this->pg_obj =& $a_pg_obj;
00060                 $this->ctrl =& $ilCtrl;
00061 
00062                 $this->content_obj =& $a_content_obj;
00063 
00064                 if($a_hier_id !== 0)
00065                 {
00066                         $this->hier_id = $a_hier_id;
00067                         $this->dom =& $a_pg_obj->getDom();
00068                 }
00069         }
00070 
00071         /*
00072         function setTargetScript($a_target_script)
00073         {
00074                 $this->target_script = $a_target_script;
00075         }
00076 
00077         function getTargetScript()
00078         {
00079                 return $this->target_script;
00080         }
00081 
00082         function setReturnLocation($a_location)
00083         {
00084                 $this->return_location = $a_location;
00085         }
00086 
00087         function getReturnLocation()
00088         {
00089                 return $this->return_location;
00090         }*/
00091 
00095         function getHierId()
00096         {
00097                 return $this->hier_id;
00098         }
00099 
00103         function delete()
00104         {
00105                 $updated = $this->pg_obj->deleteContent($this->hier_id);
00106                 if($updated !== true)
00107                 {
00108                         $_SESSION["il_pg_error"] = $updated;
00109                 }
00110                 else
00111                 {
00112                         unset($_SESSION["il_pg_error"]);
00113                 }
00114                 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00115         }
00116 
00120         function moveAfter()
00121         {
00122                 // check if a target is selected
00123                 if(!isset($_POST["target"]))
00124                 {
00125                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00126                 }
00127 
00128                 // check if only one target is selected
00129                 if(count($_POST["target"]) > 1)
00130                 {
00131                         $this->ilias->raiseError($this->lng->txt("only_one_target"),$this->ilias->error_obj->MESSAGE);
00132                 }
00133 
00134                 // check if target is within source
00135                 if($this->hier_id == substr($_POST["target"][0], 0, strlen($this->hier_id)))
00136                 {
00137                         $this->ilias->raiseError($this->lng->txt("cont_target_within_source"),$this->ilias->error_obj->MESSAGE);
00138                 }
00139                 
00140                 // strip "c" "r" of table ids from hierarchical id
00141                 $first_hier_character = substr($_POST["target"][0], 0, 1);
00142                 if ($first_hier_character == "c" ||
00143                         $first_hier_character == "r" ||
00144                         $first_hier_character == "i")
00145                 {
00146                         $_POST["target"][0] = substr($_POST["target"][0], 1);
00147                 }
00148 
00149                 // move
00150                 $updated = $this->pg_obj->moveContentAfter($this->hier_id, $_POST["target"][0]);
00151                 if($updated !== true)
00152                 {
00153                         $_SESSION["il_pg_error"] = $updated;
00154                 }
00155                 else
00156                 {
00157                         unset($_SESSION["il_pg_error"]);
00158                 }
00159 
00160                 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00161         }
00162 
00166         function moveBefore()
00167         {
00168                 // check if a target is selected
00169                 if(!isset($_POST["target"]))
00170                 {
00171                         $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00172                 }
00173 
00174                 // check if target is within source
00175                 if(count($_POST["target"]) > 1)
00176                 {
00177                         $this->ilias->raiseError($this->lng->txt("only_one_target"),$this->ilias->error_obj->MESSAGE);
00178                 }
00179 
00180                 // check if target is within source
00181                 if($this->hier_id == substr($_POST["target"][0], 0, strlen($this->hier_id)))
00182                 {
00183                         $this->ilias->raiseError($this->lng->txt("cont_target_within_source"),$this->ilias->error_obj->MESSAGE);
00184                 }
00185 
00186                 // strip "c" "r" of table ids from hierarchical id
00187                 $first_hier_character = substr($_POST["target"][0], 0, 1);
00188                 if ($first_hier_character == "c" ||
00189                         $first_hier_character == "r" ||
00190                         $first_hier_character == "i")
00191                 {
00192                         $_POST["target"][0] = substr($_POST["target"][0], 1);
00193                 }
00194 
00195                 // move
00196                 $updated = $this->pg_obj->moveContentBefore($this->hier_id, $_POST["target"][0]);
00197                 if($updated !== true)
00198                 {
00199                         $_SESSION["il_pg_error"] = $updated;
00200                 }
00201                 else
00202                 {
00203                         unset($_SESSION["il_pg_error"]);
00204                 }
00205                 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00206         }
00207         
00208         
00212         function splitPage()
00213         {
00214                 global $ilErr;
00215                 
00216                 if ($this->pg_obj->getParentType() != "lm" &&
00217                         $this->pg_obj->getParentType() != "dbk")
00218                 {
00219                         $ilErr->raiseError("Split method called for wrong parent type (".
00220                         $this->pg_obj->getParentType().")", $ilErr->FATAL);
00221                 }
00222                 else
00223                 {
00224                         $lm_page =& ilLMPageObject::_splitPage($this->pg_obj->getId(),
00225                                 $this->pg_obj->getParentType(), $this->hier_id);
00226                                 
00227                         // jump to new page
00228                         $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $lm_page->getId());
00229                         $this->ctrl->redirectByClass("illmpageobjectgui", "view");
00230                 }
00231                 
00232                 $this->ctrl->returnToParent($this, "jump".($this->hier_id - 1));
00233         }
00234 
00238         function splitPageNext()
00239         {
00240                 global $ilErr;
00241                 
00242                 if ($this->pg_obj->getParentType() != "lm" &&
00243                         $this->pg_obj->getParentType() != "dbk")
00244                 {
00245                         $ilErr->raiseError("Split method called for wrong parent type (".
00246                         $this->pg_obj->getParentType().")", $ilErr->FATAL);
00247                 }
00248                 else
00249                 {
00250                         $succ_id = ilLMPageObject::_splitPageNext($this->pg_obj->getId(),
00251                                 $this->pg_obj->getParentType(), $this->hier_id);
00252                         
00253                         // jump to successor page
00254                         if ($succ_id > 0)
00255                         {
00256                                 $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $succ_id);
00257                                 $this->ctrl->redirectByClass("illmpageobjectgui", "view");
00258                         }
00259 
00260                 }
00261                 $this->ctrl->returnToParent($this, "jump".($this->hier_id - 1));
00262         }
00263 
00267         function displayValidationError()
00268         {
00269                 if(is_array($this->updated))
00270                 {
00271                         $error_str = "<b>Validation Error(s):</b><br>";
00272                         foreach ($this->updated as $error)
00273                         {
00274                                 $err_mess = implode($error, " - ");
00275                                 if (!is_int(strpos($err_mess, ":0:")))
00276                                 {
00277                                         $error_str .= htmlentities($err_mess)."<br />";
00278                                 }
00279                         }
00280                         $this->tpl->setVariable("MESSAGE", $error_str);
00281                 }
00282         }
00283 
00284 
00285 }
00286 ?>

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