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
00090 if ($this->pg_obj->getParentType() == "lm" ||
00091 $this->pg_obj->getParentType() == "dbk")
00092 {
00093 $this->tpl->setVariable("TXT_FORMATERROR",$this->lng->txt("cont_format_error"));
00094
00095 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00096 ilObjStyleSheet::getContentStylePath(
00097 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00098 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00099 ilObjStyleSheet::getContentStylePath(
00100 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00101
00102 $this->tpl->setVariable("LINK_ILINK",
00103 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00104
00105 $this->tpl->setVariable("REMOVELINK",$this->lng->txt("cont_removeiln"));
00106
00107 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00108
00109 $this->tpl->touchBlock("internal_link_active1");
00110 $this->tpl->touchBlock("internal_link_active2");
00111 }
00112 else
00113 {
00114 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00115 ilObjStyleSheet::getContentStylePath(0));
00116 }
00117
00118 $this->displayValidationError();
00119
00120
00121 if (key($_POST["cmd"]) == "update")
00122 {
00123 $s_lang = $_POST["par_language"];
00124 $s_char = $_POST["par_characteristic"];
00125 }
00126 else
00127 {
00128 $s_lang = $this->content_obj->getLanguage();
00129 $s_char = $this->content_obj->getCharacteristic();
00130 }
00131 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00132 require_once("classes/class.ilMetaData.php");
00133 $lang = ilMetaData::getLanguages();
00134 $select_lang = ilUtil::formSelect ($s_lang,"par_language",$lang,false,true);
00135 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00136 $char = array("" => $this->lng->txt("none"),
00137 "Headline1" => $this->lng->txt("cont_Headline1"),
00138 "Headline2" => $this->lng->txt("cont_Headline2"),
00139 "Headline3" => $this->lng->txt("cont_Headline3"),
00140 "Example" => $this->lng->txt("cont_Example"),
00141 "Citation" => $this->lng->txt("cont_Citation"),
00142 "Mnemonic" => $this->lng->txt("cont_Mnemonic"),
00143 "Additional" => $this->lng->txt("cont_Additional"),
00144 "List" => $this->lng->txt("cont_List"),
00145 "Remark" => $this->lng->txt("cont_Remark"),
00146
00147 "TableContent" => $this->lng->txt("cont_TableContent")
00148 );
00149 $this->tpl->setVariable("TXT_CHARACTERISTIC", $this->lng->txt("cont_characteristic"));
00150 $select_char = ilUtil::formSelect ($s_char,
00151 "par_characteristic",$char,false,true);
00152 $this->tpl->setVariable("SELECT_CHARACTERISTIC", $select_char);
00153
00154 if (key($_POST["cmd"]) == "update")
00155 {
00156 $s_text = stripslashes($_POST["par_content"]);
00157 }
00158 else
00159 {
00160 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
00161 }
00162 $this->tpl->setVariable("PAR_TA_NAME", "par_content");
00163
00164 if (ilPageEditorGUI::_doJSEditing())
00165 {
00166
00167
00168 $s_text = str_replace("&","&", $s_text);
00169
00170 $this->tpl->setVariable("PAR_TA_CONTENT", $s_text);
00171 $this->tpl->touchBlock("initwysiwygeditor");
00172 }
00173 else
00174 {
00175 $this->tpl->setVariable("PAR_TA_CONTENT", $s_text);
00176 }
00177
00178 $this->tpl->parseCurrentBlock();
00179
00180
00181 $this->tpl->setCurrentBlock("commands");
00182 $this->tpl->setVariable("BTN_NAME", "update");
00183 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00184 $this->tpl->parseCurrentBlock();
00185
00186
00187 }
00188
00189
00193 function insert()
00194 {
00195 global $ilUser;
00196
00197
00198 $this->setTabs();
00199
00200
00201 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paragraph_edit.html", "content");
00202 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_par"));
00203 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00204 $this->tpl->setVariable("REF_ID", $_GET["ref_id"]);
00205
00206 if ($this->pg_obj->getParentType() == "lm" ||
00207 $this->pg_obj->getParentType() == "dbk")
00208 {
00209 $this->tpl->setVariable("TXT_FORMATERROR",$this->lng->txt("cont_format_error"));
00210
00211 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00212 ilObjStyleSheet::getContentStylePath(
00213 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00214 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00215 ilObjStyleSheet::getContentStylePath(
00216 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00217
00218 $this->tpl->setVariable("LINK_ILINK",
00219 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00220 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00221 $this->tpl->touchBlock("internal_link_active1");
00222 $this->tpl->touchBlock("internal_link_active2");
00223 }
00224 else
00225 {
00226 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00227 ilObjStyleSheet::getContentStylePath(0));
00228 }
00229
00230 $this->displayValidationError();
00231
00232
00233 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00234 require_once("classes/class.ilMetaData.php");
00235 $lang = ilMetaData::getLanguages();
00236
00237
00238
00239 if (key($_POST["cmd"]) == "create_par")
00240 {
00241 $s_lang = $_POST["par_language"];
00242 $s_char = $_POST["par_characteristic"];
00243 }
00244 else
00245 {
00246 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00247 {
00248 $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00249 }
00250 else
00251 {
00252 $s_lang = $ilUser->getLanguage();
00253 }
00254
00255
00256 $cont_obj =& $this->pg_obj->getContentObject($this->getHierId());
00257 if (is_object($cont_obj))
00258 {
00259 if ($cont_obj->getType() == "li" ||
00260 ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "List"))
00261 {
00262 $s_char = "List";
00263 }
00264
00265 if ($cont_obj->getType() == "td" ||
00266 ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "TableContent"))
00267 {
00268 $s_char = "TableContent";
00269 }
00270
00271 }
00272 }
00273
00274 require_once("classes/class.ilMetaData.php");
00275 $lang = ilMetaData::getLanguages();
00276 $select_lang = ilUtil::formSelect ($s_lang,"par_language",$lang,false,true);
00277 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00278 $char = array("" => $this->lng->txt("none"),
00279 "Headline1" => $this->lng->txt("cont_Headline1"),
00280 "Headline2" => $this->lng->txt("cont_Headline2"),
00281 "Headline3" => $this->lng->txt("cont_Headline3"),
00282 "Example" => $this->lng->txt("cont_Example"),
00283 "Citation" => $this->lng->txt("cont_Citation"),
00284 "Mnemonic" => $this->lng->txt("cont_Mnemonic"),
00285 "Additional" => $this->lng->txt("cont_Additional"),
00286 "List" => $this->lng->txt("cont_List"),
00287 "Remark" => $this->lng->txt("cont_Remark"),
00288
00289 "TableContent" => $this->lng->txt("cont_TableContent")
00290 );
00291 $this->tpl->setVariable("TXT_CHARACTERISTIC", $this->lng->txt("cont_characteristic"));
00292 $select_char = ilUtil::formSelect ($s_char,
00293 "par_characteristic",$char,false,true);
00294 $this->tpl->setVariable("SELECT_CHARACTERISTIC", $select_char);
00295
00296
00297
00298
00299
00300 $this->tpl->setVariable("PAR_TA_NAME", "par_content");
00301 if (key($_POST["cmd"]) == "create_par")
00302 {
00303 $this->tpl->setVariable("PAR_TA_CONTENT", stripslashes($_POST["par_content"]));
00304 }
00305 else
00306 {
00307 $this->tpl->setVariable("PAR_TA_CONTENT", "");
00308 }
00309 $this->tpl->parseCurrentBlock();
00310
00311 if (ilPageEditorGUI::_doJSEditing())
00312 {
00313 $this->tpl->touchBlock("initwysiwygeditor");
00314 }
00315
00316
00317 $this->tpl->setCurrentBlock("commands");
00318 $this->tpl->setVariable("BTN_NAME", "create_par");
00319 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00320 $this->tpl->parseCurrentBlock();
00321
00322 }
00323
00324
00325
00329 function update()
00330 {
00331 global $ilBench;
00332
00333 $ilBench->start("Editor","Paragraph_update");
00334
00335 $this->content_obj->setLanguage($_POST["par_language"]);
00336 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
00337
00338
00339
00340
00341
00342
00343 $this->updated = $this->content_obj->setText(
00344 $this->content_obj->input2xml(stripslashes($_POST["par_content"]),
00345 $_POST["usedwsiwygeditor"]));
00346
00347 if ($this->updated !== true)
00348 {
00349
00350 $ilBench->stop("Editor","Paragraph_update");
00351 $this->edit();
00352 return;
00353 }
00354
00355 $this->updated = $this->pg_obj->update();
00356
00357 $ilBench->stop("Editor","Paragraph_update");
00358
00359 if ($this->updated === true)
00360 {
00361 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00362 }
00363 else
00364 {
00365 $this->edit();
00366 }
00367 }
00368
00372 function create()
00373 {
00374
00375 $this->content_obj =& new ilPCParagraph($this->dom);
00376 $this->content_obj->create($this->pg_obj, $this->hier_id);
00377 $this->content_obj->setLanguage($_POST["par_language"]);
00378 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["par_language"];
00379 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
00380
00381 $this->updated = $this->content_obj->setText(
00382 $this->content_obj->input2xml(stripslashes($_POST["par_content"]),
00383 $_POST["usedwsiwygeditor"]));
00384
00385 if ($this->updated !== true)
00386 {
00387 $this->insert();
00388 return;
00389 }
00390 $this->updated = $this->pg_obj->update();
00391
00392 if ($this->updated === true)
00393 {
00394 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00395 }
00396 else
00397 {
00398 $this->insert();
00399 }
00400 }
00401
00405 function setTabs()
00406 {
00407
00408 include_once("classes/class.ilTabsGUI.php");
00409 $tabs_gui =& new ilTabsGUI();
00410 $this->getTabs($tabs_gui);
00411 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00412 }
00413
00419 function getTabs(&$tabs_gui)
00420 {
00421
00422 $tabs_gui->addTarget("cont_back",
00423 $this->ctrl->getParentReturn($this), "",
00424 "");
00425 }
00426
00427
00428 }
00429 ?>