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_span",
100 $ilCtrl->getLinkTarget($this,
"editCellSpan"),
"editCellSpan",
125 $html = $this->form->getHTML();
126 $html.=
"<br />".$this->renderTable(
"");
127 $tpl->setContent($html);
137 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
139 $this->form->setFormAction($ilCtrl->getFormAction($this));
140 if ($a_mode ==
"create")
142 $this->form->setTitle($this->lng->txt(
"cont_insert_table"));
146 $this->form->setTitle($this->lng->txt(
"cont_table_properties"));
149 if ($a_mode ==
"create")
152 for($i=1; $i<=20; $i++)
161 $this->form->addItem($cols);
167 $this->form->addItem($rows);
171 $width =
new ilTextInputGUI($this->lng->txt(
"cont_table_width"),
"width");
173 $width->setMaxLength(6);
174 $this->form->addItem($width);
177 $border =
new ilTextInputGUI($this->lng->txt(
"cont_table_border"),
"border");
180 $border->setMaxLength(6);
181 $this->form->addItem($border);
184 $padding =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellpadding"),
"padding");
186 $padding->setSize(6);
187 $padding->setMaxLength(6);
188 $this->form->addItem($padding);
191 $spacing =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellspacing"),
"spacing");
193 $spacing->setSize(6);
194 $spacing->setMaxLength(6);
195 $this->form->addItem($spacing);
198 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
203 $chars = array_merge($templates, $chars);
204 if (is_object($this->content_obj))
206 if ($chars[$a_seleted_value] ==
"" && ($this->content_obj->getClass() !=
""))
208 $chars = array_merge(
209 array($this->content_obj->getClass() => $this->content_obj->getClass()),
213 foreach($chars as $k => $char)
215 if (strpos($k,
":") > 0)
217 $t = explode(
":", $k);
218 $html = $this->style->lookupTemplatePreview(
$t[1]).
'<div style="clear:both;" class="small">'.$char.
"</div>";
222 $html =
'<table class="ilc_table_'.$k.
'"><tr><td class="small">'.
223 $char.
'</td></tr></table>';
225 $char_prop->addOption($k, $char, $html);
227 $char_prop->setValue(
"StandardTable");
228 $this->form->addItem($char_prop);
231 for($i=0; $i<=3; $i++)
237 $rh =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_header"),
"row_header");
240 $this->form->addItem($rh);
243 $rf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_footer"),
"row_footer");
246 $this->form->addItem($rf);
249 $ch =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_header"),
"col_header");
252 $this->form->addItem($ch);
255 $cf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_footer"),
"col_footer");
258 $this->form->addItem($cf);
260 if ($a_mode ==
"create")
263 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
269 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
270 foreach($options as $k => $option)
272 $html =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_'.$k.
'">'.
273 $option.
'</td></tr></table>';
274 $fr_style->addOption($k, $option, $html);
277 $fr_style->setValue(
"");
278 $this->form->addItem($fr_style);
282 $align_opts = array(
"Left" => $lng->txt(
"cont_left"),
283 "Right" => $lng->txt(
"cont_right"),
"Center" => $lng->txt(
"cont_center"),
284 "LeftFloat" => $lng->txt(
"cont_left_float"),
285 "RightFloat" => $lng->txt(
"cont_right_float"));
288 $align->setValue(
"Center");
289 $this->form->addItem($align);
292 $caption =
new ilTextInputGUI($this->lng->txt(
"cont_caption"),
"caption");
294 $this->form->addItem($caption);
297 $ca_opts = array(
"top" => $lng->txt(
"cont_top"),
298 "bottom" => $lng->txt(
"cont_bottom"));
302 $caption->addSubItem($ca);
305 if ($a_mode ==
"create")
309 $op =
new ilRadioOption($this->lng->txt(
"cont_html_table"),
"html");
310 $import->addOption($op);
311 $op2 =
new ilRadioOption($this->lng->txt(
"cont_spreadsheet_table"),
"spreadsheet");
314 $import_data->setRows(8);
315 $import_data->setCols(50);
318 $import->addOption($op2);
319 $import->setValue(
"html");
320 $this->form->addItem($import);
326 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
330 $s_lang = $ilUser->getLanguage();
332 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
336 $language->setValue($s_lang);
337 $this->form->addItem($language);
339 if ($a_mode ==
"create")
341 $this->form->addCommandButton(
"create_tab", $lng->txt(
"save"));
342 $this->form->addCommandButton(
"cancelCreate", $lng->txt(
"cancel"));
346 $this->form->addCommandButton(
"saveProperties", $lng->txt(
"save"));
356 $values[
"width"] = $this->content_obj->getWidth();
357 $values[
"border"] = $this->content_obj->getBorder();
358 $values[
"padding"] = $this->content_obj->getCellPadding();
359 $values[
"spacing"] = $this->content_obj->getCellSpacing();
360 $values[
"row_header"] = $this->content_obj->getHeaderRows();
361 $values[
"row_footer"] = $this->content_obj->getFooterRows();
362 $values[
"col_header"] = $this->content_obj->getHeaderCols();
363 $values[
"col_footer"] = $this->content_obj->getFooterCols();
364 if ($this->content_obj->getTemplate() !=
"")
366 $values[
"characteristic"] =
"t:".
368 $this->content_obj->getTemplate();
372 $values[
"characteristic"] = $this->content_obj->getClass();
374 $values[
"align"] = $this->content_obj->getHorizontalAlign();
375 $values[
"caption"] = $this->content_obj->getCaption();
376 $values[
"cap_align"] = $this->content_obj->getCaptionAlign();
377 $values[
"language"] = $this->content_obj->getLanguage();
379 $this->form->setValuesByArray($values);
381 $ca = $this->form->getItemByPostVar(
"cap_align");
382 $ca->setValue($this->content_obj->getCaptionAlign());
390 $tab_node = $this->content_obj->getNode();
391 $content = $this->dom->dump_node($tab_node);
392 $trans = $this->pg_obj->getLanguageVariablesXML();
393 $mobs = $this->pg_obj->getMultimediaXML();
398 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
400 $template_xml = $style->getTemplateXML();
404 $content = $content.$mobs.$trans.$template_xml;
412 static function _renderTable($content, $a_mode =
"table_edit", $a_submode =
"", $a_table_obj = null)
416 $content =
"<dummy>".$content.
"</dummy>";
418 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
419 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
426 $params = array (
'mode' => $a_mode,
427 'med_disabled_path' => $med_disabled_path,
428 'media_mode' => $ilUser->getPref(
"ilPageEditor_MediaMode"),
429 'webspace_path' => $wb_path,
'enlarge_path' => $enlarge_path);
435 $output = str_replace(
"<",
"<",$output);
436 $output = str_replace(
">",
">",$output);
437 $output = str_replace(
"&",
"&",$output);
439 if ($a_mode ==
"table_edit" && !is_null($a_table_obj))
458 return '<div style="float:left;">'.$output.
'</div>';
468 $classes = $a_table->getAllCellClasses();
470 foreach ($classes as $k => $v)
474 $v = $lng->txt(
"none");
476 if (substr($v, 0, 4) ==
"ilc_")
480 $check = $lng->txt(
"cont_style").
": ".
481 '<input type="checkbox" value="1"'.
482 ' name="target['.$k.
']">'.
'</input> '.$v;
484 $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $check, $a_output);
496 $widths = $a_table->getAllCellWidths();
498 foreach ($widths as $k => $v)
500 $check = $lng->txt(
"cont_width").
": ".
501 '<input class="small" type="text" size="5" maxlength="10"'.
502 ' name="width['.$k.
']" value="'.$v.
'">'.
'</input>';
504 $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $check, $a_output);
516 $spans = $a_table->getAllCellSpans();
518 foreach ($spans as $k => $v)
521 $selects =
'<div style="white-space:nowrap;">'.$lng->txt(
"cont_colspan").
": ".
522 '<select class="small" name="colspan['.$k.
']">';
523 for ($i = 1; $i <= $v[
"max_x"] - $v[
"x"] + 1; $i++)
525 $sel_str = ($i == $v[
"colspan"])
526 ?
'selected="selected"'
528 $selects.=
'<option value="'.$i.
'" '.$sel_str.
'>'.$i.
'</option>';
530 $selects.=
"</select></div>";
533 $selects.=
'<div style="margin-top:3px; white-space:nowrap;">'.$lng->txt(
"cont_rowspan").
": ".
534 '<select class="small" name="rowspan['.$k.
']">';
535 for ($i = 1; $i <= $v[
"max_y"] - $v[
"y"] + 1; $i++)
537 $sel_str = ($i == $v[
"rowspan"])
538 ?
'selected="selected"'
540 $selects.=
'<option value="'.$i.
'" '.$sel_str.
'>'.$i.
'</option>';
542 $selects.=
"</select></div>";
544 $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $selects, $a_output);
559 $ilTabs->setSubTabActive(
"cont_style");
562 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
564 $form->setFormAction($ilCtrl->getFormAction($this));
565 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
568 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
574 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
575 foreach($options as $k => $option)
577 $html =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_'.$k.
'">'.
578 $option.
'</td></tr></table>';
579 $style->addOption($k, $option, $html);
582 $style->setValue(
"");
583 $style->setInfo($lng->txt(
"cont_set_tab_style_info"));
584 $form->addItem($style);
585 $form->setKeepOpen(
true);
587 $form->addCommandButton(
"setStyles", $lng->txt(
"cont_set_styles"));
589 $html = $form->getHTML();
590 $html.=
"<br />".$this->renderTable(
"table_edit",
"style").
"</form>";
591 $tpl->setContent($html);
605 $ilTabs->setSubTabActive(
"cont_width");
606 $ilTabs->setTabActive(
"cont_table_cell_properties");
608 $ctpl =
new ilTemplate(
"tpl.table_cell_properties.html",
true,
true,
"Services/COPage");
609 $ctpl->setVariable(
"BTN_NAME",
"setWidths");
610 $ctpl->setVariable(
"BTN_TEXT", $lng->txt(
"cont_save_widths"));
611 $ctpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
613 $html = $ctpl->get();
614 $html.=
"<br />".$this->renderTable(
"table_edit",
"width").
"</form>";
615 $tpl->setContent($html);
629 $ilTabs->setSubTabActive(
"cont_span");
630 $ilTabs->setTabActive(
"cont_table_cell_properties");
632 $ctpl =
new ilTemplate(
"tpl.table_cell_properties.html",
true,
true,
"Services/COPage");
633 $ctpl->setVariable(
"BTN_NAME",
"setSpans");
634 $ctpl->setVariable(
"BTN_TEXT", $lng->txt(
"cont_save_spans"));
635 $ctpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
637 $html = $ctpl->get();
638 $html.=
"<br />".$this->renderTable(
"table_edit",
"span").
"</form>";
639 $tpl->setContent($html);
650 if (is_array(
$_POST[
"target"]))
652 foreach (
$_POST[
"target"] as $k => $value)
656 $cid = explode(
":", $k);
662 $this->updated = $this->pg_obj->update();
664 $this->ctrl->redirect($this,
"editCellStyle");
674 if (is_array(
$_POST[
"width"]))
676 foreach (
$_POST[
"width"] as $k => $width)
678 $cid = explode(
":", $k);
683 $this->updated = $this->pg_obj->update();
685 $this->ctrl->redirect($this,
"editCellWidth");
695 if (is_array(
$_POST[
"colspan"]))
697 foreach (
$_POST[
"colspan"] as $k => $span)
702 $this->content_obj->setTDSpans(
$_POST[
"colspan"],
$_POST[
"rowspan"]);
704 $this->updated = $this->pg_obj->update();
706 $this->ctrl->redirect($this,
"editCellSpan");
716 $caption = str_replace(
"&",
"&", $caption);
717 $caption = str_replace(
"<",
"<", $caption);
718 $caption = str_replace(
">",
">", $caption);
730 if (strpos(
$_POST[
"characteristic"],
":") > 0)
732 $t = explode(
":",
$_POST[
"characteristic"]);
734 $this->content_obj->setClass(
"");
739 $this->content_obj->setTemplate(
"");
741 $this->content_obj->setCaption($caption,
751 $this->updated = $this->pg_obj->update();
752 if ($this->updated ===
true)
754 $this->ctrl->redirect($this,
"edit");
759 $this->pg_obj->addHierIDs();
769 $this->content_obj->setHorizontalAlign(
"Right");
770 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
771 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
779 $this->content_obj->setHorizontalAlign(
"Left");
780 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
781 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
789 $this->content_obj->setHorizontalAlign(
"Center");
790 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
791 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
799 $this->content_obj->setHorizontalAlign(
"LeftFloat");
800 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
801 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
809 $this->content_obj->setHorizontalAlign(
"RightFloat");
810 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
811 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
824 $html = $this->form->getHTML();
825 $tpl->setContent($html);
844 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
845 $import_table = trim(
$_POST[
"import_table"]);
848 if (!empty ($import_table))
850 switch(
$_POST[
"import_type"])
854 if (!$this->content_obj->importHtml (
$_POST[
"language"], $import_table))
863 $this->content_obj->importSpreadsheet(
$_POST[
"language"], $import_table);
878 $this->content_obj->setFirstRowStyle($frtype);
881 $this->updated = $this->pg_obj->update();
883 if ($this->updated ===
true)
898 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);