4 require_once(
"./Services/COPage/classes/class.ilPCTable.php");
5 require_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);
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");
282 $this->form->addItem($rh);
285 $rf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_footer"),
"row_footer");
288 $this->form->addItem($rf);
291 $ch =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_header"),
"col_header");
294 $this->form->addItem($ch);
297 $cf =
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_footer"),
"col_footer");
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"));
330 $align->setValue(
"Center");
331 $this->form->addItem($align);
334 $caption =
new ilTextInputGUI($this->lng->txt(
"cont_caption"),
"caption");
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"),
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);
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");
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 );
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);
473 $output = str_replace(
"<",
"<", $output);
474 $output = str_replace(
">",
">", $output);
475 $output = str_replace(
"&",
"&", $output);
478 if ($a_mode ==
"table_edit" && !is_null($a_table_obj)) {
479 switch ($a_submode) {
499 return '<div class="ilFloatLeft">' . $output .
'</div>';
509 $lng = $DIC->language();
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);
536 $lng = $DIC->language();
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);
560 $lng = $DIC->language();
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);
581 $lng = $DIC->language();
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")
999 $si->setInfo(
$lng->txt(
""));
1000 $form->addItem($si);
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");
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
edit()
edit properties form
executeCommand()
execute command
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.
setAlignment()
Set cell alignments.
leftFloatAlign()
align table to left float
static _addSpanInputs($a_output, $a_table)
Add span inputs.
setCellPropertiesSubTabs()
Set tabs.
static _addWidthInputs($a_output, $a_table)
Add width inputs.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor public.
editCellSpan()
Edit cell spans.
setStyles()
Set cell styles and.
editCellWidth()
Edit cell widths.
getTemplateOptions($a_type="")
Get table templates.
create()
create new table in dom and update page in db
setCharacteristics($a_chars)
Set Characteristics.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
static _renderTable($content, $a_mode="table_edit", $a_submode="", $a_table_obj=null, $unmask=true)
Static render table function.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
if(isset($_POST['submit'])) $form
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
insert()
insert new table form
getCharacteristics()
Get characteristics.
Create styles array
The data for the language used.
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
This class represents a text area property in a property form.
static _addAlignmentCheckboxes($a_output, $a_table)
Add alignment checkboxes in edit mode.
rightFloatAlign()
align table to left
leftAlign()
align table to left
setProperties()
Set properties from input form.
editCellStyle()
Edit cell styles.
static getWebspaceDir($mode="filesystem")
get webspace directory
afterCreation()
After creation processing.
setWidths()
Set cell widths.
getPropertiesFormValues()
Get properties form.
setSpans()
Set cell spans.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
editCellAlignment()
Edit cell styles.