4require_once(
"./Services/COPage/classes/class.ilPCTable.php");
5require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
24 function ilPCTableGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id =
"")
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")));
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",
114 return parent::getTemplateOptions(
"table");
129 $html = $this->form->getHTML();
130 $html.=
"<br />".$this->renderTable(
"");
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++)
163 $cols->setOptions($nr);
165 $this->form->addItem($cols);
169 $rows->setOptions($nr);
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);
182 $border->setInfo($this->lng->txt(
"cont_table_border_info"));
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);
198 $spacing->setValue(
"0px");
199 $this->form->addItem($spacing);
207 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
212 $chars = array_merge($templates, $chars);
213 if (is_object($this->content_obj))
215 if ($chars[$a_seleted_value] ==
"" && ($this->content_obj->getClass() !=
""))
217 $chars = array_merge(
218 array($this->content_obj->getClass() => $this->content_obj->getClass()),
222 foreach($chars as $k => $char)
224 if (strpos($k,
":") > 0)
226 $t = explode(
":", $k);
227 $html = $this->style->lookupTemplatePreview(
$t[1]).
'<div style="clear:both;" class="small">'.$char.
"</div>";
231 $html =
'<table class="ilc_table_'.$k.
'"><tr><td class="small">'.
232 $char.
'</td></tr></table>';
234 $char_prop->addOption($k, $char,
$html);
236 $char_prop->setValue(
"StandardTable");
237 $this->form->addItem($char_prop);
240 for($i=0; $i<=3; $i++)
246 $rh =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_header"),
"row_header");
247 $rh->setOptions($nr);
249 $this->form->addItem($rh);
252 $rf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_footer"),
"row_footer");
253 $rf->setOptions($nr);
255 $this->form->addItem($rf);
258 $ch =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_header"),
"col_header");
259 $ch->setOptions($nr);
261 $this->form->addItem($ch);
264 $cf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_footer"),
"col_footer");
265 $cf->setOptions($nr);
267 $this->form->addItem($cf);
269 if ($a_mode ==
"create")
272 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
278 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
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);
286 $fr_style->setValue(
"");
287 $this->form->addItem($fr_style);
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"));
296 $align->setOptions($align_opts);
297 $align->setValue(
"Center");
298 $this->form->addItem($align);
301 $caption =
new ilTextInputGUI($this->lng->txt(
"cont_caption"),
"caption");
302 $caption->setSize(60);
303 $this->form->addItem($caption);
306 $ca_opts = array(
"top" =>
$lng->txt(
"cont_top"),
307 "bottom" =>
$lng->txt(
"cont_bottom"));
310 $ca->setOptions($ca_opts);
311 $caption->addSubItem($ca);
314 if ($a_mode ==
"create")
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");
323 $import_data->setRows(8);
324 $import_data->setCols(50);
325 $op2->addSubItem($import_data);
327 $import->addOption($op2);
328 $import->setValue(
"html");
329 $this->form->addItem($import);
335 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
339 $s_lang =
$ilUser->getLanguage();
341 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
344 $language->setOptions(
$lang);
345 $language->setValue($s_lang);
346 $this->form->addItem($language);
348 if ($a_mode ==
"create")
350 $this->form->addCommandButton(
"create_tab",
$lng->txt(
"save"));
351 $this->form->addCommandButton(
"cancelCreate",
$lng->txt(
"cancel"));
355 $this->form->addCommandButton(
"saveProperties",
$lng->txt(
"save"));
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() !=
"")
375 $values[
"characteristic"] =
"t:".
377 $this->content_obj->getTemplate();
381 $values[
"characteristic"] = $this->content_obj->getClass();
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();
388 $this->form->setValuesByArray($values);
390 $ca = $this->form->getItemByPostVar(
"cap_align");
391 $ca->setValue($this->content_obj->getCaptionAlign());
399 $tab_node = $this->content_obj->getNode();
400 $tab_node->set_attribute(
"Enabled",
"True");
401 $content = $this->dom->dump_node($tab_node);
403 $trans = $this->pg_obj->getLanguageVariablesXML();
404 $mobs = $this->pg_obj->getMultimediaXML();
409 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
411 $template_xml =
$style->getTemplateXML();
415 $content = $content.$mobs.$trans.$template_xml;
423 static function _renderTable($content, $a_mode =
"table_edit", $a_submode =
"", $a_table_obj =
null)
427 $content =
"<dummy>".$content.
"</dummy>";
429 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
430 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
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);
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 class="ilFloatLeft">'.$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);
615 $html =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_'.$k.
'">'.
616 $option.
'</td></tr></table>';
621 $style->setInfo(
$lng->txt(
"cont_set_tab_style_info"));
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>";
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>";
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>";
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();
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")
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>";
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");
static _lookupTemplateIdByName($a_style_id, $a_name)
Lookup table template preview.
static _lookupType($a_id, $a_reference=false)
lookup object type
create()
create new table in dom and update page in db
setStyles()
Set cell styles and.
static _renderTable($content, $a_mode="table_edit", $a_submode="", $a_table_obj=null)
Static render table function.
& executeCommand()
execute command
editCellAlignment()
Edit cell styles.
centerAlign()
align table to left
static _addAlignmentCheckboxes($a_output, $a_table)
Add alignment checkboxes in edit mode.
getTemplateOptions()
Get table templates.
renderTable($a_mode="table_edit", $a_submode="")
Render the table.
setProperties()
Set properties from input form.
editCellWidth()
Edit cell widths.
static _addWidthInputs($a_output, $a_table)
Add width inputs.
insert()
insert new table form
saveProperties()
save table properties in db and return to page edit screen
setSpans()
Set cell spans.
rightAlign()
align table to right
setWidths()
Set cell widths.
initPropertiesForm($a_mode="edit")
Init properties form.
static _addStyleCheckboxes($a_output, $a_table)
Add style checkboxes in edit mode.
getPropertiesFormValues()
Get properties form.
rightFloatAlign()
align table to left
leftFloatAlign()
align table to left float
setBasicTableCellStyles()
Set basic table cell styles.
static _addSpanInputs($a_output, $a_table)
Add span inputs.
editCellStyle()
Edit cell styles.
ilPCTableGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
leftAlign()
align table to left
setCellPropertiesSubTabs()
Set tabs.
editCellSpan()
Edit cell spans.
edit()
edit properties form
afterCreation()
After creation processing.
getNewTableObject()
Get new table object.
setAlignment()
Set cell alignments.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
displayValidationError()
display validation errors
getCharacteristics()
Get characteristics.
setCharacteristics($a_chars)
Set Characteristics.
getStyleId()
Get Style Id.
This class represents an option in a radio group.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getWebspaceDir($mode="filesystem")
get webspace directory
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
if(!is_array($argv)) $options