4require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
5require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
25 parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
38 return array(
"Standard" =>
$lng->txt(
"cont_standard"),
39 "Headline1" =>
$lng->txt(
"cont_Headline1"),
40 "Headline2" =>
$lng->txt(
"cont_Headline2"),
41 "Headline3" =>
$lng->txt(
"cont_Headline3"),
42 "Citation" =>
$lng->txt(
"cont_Citation"),
43 "Mnemonic" =>
$lng->txt(
"cont_Mnemonic"),
44 "Example" =>
$lng->txt(
"cont_Example"),
45 "Additional" =>
$lng->txt(
"cont_Additional"),
46 "Remark" =>
$lng->txt(
"cont_Remark"),
47 "List" =>
$lng->txt(
"cont_List"),
48 "TableContent" =>
$lng->txt(
"cont_TableContent")
60 if ($a_style_id > 0 &&
63 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
65 $types = array(
"text_block",
"heading1",
"heading2",
"heading3");
67 foreach ($types as
$t)
69 $chars = array_merge($chars,
$style->getCharacteristics(
$t));
72 foreach ($chars as $char)
74 if ($st_chars[$char] !=
"")
76 $new_chars[$char] = $st_chars[$char];
80 $new_chars[$char] = $char;
96 $next_class = $this->ctrl->getNextClass($this);
99 array(
"text_block",
"heading1",
"heading2",
"heading3"));
102 $cmd = $this->ctrl->getCmd();
104 $this->log->debug(
"ilPCParagraphGUI: executeCommand ".
$cmd);
119 function edit($a_insert =
false)
124 $tpl =
new ilTemplate(
"tpl.paragraph_edit.html",
true,
true,
"Services/COPage");
132 $tpl->setCurrentBlock(
"commands");
133 $tpl->setVariable(
"BTN_NAME",
"create_par");
134 $tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
135 $tpl->setVariable(
"BTN_CANCEL",
"cancelCreate");
136 $tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
137 $tpl->parseCurrentBlock();
138 $tpl->setCurrentBlock(
"commands2");
139 $tpl->setVariable(
"BTN_NAME",
"create_par");
140 $tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
141 $tpl->setVariable(
"BTN_CANCEL",
"cancelCreate");
142 $tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
143 $tpl->parseCurrentBlock();
144 $tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_insert_par"));
148 $tpl->setCurrentBlock(
"commands");
149 $tpl->setVariable(
"BTN_NAME",
"update");
150 $tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
151 $tpl->setVariable(
"BTN_CANCEL",
"cancelUpdate");
152 $tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
153 $tpl->parseCurrentBlock();
154 $tpl->setCurrentBlock(
"commands2");
155 $tpl->setVariable(
"BTN_NAME",
"update");
156 $tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
157 $tpl->setVariable(
"BTN_CANCEL",
"cancelUpdate");
158 $tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
159 $tpl->parseCurrentBlock();
160 $tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_edit_par"));
167 if (key(
$_POST[
"cmd"]) ==
"update")
169 $s_lang =
$_POST[
"par_language"];
173 $s_lang = $this->content_obj->getLanguage();
178 if (key(
$_POST[
"cmd"]) ==
"create_par")
180 $s_lang =
$_POST[
"par_language"];
186 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
190 $s_lang =
$ilUser->getLanguage();
199 $tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
201 $tpl->setVariable(
"PAR_TA_NAME",
"par_content");
203 $this->tpl->addJavascript(
"./Services/COPage/phpBB/3_0_5/editor.js");
204 $this->tpl->addJavascript(
"./Services/COPage/js/paragraph_editing.js");
209 $tpl->setVariable(
"TXT_LANGUAGE", $this->lng->txt(
"language"));
210 $tpl->setVariable(
"TXT_ANCHOR", $this->lng->txt(
"cont_anchor"));
212 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
215 $tpl->setVariable(
"SELECT_LANGUAGE", $select_lang);
217 $tpl->setVariable(
"TXT_CHARACTERISTIC", $this->lng->txt(
"cont_characteristic"));
222 if (key(
$_POST[
"cmd"]) ==
"update" || key(
$_POST[
"cmd"]) ==
"create_par")
226 $s_text = str_replace(
"{",
"{", $s_text);
227 $s_text = str_replace(
"}",
"}", $s_text);
231 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
234 $tpl->setVariable(
"PAR_TA_CONTENT", $s_text);
236 $tpl->parseCurrentBlock();
238 $this->tpl->setContent(
$tpl->get());
253 if (key(
$_POST[
"cmd"]) ==
"update")
255 $s_char =
$_POST[
"par_characteristic"];
259 $s_char = $this->content_obj->getCharacteristic();
262 $s_char =
"Standard";
268 if (key(
$_POST[
"cmd"]) ==
"create_par")
270 $s_char =
$_POST[
"par_characteristic"];
274 $s_char =
"Standard";
277 $cont_obj = $this->pg_obj->getContentObject($this->
getHierId());
278 if (is_object($cont_obj))
280 if ($cont_obj->getType() ==
"li" ||
281 ($cont_obj->getType() ==
"par" && $cont_obj->getCharacteristic() ==
"List"))
286 if ($cont_obj->getType() ==
"td" ||
287 ($cont_obj->getType() ==
"par" && $cont_obj->getCharacteristic() ==
"TableContent"))
289 $s_char =
"TableContent";
305 $s_text = $this->content_obj->getText();
307 $s_text = $this->content_obj->xml2output($s_text,
true,
false);
312 $ids =
"###".$this->content_obj->readHierId().
":".$this->content_obj->readPCId().
"###".
315 $this->log->debug(
"ilPCParagraphGUI, editJS(): echo paragraph and exit: ".substr($ids.$s_text, 0, 100));
326 echo $this->content_obj->getParagraphSequenceContent($this->pg_obj);
338 $s_text = str_replace(array(
"<SimpleBulletList>",
"</SimpleBulletList>"),
339 array(
"<ul class='ilc_list_u_BulletedList'>",
"</ul>"),
341 $s_text = str_replace(array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"),
342 array(
"<ol class='ilc_list_o_NumberedList'>",
"</ol>"), $s_text);
343 $s_text = str_replace(array(
"<SimpleListItem>",
"</SimpleListItem>"),
344 array(
"<li class='ilc_list_item_StandardListItem'>",
"</li>"), $s_text);
345 $s_text = str_replace(array(
"<SimpleListItem/>"),
346 array(
"<li class='ilc_list_item_StandardListItem'></li>"), $s_text);
353 include_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
356 if (!in_array($bb, array(
"code",
"tex",
"fn",
"xln",
"sub",
"sup")))
358 $s_text = str_replace(
"[".$bb.
"]",
359 '<span class="ilc_text_inline_'.$cl.
'">', $s_text);
360 $s_text = str_replace(
"[/".$bb.
"]",
366 $s_text = str_replace(array(
"[code]",
"[/code]"),
367 array(
"<code>",
"</code>"), $s_text);
370 $s_text = str_replace(array(
"[sup]",
"[/sup]"),
371 array(
'<sup class="ilc_sup_Sup">',
"</sup>"), $s_text);
374 $s_text = str_replace(array(
"[sub]",
"[/sub]"),
375 array(
'<sub class="ilc_sub_Sub">',
"</sub>"), $s_text);
391 $this->log->debug(
"start");
393 $this->updated = $this->content_obj->saveJS($this->pg_obj,
394 $_POST[
"ajaxform_content"],
398 $this->log->debug(
"ilPCParagraphGUI, saveJS: got updated value ".$this->updated);
402 if ($this->updated ===
true)
404 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
405 $this->log->debug(
"ilPCParagraphGUI, saveJS: echoing pc_id_str ".$a_pc_id_str.
" (and exit)");
411 if ($this->updated !==
true && is_array($this->updated))
416 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
418 $ilCtrl->setParameterByClass(
$ilCtrl->getReturnClass($this),
"updated_pc_id_str",
419 urlencode($a_pc_id_str));
420 $this->log->debug(
"ilPCParagraphGUI, saveJS: redirecting to edit command of ".
$ilCtrl->getReturnClass($this).
".");
421 $ilCtrl->redirectByClass(
$ilCtrl->getReturnClass($this),
"edit",
"",
true);
432 foreach ($a_err as $err)
434 $err_str.= $err[1].
"<br />";
437 $this->log->debug(
"ilPCParagraphGUI, outputError() and exit: ".substr($err_str, 0, 100));
447 $this->log->debug(
"ilPCParagraphGUI, cancel(): return to parent: jump".$this->hier_id);
448 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
460 if ($chars[$a_seleted_value] ==
"" && ($a_seleted_value !=
""))
462 $chars = array_merge(array($a_seleted_value => $a_seleted_value),
466 foreach ($chars as $char => $char_lang)
468 $a_tpl->setCurrentBlock(
"characteristic_cell");
469 $a_tpl->setVariable(
"CHAR_HTML",
470 '<div class="ilc_text_block_'.$char.
'" style="margin-top:2px; margin-bottom:2px; position:static;">'.$char_lang.
"</div>");
471 $a_tpl->setVariable(
"CHAR_VALUE", $char);
472 if ($char == $a_seleted_value)
474 $a_tpl->setVariable(
"SELECTED",
475 ' checked="checked" ');
477 $a_tpl->parseCurrentBlock();
478 if ((($i+1) % 3) == 0)
480 $a_tpl->touchBlock(
"characteristic_row");
484 $a_tpl->touchBlock(
"characteristic_table");
495 $a_tpl->setVariable(
"ADV_SEL_STYLE", self::getStyleSelector($a_selected,
504 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
506 $selection->setPullRight(
false);
507 $selection->setFormSelectMode(
"par_characteristic",
"",
false,
510 $selection->setId(
"style_selection");
511 $selection->setSelectionHeaderClass(
"ilEditSubmit ilTinyMenuDropDown");
513 $selection->setSelectedValue($a_selected);
514 $selection->setUseImages(
false);
518 $selection->setSelectCallback(
"ilCOPage.setParagraphClass");
522 $title_char = ($chars[$a_selected] !=
"")
523 ? $chars[$a_selected]
525 $selection->setListTitle($title_char);
527 if ($chars[$a_seleted] ==
"" && ($a_seleted !=
""))
529 $chars = array_merge(array($a_seleted => $a_seleted),
533 foreach ($chars as $char => $char_lang)
539 case "Headline1":
$t =
"heading1"; $tag =
"h1";
break;
540 case "Headline2":
$t =
"heading2"; $tag =
"h2";
break;
541 case "Headline3":
$t =
"heading3"; $tag =
"h3";
break;
543 $html =
'<div class="ilCOPgEditStyleSelectionItem"><'.$tag.
' class="ilc_'.
$t.
'_'.$char.
'" style="'.self::$style_selector_reset.
'">'.$char_lang.
"</".$tag.
"></div>";
544 $selection->addItem($char_lang, $char,
"",
545 "", $char,
"",
$html);
547 return $selection->getHTML();
557 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
559 $selection->setPullRight(
false);
560 $selection->setFormSelectMode(
"char_characteristic",
"",
false,
563 $selection->setId(
"char_style_selection");
564 $selection->setSelectionHeaderClass(
"ilEditSubmit");
567 $selection->setUseImages(
false);
571 $selection->setSelectCallback(
"ilCOPage.setCharacterClass");
578 $selection->setListTitle(
" <i>A</i>");
587 "Comment" => array(
"code" =>
"com",
"txt" =>
$lng->txt(
"cont_char_style_com")),
588 "Quotation" => array(
"code" =>
"quot",
"txt" =>
$lng->txt(
"cont_char_style_quot")),
589 "Accent" => array(
"code" =>
"acc",
"txt" =>
$lng->txt(
"cont_char_style_acc")),
590 "Code" => array(
"code" =>
"code",
"txt" =>
$lng->txt(
"cont_char_style_code"))
592 foreach ($chars as $key => $char)
595 $a_par_type,
"active_".$char[
"code"],
true))
601 case "Code": $tag =
"code";
break;
603 $html =
'<'.$tag.
' class="ilc_'.
$t.
'_'.$key.
'" style="font-size:90%; margin-top:2px; margin-bottom:2px; position:static;">'.$char[
"txt"].
"</".$tag.
">";
609 $html =
'<a class="nostyle" style="display:block;" href="#" onclick="return false;">'.$html.
"</a>";
610 $selection->addItem($char[
"txt"], $key,
"",
611 "", $key,
"",
$html);
614 return $selection->getHTML();
622 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
624 if ($this->pg_obj->getParentType() ==
"gdf" ||
625 $this->pg_obj->getParentType() ==
"lm" ||
626 $this->pg_obj->getParentType() ==
"dbk")
628 if ($this->pg_obj->getParentType() !=
"gdf")
640 if ($this->pg_obj->getParentType() !=
"sahs")
652 $this->log->debug(
"ilPCParagraphGUI, saveJS: got updated value ".$this->updated);
653 return $this->
edit(
true);
661 $this->log->debug(
"ilPCParagraphGUI, update(): start");
664 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
665 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
667 $this->updated = $this->content_obj->setText(
668 $this->content_obj->input2xml(
$_POST[
"par_content"],
669 $_POST[
"usedwsiwygeditor"]),
true);
670 if ($this->updated !==
true)
676 $this->updated = $this->content_obj->updatePage($this->pg_obj);
679 if ($this->updated ===
true)
681 $this->log->debug(
"ilPCParagraphGUI, update(): return to parent: jump".$this->hier_id);
682 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
686 $this->log->debug(
"ilPCParagraphGUI, update(): call edit.");
697 $this->log->debug(
"ilPCParagraphGUI, create(): start.");
699 if (
$_POST[
"ajaxform_hier_id"] !=
"")
706 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
708 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
710 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
712 $this->updated = $this->content_obj->setText(
713 $this->content_obj->input2xml(
$_POST[
"par_content"],
714 $_POST[
"usedwsiwygeditor"]),
true);
716 if ($this->updated !==
true)
721 $this->updated = $this->content_obj->updatePage($this->pg_obj);
723 if ($this->updated ===
true)
725 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
740 $this->log->debug(
"ilPCParagraphGUI, createJS(): start");
743 $this->updated = $this->content_obj->saveJS($this->pg_obj,
744 $_POST[
"ajaxform_content"],
752 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
754 $this->log->debug(
"ilPCParagraphGUI, createJS(): echo pc id and exit: ".$a_pc_id_str);
759 if ($this->updated !==
true && is_array($this->updated))
765 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
766 $ilCtrl->setParameterByClass(
$ilCtrl->getReturnClass($this),
"updated_pc_id_str",
767 urlencode($a_pc_id_str));
768 $this->log->debug(
"ilPCParagraphGUI, createJS(): return to edit cmd of ".
$ilCtrl->getReturnClass($this));
770 $ilCtrl->redirectByClass(
$ilCtrl->getReturnClass($this),
"edit",
"",
true);
780 $a_tpl->setCurrentBlock(
"help_item");
781 $a_tpl->setVariable(
"TXT_HELP",
"<b>".
$lng->txt(
"cont_syntax_help").
"</b>");
782 $a_tpl->parseCurrentBlock();
783 $a_tpl->setCurrentBlock(
"help_item");
784 $a_tpl->setVariable(
"TXT_HELP",
"* ".
$lng->txt(
"cont_bullet_list"));
785 $a_tpl->parseCurrentBlock();
786 $a_tpl->setCurrentBlock(
"help_item");
787 $a_tpl->setVariable(
"TXT_HELP",
"# ".
$lng->txt(
"cont_numbered_list"));
788 $a_tpl->parseCurrentBlock();
789 $a_tpl->setCurrentBlock(
"help_item");
790 $a_tpl->setVariable(
"TXT_HELP",
"=".
$lng->txt(
"cont_Headline1").
"=<br />".
791 "==".$lng->txt(
"cont_Headline2").
"==<br />".
792 "===".$lng->txt(
"cont_Headline3").
"===");
793 $a_tpl->parseCurrentBlock();
797 $a_tpl->setCurrentBlock(
"help_item");
798 $a_tpl->setVariable(
"TXT_HELP",
"[[".
$lng->txt(
"cont_wiki_page_link").
"]]");
799 $a_tpl->parseCurrentBlock();
802 $a_tpl->setCurrentBlock(
"help");
803 $a_tpl->parseCurrentBlock();
User interface class for advanced drop-down selection lists.
const ON_ITEM_CLICK_FORM_SELECT
_lookupStyleSheetId($a_cont_obj_id)
lookup style sheet ID
getContentStylePath($a_style_id)
get content style path
static _lookupType($a_id, $a_reference=false)
lookup object type
saveJS()
Save paragraph by JS call.
insert()
insert paragraph form
insertCharacteristicTable($a_tpl, $a_seleted_value)
Insert characteristic table.
determineCharacteristic($a_insert=false)
Determine current characteristic.
outputError($a_err)
Output error.
static xml2outputJS($s_text, $char, $a_pc_id)
Prepare content for js output.
& executeCommand()
execute command
createJS()
Create paragraph per JS.
editJS()
Edit paragraph (Ajax mode, sends the content of the paragraph)
create()
create new paragraph in dom and update page in db
static _getCharacteristics($a_style_id)
Get characteristics.
static getCharStyleSelector($a_par_type, $a_use_callback=true)
Get character style selector.
static getStyleSelector($a_selected, $a_chars, $a_use_callback=false)
Get style selector.
edit($a_insert=false)
edit paragraph form
insertHelp($a_tpl)
Insert Help.
insertStyleSelectionList($a_tpl, $a_selected)
Insert style selection list.
static _getStandardCharacteristics()
Get standard characteristics.
update()
update paragraph in dom and update page in db
ilPCParagraphGUI($a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
editMultipleJS()
Edit multiple paragraphs (Ajax mode, sends the content of the paragraphs)
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getHierId()
get hierarchical id in dom object
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
getPageConfig()
Get Page Config.
displayValidationError()
display validation errors
static _getCommonBBButtons()
Get common bb buttons.
getCharacteristics()
Get characteristics.
getBBMenu($a_ta_name="par_content")
Get the bb menu incl.
setCharacteristics($a_chars)
Set Characteristics.
static lookupSettingByParentType($a_par_type, $a_name, $a_default=false)
Lookup setting by parent type.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.