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.ilPCParagraph.php");
00025 require_once("./content/classes/Pages/class.ilPageContentGUI.php");
00026 require_once("./content/classes/Pages/class.ilWysiwygUtil.php");
00027
00038 class ilPCParagraphGUI extends ilPageContentGUI
00039 {
00040
00045 function ilPCParagraphGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id)
00046 {
00047 parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id);
00048 }
00049
00050
00054 function &executeCommand()
00055 {
00056
00057 $next_class = $this->ctrl->getNextClass($this);
00058
00059
00060 $cmd = $this->ctrl->getCmd();
00061
00062 switch($next_class)
00063 {
00064 default:
00065 $ret =& $this->$cmd();
00066 break;
00067 }
00068
00069 return $ret;
00070 }
00071
00075 function edit()
00076 {
00077 global $ilUser, $ilias;
00078
00079
00080 $this->setTabs();
00081
00082 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paragraph_edit.html", "content");
00083
00084
00085 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_par"));
00086 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00087 $this->tpl->setVariable("REF_ID", $_GET["ref_id"]);
00088
00089 $this->tpl->setVariable("EDITOR_URL", ILIAS_HTTP_PATH."/content/htmlarea/");
00090 $this->tpl->setVariable("JS_HTMLAREA", ILIAS_HTTP_PATH."/content/htmlarea/htmlarea.js");
00091 $this->tpl->setVariable("JS_HANDLETAGS", ILIAS_HTTP_PATH."/content/js/handletags.js");
00092 $this->ctrl->setParameter($this, "ptype", "footnote");
00093 $this->tpl->setVariable("POPUP_TARGET_FOOTNOTE",
00094 $this->ctrl->getLinkTarget($this, "popup"));
00095 $this->ctrl->setParameter($this, "ptype", "xtl");
00096 $this->tpl->setVariable("POPUP_TARGET_XTL",
00097 $this->ctrl->getLinkTarget($this, "popup"));
00098
00099 $this->tpl->setVariable("TXT_STR", $this->lng->txt("cont_text_str"));
00100 $this->tpl->setVariable("TXT_EMP", $this->lng->txt("cont_text_emp"));
00101 $this->tpl->setVariable("TXT_COM", $this->lng->txt("cont_text_com"));
00102 $this->tpl->setVariable("TXT_FN", $this->lng->txt("cont_text_fn"));
00103 $this->tpl->setVariable("TXT_QUOT", $this->lng->txt("cont_text_quot"));
00104 $this->tpl->setVariable("TXT_CODE", $this->lng->txt("cont_text_code"));
00105 $this->tpl->setVariable("TXT_ILN", $this->lng->txt("cont_text_iln"));
00106 $this->tpl->setVariable("TXT_XLN", $this->lng->txt("cont_text_xln"));
00107 $this->tpl->setVariable("TXT_TEX", $this->lng->txt("cont_text_tex"));
00108
00109 include_once("./classes/class.ilObjStyleSheet.php");
00110
00111 if ($this->pg_obj->getParentType() == "gdf" ||
00112 $this->pg_obj->getParentType() == "lm" ||
00113 $this->pg_obj->getParentType() == "dbk")
00114 {
00115 $this->tpl->setVariable("TXT_FORMATERROR",$this->lng->txt("cont_format_error"));
00116
00117 $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00118 ilUtil::getStyleSheetLocation());
00119
00120 if ($this->pg_obj->getParentType() != "gdf")
00121 {
00122 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00123 ilObjStyleSheet::getContentStylePath(
00124 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00125 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00126 ilObjStyleSheet::getContentStylePath(
00127 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00128 }
00129 else
00130 {
00131 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00132 ilObjStyleSheet::getContentStylePath(0));
00133 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00134 ilObjStyleSheet::getContentStylePath(0));
00135 }
00136
00137 if (!ilPageEditorGUI::_doJSEditing())
00138 {
00139 $this->tpl->setCurrentBlock("bb_ilink_button");
00140 $this->tpl->setVariable("BB_LINK_ILINK",
00141 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00142 $this->tpl->setVariable("BB_TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00143 $this->tpl->setCurrentBlock("bb_buttons");
00144 $this->tpl->parseCurrentBlock();
00145 }
00146 else
00147 {
00148 $this->tpl->setVariable("LINK_ILINK",
00149 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00150 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00151 }
00152
00153 $this->tpl->setVariable("REMOVELINK",$this->lng->txt("cont_removeiln"));
00154
00155 $this->tpl->touchBlock("internal_link_active1");
00156 $this->tpl->touchBlock("internal_link_active2");
00157 }
00158 else
00159 {
00160 $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00161 ilUtil::getStyleSheetLocation());
00162 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00163 ilObjStyleSheet::getContentStylePath(0));
00164 if (!ilPageEditorGUI::_doJSEditing())
00165 {
00166 $this->tpl->touchBlock("bb_buttons");
00167 }
00168 }
00169
00170 $this->displayValidationError();
00171
00172
00173 if (key($_POST["cmd"]) == "update")
00174 {
00175 $s_lang = $_POST["par_language"];
00176 $s_char = $_POST["par_characteristic"];
00177 }
00178 else
00179 {
00180 $s_lang = $this->content_obj->getLanguage();
00181 $s_char = $this->content_obj->getCharacteristic();
00182 }
00183 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00184 require_once("classes/class.ilMetaData.php");
00185 $lang = ilMetaData::getLanguages();
00186 $select_lang = ilUtil::formSelect ($s_lang,"par_language",$lang,false,true);
00187 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00188 $char = array("" => $this->lng->txt("none"),
00189 "Headline1" => $this->lng->txt("cont_Headline1"),
00190 "Headline2" => $this->lng->txt("cont_Headline2"),
00191 "Headline3" => $this->lng->txt("cont_Headline3"),
00192 "Example" => $this->lng->txt("cont_Example"),
00193 "Citation" => $this->lng->txt("cont_Citation"),
00194 "Mnemonic" => $this->lng->txt("cont_Mnemonic"),
00195 "Additional" => $this->lng->txt("cont_Additional"),
00196 "List" => $this->lng->txt("cont_List"),
00197 "Remark" => $this->lng->txt("cont_Remark"),
00198
00199 "TableContent" => $this->lng->txt("cont_TableContent")
00200 );
00201 $this->tpl->setVariable("TXT_CHARACTERISTIC", $this->lng->txt("cont_characteristic"));
00202 $select_char = ilUtil::formSelect ($s_char,
00203 "par_characteristic",$char,false,true);
00204 $this->tpl->setVariable("SELECT_CHARACTERISTIC", $select_char);
00205
00206 if (key($_POST["cmd"]) == "update")
00207 {
00208 $s_text = ilUtil::stripSlashes($_POST["par_content"], false);
00209 }
00210 else
00211 {
00212 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
00213 }
00214 $this->tpl->setVariable("PAR_TA_NAME", "par_content");
00215
00216 if (ilPageEditorGUI::_doJSEditing())
00217 {
00218
00219
00220 $s_text = str_replace("&","&", $s_text);
00221
00222 $this->tpl->setVariable("PAR_TA_CONTENT", $s_text);
00223 $this->tpl->touchBlock("initwysiwygeditor");
00224 }
00225 else
00226 {
00227 $this->tpl->setVariable("PAR_TA_CONTENT", $s_text);
00228 }
00229
00230 $this->tpl->parseCurrentBlock();
00231
00232
00233 $this->tpl->setCurrentBlock("commands");
00234 $this->tpl->setVariable("BTN_NAME", "update");
00235 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00236 $this->tpl->setVariable("BTN_CANCEL", "cancelUpdate");
00237 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00238 $this->tpl->parseCurrentBlock();
00239
00240 }
00241
00242
00246 function insert()
00247 {
00248 global $ilUser;
00249
00250
00251 $this->setTabs();
00252
00253
00254 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paragraph_edit.html", "content");
00255 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_par"));
00256 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00257 $this->tpl->setVariable("REF_ID", $_GET["ref_id"]);
00258
00259 $this->tpl->setVariable("EDITOR_URL", ILIAS_HTTP_PATH."/content/htmlarea/");
00260 $this->tpl->setVariable("JS_HTMLAREA", ILIAS_HTTP_PATH."/content/htmlarea/htmlarea.js");
00261 $this->tpl->setVariable("JS_HANDLETAGS", ILIAS_HTTP_PATH."/content/js/handletags.js");
00262 $this->ctrl->setParameter($this, "ptype", "footnote");
00263 $this->tpl->setVariable("POPUP_TARGET_FOOTNOTE",
00264 $this->ctrl->getLinkTarget($this, "popup"));
00265 $this->ctrl->setParameter($this, "ptype", "xtl");
00266 $this->tpl->setVariable("POPUP_TARGET_XTL",
00267 $this->ctrl->getLinkTarget($this, "popup"));
00268
00269 $this->tpl->setVariable("TXT_STR", $this->lng->txt("cont_text_str"));
00270 $this->tpl->setVariable("TXT_EMP", $this->lng->txt("cont_text_emp"));
00271 $this->tpl->setVariable("TXT_COM", $this->lng->txt("cont_text_com"));
00272 $this->tpl->setVariable("TXT_FN", $this->lng->txt("cont_text_fn"));
00273 $this->tpl->setVariable("TXT_QUOT", $this->lng->txt("cont_text_quot"));
00274 $this->tpl->setVariable("TXT_CODE", $this->lng->txt("cont_text_code"));
00275 $this->tpl->setVariable("TXT_ILN", $this->lng->txt("cont_text_iln"));
00276 $this->tpl->setVariable("TXT_XLN", $this->lng->txt("cont_text_xln"));
00277 $this->tpl->setVariable("TXT_TEX", $this->lng->txt("cont_text_tex"));
00278
00279 include_once("./classes/class.ilObjStyleSheet.php");
00280
00281 if ($this->pg_obj->getParentType() == "gdf" ||
00282 $this->pg_obj->getParentType() == "lm" ||
00283 $this->pg_obj->getParentType() == "dbk")
00284 {
00285 $this->tpl->setVariable("TXT_FORMATERROR",$this->lng->txt("cont_format_error"));
00286
00287 if ($this->pg_obj->getParentType() != "gdf")
00288 {
00289 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00290 ilObjStyleSheet::getContentStylePath(
00291 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00292 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00293 ilObjStyleSheet::getContentStylePath(
00294 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00295 }
00296 else
00297 {
00298 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00299 ilObjStyleSheet::getContentStylePath(0));
00300 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00301 ilObjStyleSheet::getContentStylePath(0));
00302 }
00303
00304 $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00305 ilUtil::getStyleSheetLocation());
00306
00307 if (!ilPageEditorGUI::_doJSEditing())
00308 {
00309 $this->tpl->setCurrentBlock("bb_ilink_button");
00310 $this->tpl->setVariable("BB_LINK_ILINK",
00311 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00312 $this->tpl->setVariable("BB_TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00313 $this->tpl->parseCurrentBlock();
00314 $this->tpl->setCurrentBlock("bb_buttons");
00315 $this->tpl->parseCurrentBlock();
00316 }
00317 else
00318 {
00319 $this->tpl->setVariable("LINK_ILINK",
00320 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00321 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00322 }
00323
00324 $this->tpl->touchBlock("internal_link_active1");
00325 $this->tpl->touchBlock("internal_link_active2");
00326 }
00327 else
00328 {
00329 $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00330 ilUtil::getStyleSheetLocation());
00331 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00332 ilObjStyleSheet::getContentStylePath(0));
00333 if (!ilPageEditorGUI::_doJSEditing())
00334 {
00335 $this->tpl->touchBlock("bb_buttons");
00336 }
00337 }
00338
00339 $this->displayValidationError();
00340
00341
00342 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00343 require_once("classes/class.ilMetaData.php");
00344 $lang = ilMetaData::getLanguages();
00345
00346
00347
00348 if (key($_POST["cmd"]) == "create_par")
00349 {
00350 $s_lang = $_POST["par_language"];
00351 $s_char = $_POST["par_characteristic"];
00352 }
00353 else
00354 {
00355 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00356 {
00357 $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00358 }
00359 else
00360 {
00361 $s_lang = $ilUser->getLanguage();
00362 }
00363
00364
00365 $cont_obj =& $this->pg_obj->getContentObject($this->getHierId());
00366 if (is_object($cont_obj))
00367 {
00368 if ($cont_obj->getType() == "li" ||
00369 ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "List"))
00370 {
00371 $s_char = "List";
00372 }
00373
00374 if ($cont_obj->getType() == "td" ||
00375 ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "TableContent"))
00376 {
00377 $s_char = "TableContent";
00378 }
00379
00380 }
00381 }
00382
00383 require_once("classes/class.ilMetaData.php");
00384 $lang = ilMetaData::getLanguages();
00385 $select_lang = ilUtil::formSelect ($s_lang,"par_language",$lang,false,true);
00386 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00387 $char = array("" => $this->lng->txt("none"),
00388 "Headline1" => $this->lng->txt("cont_Headline1"),
00389 "Headline2" => $this->lng->txt("cont_Headline2"),
00390 "Headline3" => $this->lng->txt("cont_Headline3"),
00391 "Example" => $this->lng->txt("cont_Example"),
00392 "Citation" => $this->lng->txt("cont_Citation"),
00393 "Mnemonic" => $this->lng->txt("cont_Mnemonic"),
00394 "Additional" => $this->lng->txt("cont_Additional"),
00395 "List" => $this->lng->txt("cont_List"),
00396 "Remark" => $this->lng->txt("cont_Remark"),
00397
00398 "TableContent" => $this->lng->txt("cont_TableContent")
00399 );
00400 $this->tpl->setVariable("TXT_CHARACTERISTIC", $this->lng->txt("cont_characteristic"));
00401 $select_char = ilUtil::formSelect ($s_char,
00402 "par_characteristic",$char,false,true);
00403 $this->tpl->setVariable("SELECT_CHARACTERISTIC", $select_char);
00404
00405
00406
00407
00408
00409 $this->tpl->setVariable("PAR_TA_NAME", "par_content");
00410 if (key($_POST["cmd"]) == "create_par")
00411 {
00412 $this->tpl->setVariable("PAR_TA_CONTENT",
00413 ilUtil::stripSlashes($_POST["par_content"], false));
00414 }
00415 else
00416 {
00417 $this->tpl->setVariable("PAR_TA_CONTENT", "");
00418 }
00419 $this->tpl->parseCurrentBlock();
00420
00421 if (ilPageEditorGUI::_doJSEditing())
00422 {
00423 $this->tpl->touchBlock("initwysiwygeditor");
00424 }
00425
00426
00427 $this->tpl->setCurrentBlock("commands");
00428 $this->tpl->setVariable("BTN_NAME", "create_par");
00429 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00430 $this->tpl->setVariable("BTN_CANCEL", "cancelCreate");
00431 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00432 $this->tpl->parseCurrentBlock();
00433
00434 }
00435
00436
00437
00441 function update()
00442 {
00443 global $ilBench;
00444
00445 $ilBench->start("Editor","Paragraph_update");
00446
00447 $this->content_obj->setLanguage($_POST["par_language"]);
00448 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458 $this->updated = $this->content_obj->setText(
00459 $this->content_obj->input2xml($_POST["par_content"],
00460 $_POST["usedwsiwygeditor"]));
00461
00462 if ($this->updated !== true)
00463 {
00464 $ilBench->stop("Editor","Paragraph_update");
00465 $this->edit();
00466 return;
00467 }
00468
00469 $this->updated = $this->pg_obj->update();
00470
00471
00472 $ilBench->stop("Editor","Paragraph_update");
00473
00474 if ($this->updated === true)
00475 {
00476 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00477 }
00478 else
00479 {
00480 $this->edit();
00481 }
00482 }
00483
00484
00488 function create()
00489 {
00490
00491 $this->content_obj =& new ilPCParagraph($this->dom);
00492 $this->content_obj->create($this->pg_obj, $this->hier_id);
00493 $this->content_obj->setLanguage($_POST["par_language"]);
00494 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["par_language"];
00495 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
00496
00497 $this->updated = $this->content_obj->setText(
00498 $this->content_obj->input2xml($_POST["par_content"],
00499 $_POST["usedwsiwygeditor"]));
00500
00501 if ($this->updated !== true)
00502 {
00503 $this->insert();
00504 return;
00505 }
00506 $this->updated = $this->pg_obj->update();
00507
00508 if ($this->updated === true)
00509 {
00510 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00511 }
00512 else
00513 {
00514 $this->insert();
00515 }
00516 }
00517
00521 function popup()
00522 {
00523 include_once "./content/classes/Pages/class.ilWysiwygUtil.php";
00524 $popup = new ilWysiwygUtil();
00525 $popup->show($_GET["ptype"]);
00526 exit;
00527 }
00528
00532 function setTabs()
00533 {
00534 global $ilTabs;
00535
00536
00537 #include_once("classes/class.ilTabsGUI.php");
00538 #$tabs_gui =& new ilTabsGUI();
00539 $this->getTabs($ilTabs);
00540 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00541 }
00542
00548 function getTabs(&$tabs_gui)
00549 {
00550
00551
00552
00553
00554
00555
00556 }
00557
00558
00559 }
00560 ?>