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 "Remark" =>
$lng->txt(
"cont_Remark"),
59 "List" =>
$lng->txt(
"cont_List"),
60 "TableContent" =>
$lng->txt(
"cont_TableContent")
72 if ($a_style_id > 0 &&
74 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
76 $types = array(
"text_block",
"heading1",
"heading2",
"heading3");
78 foreach ($types as
$t) {
79 $chars = array_merge($chars,
$style->getCharacteristics(
$t));
82 foreach ($chars as $char) {
83 if ($st_chars[$char] !=
"") {
84 $new_chars[$char] = $st_chars[$char];
86 $new_chars[$char] = $char;
107 if ($a_style_id > 0 &&
109 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
111 $types = array(
"text_inline");
112 foreach ($types as
$t) {
113 $chars = array_merge($chars,
$style->getCharacteristics(
$t,
false, $a_include_core));
127 $next_class = $this->ctrl->getNextClass($this);
130 array(
"text_block",
"heading1",
"heading2",
"heading3")
134 $cmd = $this->ctrl->getCmd();
136 $this->log->debug(
"ilPCParagraphGUI: executeCommand " . $cmd);
138 switch ($next_class) {
140 $ret = $this->$cmd();
150 public function edit($a_insert =
false)
155 $tpl =
new ilTemplate(
"tpl.paragraph_edit.html",
true,
true,
"Services/COPage");
162 $tpl->setCurrentBlock(
"commands");
163 $tpl->setVariable(
"BTN_NAME",
"create_par");
164 $tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
165 $tpl->setVariable(
"BTN_CANCEL",
"cancelCreate");
166 $tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
167 $tpl->parseCurrentBlock();
174 $tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_insert_par"));
176 $tpl->setCurrentBlock(
"commands");
177 $tpl->setVariable(
"BTN_NAME",
"update");
178 $tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
179 $tpl->setVariable(
"BTN_CANCEL",
"cancelUpdate");
180 $tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
181 $tpl->parseCurrentBlock();
188 $tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_edit_par"));
194 if (key(
$_POST[
"cmd"]) ==
"update") {
195 $s_lang =
$_POST[
"par_language"];
197 $s_lang = $this->content_obj->getLanguage();
200 if (key(
$_POST[
"cmd"]) ==
"create_par") {
201 $s_lang =
$_POST[
"par_language"];
206 $s_lang =
$ilUser->getLanguage();
215 $tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
217 $tpl->setVariable(
"PAR_TA_NAME",
"par_content");
219 $this->tpl->addJavascript(
"./Services/COPage/phpBB/3_0_5/editor.js");
220 $this->tpl->addJavascript(
"./Services/COPage/js/paragraph_editing.js");
225 $tpl->setVariable(
"TXT_LANGUAGE", $this->lng->txt(
"language"));
226 $tpl->setVariable(
"TXT_ANCHOR", $this->lng->txt(
"cont_anchor"));
228 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
231 $tpl->setVariable(
"SELECT_LANGUAGE", $select_lang);
233 $tpl->setVariable(
"TXT_CHARACTERISTIC", $this->lng->txt(
"cont_characteristic"));
238 if (key(
$_POST[
"cmd"]) ==
"update" || key(
$_POST[
"cmd"]) ==
"create_par") {
241 $s_text = str_replace(
"{",
"{", $s_text);
242 $s_text = str_replace(
"}",
"}", $s_text);
243 } elseif (!$a_insert) {
244 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
247 $tpl->setVariable(
"PAR_TA_CONTENT", $s_text);
249 $tpl->parseCurrentBlock();
251 $this->tpl->setContent(
$tpl->get());
265 if (key(
$_POST[
"cmd"]) ==
"update") {
266 $s_char =
$_POST[
"par_characteristic"];
268 $s_char = $this->content_obj->getCharacteristic();
270 $s_char =
"Standard";
274 if (key(
$_POST[
"cmd"]) ==
"create_par") {
275 $s_char =
$_POST[
"par_characteristic"];
277 $s_char =
"Standard";
280 $cont_obj = $this->pg_obj->getContentObject($this->
getHierId());
281 if (is_object($cont_obj)) {
282 if ($cont_obj->getType() ==
"li" ||
283 ($cont_obj->getType() ==
"par" && $cont_obj->getCharacteristic() ==
"List")) {
287 if ($cont_obj->getType() ==
"td" ||
288 ($cont_obj->getType() ==
"par" && $cont_obj->getCharacteristic() ==
"TableContent")) {
289 $s_char =
"TableContent";
302 $s_text = $this->content_obj->getText();
303 $this->log->debug(
"step 1: " . substr($s_text, 0, 1000));
306 $s_text = $this->content_obj->xml2output($s_text,
true,
false);
307 $this->log->debug(
"step 2: " . substr($s_text, 0, 1000));
312 $this->log->debug(
"step 3: " . substr($s_text, 0, 1000));
315 $ids =
"###" . $this->content_obj->readHierId() .
":" . $this->content_obj->readPCId() .
"###" .
318 $this->log->debug(
"step 4: " . substr($ids . $s_text, 0, 1000));
327 echo $this->content_obj->getParagraphSequenceContent($this->pg_obj);
339 $s_text = str_replace(
340 array(
"<SimpleBulletList>",
"</SimpleBulletList>"),
341 array(
"<ul class='ilc_list_u_BulletedList'>",
"</ul>"),
344 $s_text = str_replace(
345 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"),
346 array(
"<ol class='ilc_list_o_NumberedList'>",
"</ol>"),
349 $s_text = str_replace(
350 array(
"<SimpleListItem>",
"</SimpleListItem>"),
351 array(
"<li class='ilc_list_item_StandardListItem'>",
"</li>"),
354 $s_text = str_replace(
355 array(
"<SimpleListItem/>"),
356 array(
"<li class='ilc_list_item_StandardListItem'></li>"),
365 include_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
367 if (!in_array($bb, array(
"code",
"tex",
"fn",
"xln",
"sub",
"sup"))) {
368 $s_text = str_replace(
370 '<span class="ilc_text_inline_' . $cl .
'">',
373 $s_text = str_replace(
382 $ws=
"[ \t\r\f\v\n]*";
383 while (preg_match(
"~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $s_text, $found)) {
385 if (isset($attribs[
"class"])) {
386 $s_text = str_replace(
"[" . $found[1] .
"]",
"<span class=\"ilc_text_inline_" . $attribs[
"class"] .
"\">", $s_text);
388 $s_text = str_replace(
"[" . $found[1] .
"]",
"[error:marked" . $found[1] .
"]", $s_text);
391 $s_text = preg_replace(
'~\[\/marked\]~i',
"</span>", $s_text);
395 $s_text = str_replace(
396 array(
"[code]",
"[/code]"),
397 array(
"<code>",
"</code>"),
402 $s_text = str_replace(
403 array(
"[sup]",
"[/sup]"),
404 array(
'<sup class="ilc_sup_Sup">',
"</sup>"),
409 $s_text = str_replace(
410 array(
"[sub]",
"[/sub]"),
411 array(
'<sub class="ilc_sub_Sub">',
"</sub>"),
429 $this->log->debug(
"start");
431 $this->updated = $this->content_obj->saveJS(
433 $_POST[
"ajaxform_content"],
438 $this->log->debug(
"ilPCParagraphGUI, saveJS: got updated value " . $this->updated);
440 if (
$_POST[
"quick_save"]) {
441 if ($this->updated ===
true) {
442 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
443 $this->log->debug(
"ilPCParagraphGUI, saveJS: echoing pc_id_str " . $a_pc_id_str .
" (and exit)");
449 if ($this->updated !==
true && is_array($this->updated)) {
453 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
456 $ilCtrl->getReturnClass($this),
458 urlencode($a_pc_id_str)
460 $this->log->debug(
"ilPCParagraphGUI, saveJS: redirecting to edit command of " .
$ilCtrl->getReturnClass($this) .
".");
461 $ilCtrl->redirectByClass(
$ilCtrl->getReturnClass($this),
"edit",
"",
true);
472 foreach ($a_err as $err) {
473 $err_str.= $err[1] .
"<br />";
476 $this->log->debug(
"ilPCParagraphGUI, outputError() and exit: " . substr($err_str, 0, 100));
486 $this->log->debug(
"ilPCParagraphGUI, cancel(): return to parent: jump" . $this->hier_id);
487 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
499 if ($chars[$a_seleted_value] ==
"" && ($a_seleted_value !=
"")) {
500 $chars = array_merge(
501 array($a_seleted_value => $a_seleted_value),
506 foreach ($chars as $char => $char_lang) {
507 $a_tpl->setCurrentBlock(
"characteristic_cell");
510 '<div class="ilc_text_block_' . $char .
'" style="margin-top:2px; margin-bottom:2px; position:static;">' . $char_lang .
"</div>"
512 $a_tpl->setVariable(
"CHAR_VALUE", $char);
513 if ($char == $a_seleted_value) {
516 ' checked="checked" '
519 $a_tpl->parseCurrentBlock();
520 if (((
$i+1) % 3) == 0) {
521 $a_tpl->touchBlock(
"characteristic_row");
525 $a_tpl->touchBlock(
"characteristic_table");
536 $a_tpl->setVariable(
"ADV_SEL_STYLE", self::getStyleSelector(
547 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
549 $selection->setPullRight(
false);
550 $selection->setFormSelectMode(
551 "par_characteristic",
562 $selection->setId(
"style_selection");
563 $selection->setSelectionHeaderClass(
"ilEditSubmit ilTinyMenuDropDown");
565 $selection->setSelectedValue($a_selected);
566 $selection->setUseImages(
false);
568 if ($a_use_callback) {
569 $selection->setSelectCallback(
"ilCOPage.setParagraphClass");
573 $title_char = ($chars[$a_selected] !=
"")
574 ? $chars[$a_selected]
576 $selection->setListTitle($title_char);
578 if ($chars[$a_seleted] ==
"" && ($a_seleted !=
"")) {
579 $chars = array_merge(
580 array($a_seleted => $a_seleted),
585 foreach ($chars as $char => $char_lang) {
589 case "Headline1":
$t =
"heading1";
$tag =
"h1";
break;
590 case "Headline2":
$t =
"heading2";
$tag =
"h2";
break;
591 case "Headline3":
$t =
"heading3";
$tag =
"h3";
break;
593 $html =
'<div class="ilCOPgEditStyleSelectionItem"><' .
$tag .
' class="ilc_' .
$t .
'_' . $char .
'" style="' . self::$style_selector_reset .
'">' . $char_lang .
"</" .
$tag .
"></div>";
604 return $selection->getHTML();
616 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
618 $selection->setPullRight(
false);
619 $selection->setFormSelectMode(
620 "char_characteristic",
631 $selection->setId(
"char_style_selection");
632 $selection->setSelectionHeaderClass(
"ilEditSubmit");
635 $selection->setUseImages(
false);
637 if (is_string($a_use_callback)) {
638 $selection->setSelectCallback($a_use_callback);
639 } elseif ($a_use_callback ===
true) {
640 $selection->setSelectCallback(
"ilCOPage.setCharacterClass");
647 $selection->setListTitle(
" <i>A</i>");
656 "Comment" => array(
"code" =>
"com",
"txt" =>
$lng->txt(
"cont_char_style_com")),
657 "Quotation" => array(
"code" =>
"quot",
"txt" =>
$lng->txt(
"cont_char_style_quot")),
658 "Accent" => array(
"code" =>
"acc",
"txt" =>
$lng->txt(
"cont_char_style_acc")),
659 "Code" => array(
"code" =>
"code",
"txt" =>
$lng->txt(
"cont_char_style_code"))
662 if ($a_style_id > 0) {
664 if (!isset($chars[$c])) {
665 $chars[$c] = array(
"code" =>
"",
"txt" => $c);
670 foreach ($chars as
$key => $char) {
673 "active_" . $char[
"code"],
679 case "Code":
$tag =
"code";
break;
681 $html =
'<' .
$tag .
' class="ilc_' .
$t .
'_' .
$key .
'" style="font-size:90%; margin-top:2px; margin-bottom:2px; position:static;">' . $char[
"txt"] .
"</" .
$tag .
">";
687 $html =
'<a class="nostyle" style="display:block;" href="#" onclick="return false;">' .
$html .
"</a>";
699 return $selection->getHTML();
707 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
709 if ($this->pg_obj->getParentType() ==
"gdf" ||
710 $this->pg_obj->getParentType() ==
"lm") {
711 if ($this->pg_obj->getParentType() !=
"gdf") {
719 if ($this->pg_obj->getParentType() !=
"sahs") {
730 $this->log->debug(
"ilPCParagraphGUI, saveJS: got updated value " . $this->updated);
731 return $this->
edit(
true);
739 $this->log->debug(
"ilPCParagraphGUI, update(): start");
742 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
743 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
745 $this->updated = $this->content_obj->setText(
746 $this->content_obj->input2xml(
748 $_POST[
"usedwsiwygeditor"]
752 if ($this->updated !==
true) {
757 $this->updated = $this->content_obj->updatePage($this->pg_obj);
760 if ($this->updated ===
true) {
761 $this->log->debug(
"ilPCParagraphGUI, update(): return to parent: jump" . $this->hier_id);
762 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
764 $this->log->debug(
"ilPCParagraphGUI, update(): call edit.");
775 $this->log->debug(
"ilPCParagraphGUI, create(): start.");
777 if (
$_POST[
"ajaxform_hier_id"] !=
"") {
783 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
785 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
787 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
789 $this->updated = $this->content_obj->setText(
790 $this->content_obj->input2xml(
792 $_POST[
"usedwsiwygeditor"]
797 if ($this->updated !==
true) {
801 $this->updated = $this->content_obj->updatePage($this->pg_obj);
803 if ($this->updated ===
true) {
804 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
818 $this->log->debug(
"ilPCParagraphGUI, createJS(): start");
821 $this->updated = $this->content_obj->saveJS(
823 $_POST[
"ajaxform_content"],
828 if (
$_POST[
"quick_save"]) {
829 if ($this->updated) {
830 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
832 $this->log->debug(
"ilPCParagraphGUI, createJS(): echo pc id and exit: " . $a_pc_id_str);
837 if ($this->updated !==
true && is_array($this->updated)) {
842 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj,
true);
844 $ilCtrl->getReturnClass($this),
846 urlencode($a_pc_id_str)
848 $this->log->debug(
"ilPCParagraphGUI, createJS(): return to edit cmd of " .
$ilCtrl->getReturnClass($this));
850 $ilCtrl->redirectByClass(
$ilCtrl->getReturnClass($this),
"edit",
"",
true);
860 $a_tpl->setCurrentBlock(
"help_item");
861 $a_tpl->setVariable(
"TXT_HELP",
"<b>" .
$lng->txt(
"cont_syntax_help") .
"</b>");
862 $a_tpl->parseCurrentBlock();
863 $a_tpl->setCurrentBlock(
"help_item");
864 $a_tpl->setVariable(
"TXT_HELP",
"* " .
$lng->txt(
"cont_bullet_list"));
865 $a_tpl->parseCurrentBlock();
866 $a_tpl->setCurrentBlock(
"help_item");
867 $a_tpl->setVariable(
"TXT_HELP",
"# " .
$lng->txt(
"cont_numbered_list"));
868 $a_tpl->parseCurrentBlock();
869 $a_tpl->setCurrentBlock(
"help_item");
870 $a_tpl->setVariable(
"TXT_HELP",
"=" .
$lng->txt(
"cont_Headline1") .
"=<br />" .
871 "==" .
$lng->txt(
"cont_Headline2") .
"==<br />" .
872 "===" .
$lng->txt(
"cont_Headline3") .
"===");
873 $a_tpl->parseCurrentBlock();
876 $a_tpl->setCurrentBlock(
"help_item");
877 $a_tpl->setVariable(
"TXT_HELP",
"[[" .
$lng->txt(
"cont_wiki_page_link") .
"]]");
878 $a_tpl->parseCurrentBlock();
881 $a_tpl->setCurrentBlock(
"help");
882 $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.
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
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag