4 require_once(
"./Services/COPage/classes/class.ilPCTable.php");
 
    5 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
 
   24         function ilPCTableGUI(&$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",
 
  129                 $html = $this->form->getHTML();
 
  130                 $html.= 
"<br />".$this->renderTable(
"");
 
  131                 $tpl->setContent($html);
 
  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++)
 
  165                         $this->form->addItem($cols);
 
  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);
 
  181                 $border = 
new ilTextInputGUI($this->lng->txt(
"cont_table_border"), 
"border");
 
  184                 $border->setMaxLength(6);
 
  185                 $this->form->addItem($border);
 
  188                 $padding = 
new ilTextInputGUI($this->lng->txt(
"cont_table_cellpadding"), 
"padding");
 
  190                 $padding->setSize(6);
 
  191                 $padding->setMaxLength(6);
 
  192                 $this->form->addItem($padding);
 
  195                 $spacing = 
new ilTextInputGUI($this->lng->txt(
"cont_table_cellspacing"), 
"spacing");
 
  197                 $spacing->setSize(6);
 
  198                 $spacing->setMaxLength(6);
 
  199                 $this->form->addItem($spacing);
 
  202                 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
 
  207                 $chars = array_merge($templates, $chars);
 
  208                 if (is_object($this->content_obj))
 
  210                         if ($chars[$a_seleted_value] == 
"" && ($this->content_obj->getClass() != 
""))
 
  212                                 $chars = array_merge(
 
  213                                         array($this->content_obj->getClass() => $this->content_obj->getClass()),
 
  217                 foreach($chars as $k => $char)
 
  219                         if (strpos($k, 
":") > 0)
 
  221                                 $t = explode(
":", $k);
 
  222                                 $html = $this->style->lookupTemplatePreview(
$t[1]).
'<div style="clear:both;" class="small">'.$char.
"</div>";
 
  226                                 $html = 
'<table class="ilc_table_'.$k.
'"><tr><td class="small">'.
 
  227                                         $char.
'</td></tr></table>';
 
  229                         $char_prop->addOption($k, $char, $html);
 
  231                 $char_prop->setValue(
"StandardTable");
 
  232                 $this->form->addItem($char_prop);
 
  235                 for($i=0; $i<=3; $i++)
 
  241                 $rh = 
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_header"), 
"row_header");
 
  244                 $this->form->addItem($rh);
 
  247                 $rf = 
new ilSelectInputGUI($this->lng->txt(
"cont_nr_row_footer"), 
"row_footer");
 
  250                 $this->form->addItem($rf);
 
  253                 $ch = 
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_header"), 
"col_header");
 
  256                 $this->form->addItem($ch);
 
  259                 $cf = 
new ilSelectInputGUI($this->lng->txt(
"cont_nr_col_footer"), 
"col_footer");
 
  262                 $this->form->addItem($cf);
 
  264                 if ($a_mode == 
"create")
 
  267                         require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
 
  273                         $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);
 
  274                         foreach($options as $k => $option)
 
  276                                 $html = 
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_'.$k.
'">'.
 
  277                                         $option.
'</td></tr></table>';
 
  278                                 $fr_style->addOption($k, $option, $html);
 
  281                         $fr_style->setValue(
"");
 
  282                         $this->form->addItem($fr_style);
 
  286                 $align_opts = array(
"Left" => $lng->txt(
"cont_left"),
 
  287                         "Right" => $lng->txt(
"cont_right"), 
"Center" => $lng->txt(
"cont_center"),
 
  288                         "LeftFloat" => $lng->txt(
"cont_left_float"),
 
  289                         "RightFloat" => $lng->txt(
"cont_right_float"));
 
  292                 $align->setValue(
"Center");
 
  293                 $this->form->addItem($align);
 
  296                 $caption = 
new ilTextInputGUI($this->lng->txt(
"cont_caption"), 
"caption");
 
  298                 $this->form->addItem($caption);
 
  301                 $ca_opts = array(
"top" => $lng->txt(
"cont_top"),
 
  302                         "bottom" => $lng->txt(
"cont_bottom"));
 
  306                 $caption->addSubItem($ca);
 
  309                 if ($a_mode == 
"create")
 
  313                         $op = 
new ilRadioOption($this->lng->txt(
"cont_html_table"), 
"html");
 
  314                         $import->addOption($op);
 
  315                         $op2 = 
new ilRadioOption($this->lng->txt(
"cont_spreadsheet_table"), 
"spreadsheet");
 
  318                                 $import_data->setRows(8);
 
  319                                 $import_data->setCols(50);
 
  322                         $import->addOption($op2);
 
  323                         $import->setValue(
"html");
 
  324                         $this->form->addItem($import);
 
  330                         $s_lang = 
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
 
  334                         $s_lang = $ilUser->getLanguage();
 
  336                 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
 
  340                 $language->setValue($s_lang);
 
  341                 $this->form->addItem($language);
 
  343                 if ($a_mode == 
"create")
 
  345                         $this->form->addCommandButton(
"create_tab", $lng->txt(
"save"));
 
  346                         $this->form->addCommandButton(
"cancelCreate", $lng->txt(
"cancel"));
 
  350                         $this->form->addCommandButton(
"saveProperties", $lng->txt(
"save"));
 
  360                 $values[
"width"] = $this->content_obj->getWidth();
 
  361                 $values[
"border"] = $this->content_obj->getBorder();
 
  362                 $values[
"padding"] = $this->content_obj->getCellPadding();
 
  363                 $values[
"spacing"] = $this->content_obj->getCellSpacing();
 
  364                 $values[
"row_header"] = $this->content_obj->getHeaderRows();
 
  365                 $values[
"row_footer"] = $this->content_obj->getFooterRows();
 
  366                 $values[
"col_header"] = $this->content_obj->getHeaderCols();
 
  367                 $values[
"col_footer"] = $this->content_obj->getFooterCols();
 
  368                 if ($this->content_obj->getTemplate() != 
"")
 
  370                         $values[
"characteristic"] = 
"t:".
 
  372                                 $this->content_obj->getTemplate();
 
  376                         $values[
"characteristic"] = $this->content_obj->getClass();
 
  378                 $values[
"align"] = $this->content_obj->getHorizontalAlign();
 
  379                 $values[
"caption"] = $this->content_obj->getCaption();
 
  380                 $values[
"cap_align"] = $this->content_obj->getCaptionAlign();
 
  381                 $values[
"language"] = $this->content_obj->getLanguage();
 
  383                 $this->form->setValuesByArray($values);
 
  385                 $ca = $this->form->getItemByPostVar(
"cap_align");
 
  386                 $ca->setValue($this->content_obj->getCaptionAlign());
 
  394                 $tab_node = $this->content_obj->getNode();
 
  395                 $tab_node->set_attribute(
"Enabled", 
"True");
 
  396                 $content = $this->dom->dump_node($tab_node);
 
  398                 $trans = $this->pg_obj->getLanguageVariablesXML();
 
  399                 $mobs = $this->pg_obj->getMultimediaXML();
 
  404                                 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
 
  406                                 $template_xml = $style->getTemplateXML();
 
  410                 $content = $content.$mobs.$trans.$template_xml;
 
  418         static function _renderTable($content, $a_mode = 
"table_edit", $a_submode = 
"", $a_table_obj = null)
 
  422                 $content = 
"<dummy>".$content.
"</dummy>";
 
  424                 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
 
  425                 $args = array( 
'/_xml' => $content, 
'/_xsl' => $xsl );
 
  432                 $params = array (
'mode' => $a_mode,
 
  433                         'med_disabled_path' => $med_disabled_path,
 
  434                         'media_mode' => $ilUser->getPref(
"ilPageEditor_MediaMode"),
 
  435                         'media_mode' => 
'disable',
 
  436                         'webspace_path' => $wb_path, 
'enlarge_path' => $enlarge_path);
 
  437                 $output = 
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args, $params);
 
  442                 $output = str_replace(
"<",
"<",$output);
 
  443                 $output = str_replace(
">",
">",$output);
 
  444                 $output = str_replace(
"&",
"&",$output);
 
  446                 if ($a_mode == 
"table_edit" && !is_null($a_table_obj))
 
  469                 return '<div style="float:left;">'.$output.
'</div>';
 
  479                 $classes = $a_table->getAllCellClasses();
 
  481                 foreach ($classes as $k => $v)
 
  485                                 $v = $lng->txt(
"none");
 
  487                         if (substr($v, 0, 4) == 
"ilc_")
 
  491                         $check = $lng->txt(
"cont_style").
": ".
 
  492                                 '<input type="checkbox" value="1"'.
 
  493                                 ' name="target['.$k.
']">'.
'</input> '.$v;
 
  495                         $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $check, $a_output);
 
  507                 $classes = $a_table->getAllCellAlignments();
 
  509                 foreach ($classes as $k => $v)
 
  513                                 $v = $lng->txt(
"default");
 
  515                         $check = $lng->txt(
"cont_alignment").
": ".
 
  516                                 '<input type="checkbox" value="1"'.
 
  517                                 ' name="target['.$k.
']">'.
'</input> '.$v;
 
  519                         $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $check, $a_output);
 
  531                 $widths = $a_table->getAllCellWidths();
 
  533                 foreach ($widths as $k => $v)
 
  535                         $check = $lng->txt(
"cont_width").
": ".
 
  536                                 '<input class="small" type="text" size="5" maxlength="10"'.
 
  537                                 ' name="width['.$k.
']" value="'.$v.
'">'.
'</input>';
 
  539                         $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $check, $a_output);
 
  551                 $spans = $a_table->getAllCellSpans();
 
  553                 foreach ($spans as $k => $v)
 
  556                         $selects = 
'<div style="white-space:nowrap;">'.$lng->txt(
"cont_colspan").
": ".
 
  557                                 '<select class="small" name="colspan['.$k.
']">';
 
  558                         for ($i = 1; $i <= $v[
"max_x"] - $v[
"x"] + 1; $i++)
 
  560                                 $sel_str = ($i == $v[
"colspan"])
 
  561                                         ? 
'selected="selected"' 
  563                                 $selects.= 
'<option value="'.$i.
'" '.$sel_str.
'>'.$i.
'</option>';
 
  565                         $selects.= 
"</select></div>";
 
  568                         $selects.= 
'<div style="margin-top:3px; white-space:nowrap;">'.$lng->txt(
"cont_rowspan").
": ".
 
  569                                 '<select class="small" name="rowspan['.$k.
']">';
 
  570                         for ($i = 1; $i <= $v[
"max_y"] - $v[
"y"] + 1; $i++)
 
  572                                 $sel_str = ($i == $v[
"rowspan"])
 
  573                                         ? 
'selected="selected"' 
  575                                 $selects.= 
'<option value="'.$i.
'" '.$sel_str.
'>'.$i.
'</option>';
 
  577                         $selects.= 
"</select></div>";
 
  579                         $a_output = str_replace(
"{{{{{TableEdit;".$k.
"}}}}}", $selects, $a_output);
 
  594                 $ilTabs->setSubTabActive(
"cont_style");
 
  597                 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  599                 $form->setFormAction($ilCtrl->getFormAction($this));
 
  600                 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
 
  603                 require_once(
"./Services/Form/classes/class.ilAdvSelectInputGUI.php");
 
  609                 $options = array_merge(array(
"" => $this->lng->txt(
"none")), $chars);   
 
  610                 foreach($options as $k => $option)
 
  612                         $html = 
'<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_'.$k.
'">'.
 
  613                                 $option.
'</td></tr></table>';
 
  614                         $style->addOption($k, $option, $html);
 
  617                 $style->setValue(
"");
 
  618                 $style->setInfo($lng->txt(
"cont_set_tab_style_info"));
 
  619                 $form->addItem($style);
 
  620                 $form->setKeepOpen(
true);
 
  622                 $form->addCommandButton(
"setStyles", $lng->txt(
"cont_set_styles"));
 
  624                 $html = $form->getHTML();
 
  625                 $html.= 
"<br />".$this->renderTable(
"table_edit", 
"style").
"</form>";
 
  626                 $tpl->setContent($html);
 
  640                 $ilTabs->setSubTabActive(
"cont_width");
 
  641                 $ilTabs->setTabActive(
"cont_table_cell_properties");
 
  643                 $ctpl = 
new ilTemplate(
"tpl.table_cell_properties.html", 
true, 
true, 
"Services/COPage");
 
  644                 $ctpl->setVariable(
"BTN_NAME", 
"setWidths");
 
  645                 $ctpl->setVariable(
"BTN_TEXT", $lng->txt(
"cont_save_widths"));
 
  646                 $ctpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
 
  648                 $html = $ctpl->get();
 
  649                 $html.= 
"<br />".$this->renderTable(
"table_edit", 
"width").
"</form>";
 
  650                 $tpl->setContent($html);
 
  664                 $ilTabs->setSubTabActive(
"cont_span");
 
  665                 $ilTabs->setTabActive(
"cont_table_cell_properties");
 
  667                 $ctpl = 
new ilTemplate(
"tpl.table_cell_properties.html", 
true, 
true, 
"Services/COPage");
 
  668                 $ctpl->setVariable(
"BTN_NAME", 
"setSpans");
 
  669                 $ctpl->setVariable(
"BTN_TEXT", $lng->txt(
"cont_save_spans"));
 
  670                 $ctpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
 
  672                 $html = $ctpl->get();
 
  673                 $html.= 
"<br />".$this->renderTable(
"table_edit", 
"span").
"</form>";
 
  674                 $tpl->setContent($html);
 
  685                 if (is_array(
$_POST[
"target"]))
 
  687                         foreach (
$_POST[
"target"] as $k => $value)
 
  691                                         $cid = explode(
":", $k);
 
  697                 $this->updated = $this->pg_obj->update();
 
  699                 $this->ctrl->redirect($this, 
"editCellStyle");
 
  709                 if (is_array(
$_POST[
"width"]))
 
  711                         foreach (
$_POST[
"width"] as $k => $width)
 
  713                                 $cid = explode(
":", $k);
 
  718                 $this->updated = $this->pg_obj->update();
 
  720                 $this->ctrl->redirect($this, 
"editCellWidth");
 
  730                 if (is_array(
$_POST[
"colspan"]))
 
  732                         foreach (
$_POST[
"colspan"] as $k => $span)
 
  737                         $this->content_obj->setTDSpans(
$_POST[
"colspan"], 
$_POST[
"rowspan"]);
 
  739                 $this->updated = $this->pg_obj->update();
 
  741                 $this->ctrl->redirect($this, 
"editCellSpan");
 
  751                 $caption = str_replace(
"&",
"&", $caption);
 
  752                 $caption = str_replace(
"<",
"<", $caption);
 
  753                 $caption = str_replace(
">",
">", $caption);
 
  765                 if (strpos(
$_POST[
"characteristic"], 
":") > 0)
 
  767                         $t = explode(
":", 
$_POST[
"characteristic"]);
 
  769                         $this->content_obj->setClass(
"");
 
  774                         $this->content_obj->setTemplate(
"");
 
  776                 $this->content_obj->setCaption($caption,
 
  786                 $this->updated = $this->pg_obj->update();
 
  787                 if ($this->updated === 
true)
 
  789                         $this->ctrl->redirect($this, 
"edit");
 
  794                         $this->pg_obj->addHierIDs();
 
  804                 $this->content_obj->setHorizontalAlign(
"Right");
 
  805                 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
 
  806                 $this->ctrl->returnToParent($this, 
"jump".$this->hier_id);
 
  814                 $this->content_obj->setHorizontalAlign(
"Left");
 
  815                 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
 
  816                 $this->ctrl->returnToParent($this, 
"jump".$this->hier_id);
 
  824                 $this->content_obj->setHorizontalAlign(
"Center");
 
  825                 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
 
  826                 $this->ctrl->returnToParent($this, 
"jump".$this->hier_id);
 
  834                 $this->content_obj->setHorizontalAlign(
"LeftFloat");
 
  835                 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
 
  836                 $this->ctrl->returnToParent($this, 
"jump".$this->hier_id);
 
  844                 $this->content_obj->setHorizontalAlign(
"RightFloat");
 
  845                 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
 
  846                 $this->ctrl->returnToParent($this, 
"jump".$this->hier_id);
 
  859                 $html = $this->form->getHTML();
 
  860                 $tpl->setContent($html);
 
  879                 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
 
  880                 $import_table = trim(
$_POST[
"import_table"]);
 
  883                 if (!empty ($import_table))
 
  885                         switch(
$_POST[
"import_type"])
 
  889                                         if (!$this->content_obj->importHtml (
$_POST[
"language"], $import_table))
 
  898                                         $this->content_obj->importSpreadsheet(
$_POST[
"language"], $import_table);
 
  913                         $this->content_obj->setFirstRowStyle($frtype);
 
  916                 $this->updated = $this->pg_obj->update();
 
  918                 if ($this->updated === 
true)
 
  933                 $this->ctrl->returnToParent($this, 
"jump".$this->hier_id);
 
  951                 $ilTabs->setSubTabActive(
"cont_alignment");
 
  952                 $ilTabs->setTabActive(
"cont_table_cell_properties");
 
  955                 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  957                 $form->setFormAction($ilCtrl->getFormAction($this));
 
  958                 $form->setTitle($this->lng->txt(
"cont_table_cell_properties"));
 
  962                         "" => $lng->txt(
"default"),
 
  963                         "Left" => $lng->txt(
"cont_left"),
 
  964                         "Center" => $lng->txt(
"cont_center"),
 
  965                         "Right" => $lng->txt(
"cont_right")
 
  969                 $si->setInfo($lng->txt(
""));
 
  972                 $form->setKeepOpen(
true);
 
  974                 $form->addCommandButton(
"setAlignment", $lng->txt(
"cont_set_alignment"));
 
  976                 $html = $form->getHTML();
 
  977                 $html.= 
"<br />".$this->renderTable(
"table_edit", 
"alignment").
"</form>";
 
  978                 $tpl->setContent($html);
 
  989                 if (is_array(
$_POST[
"target"]))
 
  991                         foreach (
$_POST[
"target"] as $k => $value)
 
  995                                         $cid = explode(
":", $k);
 
 1001                 $this->updated = $this->pg_obj->update();
 
 1004                 $this->ctrl->redirect($this, 
"editCellAlignment");