24 require_once(
"./Services/COPage/classes/class.ilPCDataTable.php");
25 require_once(
"./Services/COPage/classes/class.ilPCTableGUI.php");
26 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
56 $next_class = $this->ctrl->getNextClass($this);
59 $cmd = $this->ctrl->getCmd();
93 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
95 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.tabledata.html",
"Services/COPage");
98 $dtpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"tableAction"));
99 $dtpl->setVariable(
"BB_MENU", $this->
getBBMenu());
101 $this->tpl->addJavascript(
"./Services/COPage/phpBB/3_0_0/editor.js");
102 $this->tpl->addJavascript(
"./Services/COPage/js/page_editing.js");
106 $path =
"//PageContent[@HierId='".$this->getHierId().
"']".
110 for($i = 0; $i < count(
$res->nodeset); $i++)
114 $path2 =
"//PageContent[@HierId='".$this->getHierId().
"']".
115 "/Table/TableRow[$i+1]/TableData";
121 for($j = 0; $j < count($res2->nodeset); $j++)
125 $dtpl->touchBlock(
"empty_td");
130 if (count($res2->nodeset) == 1)
136 $move_type =
"forward";
139 else if ($j == (count($res2->nodeset) - 1))
141 $move_type =
"backward";
147 $dtpl->setCurrentBlock(
"col_icon");
148 $dtpl->setVariable(
"COL_ICON_ALT", $lng->txt(
"content_column"));
150 $dtpl->setVariable(
"COL_ONCLICK",
"COL_".$move_type);
151 $dtpl->setVariable(
"NR", $j);
152 $dtpl->parseCurrentBlock();
154 $dtpl->setCurrentBlock(
"row");
155 $dtpl->parseCurrentBlock();
159 for($j = 0; $j < count($res2->nodeset); $j++)
166 if (count(
$res->nodeset) == 1)
172 $move_type =
"forward";
175 else if ($i == (count(
$res->nodeset) - 1))
177 $move_type =
"backward";
183 $dtpl->setCurrentBlock(
"row_icon");
184 $dtpl->setVariable(
"ROW_ICON_ALT", $lng->txt(
"content_row"));
186 $dtpl->setVariable(
"ROW_ONCLICK",
"ROW_".$move_type);
187 $dtpl->setVariable(
"NR", $i);
188 $dtpl->parseCurrentBlock();
192 $dtpl->setCurrentBlock(
"cell");
194 if (is_array($_POST[
"cmd"]) && key($_POST[
"cmd"]) ==
"update")
203 $dtpl->setVariable(
"PAR_TA_NAME",
"cell[".$i.
"][".$j.
"]");
204 $dtpl->setVariable(
"PAR_TA_CONTENT", $s_text);
205 $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"]))
283 foreach ($_POST[
"cell"] as $i => $row)
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");
321 if (is_array($_POST[
"target"]))
323 foreach ($_POST[
"target"] as
$hier_id)
325 $this->content_obj->setTDWidth($hier_id, $_POST[
"td_width"]);
329 $this->updated = $this->pg_obj->update();
330 $this->pg_obj->addHierIDs();
339 if (is_array($_POST[
"target"]))
341 foreach ($_POST[
"target"] as
$hier_id)
343 $this->content_obj->setTDClass($hier_id, $_POST[
"td_class"]);
347 $this->updated = $this->pg_obj->update();
348 $this->pg_obj->addHierIDs();
363 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
365 $form->setFormAction($ilCtrl->getFormAction($this));
366 $form->setTitle($this->lng->txt(
"cont_insert_table"));
369 for($i=1; $i<=20; $i++)
378 $form->addItem($cols);
384 $form->addItem($rows);
387 $width =
new ilTextInputGUI($this->lng->txt(
"cont_table_width"),
"width");
390 $width->setMaxLength(6);
391 $form->addItem($width);
394 $border =
new ilTextInputGUI($this->lng->txt(
"cont_table_border"),
"border");
397 $border->setMaxLength(6);
398 $form->addItem($border);
401 $padding =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellpadding"),
"padding");
403 $padding->setSize(6);
404 $padding->setMaxLength(6);
405 $form->addItem($padding);
408 $spacing =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellspacing"),
"spacing");
410 $spacing->setSize(6);
411 $spacing->setMaxLength(6);
412 $form->addItem($spacing);
415 require_once(
"./Services/Form/classes/class.ilRadioMatrixInputGUI.php");
417 $options = array(
"" => $this->lng->txt(
"none"),
"ilc_Cell1" =>
"Cell1",
"ilc_Cell2" =>
"Cell2",
418 "ilc_Cell3" =>
"Cell3",
"ilc_Cell4" =>
"Cell4");
419 foreach($options as $k => $option)
421 $options[$k] =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="'.$k.
'">'.
422 $option.
'</td></tr></table>';
426 require_once(
"./Services/Form/classes/class.ilRadioMatrixInputGUI.php");
428 $options = array(
"" => $this->lng->txt(
"none"),
"ilc_Cell1" =>
"Cell1",
"ilc_Cell2" =>
"Cell2",
429 "ilc_Cell3" =>
"Cell3",
"ilc_Cell4" =>
"Cell4");
430 foreach($options as $k => $option)
432 $options[$k] =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="'.$k.
'">'.
433 $option.
'</td></tr></table>';
437 $fr_style->setOptions($options);
438 $form->addItem($fr_style);
441 $align_opts = array(
"Left" => $lng->txt(
"cont_left"),
442 "Right" => $lng->txt(
"cont_right"),
"Center" => $lng->txt(
"cont_center"),
443 "LeftFloat" => $lng->txt(
"cont_left_float"),
444 "RightFloat" => $lng->txt(
"cont_right_float"));
447 $align->setValue(
"Center");
448 $form->addItem($align);
452 $op =
new ilRadioOption($this->lng->txt(
"cont_html_table"),
"html");
453 $import->addOption($op);
454 $op2 =
new ilRadioOption($this->lng->txt(
"cont_spreadsheet_table"),
"spreadsheet");
457 $import_data->setRows(8);
458 $import_data->setCols(50);
461 $import->addOption($op2);
462 $import->setValue(
"html");
463 $form->addItem($import);
468 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
472 $s_lang = $ilUser->getLanguage();
474 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
477 $language =
new ilSelectInputGUI($this->lng->txt(
"language"),
"tab_language");
479 $language->setValue($s_lang);
480 $form->addItem($language);
482 $form->addCommandButton(
"create_tab", $lng->txt(
"save"));
483 $form->addCommandButton(
"cancelCreate", $lng->txt(
"cancel"));
485 $html = $form->getHTML();
486 $tpl->setContent($html);
491 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.table_new.html",
"Services/COPage");
492 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_insert_table"));
493 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
497 for($i=1; $i<=10; $i++)
504 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
508 $s_lang = $ilUser->getLanguage();
512 $this->tpl->setVariable(
"TXT_LANGUAGE", $this->lng->txt(
"language"));
513 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
516 $this->tpl->setVariable(
"SELECT_LANGUAGE", $select_language);
517 $this->tpl->setVariable(
"TXT_COLS", $this->lng->txt(
"cont_nr_cols"));
519 $this->tpl->setVariable(
"SELECT_COLS", $select_cols);
520 $this->tpl->setVariable(
"TXT_ROWS", $this->lng->txt(
"cont_nr_rows"));
522 $this->tpl->setVariable(
"SELECT_ROWS", $select_rows);
525 $this->tpl->setVariable(
"TXT_HTML_IMPORT", $this->lng->txt(
"cont_table_html_import"));
526 $this->tpl->setVariable(
"TXT_SPREADSHEET", $this->lng->txt(
"cont_table_spreadsheet_import"));
527 $this->tpl->setVariable(
"TXT_BTN_HTML_IMPORT", $this->lng->txt(
"import"));
528 $this->tpl->setVariable(
"TXT_HTML_IMPORT_INFO", $this->lng->txt(
"cont_table_html_import_info"));
529 $this->tpl->setVariable(
"TXT_SPREADSHEET_IMPORT_INFO", $this->lng->txt(
"cont_table_spreadsheet_import_info"));
530 $this->tpl->setVariable(
"CMD_HTML_IMPORT",
"create_tab");
531 $this->tpl->setVariable(
"SELECT_ROWS", $select_rows);
536 $this->tpl->setCurrentBlock(
"commands");
537 $this->tpl->setVariable(
"BTN_NAME",
"create_tab");
538 $this->tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
539 $this->tpl->setVariable(
"BTN_CANCEL",
"cancelCreate");
540 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
541 $this->tpl->parseCurrentBlock();
554 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
556 $import_table = trim($_POST[
"import_table"]);
559 if (!empty ($import_table))
561 switch($_POST[
"import_type"])
565 if (!$this->content_obj->importHtml ($_POST[
"tab_language"], $import_table))
574 $this->content_obj->importSpreadsheet($_POST[
"tab_language"], $import_table);
592 $this->content_obj->setFirstRowStyle($frtype);
595 $this->updated = $this->pg_obj->update();
597 if ($this->updated ===
true)
599 $this->pg_obj->stripHierIDs();
600 $this->pg_obj->addHierIDs();
601 $ilCtrl->setParameter($this,
"hier_id", $this->content_obj->readHierId());
602 $ilCtrl->setParameter($this,
"pc_id", $this->content_obj->readPCId());
603 $this->content_obj->setHierId($this->content_obj->readHierId());
604 $this->
setHierId($this->content_obj->readHierId());
605 $this->content_obj->setPCId($this->content_obj->readPCId());
626 $this->pg_obj->addHierIDs();
628 $cell_hier_id = ($_POST[
"type"] ==
"col")
629 ? $this->hier_id.
"_1_".($_POST[
"id"] + 1)
630 : $this->hier_id.
"_".($_POST[
"id"] + 1).
"_1";
631 $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
632 if (is_object($cell_obj))
634 $cell_obj->$_POST[
"action"]();
635 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
637 $ilCtrl->redirect($this,
"editData");
649 $ilTabs->addTarget(
"cont_ed_edit_data",
650 $ilCtrl->getLinkTarget($this,
"editData"),
"editData",