4 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
5 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
23 function __construct($a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id =
"")
25 parent::__construct($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/Content/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;
101 if ($a_style_id > 0 &&
104 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
106 $types =
array(
"text_inline");
107 foreach ($types as
$t)
109 $chars = array_merge($chars,
$style->getCharacteristics($t,
false, $a_include_core));
123 $next_class = $this->ctrl->getNextClass($this);
126 array(
"text_block",
"heading1",
"heading2",
"heading3"));
129 $cmd = $this->ctrl->getCmd();
131 $this->log->debug(
"ilPCParagraphGUI: executeCommand ".
$cmd);
146 function edit($a_insert =
false)
151 $tpl =
new ilTemplate(
"tpl.paragraph_edit.html",
true,
true,
"Services/COPage");
159 $tpl->setCurrentBlock(
"commands");
160 $tpl->setVariable(
"BTN_NAME",
"create_par");
161 $tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
162 $tpl->setVariable(
"BTN_CANCEL",
"cancelCreate");
163 $tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
164 $tpl->parseCurrentBlock();
171 $tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_insert_par"));
175 $tpl->setCurrentBlock(
"commands");
176 $tpl->setVariable(
"BTN_NAME",
"update");
177 $tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
178 $tpl->setVariable(
"BTN_CANCEL",
"cancelUpdate");
179 $tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
180 $tpl->parseCurrentBlock();
187 $tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_edit_par"));
194 if (key(
$_POST[
"cmd"]) ==
"update")
196 $s_lang =
$_POST[
"par_language"];
200 $s_lang = $this->content_obj->getLanguage();
205 if (key(
$_POST[
"cmd"]) ==
"create_par")
207 $s_lang =
$_POST[
"par_language"];
213 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
217 $s_lang = $ilUser->getLanguage();
226 $tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
228 $tpl->setVariable(
"PAR_TA_NAME",
"par_content");
230 $this->tpl->addJavascript(
"./Services/COPage/phpBB/3_0_5/editor.js");
231 $this->tpl->addJavascript(
"./Services/COPage/js/paragraph_editing.js");
236 $tpl->setVariable(
"TXT_LANGUAGE", $this->lng->txt(
"language"));
237 $tpl->setVariable(
"TXT_ANCHOR", $this->lng->txt(
"cont_anchor"));
239 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
242 $tpl->setVariable(
"SELECT_LANGUAGE", $select_lang);
244 $tpl->setVariable(
"TXT_CHARACTERISTIC", $this->lng->txt(
"cont_characteristic"));
249 if (key(
$_POST[
"cmd"]) ==
"update" || key(
$_POST[
"cmd"]) ==
"create_par")
253 $s_text = str_replace(
"{",
"{", $s_text);
254 $s_text = str_replace(
"}",
"}", $s_text);
258 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
261 $tpl->setVariable(
"PAR_TA_CONTENT", $s_text);
263 $tpl->parseCurrentBlock();
265 $this->tpl->setContent(
$tpl->get());
280 if (key(
$_POST[
"cmd"]) ==
"update")
282 $s_char =
$_POST[
"par_characteristic"];
286 $s_char = $this->content_obj->getCharacteristic();
289 $s_char =
"Standard";
295 if (key(
$_POST[
"cmd"]) ==
"create_par")
297 $s_char =
$_POST[
"par_characteristic"];
301 $s_char =
"Standard";
304 $cont_obj = $this->pg_obj->getContentObject($this->
getHierId());
305 if (is_object($cont_obj))
307 if ($cont_obj->getType() ==
"li" ||
308 ($cont_obj->getType() ==
"par" && $cont_obj->getCharacteristic() ==
"List"))
313 if ($cont_obj->getType() ==
"td" ||
314 ($cont_obj->getType() ==
"par" && $cont_obj->getCharacteristic() ==
"TableContent"))
316 $s_char =
"TableContent";
330 $s_text = $this->content_obj->getText();
331 $this->log->debug(
"step 1: ".substr($s_text, 0, 1000));
334 $s_text = $this->content_obj->xml2output($s_text,
true,
false);
335 $this->log->debug(
"step 2: ".substr($s_text, 0, 1000));
340 $this->log->debug(
"step 3: ".substr($s_text, 0, 1000));
343 $ids =
"###".$this->content_obj->readHierId().
":".$this->content_obj->readPCId().
"###".
346 $this->log->debug(
"step 4: ".substr($ids.$s_text, 0, 1000));
357 echo $this->content_obj->getParagraphSequenceContent($this->pg_obj);
369 $s_text = str_replace(
array(
"<SimpleBulletList>",
"</SimpleBulletList>"),
370 array(
"<ul class='ilc_list_u_BulletedList'>",
"</ul>"),
372 $s_text = str_replace(
array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"),
373 array(
"<ol class='ilc_list_o_NumberedList'>",
"</ol>"), $s_text);
374 $s_text = str_replace(
array(
"<SimpleListItem>",
"</SimpleListItem>"),
375 array(
"<li class='ilc_list_item_StandardListItem'>",
"</li>"), $s_text);
376 $s_text = str_replace(
array(
"<SimpleListItem/>"),
377 array(
"<li class='ilc_list_item_StandardListItem'></li>"), $s_text);
384 include_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
387 if (!in_array($bb,
array(
"code",
"tex",
"fn",
"xln",
"sub",
"sup")))
389 $s_text = str_replace(
"[".$bb.
"]",
390 '<span class="ilc_text_inline_'.$cl.
'">', $s_text);
391 $s_text = str_replace(
"[/".$bb.
"]",
397 $ws=
"[ \t\r\f\v\n]*";
398 while (preg_match(
"~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $s_text, $found))
401 if (isset($attribs[
"class"]))
403 $s_text = str_replace(
"[".$found[1].
"]",
"<span class=\"ilc_text_inline_".$attribs[
"class"].
"\">", $s_text);
407 $s_text = str_replace(
"[".$found[1].
"]",
"[error:marked".$found[1].
"]",$s_text);
410 $s_text = preg_replace(
'~\[\/marked\]~i',
"</span>",$s_text);
414 $s_text = str_replace(
array(
"[code]",
"[/code]"),
415 array(
"<code>",
"</code>"), $s_text);
418 $s_text = str_replace(
array(
"[sup]",
"[/sup]"),
419 array(
'<sup class="ilc_sup_Sup">',
"</sup>"), $s_text);
422 $s_text = str_replace(
array(
"[sub]",
"[/sub]"),
423 array(
'<sub class="ilc_sub_Sub">',
"</sub>"), $s_text);
439 $this->log->debug(
"start");
441 $this->updated = $this->content_obj->saveJS($this->pg_obj,
442 $_POST[
"ajaxform_content"],
446 $this->log->debug(
"ilPCParagraphGUI, saveJS: got updated value ".$this->updated);
450 if ($this->updated ===
true)
452 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
453 $this->log->debug(
"ilPCParagraphGUI, saveJS: echoing pc_id_str ".$a_pc_id_str.
" (and exit)");
459 if ($this->updated !==
true && is_array($this->updated))
464 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
466 $ilCtrl->setParameterByClass($ilCtrl->getReturnClass($this),
"updated_pc_id_str",
467 urlencode($a_pc_id_str));
468 $this->log->debug(
"ilPCParagraphGUI, saveJS: redirecting to edit command of ".$ilCtrl->getReturnClass($this).
".");
469 $ilCtrl->redirectByClass($ilCtrl->getReturnClass($this),
"edit",
"",
true);
480 foreach ($a_err as $err)
482 $err_str.= $err[1].
"<br />";
485 $this->log->debug(
"ilPCParagraphGUI, outputError() and exit: ".substr($err_str, 0, 100));
495 $this->log->debug(
"ilPCParagraphGUI, cancel(): return to parent: jump".$this->hier_id);
496 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
508 if ($chars[$a_seleted_value] ==
"" && ($a_seleted_value !=
""))
510 $chars = array_merge(
array($a_seleted_value => $a_seleted_value),
514 foreach ($chars as $char => $char_lang)
516 $a_tpl->setCurrentBlock(
"characteristic_cell");
517 $a_tpl->setVariable(
"CHAR_HTML",
518 '<div class="ilc_text_block_'.$char.
'" style="margin-top:2px; margin-bottom:2px; position:static;">'.$char_lang.
"</div>");
519 $a_tpl->setVariable(
"CHAR_VALUE", $char);
520 if ($char == $a_seleted_value)
522 $a_tpl->setVariable(
"SELECTED",
523 ' checked="checked" ');
525 $a_tpl->parseCurrentBlock();
526 if ((($i+1) % 3) == 0)
528 $a_tpl->touchBlock(
"characteristic_row");
532 $a_tpl->touchBlock(
"characteristic_table");
543 $a_tpl->setVariable(
"ADV_SEL_STYLE", self::getStyleSelector($a_selected,
552 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
554 $selection->setPullRight(
false);
555 $selection->setFormSelectMode(
"par_characteristic",
"",
false,
558 $selection->setId(
"style_selection");
559 $selection->setSelectionHeaderClass(
"ilEditSubmit ilTinyMenuDropDown");
561 $selection->setSelectedValue($a_selected);
562 $selection->setUseImages(
false);
566 $selection->setSelectCallback(
"ilCOPage.setParagraphClass");
570 $title_char = ($chars[$a_selected] !=
"")
571 ? $chars[$a_selected]
573 $selection->setListTitle($title_char);
575 if ($chars[$a_seleted] ==
"" && ($a_seleted !=
""))
577 $chars = array_merge(
array($a_seleted => $a_seleted),
581 foreach ($chars as $char => $char_lang)
587 case "Headline1":
$t =
"heading1"; $tag =
"h1";
break;
588 case "Headline2":
$t =
"heading2"; $tag =
"h2";
break;
589 case "Headline3":
$t =
"heading3"; $tag =
"h3";
break;
591 $html =
'<div class="ilCOPgEditStyleSelectionItem"><'.$tag.
' class="ilc_'.
$t.
'_'.$char.
'" style="'.self::$style_selector_reset.
'">'.$char_lang.
"</".$tag.
"></div>";
592 $selection->addItem($char_lang, $char,
"",
593 "", $char,
"",
$html);
595 return $selection->getHTML();
605 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
607 $selection->setPullRight(
false);
608 $selection->setFormSelectMode(
"char_characteristic",
"",
false,
611 $selection->setId(
"char_style_selection");
612 $selection->setSelectionHeaderClass(
"ilEditSubmit");
615 $selection->setUseImages(
false);
619 $selection->setSelectCallback(
"ilCOPage.setCharacterClass");
626 $selection->setListTitle(
" <i>A</i>");
635 "Comment" =>
array(
"code" =>
"com",
"txt" => $lng->txt(
"cont_char_style_com")),
636 "Quotation" =>
array(
"code" =>
"quot",
"txt" =>$lng->txt(
"cont_char_style_quot")),
637 "Accent" =>
array(
"code" =>
"acc",
"txt" => $lng->txt(
"cont_char_style_acc")),
638 "Code" =>
array(
"code" =>
"code",
"txt" => $lng->txt(
"cont_char_style_code"))
641 if ($a_style_id > 0 )
645 if (!isset($chars[$c]))
647 $chars[$c] =
array(
"code" =>
"",
"txt" => $c);
652 foreach ($chars as $key => $char)
655 $a_par_type,
"active_".$char[
"code"],
true))
661 case "Code": $tag =
"code";
break;
663 $html =
'<'.$tag.
' class="ilc_'.
$t.
'_'.$key.
'" style="font-size:90%; margin-top:2px; margin-bottom:2px; position:static;">'.$char[
"txt"].
"</".$tag.
">";
669 $html =
'<a class="nostyle" style="display:block;" href="#" onclick="return false;">'.$html.
"</a>";
670 $selection->addItem($char[
"txt"], $key,
"",
671 "", $key,
"",
$html);
674 return $selection->getHTML();
682 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
684 if ($this->pg_obj->getParentType() ==
"gdf" ||
685 $this->pg_obj->getParentType() ==
"lm")
687 if ($this->pg_obj->getParentType() !=
"gdf")
699 if ($this->pg_obj->getParentType() !=
"sahs")
711 $this->log->debug(
"ilPCParagraphGUI, saveJS: got updated value ".$this->updated);
712 return $this->
edit(
true);
720 $this->log->debug(
"ilPCParagraphGUI, update(): start");
723 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
724 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
726 $this->updated = $this->content_obj->setText(
727 $this->content_obj->input2xml(
$_POST[
"par_content"],
728 $_POST[
"usedwsiwygeditor"]),
true);
729 if ($this->updated !==
true)
735 $this->updated = $this->content_obj->updatePage($this->pg_obj);
738 if ($this->updated ===
true)
740 $this->log->debug(
"ilPCParagraphGUI, update(): return to parent: jump".$this->hier_id);
741 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
745 $this->log->debug(
"ilPCParagraphGUI, update(): call edit.");
756 $this->log->debug(
"ilPCParagraphGUI, create(): start.");
758 if (
$_POST[
"ajaxform_hier_id"] !=
"")
765 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
767 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
769 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
771 $this->updated = $this->content_obj->setText(
772 $this->content_obj->input2xml(
$_POST[
"par_content"],
773 $_POST[
"usedwsiwygeditor"]),
true);
775 if ($this->updated !==
true)
780 $this->updated = $this->content_obj->updatePage($this->pg_obj);
782 if ($this->updated ===
true)
784 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
799 $this->log->debug(
"ilPCParagraphGUI, createJS(): start");
802 $this->updated = $this->content_obj->saveJS($this->pg_obj,
803 $_POST[
"ajaxform_content"],
811 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
813 $this->log->debug(
"ilPCParagraphGUI, createJS(): echo pc id and exit: ".$a_pc_id_str);
818 if ($this->updated !==
true && is_array($this->updated))
824 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
825 $ilCtrl->setParameterByClass($ilCtrl->getReturnClass($this),
"updated_pc_id_str",
826 urlencode($a_pc_id_str));
827 $this->log->debug(
"ilPCParagraphGUI, createJS(): return to edit cmd of ".$ilCtrl->getReturnClass($this));
829 $ilCtrl->redirectByClass($ilCtrl->getReturnClass($this),
"edit",
"",
true);
839 $a_tpl->setCurrentBlock(
"help_item");
840 $a_tpl->setVariable(
"TXT_HELP",
"<b>".$lng->txt(
"cont_syntax_help").
"</b>");
841 $a_tpl->parseCurrentBlock();
842 $a_tpl->setCurrentBlock(
"help_item");
843 $a_tpl->setVariable(
"TXT_HELP",
"* ".$lng->txt(
"cont_bullet_list"));
844 $a_tpl->parseCurrentBlock();
845 $a_tpl->setCurrentBlock(
"help_item");
846 $a_tpl->setVariable(
"TXT_HELP",
"# ".$lng->txt(
"cont_numbered_list"));
847 $a_tpl->parseCurrentBlock();
848 $a_tpl->setCurrentBlock(
"help_item");
849 $a_tpl->setVariable(
"TXT_HELP",
"=".$lng->txt(
"cont_Headline1").
"=<br />".
850 "==".$lng->txt(
"cont_Headline2").
"==<br />".
851 "===".$lng->txt(
"cont_Headline3").
"===");
852 $a_tpl->parseCurrentBlock();
856 $a_tpl->setCurrentBlock(
"help_item");
857 $a_tpl->setVariable(
"TXT_HELP",
"[[".$lng->txt(
"cont_wiki_page_link").
"]]");
858 $a_tpl->parseCurrentBlock();
861 $a_tpl->setCurrentBlock(
"help");
862 $a_tpl->parseCurrentBlock();
const ON_ITEM_CLICK_FORM_SELECT
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
static _lookupStyleSheetId($a_cont_obj_id)
lookup style sheet ID
update()
update paragraph in dom and update page in db
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ...
static xml2outputJS($s_text, $char, $a_pc_id)
Prepare content for js output.
edit($a_insert=false)
edit paragraph form
getHierId()
get hierarchical id in dom object
static _getCharacteristics($a_style_id)
Get characteristics.
insertStyleSelectionList($a_tpl, $a_selected)
Insert style selection list.
static _getStandardCharacteristics()
Get standard characteristics.
static _getTextCharacteristics($a_style_id, $a_include_core=false)
Get text characteristics.
static getStyleSelector($a_selected, $a_chars, $a_use_callback=false)
Get style selector.
getPageConfig()
Get Page Config.
insert()
insert paragraph form
saveJS()
Save paragraph by JS call.
create()
create new paragraph in dom and update page in db
setCharacteristics($a_chars)
Set Characteristics.
getBBMenu($a_ta_name="par_content")
Get the bb menu incl.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
editJS()
Edit paragraph (Ajax mode, sends the content of the paragraph)
static getCharStyleSelector($a_par_type, $a_use_callback=true, $a_style_id=0)
Get character style selector.
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.
special template class to simplify handling of ITX/PEAR
displayValidationError()
display validation errors
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getCharacteristics()
Get characteristics.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
editMultipleJS()
Edit multiple paragraphs (Ajax mode, sends the content of the paragraphs)
User interface class for advanced drop-down selection lists.
static getContentStylePath($a_style_id)
get content style path
static lookupSettingByParentType($a_par_type, $a_name, $a_default=false)
Lookup setting by parent type.
determineCharacteristic($a_insert=false)
Determine current characteristic.
executeCommand()
execute command
static _getCommonBBButtons()
Get common bb buttons.
outputError($a_err)
Output error.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
insertCharacteristicTable($a_tpl, $a_seleted_value)
Insert characteristic table.
__construct($a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor public.
insertHelp($a_tpl)
Insert Help.
createJS()
Create paragraph per JS.