4 require_once(
"./Services/COPage/classes/class.ilPCDataTable.php");
5 require_once(
"./Services/COPage/classes/class.ilPCTableGUI.php");
6 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
28 $this->
setCharacteristics(array(
"StandardTable" => $this->lng->txt(
"cont_StandardTable")));
39 $next_class = $this->ctrl->getNextClass($this);
42 $cmd = $this->ctrl->getCmd();
72 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
74 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.tabledata.html",
"Services/COPage");
77 $dtpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"tableAction"));
78 $dtpl->setVariable(
"BB_MENU", $this->
getBBMenu(
"cell_0_0"));
80 $this->tpl->addJavascript(
"./Services/COPage/phpBB/3_0_5/editor.js");
81 $this->tpl->addJavascript(
"./Services/COPage/js/page_editing.js");
82 $this->tpl->addJavascript(
"./Services/COPage/js/paragraph_editing.js");
86 $path =
"//PageContent[@HierId='".$this->getHierId().
"']".
90 for($i = 0; $i < count(
$res->nodeset); $i++)
94 $path2 =
"//PageContent[@HierId='".$this->getHierId().
"']".
95 "/Table/TableRow[$i+1]/TableData";
101 for($j = 0; $j < count($res2->nodeset); $j++)
105 $dtpl->touchBlock(
"empty_td");
110 if (count($res2->nodeset) == 1)
116 $move_type =
"forward";
119 else if ($j == (count($res2->nodeset) - 1))
121 $move_type =
"backward";
127 $dtpl->setCurrentBlock(
"col_icon");
128 $dtpl->setVariable(
"COL_ICON_ALT", $lng->txt(
"content_column"));
130 $dtpl->setVariable(
"COL_ONCLICK",
"COL_".$move_type);
131 $dtpl->setVariable(
"NR", $j);
132 $dtpl->parseCurrentBlock();
134 $dtpl->setCurrentBlock(
"row");
135 $dtpl->parseCurrentBlock();
139 for($j = 0; $j < count($res2->nodeset); $j++)
146 if (count(
$res->nodeset) == 1)
152 $move_type =
"forward";
155 else if ($i == (count(
$res->nodeset) - 1))
157 $move_type =
"backward";
163 $dtpl->setCurrentBlock(
"row_icon");
164 $dtpl->setVariable(
"ROW_ICON_ALT", $lng->txt(
"content_row"));
166 $dtpl->setVariable(
"ROW_ONCLICK",
"ROW_".$move_type);
167 $dtpl->setVariable(
"NR", $i);
168 $dtpl->parseCurrentBlock();
172 if ($res2->nodeset[$j]->get_attribute(
"Hidden") !=
"Y")
174 $dtpl->setCurrentBlock(
"cell");
176 if (is_array(
$_POST[
"cmd"]) && key(
$_POST[
"cmd"]) ==
"update")
185 $dtpl->setVariable(
"PAR_TA_NAME",
"cell[".$i.
"][".$j.
"]");
186 $dtpl->setVariable(
"PAR_TA_ID",
"cell_".$i.
"_".$j);
187 $dtpl->setVariable(
"PAR_TA_CONTENT", $s_text);
189 $cs = $res2->nodeset[$j]->get_attribute(
"ColSpan");
190 $rs = $res2->nodeset[$j]->get_attribute(
"RowSpan");
195 $dtpl->setVariable(
"COLSPAN",
'colspan="'.$cs.
'"');
196 $dtpl->setVariable(
"WIDTH", (140 + ($cs - 1) * 146));
200 $dtpl->setVariable(
"ROWSPAN",
'rowspan="'.$rs.
'"');
201 $dtpl->setVariable(
"HEIGHT", (80 + ($rs - 1) * 86));
203 $dtpl->parseCurrentBlock();
206 $dtpl->setCurrentBlock(
"row");
207 $dtpl->parseCurrentBlock();
211 $types = array(
"row",
"col");
212 $moves = array(
"none",
"backward",
"both",
"forward");
214 "row" => array(
"newRowAfter" =>
"cont_ed_new_row_after",
215 "newRowBefore" =>
"cont_ed_new_row_before",
216 "moveRowUp" =>
"cont_ed_row_up",
217 "moveRowDown" =>
"cont_ed_row_down",
218 "deleteRow" =>
"cont_ed_delete_row"),
219 "col" => array(
"newColAfter" =>
"cont_ed_new_col_after",
220 "newColBefore" =>
"cont_ed_new_col_before",
221 "moveColLeft" =>
"cont_ed_col_left",
222 "moveColRight" =>
"cont_ed_col_right",
223 "deleteCol" =>
"cont_ed_delete_col")
226 foreach($types as $type)
228 foreach($moves as $move)
230 foreach($commands[$type] as $command => $lang_var)
232 if ($move ==
"none" && (substr($command, 0, 4) ==
"move"))
236 if (($move ==
"backward" && (in_array($command, array(
"movedown",
"moveright")))) ||
237 ($move ==
"forward" && (in_array($command, array(
"moveup",
"moveleft")))))
241 $this->tpl->setCurrentBlock(
"menu_item");
242 $this->tpl->setVariable(
"MENU_ITEM_TITLE", $lng->txt($lang_var));
243 $this->tpl->setVariable(
"CMD", $command);
244 $this->tpl->setVariable(
"TYPE", $type);
245 $this->tpl->parseCurrentBlock();
247 $this->tpl->setCurrentBlock(
"menu");
248 $this->tpl->setVariable(
"TYPE", $type);
249 $this->tpl->setVariable(
"MOVE", $move);
250 $this->tpl->parseCurrentBlock();
255 $this->tpl->setCurrentBlock(
"commands");
256 $this->tpl->setVariable(
"BTN_NAME",
"update");
257 $this->tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
258 $this->tpl->parseCurrentBlock();
260 $this->tpl->setVariable(
"FORMACTION2",
261 $ilCtrl->getFormAction($this,
"tableAction"));
262 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_table"));
273 $ilBench->start(
"Editor",
"Data_Table_update");
276 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
280 if (is_array(
$_POST[
"cell"]))
286 foreach (
$row as $j => $cell)
290 $this->content_obj->getLanguage());
296 $this->updated = $this->content_obj->setData($data);
298 if ($this->updated !==
true)
300 $ilBench->stop(
"Editor",
"Data_Table_update");
305 $this->updated = $this->pg_obj->update();
306 $ilBench->stop(
"Editor",
"Data_Table_update");
311 $this->ctrl->redirect($this,
"editData");
322 if (
$_POST[
"cancel_update"])
325 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
329 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
330 include_once(
"./Services/COPage/classes/class.ilPCParagraphGUI.php");
332 foreach (
$_POST as $k => $content)
334 if (substr($k, 0, 5) !=
"cell_")
341 $p1 = strpos($div,
'>');
342 $div = substr($div, $p1 + 1);
343 $div =
"<div class='ilc_text_block_TableContent'>".$div;
347 $ilCtrl->returnToParent($this,
"jump".$this->hier_id);
349 $text = $text[
"text"];
352 $this->content_obj->getLanguage(),
true,
false);
356 $id = explode(
"_", $k);
357 $data[(int) $id[1]][(
int) $id[2]] = $text;
361 $this->updated = $this->content_obj->setData($data);
363 if ($this->updated !==
true)
369 $this->updated = $this->pg_obj->update();
374 $this->pg_obj->addHierIDs();
376 if (
$_POST[
"tab_cmd"] !=
"")
378 $cell_hier_id = (
$_POST[
"tab_cmd_type"] ==
"col")
379 ? $this->hier_id.
"_1_".(
$_POST[
"tab_cmd_id"] + 1)
380 : $this->hier_id.
"_".(
$_POST[
"tab_cmd_id"] + 1).
"_1";
381 $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
382 if (is_object($cell_obj))
384 $cell_obj->$_POST[
"tab_cmd"]();
385 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
390 if (
$_POST[
"save_return"])
392 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
396 $this->ctrl->redirect($this,
"editData");
416 $this->pg_obj->stripHierIDs();
417 $this->pg_obj->addHierIDs();
418 $ilCtrl->setParameter($this,
"hier_id", $this->content_obj->readHierId());
419 $ilCtrl->setParameter($this,
"pc_id", $this->content_obj->readPCId());
420 $this->content_obj->setHierId($this->content_obj->readHierId());
421 $this->
setHierId($this->content_obj->readHierId());
422 $this->content_obj->setPCId($this->content_obj->readPCId());
434 $this->pg_obj->addHierIDs();
436 $cell_hier_id = (
$_POST[
"type"] ==
"col")
437 ? $this->hier_id.
"_1_".(
$_POST[
"id"] + 1)
438 : $this->hier_id.
"_".(
$_POST[
"id"] + 1).
"_1";
439 $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
440 if (is_object($cell_obj))
442 $cell_obj->$_POST[
"action"]();
443 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
445 $ilCtrl->redirect($this,
"editData");
457 $ilTabs->addTarget(
"cont_ed_edit_data",
458 $ilCtrl->getLinkTarget($this,
"editData"),
"editData",
489 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
493 $dtpl =
new ilTemplate(
"tpl.tabledata2.html",
true,
true,
"Services/COPage");
494 $dtpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"tableAction"));
497 $dtpl->setVariable(
"WYSIWYG_ACTION",
498 $ilCtrl->getFormAction($this,
"updateJS"));
502 $path =
"//PageContent[@HierId='".$this->getHierId().
"']".
506 for($i = 0; $i < count(
$res->nodeset); $i++)
510 $path2 =
"//PageContent[@HierId='".$this->getHierId().
"']".
511 "/Table/TableRow[$i+1]/TableData";
517 for($j = 0; $j < count($res2->nodeset); $j++)
521 $dtpl->touchBlock(
"empty_td");
526 if (count($res2->nodeset) == 1)
532 $move_type =
"forward";
535 else if ($j == (count($res2->nodeset) - 1))
537 $move_type =
"backward";
543 $dtpl->setCurrentBlock(
"col_icon");
544 $dtpl->setVariable(
"COL_ICON_ALT", $lng->txt(
"content_column"));
546 $dtpl->setVariable(
"COL_ONCLICK",
"COL_".$move_type);
547 $dtpl->setVariable(
"NR", $j);
548 $dtpl->parseCurrentBlock();
550 $dtpl->setCurrentBlock(
"row");
551 $dtpl->parseCurrentBlock();
555 for($j = 0; $j < count($res2->nodeset); $j++)
562 if (count(
$res->nodeset) == 1)
568 $move_type =
"forward";
571 else if ($i == (count(
$res->nodeset) - 1))
573 $move_type =
"backward";
579 $dtpl->setCurrentBlock(
"row_icon");
580 $dtpl->setVariable(
"ROW_ICON_ALT", $lng->txt(
"content_row"));
582 $dtpl->setVariable(
"ROW_ONCLICK",
"ROW_".$move_type);
583 $dtpl->setVariable(
"NR", $i);
584 $dtpl->parseCurrentBlock();
588 if ($res2->nodeset[$j]->get_attribute(
"Hidden") !=
"Y")
590 $dtpl->setCurrentBlock(
"cell");
592 if (is_array(
$_POST[
"cmd"]) && key(
$_POST[
"cmd"]) ==
"update")
600 include_once(
"./Services/COPage/classes/class.ilPCParagraphGUI.php");
602 $this->content_obj->readPCId().
"_".$i.
"_".$j);
605 $dtpl->setVariable(
"PAR_TA_NAME",
"cell[".$i.
"][".$j.
"]");
606 $dtpl->setVariable(
"PAR_TA_ID",
"cell_".$i.
"_".$j);
607 $dtpl->setVariable(
"PAR_TA_CONTENT", $s_text);
609 $cs = $res2->nodeset[$j]->get_attribute(
"ColSpan");
610 $rs = $res2->nodeset[$j]->get_attribute(
"RowSpan");
611 $dtpl->setVariable(
"WIDTH",
"140");
612 $dtpl->setVariable(
"HEIGHT",
"80");
615 $dtpl->setVariable(
"COLSPAN",
'colspan="'.$cs.
'"');
616 $dtpl->setVariable(
"WIDTH", (140 + ($cs - 1) * 146));
620 $dtpl->setVariable(
"ROWSPAN",
'rowspan="'.$rs.
'"');
621 $dtpl->setVariable(
"HEIGHT", (80 + ($rs - 1) * 86));
623 $dtpl->parseCurrentBlock();
626 $dtpl->setCurrentBlock(
"row");
627 $dtpl->parseCurrentBlock();
631 $types = array(
"row",
"col");
632 $moves = array(
"none",
"backward",
"both",
"forward");
634 "row" => array(
"newRowAfter" =>
"cont_ed_new_row_after",
635 "newRowBefore" =>
"cont_ed_new_row_before",
636 "moveRowUp" =>
"cont_ed_row_up",
637 "moveRowDown" =>
"cont_ed_row_down",
638 "deleteRow" =>
"cont_ed_delete_row"),
639 "col" => array(
"newColAfter" =>
"cont_ed_new_col_after",
640 "newColBefore" =>
"cont_ed_new_col_before",
641 "moveColLeft" =>
"cont_ed_col_left",
642 "moveColRight" =>
"cont_ed_col_right",
643 "deleteCol" =>
"cont_ed_delete_col")
646 foreach($types as $type)
648 foreach($moves as $move)
650 foreach($commands[$type] as $command => $lang_var)
652 if ($move ==
"none" && (substr($command, 0, 4) ==
"move"))
656 if (($move ==
"backward" && (in_array($command, array(
"movedown",
"moveright")))) ||
657 ($move ==
"forward" && (in_array($command, array(
"moveup",
"moveleft")))))
661 $dtpl->setCurrentBlock(
"menu_item");
662 $dtpl->setVariable(
"MENU_ITEM_TITLE", $lng->txt($lang_var));
663 $dtpl->setVariable(
"CMD", $command);
664 $dtpl->setVariable(
"TYPE", $type);
665 $dtpl->parseCurrentBlock();
667 $dtpl->setCurrentBlock(
"menu");
668 $dtpl->setVariable(
"TYPE", $type);
669 $dtpl->setVariable(
"MOVE", $move);
670 $dtpl->parseCurrentBlock();
675 $dtpl->setVariable(
"FORMACTION2",
676 $ilCtrl->getFormAction($this,
"tableAction"));
677 $dtpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_table"));
680 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
684 $GLOBALS[
"tpl"]->addJavascript(
"Services/COPage/tiny/4_1_5/tinymce.js");
685 $GLOBALS[
"tpl"]->addJavaScript(
"./Services/COPage/js/ilcopagecallback.js");
686 $GLOBALS[
"tpl"]->addJavascript(
"Services/COPage/js/page_editing.js");
688 $GLOBALS[
"tpl"]->addOnloadCode(
"var preloader = new Image();
689 preloader.src = './templates/default/images/loader.svg';
690 ilCOPage.setContentCss('".
693 ilCOPage.editTD('cell_0_0');
707 $dtpl->setVariable(
"IL_TINY_MENU",
709 $this->pg_obj->getParentType(),
710 $cfg->getEnableInternalLinks(),
711 $cfg->getEnableWikiLinks(),
712 $cfg->getEnableKeywords(),
714 false,
true, $cfg->getEnableAnchors(),
false));
717 if ($cfg->getEnableInternalLinks() || $cfg->getEnableWikiLinks())
719 include_once(
"./Services/Link/classes/class.ilInternalLinkGUI.php");
720 $dtpl->setCurrentBlock(
"int_link_prep");
722 $ilCtrl->getLinkTargetByClass(array(
"ilpageeditorgui",
"ilinternallinkgui"),
723 "",
false,
true,
false)));
726 $this->tpl->setContent($dtpl->get());