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");
85 $path =
"//PageContent[@HierId='".$this->getHierId().
"']".
89 for($i = 0; $i < count(
$res->nodeset); $i++)
93 $path2 =
"//PageContent[@HierId='".$this->getHierId().
"']".
94 "/Table/TableRow[$i+1]/TableData";
100 for($j = 0; $j < count($res2->nodeset); $j++)
104 $dtpl->touchBlock(
"empty_td");
109 if (count($res2->nodeset) == 1)
115 $move_type =
"forward";
118 else if ($j == (count($res2->nodeset) - 1))
120 $move_type =
"backward";
126 $dtpl->setCurrentBlock(
"col_icon");
127 $dtpl->setVariable(
"COL_ICON_ALT", $lng->txt(
"content_column"));
129 $dtpl->setVariable(
"COL_ONCLICK",
"COL_".$move_type);
130 $dtpl->setVariable(
"NR", $j);
131 $dtpl->parseCurrentBlock();
133 $dtpl->setCurrentBlock(
"row");
134 $dtpl->parseCurrentBlock();
138 for($j = 0; $j < count($res2->nodeset); $j++)
145 if (count(
$res->nodeset) == 1)
151 $move_type =
"forward";
154 else if ($i == (count(
$res->nodeset) - 1))
156 $move_type =
"backward";
162 $dtpl->setCurrentBlock(
"row_icon");
163 $dtpl->setVariable(
"ROW_ICON_ALT", $lng->txt(
"content_row"));
165 $dtpl->setVariable(
"ROW_ONCLICK",
"ROW_".$move_type);
166 $dtpl->setVariable(
"NR", $i);
167 $dtpl->parseCurrentBlock();
171 if ($res2->nodeset[$j]->get_attribute(
"Hidden") !=
"Y")
173 $dtpl->setCurrentBlock(
"cell");
175 if (is_array(
$_POST[
"cmd"]) && key(
$_POST[
"cmd"]) ==
"update")
184 $dtpl->setVariable(
"PAR_TA_NAME",
"cell[".$i.
"][".$j.
"]");
185 $dtpl->setVariable(
"PAR_TA_ID",
"cell_".$i.
"_".$j);
186 $dtpl->setVariable(
"PAR_TA_CONTENT", $s_text);
188 $cs = $res2->nodeset[$j]->get_attribute(
"ColSpan");
189 $rs = $res2->nodeset[$j]->get_attribute(
"RowSpan");
194 $dtpl->setVariable(
"COLSPAN",
'colspan="'.$cs.
'"');
195 $dtpl->setVariable(
"WIDTH", (140 + ($cs - 1) * 146));
199 $dtpl->setVariable(
"ROWSPAN",
'rowspan="'.$rs.
'"');
200 $dtpl->setVariable(
"HEIGHT", (80 + ($rs - 1) * 86));
202 $dtpl->parseCurrentBlock();
205 $dtpl->setCurrentBlock(
"row");
206 $dtpl->parseCurrentBlock();
210 $types = array(
"row",
"col");
211 $moves = array(
"none",
"backward",
"both",
"forward");
213 "row" => array(
"newRowAfter" =>
"cont_ed_new_row_after",
214 "newRowBefore" =>
"cont_ed_new_row_before",
215 "moveRowUp" =>
"cont_ed_row_up",
216 "moveRowDown" =>
"cont_ed_row_down",
217 "deleteRow" =>
"cont_ed_delete_row"),
218 "col" => array(
"newColAfter" =>
"cont_ed_new_col_after",
219 "newColBefore" =>
"cont_ed_new_col_before",
220 "moveColLeft" =>
"cont_ed_col_left",
221 "moveColRight" =>
"cont_ed_col_right",
222 "deleteCol" =>
"cont_ed_delete_col")
225 foreach($types as $type)
227 foreach($moves as $move)
229 foreach($commands[$type] as
$command => $lang_var)
231 if ($move ==
"none" && (substr(
$command, 0, 4) ==
"move"))
235 if (($move ==
"backward" && (in_array(
$command, array(
"movedown",
"moveright")))) ||
236 ($move ==
"forward" && (in_array(
$command, array(
"moveup",
"moveleft")))))
240 $this->tpl->setCurrentBlock(
"menu_item");
241 $this->tpl->setVariable(
"MENU_ITEM_TITLE", $lng->txt($lang_var));
242 $this->tpl->setVariable(
"CMD",
$command);
243 $this->tpl->setVariable(
"TYPE", $type);
244 $this->tpl->parseCurrentBlock();
246 $this->tpl->setCurrentBlock(
"menu");
247 $this->tpl->setVariable(
"TYPE", $type);
248 $this->tpl->setVariable(
"MOVE", $move);
249 $this->tpl->parseCurrentBlock();
254 $this->tpl->setCurrentBlock(
"commands");
255 $this->tpl->setVariable(
"BTN_NAME",
"update");
256 $this->tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
257 $this->tpl->parseCurrentBlock();
259 $this->tpl->setVariable(
"FORMACTION2",
260 $ilCtrl->getFormAction($this,
"tableAction"));
261 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_table"));
272 $ilBench->start(
"Editor",
"Data_Table_update");
275 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
279 if (is_array(
$_POST[
"cell"]))
285 foreach (
$row as $j => $cell)
289 $this->content_obj->getLanguage());
295 $this->updated = $this->content_obj->setData(
$data);
297 if ($this->updated !==
true)
299 $ilBench->stop(
"Editor",
"Data_Table_update");
304 $this->updated = $this->pg_obj->update();
305 $ilBench->stop(
"Editor",
"Data_Table_update");
310 $this->ctrl->redirect($this,
"editData");
321 if (
$_POST[
"cancel_update"])
324 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
328 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
329 include_once(
"./Services/COPage/classes/class.ilPCParagraphGUI.php");
331 foreach (
$_POST as $k => $content)
333 if (substr($k, 0, 5) !=
"cell_")
340 $p1 = strpos($div,
'>');
341 $div = substr($div, $p1 + 1);
342 $div =
"<div class='ilc_text_block_TableContent'>".$div;
346 $ilCtrl->returnToParent($this,
"jump".$this->hier_id);
348 $text = $text[
"text"];
351 $this->content_obj->getLanguage(),
true,
false);
355 $id = explode(
"_", $k);
356 $data[(int) $id[1]][(
int) $id[2]] = $text;
360 $this->updated = $this->content_obj->setData(
$data);
362 if ($this->updated !==
true)
368 $this->updated = $this->pg_obj->update();
373 $this->pg_obj->addHierIDs();
375 if (
$_POST[
"tab_cmd"] !=
"")
377 $cell_hier_id = (
$_POST[
"tab_cmd_type"] ==
"col")
378 ? $this->hier_id.
"_1_".(
$_POST[
"tab_cmd_id"] + 1)
379 : $this->hier_id.
"_".(
$_POST[
"tab_cmd_id"] + 1).
"_1";
380 $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
381 if (is_object($cell_obj))
383 $cell_obj->$_POST[
"tab_cmd"]();
384 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
389 if (
$_POST[
"save_return"])
391 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
395 $this->ctrl->redirect($this,
"editData");
415 $this->pg_obj->stripHierIDs();
416 $this->pg_obj->addHierIDs();
417 $ilCtrl->setParameter($this,
"hier_id", $this->content_obj->readHierId());
418 $ilCtrl->setParameter($this,
"pc_id", $this->content_obj->readPCId());
419 $this->content_obj->setHierId($this->content_obj->readHierId());
420 $this->
setHierId($this->content_obj->readHierId());
421 $this->content_obj->setPCId($this->content_obj->readPCId());
433 $this->pg_obj->addHierIDs();
435 $cell_hier_id = (
$_POST[
"type"] ==
"col")
436 ? $this->hier_id.
"_1_".(
$_POST[
"id"] + 1)
437 : $this->hier_id.
"_".(
$_POST[
"id"] + 1).
"_1";
438 $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
439 if (is_object($cell_obj))
441 $cell_obj->$_POST[
"action"]();
442 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
444 $ilCtrl->redirect($this,
"editData");
456 $ilTabs->addTarget(
"cont_ed_edit_data",
457 $ilCtrl->getLinkTarget($this,
"editData"),
"editData",
486 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
488 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.tabledata2.html",
"Services/COPage");
491 $dtpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"tableAction"));
498 $this->tpl->setVariable(
"WYSIWYG_ACTION",
499 $ilCtrl->getFormAction($this,
"updateJS"));
504 $path =
"//PageContent[@HierId='".$this->getHierId().
"']".
508 for($i = 0; $i < count(
$res->nodeset); $i++)
512 $path2 =
"//PageContent[@HierId='".$this->getHierId().
"']".
513 "/Table/TableRow[$i+1]/TableData";
519 for($j = 0; $j < count($res2->nodeset); $j++)
523 $dtpl->touchBlock(
"empty_td");
528 if (count($res2->nodeset) == 1)
534 $move_type =
"forward";
537 else if ($j == (count($res2->nodeset) - 1))
539 $move_type =
"backward";
545 $dtpl->setCurrentBlock(
"col_icon");
546 $dtpl->setVariable(
"COL_ICON_ALT", $lng->txt(
"content_column"));
548 $dtpl->setVariable(
"COL_ONCLICK",
"COL_".$move_type);
549 $dtpl->setVariable(
"NR", $j);
550 $dtpl->parseCurrentBlock();
552 $dtpl->setCurrentBlock(
"row");
553 $dtpl->parseCurrentBlock();
557 for($j = 0; $j < count($res2->nodeset); $j++)
564 if (count(
$res->nodeset) == 1)
570 $move_type =
"forward";
573 else if ($i == (count(
$res->nodeset) - 1))
575 $move_type =
"backward";
581 $dtpl->setCurrentBlock(
"row_icon");
582 $dtpl->setVariable(
"ROW_ICON_ALT", $lng->txt(
"content_row"));
584 $dtpl->setVariable(
"ROW_ONCLICK",
"ROW_".$move_type);
585 $dtpl->setVariable(
"NR", $i);
586 $dtpl->parseCurrentBlock();
590 if ($res2->nodeset[$j]->get_attribute(
"Hidden") !=
"Y")
592 $dtpl->setCurrentBlock(
"cell");
594 if (is_array(
$_POST[
"cmd"]) && key(
$_POST[
"cmd"]) ==
"update")
602 include_once(
"./Services/COPage/classes/class.ilPCParagraphGUI.php");
604 $this->content_obj->readPCId().
"_".$i.
"_".$j);
607 $dtpl->setVariable(
"PAR_TA_NAME",
"cell[".$i.
"][".$j.
"]");
608 $dtpl->setVariable(
"PAR_TA_ID",
"cell_".$i.
"_".$j);
609 $dtpl->setVariable(
"PAR_TA_CONTENT", $s_text);
611 $cs = $res2->nodeset[$j]->get_attribute(
"ColSpan");
612 $rs = $res2->nodeset[$j]->get_attribute(
"RowSpan");
613 $dtpl->setVariable(
"WIDTH",
"140");
614 $dtpl->setVariable(
"HEIGHT",
"80");
617 $dtpl->setVariable(
"COLSPAN",
'colspan="'.$cs.
'"');
618 $dtpl->setVariable(
"WIDTH", (140 + ($cs - 1) * 146));
622 $dtpl->setVariable(
"ROWSPAN",
'rowspan="'.$rs.
'"');
623 $dtpl->setVariable(
"HEIGHT", (80 + ($rs - 1) * 86));
625 $dtpl->parseCurrentBlock();
628 $dtpl->setCurrentBlock(
"row");
629 $dtpl->parseCurrentBlock();
633 $types = array(
"row",
"col");
634 $moves = array(
"none",
"backward",
"both",
"forward");
636 "row" => array(
"newRowAfter" =>
"cont_ed_new_row_after",
637 "newRowBefore" =>
"cont_ed_new_row_before",
638 "moveRowUp" =>
"cont_ed_row_up",
639 "moveRowDown" =>
"cont_ed_row_down",
640 "deleteRow" =>
"cont_ed_delete_row"),
641 "col" => array(
"newColAfter" =>
"cont_ed_new_col_after",
642 "newColBefore" =>
"cont_ed_new_col_before",
643 "moveColLeft" =>
"cont_ed_col_left",
644 "moveColRight" =>
"cont_ed_col_right",
645 "deleteCol" =>
"cont_ed_delete_col")
648 foreach($types as $type)
650 foreach($moves as $move)
652 foreach($commands[$type] as
$command => $lang_var)
654 if ($move ==
"none" && (substr(
$command, 0, 4) ==
"move"))
658 if (($move ==
"backward" && (in_array(
$command, array(
"movedown",
"moveright")))) ||
659 ($move ==
"forward" && (in_array(
$command, array(
"moveup",
"moveleft")))))
663 $this->tpl->setCurrentBlock(
"menu_item");
664 $this->tpl->setVariable(
"MENU_ITEM_TITLE", $lng->txt($lang_var));
665 $this->tpl->setVariable(
"CMD",
$command);
666 $this->tpl->setVariable(
"TYPE", $type);
667 $this->tpl->parseCurrentBlock();
669 $this->tpl->setCurrentBlock(
"menu");
670 $this->tpl->setVariable(
"TYPE", $type);
671 $this->tpl->setVariable(
"MOVE", $move);
672 $this->tpl->parseCurrentBlock();
677 $this->tpl->setVariable(
"FORMACTION2",
678 $ilCtrl->getFormAction($this,
"tableAction"));
679 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_table"));
682 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
686 $GLOBALS[
"tpl"]->addJavascript(
"Services/RTE/tiny_mce_3_3_9_2/il_tiny_mce_src.js");
687 $GLOBALS[
"tpl"]->addJavaScript(
"./Services/COPage/js/ilcopagecallback.js");
688 $GLOBALS[
"tpl"]->addJavaScript(
"./Services/COPage/js/ilpageedit.js");
689 $GLOBALS[
"tpl"]->addJavascript(
"Services/COPage/js/page_editing.js");
691 $GLOBALS[
"tpl"]->addOnloadCode(
"var preloader = new Image();
692 preloader.src = './templates/default/images/loader.gif';
693 ilCOPage.setContentCss('".
696 ilCOPage.editTD('cell_0_0');
700 $this->tpl->setVariable(
"IL_TINY_MENU",
702 $this->pg_obj->getParentType(),
704 $this->pg_obj->getParentType() ==
"wpg",