ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules 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_alignment",
100  $ilCtrl->getLinkTarget($this, "editCellAlignment"), "editCellAlignment",
101  get_class($this));
102 
103  $ilTabs->addSubTabTarget("cont_span",
104  $ilCtrl->getLinkTarget($this, "editCellSpan"), "editCellSpan",
105  get_class($this));
106 
107  }
108 
113  {
114  return parent::getTemplateOptions("table");
115  }
116 
120  function edit()
121  {
122  global $ilCtrl, $lng, $tpl;
123 
124  $this->displayValidationError();
125  $this->setTabs();
126 
127  $this->initPropertiesForm();
128  $this->getPropertiesFormValues();
129  $html = $this->form->getHTML();
130  $html.= "<br />".$this->renderTable("");
131  $tpl->setContent($html);
132  }
133 
137  function initPropertiesForm($a_mode = "edit")
138  {
139  global $ilCtrl, $lng, $tpl, $ilUser;
140 
141  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
142  $this->form = new ilPropertyFormGUI();
143  $this->form->setFormAction($ilCtrl->getFormAction($this));
144  if ($a_mode == "create")
145  {
146  $this->form->setTitle($this->lng->txt("cont_insert_table"));
147  }
148  else
149  {
150  $this->form->setTitle($this->lng->txt("cont_table_properties"));
151  }
152 
153  if ($a_mode == "create")
154  {
155  $nr = array();
156  for($i=1; $i<=20; $i++)
157  {
158  $nr[$i] = $i;
159  }
160 
161  // cols
162  $cols = new ilSelectInputGUI($this->lng->txt("cont_nr_cols"), "nr_cols");
163  $cols->setOptions($nr);
164  $cols->setValue(2);
165  $this->form->addItem($cols);
166 
167  // rows
168  $rows = new ilSelectInputGUI($this->lng->txt("cont_nr_rows"), "nr_rows");
169  $rows->setOptions($nr);
170  $rows->setValue(2);
171  $this->form->addItem($rows);
172  }
173 
174  // width
175  $width = new ilTextInputGUI($this->lng->txt("cont_table_width"), "width");
176  $width->setSize(6);
177  $width->setMaxLength(6);
178  $this->form->addItem($width);
179 
180  // border
181  $border = new ilTextInputGUI($this->lng->txt("cont_table_border"), "border");
182  $border->setInfo($this->lng->txt("cont_table_border_info"));
183  $border->setValue("1px");
184  $border->setSize(6);
185  $border->setMaxLength(6);
186  $this->form->addItem($border);
187 
188  // padding
189  $padding = new ilTextInputGUI($this->lng->txt("cont_table_cellpadding"), "padding");
190  $padding->setInfo($this->lng->txt("cont_table_cellpadding_info"));
191  $padding->setValue("2px");
192  $padding->setSize(6);
193  $padding->setMaxLength(6);
194  $this->form->addItem($padding);
195 
196  // spacing (deprecated, only hidden)
197  $spacing = new ilHiddenInputGUI("spacing");
198  $spacing->setValue("0px");
199  $this->form->addItem($spacing);
200  /*$spacing = new ilTextInputGUI($this->lng->txt("cont_table_cellspacing"), "spacing");
201  $spacing->setValue("0px");
202  $spacing->setSize(6);
203  $spacing->setMaxLength(6);
204  $this->form->addItem($spacing);*/
205 
206  // table templates and table classes
207  require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
208  $char_prop = new ilAdvSelectInputGUI($this->lng->txt("cont_characteristic"),
209  "characteristic");
210  $chars = $this->getCharacteristics();
211  $templates = $this->getTemplateOptions();
212  $chars = array_merge($templates, $chars);
213  if (is_object($this->content_obj))
214  {
215  if ($chars[$a_seleted_value] == "" && ($this->content_obj->getClass() != ""))
216  {
217  $chars = array_merge(
218  array($this->content_obj->getClass() => $this->content_obj->getClass()),
219  $chars);
220  }
221  }
222  foreach($chars as $k => $char)
223  {
224  if (strpos($k, ":") > 0)
225  {
226  $t = explode(":", $k);
227  $html = $this->style->lookupTemplatePreview($t[1]).'<div style="clear:both;" class="small">'.$char."</div>";
228  }
229  else
230  {
231  $html = '<table class="ilc_table_'.$k.'"><tr><td class="small">'.
232  $char.'</td></tr></table>';
233  }
234  $char_prop->addOption($k, $char, $html);
235  }
236  $char_prop->setValue("StandardTable");
237  $this->form->addItem($char_prop);
238 
239  $nr = array();
240  for($i=0; $i<=3; $i++)
241  {
242  $nr[$i] = $i;
243  }
244 
245  // row header
246  $rh = new ilSelectInputGUI($this->lng->txt("cont_nr_row_header"), "row_header");
247  $rh->setOptions($nr);
248  $rh->setValue(1);
249  $this->form->addItem($rh);
250 
251  // row footer
252  $rf = new ilSelectInputGUI($this->lng->txt("cont_nr_row_footer"), "row_footer");
253  $rf->setOptions($nr);
254  $rf->setValue(0);
255  $this->form->addItem($rf);
256 
257  // col header
258  $ch = new ilSelectInputGUI($this->lng->txt("cont_nr_col_header"), "col_header");
259  $ch->setOptions($nr);
260  $ch->setValue(0);
261  $this->form->addItem($ch);
262 
263  // col footer
264  $cf = new ilSelectInputGUI($this->lng->txt("cont_nr_col_footer"), "col_footer");
265  $cf->setOptions($nr);
266  $cf->setValue(0);
267  $this->form->addItem($cf);
268 
269  if ($a_mode == "create")
270  {
271  // first row style
272  require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
273  $fr_style = new ilAdvSelectInputGUI($this->lng->txt("cont_first_row_style"),
274  "first_row_style");
275  $this->setBasicTableCellStyles();
276  $this->getCharacteristicsOfCurrentStyle("table_cell");
277  $chars = $this->getCharacteristics();
278  $options = array_merge(array("" => $this->lng->txt("none")), $chars);
279  foreach($options as $k => $option)
280  {
281  $html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_'.$k.'">'.
282  $option.'</td></tr></table>';
283  $fr_style->addOption($k, $option, $html);
284  }
285 
286  $fr_style->setValue("");
287  $this->form->addItem($fr_style);
288  }
289 
290  // alignment
291  $align_opts = array("Left" => $lng->txt("cont_left"),
292  "Right" => $lng->txt("cont_right"), "Center" => $lng->txt("cont_center"),
293  "LeftFloat" => $lng->txt("cont_left_float"),
294  "RightFloat" => $lng->txt("cont_right_float"));
295  $align = new ilSelectInputGUI($this->lng->txt("cont_align"), "align");
296  $align->setOptions($align_opts);
297  $align->setValue("Center");
298  $this->form->addItem($align);
299 
300  // caption
301  $caption = new ilTextInputGUI($this->lng->txt("cont_caption"), "caption");
302  $caption->setSize(60);
303  $this->form->addItem($caption);
304 
305  // caption align
306  $ca_opts = array("top" => $lng->txt("cont_top"),
307  "bottom" => $lng->txt("cont_bottom"));
308  $ca = new ilSelectInputGUI($this->lng->txt("cont_align"),
309  "cap_align");
310  $ca->setOptions($ca_opts);
311  $caption->addSubItem($ca);
312 
313  // import
314  if ($a_mode == "create")
315  {
316  // import table
317  $import = new ilRadioGroupInputGUI($this->lng->txt("cont_paste_table"), "import_type");
318  $op = new ilRadioOption($this->lng->txt("cont_html_table"), "html");
319  $import->addOption($op);
320  $op2 = new ilRadioOption($this->lng->txt("cont_spreadsheet_table"), "spreadsheet");
321 
322  $import_data = new ilTextAreaInputGUI("", "import_table");
323  $import_data->setRows(8);
324  $import_data->setCols(50);
325  $op2->addSubItem($import_data);
326 
327  $import->addOption($op2);
328  $import->setValue("html");
329  $this->form->addItem($import);
330  }
331 
332  // language
333  if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
334  {
335  $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
336  }
337  else
338  {
339  $s_lang = $ilUser->getLanguage();
340  }
341  require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
343  $language = new ilSelectInputGUI($this->lng->txt("language"), "language");
344  $language->setOptions($lang);
345  $language->setValue($s_lang);
346  $this->form->addItem($language);
347 
348  if ($a_mode == "create")
349  {
350  $this->form->addCommandButton("create_tab", $lng->txt("save"));
351  $this->form->addCommandButton("cancelCreate", $lng->txt("cancel"));
352  }
353  else
354  {
355  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
356  }
357  }
358 
363  {
364  $values = array();
365  $values["width"] = $this->content_obj->getWidth();
366  $values["border"] = $this->content_obj->getBorder();
367  $values["padding"] = $this->content_obj->getCellPadding();
368  $values["spacing"] = $this->content_obj->getCellSpacing();
369  $values["row_header"] = $this->content_obj->getHeaderRows();
370  $values["row_footer"] = $this->content_obj->getFooterRows();
371  $values["col_header"] = $this->content_obj->getHeaderCols();
372  $values["col_footer"] = $this->content_obj->getFooterCols();
373  if ($this->content_obj->getTemplate() != "")
374  {
375  $values["characteristic"] = "t:".
376  ilObjStyleSheet::_lookupTemplateIdByName($this->getStyleId(), $this->content_obj->getTemplate()).":".
377  $this->content_obj->getTemplate();
378  }
379  else
380  {
381  $values["characteristic"] = $this->content_obj->getClass();
382  }
383  $values["align"] = $this->content_obj->getHorizontalAlign();
384  $values["caption"] = $this->content_obj->getCaption();
385  $values["cap_align"] = $this->content_obj->getCaptionAlign();
386  $values["language"] = $this->content_obj->getLanguage();
387 
388  $this->form->setValuesByArray($values);
389 
390  $ca = $this->form->getItemByPostVar("cap_align");
391  $ca->setValue($this->content_obj->getCaptionAlign());
392  }
393 
397  function renderTable($a_mode = "table_edit", $a_submode = "")
398  {
399  $tab_node = $this->content_obj->getNode();
400  $tab_node->set_attribute("Enabled", "True");
401  $content = $this->dom->dump_node($tab_node);
402 
403  $trans = $this->pg_obj->getLanguageVariablesXML();
404  $mobs = $this->pg_obj->getMultimediaXML();
405  if ($this->getStyleId() > 0)
406  {
407  if (ilObject::_lookupType($this->getStyleId()) == "sty")
408  {
409  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
410  $style = new ilObjStyleSheet($this->getStyleId());
411  $template_xml = $style->getTemplateXML();
412  }
413  }
414 
415  $content = $content.$mobs.$trans.$template_xml;
416 
417  return ilPCTableGUI::_renderTable($content, $a_mode, $a_submode, $this->content_obj);
418  }
419 
423  static function _renderTable($content, $a_mode = "table_edit", $a_submode = "", $a_table_obj = null)
424  {
425  global $ilUser;
426 
427  $content = "<dummy>".$content."</dummy>";
428 
429  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
430  $args = array( '/_xml' => $content, '/_xsl' => $xsl );
431  $xh = xslt_create();
432 //echo "<b>XML</b>:".htmlentities($content).":<br>";
433 //echo "<b>XSLT</b>:".htmlentities($xsl).":<br>";
434  $wb_path = ilUtil::getWebspaceDir("output");
435  $enlarge_path = ilUtil::getImagePath("enlarge.svg");
436  $params = array ('mode' => $a_mode,
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);
441  echo xslt_error($xh);
442  xslt_free($xh);
443 
444  // unmask user html
445  $output = str_replace("&lt;","<",$output);
446  $output = str_replace("&gt;",">",$output);
447  $output = str_replace("&amp;","&",$output);
448 
449  if ($a_mode == "table_edit" && !is_null($a_table_obj))
450  {
451  switch ($a_submode)
452  {
453  case "style":
454  $output = ilPCTableGUI::_addStyleCheckboxes($output, $a_table_obj);
455  break;
456 
457  case "alignment":
458  $output = ilPCTableGUI::_addAlignmentCheckboxes($output, $a_table_obj);
459  break;
460 
461  case "width":
462  $output = ilPCTableGUI::_addWidthInputs($output, $a_table_obj);
463  break;
464 
465  case "span":
466  $output = ilPCTableGUI::_addSpanInputs($output, $a_table_obj);
467  break;
468  }
469  }
470 
471 
472  return '<div class="ilFloatLeft">'.$output.'</div>';
473  }
474 
478  static function _addStyleCheckboxes($a_output, $a_table)
479  {
480  global $lng;
481 
482  $classes = $a_table->getAllCellClasses();
483 
484  foreach ($classes as $k => $v)
485  {
486  if ($v == "")
487  {
488  $v = $lng->txt("none");
489  }
490  if (substr($v, 0, 4) == "ilc_")
491  {
492  $v = substr($v, 4);
493  }
494  $check = $lng->txt("cont_style").": ".
495  '<input type="checkbox" value="1"'.
496  ' name="target['.$k.']">'.'</input> '.$v;
497 
498  $a_output = str_replace("{{{{{TableEdit;".$k."}}}}}", $check, $a_output);
499  }
500  return $a_output;
501  }
502 
506  static function _addAlignmentCheckboxes($a_output, $a_table)
507  {
508  global $lng;
509 
510  $classes = $a_table->getAllCellAlignments();
511 
512  foreach ($classes as $k => $v)
513  {
514  if ($v == "")
515  {
516  $v = $lng->txt("default");
517  }
518  $check = $lng->txt("cont_alignment").": ".
519  '<input type="checkbox" value="1"'.
520  ' name="target['.$k.']">'.'</input> '.$v;
521 
522  $a_output = str_replace("{{{{{TableEdit;".$k."}}}}}", $check, $a_output);
523  }
524  return $a_output;
525  }
526 
530  static function _addWidthInputs($a_output, $a_table)
531  {
532  global $lng;
533 
534  $widths = $a_table->getAllCellWidths();
535 
536  foreach ($widths as $k => $v)
537  {
538  $check = $lng->txt("cont_width").": ".
539  '<input class="small" type="text" size="5" maxlength="10"'.
540  ' name="width['.$k.']" value="'.$v.'">'.'</input>';
541 
542  $a_output = str_replace("{{{{{TableEdit;".$k."}}}}}", $check, $a_output);
543  }
544  return $a_output;
545  }
546 
550  static function _addSpanInputs($a_output, $a_table)
551  {
552  global $lng;
553 
554  $spans = $a_table->getAllCellSpans();
555 
556  foreach ($spans as $k => $v)
557  {
558  // colspans
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++)
562  {
563  $sel_str = ($i == $v["colspan"])
564  ? 'selected="selected"'
565  : '';
566  $selects.= '<option value="'.$i.'" '.$sel_str.'>'.$i.'</option>';
567  }
568  $selects.= "</select></div>";
569 
570  // rowspans
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++)
574  {
575  $sel_str = ($i == $v["rowspan"])
576  ? 'selected="selected"'
577  : '';
578  $selects.= '<option value="'.$i.'" '.$sel_str.'>'.$i.'</option>';
579  }
580  $selects.= "</select></div>";
581 
582  $a_output = str_replace("{{{{{TableEdit;".$k."}}}}}", $selects, $a_output);
583  }
584  return $a_output;
585  }
586 
590  function editCellStyle()
591  {
592  global $ilCtrl, $tpl, $lng, $ilTabs;
593 
594  $this->displayValidationError();
595  $this->setTabs();
596  $this->setCellPropertiesSubTabs();
597  $ilTabs->setSubTabActive("cont_style");
598 
599  // edit form
600  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
601  $form = new ilPropertyFormGUI();
602  $form->setFormAction($ilCtrl->getFormAction($this));
603  $form->setTitle($this->lng->txt("cont_table_cell_properties"));
604 
605  // first row style
606  require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
607  $style = new ilAdvSelectInputGUI($this->lng->txt("cont_style"),
608  "style");
609  $this->setBasicTableCellStyles();
610  $this->getCharacteristicsOfCurrentStyle("table_cell"); // scorm-2004
611  $chars = $this->getCharacteristics(); // scorm-2004
612  $options = array_merge(array("" => $this->lng->txt("none")), $chars); // scorm-2004
613  foreach($options as $k => $option)
614  {
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);
618  }
619 
620  $style->setValue("");
621  $style->setInfo($lng->txt("cont_set_tab_style_info"));
622  $form->addItem($style);
623  $form->setKeepOpen(true);
624 
625  $form->addCommandButton("setStyles", $lng->txt("cont_set_styles"));
626 
627  $html = $form->getHTML();
628  $html.= "<br />".$this->renderTable("table_edit", "style")."</form>";
629  $tpl->setContent($html);
630 
631  }
632 
636  function editCellWidth()
637  {
638  global $ilCtrl, $tpl, $lng, $ilTabs;
639 
640  $this->displayValidationError();
641  $this->setTabs();
642  $this->setCellPropertiesSubTabs();
643  $ilTabs->setSubTabActive("cont_width");
644  $ilTabs->setTabActive("cont_table_cell_properties");
645 
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));
650 
651  $html = $ctpl->get();
652  $html.= "<br />".$this->renderTable("table_edit", "width")."</form>";
653  $tpl->setContent($html);
654 
655  }
656 
660  function editCellSpan()
661  {
662  global $ilCtrl, $tpl, $lng, $ilTabs;
663 
664  $this->displayValidationError();
665  $this->setTabs();
666  $this->setCellPropertiesSubTabs();
667  $ilTabs->setSubTabActive("cont_span");
668  $ilTabs->setTabActive("cont_table_cell_properties");
669 
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));
674 
675  $html = $ctpl->get();
676  $html.= "<br />".$this->renderTable("table_edit", "span")."</form>";
677  $tpl->setContent($html);
678 
679  }
680 
684  function setStyles()
685  {
686  global $lng;
687 
688  if (is_array($_POST["target"]))
689  {
690  foreach ($_POST["target"] as $k => $value)
691  {
692  if ($value > 0)
693  {
694  $cid = explode(":", $k);
695  $this->content_obj->setTDClass(ilUtil::stripSlashes($cid[0]),
696  ilUtil::stripSlashes($_POST["style"]), ilUtil::stripSlashes($cid[1]));
697  }
698  }
699  }
700  $this->updated = $this->pg_obj->update();
701  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
702  $this->ctrl->redirect($this, "editCellStyle");
703  }
704 
708  function setWidths()
709  {
710  global $lng;
711 
712  if (is_array($_POST["width"]))
713  {
714  foreach ($_POST["width"] as $k => $width)
715  {
716  $cid = explode(":", $k);
717  $this->content_obj->setTDWidth(ilUtil::stripSlashes($cid[0]),
718  ilUtil::stripSlashes($width), ilUtil::stripSlashes($cid[1]));
719  }
720  }
721  $this->updated = $this->pg_obj->update();
722  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
723  $this->ctrl->redirect($this, "editCellWidth");
724  }
725 
729  function setSpans()
730  {
731  global $lng;
732 
733  if (is_array($_POST["colspan"]))
734  {
735  foreach ($_POST["colspan"] as $k => $span)
736  {
737  $_POST["colspan"][$k] = ilUtil::stripSlashes($span);
738  $_POST["rowspan"][$k] = ilUtil::stripSlashes($_POST["rowspan"][$k]);
739  }
740  $this->content_obj->setTDSpans($_POST["colspan"], $_POST["rowspan"]);
741  }
742  $this->updated = $this->pg_obj->update();
743  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
744  $this->ctrl->redirect($this, "editCellSpan");
745  }
746 
750  function setProperties()
751  {
752  // mask html
753  $caption = ilUtil::stripSlashes($_POST["caption"]);
754  $caption = str_replace("&","&amp;", $caption);
755  $caption = str_replace("<","&lt;", $caption);
756  $caption = str_replace(">","&gt;", $caption);
757 
758  $this->content_obj->setLanguage(ilUtil::stripSlashes($_POST["language"]));
759  $this->content_obj->setWidth(ilUtil::stripSlashes($_POST["width"]));
760  $this->content_obj->setBorder(ilUtil::stripSlashes($_POST["border"]));
761  $this->content_obj->setCellSpacing(ilUtil::stripSlashes($_POST["spacing"]));
762  $this->content_obj->setCellPadding(ilUtil::stripSlashes($_POST["padding"]));
763  $this->content_obj->setHorizontalAlign(ilUtil::stripSlashes($_POST["align"]));
764  $this->content_obj->setHeaderRows(ilUtil::stripSlashes($_POST["row_header"]));
765  $this->content_obj->setHeaderCols(ilUtil::stripSlashes($_POST["col_header"]));
766  $this->content_obj->setFooterRows(ilUtil::stripSlashes($_POST["row_footer"]));
767  $this->content_obj->setFooterCols(ilUtil::stripSlashes($_POST["col_footer"]));
768  if (strpos($_POST["characteristic"], ":") > 0)
769  {
770  $t = explode(":", $_POST["characteristic"]);
771  $this->content_obj->setTemplate(ilUtil::stripSlashes($t[2]));
772  $this->content_obj->setClass("");
773  }
774  else
775  {
776  $this->content_obj->setClass(ilUtil::stripSlashes($_POST["characteristic"]));
777  $this->content_obj->setTemplate("");
778  }
779  $this->content_obj->setCaption($caption,
780  ilUtil::stripSlashes($_POST["cap_align"]));
781  }
782 
786  function saveProperties()
787  {
788  $this->setProperties();
789  $this->updated = $this->pg_obj->update();
790  if ($this->updated === true)
791  {
792  $this->ctrl->redirect($this, "edit");
793  //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
794  }
795  else
796  {
797  $this->pg_obj->addHierIDs();
798  $this->edit();
799  }
800  }
801 
805  function rightAlign()
806  {
807  $this->content_obj->setHorizontalAlign("Right");
808  $_SESSION["il_pg_error"] = $this->pg_obj->update();
809  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
810  }
811 
815  function leftAlign()
816  {
817  $this->content_obj->setHorizontalAlign("Left");
818  $_SESSION["il_pg_error"] = $this->pg_obj->update();
819  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
820  }
821 
825  function centerAlign()
826  {
827  $this->content_obj->setHorizontalAlign("Center");
828  $_SESSION["il_pg_error"] = $this->pg_obj->update();
829  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
830  }
831 
835  function leftFloatAlign()
836  {
837  $this->content_obj->setHorizontalAlign("LeftFloat");
838  $_SESSION["il_pg_error"] = $this->pg_obj->update();
839  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
840  }
841 
845  function rightFloatAlign()
846  {
847  $this->content_obj->setHorizontalAlign("RightFloat");
848  $_SESSION["il_pg_error"] = $this->pg_obj->update();
849  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
850  }
851 
855  function insert()
856  {
857  global $ilUser, $ilCtrl, $tpl, $lng;
858 
859  $this->displayValidationError();
860 
861  $this->initPropertiesForm("create");
862  $html = $this->form->getHTML();
863  $tpl->setContent($html);
864  }
865 
869  function getNewTableObject()
870  {
871  return new ilPCTable($this->getPage());
872  }
873 
877  function create()
878  {
879  global $lng;
880 
881  $this->content_obj = $this->getNewTableObject();
882  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
883  $import_table = trim($_POST["import_table"]);
884 
885  // import xhtml or spreadsheet table
886  if (!empty ($import_table))
887  {
888  switch($_POST["import_type"])
889  {
890  // xhtml import
891  case "html":
892  if (!$this->content_obj->importHtml ($_POST["language"], $import_table))
893  {
894  $this->insert();
895  return;
896  }
897  break;
898 
899  // spreadsheet
900  case "spreadsheet":
901  $this->content_obj->importSpreadsheet($_POST["language"], $import_table);
902  break;
903  }
904  }
905  else
906  {
907  $this->content_obj->addRows(ilUtil::stripSlashes($_POST["nr_rows"]),
908  ilUtil::stripSlashes($_POST["nr_cols"]));
909  }
910 
911  $this->setProperties();
912 
913  $frtype = ilUtil::stripSlashes($_POST["first_row_style"]);
914  if ($frtype != "")
915  {
916  $this->content_obj->setFirstRowStyle($frtype);
917  }
918 
919  $this->updated = $this->pg_obj->update();
920 
921  if ($this->updated === true)
922  {
923  $this->afterCreation();
924  }
925  else
926  {
927  $this->insert();
928  }
929  }
930 
934  function afterCreation()
935  {
936  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
937  }
938 
939 
940  //
941  // Edit cell alignments
942  //
943 
947  function editCellAlignment()
948  {
949  global $ilCtrl, $tpl, $lng, $ilTabs;
950 
951  $this->displayValidationError();
952  $this->setTabs();
953  $this->setCellPropertiesSubTabs();
954  $ilTabs->setSubTabActive("cont_alignment");
955  $ilTabs->setTabActive("cont_table_cell_properties");
956 
957  // edit form
958  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
959  $form = new ilPropertyFormGUI();
960  $form->setFormAction($ilCtrl->getFormAction($this));
961  $form->setTitle($this->lng->txt("cont_table_cell_properties"));
962 
963  // alignment
964  $options = array(
965  "" => $lng->txt("default"),
966  "Left" => $lng->txt("cont_left"),
967  "Center" => $lng->txt("cont_center"),
968  "Right" => $lng->txt("cont_right")
969  );
970  $si = new ilSelectInputGUI($lng->txt("cont_alignment"), "alignment");
971  $si->setOptions($options);
972  $si->setInfo($lng->txt(""));
973  $form->addItem($si);
974 
975  $form->setKeepOpen(true);
976 
977  $form->addCommandButton("setAlignment", $lng->txt("cont_set_alignment"));
978 
979  $html = $form->getHTML();
980  $html.= "<br />".$this->renderTable("table_edit", "alignment")."</form>";
981  $tpl->setContent($html);
982 
983  }
984 
988  function setAlignment()
989  {
990  global $lng;
991 
992  if (is_array($_POST["target"]))
993  {
994  foreach ($_POST["target"] as $k => $value)
995  {
996  if ($value > 0)
997  {
998  $cid = explode(":", $k);
999  $this->content_obj->setTDAlignment(ilUtil::stripSlashes($cid[0]),
1000  ilUtil::stripSlashes($_POST["alignment"]), ilUtil::stripSlashes($cid[1]));
1001  }
1002  }
1003  }
1004  $this->updated = $this->pg_obj->update();
1005  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1006 
1007  $this->ctrl->redirect($this, "editCellAlignment");
1008  }
1009 
1010 
1011 }
1012 ?>
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
edit()
edit properties form
xslt_create()
static _lookupTemplateIdByName($a_style_id, $a_name)
Lookup table template preview.
This class represents an option in a radio group.
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
getNewTableObject()
Get new table object.
initPropertiesForm($a_mode="edit")
Init properties form.
$_POST['username']
Definition: cron.php:12
& executeCommand()
execute command
setAlignment()
Set cell alignments.
leftFloatAlign()
align table to left float
This class represents a selection list property in a property form.
This class represents a property form user interface.
Class ilPCTable.
$_GET["client_id"]
static _addSpanInputs($a_output, $a_table)
Add span inputs.
setCellPropertiesSubTabs()
Set tabs.
xslt_free(&$proc)
static _addWidthInputs($a_output, $a_table)
Add width inputs.
$cmd
Definition: sahs_server.php:35
editCellSpan()
Edit cell spans.
setStyles()
Set cell styles and.
editCellWidth()
Edit cell widths.
create()
create new table in dom and update page in db
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
setTabs()
Set tabs.
xslt_error(&$proc)
setCharacteristics($a_chars)
Set Characteristics.
getTemplateOptions()
Get table templates.
This class represents a hidden form property in a property form.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
ilPCTableGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor public.
This class represents a property in a property form.
if(!is_array($argv)) $options
$mobs
addSubItem($a_item)
Add Subitem.
setBasicTableCellStyles()
Set basic table cell styles.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
rightAlign()
align table to right
setSize($a_size)
Set Size.
displayValidationError()
display validation errors
This class represents a text property in a property form.
getStyleId()
Get Style Id.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Class ilPCTableGUI.
setOptions($a_options)
Set Options.
insert()
insert new table form
getCharacteristics()
Get characteristics.
static _lookupType($a_id, $a_reference=false)
lookup object type
saveProperties()
save table properties in db and return to page edit screen
static _addStyleCheckboxes($a_output, $a_table)
Add style checkboxes in edit mode.
renderTable($a_mode="table_edit", $a_submode="")
Render the table.
centerAlign()
align table to left
global $ilUser
Definition: imgupload.php:15
static _renderTable($content, $a_mode="table_edit", $a_submode="", $a_table_obj=null)
Static render table function.
This class represents a text area property in a property form.
static _addAlignmentCheckboxes($a_output, $a_table)
Add alignment checkboxes in edit mode.
Class ilObjStyleSheet.
rightFloatAlign()
align table to left
leftAlign()
align table to left
setProperties()
Set properties from input form.
editCellStyle()
Edit cell styles.
This class represents an advanced selection list property in a property form.
static getWebspaceDir($mode="filesystem")
get webspace directory
afterCreation()
After creation processing.
setWidths()
Set cell widths.
getPropertiesFormValues()
Get properties form.
setSpans()
Set cell spans.
editCellAlignment()
Edit cell styles.