24 require_once(
"./Services/COPage/classes/class.ilPCTable.php");
25 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
44 function ilPCTableGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id =
"")
55 $next_class = $this->ctrl->getNextClass($this);
58 $cmd = $this->ctrl->getCmd();
78 $ilTabs->setBackTarget($lng->txt(
"pg"),
79 $this->ctrl->getParentReturn($this));
81 $ilTabs->addTarget(
"cont_table_properties",
82 $ilCtrl->getLinkTarget($this,
"edit"),
"edit",
85 $ilTabs->addTarget(
"cont_table_cell_properties",
86 $ilCtrl->getLinkTarget($this,
"editCells"),
"editCells",
102 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
104 $form->setFormAction($ilCtrl->getFormAction($this));
105 $form->setTitle($this->lng->txt(
"cont_table_properties"));
108 $width =
new ilTextInputGUI($this->lng->txt(
"cont_table_width"),
"width");
109 $width->
setValue($this->content_obj->getWidth());
111 $width->setMaxLength(6);
112 $form->addItem($width);
115 $border =
new ilTextInputGUI($this->lng->txt(
"cont_table_border"),
"border");
116 $border->
setValue($this->content_obj->getBorder());
118 $border->setMaxLength(6);
119 $form->addItem($border);
122 $padding =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellpadding"),
"padding");
123 $padding->
setValue($this->content_obj->getCellPadding());
124 $padding->setSize(6);
125 $padding->setMaxLength(6);
126 $form->addItem($padding);
129 $spacing =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellspacing"),
"spacing");
130 $spacing->
setValue($this->content_obj->getCellSpacing());
131 $spacing->setSize(6);
132 $spacing->setMaxLength(6);
133 $form->addItem($spacing);
136 $align_opts = array(
"Left" => $lng->txt(
"cont_left"),
137 "Right" => $lng->txt(
"cont_right"),
"Center" => $lng->txt(
"cont_center"),
138 "LeftFloat" => $lng->txt(
"cont_left_float"),
139 "RightFloat" => $lng->txt(
"cont_right_float"));
142 $align->setValue($this->content_obj->getHorizontalAlign());
143 $form->addItem($align);
146 $caption =
new ilTextInputGUI($this->lng->txt(
"cont_caption"),
"caption");
147 $caption->
setValue($this->content_obj->getCaption());
148 $caption->setSize(60);
149 $form->addItem($caption);
152 $ca_opts = array(
"top" => $lng->txt(
"cont_top"),
153 "bottom" => $lng->txt(
"cont_bottom"));
157 $ca->setValue($this->content_obj->getCaptionAlign());
158 $caption->addSubItem($ca);
161 $s_lang = $this->content_obj->getLanguage();
162 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
165 $language =
new ilSelectInputGUI($this->lng->txt(
"language"),
"tab_language");
167 $language->setValue($s_lang);
168 $form->addItem($language);
170 $form->addCommandButton(
"saveProperties", $lng->txt(
"save"));
172 $html = $form->getHTML();
173 $html.=
"<br />".$this->renderTable(
"");
174 $tpl->setContent($html);
184 $tab_node = $this->content_obj->getNode();
185 $content = $this->dom->dump_node($tab_node);
186 $trans = $this->pg_obj->getLanguageVariablesXML();
187 $mobs = $this->pg_obj->getMultimediaXML();
188 $content =
"<dummy>".$content.$mobs.$trans.
"</dummy>";
190 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
191 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
198 $params = array (
'mode' => $a_mode,
199 'med_disabled_path' => $med_disabled_path,
200 'media_mode' => $ilUser->getPref(
"ilPageEditor_MediaMode"),
201 'webspace_path' => $wb_path,
'enlarge_path' => $enlarge_path);
202 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args, $params);
207 $output = str_replace(
"<",
"<",$output);
208 $output = str_replace(
">",
">",$output);
209 $output = str_replace(
"&",
"&",$output);
211 return '<div style="float:left;">'.$output.
'</div>';
225 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
227 $form->setFormAction($ilCtrl->getFormAction($this));
228 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
231 require_once(
"./Services/Form/classes/class.ilRadioMatrixInputGUI.php");
233 $options = array(
"" => $this->lng->txt(
"none"),
"ilc_Cell1" =>
"Cell1",
"ilc_Cell2" =>
"Cell2",
234 "ilc_Cell3" =>
"Cell3",
"ilc_Cell4" =>
"Cell4");
235 foreach($options as $k => $option)
237 $options[$k] =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="'.$k.
'">'.
238 $option.
'</td></tr></table>';
242 $style->setInfo($lng->txt(
"cont_set_tab_style_info"));
243 $style->setOptions($options);
244 $form->addItem($style);
245 $form->setKeepOpen(
true);
247 $form->addCommandButton(
"setStylesAndWidths", $lng->txt(
"cont_set_styles_and_widths"));
249 $html = $form->getHTML();
250 $html.=
"<br />".$this->renderTable().
"</form>";
251 $tpl->setContent($html);
260 if (is_array($_POST[
"target"]))
262 foreach ($_POST[
"target"] as $k => $value)
266 $cid = explode(
":", $k);
267 $this->content_obj->setTDClass($cid[0], $_POST[
"style"], $cid[1]);
271 if (is_array($_POST[
"width"]))
273 foreach ($_POST[
"width"] as $k => $width)
275 $cid = explode(
":", $k);
276 $this->content_obj->setTDWidth($cid[0], $width, $cid[1]);
279 $this->updated = $this->pg_obj->update();
280 $this->ctrl->redirect($this,
"editCells");
288 if (is_array($_POST[
"target"]))
290 foreach ($_POST[
"target"] as $target)
292 $cid = explode(
":", $target);
293 $this->content_obj->setTDWidth($cid[0], $_POST[
"td_width"], $cid[1]);
298 $this->updated = $this->pg_obj->update();
299 $this->pg_obj->addHierIDs();
308 if (is_array($_POST[
"target"]))
310 foreach ($_POST[
"target"] as $target)
312 $cid = explode(
":", $target);
313 $this->content_obj->setTDClass($cid[0], $_POST[
"td_class"], $cid[1]);
317 $this->updated = $this->pg_obj->update();
318 $this->pg_obj->addHierIDs();
327 $caption = str_replace(
"&",
"&", $caption);
328 $caption = str_replace(
"<",
"<", $caption);
329 $caption = str_replace(
">",
">", $caption);
337 $this->content_obj->setCaption($caption,
347 $this->updated = $this->pg_obj->update();
348 if ($this->updated ===
true)
350 $this->ctrl->redirect($this,
"edit");
355 $this->pg_obj->addHierIDs();
365 $this->content_obj->setHorizontalAlign(
"Right");
366 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
367 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
375 $this->content_obj->setHorizontalAlign(
"Left");
376 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
377 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
385 $this->content_obj->setHorizontalAlign(
"Center");
386 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
387 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
395 $this->content_obj->setHorizontalAlign(
"LeftFloat");
396 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
397 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
405 $this->content_obj->setHorizontalAlign(
"RightFloat");
406 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
407 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
420 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
422 $form->setFormAction($ilCtrl->getFormAction($this));
423 $form->setTitle($this->lng->txt(
"cont_insert_table"));
426 for($i=1; $i<=20; $i++)
435 $form->addItem($cols);
441 $form->addItem($rows);
444 $width =
new ilTextInputGUI($this->lng->txt(
"cont_table_width"),
"width");
447 $width->setMaxLength(6);
448 $form->addItem($width);
451 $border =
new ilTextInputGUI($this->lng->txt(
"cont_table_border"),
"border");
454 $border->setMaxLength(6);
455 $form->addItem($border);
458 $padding =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellpadding"),
"padding");
460 $padding->setSize(6);
461 $padding->setMaxLength(6);
462 $form->addItem($padding);
465 $spacing =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellspacing"),
"spacing");
467 $spacing->setSize(6);
468 $spacing->setMaxLength(6);
469 $form->addItem($spacing);
472 require_once(
"./Services/Form/classes/class.ilRadioMatrixInputGUI.php");
474 $options = array(
"" => $this->lng->txt(
"none"),
"ilc_Cell1" =>
"Cell1",
"ilc_Cell2" =>
"Cell2",
475 "ilc_Cell3" =>
"Cell3",
"ilc_Cell4" =>
"Cell4");
476 foreach($options as $k => $option)
478 $options[$k] =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="'.$k.
'">'.
479 $option.
'</td></tr></table>';
483 $fr_style->setOptions($options);
484 $form->addItem($fr_style);
487 $align_opts = array(
"Left" => $lng->txt(
"cont_left"),
488 "Right" => $lng->txt(
"cont_right"),
"Center" => $lng->txt(
"cont_center"),
489 "LeftFloat" => $lng->txt(
"cont_left_float"),
490 "RightFloat" => $lng->txt(
"cont_right_float"));
493 $align->setValue(
"Center");
494 $form->addItem($align);
498 $op =
new ilRadioOption($this->lng->txt(
"cont_html_table"),
"html");
499 $import->addOption($op);
500 $op2 =
new ilRadioOption($this->lng->txt(
"cont_spreadsheet_table"),
"spreadsheet");
503 $import_data->setRows(8);
504 $import_data->setCols(50);
507 $import->addOption($op2);
508 $import->setValue(
"html");
509 $form->addItem($import);
514 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
518 $s_lang = $ilUser->getLanguage();
520 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
523 $language =
new ilSelectInputGUI($this->lng->txt(
"language"),
"tab_language");
525 $language->setValue($s_lang);
526 $form->addItem($language);
528 $form->addCommandButton(
"create_tab", $lng->txt(
"save"));
529 $form->addCommandButton(
"cancelCreate", $lng->txt(
"cancel"));
531 $html = $form->getHTML();
532 $tpl->setContent($html);
536 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.table_new.html",
"Services/COPage");
537 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_insert_table"));
538 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
540 for($i=1; $i<=10; $i++)
547 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
551 $s_lang = $ilUser->getLanguage();
555 $this->tpl->setVariable(
"TXT_LANGUAGE", $this->lng->txt(
"language"));
556 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
559 $this->tpl->setVariable(
"SELECT_LANGUAGE", $select_language);
560 $this->tpl->setVariable(
"TXT_COLS", $this->lng->txt(
"cont_nr_cols"));
562 $this->tpl->setVariable(
"SELECT_COLS", $select_cols);
563 $this->tpl->setVariable(
"TXT_ROWS", $this->lng->txt(
"cont_nr_rows"));
565 $this->tpl->setVariable(
"SELECT_ROWS", $select_rows);
568 $this->tpl->setVariable(
"TXT_HTML_IMPORT", $this->lng->txt(
"cont_table_html_import"));
569 $this->tpl->setVariable(
"TXT_SPREADSHEET", $this->lng->txt(
"cont_table_spreadsheet_import"));
570 $this->tpl->setVariable(
"TXT_BTN_HTML_IMPORT", $this->lng->txt(
"import"));
571 $this->tpl->setVariable(
"TXT_HTML_IMPORT_INFO", $this->lng->txt(
"cont_table_html_import_info"));
572 $this->tpl->setVariable(
"TXT_SPREADSHEET_IMPORT_INFO", $this->lng->txt(
"cont_table_spreadsheet_import_info"));
573 $this->tpl->setVariable(
"CMD_HTML_IMPORT",
"create_tab");
574 $this->tpl->setVariable(
"SELECT_ROWS", $select_rows);
579 $this->tpl->setCurrentBlock(
"commands");
580 $this->tpl->setVariable(
"BTN_NAME",
"create_tab");
581 $this->tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
582 $this->tpl->setVariable(
"BTN_CANCEL",
"cancelCreate");
583 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
584 $this->tpl->parseCurrentBlock();
595 $this->content_obj =
new ilPCTable($this->dom);
596 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
598 $import_table = trim($_POST[
"import_table"]);
601 if (!empty ($import_table))
603 switch($_POST[
"import_type"])
607 if (!$this->content_obj->importHtml ($_POST[
"tab_language"], $import_table))
616 $this->content_obj->importSpreadsheet($_POST[
"tab_language"], $import_table);
634 $this->content_obj->setFirstRowStyle($frtype);
637 $this->updated = $this->pg_obj->update();
639 if ($this->updated ===
true)
641 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);