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();
43 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
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");
168 $html = $this->form->getHTML();
183 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
185 $this->form->setFormAction(
$ilCtrl->getFormAction($this));
186 if ($a_mode ==
"create") {
187 $this->form->setTitle($this->lng->txt(
"cont_insert_table"));
189 $this->form->setTitle($this->lng->txt(
"cont_table_properties"));
192 if ($a_mode ==
"create") {
194 for (
$i=1;
$i<=20;
$i++) {
200 $cols->setOptions($nr);
202 $this->form->addItem(
$cols);
206 $rows->setOptions($nr);
208 $this->form->addItem(
$rows);
212 $width =
new ilTextInputGUI($this->lng->txt(
"cont_table_width"),
"width");
214 $width->setMaxLength(6);
215 $this->form->addItem($width);
219 $border->setInfo($this->lng->txt(
"cont_table_border_info"));
226 $padding =
new ilTextInputGUI($this->lng->txt(
"cont_table_cellpadding"),
"padding");
227 $padding->setInfo($this->lng->txt(
"cont_table_cellpadding_info"));
228 $padding->setValue(
"2px");
229 $padding->setSize(6);
230 $padding->setMaxLength(6);
231 $this->form->addItem($padding);
235 $spacing->setValue(
"0px");
236 $this->form->addItem($spacing);
244 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
246 $this->lng->txt(
"cont_characteristic"),
251 $chars = array_merge($templates, $chars);
252 if (is_object($this->content_obj)) {
253 if ($chars[$a_seleted_value] ==
"" && ($this->content_obj->getClass() !=
"")) {
254 $chars = array_merge(
255 array($this->content_obj->getClass() => $this->content_obj->getClass()),
260 foreach ($chars as $k => $char) {
261 if (strpos($k,
":") > 0) {
262 $t = explode(
":", $k);
263 $html = $this->style->lookupTemplatePreview(
$t[1]) .
'<div style="clear:both;" class="small">' . $char .
"</div>";
265 $html =
'<table class="ilc_table_' . $k .
'"><tr><td class="small">' .
266 $char .
'</td></tr></table>';
268 $char_prop->addOption($k, $char,
$html);
270 $char_prop->setValue(
"StandardTable");
271 $this->form->addItem($char_prop);
279 $rh =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_header"),
"row_header");
280 $rh->setOptions($nr);
282 $this->form->addItem($rh);
285 $rf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_footer"),
"row_footer");
286 $rf->setOptions($nr);
288 $this->form->addItem($rf);
291 $ch =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_header"),
"col_header");
292 $ch->setOptions($nr);
294 $this->form->addItem($ch);
297 $cf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_footer"),
"col_footer");
298 $cf->setOptions($nr);
300 $this->form->addItem($cf);
302 if ($a_mode ==
"create") {
304 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
306 $this->lng->txt(
"cont_first_row_style"),
312 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
313 foreach (
$options as $k => $option) {
314 $html =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_' . $k .
'">' .
315 $option .
'</td></tr></table>';
316 $fr_style->addOption($k, $option,
$html);
319 $fr_style->setValue(
"");
320 $this->form->addItem($fr_style);
324 $align_opts = array(
"Left" =>
$lng->txt(
"cont_left"),
325 "Right" =>
$lng->txt(
"cont_right"),
"Center" =>
$lng->txt(
"cont_center"),
326 "LeftFloat" =>
$lng->txt(
"cont_left_float"),
327 "RightFloat" =>
$lng->txt(
"cont_right_float"));
329 $align->setOptions($align_opts);
330 $align->setValue(
"Center");
331 $this->form->addItem($align);
334 $caption =
new ilTextInputGUI($this->lng->txt(
"cont_caption"),
"caption");
335 $caption->setSize(60);
336 $this->form->addItem($caption);
339 $ca_opts = array(
"top" =>
$lng->txt(
"cont_top"),
340 "bottom" =>
$lng->txt(
"cont_bottom"));
342 $this->lng->txt(
"cont_align"),
345 $ca->setOptions($ca_opts);
346 $caption->addSubItem($ca);
349 if ($a_mode ==
"create") {
352 $op =
new ilRadioOption($this->lng->txt(
"cont_html_table"),
"html");
353 $import->addOption($op);
354 $op2 =
new ilRadioOption($this->lng->txt(
"cont_spreadsheet_table"),
"spreadsheet");
357 $import_data->setRows(8);
358 $import_data->setCols(50);
359 $op2->addSubItem($import_data);
361 $import->addOption($op2);
362 $import->setValue(
"html");
363 $this->form->addItem($import);
370 $s_lang =
$ilUser->getLanguage();
372 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
375 $language->setOptions(
$lang);
376 $language->setValue($s_lang);
377 $this->form->addItem($language);
379 if ($a_mode ==
"create") {
380 $this->form->addCommandButton(
"create_tab",
$lng->txt(
"save"));
381 $this->form->addCommandButton(
"cancelCreate",
$lng->txt(
"cancel"));
383 $this->form->addCommandButton(
"saveProperties",
$lng->txt(
"save"));
393 $values[
"width"] = $this->content_obj->getWidth();
394 $values[
"border"] = $this->content_obj->getBorder();
395 $values[
"padding"] = $this->content_obj->getCellPadding();
396 $values[
"spacing"] = $this->content_obj->getCellSpacing();
397 $values[
"row_header"] = $this->content_obj->getHeaderRows();
398 $values[
"row_footer"] = $this->content_obj->getFooterRows();
399 $values[
"col_header"] = $this->content_obj->getHeaderCols();
400 $values[
"col_footer"] = $this->content_obj->getFooterCols();
401 if ($this->content_obj->getTemplate() !=
"") {
402 $values[
"characteristic"] =
"t:" .
404 $this->content_obj->getTemplate();
406 $values[
"characteristic"] = $this->content_obj->getClass();
408 $values[
"align"] = $this->content_obj->getHorizontalAlign();
409 $values[
"caption"] = $this->content_obj->getCaption();
410 $values[
"cap_align"] = $this->content_obj->getCaptionAlign();
411 $values[
"language"] = $this->content_obj->getLanguage();
413 $this->form->setValuesByArray($values);
415 $ca = $this->form->getItemByPostVar(
"cap_align");
416 $ca->setValue($this->content_obj->getCaptionAlign());
422 public function renderTable($a_mode =
"table_edit", $a_submode =
"")
424 $tab_node = $this->content_obj->getNode();
425 $tab_node->set_attribute(
"Enabled",
"True");
426 $content = $this->dom->dump_node($tab_node);
428 $trans = $this->pg_obj->getLanguageVariablesXML();
429 $mobs = $this->pg_obj->getMultimediaXML();
432 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
434 $template_xml =
$style->getTemplateXML();
438 $content = $content .
$mobs . $trans . $template_xml;
441 !$this->pg_obj->getPageConfig()->getPreventHTMLUnmasking());
447 public static function _renderTable($content, $a_mode =
"table_edit", $a_submode =
"", $a_table_obj =
null,
454 $content =
"<dummy>" . $content .
"</dummy>";
456 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
457 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
463 $params = array(
'mode' => $a_mode,
464 'media_mode' =>
$ilUser->getPref(
"ilPageEditor_MediaMode"),
465 'media_mode' =>
'disable',
466 'webspace_path' => $wb_path,
'enlarge_path' => $enlarge_path);
467 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",
null, $args,
$params);
478 if ($a_mode ==
"table_edit" && !is_null($a_table_obj)) {
479 switch ($a_submode) {
499 return '<div class="ilFloatLeft">' .
$output .
'</div>';
511 $classes = $a_table->getAllCellClasses();
513 foreach ($classes as $k => $v) {
515 $v =
$lng->txt(
"none");
517 if (substr($v, 0, 4) ==
"ilc_") {
520 $check =
$lng->txt(
"cont_style") .
": " .
521 '<input type="checkbox" value="1"' .
522 ' name="target[' . $k .
']">' .
'</input> ' . $v;
524 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $check, $a_output);
538 $classes = $a_table->getAllCellAlignments();
540 foreach ($classes as $k => $v) {
542 $v =
$lng->txt(
"default");
544 $check =
$lng->txt(
"cont_alignment") .
": " .
545 '<input type="checkbox" value="1"' .
546 ' name="target[' . $k .
']">' .
'</input> ' . $v;
548 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $check, $a_output);
562 $widths = $a_table->getAllCellWidths();
564 foreach ($widths as $k => $v) {
565 $check =
$lng->txt(
"cont_width") .
": " .
566 '<input class="small" type="text" size="5" maxlength="10"' .
567 ' name="width[' . $k .
']" value="' . $v .
'">' .
'</input>';
569 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $check, $a_output);
583 $spans = $a_table->getAllCellSpans();
585 foreach ($spans as $k => $v) {
587 $selects =
'<div style="white-space:nowrap;">' .
$lng->txt(
"cont_colspan") .
": " .
588 '<select class="small" name="colspan[' . $k .
']">';
589 for (
$i = 1;
$i <= $v[
"max_x"] - $v[
"x"] + 1;
$i++) {
590 $sel_str = (
$i == $v[
"colspan"])
591 ?
'selected="selected"'
593 $selects.=
'<option value="' .
$i .
'" ' . $sel_str .
'>' .
$i .
'</option>';
595 $selects.=
"</select></div>";
598 $selects.=
'<div style="margin-top:3px; white-space:nowrap;">' .
$lng->txt(
"cont_rowspan") .
": " .
599 '<select class="small" name="rowspan[' . $k .
']">';
600 for (
$i = 1;
$i <= $v[
"max_y"] - $v[
"y"] + 1;
$i++) {
601 $sel_str = (
$i == $v[
"rowspan"])
602 ?
'selected="selected"'
604 $selects.=
'<option value="' .
$i .
'" ' . $sel_str .
'>' .
$i .
'</option>';
606 $selects.=
"</select></div>";
608 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $selects, $a_output);
626 $ilTabs->setSubTabActive(
"cont_style");
629 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
632 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
635 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
637 $this->lng->txt(
"cont_style"),
643 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
644 foreach (
$options as $k => $option) {
645 $html =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_' . $k .
'">' .
646 $option .
'</td></tr></table>';
651 $style->setInfo(
$lng->txt(
"cont_set_tab_style_info"));
653 $form->setKeepOpen(
true);
655 $form->addCommandButton(
"setStyles",
$lng->txt(
"cont_set_styles"));
675 $ilTabs->setSubTabActive(
"cont_width");
676 $ilTabs->setTabActive(
"cont_table_cell_properties");
678 $ctpl =
new ilTemplate(
"tpl.table_cell_properties.html",
true,
true,
"Services/COPage");
679 $ctpl->setVariable(
"BTN_NAME",
"setWidths");
680 $ctpl->setVariable(
"BTN_TEXT",
$lng->txt(
"cont_save_widths"));
681 $ctpl->setVariable(
"FORMACTION",
$ilCtrl->getFormAction($this));
683 $html = $ctpl->get();
701 $ilTabs->setSubTabActive(
"cont_span");
702 $ilTabs->setTabActive(
"cont_table_cell_properties");
704 $ctpl =
new ilTemplate(
"tpl.table_cell_properties.html",
true,
true,
"Services/COPage");
705 $ctpl->setVariable(
"BTN_NAME",
"setSpans");
706 $ctpl->setVariable(
"BTN_TEXT",
$lng->txt(
"cont_save_spans"));
707 $ctpl->setVariable(
"FORMACTION",
$ilCtrl->getFormAction($this));
709 $html = $ctpl->get();
721 if (is_array(
$_POST[
"target"])) {
722 foreach (
$_POST[
"target"] as $k => $value) {
724 $cid = explode(
":", $k);
725 $this->content_obj->setTDClass(
733 $this->updated = $this->pg_obj->update();
735 $this->ctrl->redirect($this,
"editCellStyle");
745 if (is_array(
$_POST[
"width"])) {
746 foreach (
$_POST[
"width"] as $k => $width) {
747 $cid = explode(
":", $k);
748 $this->content_obj->setTDWidth(
755 $this->updated = $this->pg_obj->update();
757 $this->ctrl->redirect($this,
"editCellWidth");
767 if (is_array(
$_POST[
"colspan"])) {
768 foreach (
$_POST[
"colspan"] as $k => $span) {
772 $this->content_obj->setTDSpans(
$_POST[
"colspan"],
$_POST[
"rowspan"]);
774 $this->updated = $this->pg_obj->update();
776 $this->ctrl->redirect($this,
"editCellSpan");
786 $caption = str_replace(
"&",
"&", $caption);
787 $caption = str_replace(
"<",
"<", $caption);
788 $caption = str_replace(
">",
">", $caption);
800 if (strpos(
$_POST[
"characteristic"],
":") > 0) {
801 $t = explode(
":",
$_POST[
"characteristic"]);
803 $this->content_obj->setClass(
"");
806 $this->content_obj->setTemplate(
"");
808 $this->content_obj->setCaption(
820 $this->updated = $this->pg_obj->update();
821 if ($this->updated ===
true) {
822 $this->ctrl->redirect($this,
"edit");
825 $this->pg_obj->addHierIDs();
835 $this->content_obj->setHorizontalAlign(
"Right");
836 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
837 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
845 $this->content_obj->setHorizontalAlign(
"Left");
846 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
847 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
855 $this->content_obj->setHorizontalAlign(
"Center");
856 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
857 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
865 $this->content_obj->setHorizontalAlign(
"LeftFloat");
866 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
867 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
875 $this->content_obj->setHorizontalAlign(
"RightFloat");
876 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
877 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
893 $html = $this->form->getHTML();
913 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
914 $import_table = trim(
$_POST[
"import_table"]);
917 if (!empty($import_table)) {
918 switch (
$_POST[
"import_type"]) {
921 if (!$this->content_obj->importHtml(
$_POST[
"language"], $import_table)) {
929 $this->content_obj->importSpreadsheet(
$_POST[
"language"], $import_table);
933 $this->content_obj->addRows(
943 $this->content_obj->setFirstRowStyle($frtype);
946 $this->updated = $this->pg_obj->update();
948 if ($this->updated ===
true) {
960 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
981 $ilTabs->setSubTabActive(
"cont_alignment");
982 $ilTabs->setTabActive(
"cont_table_cell_properties");
985 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
988 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
992 "" =>
$lng->txt(
"default"),
993 "Left" =>
$lng->txt(
"cont_left"),
994 "Center" =>
$lng->txt(
"cont_center"),
995 "Right" =>
$lng->txt(
"cont_right")
1002 $form->setKeepOpen(
true);
1004 $form->addCommandButton(
"setAlignment",
$lng->txt(
"cont_set_alignment"));
1007 $html.=
"<br />" . $this->
renderTable(
"table_edit",
"alignment") .
"</form>";
1018 if (is_array(
$_POST[
"target"])) {
1019 foreach (
$_POST[
"target"] as $k => $value) {
1021 $cid = explode(
":", $k);
1022 $this->content_obj->setTDAlignment(
1030 $this->updated = $this->pg_obj->update();
1033 $this->ctrl->redirect($this,
"editCellAlignment");
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
An exception for terminatinating execution or to throw for unit testing.
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.
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.
static _renderTable($content, $a_mode="table_edit", $a_submode="", $a_table_obj=null, $unmask=true)
Static render table function.
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_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
if(isset($_POST['submit'])) $form