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 $output = str_replace("&","&",$output);
00119
00120
00121 $this->tpl->setVariable("CONT_TABLE", $output);
00122
00123
00124
00125 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00126 $lang = ilMetaData::getLanguages();
00127 $select_lang = ilUtil::formSelect ($this->content_obj->getLanguage(),"tab_language",$lang,false,true);
00128 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00129
00130
00131 $this->tpl->setVariable("TXT_TABLE_WIDTH", $this->lng->txt("cont_table_width"));
00132 $this->tpl->setVariable("INPUT_TABLE_WIDTH", "tab_width");
00133 $this->tpl->setVariable("VAL_TABLE_WIDTH", $this->content_obj->getWidth());
00134
00135
00136 $this->tpl->setVariable("TXT_TABLE_BORDER", $this->lng->txt("cont_table_border"));
00137 $this->tpl->setVariable("INPUT_TABLE_BORDER", "tab_border");
00138 $this->tpl->setVariable("VAL_TABLE_BORDER", $this->content_obj->getBorder());
00139
00140
00141 $this->tpl->setVariable("TXT_TABLE_PADDING", $this->lng->txt("cont_table_cellpadding"));
00142 $this->tpl->setVariable("INPUT_TABLE_PADDING", "tab_padding");
00143 $this->tpl->setVariable("VAL_TABLE_PADDING", $this->content_obj->getCellPadding());
00144
00145
00146 $this->tpl->setVariable("TXT_TABLE_SPACING", $this->lng->txt("cont_table_cellspacing"));
00147 $this->tpl->setVariable("INPUT_TABLE_SPACING", "tab_spacing");
00148 $this->tpl->setVariable("VAL_TABLE_SPACING", $this->content_obj->getCellSpacing());
00149
00150
00151 $caption = $this->content_obj->getCaption();
00152 $caption = str_replace("&", "&", $caption);
00153 $this->tpl->setVariable("TXT_CAPTION", $this->lng->txt("cont_caption"));
00154 $this->tpl->setVariable("INPUT_CAPTION", "tab_caption");
00155 $this->tpl->setVariable("VAL_CAPTION", $caption);
00156 $select_align = ilUtil::formSelect ($this->content_obj->getCaptionAlign(),"tab_cap_align",
00157 array("top" => $this->lng->txt("cont_top"), "bottom" => $this->lng->txt("cont_bottom")),false,true);
00158 $this->tpl->setVariable("SELECT_CAPTION", $select_align);
00159
00160 $this->tpl->parseCurrentBlock();
00161
00162
00163 $this->tpl->setCurrentBlock("commands");
00164 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00165 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00166 $this->tpl->parseCurrentBlock();
00167
00168 }
00169
00173 function setWidth()
00174 {
00175 if (is_array($_POST["target"]))
00176 {
00177 foreach ($_POST["target"] as $hier_id)
00178 {
00179 $this->content_obj->setTDWidth($hier_id, $_POST["td_width"]);
00180 }
00181 }
00182 $this->updated = $this->pg_obj->update();
00183 $this->pg_obj->addHierIDs();
00184 $this->edit();
00185 }
00186
00190 function setClass()
00191 {
00192 if (is_array($_POST["target"]))
00193 {
00194 foreach ($_POST["target"] as $hier_id)
00195 {
00196 $this->content_obj->setTDClass($hier_id, $_POST["td_class"]);
00197 }
00198 }
00199 $this->updated = $this->pg_obj->update();
00200 $this->pg_obj->addHierIDs();
00201 $this->edit();
00202 }
00203
00207 function saveProperties()
00208 {
00209
00210 $caption = $_POST["tab_caption"];
00211 $caption = str_replace("&","&", $caption);
00212 $caption = str_replace("<","<", $caption);
00213 $caption = str_replace(">",">", $caption);
00214
00215 $this->content_obj->setLanguage($_POST["tab_language"]);
00216 $this->content_obj->setWidth($_POST["tab_width"]);
00217 $this->content_obj->setBorder($_POST["tab_border"]);
00218 $this->content_obj->setCellSpacing($_POST["tab_spacing"]);
00219 $this->content_obj->setCellPadding($_POST["tab_padding"]);
00220 $this->content_obj->setCaption($caption, $_POST["tab_cap_align"]);
00221 $this->updated = $this->pg_obj->update();
00222 if ($this->updated === true)
00223 {
00224 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00225 }
00226 else
00227 {
00228 $this->pg_obj->addHierIDs();
00229 $this->edit();
00230 }
00231 }
00232
00236 function rightAlign()
00237 {
00238 $this->content_obj->setHorizontalAlign("Right");
00239 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00240 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00241 }
00242
00246 function leftAlign()
00247 {
00248 $this->content_obj->setHorizontalAlign("Left");
00249 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00250 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00251 }
00252
00256 function centerAlign()
00257 {
00258 $this->content_obj->setHorizontalAlign("Center");
00259 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00260 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00261 }
00262
00266 function leftFloatAlign()
00267 {
00268 $this->content_obj->setHorizontalAlign("LeftFloat");
00269 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00270 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00271 }
00272
00276 function rightFloatAlign()
00277 {
00278 $this->content_obj->setHorizontalAlign("RightFloat");
00279 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00280 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00281 }
00282
00286 function insert()
00287 {
00288 global $ilUser;
00289
00290 $this->setTabs();
00291
00292
00293 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.table_new.html", "content");
00294 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_table"));
00295 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00296
00297 $this->displayValidationError();
00298
00299 for($i=1; $i<=10; $i++)
00300 {
00301 $nr[$i] = $i;
00302 }
00303
00304 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00305 {
00306 $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00307 }
00308 else
00309 {
00310 $s_lang = $ilUser->getLanguage();
00311 }
00312
00313
00314 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00315 $lang = ilMetaData::getLanguages();
00316 $select_language = ilUtil::formSelect ($s_lang, "tab_language", $lang, false, true);
00317 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00318 $this->tpl->setVariable("TXT_COLS", $this->lng->txt("cont_nr_cols"));
00319 $select_cols = ilUtil::formSelect ("2","nr_cols",$nr,false,true);
00320 $this->tpl->setVariable("SELECT_COLS", $select_cols);
00321 $this->tpl->setVariable("TXT_ROWS", $this->lng->txt("cont_nr_rows"));
00322 $select_rows = ilUtil::formSelect ("2","nr_rows",$nr,false,true);
00323 $this->tpl->setVariable("SELECT_ROWS", $select_rows);
00324
00325
00326 $this->tpl->setVariable("TXT_HTML_IMPORT", $this->lng->txt("cont_table_html_import"));
00327 $this->tpl->setVariable("TXT_SPREADSHEET", $this->lng->txt("cont_table_spreadsheet_import"));
00328 $this->tpl->setVariable("TXT_BTN_HTML_IMPORT", $this->lng->txt("import"));
00329 $this->tpl->setVariable("TXT_HTML_IMPORT_INFO", $this->lng->txt("cont_table_html_import_info"));
00330 $this->tpl->setVariable("TXT_SPREADSHEET_IMPORT_INFO", $this->lng->txt("cont_table_spreadsheet_import_info"));
00331 $this->tpl->setVariable("CMD_HTML_IMPORT", "create_tab");
00332 $this->tpl->setVariable("SELECT_ROWS", $select_rows);
00333
00334 $this->tpl->parseCurrentBlock();
00335
00336
00337 $this->tpl->setCurrentBlock("commands");
00338 $this->tpl->setVariable("BTN_NAME", "create_tab");
00339 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00340 $this->tpl->parseCurrentBlock();
00341
00342 }
00343
00344
00348 function create()
00349 {
00350 global $lng;
00351 $this->content_obj = new ilPCTable($this->dom);
00352 $this->content_obj->create($this->pg_obj, $this->hier_id);
00353 $this->content_obj->setLanguage($_POST["tab_language"]);
00354 $import_table = trim($_POST["import_table"]);
00355
00356
00357 if (!empty ($import_table))
00358 {
00359 switch($_POST["import_type"])
00360 {
00361
00362 case "html":
00363 if (!$this->content_obj->importHtml ($_POST["tab_language"], $import_table))
00364 {
00365 $this->insert();
00366 return;
00367 }
00368 break;
00369
00370
00371 case "spreadsheet":
00372 $this->content_obj->importSpreadsheet($_POST["tab_language"], $import_table);
00373 break;
00374 }
00375 }
00376 else
00377 {
00378 $this->content_obj->addRows($_POST["nr_rows"], $_POST["nr_cols"]);
00379 }
00380
00381 $this->updated = $this->pg_obj->update();
00382
00383 if ($this->updated === true)
00384 {
00385 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00386 }
00387 else
00388 {
00389 $this->insert();
00390 }
00391 }
00392
00396 function setTabs()
00397 {
00398
00399 include_once("classes/class.ilTabsGUI.php");
00400 $tabs_gui =& new ilTabsGUI();
00401 $this->getTabs($tabs_gui);
00402 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00403 }
00404
00410 function getTabs(&$tabs_gui)
00411 {
00412
00413 $tabs_gui->addTarget("cont_back",
00414 $this->ctrl->getParentReturn($this), "",
00415 "");
00416 }
00417
00418 }
00419 ?>