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