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);
274 for (
$i = 0;
$i <= 3;
$i++) {
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");
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;
445 !$this->pg_obj->getPageConfig()->getPreventHTMLUnmasking()
454 $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);
487 if ($a_mode ==
"table_edit" && !is_null($a_table_obj)) {
488 switch ($a_submode) {
508 return '<div class="ilFloatLeft">' .
$output .
'</div>';
520 $classes = $a_table->getAllCellClasses();
522 foreach ($classes as $k => $v) {
524 $v =
$lng->txt(
"none");
526 if (substr($v, 0, 4) ==
"ilc_") {
529 $check =
$lng->txt(
"cont_style") .
": " .
530 '<input type="checkbox" value="1"' .
531 ' name="target[' . $k .
']">' .
'</input> ' . $v;
533 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $check, $a_output);
547 $classes = $a_table->getAllCellAlignments();
549 foreach ($classes as $k => $v) {
551 $v =
$lng->txt(
"default");
553 $check =
$lng->txt(
"cont_alignment") .
": " .
554 '<input type="checkbox" value="1"' .
555 ' name="target[' . $k .
']">' .
'</input> ' . $v;
557 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $check, $a_output);
571 $widths = $a_table->getAllCellWidths();
573 foreach ($widths as $k => $v) {
574 $check =
$lng->txt(
"cont_width") .
": " .
575 '<input class="small" type="text" size="5" maxlength="10"' .
576 ' name="width[' . $k .
']" value="' . $v .
'">' .
'</input>';
578 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $check, $a_output);
592 $spans = $a_table->getAllCellSpans();
594 foreach ($spans as $k => $v) {
596 $selects =
'<div style="white-space:nowrap;">' .
$lng->txt(
"cont_colspan") .
": " .
597 '<select class="small" name="colspan[' . $k .
']">';
598 for (
$i = 1;
$i <= $v[
"max_x"] - $v[
"x"] + 1;
$i++) {
599 $sel_str = (
$i == $v[
"colspan"])
600 ?
'selected="selected"'
602 $selects .=
'<option value="' .
$i .
'" ' . $sel_str .
'>' .
$i .
'</option>';
604 $selects .=
"</select></div>";
607 $selects .=
'<div style="margin-top:3px; white-space:nowrap;">' .
$lng->txt(
"cont_rowspan") .
": " .
608 '<select class="small" name="rowspan[' . $k .
']">';
609 for (
$i = 1;
$i <= $v[
"max_y"] - $v[
"y"] + 1;
$i++) {
610 $sel_str = (
$i == $v[
"rowspan"])
611 ?
'selected="selected"'
613 $selects .=
'<option value="' .
$i .
'" ' . $sel_str .
'>' .
$i .
'</option>';
615 $selects .=
"</select></div>";
617 $a_output = str_replace(
"{{{{{TableEdit;" . $k .
"}}}}}", $selects, $a_output);
635 $ilTabs->setSubTabActive(
"cont_style");
638 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
641 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
644 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
646 $this->lng->txt(
"cont_style"),
652 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
653 foreach (
$options as $k => $option) {
654 $html =
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_' . $k .
'">' .
655 $option .
'</td></tr></table>';
660 $style->setInfo(
$lng->txt(
"cont_set_tab_style_info"));
662 $form->setKeepOpen(
true);
664 $form->addCommandButton(
"setStyles",
$lng->txt(
"cont_set_styles"));
684 $ilTabs->setSubTabActive(
"cont_width");
685 $ilTabs->setTabActive(
"cont_table_cell_properties");
687 $ctpl =
new ilTemplate(
"tpl.table_cell_properties.html",
true,
true,
"Services/COPage");
688 $ctpl->setVariable(
"BTN_NAME",
"setWidths");
689 $ctpl->setVariable(
"BTN_TEXT",
$lng->txt(
"cont_save_widths"));
690 $ctpl->setVariable(
"FORMACTION",
$ilCtrl->getFormAction($this));
692 $html = $ctpl->get();
710 $ilTabs->setSubTabActive(
"cont_span");
711 $ilTabs->setTabActive(
"cont_table_cell_properties");
713 $ctpl =
new ilTemplate(
"tpl.table_cell_properties.html",
true,
true,
"Services/COPage");
714 $ctpl->setVariable(
"BTN_NAME",
"setSpans");
715 $ctpl->setVariable(
"BTN_TEXT",
$lng->txt(
"cont_save_spans"));
716 $ctpl->setVariable(
"FORMACTION",
$ilCtrl->getFormAction($this));
718 $html = $ctpl->get();
730 if (is_array(
$_POST[
"target"])) {
731 foreach (
$_POST[
"target"] as $k => $value) {
733 $cid = explode(
":", $k);
734 $this->content_obj->setTDClass(
742 $this->updated = $this->pg_obj->update();
743 ilUtil::sendSuccess(
$lng->txt(
"msg_obj_modified"),
true);
744 $this->ctrl->redirect($this,
"editCellStyle");
754 if (is_array(
$_POST[
"width"])) {
755 foreach (
$_POST[
"width"] as $k => $width) {
756 $cid = explode(
":", $k);
757 $this->content_obj->setTDWidth(
764 $this->updated = $this->pg_obj->update();
765 ilUtil::sendSuccess(
$lng->txt(
"msg_obj_modified"),
true);
766 $this->ctrl->redirect($this,
"editCellWidth");
776 if (is_array(
$_POST[
"colspan"])) {
777 foreach (
$_POST[
"colspan"] as $k => $span) {
781 $this->content_obj->setTDSpans(
$_POST[
"colspan"],
$_POST[
"rowspan"]);
783 $this->updated = $this->pg_obj->update();
784 ilUtil::sendSuccess(
$lng->txt(
"msg_obj_modified"),
true);
785 $this->ctrl->redirect($this,
"editCellSpan");
795 $caption = str_replace(
"&",
"&", $caption);
796 $caption = str_replace(
"<",
"<", $caption);
797 $caption = str_replace(
">",
">", $caption);
809 if (strpos(
$_POST[
"characteristic"],
":") > 0) {
810 $t = explode(
":",
$_POST[
"characteristic"]);
812 $this->content_obj->setClass(
"");
815 $this->content_obj->setTemplate(
"");
817 $this->content_obj->setCaption(
829 $this->updated = $this->pg_obj->update();
830 if ($this->updated ===
true) {
831 $this->ctrl->redirect($this,
"edit");
834 $this->pg_obj->addHierIDs();
844 $this->content_obj->setHorizontalAlign(
"Right");
845 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
846 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
854 $this->content_obj->setHorizontalAlign(
"Left");
855 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
856 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
864 $this->content_obj->setHorizontalAlign(
"Center");
865 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
866 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
874 $this->content_obj->setHorizontalAlign(
"LeftFloat");
875 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
876 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
884 $this->content_obj->setHorizontalAlign(
"RightFloat");
885 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
886 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
902 $html = $this->form->getHTML();
922 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
923 $import_table = trim(
$_POST[
"import_table"]);
926 if (!empty($import_table)) {
927 switch (
$_POST[
"import_type"]) {
930 if (!$this->content_obj->importHtml(
$_POST[
"language"], $import_table)) {
938 $this->content_obj->importSpreadsheet(
$_POST[
"language"], $import_table);
942 $this->content_obj->addRows(
952 $this->content_obj->setFirstRowStyle($frtype);
955 $this->updated = $this->pg_obj->update();
957 if ($this->updated ===
true) {
969 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
990 $ilTabs->setSubTabActive(
"cont_alignment");
991 $ilTabs->setTabActive(
"cont_table_cell_properties");
994 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
997 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
1001 "" =>
$lng->txt(
"default"),
1002 "Left" =>
$lng->txt(
"cont_left"),
1003 "Center" =>
$lng->txt(
"cont_center"),
1004 "Right" =>
$lng->txt(
"cont_right")
1011 $form->setKeepOpen(
true);
1013 $form->addCommandButton(
"setAlignment",
$lng->txt(
"cont_set_alignment"));
1016 $html .=
"<br />" . $this->
renderTable(
"table_edit",
"alignment") .
"</form>";
1027 if (is_array(
$_POST[
"target"])) {
1028 foreach (
$_POST[
"target"] as $k => $value) {
1030 $cid = explode(
":", $k);
1031 $this->content_obj->setTDAlignment(
1039 $this->updated = $this->pg_obj->update();
1040 ilUtil::sendSuccess(
$lng->txt(
"msg_obj_modified"),
true);
1042 $this->ctrl->redirect($this,
"editCellAlignment");
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 _renderTable( $content, $a_mode="table_edit", $a_submode="", $a_table_obj=null, $unmask=true)
Static render table function.
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)
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
if(isset($_POST['submit'])) $form