4 require_once(
"./Services/COPage/classes/class.ilPCTable.php");
5 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
24 function ilPCTableGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id =
"")
27 $this->
setCharacteristics(array(
"StandardTable" => $this->lng->txt(
"cont_StandardTable")));
37 "Cell3" =>
"Cell3",
"Cell4" =>
"Cell4"));
48 $next_class = $this->ctrl->getNextClass($this);
51 $cmd = $this->ctrl->getCmd();
71 $ilTabs->setBackTarget($lng->txt(
"pg"),
72 $this->ctrl->getParentReturn($this));
74 $ilTabs->addTarget(
"cont_table_properties",
75 $ilCtrl->getLinkTarget($this,
"edit"),
"edit",
78 $ilTabs->addTarget(
"cont_table_cell_properties",
79 $ilCtrl->getLinkTarget($this,
"editCellStyle"),
"editCellStyle",
91 $ilTabs->addSubTabTarget(
"cont_style",
92 $ilCtrl->getLinkTarget($this,
"editCellStyle"),
"editCellStyle",
95 $ilTabs->addSubTabTarget(
"cont_width",
96 $ilCtrl->getLinkTarget($this,
"editCellWidth"),
"editCellWidth",
99 $ilTabs->addSubTabTarget(
"cont_alignment",
100 $ilCtrl->getLinkTarget($this,
"editCellAlignment"),
"editCellAlignment",
103 $ilTabs->addSubTabTarget(
"cont_span",
104 $ilCtrl->getLinkTarget($this,
"editCellSpan"),
"editCellSpan",
129 $html = $this->form->getHTML();
130 $html.=
"<br />".$this->renderTable(
"");
131 $tpl->setContent($html);
141 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
143 $this->form->setFormAction($ilCtrl->getFormAction($this));
144 if ($a_mode ==
"create")
146 $this->form->setTitle($this->lng->txt(
"cont_insert_table"));
150 $this->form->setTitle($this->lng->txt(
"cont_table_properties"));
153 if ($a_mode ==
"create")
156 for($i=1; $i<=20; $i++)
165 $this->form->addItem($cols);
171 $this->form->addItem($rows);
175 $width =
new ilTextInputGUI($this->lng->txt(
"cont_table_width"),
"width");
177 $width->setMaxLength(6);
178 $this->form->addItem($width);
181 $border =
new ilTextInputGUI($this->lng->txt(
"cont_table_border"),
"border");
184 $border->setMaxLength(6);
185 $this->form->addItem($border);
188 $padding =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellpadding"),
"padding");
190 $padding->setSize(6);
191 $padding->setMaxLength(6);
192 $this->form->addItem($padding);
196 $spacing->setValue(
"0px");
197 $this->form->addItem($spacing);
205 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
210 $chars = array_merge($templates, $chars);
211 if (is_object($this->content_obj))
213 if ($chars[$a_seleted_value] ==
"" && ($this->content_obj->getClass() !=
""))
215 $chars = array_merge(
216 array($this->content_obj->getClass() => $this->content_obj->getClass()),
220 foreach($chars as $k => $char)
222 if (strpos($k,
":") > 0)
224 $t = explode(
":", $k);
225 $html = $this->style->lookupTemplatePreview(
$t[1]).
'<div style="clear:both;" class="small">'.$char.
"</div>";
229 $html =
'<table class="ilc_table_'.$k.
'"><tr><td class="small">'.
230 $char.
'</td></tr></table>';
232 $char_prop->addOption($k, $char, $html);
234 $char_prop->setValue(
"StandardTable");
235 $this->form->addItem($char_prop);
238 for($i=0; $i<=3; $i++)
244 $rh =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_header"),
"row_header");
247 $this->form->addItem($rh);
250 $rf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_footer"),
"row_footer");
253 $this->form->addItem($rf);
256 $ch =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_header"),
"col_header");
259 $this->form->addItem($ch);
262 $cf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_footer"),
"col_footer");
265 $this->form->addItem($cf);
267 if ($a_mode ==
"create")
270 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
276 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
277 foreach($options as $k => $option)
279 $html =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_'.$k.
'">'.
280 $option.
'</td></tr></table>';
281 $fr_style->addOption($k, $option, $html);
284 $fr_style->setValue(
"");
285 $this->form->addItem($fr_style);
289 $align_opts = array(
"Left" => $lng->txt(
"cont_left"),
290 "Right" => $lng->txt(
"cont_right"),
"Center" => $lng->txt(
"cont_center"),
291 "LeftFloat" => $lng->txt(
"cont_left_float"),
292 "RightFloat" => $lng->txt(
"cont_right_float"));
295 $align->setValue(
"Center");
296 $this->form->addItem($align);
299 $caption =
new ilTextInputGUI($this->lng->txt(
"cont_caption"),
"caption");
301 $this->form->addItem($caption);
304 $ca_opts = array(
"top" => $lng->txt(
"cont_top"),
305 "bottom" => $lng->txt(
"cont_bottom"));
309 $caption->addSubItem($ca);
312 if ($a_mode ==
"create")
316 $op =
new ilRadioOption($this->lng->txt(
"cont_html_table"),
"html");
317 $import->addOption($op);
318 $op2 =
new ilRadioOption($this->lng->txt(
"cont_spreadsheet_table"),
"spreadsheet");
321 $import_data->setRows(8);
322 $import_data->setCols(50);
325 $import->addOption($op2);
326 $import->setValue(
"html");
327 $this->form->addItem($import);
333 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
337 $s_lang = $ilUser->getLanguage();
339 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
343 $language->setValue($s_lang);
344 $this->form->addItem($language);
346 if ($a_mode ==
"create")
348 $this->form->addCommandButton(
"create_tab", $lng->txt(
"save"));
349 $this->form->addCommandButton(
"cancelCreate", $lng->txt(
"cancel"));
353 $this->form->addCommandButton(
"saveProperties", $lng->txt(
"save"));
363 $values[
"width"] = $this->content_obj->getWidth();
364 $values[
"border"] = $this->content_obj->getBorder();
365 $values[
"padding"] = $this->content_obj->getCellPadding();
366 $values[
"spacing"] = $this->content_obj->getCellSpacing();
367 $values[
"row_header"] = $this->content_obj->getHeaderRows();
368 $values[
"row_footer"] = $this->content_obj->getFooterRows();
369 $values[
"col_header"] = $this->content_obj->getHeaderCols();
370 $values[
"col_footer"] = $this->content_obj->getFooterCols();
371 if ($this->content_obj->getTemplate() !=
"")
373 $values[
"characteristic"] =
"t:".
375 $this->content_obj->getTemplate();
379 $values[
"characteristic"] = $this->content_obj->getClass();
381 $values[
"align"] = $this->content_obj->getHorizontalAlign();
382 $values[
"caption"] = $this->content_obj->getCaption();
383 $values[
"cap_align"] = $this->content_obj->getCaptionAlign();
384 $values[
"language"] = $this->content_obj->getLanguage();
386 $this->form->setValuesByArray($values);
388 $ca = $this->form->getItemByPostVar(
"cap_align");
389 $ca->setValue($this->content_obj->getCaptionAlign());
397 $tab_node = $this->content_obj->getNode();
398 $tab_node->set_attribute(
"Enabled",
"True");
399 $content = $this->dom->dump_node($tab_node);
401 $trans = $this->pg_obj->getLanguageVariablesXML();
402 $mobs = $this->pg_obj->getMultimediaXML();
407 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
409 $template_xml = $style->getTemplateXML();
413 $content = $content.$mobs.$trans.$template_xml;
421 static function _renderTable($content, $a_mode =
"table_edit", $a_submode =
"", $a_table_obj = null)
425 $content =
"<dummy>".$content.
"</dummy>";
427 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
428 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
435 $params = array (
'mode' => $a_mode,
436 'med_disabled_path' => $med_disabled_path,
437 'media_mode' => $ilUser->getPref(
"ilPageEditor_MediaMode"),
438 'media_mode' =>
'disable',
439 'webspace_path' => $wb_path,
'enlarge_path' => $enlarge_path);
440 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args, $params);
445 $output = str_replace(
"<",
"<",$output);
446 $output = str_replace(
">",
">",$output);
447 $output = str_replace(
"&",
"&",$output);
449 if ($a_mode ==
"table_edit" && !is_null($a_table_obj))
472 return '<div style="float:left;">'.$output.
'</div>';
482 $classes = $a_table->getAllCellClasses();
484 foreach ($classes as $k => $v)
488 $v = $lng->txt(
"none");
490 if (substr($v, 0, 4) ==
"ilc_")
494 $check = $lng->txt(
"cont_style").
": ".
495 '<input type="checkbox" value="1"'.
496 ' name="target['.$k.
']">'.
'</input> '.$v;
498 $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $check, $a_output);
510 $classes = $a_table->getAllCellAlignments();
512 foreach ($classes as $k => $v)
516 $v = $lng->txt(
"default");
518 $check = $lng->txt(
"cont_alignment").
": ".
519 '<input type="checkbox" value="1"'.
520 ' name="target['.$k.
']">'.
'</input> '.$v;
522 $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $check, $a_output);
534 $widths = $a_table->getAllCellWidths();
536 foreach ($widths as $k => $v)
538 $check = $lng->txt(
"cont_width").
": ".
539 '<input class="small" type="text" size="5" maxlength="10"'.
540 ' name="width['.$k.
']" value="'.$v.
'">'.
'</input>';
542 $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $check, $a_output);
554 $spans = $a_table->getAllCellSpans();
556 foreach ($spans as $k => $v)
559 $selects =
'<div style="white-space:nowrap;">'.$lng->txt(
"cont_colspan").
": ".
560 '<select class="small" name="colspan['.$k.
']">';
561 for ($i = 1; $i <= $v[
"max_x"] - $v[
"x"] + 1; $i++)
563 $sel_str = ($i == $v[
"colspan"])
564 ?
'selected="selected"'
566 $selects.=
'<option value="'.$i.
'" '.$sel_str.
'>'.$i.
'</option>';
568 $selects.=
"</select></div>";
571 $selects.=
'<div style="margin-top:3px; white-space:nowrap;">'.$lng->txt(
"cont_rowspan").
": ".
572 '<select class="small" name="rowspan['.$k.
']">';
573 for ($i = 1; $i <= $v[
"max_y"] - $v[
"y"] + 1; $i++)
575 $sel_str = ($i == $v[
"rowspan"])
576 ?
'selected="selected"'
578 $selects.=
'<option value="'.$i.
'" '.$sel_str.
'>'.$i.
'</option>';
580 $selects.=
"</select></div>";
582 $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $selects, $a_output);
597 $ilTabs->setSubTabActive(
"cont_style");
600 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
602 $form->setFormAction($ilCtrl->getFormAction($this));
603 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
606 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
612 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
613 foreach($options as $k => $option)
615 $html =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_'.$k.
'">'.
616 $option.
'</td></tr></table>';
617 $style->addOption($k, $option, $html);
620 $style->setValue(
"");
621 $style->setInfo($lng->txt(
"cont_set_tab_style_info"));
622 $form->addItem($style);
623 $form->setKeepOpen(
true);
625 $form->addCommandButton(
"setStyles", $lng->txt(
"cont_set_styles"));
627 $html = $form->getHTML();
628 $html.=
"<br />".$this->renderTable(
"table_edit",
"style").
"</form>";
629 $tpl->setContent($html);
643 $ilTabs->setSubTabActive(
"cont_width");
644 $ilTabs->setTabActive(
"cont_table_cell_properties");
646 $ctpl =
new ilTemplate(
"tpl.table_cell_properties.html",
true,
true,
"Services/COPage");
647 $ctpl->setVariable(
"BTN_NAME",
"setWidths");
648 $ctpl->setVariable(
"BTN_TEXT", $lng->txt(
"cont_save_widths"));
649 $ctpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
651 $html = $ctpl->get();
652 $html.=
"<br />".$this->renderTable(
"table_edit",
"width").
"</form>";
653 $tpl->setContent($html);
667 $ilTabs->setSubTabActive(
"cont_span");
668 $ilTabs->setTabActive(
"cont_table_cell_properties");
670 $ctpl =
new ilTemplate(
"tpl.table_cell_properties.html",
true,
true,
"Services/COPage");
671 $ctpl->setVariable(
"BTN_NAME",
"setSpans");
672 $ctpl->setVariable(
"BTN_TEXT", $lng->txt(
"cont_save_spans"));
673 $ctpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
675 $html = $ctpl->get();
676 $html.=
"<br />".$this->renderTable(
"table_edit",
"span").
"</form>";
677 $tpl->setContent($html);
688 if (is_array(
$_POST[
"target"]))
690 foreach (
$_POST[
"target"] as $k => $value)
694 $cid = explode(
":", $k);
700 $this->updated = $this->pg_obj->update();
702 $this->ctrl->redirect($this,
"editCellStyle");
712 if (is_array(
$_POST[
"width"]))
714 foreach (
$_POST[
"width"] as $k => $width)
716 $cid = explode(
":", $k);
721 $this->updated = $this->pg_obj->update();
723 $this->ctrl->redirect($this,
"editCellWidth");
733 if (is_array(
$_POST[
"colspan"]))
735 foreach (
$_POST[
"colspan"] as $k => $span)
740 $this->content_obj->setTDSpans(
$_POST[
"colspan"],
$_POST[
"rowspan"]);
742 $this->updated = $this->pg_obj->update();
744 $this->ctrl->redirect($this,
"editCellSpan");
754 $caption = str_replace(
"&",
"&", $caption);
755 $caption = str_replace(
"<",
"<", $caption);
756 $caption = str_replace(
">",
">", $caption);
768 if (strpos(
$_POST[
"characteristic"],
":") > 0)
770 $t = explode(
":",
$_POST[
"characteristic"]);
772 $this->content_obj->setClass(
"");
777 $this->content_obj->setTemplate(
"");
779 $this->content_obj->setCaption($caption,
789 $this->updated = $this->pg_obj->update();
790 if ($this->updated ===
true)
792 $this->ctrl->redirect($this,
"edit");
797 $this->pg_obj->addHierIDs();
807 $this->content_obj->setHorizontalAlign(
"Right");
808 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
809 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
817 $this->content_obj->setHorizontalAlign(
"Left");
818 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
819 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
827 $this->content_obj->setHorizontalAlign(
"Center");
828 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
829 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
837 $this->content_obj->setHorizontalAlign(
"LeftFloat");
838 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
839 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
847 $this->content_obj->setHorizontalAlign(
"RightFloat");
848 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
849 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
862 $html = $this->form->getHTML();
863 $tpl->setContent($html);
882 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
883 $import_table = trim(
$_POST[
"import_table"]);
886 if (!empty ($import_table))
888 switch(
$_POST[
"import_type"])
892 if (!$this->content_obj->importHtml (
$_POST[
"language"], $import_table))
901 $this->content_obj->importSpreadsheet(
$_POST[
"language"], $import_table);
916 $this->content_obj->setFirstRowStyle($frtype);
919 $this->updated = $this->pg_obj->update();
921 if ($this->updated ===
true)
936 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
954 $ilTabs->setSubTabActive(
"cont_alignment");
955 $ilTabs->setTabActive(
"cont_table_cell_properties");
958 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
960 $form->setFormAction($ilCtrl->getFormAction($this));
961 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
965 "" => $lng->txt(
"default"),
966 "Left" => $lng->txt(
"cont_left"),
967 "Center" => $lng->txt(
"cont_center"),
968 "Right" => $lng->txt(
"cont_right")
972 $si->setInfo($lng->txt(
""));
975 $form->setKeepOpen(
true);
977 $form->addCommandButton(
"setAlignment", $lng->txt(
"cont_set_alignment"));
979 $html = $form->getHTML();
980 $html.=
"<br />".$this->renderTable(
"table_edit",
"alignment").
"</form>";
981 $tpl->setContent($html);
992 if (is_array(
$_POST[
"target"]))
994 foreach (
$_POST[
"target"] as $k => $value)
998 $cid = explode(
":", $k);
1004 $this->updated = $this->pg_obj->update();
1007 $this->ctrl->redirect($this,
"editCellAlignment");