00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once("./content/classes/Pages/class.ilPCTable.php");
00025 require_once("./content/classes/Pages/class.ilPageContentGUI.php");
00026
00037 class ilPCTableGUI extends ilPageContentGUI
00038 {
00039
00044 function ilPCTableGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id)
00045 {
00046 parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id);
00047 }
00048
00052 function &executeCommand()
00053 {
00054
00055 $next_class = $this->ctrl->getNextClass($this);
00056
00057
00058 $cmd = $this->ctrl->getCmd();
00059
00060 switch($next_class)
00061 {
00062 default:
00063 $ret =& $this->$cmd();
00064 break;
00065 }
00066
00067 return $ret;
00068 }
00069
00070
00074 function edit()
00075 {
00076
00077 $this->setTabs();
00078
00079
00080 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.table_properties.html", "content");
00081 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_tab_properties"));
00082 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00083
00084 $this->displayValidationError();
00085
00086
00087 $this->tpl->setVariable("TXT_TABLE", $this->lng->txt("cont_table"));
00088 $this->tpl->setVariable("INPUT_TD_WIDTH", "td_width");
00089 $this->tpl->setVariable("BTN_WIDTH", "setWidth");
00090 $this->tpl->setVariable("BTN_TXT_WIDTH", $this->lng->txt("cont_set_width"));
00091
00092 $select_class = ilUtil::formSelect ("","td_class",
00093 array("" => $this->lng->txt("none"), "ilc_Cell1" => "Cell1", "ilc_Cell2" => "Cell2",
00094 "ilc_Cell3" => "Cell3", "ilc_Cell4" => "Cell4"),false,true);
00095 $this->tpl->setVariable("SELECT_CLASS", $select_class);
00096 $this->tpl->setVariable("BTN_CLASS", "setClass");
00097 $this->tpl->setVariable("BTN_TXT_CLASS", $this->lng->txt("cont_set_class"));
00098 $tab_node = $this->content_obj->getNode();
00099 $content = $this->dom->dump_node($tab_node);
00100
00101 $trans =& $this->pg_obj->getLanguageVariablesXML();
00102 $content = "<dummy>".$content.$trans."</dummy>";
00103
00104 $xsl = file_get_contents("./content/page.xsl");
00105 $args = array( '/_xml' => $content, '/_xsl' => $xsl );
00106 $xh = xslt_create();
00107
00108
00109 $med_disabled_path = ilUtil::getImagePath("media_disabled.gif");
00110 $params = array ('mode' => 'table_edit', 'med_disabled_path' => $med_disabled_path);
00111 $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
00112 echo xslt_error($xh);
00113 xslt_free($xh);
00114
00115
00116 $output = str_replace("<","<",$output);
00117 $output = str_replace(">",">",$output);
00118
00119 $this->tpl->setVariable("CONT_TABLE", $output);
00120
00121
00122
00123 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00124 $lang = ilMetaData::getLanguages();
00125 $select_lang = ilUtil::formSelect ($this->content_obj->getLanguage(),"tab_language",$lang,false,true);
00126 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00127
00128
00129 $this->tpl->setVariable("TXT_TABLE_WIDTH", $this->lng->txt("cont_table_width"));
00130 $this->tpl->setVariable("INPUT_TABLE_WIDTH", "tab_width");
00131 $this->tpl->setVariable("VAL_TABLE_WIDTH", $this->content_obj->getWidth());
00132
00133
00134 $this->tpl->setVariable("TXT_TABLE_BORDER", $this->lng->txt("cont_table_border"));
00135 $this->tpl->setVariable("INPUT_TABLE_BORDER", "tab_border");
00136 $this->tpl->setVariable("VAL_TABLE_BORDER", $this->content_obj->getBorder());
00137
00138
00139 $this->tpl->setVariable("TXT_TABLE_PADDING", $this->lng->txt("cont_table_cellpadding"));
00140 $this->tpl->setVariable("INPUT_TABLE_PADDING", "tab_padding");
00141 $this->tpl->setVariable("VAL_TABLE_PADDING", $this->content_obj->getCellPadding());
00142
00143
00144 $this->tpl->setVariable("TXT_TABLE_SPACING", $this->lng->txt("cont_table_cellspacing"));
00145 $this->tpl->setVariable("INPUT_TABLE_SPACING", "tab_spacing");
00146 $this->tpl->setVariable("VAL_TABLE_SPACING", $this->content_obj->getCellSpacing());
00147
00148
00149 $this->tpl->setVariable("TXT_CAPTION", $this->lng->txt("cont_caption"));
00150 $this->tpl->setVariable("INPUT_CAPTION", "tab_caption");
00151 $this->tpl->setVariable("VAL_CAPTION", $this->content_obj->getCaption());
00152 $select_align = ilUtil::formSelect ($this->content_obj->getCaptionAlign(),"tab_cap_align",
00153 array("top" => $this->lng->txt("cont_top"), "bottom" => $this->lng->txt("cont_bottom")),false,true);
00154 $this->tpl->setVariable("SELECT_CAPTION", $select_align);
00155
00156 $this->tpl->parseCurrentBlock();
00157
00158
00159 $this->tpl->setCurrentBlock("commands");
00160 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00161 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00162 $this->tpl->parseCurrentBlock();
00163
00164 }
00165
00169 function setWidth()
00170 {
00171 if (is_array($_POST["target"]))
00172 {
00173 foreach ($_POST["target"] as $hier_id)
00174 {
00175 $this->content_obj->setTDWidth($hier_id, $_POST["td_width"]);
00176 }
00177 }
00178 $this->updated = $this->pg_obj->update();
00179 $this->pg_obj->addHierIDs();
00180 $this->edit();
00181 }
00182
00186 function setClass()
00187 {
00188 if (is_array($_POST["target"]))
00189 {
00190 foreach ($_POST["target"] as $hier_id)
00191 {
00192 $this->content_obj->setTDClass($hier_id, $_POST["td_class"]);
00193 }
00194 }
00195 $this->updated = $this->pg_obj->update();
00196 $this->pg_obj->addHierIDs();
00197 $this->edit();
00198 }
00199
00203 function saveProperties()
00204 {
00205 $this->content_obj->setLanguage($_POST["tab_language"]);
00206 $this->content_obj->setWidth($_POST["tab_width"]);
00207 $this->content_obj->setBorder($_POST["tab_border"]);
00208 $this->content_obj->setCellSpacing($_POST["tab_spacing"]);
00209 $this->content_obj->setCellPadding($_POST["tab_padding"]);
00210 $this->content_obj->setCaption($_POST["tab_caption"], $_POST["tab_cap_align"]);
00211 $this->updated = $this->pg_obj->update();
00212 if ($this->updated === true)
00213 {
00214 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00215 }
00216 else
00217 {
00218 $this->pg_obj->addHierIDs();
00219 $this->edit();
00220 }
00221 }
00222
00226 function rightAlign()
00227 {
00228 $this->content_obj->setHorizontalAlign("Right");
00229 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00230 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00231 }
00232
00236 function leftAlign()
00237 {
00238 $this->content_obj->setHorizontalAlign("Left");
00239 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00240 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00241 }
00242
00246 function centerAlign()
00247 {
00248 $this->content_obj->setHorizontalAlign("Center");
00249 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00250 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00251 }
00252
00256 function leftFloatAlign()
00257 {
00258 $this->content_obj->setHorizontalAlign("LeftFloat");
00259 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00260 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00261 }
00262
00266 function rightFloatAlign()
00267 {
00268 $this->content_obj->setHorizontalAlign("RightFloat");
00269 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00270 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00271 }
00272
00276 function insert()
00277 {
00278 global $ilUser;
00279
00280 $this->setTabs();
00281
00282
00283 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.table_new.html", "content");
00284 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_table"));
00285 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00286
00287 $this->displayValidationError();
00288
00289 for($i=1; $i<=10; $i++)
00290 {
00291 $nr[$i] = $i;
00292 }
00293
00294 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00295 {
00296 $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00297 }
00298 else
00299 {
00300 $s_lang = $ilUser->getLanguage();
00301 }
00302
00303
00304 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00305 $lang = ilMetaData::getLanguages();
00306 $select_language = ilUtil::formSelect ($s_lang, "tab_language", $lang, false, true);
00307 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00308 $this->tpl->setVariable("TXT_COLS", $this->lng->txt("cont_nr_cols"));
00309 $select_cols = ilUtil::formSelect ("2","nr_cols",$nr,false,true);
00310 $this->tpl->setVariable("SELECT_COLS", $select_cols);
00311 $this->tpl->setVariable("TXT_ROWS", $this->lng->txt("cont_nr_rows"));
00312 $select_rows = ilUtil::formSelect ("2","nr_rows",$nr,false,true);
00313 $this->tpl->setVariable("SELECT_ROWS", $select_rows);
00314
00315
00316 $this->tpl->setVariable("TXT_HTML_IMPORT", $this->lng->txt("cont_table_html_import"));
00317 $this->tpl->setVariable("TXT_BTN_HTML_IMPORT", $this->lng->txt("import"));
00318 $this->tpl->setVariable("TXT_HTML_IMPORT_INFO", $this->lng->txt("cont_table_html_import_info"));
00319 $this->tpl->setVariable("CMD_HTML_IMPORT", "create_tab");
00320 $this->tpl->setVariable("SELECT_ROWS", $select_rows);
00321
00322 $this->tpl->parseCurrentBlock();
00323
00324
00325 $this->tpl->setCurrentBlock("commands");
00326 $this->tpl->setVariable("BTN_NAME", "create_tab");
00327 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00328 $this->tpl->parseCurrentBlock();
00329
00330 }
00331
00332
00336 function create()
00337 {
00338 global $lng;
00339 $this->content_obj = new ilPCTable($this->dom);
00340 $this->content_obj->create($this->pg_obj, $this->hier_id);
00341 $this->content_obj->setLanguage($_POST["tab_language"]);
00342 $html = trim($_POST["htmltable"]);
00343
00344 if (!empty ($html)) {
00345 if (!$this->content_obj->importHtml ($_POST["tab_language"], $html)) {
00346 $this->insert();
00347 return;
00348 }
00349 } else {
00350 $this->content_obj->addRows($_POST["nr_rows"], $_POST["nr_cols"]);
00351 }
00352
00353 $this->updated = $this->pg_obj->update();
00354
00355 if ($this->updated === true)
00356 {
00357 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00358 }
00359 else
00360 {
00361 $this->insert();
00362 }
00363 }
00364
00368 function setTabs()
00369 {
00370
00371 include_once("classes/class.ilTabsGUI.php");
00372 $tabs_gui =& new ilTabsGUI();
00373 $this->getTabs($tabs_gui);
00374 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00375 }
00376
00382 function getTabs(&$tabs_gui)
00383 {
00384
00385 $tabs_gui->addTarget("cont_back",
00386 $this->ctrl->getParentReturn($this), "",
00387 "");
00388 }
00389
00390 }
00391 ?>