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