4require_once(
"./Services/COPage/classes/class.ilPCTable.php");
5require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
34 public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id =
"")
38 $this->tabs =
$DIC->tabs();
39 $this->ctrl =
$DIC->ctrl();
40 $this->lng =
$DIC->language();
41 $this->tpl =
$DIC[
"tpl"];
42 $this->
user = $DIC->user();
44 $this->
setCharacteristics(array(
"StandardTable" => $this->lng->txt(
"cont_StandardTable")));
53 "Cell3" =>
"Cell3",
"Cell4" =>
"Cell4"));
64 $next_class = $this->ctrl->getNextClass($this);
67 $cmd = $this->ctrl->getCmd();
69 switch ($next_class) {
88 $ilTabs->setBackTarget(
90 $this->ctrl->getParentReturn($this)
94 "cont_table_properties",
95 $ilCtrl->getLinkTarget($this,
"edit"),
101 "cont_table_cell_properties",
102 $ilCtrl->getLinkTarget($this,
"editCellStyle"),
117 $ilTabs->addSubTabTarget(
119 $ilCtrl->getLinkTarget($this,
"editCellStyle"),
124 $ilTabs->addSubTabTarget(
126 $ilCtrl->getLinkTarget($this,
"editCellWidth"),
131 $ilTabs->addSubTabTarget(
133 $ilCtrl->getLinkTarget($this,
"editCellAlignment"),
138 $ilTabs->addSubTabTarget(
140 $ilCtrl->getLinkTarget($this,
"editCellSpan"),
151 return parent::getTemplateOptions(
"table");
166 $html = $this->form->getHTML();
168 $tpl->setContent($html);
181 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
183 $this->form->setFormAction(
$ilCtrl->getFormAction($this));
184 if ($a_mode ==
"create") {
185 $this->form->setTitle($this->lng->txt(
"cont_insert_table"));
187 $this->form->setTitle($this->lng->txt(
"cont_table_properties"));
190 if ($a_mode ==
"create") {
192 for (
$i = 1;
$i <= 20;
$i++) {
198 $cols->setOptions($nr);
200 $this->form->addItem(
$cols);
204 $rows->setOptions($nr);
206 $this->form->addItem(
$rows);
210 $width =
new ilTextInputGUI($this->lng->txt(
"cont_table_width"),
"width");
212 $width->setMaxLength(6);
213 $this->form->addItem($width);
216 $border =
new ilTextInputGUI($this->lng->txt(
"cont_table_border"),
"border");
217 $border->setInfo($this->lng->txt(
"cont_table_border_info"));
218 $border->setValue(
"1px");
220 $border->setMaxLength(6);
221 $this->form->addItem($border);
224 $padding =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellpadding"),
"padding");
225 $padding->setInfo($this->lng->txt(
"cont_table_cellpadding_info"));
226 $padding->setValue(
"2px");
227 $padding->setSize(6);
228 $padding->setMaxLength(6);
229 $this->form->addItem($padding);
233 $spacing->setValue(
"0px");
234 $this->form->addItem($spacing);
242 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
244 $this->lng->txt(
"cont_characteristic"),
249 $chars = array_merge($templates, $chars);
250 if (is_object($this->content_obj)) {
251 if ($chars[$a_seleted_value] ==
"" && ($this->content_obj->getClass() !=
"")) {
252 $chars = array_merge(
253 array($this->content_obj->getClass() => $this->content_obj->getClass()),
258 foreach ($chars as $k => $char) {
259 if (strpos($k,
":") > 0) {
260 $t = explode(
":", $k);
261 $html = $this->style->lookupTemplatePreview($t[1]) .
'<div style="clear:both;" class="small">' . $char .
"</div>";
263 $html =
'<table class="ilc_table_' . $k .
'"><tr><td class="small">' .
264 $char .
'</td></tr></table>';
266 $char_prop->addOption($k, $char, $html);
268 $char_prop->setValue(
"StandardTable");
269 $this->form->addItem($char_prop);
272 for (
$i = 0;
$i <= 3;
$i++) {
277 $rh =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_header"),
"row_header");
278 $rh->setOptions($nr);
280 $this->form->addItem($rh);
283 $rf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_footer"),
"row_footer");
284 $rf->setOptions($nr);
286 $this->form->addItem($rf);
289 $ch =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_header"),
"col_header");
290 $ch->setOptions($nr);
292 $this->form->addItem($ch);
295 $cf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_footer"),
"col_footer");
296 $cf->setOptions($nr);
298 $this->form->addItem($cf);
300 if ($a_mode ==
"create") {
302 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
304 $this->lng->txt(
"cont_first_row_style"),
310 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
311 foreach ($options as $k => $option) {
312 $html =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_' . $k .
'">' .
313 $option .
'</td></tr></table>';
314 $fr_style->addOption($k, $option, $html);
317 $fr_style->setValue(
"");
318 $this->form->addItem($fr_style);
322 $align_opts = array(
"Left" =>
$lng->txt(
"cont_left"),
323 "Right" =>
$lng->txt(
"cont_right"),
"Center" =>
$lng->txt(
"cont_center"),
324 "LeftFloat" =>
$lng->txt(
"cont_left_float"),
325 "RightFloat" =>
$lng->txt(
"cont_right_float"));
327 $align->setOptions($align_opts);
328 $align->setValue(
"Center");
329 $this->form->addItem($align);
332 $caption =
new ilTextInputGUI($this->lng->txt(
"cont_caption"),
"caption");
333 $caption->setSize(60);
334 $this->form->addItem($caption);
337 $ca_opts = array(
"top" =>
$lng->txt(
"cont_top"),
338 "bottom" =>
$lng->txt(
"cont_bottom"));
340 $this->lng->txt(
"cont_align"),
343 $ca->setOptions($ca_opts);
344 $caption->addSubItem($ca);
347 if ($a_mode ==
"create") {
350 $op =
new ilRadioOption($this->lng->txt(
"cont_html_table"),
"html");
351 $import->addOption($op);
352 $op2 =
new ilRadioOption($this->lng->txt(
"cont_spreadsheet_table"),
"spreadsheet");
355 $import_data->setRows(8);
356 $import_data->setCols(50);
357 $op2->addSubItem($import_data);
359 $import->addOption($op2);
360 $import->setValue(
"html");
361 $this->form->addItem($import);
368 $s_lang =
$ilUser->getLanguage();
370 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
373 $language->setOptions(
$lang);
374 $language->setValue($s_lang);
375 $this->form->addItem($language);
377 if ($a_mode ==
"create") {
378 $this->form->addCommandButton(
"create_tab",
$lng->txt(
"save"));
379 $this->form->addCommandButton(
"cancelCreate",
$lng->txt(
"cancel"));
381 $this->form->addCommandButton(
"saveProperties",
$lng->txt(
"save"));
391 $values[
"width"] = $this->content_obj->getWidth();
392 $values[
"border"] = $this->content_obj->getBorder();
393 $values[
"padding"] = $this->content_obj->getCellPadding();
394 $values[
"spacing"] = $this->content_obj->getCellSpacing();
395 $values[
"row_header"] = $this->content_obj->getHeaderRows();
396 $values[
"row_footer"] = $this->content_obj->getFooterRows();
397 $values[
"col_header"] = $this->content_obj->getHeaderCols();
398 $values[
"col_footer"] = $this->content_obj->getFooterCols();
399 if ($this->content_obj->getTemplate() !=
"") {
400 $values[
"characteristic"] =
"t:" .
402 $this->content_obj->getTemplate();
404 $values[
"characteristic"] = $this->content_obj->getClass();
406 $values[
"align"] = $this->content_obj->getHorizontalAlign();
407 $values[
"caption"] = $this->content_obj->getCaption();
408 $values[
"cap_align"] = $this->content_obj->getCaptionAlign();
409 $values[
"language"] = $this->content_obj->getLanguage();
411 $this->form->setValuesByArray($values);
413 $ca = $this->form->getItemByPostVar(
"cap_align");
414 $ca->setValue($this->content_obj->getCaptionAlign());
420 public function renderTable($a_mode =
"table_edit", $a_submode =
"")
422 $tab_node = $this->content_obj->getNode();
423 $tab_node->set_attribute(
"Enabled",
"True");
424 $content = $this->dom->dump_node($tab_node);
426 $trans = $this->pg_obj->getLanguageVariablesXML();
427 $mobs = $this->pg_obj->getMultimediaXML();
430 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
432 $template_xml = $style->getTemplateXML();
436 $content = $content .
$mobs . $trans . $template_xml;
443 !$this->pg_obj->getPageConfig()->getPreventHTMLUnmasking(),
453 $a_mode =
"table_edit",
463 $content =
"<dummy>" . $content .
"</dummy>";
465 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
466 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
472 $params = array(
'mode' => $a_mode,
473 'media_mode' =>
$ilUser->getPref(
"ilPageEditor_MediaMode"),
474 'media_mode' =>
'disable',
475 'webspace_path' => $wb_path,
'enlarge_path' => $enlarge_path);
476 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",
null, $args, $params);
482 $output = str_replace(
"<",
"<", $output);
483 $output = str_replace(
">",
">", $output);
484 $output = str_replace(
"&",
"&", $output);
487 if ($a_mode ==
"table_edit" && !is_null($a_table_obj)) {
488 switch ($a_submode) {
508 if (isset($page_object)) {
510 foreach ($defs as $def) {
512 $pc_class = $def[
"pc_class"];
513 $pc_obj =
new $pc_class($page_object);
516 $output = $pc_obj->modifyPageContentPostXsl($output,
"presentation",
false);
533 $classes = $a_table->getAllCellClasses();
535 foreach ($classes as $k => $v) {
537 $v =
$lng->txt(
"none");
539 if (substr($v, 0, 4) ==
"ilc_") {
542 $check =
$lng->txt(
"cont_style") .
": " .
543 '<input type="checkbox" value="1"' .
544 ' name="target[' . $k .
']">' .
'</input> ' . $v;
546 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $check, $a_output);
560 $classes = $a_table->getAllCellAlignments();
562 foreach ($classes as $k => $v) {
564 $v =
$lng->txt(
"default");
566 $check =
$lng->txt(
"cont_alignment") .
": " .
567 '<input type="checkbox" value="1"' .
568 ' name="target[' . $k .
']">' .
'</input> ' . $v;
570 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $check, $a_output);
584 $widths = $a_table->getAllCellWidths();
586 foreach ($widths as $k => $v) {
587 $check =
$lng->txt(
"cont_width") .
": " .
588 '<input class="small" type="text" size="5" maxlength="10"' .
589 ' name="width[' . $k .
']" value="' . $v .
'">' .
'</input>';
591 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $check, $a_output);
605 $spans = $a_table->getAllCellSpans();
607 foreach ($spans as $k => $v) {
609 $selects =
'<div style="white-space:nowrap;">' .
$lng->txt(
"cont_colspan") .
": " .
610 '<select class="small" name="colspan[' . $k .
']">';
611 for (
$i = 1;
$i <= $v[
"max_x"] - $v[
"x"] + 1;
$i++) {
612 $sel_str = (
$i == $v[
"colspan"])
613 ?
'selected="selected"'
615 $selects .=
'<option value="' .
$i .
'" ' . $sel_str .
'>' .
$i .
'</option>';
617 $selects .=
"</select></div>";
620 $selects .=
'<div style="margin-top:3px; white-space:nowrap;">' .
$lng->txt(
"cont_rowspan") .
": " .
621 '<select class="small" name="rowspan[' . $k .
']">';
622 for (
$i = 1;
$i <= $v[
"max_y"] - $v[
"y"] + 1;
$i++) {
623 $sel_str = (
$i == $v[
"rowspan"])
624 ?
'selected="selected"'
626 $selects .=
'<option value="' .
$i .
'" ' . $sel_str .
'>' .
$i .
'</option>';
628 $selects .=
"</select></div>";
630 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $selects, $a_output);
648 $ilTabs->setSubTabActive(
"cont_style");
651 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
653 $form->setFormAction(
$ilCtrl->getFormAction($this));
654 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
657 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
659 $this->lng->txt(
"cont_style"),
665 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
666 foreach ($options as $k => $option) {
667 $html =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_' . $k .
'">' .
668 $option .
'</td></tr></table>';
669 $style->addOption($k, $option, $html);
672 $style->setValue(
"");
673 $style->setInfo(
$lng->txt(
"cont_set_tab_style_info"));
674 $form->addItem($style);
675 $form->setKeepOpen(
true);
677 $form->addCommandButton(
"setStyles",
$lng->txt(
"cont_set_styles"));
679 $html = $form->getHTML();
680 $html .=
"<br />" . $this->
renderTable(
"table_edit",
"style") .
"</form>";
681 $tpl->setContent($html);
697 $ilTabs->setSubTabActive(
"cont_width");
698 $ilTabs->setTabActive(
"cont_table_cell_properties");
700 $ctpl =
new ilTemplate(
"tpl.table_cell_properties.html",
true,
true,
"Services/COPage");
701 $ctpl->setVariable(
"BTN_NAME",
"setWidths");
702 $ctpl->setVariable(
"BTN_TEXT",
$lng->txt(
"cont_save_widths"));
703 $ctpl->setVariable(
"FORMACTION",
$ilCtrl->getFormAction($this));
705 $html = $ctpl->get();
706 $html .=
"<br />" . $this->
renderTable(
"table_edit",
"width") .
"</form>";
707 $tpl->setContent($html);
723 $ilTabs->setSubTabActive(
"cont_span");
724 $ilTabs->setTabActive(
"cont_table_cell_properties");
726 $ctpl =
new ilTemplate(
"tpl.table_cell_properties.html",
true,
true,
"Services/COPage");
727 $ctpl->setVariable(
"BTN_NAME",
"setSpans");
728 $ctpl->setVariable(
"BTN_TEXT",
$lng->txt(
"cont_save_spans"));
729 $ctpl->setVariable(
"FORMACTION",
$ilCtrl->getFormAction($this));
731 $html = $ctpl->get();
732 $html .=
"<br />" . $this->
renderTable(
"table_edit",
"span") .
"</form>";
733 $tpl->setContent($html);
743 if (is_array(
$_POST[
"target"])) {
744 foreach (
$_POST[
"target"] as $k => $value) {
746 $cid = explode(
":", $k);
747 $this->content_obj->setTDClass(
755 $this->updated = $this->pg_obj->update();
756 ilUtil::sendSuccess(
$lng->txt(
"msg_obj_modified"),
true);
757 $this->ctrl->redirect($this,
"editCellStyle");
767 if (is_array(
$_POST[
"width"])) {
768 foreach (
$_POST[
"width"] as $k => $width) {
769 $cid = explode(
":", $k);
770 $this->content_obj->setTDWidth(
777 $this->updated = $this->pg_obj->update();
778 ilUtil::sendSuccess(
$lng->txt(
"msg_obj_modified"),
true);
779 $this->ctrl->redirect($this,
"editCellWidth");
789 if (is_array(
$_POST[
"colspan"])) {
790 foreach (
$_POST[
"colspan"] as $k => $span) {
794 $this->content_obj->setTDSpans(
$_POST[
"colspan"],
$_POST[
"rowspan"]);
796 $this->updated = $this->pg_obj->update();
797 ilUtil::sendSuccess(
$lng->txt(
"msg_obj_modified"),
true);
798 $this->ctrl->redirect($this,
"editCellSpan");
808 $caption = str_replace(
"&",
"&", $caption);
809 $caption = str_replace(
"<",
"<", $caption);
810 $caption = str_replace(
">",
">", $caption);
822 if (strpos(
$_POST[
"characteristic"],
":") > 0) {
823 $t = explode(
":",
$_POST[
"characteristic"]);
825 $this->content_obj->setClass(
"");
828 $this->content_obj->setTemplate(
"");
830 $this->content_obj->setCaption(
842 $this->updated = $this->pg_obj->update();
843 if ($this->updated ===
true) {
844 $this->ctrl->redirect($this,
"edit");
847 $this->pg_obj->addHierIDs();
857 $this->content_obj->setHorizontalAlign(
"Right");
858 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
859 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
867 $this->content_obj->setHorizontalAlign(
"Left");
868 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
869 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
877 $this->content_obj->setHorizontalAlign(
"Center");
878 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
879 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
887 $this->content_obj->setHorizontalAlign(
"LeftFloat");
888 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
889 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
897 $this->content_obj->setHorizontalAlign(
"RightFloat");
898 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
899 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
915 $html = $this->form->getHTML();
916 $tpl->setContent($html);
935 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
936 $import_table = trim(
$_POST[
"import_table"]);
939 if (!empty($import_table)) {
940 switch (
$_POST[
"import_type"]) {
943 if (!$this->content_obj->importHtml(
$_POST[
"language"], $import_table)) {
951 $this->content_obj->importSpreadsheet(
$_POST[
"language"], $import_table);
955 $this->content_obj->addRows(
965 $this->content_obj->setFirstRowStyle($frtype);
968 $this->updated = $this->pg_obj->update();
970 if ($this->updated ===
true) {
982 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
1003 $ilTabs->setSubTabActive(
"cont_alignment");
1004 $ilTabs->setTabActive(
"cont_table_cell_properties");
1007 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1009 $form->setFormAction(
$ilCtrl->getFormAction($this));
1010 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
1014 "" =>
$lng->txt(
"default"),
1015 "Left" =>
$lng->txt(
"cont_left"),
1016 "Center" =>
$lng->txt(
"cont_center"),
1017 "Right" =>
$lng->txt(
"cont_right")
1020 $si->setOptions($options);
1022 $form->addItem(
$si);
1024 $form->setKeepOpen(
true);
1026 $form->addCommandButton(
"setAlignment",
$lng->txt(
"cont_set_alignment"));
1028 $html = $form->getHTML();
1029 $html .=
"<br />" . $this->
renderTable(
"table_edit",
"alignment") .
"</form>";
1030 $tpl->setContent($html);
1040 if (is_array(
$_POST[
"target"])) {
1041 foreach (
$_POST[
"target"] as $k => $value) {
1043 $cid = explode(
":", $k);
1044 $this->content_obj->setTDAlignment(
1052 $this->updated = $this->pg_obj->update();
1053 ilUtil::sendSuccess(
$lng->txt(
"msg_obj_modified"),
true);
1055 $this->ctrl->redirect($this,
"editCellAlignment");
An exception for terminatinating execution or to throw for unit testing.
static getPCDefinitions()
Get PC definitions.
static requirePCClassByName($a_name)
Get instance.
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.
getTemplateOptions($a_type="")
Get table templates.
editCellAlignment()
Edit cell styles.
centerAlign()
align table to left
static _addAlignmentCheckboxes($a_output, $a_table)
Add alignment checkboxes in edit mode.
renderTable($a_mode="table_edit", $a_submode="")
Render the table.
setProperties()
Set properties from input form.
static _renderTable( $content, $a_mode="table_edit", $a_submode="", $a_table_obj=null, $unmask=true, $page_object=null)
Static render table function.
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
executeCommand()
execute command
setBasicTableCellStyles()
Set basic table cell styles.
static _addSpanInputs($a_output, $a_table)
Add span inputs.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
editCellStyle()
Edit cell styles.
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 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)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc