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");
82 $this->tpl->addJavascript(
"./Services/COPage/js/paragraph_editing.js");
83 $this->tpl->addJavascript(
"./Services/COPage/js/page_editing_4_0_12.js");
87 $path =
"//PageContent[@HierId='".$this->getHierId().
"']".
91 for($i = 0; $i < count(
$res->nodeset); $i++)
95 $path2 =
"//PageContent[@HierId='".$this->getHierId().
"']".
96 "/Table/TableRow[$i+1]/TableData";
102 for($j = 0; $j < count($res2->nodeset); $j++)
106 $dtpl->touchBlock(
"empty_td");
111 if (count($res2->nodeset) == 1)
117 $move_type =
"forward";
120 else if ($j == (count($res2->nodeset) - 1))
122 $move_type =
"backward";
128 $dtpl->setCurrentBlock(
"col_icon");
129 $dtpl->setVariable(
"COL_ICON_ALT", $lng->txt(
"content_column"));
131 $dtpl->setVariable(
"COL_ONCLICK",
"COL_".$move_type);
132 $dtpl->setVariable(
"NR", $j);
133 $dtpl->parseCurrentBlock();
135 $dtpl->setCurrentBlock(
"row");
136 $dtpl->parseCurrentBlock();
140 for($j = 0; $j < count($res2->nodeset); $j++)
147 if (count(
$res->nodeset) == 1)
153 $move_type =
"forward";
156 else if ($i == (count(
$res->nodeset) - 1))
158 $move_type =
"backward";
164 $dtpl->setCurrentBlock(
"row_icon");
165 $dtpl->setVariable(
"ROW_ICON_ALT", $lng->txt(
"content_row"));
167 $dtpl->setVariable(
"ROW_ONCLICK",
"ROW_".$move_type);
168 $dtpl->setVariable(
"NR", $i);
169 $dtpl->parseCurrentBlock();
173 if ($res2->nodeset[$j]->get_attribute(
"Hidden") !=
"Y")
175 $dtpl->setCurrentBlock(
"cell");
177 if (is_array(
$_POST[
"cmd"]) && key(
$_POST[
"cmd"]) ==
"update")
186 $dtpl->setVariable(
"PAR_TA_NAME",
"cell[".$i.
"][".$j.
"]");
187 $dtpl->setVariable(
"PAR_TA_ID",
"cell_".$i.
"_".$j);
188 $dtpl->setVariable(
"PAR_TA_CONTENT", $s_text);
190 $cs = $res2->nodeset[$j]->get_attribute(
"ColSpan");
191 $rs = $res2->nodeset[$j]->get_attribute(
"RowSpan");
196 $dtpl->setVariable(
"COLSPAN",
'colspan="'.$cs.
'"');
197 $dtpl->setVariable(
"WIDTH", (140 + ($cs - 1) * 146));
201 $dtpl->setVariable(
"ROWSPAN",
'rowspan="'.$rs.
'"');
202 $dtpl->setVariable(
"HEIGHT", (80 + ($rs - 1) * 86));
204 $dtpl->parseCurrentBlock();
207 $dtpl->setCurrentBlock(
"row");
208 $dtpl->parseCurrentBlock();
212 $types = array(
"row",
"col");
213 $moves = array(
"none",
"backward",
"both",
"forward");
215 "row" => array(
"newRowAfter" =>
"cont_ed_new_row_after",
216 "newRowBefore" =>
"cont_ed_new_row_before",
217 "moveRowUp" =>
"cont_ed_row_up",
218 "moveRowDown" =>
"cont_ed_row_down",
219 "deleteRow" =>
"cont_ed_delete_row"),
220 "col" => array(
"newColAfter" =>
"cont_ed_new_col_after",
221 "newColBefore" =>
"cont_ed_new_col_before",
222 "moveColLeft" =>
"cont_ed_col_left",
223 "moveColRight" =>
"cont_ed_col_right",
224 "deleteCol" =>
"cont_ed_delete_col")
227 foreach($types as $type)
229 foreach($moves as $move)
231 foreach($commands[$type] as $command => $lang_var)
233 if ($move ==
"none" && (substr($command, 0, 4) ==
"move"))
237 if (($move ==
"backward" && (in_array($command, array(
"movedown",
"moveright")))) ||
238 ($move ==
"forward" && (in_array($command, array(
"moveup",
"moveleft")))))
242 $this->tpl->setCurrentBlock(
"menu_item");
243 $this->tpl->setVariable(
"MENU_ITEM_TITLE", $lng->txt($lang_var));
244 $this->tpl->setVariable(
"CMD", $command);
245 $this->tpl->setVariable(
"TYPE", $type);
246 $this->tpl->parseCurrentBlock();
248 $this->tpl->setCurrentBlock(
"menu");
249 $this->tpl->setVariable(
"TYPE", $type);
250 $this->tpl->setVariable(
"MOVE", $move);
251 $this->tpl->parseCurrentBlock();
256 $this->tpl->setCurrentBlock(
"commands");
257 $this->tpl->setVariable(
"BTN_NAME",
"update");
258 $this->tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
259 $this->tpl->parseCurrentBlock();
261 $this->tpl->setVariable(
"FORMACTION2",
262 $ilCtrl->getFormAction($this,
"tableAction"));
263 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_table"));
274 $ilBench->start(
"Editor",
"Data_Table_update");
277 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
281 if (is_array(
$_POST[
"cell"]))
287 foreach (
$row as $j => $cell)
291 $this->content_obj->getLanguage());
297 $this->updated = $this->content_obj->setData($data);
299 if ($this->updated !==
true)
301 $ilBench->stop(
"Editor",
"Data_Table_update");
306 $this->updated = $this->pg_obj->update();
307 $ilBench->stop(
"Editor",
"Data_Table_update");
312 $this->ctrl->redirect($this,
"editData");
323 if (
$_POST[
"cancel_update"])
326 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
330 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
331 include_once(
"./Services/COPage/classes/class.ilPCParagraphGUI.php");
333 foreach (
$_POST as $k => $content)
335 if (substr($k, 0, 5) !=
"cell_")
342 $p1 = strpos($div,
'>');
343 $div = substr($div, $p1 + 1);
344 $div =
"<div class='ilc_text_block_TableContent'>".$div;
348 $ilCtrl->returnToParent($this,
"jump".$this->hier_id);
350 $text = $text[
"text"];
353 $this->content_obj->getLanguage(),
true,
false);
357 $id = explode(
"_", $k);
358 $data[(int) $id[1]][(
int) $id[2]] = $text;
362 $this->updated = $this->content_obj->setData($data);
364 if ($this->updated !==
true)
370 $this->updated = $this->pg_obj->update();
375 $this->pg_obj->addHierIDs();
377 if (
$_POST[
"tab_cmd"] !=
"")
379 $cell_hier_id = (
$_POST[
"tab_cmd_type"] ==
"col")
380 ? $this->hier_id.
"_1_".(
$_POST[
"tab_cmd_id"] + 1)
381 : $this->hier_id.
"_".(
$_POST[
"tab_cmd_id"] + 1).
"_1";
382 $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
383 if (is_object($cell_obj))
385 $cell_obj->$_POST[
"tab_cmd"]();
386 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
391 if (
$_POST[
"save_return"])
393 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
397 $this->ctrl->redirect($this,
"editData");
417 $this->pg_obj->stripHierIDs();
418 $this->pg_obj->addHierIDs();
419 $ilCtrl->setParameter($this,
"hier_id", $this->content_obj->readHierId());
420 $ilCtrl->setParameter($this,
"pc_id", $this->content_obj->readPCId());
421 $this->content_obj->setHierId($this->content_obj->readHierId());
422 $this->
setHierId($this->content_obj->readHierId());
423 $this->content_obj->setPCId($this->content_obj->readPCId());
435 $this->pg_obj->addHierIDs();
437 $cell_hier_id = (
$_POST[
"type"] ==
"col")
438 ? $this->hier_id.
"_1_".(
$_POST[
"id"] + 1)
439 : $this->hier_id.
"_".(
$_POST[
"id"] + 1).
"_1";
440 $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
441 if (is_object($cell_obj))
443 $cell_obj->$_POST[
"action"]();
444 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
446 $ilCtrl->redirect($this,
"editData");
458 $ilTabs->addTarget(
"cont_ed_edit_data",
459 $ilCtrl->getLinkTarget($this,
"editData"),
"editData",
488 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
490 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.tabledata2.html",
"Services/COPage");
493 $dtpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"tableAction"));
500 $this->tpl->setVariable(
"WYSIWYG_ACTION",
501 $ilCtrl->getFormAction($this,
"updateJS"));
506 $path =
"//PageContent[@HierId='".$this->getHierId().
"']".
510 for($i = 0; $i < count(
$res->nodeset); $i++)
514 $path2 =
"//PageContent[@HierId='".$this->getHierId().
"']".
515 "/Table/TableRow[$i+1]/TableData";
521 for($j = 0; $j < count($res2->nodeset); $j++)
525 $dtpl->touchBlock(
"empty_td");
530 if (count($res2->nodeset) == 1)
536 $move_type =
"forward";
539 else if ($j == (count($res2->nodeset) - 1))
541 $move_type =
"backward";
547 $dtpl->setCurrentBlock(
"col_icon");
548 $dtpl->setVariable(
"COL_ICON_ALT", $lng->txt(
"content_column"));
550 $dtpl->setVariable(
"COL_ONCLICK",
"COL_".$move_type);
551 $dtpl->setVariable(
"NR", $j);
552 $dtpl->parseCurrentBlock();
554 $dtpl->setCurrentBlock(
"row");
555 $dtpl->parseCurrentBlock();
559 for($j = 0; $j < count($res2->nodeset); $j++)
566 if (count(
$res->nodeset) == 1)
572 $move_type =
"forward";
575 else if ($i == (count(
$res->nodeset) - 1))
577 $move_type =
"backward";
583 $dtpl->setCurrentBlock(
"row_icon");
584 $dtpl->setVariable(
"ROW_ICON_ALT", $lng->txt(
"content_row"));
586 $dtpl->setVariable(
"ROW_ONCLICK",
"ROW_".$move_type);
587 $dtpl->setVariable(
"NR", $i);
588 $dtpl->parseCurrentBlock();
592 if ($res2->nodeset[$j]->get_attribute(
"Hidden") !=
"Y")
594 $dtpl->setCurrentBlock(
"cell");
596 if (is_array(
$_POST[
"cmd"]) && key(
$_POST[
"cmd"]) ==
"update")
604 include_once(
"./Services/COPage/classes/class.ilPCParagraphGUI.php");
606 $this->content_obj->readPCId().
"_".$i.
"_".$j);
609 $dtpl->setVariable(
"PAR_TA_NAME",
"cell[".$i.
"][".$j.
"]");
610 $dtpl->setVariable(
"PAR_TA_ID",
"cell_".$i.
"_".$j);
611 $dtpl->setVariable(
"PAR_TA_CONTENT", $s_text);
613 $cs = $res2->nodeset[$j]->get_attribute(
"ColSpan");
614 $rs = $res2->nodeset[$j]->get_attribute(
"RowSpan");
615 $dtpl->setVariable(
"WIDTH",
"140");
616 $dtpl->setVariable(
"HEIGHT",
"80");
619 $dtpl->setVariable(
"COLSPAN",
'colspan="'.$cs.
'"');
620 $dtpl->setVariable(
"WIDTH", (140 + ($cs - 1) * 146));
624 $dtpl->setVariable(
"ROWSPAN",
'rowspan="'.$rs.
'"');
625 $dtpl->setVariable(
"HEIGHT", (80 + ($rs - 1) * 86));
627 $dtpl->parseCurrentBlock();
630 $dtpl->setCurrentBlock(
"row");
631 $dtpl->parseCurrentBlock();
635 $types = array(
"row",
"col");
636 $moves = array(
"none",
"backward",
"both",
"forward");
638 "row" => array(
"newRowAfter" =>
"cont_ed_new_row_after",
639 "newRowBefore" =>
"cont_ed_new_row_before",
640 "moveRowUp" =>
"cont_ed_row_up",
641 "moveRowDown" =>
"cont_ed_row_down",
642 "deleteRow" =>
"cont_ed_delete_row"),
643 "col" => array(
"newColAfter" =>
"cont_ed_new_col_after",
644 "newColBefore" =>
"cont_ed_new_col_before",
645 "moveColLeft" =>
"cont_ed_col_left",
646 "moveColRight" =>
"cont_ed_col_right",
647 "deleteCol" =>
"cont_ed_delete_col")
650 foreach($types as $type)
652 foreach($moves as $move)
654 foreach($commands[$type] as $command => $lang_var)
656 if ($move ==
"none" && (substr($command, 0, 4) ==
"move"))
660 if (($move ==
"backward" && (in_array($command, array(
"movedown",
"moveright")))) ||
661 ($move ==
"forward" && (in_array($command, array(
"moveup",
"moveleft")))))
665 $this->tpl->setCurrentBlock(
"menu_item");
666 $this->tpl->setVariable(
"MENU_ITEM_TITLE", $lng->txt($lang_var));
667 $this->tpl->setVariable(
"CMD", $command);
668 $this->tpl->setVariable(
"TYPE", $type);
669 $this->tpl->parseCurrentBlock();
671 $this->tpl->setCurrentBlock(
"menu");
672 $this->tpl->setVariable(
"TYPE", $type);
673 $this->tpl->setVariable(
"MOVE", $move);
674 $this->tpl->parseCurrentBlock();
679 $this->tpl->setVariable(
"FORMACTION2",
680 $ilCtrl->getFormAction($this,
"tableAction"));
681 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_table"));
684 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
689 $GLOBALS[
"tpl"]->addJavascript(
"Services/COPage/tiny/4_0_12/tinymce.js");
690 $GLOBALS[
"tpl"]->addJavaScript(
"./Services/COPage/js/ilcopagecallback.js");
692 $GLOBALS[
"tpl"]->addJavascript(
"Services/COPage/js/page_editing_4_0_12.js");
694 $GLOBALS[
"tpl"]->addOnloadCode(
"var preloader = new Image();
695 preloader.src = './templates/default/images/loader.gif';
696 ilCOPage.setContentCss('".
699 ilCOPage.editTD('cell_0_0');
703 $this->tpl->setVariable(
"IL_TINY_MENU",
705 $this->pg_obj->getParentType(),
707 $this->pg_obj->getParentType() ==
"wpg",
710 false,
true,
false,
false));