00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
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
00123 if(!isset($_POST["target"]))
00124 {
00125 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00126 }
00127
00128
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
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
00141 $curr_node =& $this->pg_obj->getContentNode($_POST["target"][0]);
00142 if (is_object($curr_node) && $curr_node->node_name() == "FileItem")
00143 {
00144 $this->ilias->raiseError($this->lng->txt("cont_operation_not_allowed"),$this->ilias->error_obj->MESSAGE);
00145 }
00146
00147
00148 $first_hier_character = substr($_POST["target"][0], 0, 1);
00149 if ($first_hier_character == "c" ||
00150 $first_hier_character == "r" ||
00151 $first_hier_character == "i")
00152 {
00153 $_POST["target"][0] = substr($_POST["target"][0], 1);
00154 }
00155
00156
00157 $updated = $this->pg_obj->moveContentAfter($this->hier_id, $_POST["target"][0]);
00158 if($updated !== true)
00159 {
00160 $_SESSION["il_pg_error"] = $updated;
00161 }
00162 else
00163 {
00164 unset($_SESSION["il_pg_error"]);
00165 }
00166
00167 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00168 }
00169
00173 function moveBefore()
00174 {
00175
00176 if(!isset($_POST["target"]))
00177 {
00178 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00179 }
00180
00181
00182 if(count($_POST["target"]) > 1)
00183 {
00184 $this->ilias->raiseError($this->lng->txt("only_one_target"),$this->ilias->error_obj->MESSAGE);
00185 }
00186
00187
00188 if($this->hier_id == substr($_POST["target"][0], 0, strlen($this->hier_id)))
00189 {
00190 $this->ilias->raiseError($this->lng->txt("cont_target_within_source"),$this->ilias->error_obj->MESSAGE);
00191 }
00192
00193
00194 $curr_node =& $this->pg_obj->getContentNode($_POST["target"][0]);
00195 if (is_object($curr_node) && $curr_node->node_name() == "FileItem")
00196 {
00197 $this->ilias->raiseError($this->lng->txt("cont_operation_not_allowed"),$this->ilias->error_obj->MESSAGE);
00198 }
00199
00200
00201 $first_hier_character = substr($_POST["target"][0], 0, 1);
00202 if ($first_hier_character == "c" ||
00203 $first_hier_character == "r" ||
00204 $first_hier_character == "i")
00205 {
00206 $_POST["target"][0] = substr($_POST["target"][0], 1);
00207 }
00208
00209
00210 $updated = $this->pg_obj->moveContentBefore($this->hier_id, $_POST["target"][0]);
00211 if($updated !== true)
00212 {
00213 $_SESSION["il_pg_error"] = $updated;
00214 }
00215 else
00216 {
00217 unset($_SESSION["il_pg_error"]);
00218 }
00219 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00220 }
00221
00222
00226 function splitPage()
00227 {
00228 global $ilErr;
00229
00230 if ($this->pg_obj->getParentType() != "lm" &&
00231 $this->pg_obj->getParentType() != "dbk")
00232 {
00233 $ilErr->raiseError("Split method called for wrong parent type (".
00234 $this->pg_obj->getParentType().")", $ilErr->FATAL);
00235 }
00236 else
00237 {
00238 $lm_page =& ilLMPageObject::_splitPage($this->pg_obj->getId(),
00239 $this->pg_obj->getParentType(), $this->hier_id);
00240
00241
00242 $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $lm_page->getId());
00243 $this->ctrl->redirectByClass("illmpageobjectgui", "view");
00244 }
00245
00246 $this->ctrl->returnToParent($this, "jump".($this->hier_id - 1));
00247 }
00248
00252 function splitPageNext()
00253 {
00254 global $ilErr;
00255
00256 if ($this->pg_obj->getParentType() != "lm" &&
00257 $this->pg_obj->getParentType() != "dbk")
00258 {
00259 $ilErr->raiseError("Split method called for wrong parent type (".
00260 $this->pg_obj->getParentType().")", $ilErr->FATAL);
00261 }
00262 else
00263 {
00264 $succ_id = ilLMPageObject::_splitPageNext($this->pg_obj->getId(),
00265 $this->pg_obj->getParentType(), $this->hier_id);
00266
00267
00268 if ($succ_id > 0)
00269 {
00270 $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $succ_id);
00271 $this->ctrl->redirectByClass("illmpageobjectgui", "view");
00272 }
00273
00274 }
00275 $this->ctrl->returnToParent($this, "jump".($this->hier_id - 1));
00276 }
00277
00281 function displayValidationError()
00282 {
00283 if(is_array($this->updated))
00284 {
00285 $error_str = "<b>Validation Error(s):</b><br>";
00286 foreach ($this->updated as $error)
00287 {
00288 $err_mess = implode($error, " - ");
00289 if (!is_int(strpos($err_mess, ":0:")))
00290 {
00291 $error_str .= htmlentities($err_mess)."<br />";
00292 }
00293 }
00294 $this->tpl->setVariable("MESSAGE", $error_str);
00295 }
00296 else if($this->updated != "" && $this->updated !== true)
00297 {
00298 $this->tpl->setVariable("MESSAGE", "<b>Validation Error(s):</b><br />".
00299 $this->updated."<br />");
00300 }
00301 }
00302
00306 function cancelCreate()
00307 {
00308 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00309 }
00310
00314 function cancelUpdate()
00315 {
00316 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00317 }
00318
00319
00324 function deactivate()
00325 {
00326 $obj = & $this->content_obj;
00327
00328 if ($obj->isEnabled ())
00329 $obj->disable ();
00330 else
00331 $obj->enable ();
00332
00333 $updated = $this->pg_obj->update($this->hier_id);
00334 if($updated !== true)
00335 {
00336 $_SESSION["il_pg_error"] = $updated;
00337 }
00338 else
00339 {
00340 unset($_SESSION["il_pg_error"]);
00341 }
00342
00343 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00344 }
00345
00346 }
00347 ?>