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->setVariable("BTN_CANCEL", "cancelUpdate");
00167 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00168 $this->tpl->parseCurrentBlock();
00169
00170 }
00171
00175 function setWidth()
00176 {
00177 if (is_array($_POST["target"]))
00178 {
00179 foreach ($_POST["target"] as $hier_id)
00180 {
00181 $this->content_obj->setTDWidth($hier_id, $_POST["td_width"]);
00182 }
00183 }
00184 $this->setProperties();
00185 $this->updated = $this->pg_obj->update();
00186 $this->pg_obj->addHierIDs();
00187 $this->edit();
00188 }
00189
00193 function setClass()
00194 {
00195 if (is_array($_POST["target"]))
00196 {
00197 foreach ($_POST["target"] as $hier_id)
00198 {
00199 $this->content_obj->setTDClass($hier_id, $_POST["td_class"]);
00200 }
00201 }
00202 $this->setProperties();
00203 $this->updated = $this->pg_obj->update();
00204 $this->pg_obj->addHierIDs();
00205 $this->edit();
00206 }
00207
00208
00209 function setProperties()
00210 {
00211
00212 $caption = $_POST["tab_caption"];
00213 $caption = str_replace("&","&", $caption);
00214 $caption = str_replace("<","<", $caption);
00215 $caption = str_replace(">",">", $caption);
00216
00217 $this->content_obj->setLanguage($_POST["tab_language"]);
00218 $this->content_obj->setWidth($_POST["tab_width"]);
00219 $this->content_obj->setBorder($_POST["tab_border"]);
00220 $this->content_obj->setCellSpacing($_POST["tab_spacing"]);
00221 $this->content_obj->setCellPadding($_POST["tab_padding"]);
00222 $this->content_obj->setCaption($caption, $_POST["tab_cap_align"]);
00223 }
00224
00228 function saveProperties()
00229 {
00230 $this->setProperties();
00231 $this->updated = $this->pg_obj->update();
00232 if ($this->updated === true)
00233 {
00234 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00235 }
00236 else
00237 {
00238 $this->pg_obj->addHierIDs();
00239 $this->edit();
00240 }
00241 }
00242
00246 function rightAlign()
00247 {
00248 $this->content_obj->setHorizontalAlign("Right");
00249 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00250 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00251 }
00252
00256 function leftAlign()
00257 {
00258 $this->content_obj->setHorizontalAlign("Left");
00259 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00260 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00261 }
00262
00266 function centerAlign()
00267 {
00268 $this->content_obj->setHorizontalAlign("Center");
00269 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00270 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00271 }
00272
00276 function leftFloatAlign()
00277 {
00278 $this->content_obj->setHorizontalAlign("LeftFloat");
00279 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00280 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00281 }
00282
00286 function rightFloatAlign()
00287 {
00288 $this->content_obj->setHorizontalAlign("RightFloat");
00289 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00290 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00291 }
00292
00296 function insert()
00297 {
00298 global $ilUser;
00299
00300 $this->setTabs();
00301
00302
00303 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.table_new.html", "content");
00304 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_table"));
00305 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00306
00307 $this->displayValidationError();
00308
00309 for($i=1; $i<=10; $i++)
00310 {
00311 $nr[$i] = $i;
00312 }
00313
00314 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00315 {
00316 $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00317 }
00318 else
00319 {
00320 $s_lang = $ilUser->getLanguage();
00321 }
00322
00323
00324 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00325 $lang = ilMetaData::getLanguages();
00326 $select_language = ilUtil::formSelect ($s_lang, "tab_language", $lang, false, true);
00327 $this->tpl->setVariable("SELECT_LANGUAGE", $select_language);
00328 $this->tpl->setVariable("TXT_COLS", $this->lng->txt("cont_nr_cols"));
00329 $select_cols = ilUtil::formSelect ("2","nr_cols",$nr,false,true);
00330 $this->tpl->setVariable("SELECT_COLS", $select_cols);
00331 $this->tpl->setVariable("TXT_ROWS", $this->lng->txt("cont_nr_rows"));
00332 $select_rows = ilUtil::formSelect ("2","nr_rows",$nr,false,true);
00333 $this->tpl->setVariable("SELECT_ROWS", $select_rows);
00334
00335
00336 $this->tpl->setVariable("TXT_HTML_IMPORT", $this->lng->txt("cont_table_html_import"));
00337 $this->tpl->setVariable("TXT_SPREADSHEET", $this->lng->txt("cont_table_spreadsheet_import"));
00338 $this->tpl->setVariable("TXT_BTN_HTML_IMPORT", $this->lng->txt("import"));
00339 $this->tpl->setVariable("TXT_HTML_IMPORT_INFO", $this->lng->txt("cont_table_html_import_info"));
00340 $this->tpl->setVariable("TXT_SPREADSHEET_IMPORT_INFO", $this->lng->txt("cont_table_spreadsheet_import_info"));
00341 $this->tpl->setVariable("CMD_HTML_IMPORT", "create_tab");
00342 $this->tpl->setVariable("SELECT_ROWS", $select_rows);
00343
00344 $this->tpl->parseCurrentBlock();
00345
00346
00347 $this->tpl->setCurrentBlock("commands");
00348 $this->tpl->setVariable("BTN_NAME", "create_tab");
00349 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00350 $this->tpl->setVariable("BTN_CANCEL", "cancelCreate");
00351 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00352 $this->tpl->parseCurrentBlock();
00353
00354 }
00355
00356
00360 function create()
00361 {
00362 global $lng;
00363 $this->content_obj = new ilPCTable($this->dom);
00364 $this->content_obj->create($this->pg_obj, $this->hier_id);
00365 $this->content_obj->setLanguage($_POST["tab_language"]);
00366 $import_table = trim($_POST["import_table"]);
00367
00368
00369 if (!empty ($import_table))
00370 {
00371 switch($_POST["import_type"])
00372 {
00373
00374 case "html":
00375 if (!$this->content_obj->importHtml ($_POST["tab_language"], $import_table))
00376 {
00377 $this->insert();
00378 return;
00379 }
00380 break;
00381
00382
00383 case "spreadsheet":
00384 $this->content_obj->importSpreadsheet($_POST["tab_language"], $import_table);
00385 break;
00386 }
00387 }
00388 else
00389 {
00390 $this->content_obj->addRows($_POST["nr_rows"], $_POST["nr_cols"]);
00391 }
00392
00393 $this->updated = $this->pg_obj->update();
00394
00395 if ($this->updated === true)
00396 {
00397 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00398 }
00399 else
00400 {
00401 $this->insert();
00402 }
00403 }
00404
00408 function setTabs()
00409 {
00410 global $ilTabs;
00411
00412
00413 #include_once("classes/class.ilTabsGUI.php");
00414 #$tabs_gui =& new ilTabsGUI();
00415 $this->getTabs($ilTabs);
00416 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00417 }
00418
00424 function getTabs(&$tabs_gui)
00425 {
00426
00427
00428
00429
00430
00431
00432 }
00433
00434 }
00435 ?>