ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPageContentGUI.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.ilPageContent.php");
25 
35 {
37  var $ilias;
38  var $tpl;
39  var $lng;
40  var $ctrl;
41  var $pg_obj;
42  var $hier_id;
43  var $dom;
44  var $updated;
47 
52  function ilPageContentGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id = 0, $a_pc_id = "")
53  {
54  global $ilias, $tpl, $lng, $ilCtrl;
55 
56  $this->ilias =& $ilias;
57  $this->tpl =& $tpl;
58  $this->lng =& $lng;
59  $this->pg_obj =& $a_pg_obj;
60  $this->ctrl =& $ilCtrl;
61 
62  $this->content_obj =& $a_content_obj;
63  if($a_hier_id !== 0)
64  {
65  $this->hier_id = $a_hier_id;
66  $this->pc_id = $a_pc_id;
67 //echo "-".$this->pc_id."-";
68  $this->dom =& $a_pg_obj->getDom();
69  }
70  }
71 
72  /*
73  function setTargetScript($a_target_script)
74  {
75  $this->target_script = $a_target_script;
76  }
77 
78  function getTargetScript()
79  {
80  return $this->target_script;
81  }
82 
83  function setReturnLocation($a_location)
84  {
85  $this->return_location = $a_location;
86  }
87 
88  function getReturnLocation()
89  {
90  return $this->return_location;
91  }*/
92 
96  function getHierId()
97  {
98  return $this->hier_id;
99  }
100 
104  function setHierId($a_hier_id)
105  {
106  $this->hier_id = $a_hier_id;
107  }
108 
112  function getBBMenu()
113  {
114  global $lng;
115 
116  $btpl = new ilTemplate("tpl.bb_menu.html", true, true, "Services/COPage");
117 
118  // not nice, should be set by context per method
119  if ($this->pg_obj->getParentType() == "gdf" ||
120  $this->pg_obj->getParentType() == "lm" ||
121  $this->pg_obj->getParentType() == "dbk")
122  {
123  $btpl->setCurrentBlock("bb_ilink_button");
124  $btpl->setVariable("BB_LINK_ILINK",
125  $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
126  $btpl->parseCurrentBlock();
127  }
128  if ($this->pg_obj->getParentType() == "wpg")
129  {
130  $btpl->setCurrentBlock("bb_wikilink_button");
131  $btpl->setVariable("TXT_WLN2", $lng->txt("wiki_wiki_page"));
132  $btpl->parseCurrentBlock();
133  }
134 
135  $btpl->setVariable("TXT_STR", $this->lng->txt("cont_text_str"));
136  $btpl->setVariable("TXT_EMP", $this->lng->txt("cont_text_emp"));
137  $btpl->setVariable("TXT_COM", $this->lng->txt("cont_text_com"));
138  $btpl->setVariable("TXT_FN", $this->lng->txt("cont_text_fn"));
139  $btpl->setVariable("TXT_QUOT", $this->lng->txt("cont_text_quot"));
140  $btpl->setVariable("TXT_CODE", $this->lng->txt("cont_text_code"));
141  $btpl->setVariable("TXT_ILN", $this->lng->txt("cont_text_iln"));
142  $btpl->setVariable("TXT_XLN", $this->lng->txt("cont_text_xln"));
143  $btpl->setVariable("TXT_TEX", $this->lng->txt("cont_text_tex"));
144  $btpl->setVariable("TXT_BB_TIP", $this->lng->txt("cont_bb_tip"));
145  $btpl->setVariable("TXT_WLN", $lng->txt("wiki_wiki_page"));
146 
147  $btpl->setVariable("PAR_TA_NAME", "par_content");
148 
149  return $btpl->get();
150  }
151 
155  function delete()
156  {
157  $updated = $this->pg_obj->deleteContent($this->hier_id);
158  if($updated !== true)
159  {
160  $_SESSION["il_pg_error"] = $updated;
161  }
162  else
163  {
164  unset($_SESSION["il_pg_error"]);
165  }
166  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
167  }
168 
172  function moveAfter()
173  {
174  // check if a target is selected
175  if(!isset($_POST["target"]))
176  {
177  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
178  }
179 
180  // check if only one target is selected
181  if(count($_POST["target"]) > 1)
182  {
183  $this->ilias->raiseError($this->lng->txt("only_one_target"),$this->ilias->error_obj->MESSAGE);
184  }
185 
186  $a_hid = explode(":", $_POST["target"][0]);
187 //echo "-".$a_hid[0]."-".$a_hid[1]."-";
188 
189  // check if target is within source
190  if($this->hier_id == substr($a_hid[0], 0, strlen($this->hier_id)))
191  {
192  $this->ilias->raiseError($this->lng->txt("cont_target_within_source"),$this->ilias->error_obj->MESSAGE);
193  }
194 
195  // check whether target is allowed
196  $curr_node =& $this->pg_obj->getContentNode($a_hid[0], $a_hid[1]);
197  if (is_object($curr_node) && $curr_node->node_name() == "FileItem")
198  {
199  $this->ilias->raiseError($this->lng->txt("cont_operation_not_allowed"),$this->ilias->error_obj->MESSAGE);
200  }
201 
202  // strip "c" "r" of table ids from hierarchical id
203  $first_hier_character = substr($a_hid[0], 0, 1);
204  if ($first_hier_character == "c" ||
205  $first_hier_character == "r" ||
206  $first_hier_character == "i")
207  {
208  $a_hid[0] = substr($a_hid[0], 1);
209  }
210 
211  // move
212  $updated = $this->pg_obj->moveContentAfter($this->hier_id, $a_hid[0],
213  $this->content_obj->getPcId(), $a_hid[1]);
214  if($updated !== true)
215  {
216  $_SESSION["il_pg_error"] = $updated;
217  }
218  else
219  {
220  unset($_SESSION["il_pg_error"]);
221  }
222 
223  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
224  }
225 
229  function moveBefore()
230  {
231  // check if a target is selected
232  if(!isset($_POST["target"]))
233  {
234  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
235  }
236 
237  // check if target is within source
238  if(count($_POST["target"]) > 1)
239  {
240  $this->ilias->raiseError($this->lng->txt("only_one_target"),$this->ilias->error_obj->MESSAGE);
241  }
242 
243  $a_hid = explode(":", $_POST["target"][0]);
244 
245  // check if target is within source
246  if($this->hier_id == substr($a_hid[0], 0, strlen($this->hier_id)))
247  {
248  $this->ilias->raiseError($this->lng->txt("cont_target_within_source"),$this->ilias->error_obj->MESSAGE);
249  }
250 
251  // check whether target is allowed
252  $curr_node =& $this->pg_obj->getContentNode($a_hid[0], $a_hid[1]);
253  if (is_object($curr_node) && $curr_node->node_name() == "FileItem")
254  {
255  $this->ilias->raiseError($this->lng->txt("cont_operation_not_allowed"),$this->ilias->error_obj->MESSAGE);
256  }
257 
258  // strip "c" "r" of table ids from hierarchical id
259  $first_hier_character = substr($a_hid[0], 0, 1);
260  if ($first_hier_character == "c" ||
261  $first_hier_character == "r" ||
262  $first_hier_character == "i")
263  {
264  $a_hid[0] = substr($a_hid[0], 1);
265  }
266 
267  // move
268  $updated = $this->pg_obj->moveContentBefore($this->hier_id, $a_hid[0],
269  $this->content_obj->getPcId(), $a_hid[1]);
270  if($updated !== true)
271  {
272  $_SESSION["il_pg_error"] = $updated;
273  }
274  else
275  {
276  unset($_SESSION["il_pg_error"]);
277  }
278  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
279  }
280 
281 
285  function splitPage()
286  {
287  global $ilErr;
288 
289  if ($this->pg_obj->getParentType() != "lm" &&
290  $this->pg_obj->getParentType() != "dbk")
291  {
292  $ilErr->raiseError("Split method called for wrong parent type (".
293  $this->pg_obj->getParentType().")", $ilErr->FATAL);
294  }
295  else
296  {
297  $lm_page =& ilLMPageObject::_splitPage($this->pg_obj->getId(),
298  $this->pg_obj->getParentType(), $this->hier_id);
299 
300  // jump to new page
301  $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $lm_page->getId());
302  $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
303  }
304 
305  $this->ctrl->returnToParent($this, "jump".($this->hier_id - 1));
306  }
307 
311  function splitPageNext()
312  {
313  global $ilErr;
314 
315  if ($this->pg_obj->getParentType() != "lm" &&
316  $this->pg_obj->getParentType() != "dbk")
317  {
318  $ilErr->raiseError("Split method called for wrong parent type (".
319  $this->pg_obj->getParentType().")", $ilErr->FATAL);
320  }
321  else
322  {
323  $succ_id = ilLMPageObject::_splitPageNext($this->pg_obj->getId(),
324  $this->pg_obj->getParentType(), $this->hier_id);
325 
326  // jump to successor page
327  if ($succ_id > 0)
328  {
329  $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $succ_id);
330  $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
331  }
332 
333  }
334  $this->ctrl->returnToParent($this, "jump".($this->hier_id - 1));
335  }
336 
341  {
342  if(is_array($this->updated))
343  {
344  $error_str = "<b>Validation Error(s):</b><br>";
345  foreach ($this->updated as $error)
346  {
347  $err_mess = implode($error, " - ");
348  if (!is_int(strpos($err_mess, ":0:")))
349  {
350  $error_str .= htmlentities($err_mess)."<br />";
351  }
352  }
353  $this->tpl->setVariable("MESSAGE", $error_str);
354  }
355  else if($this->updated != "" && $this->updated !== true)
356  {
357  $this->tpl->setVariable("MESSAGE", "<b>Validation Error(s):</b><br />".
358  $this->updated."<br />");
359  }
360  }
361 
365  function cancelCreate()
366  {
367  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
368  }
369 
373  function cancelUpdate()
374  {
375  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
376  }
377 
378 
383  function deactivate()
384  {
385  $obj = & $this->content_obj;
386 
387  if ($obj->isEnabled ())
388  $obj->disable ();
389  else
390  $obj->enable ();
391 
392  $updated = $this->pg_obj->update($this->hier_id);
393  if($updated !== true)
394  {
395  $_SESSION["il_pg_error"] = $updated;
396  }
397  else
398  {
399  unset($_SESSION["il_pg_error"]);
400  }
401 
402  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
403  }
404 
405 }
406 ?>