ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Services/COPage/classes/class.ilPCTable.php");
5 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
6 
18 {
19 
24  function ilPCTableGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
25  {
26  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
27  $this->setCharacteristics(array("StandardTable" => $this->lng->txt("cont_StandardTable")));
28 
29  }
30 
35  {
36  $this->setCharacteristics(array("Cell1" => "Cell1", "Cell2" => "Cell2",
37  "Cell3" => "Cell3", "Cell4" => "Cell4"));
38  }
39 
43  function &executeCommand()
44  {
45  $this->getCharacteristicsOfCurrentStyle("table"); // scorm-2004
46 
47  // get next class that processes or forwards current command
48  $next_class = $this->ctrl->getNextClass($this);
49 
50  // get current command
51  $cmd = $this->ctrl->getCmd();
52 
53  switch($next_class)
54  {
55  default:
56  $ret =& $this->$cmd();
57  break;
58  }
59 
60  return $ret;
61  }
62 
63 
67  function setTabs()
68  {
69  global $ilTabs, $ilCtrl, $lng;
70 
71  $ilTabs->setBackTarget($lng->txt("pg"),
72  $this->ctrl->getParentReturn($this));
73 
74  $ilTabs->addTarget("cont_table_properties",
75  $ilCtrl->getLinkTarget($this, "edit"), "edit",
76  get_class($this));
77 
78  $ilTabs->addTarget("cont_table_cell_properties",
79  $ilCtrl->getLinkTarget($this, "editCellStyle"), "editCellStyle",
80  get_class($this));
81 
82  }
83 
88  {
89  global $ilTabs, $ilCtrl, $lng;
90 
91  $ilTabs->addSubTabTarget("cont_style",
92  $ilCtrl->getLinkTarget($this, "editCellStyle"), "editCellStyle",
93  get_class($this));
94 
95  $ilTabs->addSubTabTarget("cont_width",
96  $ilCtrl->getLinkTarget($this, "editCellWidth"), "editCellWidth",
97  get_class($this));
98 
99  $ilTabs->addSubTabTarget("cont_span",
100  $ilCtrl->getLinkTarget($this, "editCellSpan"), "editCellSpan",
101  get_class($this));
102 
103  }
104 
109  {
110  return parent::getTemplateOptions("table");
111  }
112 
116  function edit()
117  {
118  global $ilCtrl, $lng, $tpl;
119 
120  $this->displayValidationError();
121  $this->setTabs();
122 
123  $this->initPropertiesForm();
124  $this->getPropertiesFormValues();
125  $html = $this->form->getHTML();
126  $html.= "<br />".$this->renderTable("");
127  $tpl->setContent($html);
128  }
129 
133  function initPropertiesForm($a_mode = "edit")
134  {
135  global $ilCtrl, $lng, $tpl, $ilUser;
136 
137  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
138  $this->form = new ilPropertyFormGUI();
139  $this->form->setFormAction($ilCtrl->getFormAction($this));
140  if ($a_mode == "create")
141  {
142  $this->form->setTitle($this->lng->txt("cont_insert_table"));
143  }
144  else
145  {
146  $this->form->setTitle($this->lng->txt("cont_table_properties"));
147  }
148 
149  if ($a_mode == "create")
150  {
151  $nr = array();
152  for($i=1; $i<=20; $i++)
153  {
154  $nr[$i] = $i;
155  }
156 
157  // cols
158  $cols = new ilSelectInputGUI($this->lng->txt("cont_nr_cols"), "nr_cols");
159  $cols->setOptions($nr);
160  $cols->setValue(2);
161  $this->form->addItem($cols);
162 
163  // rows
164  $rows = new ilSelectInputGUI($this->lng->txt("cont_nr_rows"), "nr_rows");
165  $rows->setOptions($nr);
166  $rows->setValue(2);
167  $this->form->addItem($rows);
168  }
169 
170  // width
171  $width = new ilTextInputGUI($this->lng->txt("cont_table_width"), "width");
172  $width->setSize(6);
173  $width->setMaxLength(6);
174  $this->form->addItem($width);
175 
176  // border
177  $border = new ilTextInputGUI($this->lng->txt("cont_table_border"), "border");
178  $border->setValue("1px");
179  $border->setSize(6);
180  $border->setMaxLength(6);
181  $this->form->addItem($border);
182 
183  // padding
184  $padding = new ilTextInputGUI($this->lng->txt("cont_table_cellpadding"), "padding");
185  $padding->setValue("2px");
186  $padding->setSize(6);
187  $padding->setMaxLength(6);
188  $this->form->addItem($padding);
189 
190  // spacing
191  $spacing = new ilTextInputGUI($this->lng->txt("cont_table_cellspacing"), "spacing");
192  $spacing->setValue("0px");
193  $spacing->setSize(6);
194  $spacing->setMaxLength(6);
195  $this->form->addItem($spacing);
196 
197  // table templates and table classes
198  require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
199  $char_prop = new ilAdvSelectInputGUI($this->lng->txt("cont_characteristic"),
200  "characteristic");
201  $chars = $this->getCharacteristics();
202  $templates = $this->getTemplateOptions();
203  $chars = array_merge($templates, $chars);
204  if (is_object($this->content_obj))
205  {
206  if ($chars[$a_seleted_value] == "" && ($this->content_obj->getClass() != ""))
207  {
208  $chars = array_merge(
209  array($this->content_obj->getClass() => $this->content_obj->getClass()),
210  $chars);
211  }
212  }
213  foreach($chars as $k => $char)
214  {
215  if (strpos($k, ":") > 0)
216  {
217  $t = explode(":", $k);
218  $html = $this->style->lookupTemplatePreview($t[1]).'<div style="clear:both;" class="small">'.$char."</div>";
219  }
220  else
221  {
222  $html = '<table class="ilc_table_'.$k.'"><tr><td class="small">'.
223  $char.'</td></tr></table>';
224  }
225  $char_prop->addOption($k, $char, $html);
226  }
227  $char_prop->setValue("StandardTable");
228  $this->form->addItem($char_prop);
229 
230  $nr = array();
231  for($i=0; $i<=3; $i++)
232  {
233  $nr[$i] = $i;
234  }
235 
236  // row header
237  $rh = new ilSelectInputGUI($this->lng->txt("cont_nr_row_header"), "row_header");
238  $rh->setOptions($nr);
239  $rh->setValue(1);
240  $this->form->addItem($rh);
241 
242  // row footer
243  $rf = new ilSelectInputGUI($this->lng->txt("cont_nr_row_footer"), "row_footer");
244  $rf->setOptions($nr);
245  $rf->setValue(0);
246  $this->form->addItem($rf);
247 
248  // col header
249  $ch = new ilSelectInputGUI($this->lng->txt("cont_nr_col_header"), "col_header");
250  $ch->setOptions($nr);
251  $ch->setValue(0);
252  $this->form->addItem($ch);
253 
254  // col footer
255  $cf = new ilSelectInputGUI($this->lng->txt("cont_nr_col_footer"), "col_footer");
256  $cf->setOptions($nr);
257  $cf->setValue(0);
258  $this->form->addItem($cf);
259 
260  if ($a_mode == "create")
261  {
262  // first row style
263  require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
264  $fr_style = new ilAdvSelectInputGUI($this->lng->txt("cont_first_row_style"),
265  "first_row_style");
266  $this->setBasicTableCellStyles();
267  $this->getCharacteristicsOfCurrentStyle("table_cell");
268  $chars = $this->getCharacteristics();
269  $options = array_merge(array("" => $this->lng->txt("none")), $chars);
270  foreach($options as $k => $option)
271  {
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);
275  }
276 
277  $fr_style->setValue("");
278  $this->form->addItem($fr_style);
279  }
280 
281  // alignment
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"));
286  $align = new ilSelectInputGUI($this->lng->txt("cont_align"), "align");
287  $align->setOptions($align_opts);
288  $align->setValue("Center");
289  $this->form->addItem($align);
290 
291  // caption
292  $caption = new ilTextInputGUI($this->lng->txt("cont_caption"), "caption");
293  $caption->setSize(60);
294  $this->form->addItem($caption);
295 
296  // caption align
297  $ca_opts = array("top" => $lng->txt("cont_top"),
298  "bottom" => $lng->txt("cont_bottom"));
299  $ca = new ilSelectInputGUI($this->lng->txt("cont_align"),
300  "cap_align");
301  $ca->setOptions($ca_opts);
302  $caption->addSubItem($ca);
303 
304  // import
305  if ($a_mode == "create")
306  {
307  // import table
308  $import = new ilRadioGroupInputGUI($this->lng->txt("cont_paste_table"), "import_type");
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");
312 
313  $import_data = new ilTextAreaInputGUI("", "import_table");
314  $import_data->setRows(8);
315  $import_data->setCols(50);
316  $op2->addSubItem($import_data);
317 
318  $import->addOption($op2);
319  $import->setValue("html");
320  $this->form->addItem($import);
321  }
322 
323  // language
324  if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
325  {
326  $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
327  }
328  else
329  {
330  $s_lang = $ilUser->getLanguage();
331  }
332  require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
334  $language = new ilSelectInputGUI($this->lng->txt("language"), "language");
335  $language->setOptions($lang);
336  $language->setValue($s_lang);
337  $this->form->addItem($language);
338 
339  if ($a_mode == "create")
340  {
341  $this->form->addCommandButton("create_tab", $lng->txt("save"));
342  $this->form->addCommandButton("cancelCreate", $lng->txt("cancel"));
343  }
344  else
345  {
346  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
347  }
348  }
349 
354  {
355  $values = array();
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() != "")
365  {
366  $values["characteristic"] = "t:".
367  ilObjStyleSheet::_lookupTemplateIdByName($this->getStyleId(), $this->content_obj->getTemplate()).":".
368  $this->content_obj->getTemplate();
369  }
370  else
371  {
372  $values["characteristic"] = $this->content_obj->getClass();
373  }
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();
378 
379  $this->form->setValuesByArray($values);
380 
381  $ca = $this->form->getItemByPostVar("cap_align");
382  $ca->setValue($this->content_obj->getCaptionAlign());
383  }
384 
388  function renderTable($a_mode = "table_edit", $a_submode = "")
389  {
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();
394  if ($this->getStyleId() > 0)
395  {
396  if (ilObject::_lookupType($this->getStyleId()) == "sty")
397  {
398  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
399  $style = new ilObjStyleSheet($this->getStyleId());
400  $template_xml = $style->getTemplateXML();
401  }
402  }
403 
404  $content = $content.$mobs.$trans.$template_xml;
405 
406  return ilPCTableGUI::_renderTable($content, $a_mode, $a_submode, $this->content_obj);
407  }
408 
412  static function _renderTable($content, $a_mode = "table_edit", $a_submode = "", $a_table_obj = null)
413  {
414  global $ilUser;
415 
416  $content = "<dummy>".$content."</dummy>";
417 
418  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
419  $args = array( '/_xml' => $content, '/_xsl' => $xsl );
420  $xh = xslt_create();
421 //echo "<b>XML</b>:".htmlentities($content).":<br>";
422 //echo "<b>XSLT</b>:".htmlentities($xsl).":<br>";
423  $med_disabled_path = ilUtil::getImagePath("media_disabled.gif");
424  $wb_path = ilUtil::getWebspaceDir("output");
425  $enlarge_path = ilUtil::getImagePath("enlarge.gif");
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);
430  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
431  echo xslt_error($xh);
432  xslt_free($xh);
433 
434  // unmask user html
435  $output = str_replace("&lt;","<",$output);
436  $output = str_replace("&gt;",">",$output);
437  $output = str_replace("&amp;","&",$output);
438 
439  if ($a_mode == "table_edit" && !is_null($a_table_obj))
440  {
441  switch ($a_submode)
442  {
443  case "style":
444  $output = ilPCTableGUI::_addStyleCheckboxes($output, $a_table_obj);
445  break;
446 
447  case "width":
448  $output = ilPCTableGUI::_addWidthInputs($output, $a_table_obj);
449  break;
450 
451  case "span":
452  $output = ilPCTableGUI::_addSpanInputs($output, $a_table_obj);
453  break;
454  }
455  }
456 
457 
458  return '<div style="float:left;">'.$output.'</div>';
459  }
460 
464  static function _addStyleCheckboxes($a_output, $a_table)
465  {
466  global $lng;
467 
468  $classes = $a_table->getAllCellClasses();
469 
470  foreach ($classes as $k => $v)
471  {
472  if ($v == "")
473  {
474  $v = $lng->txt("none");
475  }
476  if (substr($v, 0, 4) == "ilc_")
477  {
478  $v = substr($v, 4);
479  }
480  $check = $lng->txt("cont_style").": ".
481  '<input type="checkbox" value="1"'.
482  ' name="target['.$k.']">'.'</input> '.$v;
483 
484  $a_output = str_replace("{{{{{TableEdit;".$k."}}}}}", $check, $a_output);
485  }
486  return $a_output;
487  }
488 
492  static function _addWidthInputs($a_output, $a_table)
493  {
494  global $lng;
495 
496  $widths = $a_table->getAllCellWidths();
497 
498  foreach ($widths as $k => $v)
499  {
500  $check = $lng->txt("cont_width").": ".
501  '<input class="small" type="text" size="5" maxlength="10"'.
502  ' name="width['.$k.']" value="'.$v.'">'.'</input>';
503 
504  $a_output = str_replace("{{{{{TableEdit;".$k."}}}}}", $check, $a_output);
505  }
506  return $a_output;
507  }
508 
512  static function _addSpanInputs($a_output, $a_table)
513  {
514  global $lng;
515 
516  $spans = $a_table->getAllCellSpans();
517 
518  foreach ($spans as $k => $v)
519  {
520  // colspans
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++)
524  {
525  $sel_str = ($i == $v["colspan"])
526  ? 'selected="selected"'
527  : '';
528  $selects.= '<option value="'.$i.'" '.$sel_str.'>'.$i.'</option>';
529  }
530  $selects.= "</select></div>";
531 
532  // rowspans
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++)
536  {
537  $sel_str = ($i == $v["rowspan"])
538  ? 'selected="selected"'
539  : '';
540  $selects.= '<option value="'.$i.'" '.$sel_str.'>'.$i.'</option>';
541  }
542  $selects.= "</select></div>";
543 
544  $a_output = str_replace("{{{{{TableEdit;".$k."}}}}}", $selects, $a_output);
545  }
546  return $a_output;
547  }
548 
552  function editCellStyle()
553  {
554  global $ilCtrl, $tpl, $lng, $ilTabs;
555 
556  $this->displayValidationError();
557  $this->setTabs();
558  $this->setCellPropertiesSubTabs();
559  $ilTabs->setSubTabActive("cont_style");
560 
561  // edit form
562  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
563  $form = new ilPropertyFormGUI();
564  $form->setFormAction($ilCtrl->getFormAction($this));
565  $form->setTitle($this->lng->txt("cont_table_cell_properties"));
566 
567  // first row style
568  require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
569  $style = new ilAdvSelectInputGUI($this->lng->txt("cont_style"),
570  "style");
571  $this->setBasicTableCellStyles();
572  $this->getCharacteristicsOfCurrentStyle("table_cell"); // scorm-2004
573  $chars = $this->getCharacteristics(); // scorm-2004
574  $options = array_merge(array("" => $this->lng->txt("none")), $chars); // scorm-2004
575  foreach($options as $k => $option)
576  {
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);
580  }
581 
582  $style->setValue("");
583  $style->setInfo($lng->txt("cont_set_tab_style_info"));
584  $form->addItem($style);
585  $form->setKeepOpen(true);
586 
587  $form->addCommandButton("setStyles", $lng->txt("cont_set_styles"));
588 
589  $html = $form->getHTML();
590  $html.= "<br />".$this->renderTable("table_edit", "style")."</form>";
591  $tpl->setContent($html);
592 
593  }
594 
598  function editCellWidth()
599  {
600  global $ilCtrl, $tpl, $lng, $ilTabs;
601 
602  $this->displayValidationError();
603  $this->setTabs();
604  $this->setCellPropertiesSubTabs();
605  $ilTabs->setSubTabActive("cont_width");
606  $ilTabs->setTabActive("cont_table_cell_properties");
607 
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));
612 
613  $html = $ctpl->get();
614  $html.= "<br />".$this->renderTable("table_edit", "width")."</form>";
615  $tpl->setContent($html);
616 
617  }
618 
622  function editCellSpan()
623  {
624  global $ilCtrl, $tpl, $lng, $ilTabs;
625 
626  $this->displayValidationError();
627  $this->setTabs();
628  $this->setCellPropertiesSubTabs();
629  $ilTabs->setSubTabActive("cont_span");
630  $ilTabs->setTabActive("cont_table_cell_properties");
631 
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));
636 
637  $html = $ctpl->get();
638  $html.= "<br />".$this->renderTable("table_edit", "span")."</form>";
639  $tpl->setContent($html);
640 
641  }
642 
646  function setStyles()
647  {
648  global $lng;
649 
650  if (is_array($_POST["target"]))
651  {
652  foreach ($_POST["target"] as $k => $value)
653  {
654  if ($value > 0)
655  {
656  $cid = explode(":", $k);
657  $this->content_obj->setTDClass(ilUtil::stripSlashes($cid[0]),
659  }
660  }
661  }
662  $this->updated = $this->pg_obj->update();
663  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
664  $this->ctrl->redirect($this, "editCellStyle");
665  }
666 
670  function setWidths()
671  {
672  global $lng;
673 
674  if (is_array($_POST["width"]))
675  {
676  foreach ($_POST["width"] as $k => $width)
677  {
678  $cid = explode(":", $k);
679  $this->content_obj->setTDWidth(ilUtil::stripSlashes($cid[0]),
681  }
682  }
683  $this->updated = $this->pg_obj->update();
684  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
685  $this->ctrl->redirect($this, "editCellWidth");
686  }
687 
691  function setSpans()
692  {
693  global $lng;
694 
695  if (is_array($_POST["colspan"]))
696  {
697  foreach ($_POST["colspan"] as $k => $span)
698  {
699  $_POST["colspan"][$k] = ilUtil::stripSlashes($span);
700  $_POST["rowspan"][$k] = ilUtil::stripSlashes($_POST["rowspan"][$k]);
701  }
702  $this->content_obj->setTDSpans($_POST["colspan"], $_POST["rowspan"]);
703  }
704  $this->updated = $this->pg_obj->update();
705  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
706  $this->ctrl->redirect($this, "editCellSpan");
707  }
708 
712  function setProperties()
713  {
714  // mask html
715  $caption = ilUtil::stripSlashes($_POST["caption"]);
716  $caption = str_replace("&","&amp;", $caption);
717  $caption = str_replace("<","&lt;", $caption);
718  $caption = str_replace(">","&gt;", $caption);
719 
720  $this->content_obj->setLanguage(ilUtil::stripSlashes($_POST["language"]));
721  $this->content_obj->setWidth(ilUtil::stripSlashes($_POST["width"]));
722  $this->content_obj->setBorder(ilUtil::stripSlashes($_POST["border"]));
723  $this->content_obj->setCellSpacing(ilUtil::stripSlashes($_POST["spacing"]));
724  $this->content_obj->setCellPadding(ilUtil::stripSlashes($_POST["padding"]));
725  $this->content_obj->setHorizontalAlign(ilUtil::stripSlashes($_POST["align"]));
726  $this->content_obj->setHeaderRows(ilUtil::stripSlashes($_POST["row_header"]));
727  $this->content_obj->setHeaderCols(ilUtil::stripSlashes($_POST["col_header"]));
728  $this->content_obj->setFooterRows(ilUtil::stripSlashes($_POST["row_footer"]));
729  $this->content_obj->setFooterCols(ilUtil::stripSlashes($_POST["col_footer"]));
730  if (strpos($_POST["characteristic"], ":") > 0)
731  {
732  $t = explode(":", $_POST["characteristic"]);
733  $this->content_obj->setTemplate(ilUtil::stripSlashes($t[2]));
734  $this->content_obj->setClass("");
735  }
736  else
737  {
738  $this->content_obj->setClass(ilUtil::stripSlashes($_POST["characteristic"]));
739  $this->content_obj->setTemplate("");
740  }
741  $this->content_obj->setCaption($caption,
742  ilUtil::stripSlashes($_POST["cap_align"]));
743  }
744 
748  function saveProperties()
749  {
750  $this->setProperties();
751  $this->updated = $this->pg_obj->update();
752  if ($this->updated === true)
753  {
754  $this->ctrl->redirect($this, "edit");
755  //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
756  }
757  else
758  {
759  $this->pg_obj->addHierIDs();
760  $this->edit();
761  }
762  }
763 
767  function rightAlign()
768  {
769  $this->content_obj->setHorizontalAlign("Right");
770  $_SESSION["il_pg_error"] = $this->pg_obj->update();
771  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
772  }
773 
777  function leftAlign()
778  {
779  $this->content_obj->setHorizontalAlign("Left");
780  $_SESSION["il_pg_error"] = $this->pg_obj->update();
781  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
782  }
783 
787  function centerAlign()
788  {
789  $this->content_obj->setHorizontalAlign("Center");
790  $_SESSION["il_pg_error"] = $this->pg_obj->update();
791  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
792  }
793 
797  function leftFloatAlign()
798  {
799  $this->content_obj->setHorizontalAlign("LeftFloat");
800  $_SESSION["il_pg_error"] = $this->pg_obj->update();
801  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
802  }
803 
807  function rightFloatAlign()
808  {
809  $this->content_obj->setHorizontalAlign("RightFloat");
810  $_SESSION["il_pg_error"] = $this->pg_obj->update();
811  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
812  }
813 
817  function insert()
818  {
819  global $ilUser, $ilCtrl, $tpl, $lng;
820 
821  $this->displayValidationError();
822 
823  $this->initPropertiesForm("create");
824  $html = $this->form->getHTML();
825  $tpl->setContent($html);
826  }
827 
831  function getNewTableObject()
832  {
833  return new ilPCTable($this->dom);
834  }
835 
839  function create()
840  {
841  global $lng;
842 
843  $this->content_obj = $this->getNewTableObject();
844  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
845  $import_table = trim($_POST["import_table"]);
846 
847  // import xhtml or spreadsheet table
848  if (!empty ($import_table))
849  {
850  switch($_POST["import_type"])
851  {
852  // xhtml import
853  case "html":
854  if (!$this->content_obj->importHtml ($_POST["language"], $import_table))
855  {
856  $this->insert();
857  return;
858  }
859  break;
860 
861  // spreadsheet
862  case "spreadsheet":
863  $this->content_obj->importSpreadsheet($_POST["language"], $import_table);
864  break;
865  }
866  }
867  else
868  {
869  $this->content_obj->addRows(ilUtil::stripSlashes($_POST["nr_rows"]),
870  ilUtil::stripSlashes($_POST["nr_cols"]));
871  }
872 
873  $this->setProperties();
874 
875  $frtype = ilUtil::stripSlashes($_POST["first_row_style"]);
876  if ($frtype != "")
877  {
878  $this->content_obj->setFirstRowStyle($frtype);
879  }
880 
881  $this->updated = $this->pg_obj->update();
882 
883  if ($this->updated === true)
884  {
885  $this->afterCreation();
886  }
887  else
888  {
889  $this->insert();
890  }
891  }
892 
896  function afterCreation()
897  {
898  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
899  }
900 
901 }
902 ?>