4require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
5require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
28 public function __construct($a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id =
"")
32 $this->
user = $DIC->user();
33 $this->ctrl =
$DIC->ctrl();
34 $this->lng =
$DIC->language();
35 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
50 return array(
"Standard" =>
$lng->txt(
"cont_standard"),
51 "Headline1" =>
$lng->txt(
"cont_Headline1"),
52 "Headline2" =>
$lng->txt(
"cont_Headline2"),
53 "Headline3" =>
$lng->txt(
"cont_Headline3"),
54 "Citation" =>
$lng->txt(
"cont_Citation"),
55 "Mnemonic" =>
$lng->txt(
"cont_Mnemonic"),
56 "Example" =>
$lng->txt(
"cont_Example"),
57 "Additional" =>
$lng->txt(
"cont_Additional"),
58 "Attention" =>
$lng->txt(
"cont_Attention"),
59 "Confirmation" =>
$lng->txt(
"cont_Confirmation"),
60 "Information" =>
$lng->txt(
"cont_Information"),
61 "Link" =>
$lng->txt(
"cont_Link"),
62 "Literature" =>
$lng->txt(
"cont_Literature"),
63 "Separator" =>
$lng->txt(
"cont_Separator"),
64 "StandardCenter" =>
$lng->txt(
"cont_StandardCenter"),
65 "Remark" =>
$lng->txt(
"cont_Remark"),
66 "List" =>
$lng->txt(
"cont_List"),
67 "TableContent" =>
$lng->txt(
"cont_TableContent")
79 return [
"Mnemonic",
"Attention"];
80 return array(
"Mnemonic" =>
$lng->txt(
"cont_Mnemonic"),
81 "Attention" =>
$lng->txt(
"cont_Attention")
93 if ($a_style_id > 0 &&
95 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
97 $types = array(
"text_block",
"heading1",
"heading2",
"heading3");
99 foreach ($types as
$t) {
100 $chars = array_merge($chars,
$style->getCharacteristics(
$t));
102 $new_chars = array();
103 foreach ($chars as $char) {
104 if ($st_chars[$char] !=
"") {
105 $new_chars[$char] = $st_chars[$char];
107 $new_chars[$char] = $char;
128 if ($a_style_id > 0 &&
130 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
132 $types = array(
"text_inline");
133 foreach ($types as
$t) {
134 $chars = array_merge($chars,
$style->getCharacteristics(
$t,
false, $a_include_core));
150 $next_class = $this->ctrl->getNextClass($this);
153 array(
"text_block",
"heading1",
"heading2",
"heading3")
157 $cmd = $this->ctrl->getCmd();
159 $this->log->debug(
"ilPCParagraphGUI: executeCommand " . $cmd);
161 switch ($next_class) {
163 $ret = $this->$cmd();
173 public function edit($a_insert =
false)
178 $tpl =
new ilTemplate(
"tpl.paragraph_edit.html",
true,
true,
"Services/COPage");
185 $tpl->setCurrentBlock(
"commands");
186 $tpl->setVariable(
"BTN_NAME",
"create_par");
187 $tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
188 $tpl->setVariable(
"BTN_CANCEL",
"cancelCreate");
189 $tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
190 $tpl->parseCurrentBlock();
197 $tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_insert_par"));
199 $tpl->setCurrentBlock(
"commands");
200 $tpl->setVariable(
"BTN_NAME",
"update");
201 $tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
202 $tpl->setVariable(
"BTN_CANCEL",
"cancelUpdate");
203 $tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
204 $tpl->parseCurrentBlock();
211 $tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_edit_par"));
217 if (key(
$_POST[
"cmd"]) ==
"update") {
218 $s_lang =
$_POST[
"par_language"];
220 $s_lang = $this->content_obj->getLanguage();
223 if (key(
$_POST[
"cmd"]) ==
"create_par") {
224 $s_lang =
$_POST[
"par_language"];
229 $s_lang =
$ilUser->getLanguage();
238 $tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
240 $tpl->setVariable(
"PAR_TA_NAME",
"par_content");
242 $this->tpl->addJavascript(
"./Services/COPage/phpBB/3_0_5/editor.js");
243 $this->tpl->addJavascript(
"./Services/COPage/js/paragraph_editing.js");
248 $tpl->setVariable(
"TXT_LANGUAGE", $this->lng->txt(
"language"));
249 $tpl->setVariable(
"TXT_ANCHOR", $this->lng->txt(
"cont_anchor"));
251 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
254 $tpl->setVariable(
"SELECT_LANGUAGE", $select_lang);
256 $tpl->setVariable(
"TXT_CHARACTERISTIC", $this->lng->txt(
"cont_characteristic"));
261 if (key(
$_POST[
"cmd"]) ==
"update" || key(
$_POST[
"cmd"]) ==
"create_par") {
264 $s_text = str_replace(
"{",
"{", $s_text);
265 $s_text = str_replace(
"}",
"}", $s_text);
266 } elseif (!$a_insert) {
267 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
270 $tpl->setVariable(
"PAR_TA_CONTENT", $s_text);
272 $tpl->parseCurrentBlock();
274 $this->tpl->setContent(
$tpl->get());
288 if (key(
$_POST[
"cmd"]) ==
"update") {
289 $s_char =
$_POST[
"par_characteristic"];
291 $s_char = $this->content_obj->getCharacteristic();
293 $s_char =
"Standard";
297 if (key(
$_POST[
"cmd"]) ==
"create_par") {
298 $s_char =
$_POST[
"par_characteristic"];
300 $s_char =
"Standard";
303 $cont_obj = $this->pg_obj->getContentObject($this->
getHierId());
304 if (is_object($cont_obj)) {
305 if ($cont_obj->getType() ==
"li" ||
306 ($cont_obj->getType() ==
"par" && $cont_obj->getCharacteristic() ==
"List")) {
310 if ($cont_obj->getType() ==
"td" ||
311 ($cont_obj->getType() ==
"par" && $cont_obj->getCharacteristic() ==
"TableContent")) {
312 $s_char =
"TableContent";
325 $s_text = $this->content_obj->getText();
326 $this->log->debug(
"step 1: " . substr($s_text, 0, 1000));
329 $s_text = $this->content_obj->xml2output($s_text,
true,
false);
330 $this->log->debug(
"step 2: " . substr($s_text, 0, 1000));
335 $this->log->debug(
"step 3: " . substr($s_text, 0, 1000));
338 $ids =
"###" . $this->content_obj->readHierId() .
":" . $this->content_obj->readPCId() .
"###" .
341 $this->log->debug(
"step 4: " . substr($ids . $s_text, 0, 1000));
350 echo $this->content_obj->getParagraphSequenceContent($this->pg_obj);
362 $s_text = str_replace(
363 array(
"<SimpleBulletList>",
"</SimpleBulletList>"),
364 array(
"<ul class='ilc_list_u_BulletedList'>",
"</ul>"),
367 $s_text = str_replace(
368 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"),
369 array(
"<ol class='ilc_list_o_NumberedList'>",
"</ol>"),
372 $s_text = str_replace(
373 array(
"<SimpleListItem>",
"</SimpleListItem>"),
374 array(
"<li class='ilc_list_item_StandardListItem'>",
"</li>"),
377 $s_text = str_replace(
378 array(
"<SimpleListItem/>"),
379 array(
"<li class='ilc_list_item_StandardListItem'></li>"),
388 include_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
390 if (!in_array($bb, array(
"code",
"tex",
"fn",
"xln",
"sub",
"sup"))) {
391 $s_text = str_replace(
393 '<span class="ilc_text_inline_' . $cl .
'">',
396 $s_text = str_replace(
405 $ws =
"[ \t\r\f\v\n]*";
406 while (preg_match(
"~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $s_text, $found)) {
408 if (isset($attribs[
"class"])) {
409 $s_text = str_replace(
"[" . $found[1] .
"]",
"<span class=\"ilc_text_inline_" . $attribs[
"class"] .
"\">", $s_text);
411 $s_text = str_replace(
"[" . $found[1] .
"]",
"[error:marked" . $found[1] .
"]", $s_text);
414 $s_text = preg_replace(
'~\[\/marked\]~i',
"</span>", $s_text);
418 $s_text = str_replace(
419 array(
"[code]",
"[/code]"),
420 array(
"<code>",
"</code>"),
425 $s_text = str_replace(
426 array(
"[sup]",
"[/sup]"),
427 array(
'<sup class="ilc_sup_Sup">',
"</sup>"),
432 $s_text = str_replace(
433 array(
"[sub]",
"[/sub]"),
434 array(
'<sub class="ilc_sub_Sub">',
"</sub>"),
452 $this->log->debug(
"start");
454 $this->updated = $this->content_obj->saveJS(
456 $_POST[
"ajaxform_content"],
461 $this->log->debug(
"ilPCParagraphGUI, saveJS: got updated value " . $this->updated);
463 if (
$_POST[
"quick_save"]) {
464 if ($this->updated ===
true) {
465 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
466 $this->log->debug(
"ilPCParagraphGUI, saveJS: echoing pc_id_str " . $a_pc_id_str .
" (and exit)");
472 if ($this->updated !==
true && is_array($this->updated)) {
476 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
479 $ilCtrl->getReturnClass($this),
481 urlencode($a_pc_id_str)
483 $this->log->debug(
"ilPCParagraphGUI, saveJS: redirecting to edit command of " .
$ilCtrl->getReturnClass($this) .
".");
484 $ilCtrl->redirectByClass(
$ilCtrl->getReturnClass($this),
"edit",
"",
true);
495 foreach ($a_err as $err) {
496 $err_str .= $err[1] .
"<br />";
499 $this->log->debug(
"ilPCParagraphGUI, outputError() and exit: " . substr($err_str, 0, 100));
509 $this->log->debug(
"ilPCParagraphGUI, cancel(): return to parent: jump" . $this->hier_id);
510 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
522 if ($chars[$a_seleted_value] ==
"" && ($a_seleted_value !=
"")) {
523 $chars = array_merge(
524 array($a_seleted_value => $a_seleted_value),
529 foreach ($chars as $char => $char_lang) {
530 $a_tpl->setCurrentBlock(
"characteristic_cell");
533 '<div class="ilc_text_block_' . $char .
'" style="margin-top:2px; margin-bottom:2px; position:static;">' . $char_lang .
"</div>"
535 $a_tpl->setVariable(
"CHAR_VALUE", $char);
536 if ($char == $a_seleted_value) {
539 ' checked="checked" '
542 $a_tpl->parseCurrentBlock();
543 if (((
$i + 1) % 3) == 0) {
544 $a_tpl->touchBlock(
"characteristic_row");
548 $a_tpl->touchBlock(
"characteristic_table");
559 $a_tpl->setVariable(
"ADV_SEL_STYLE", self::getStyleSelector(
570 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
572 $selection->setPullRight(
false);
573 $selection->setFormSelectMode(
574 "par_characteristic",
585 $selection->setId(
"style_selection");
586 $selection->setSelectionHeaderClass(
"ilEditSubmit ilTinyMenuDropDown");
588 $selection->setSelectedValue($a_selected);
589 $selection->setUseImages(
false);
591 if ($a_use_callback) {
592 $selection->setSelectCallback(
"ilCOPage.setParagraphClass");
596 $title_char = ($chars[$a_selected] !=
"")
597 ? $chars[$a_selected]
599 $selection->setListTitle($title_char);
601 if ($chars[$a_seleted] ==
"" && ($a_seleted !=
"")) {
602 $chars = array_merge(
603 array($a_seleted => $a_seleted),
608 foreach ($chars as $char => $char_lang) {
612 case "Headline1":
$t =
"heading1";
$tag =
"h1";
break;
613 case "Headline2":
$t =
"heading2";
$tag =
"h2";
break;
614 case "Headline3":
$t =
"heading3";
$tag =
"h3";
break;
616 $html =
'<div class="ilCOPgEditStyleSelectionItem"><' .
$tag .
' class="ilc_' .
$t .
'_' . $char .
'" style="' . self::$style_selector_reset .
'">' . $char_lang .
"</" .
$tag .
"></div>";
627 return $selection->getHTML();
639 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
641 $selection->setPullRight(
false);
642 $selection->setFormSelectMode(
643 "char_characteristic",
654 $selection->setId(
"char_style_selection");
655 $selection->setSelectionHeaderClass(
"ilEditSubmit");
658 $selection->setUseImages(
false);
660 if (is_string($a_use_callback)) {
661 $selection->setSelectCallback($a_use_callback);
662 } elseif ($a_use_callback ===
true) {
663 $selection->setSelectCallback(
"ilCOPage.setCharacterClass");
670 $selection->setListTitle(
" <i>A</i>");
679 "Comment" => array(
"code" =>
"com",
"txt" =>
$lng->txt(
"cont_char_style_com")),
680 "Quotation" => array(
"code" =>
"quot",
"txt" =>
$lng->txt(
"cont_char_style_quot")),
681 "Accent" => array(
"code" =>
"acc",
"txt" =>
$lng->txt(
"cont_char_style_acc")),
682 "Code" => array(
"code" =>
"code",
"txt" =>
$lng->txt(
"cont_char_style_code"))
686 if (!isset($chars[
$c])) {
687 $chars[
$c] = array(
"code" =>
"",
"txt" =>
$c);
691 foreach ($chars as
$key => $char) {
694 "active_" . $char[
"code"],
700 case "Code":
$tag =
"code";
break;
702 $html =
'<' .
$tag .
' class="ilc_' .
$t .
'_' .
$key .
'" style="font-size:90%; margin-top:2px; margin-bottom:2px; position:static;">' . $char[
"txt"] .
"</" .
$tag .
">";
708 $html =
'<a class="nostyle" style="display:block;" href="#" onclick="return false;">' .
$html .
"</a>";
720 return $selection->getHTML();
728 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
730 if ($this->pg_obj->getParentType() ==
"gdf" ||
731 $this->pg_obj->getParentType() ==
"lm") {
732 if ($this->pg_obj->getParentType() !=
"gdf") {
740 if ($this->pg_obj->getParentType() !=
"sahs") {
751 $this->log->debug(
"ilPCParagraphGUI, saveJS: got updated value " . $this->updated);
752 return $this->
edit(
true);
760 $this->log->debug(
"ilPCParagraphGUI, update(): start");
763 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
764 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
766 $this->updated = $this->content_obj->setText(
767 $this->content_obj->input2xml(
769 $_POST[
"usedwsiwygeditor"]
773 if ($this->updated !==
true) {
778 $this->updated = $this->content_obj->updatePage($this->pg_obj);
781 if ($this->updated ===
true) {
782 $this->log->debug(
"ilPCParagraphGUI, update(): return to parent: jump" . $this->hier_id);
783 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
785 $this->log->debug(
"ilPCParagraphGUI, update(): call edit.");
796 $this->log->debug(
"ilPCParagraphGUI, create(): start.");
798 if (
$_POST[
"ajaxform_hier_id"] !=
"") {
804 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
806 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
808 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
810 $this->updated = $this->content_obj->setText(
811 $this->content_obj->input2xml(
813 $_POST[
"usedwsiwygeditor"]
818 if ($this->updated !==
true) {
822 $this->updated = $this->content_obj->updatePage($this->pg_obj);
824 if ($this->updated ===
true) {
825 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
839 $this->log->debug(
"ilPCParagraphGUI, createJS(): start");
842 $this->updated = $this->content_obj->saveJS(
844 $_POST[
"ajaxform_content"],
849 if (
$_POST[
"quick_save"]) {
850 if ($this->updated) {
851 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
853 $this->log->debug(
"ilPCParagraphGUI, createJS(): echo pc id and exit: " . $a_pc_id_str);
858 if ($this->updated !==
true && is_array($this->updated)) {
863 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
865 $ilCtrl->getReturnClass($this),
867 urlencode($a_pc_id_str)
869 $this->log->debug(
"ilPCParagraphGUI, createJS(): return to edit cmd of " .
$ilCtrl->getReturnClass($this));
871 $ilCtrl->redirectByClass(
$ilCtrl->getReturnClass($this),
"edit",
"",
true);
881 $a_tpl->setCurrentBlock(
"help_item");
882 $a_tpl->setVariable(
"TXT_HELP",
"<b>" .
$lng->txt(
"cont_syntax_help") .
"</b>");
883 $a_tpl->parseCurrentBlock();
884 $a_tpl->setCurrentBlock(
"help_item");
885 $a_tpl->setVariable(
"TXT_HELP",
"* " .
$lng->txt(
"cont_bullet_list"));
886 $a_tpl->parseCurrentBlock();
887 $a_tpl->setCurrentBlock(
"help_item");
888 $a_tpl->setVariable(
"TXT_HELP",
"# " .
$lng->txt(
"cont_numbered_list"));
889 $a_tpl->parseCurrentBlock();
890 $a_tpl->setCurrentBlock(
"help_item");
891 $a_tpl->setVariable(
"TXT_HELP",
"=" .
$lng->txt(
"cont_Headline1") .
"=<br />" .
892 "==" .
$lng->txt(
"cont_Headline2") .
"==<br />" .
893 "===" .
$lng->txt(
"cont_Headline3") .
"===");
894 $a_tpl->parseCurrentBlock();
897 $a_tpl->setCurrentBlock(
"help_item");
898 $a_tpl->setVariable(
"TXT_HELP",
"[[" .
$lng->txt(
"cont_wiki_page_link") .
"]]");
899 $a_tpl->parseCurrentBlock();
902 $a_tpl->setCurrentBlock(
"help");
903 $a_tpl->parseCurrentBlock();
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
const ON_ITEM_CLICK_FORM_SELECT
static _lookupStyleSheetId($a_cont_obj_id)
lookup style sheet ID
static getContentStylePath($a_style_id, $add_random=true)
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.
__construct($a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
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
executeCommand()
execute command
static _getCharacteristics($a_style_id)
Get 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.
static _getStandardTextCharacteristics()
Get standard characteristics.
edit($a_insert=false)
edit paragraph form
insertHelp($a_tpl)
Insert Help.
insertStyleSelectionList($a_tpl, $a_selected)
Insert style selection list.
static getCharStyleSelector($a_par_type, $a_use_callback=true, $a_style_id=0)
Get character style selector.
static _getStandardCharacteristics()
Get standard characteristics.
update()
update paragraph in dom and update page in db
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.
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ... into an array
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag