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.ilPCParagraph.php");
00025 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
00026 require_once("./Services/COPage/classes/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", "Services/COPage");
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."/Services/COPage/htmlarea/");
00090 $this->tpl->setVariable("JS_HTMLAREA", ILIAS_HTTP_PATH."/Services/COPage/htmlarea/htmlarea.js");
00091 $this->tpl->setVariable("JS_HANDLETAGS", ILIAS_HTTP_PATH."/Services/COPage/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->setVariable("TXT_BB_TIP", $this->lng->txt("cont_bb_tip"));
00145 $this->tpl->parseCurrentBlock();
00146 }
00147 else
00148 {
00149 $this->tpl->setVariable("LINK_ILINK",
00150 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00151 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00152 }
00153
00154 $this->tpl->setVariable("REMOVELINK",$this->lng->txt("cont_removeiln"));
00155
00156 $this->tpl->touchBlock("internal_link_active1");
00157 $this->tpl->touchBlock("internal_link_active2");
00158 }
00159 else
00160 {
00161 $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00162 ilUtil::getStyleSheetLocation());
00163 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00164 ilObjStyleSheet::getContentStylePath(0));
00165 if (!ilPageEditorGUI::_doJSEditing())
00166 {
00167 $this->tpl->setCurrentBlock("bb_buttons");
00168 $this->tpl->setVariable("TXT_BB_TIP", $this->lng->txt("cont_bb_tip"));
00169 $this->tpl->parseCurrentBlock();
00170 }
00171 }
00172
00173 $this->displayValidationError();
00174
00175
00176 if (key($_POST["cmd"]) == "update")
00177 {
00178 $s_lang = $_POST["par_language"];
00179 $s_char = $_POST["par_characteristic"];
00180 }
00181 else
00182 {
00183 $s_lang = $this->content_obj->getLanguage();
00184 $s_char = $this->content_obj->getCharacteristic();
00185 }
00186 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00187 require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
00188 $lang = ilMDLanguageItem::_getLanguages();
00189 $select_lang = ilUtil::formSelect ($s_lang,"par_language",$lang,false,true);
00190 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00191 $char = array("" => $this->lng->txt("none"),
00192 "Headline1" => $this->lng->txt("cont_Headline1"),
00193 "Headline2" => $this->lng->txt("cont_Headline2"),
00194 "Headline3" => $this->lng->txt("cont_Headline3"),
00195 "Example" => $this->lng->txt("cont_Example"),
00196 "Citation" => $this->lng->txt("cont_Citation"),
00197 "Mnemonic" => $this->lng->txt("cont_Mnemonic"),
00198 "Additional" => $this->lng->txt("cont_Additional"),
00199 "List" => $this->lng->txt("cont_List"),
00200 "Remark" => $this->lng->txt("cont_Remark"),
00201
00202 "TableContent" => $this->lng->txt("cont_TableContent")
00203 );
00204 $this->tpl->setVariable("TXT_CHARACTERISTIC", $this->lng->txt("cont_characteristic"));
00205 $select_char = ilUtil::formSelect ($s_char,
00206 "par_characteristic",$char,false,true);
00207 $this->tpl->setVariable("SELECT_CHARACTERISTIC", $select_char);
00208
00209 if (key($_POST["cmd"]) == "update")
00210 {
00211 $s_text = ilUtil::stripSlashes($_POST["par_content"], false);
00212 }
00213 else
00214 {
00215 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
00216 }
00217 $this->tpl->setVariable("PAR_TA_NAME", "par_content");
00218
00219 if (ilPageEditorGUI::_doJSEditing())
00220 {
00221
00222
00223 $s_text = str_replace("&","&", $s_text);
00224
00225
00226 if (substr($s_text, strlen($s_text) - 6) == "[/xln]" ||
00227 substr($s_text, strlen($s_text) - 6) == "[/iln]")
00228 {
00229 $s_text = $s_text." ";
00230 }
00231
00232 $this->tpl->setVariable("PAR_TA_CONTENT", $s_text);
00233 $this->tpl->touchBlock("initwysiwygeditor");
00234 }
00235 else
00236 {
00237 $this->tpl->setVariable("PAR_TA_CONTENT", $s_text);
00238 }
00239
00240 $this->tpl->parseCurrentBlock();
00241
00242
00243 $this->tpl->setCurrentBlock("commands");
00244 $this->tpl->setVariable("BTN_NAME", "update");
00245 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00246 $this->tpl->setVariable("BTN_CANCEL", "cancelUpdate");
00247 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00248 $this->tpl->parseCurrentBlock();
00249
00250 }
00251
00252
00256 function insert()
00257 {
00258 global $ilUser;
00259
00260
00261 $this->setTabs();
00262
00263
00264 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paragraph_edit.html", "Services/COPage");
00265 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_par"));
00266 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00267 $this->tpl->setVariable("REF_ID", $_GET["ref_id"]);
00268
00269 $this->tpl->setVariable("EDITOR_URL", ILIAS_HTTP_PATH."/Services/COPage/htmlarea/");
00270 $this->tpl->setVariable("JS_HTMLAREA", ILIAS_HTTP_PATH."/Services/COPage/htmlarea/htmlarea.js");
00271 $this->tpl->setVariable("JS_HANDLETAGS", ILIAS_HTTP_PATH."/Services/COPage/js/handletags.js");
00272 $this->ctrl->setParameter($this, "ptype", "footnote");
00273 $this->tpl->setVariable("POPUP_TARGET_FOOTNOTE",
00274 $this->ctrl->getLinkTarget($this, "popup"));
00275 $this->ctrl->setParameter($this, "ptype", "xtl");
00276 $this->tpl->setVariable("POPUP_TARGET_XTL",
00277 $this->ctrl->getLinkTarget($this, "popup"));
00278
00279 $this->tpl->setVariable("TXT_STR", $this->lng->txt("cont_text_str"));
00280 $this->tpl->setVariable("TXT_EMP", $this->lng->txt("cont_text_emp"));
00281 $this->tpl->setVariable("TXT_COM", $this->lng->txt("cont_text_com"));
00282 $this->tpl->setVariable("TXT_FN", $this->lng->txt("cont_text_fn"));
00283 $this->tpl->setVariable("TXT_QUOT", $this->lng->txt("cont_text_quot"));
00284 $this->tpl->setVariable("TXT_CODE", $this->lng->txt("cont_text_code"));
00285 $this->tpl->setVariable("TXT_ILN", $this->lng->txt("cont_text_iln"));
00286 $this->tpl->setVariable("TXT_XLN", $this->lng->txt("cont_text_xln"));
00287 $this->tpl->setVariable("TXT_TEX", $this->lng->txt("cont_text_tex"));
00288
00289 include_once("./classes/class.ilObjStyleSheet.php");
00290
00291 if ($this->pg_obj->getParentType() == "gdf" ||
00292 $this->pg_obj->getParentType() == "lm" ||
00293 $this->pg_obj->getParentType() == "dbk")
00294 {
00295 $this->tpl->setVariable("TXT_FORMATERROR",$this->lng->txt("cont_format_error"));
00296
00297 if ($this->pg_obj->getParentType() != "gdf")
00298 {
00299 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00300 ilObjStyleSheet::getContentStylePath(
00301 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00302 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00303 ilObjStyleSheet::getContentStylePath(
00304 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00305 }
00306 else
00307 {
00308 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00309 ilObjStyleSheet::getContentStylePath(0));
00310 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00311 ilObjStyleSheet::getContentStylePath(0));
00312 }
00313
00314 $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00315 ilUtil::getStyleSheetLocation());
00316
00317 if (!ilPageEditorGUI::_doJSEditing())
00318 {
00319 $this->tpl->setCurrentBlock("bb_ilink_button");
00320 $this->tpl->setVariable("BB_LINK_ILINK",
00321 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00322 $this->tpl->setVariable("BB_TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00323 $this->tpl->parseCurrentBlock();
00324 $this->tpl->setCurrentBlock("bb_buttons");
00325 $this->tpl->setVariable("TXT_BB_TIP", $this->lng->txt("cont_bb_tip"));
00326 $this->tpl->parseCurrentBlock();
00327 }
00328 else
00329 {
00330 $this->tpl->setVariable("LINK_ILINK",
00331 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00332 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00333 }
00334
00335 $this->tpl->touchBlock("internal_link_active1");
00336 $this->tpl->touchBlock("internal_link_active2");
00337 }
00338 else
00339 {
00340 $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00341 ilUtil::getStyleSheetLocation());
00342 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00343 ilObjStyleSheet::getContentStylePath(0));
00344 if (!ilPageEditorGUI::_doJSEditing())
00345 {
00346 $this->tpl->setCurrentBlock("bb_buttons");
00347 $this->tpl->setVariable("TXT_BB_TIP", $this->lng->txt("cont_bb_tip"));
00348 $this->tpl->parseCurrentBlock();
00349 }
00350 }
00351
00352 $this->displayValidationError();
00353
00354
00355 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00356 require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
00357 $lang = ilMDLanguageItem::_getLanguages();
00358
00359
00360
00361 if (key($_POST["cmd"]) == "create_par")
00362 {
00363 $s_lang = $_POST["par_language"];
00364 $s_char = $_POST["par_characteristic"];
00365 }
00366 else
00367 {
00368 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00369 {
00370 $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00371 }
00372 else
00373 {
00374 $s_lang = $ilUser->getLanguage();
00375 }
00376
00377
00378 $cont_obj =& $this->pg_obj->getContentObject($this->getHierId());
00379 if (is_object($cont_obj))
00380 {
00381 if ($cont_obj->getType() == "li" ||
00382 ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "List"))
00383 {
00384 $s_char = "List";
00385 }
00386
00387 if ($cont_obj->getType() == "td" ||
00388 ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "TableContent"))
00389 {
00390 $s_char = "TableContent";
00391 }
00392
00393 }
00394 }
00395
00396 require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
00397 $lang = ilMDLanguageItem::_getLanguages();
00398 $select_lang = ilUtil::formSelect ($s_lang,"par_language",$lang,false,true);
00399 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00400 $char = array("" => $this->lng->txt("none"),
00401 "Headline1" => $this->lng->txt("cont_Headline1"),
00402 "Headline2" => $this->lng->txt("cont_Headline2"),
00403 "Headline3" => $this->lng->txt("cont_Headline3"),
00404 "Example" => $this->lng->txt("cont_Example"),
00405 "Citation" => $this->lng->txt("cont_Citation"),
00406 "Mnemonic" => $this->lng->txt("cont_Mnemonic"),
00407 "Additional" => $this->lng->txt("cont_Additional"),
00408 "List" => $this->lng->txt("cont_List"),
00409 "Remark" => $this->lng->txt("cont_Remark"),
00410
00411 "TableContent" => $this->lng->txt("cont_TableContent")
00412 );
00413 $this->tpl->setVariable("TXT_CHARACTERISTIC", $this->lng->txt("cont_characteristic"));
00414 $select_char = ilUtil::formSelect ($s_char,
00415 "par_characteristic",$char,false,true);
00416 $this->tpl->setVariable("SELECT_CHARACTERISTIC", $select_char);
00417
00418
00419
00420
00421
00422 $this->tpl->setVariable("PAR_TA_NAME", "par_content");
00423 if (key($_POST["cmd"]) == "create_par")
00424 {
00425 $this->tpl->setVariable("PAR_TA_CONTENT",
00426 ilUtil::stripSlashes($_POST["par_content"], false));
00427 }
00428 else
00429 {
00430 $this->tpl->setVariable("PAR_TA_CONTENT", "");
00431 }
00432 $this->tpl->parseCurrentBlock();
00433
00434 if (ilPageEditorGUI::_doJSEditing())
00435 {
00436 $this->tpl->touchBlock("initwysiwygeditor");
00437 }
00438
00439
00440 $this->tpl->setCurrentBlock("commands");
00441 $this->tpl->setVariable("BTN_NAME", "create_par");
00442 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00443 $this->tpl->setVariable("BTN_CANCEL", "cancelCreate");
00444 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00445 $this->tpl->parseCurrentBlock();
00446
00447 }
00448
00449
00450
00454 function update()
00455 {
00456 global $ilBench;
00457
00458 $ilBench->start("Editor","Paragraph_update");
00459
00460 $this->content_obj->setLanguage($_POST["par_language"]);
00461 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471 $this->updated = $this->content_obj->setText(
00472 $this->content_obj->input2xml($_POST["par_content"],
00473 $_POST["usedwsiwygeditor"]));
00474
00475 if ($this->updated !== true)
00476 {
00477 $ilBench->stop("Editor","Paragraph_update");
00478 $this->edit();
00479 return;
00480 }
00481
00482 $this->updated = $this->pg_obj->update();
00483
00484
00485 $ilBench->stop("Editor","Paragraph_update");
00486
00487 if ($this->updated === true)
00488 {
00489 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00490 }
00491 else
00492 {
00493 $this->edit();
00494 }
00495 }
00496
00497
00501 function create()
00502 {
00503
00504 $this->content_obj =& new ilPCParagraph($this->dom);
00505 $this->content_obj->create($this->pg_obj, $this->hier_id);
00506 $this->content_obj->setLanguage($_POST["par_language"]);
00507 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["par_language"];
00508 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
00509
00510 $this->updated = $this->content_obj->setText(
00511 $this->content_obj->input2xml($_POST["par_content"],
00512 $_POST["usedwsiwygeditor"]));
00513
00514 if ($this->updated !== true)
00515 {
00516 $this->insert();
00517 return;
00518 }
00519 $this->updated = $this->pg_obj->update();
00520
00521 if ($this->updated === true)
00522 {
00523 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00524 }
00525 else
00526 {
00527 $this->insert();
00528 }
00529 }
00530
00534 function popup()
00535 {
00536 include_once "./Services/COPage/classes/class.ilWysiwygUtil.php";
00537 $popup = new ilWysiwygUtil();
00538 $popup->show($_GET["ptype"]);
00539 exit;
00540 }
00541
00545 function setTabs()
00546 {
00547 global $ilTabs;
00548
00549
00550 #include_once("classes/class.ilTabsGUI.php");
00551 #$tabs_gui =& new ilTabsGUI();
00552 $this->getTabs($ilTabs);
00553 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00554 }
00555
00561 function getTabs(&$tabs_gui)
00562 {
00563
00564
00565
00566
00567
00568
00569 }
00570
00571
00572 }
00573 ?>