ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilPageContentGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once("./Services/COPage/classes/class.ilPageContent.php");
5
15{
17 var $ilias;
18 var $tpl;
19 var $lng;
20 var $ctrl;
23 var $dom;
27 var $page_config = null;
28
29 static $style_selector_reset = "margin-top:2px; margin-bottom:2px; text-indent:0px; position:static; float:none; width: auto;";
30
31 // common bb buttons (special ones are iln and wln)
32 protected static $common_bb_buttons = array(
33 "str" => "Strong", "emp" => "Emph", "imp" => "Important", "com" => "Comment",
34 "quot" => "Quotation", "acc" => "Accent", "code" => "Code", "tex" => "Tex",
35 "fn" => "Footnote", "xln" => "ExternalLink"
36 );
37
42 function ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id = 0, $a_pc_id = "")
43 {
44 global $ilias, $tpl, $lng, $ilCtrl;
45 $this->ilias = $ilias;
46 $this->tpl = $tpl;
47 $this->lng = $lng;
48 $this->pg_obj = $a_pg_obj;
49 $this->ctrl = $ilCtrl;
50 $this->content_obj = $a_content_obj;
51
52 if($a_hier_id !== 0)
53 {
54 $this->hier_id = $a_hier_id;
55 $this->pc_id = $a_pc_id;
56//echo "-".$this->pc_id."-";
57 $this->dom = $a_pg_obj->getDom();
58 }
59 }
60
66 function setContentObject($a_val)
67 {
68 $this->content_obj = $a_val;
69 }
70
77 {
78 return $this->content_obj;
79 }
80
86 function setPage($a_val)
87 {
88 $this->pg_obj = $a_val;
89 }
90
96 function getPage()
97 {
98 return $this->pg_obj;
99 }
100
106 function setPageConfig($a_val)
107 {
108 $this->page_config = $a_val;
109 }
110
116 function getPageConfig()
117 {
118 return $this->page_config;
119 }
120
124 static function _getCommonBBButtons()
125 {
127 }
128
129 // scorm2004-start
135 function setStyleId($a_styleid)
136 {
137 $this->styleid = $a_styleid;
138 }
139
145 function getStyleId()
146 {
147 return $this->styleid;
148 }
149
153 function getStyle()
154 {
155 if ((!is_object($this->style) || $this->getStyleId() != $this->style->getId()) && $this->getStyleId() > 0)
156 {
157 if (ilObject::_lookupType($this->getStyleId()) == "sty")
158 {
159 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
160 $this->style = new ilObjStyleSheet($this->getStyleId());
161 }
162 }
163
164 return $this->style;
165 }
166
170 protected function getCharacteristicsOfCurrentStyle($a_type)
171 {
172 if ($this->getStyleId() > 0 &&
173 ilObject::_lookupType($this->getStyleId()) == "sty")
174 {
175 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
176 $style = new ilObjStyleSheet($this->getStyleId());
177 $chars = array();
178 if (!is_array($a_type))
179 {
180 $a_type = array($a_type);
181 }
182 foreach ($a_type as $at)
183 {
184 $chars = array_merge($chars, $style->getCharacteristics($at, true));
185 }
186 $new_chars = array();
187 if (is_array($chars))
188 {
189 foreach ($chars as $char)
190 {
191 if ($this->chars[$char] != "") // keep lang vars for standard chars
192 {
193 $new_chars[$char] = $this->chars[$char];
194 }
195 else
196 {
197 $new_chars[$char] = $char;
198 }
199 asort($new_chars);
200 }
201 }
202 $this->setCharacteristics($new_chars);
203 }
204 }
205
209 function setCharacteristics($a_chars)
210 {
211 $this->chars = $a_chars;
212 }
213
218 {
219 return $this->chars ? $this->chars : array();
220 }
221 // scorm2004-end
222
223
227 function getHierId()
228 {
229 return $this->hier_id;
230 }
231
235 function setHierId($a_hier_id)
236 {
237 $this->hier_id = $a_hier_id;
238 }
239
243 function getBBMenu($a_ta_name = "par_content")
244 {
245 global $lng, $ilCtrl;
246
247 include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
248
249 $btpl = new ilTemplate("tpl.bb_menu.html", true, true, "Services/COPage");
250
251 // not nice, should be set by context per method
252 //if ($this->pg_obj->getParentType() == "gdf" ||
253 // $this->pg_obj->getParentType() == "lm" ||
254 // $this->pg_obj->getParentType() == "dbk")
255 if ($this->getPageConfig()->getEnableInternalLinks())
256 {
257 $btpl->setCurrentBlock("bb_ilink_button");
258 $btpl->setVariable("BB_LINK_ILINK",
259 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
260 $btpl->parseCurrentBlock();
261
262 // add int link parts
263 include_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
264 $btpl->setCurrentBlock("int_link_prep");
265 $btpl->setVariable("INT_LINK_PREP", ilInternalLinkGUI::getInitHTML(
266 $ilCtrl->getLinkTargetByClass(array("ilpageeditorgui", "ilinternallinkgui"),
267 "", false, true, false), true));
268 $btpl->parseCurrentBlock();
269
270 }
271
272 if ($this->getPageConfig()->getEnableKeywords())
273 {
274 $btpl->touchBlock("bb_kw_button");
275 $btpl->setVariable("TXT_KW", $this->lng->txt("cont_text_keyword"));
276 }
277 if ($this->pg_obj->getParentType() == "wpg")
278 {
279 $btpl->setCurrentBlock("bb_wikilink_button2");
280 $btpl->setVariable("TXT_WIKI_BUTTON2", $lng->txt("obj_wiki"));
281 $btpl->setVariable("WIKI_BUTTON2_URL", $ilCtrl->getLinkTargetByClass("ilwikipagegui", ""));
282 $btpl->parseCurrentBlock();
283
284 $btpl->setCurrentBlock("bb_wikilink_button");
285 $btpl->setVariable("TXT_WLN2", $lng->txt("wiki_wiki_page"));
286 $btpl->parseCurrentBlock();
287 }
288 $mathJaxSetting = new ilSetting("MathJax");
289 $style = $this->getStyle();
290//echo URL_TO_LATEX;
291 foreach (self::$common_bb_buttons as $c => $st)
292 {
293 if (ilPageEditorSettings::lookupSettingByParentType($this->pg_obj->getParentType(), "active_".$c, true))
294 {
295 if ($c != "tex" || $mathJaxSetting->get("enable") || defined("URL_TO_LATEX"))
296 {
297 $btpl->touchBlock("bb_".$c."_button");
298 $btpl->setVariable("TXT_".strtoupper($c), $this->lng->txt("cont_text_".$c));
299 }
300 }
301 }
302
303 if ($this->getPageConfig()->getEnableAnchors())
304 {
305 $btpl->touchBlock("bb_anc_button");
306 $btpl->setVariable("TXT_ANC", $lng->txt("cont_anchor").":");
307 }
308
309 // footnote
310// $btpl->setVariable("TXT_FN", $this->lng->txt("cont_text_fn"));
311
312// $btpl->setVariable("TXT_CODE", $this->lng->txt("cont_text_code"));
313 $btpl->setVariable("TXT_ILN", $this->lng->txt("cont_text_iln"));
314// $btpl->setVariable("TXT_XLN", $this->lng->txt("cont_text_xln"));
315// $btpl->setVariable("TXT_TEX", $this->lng->txt("cont_text_tex"));
316 $btpl->setVariable("TXT_BB_TIP", $this->lng->txt("cont_bb_tip"));
317 $btpl->setVariable("TXT_WLN", $lng->txt("wiki_wiki_page"));
318
319 $btpl->setVariable("PAR_TA_NAME", $a_ta_name);
320
321 return $btpl->get();
322 }
323
327 function delete()
328 {
329 $updated = $this->pg_obj->deleteContent($this->hier_id);
330 if($updated !== true)
331 {
332 $_SESSION["il_pg_error"] = $updated;
333 }
334 else
335 {
336 unset($_SESSION["il_pg_error"]);
337 }
338 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
339 }
340
344 function moveAfter()
345 {
346 // check if a target is selected
347 if(!isset($_POST["target"]))
348 {
349 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
350 }
351
352 // check if only one target is selected
353 if(count($_POST["target"]) > 1)
354 {
355 $this->ilias->raiseError($this->lng->txt("only_one_target"),$this->ilias->error_obj->MESSAGE);
356 }
357
358 $a_hid = explode(":", $_POST["target"][0]);
359//echo "-".$a_hid[0]."-".$a_hid[1]."-";
360
361 // check if target is within source
362 if($this->hier_id == substr($a_hid[0], 0, strlen($this->hier_id)))
363 {
364 $this->ilias->raiseError($this->lng->txt("cont_target_within_source"),$this->ilias->error_obj->MESSAGE);
365 }
366
367 // check whether target is allowed
368 $curr_node =& $this->pg_obj->getContentNode($a_hid[0], $a_hid[1]);
369 if (is_object($curr_node) && $curr_node->node_name() == "FileItem")
370 {
371 $this->ilias->raiseError($this->lng->txt("cont_operation_not_allowed"),$this->ilias->error_obj->MESSAGE);
372 }
373
374 // strip "c" "r" of table ids from hierarchical id
375 $first_hier_character = substr($a_hid[0], 0, 1);
376 if ($first_hier_character == "c" ||
377 $first_hier_character == "r" ||
378 $first_hier_character == "i")
379 {
380 $a_hid[0] = substr($a_hid[0], 1);
381 }
382
383 // move
384 $updated = $this->pg_obj->moveContentAfter($this->hier_id, $a_hid[0],
385 $this->content_obj->getPcId(), $a_hid[1]);
386 if($updated !== true)
387 {
388 $_SESSION["il_pg_error"] = $updated;
389 }
390 else
391 {
392 unset($_SESSION["il_pg_error"]);
393 }
394
395 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
396 }
397
401 function moveBefore()
402 {
403 // check if a target is selected
404 if(!isset($_POST["target"]))
405 {
406 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
407 }
408
409 // check if target is within source
410 if(count($_POST["target"]) > 1)
411 {
412 $this->ilias->raiseError($this->lng->txt("only_one_target"),$this->ilias->error_obj->MESSAGE);
413 }
414
415 $a_hid = explode(":", $_POST["target"][0]);
416
417 // check if target is within source
418 if($this->hier_id == substr($a_hid[0], 0, strlen($this->hier_id)))
419 {
420 $this->ilias->raiseError($this->lng->txt("cont_target_within_source"),$this->ilias->error_obj->MESSAGE);
421 }
422
423 // check whether target is allowed
424 $curr_node =& $this->pg_obj->getContentNode($a_hid[0], $a_hid[1]);
425 if (is_object($curr_node) && $curr_node->node_name() == "FileItem")
426 {
427 $this->ilias->raiseError($this->lng->txt("cont_operation_not_allowed"),$this->ilias->error_obj->MESSAGE);
428 }
429
430 // strip "c" "r" of table ids from hierarchical id
431 $first_hier_character = substr($a_hid[0], 0, 1);
432 if ($first_hier_character == "c" ||
433 $first_hier_character == "r" ||
434 $first_hier_character == "i")
435 {
436 $a_hid[0] = substr($a_hid[0], 1);
437 }
438
439 // move
440 $updated = $this->pg_obj->moveContentBefore($this->hier_id, $a_hid[0],
441 $this->content_obj->getPcId(), $a_hid[1]);
442 if($updated !== true)
443 {
444 $_SESSION["il_pg_error"] = $updated;
445 }
446 else
447 {
448 unset($_SESSION["il_pg_error"]);
449 }
450 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
451 }
452
453
457 function splitPage()
458 {
459 global $ilErr;
460
461 if ($this->pg_obj->getParentType() != "lm" &&
462 $this->pg_obj->getParentType() != "dbk")
463 {
464 $ilErr->raiseError("Split method called for wrong parent type (".
465 $this->pg_obj->getParentType().")", $ilErr->FATAL);
466 }
467 else
468 {
469 $lm_page =& ilLMPageObject::_splitPage($this->pg_obj->getId(),
470 $this->pg_obj->getParentType(), $this->hier_id);
471
472 // jump to new page
473 $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $lm_page->getId());
474 $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
475 }
476
477 $this->ctrl->returnToParent($this, "jump".($this->hier_id - 1));
478 }
479
483 function splitPageNext()
484 {
485 global $ilErr;
486
487 if ($this->pg_obj->getParentType() != "lm" &&
488 $this->pg_obj->getParentType() != "dbk")
489 {
490 $ilErr->raiseError("Split method called for wrong parent type (".
491 $this->pg_obj->getParentType().")", $ilErr->FATAL);
492 }
493 else
494 {
495 $succ_id = ilLMPageObject::_splitPageNext($this->pg_obj->getId(),
496 $this->pg_obj->getParentType(), $this->hier_id);
497
498 // jump to successor page
499 if ($succ_id > 0)
500 {
501 $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $succ_id);
502 $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
503 }
504
505 }
506 $this->ctrl->returnToParent($this, "jump".($this->hier_id - 1));
507 }
508
513 {
514 if(is_array($this->updated))
515 {
516 $error_str = "<b>Error(s):</b><br>";
517 foreach ($this->updated as $error)
518 {
519 $err_mess = implode($error, " - ");
520 if (!is_int(strpos($err_mess, ":0:")))
521 {
522 $error_str .= htmlentities($err_mess)."<br />";
523 }
524 }
525 ilUtil::sendFailure($error_str);
526 }
527 else if($this->updated != "" && $this->updated !== true)
528 {
529 ilUtil::sendFailure("<b>Error(s):</b><br />".
530 $this->updated);
531 }
532 }
533
537 function cancelCreate()
538 {
539 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
540 }
541
545 function cancelUpdate()
546 {
547 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
548 }
549
553 function cancel()
554 {
555 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
556 }
557
562 function deactivate()
563 {
564 $obj = & $this->content_obj;
565
566 if ($obj->isEnabled ())
567 $obj->disable ();
568 else
569 $obj->enable ();
570
571 $updated = $this->pg_obj->update($this->hier_id);
572 if($updated !== true)
573 {
574 $_SESSION["il_pg_error"] = $updated;
575 }
576 else
577 {
578 unset($_SESSION["il_pg_error"]);
579 }
580
581 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
582 }
583
587 function cut()
588 {
589 global $lng;
590
591 $obj = $this->content_obj;
592
593 $updated = $this->pg_obj->cutContents(array($this->hier_id.":".$this->pc_id));
594 if($updated !== true)
595 {
596 $_SESSION["il_pg_error"] = $updated;
597 }
598 else
599 {
600 unset($_SESSION["il_pg_error"]);
601 }
602
603 ilUtil::sendSuccess($lng->txt("cont_sel_el_cut_use_paste"), true);
604 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
605 }
606
610 function copy()
611 {
612 global $lng;
613
614 $obj = $this->content_obj;
615
616 ilUtil::sendSuccess($lng->txt("cont_sel_el_copied_use_paste"), true);
617 $this->pg_obj->copyContents(array($this->hier_id.":".$this->pc_id));
618
619 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
620 }
621
622
626 function getTemplateOptions($a_type)
627 {
628 $style = $this->getStyle();
629
630 if (is_object($style))
631 {
632 $ts = $style->getTemplates($a_type);
633 $options = array();
634 foreach ($ts as $t)
635 {
636 $options["t:".$t["id"].":".$t["name"]] = $t["name"];
637 }
638 return $options;
639 }
640 return array();
641 }
642
643}
644?>
getInitHTML($a_url, $a_move_to_body=false)
Get initialisation HTML to use interna link editing.
_splitPageNext($a_page_id, $a_pg_parent_type, $a_hier_id)
split page to next page at hierarchical id
_splitPage($a_page_id, $a_pg_parent_type, $a_hier_id)
split page at hierarchical id
Class ilObjStyleSheet.
static _lookupType($a_id, $a_reference=false)
lookup object type
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getHierId()
get hierarchical id in dom object
setPageConfig($a_val)
Set Page Config.
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
deactivate()
gui function set enabled if is not enabled and vice versa
getPageConfig()
Get Page Config.
getTemplateOptions($a_type)
Get table templates.
displayValidationError()
display validation errors
static _getCommonBBButtons()
Get common bb buttons.
getCharacteristics()
Get characteristics.
ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id=0, $a_pc_id="")
Constructor @access public.
setPage($a_val)
Set page.
moveAfter()
move content element after another element
splitPageNext()
split page to next page at specified position
cut()
Cut single element.
setStyleId($a_styleid)
Set Style Id.
splitPage()
split page to new page at specified position
getContentObject()
Get content object.
moveBefore()
move content element before another element
setContentObject($a_val)
Set content object.
cancelCreate()
cancel creating page content
getStyle()
Get style object.
getBBMenu($a_ta_name="par_content")
Get the bb menu incl.
setCharacteristics($a_chars)
Set Characteristics.
copy()
Copy single element.
setHierId($a_hier_id)
get hierarchical id in dom object
static lookupSettingByParentType($a_par_type, $a_name, $a_default=false)
Lookup setting by parent type.
ILIAS Setting Class.
special template class to simplify handling of ITX/PEAR
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST['username']
Definition: cron.php:12
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
if(!is_array($argv)) $options
if(strpos( $jquery_path, './')===0) else if(strpos($jquery_path, '.')===0) $mathJaxSetting
Definition: latex.php:34