• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/Pages/class.ilPCParagraphGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 // get next class that processes or forwards current command
00057                 $next_class = $this->ctrl->getNextClass($this);
00058 
00059                 // get current command
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                 // set tabs
00080                 $this->setTabs();
00081 
00082                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paragraph_edit.html", "content");
00083                 //$content = $this->pg_obj->getContent();
00084                 //$cnt = 1;
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                                 
00108                 if ($this->pg_obj->getParentType() == "lm" ||
00109                         $this->pg_obj->getParentType() == "dbk")
00110                 {
00111                         $this->tpl->setVariable("TXT_FORMATERROR",$this->lng->txt("cont_format_error"));
00112                         
00113                         $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00114                                 ilUtil::getStyleSheetLocation());                       
00115                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00116                                 ilObjStyleSheet::getContentStylePath(
00117                                         ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00118                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00119                                 ilObjStyleSheet::getContentStylePath(
00120                                         ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00121 
00122                         if (!ilPageEditorGUI::_doJSEditing())
00123                         {
00124                                 $this->tpl->setCurrentBlock("bb_ilink_button");
00125                                 $this->tpl->setVariable("BB_LINK_ILINK",
00126                                         $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00127                                 $this->tpl->setVariable("BB_TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00128                                 $this->tpl->setCurrentBlock("bb_buttons");
00129                                 $this->tpl->parseCurrentBlock();
00130                         }
00131                         else
00132                         {
00133                                 $this->tpl->setVariable("LINK_ILINK",
00134                                         $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00135                                 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00136                         }
00137                         
00138                         $this->tpl->setVariable("REMOVELINK",$this->lng->txt("cont_removeiln"));
00139                                                 
00140                         $this->tpl->touchBlock("internal_link_active1");
00141                         $this->tpl->touchBlock("internal_link_active2");
00142                 }
00143                 else
00144                 {
00145                         $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00146                                 ilUtil::getStyleSheetLocation());
00147                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00148                                 ilObjStyleSheet::getContentStylePath(0));
00149                         if (!ilPageEditorGUI::_doJSEditing())
00150                         {
00151                                 $this->tpl->touchBlock("bb_buttons");
00152                         }
00153                 }
00154 
00155                 $this->displayValidationError();
00156 
00157                 // language and characteristic selection
00158                 if (key($_POST["cmd"]) == "update")
00159                 {
00160                         $s_lang = $_POST["par_language"];
00161                         $s_char = $_POST["par_characteristic"];
00162                 }
00163                 else
00164                 {
00165                         $s_lang = $this->content_obj->getLanguage();
00166                         $s_char = $this->content_obj->getCharacteristic();
00167                 }
00168                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00169                 require_once("classes/class.ilMetaData.php");
00170                 $lang = ilMetaData::getLanguages();
00171                 $select_lang = ilUtil::formSelect ($s_lang,"par_language",$lang,false,true);
00172                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00173                 $char = array("" => $this->lng->txt("none"),
00174                         "Headline1" => $this->lng->txt("cont_Headline1"),
00175                         "Headline2" => $this->lng->txt("cont_Headline2"),
00176                         "Headline3" => $this->lng->txt("cont_Headline3"),
00177                         "Example" => $this->lng->txt("cont_Example"),
00178                         "Citation" => $this->lng->txt("cont_Citation"),
00179                         "Mnemonic" => $this->lng->txt("cont_Mnemonic"),
00180                         "Additional" => $this->lng->txt("cont_Additional"),
00181                         "List" => $this->lng->txt("cont_List"),
00182                         "Remark" => $this->lng->txt("cont_Remark"),
00183                         // "Code" => $this->lng->txt("cont_Code"),
00184                         "TableContent" => $this->lng->txt("cont_TableContent")
00185                         );
00186                 $this->tpl->setVariable("TXT_CHARACTERISTIC", $this->lng->txt("cont_characteristic"));
00187                 $select_char = ilUtil::formSelect ($s_char,
00188                         "par_characteristic",$char,false,true);
00189                 $this->tpl->setVariable("SELECT_CHARACTERISTIC", $select_char);
00190 
00191                 if (key($_POST["cmd"]) == "update")
00192                 {
00193                         $s_text = stripslashes($_POST["par_content"]);
00194                 }
00195                 else
00196                 {
00197                         $s_text = $this->content_obj->xml2output($this->content_obj->getText());
00198                 }
00199                 $this->tpl->setVariable("PAR_TA_NAME", "par_content");
00200 
00201                 if (ilPageEditorGUI::_doJSEditing())
00202                 {
00203                         // this line is necessary to prevent unwanted converts
00204                         // e.g. an entered "&lt;" to a "<"
00205                         $s_text = str_replace("&","&amp;", $s_text);
00206 
00207                         $this->tpl->setVariable("PAR_TA_CONTENT", $s_text);
00208                         $this->tpl->touchBlock("initwysiwygeditor");
00209                 }
00210                 else
00211                 {
00212                         $this->tpl->setVariable("PAR_TA_CONTENT", $s_text);
00213                 }
00214 
00215                 $this->tpl->parseCurrentBlock();
00216 
00217                 // operations
00218                 $this->tpl->setCurrentBlock("commands");
00219                 $this->tpl->setVariable("BTN_NAME", "update");
00220                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00221                 $this->tpl->setVariable("BTN_CANCEL", "cancelUpdate");
00222                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00223                 $this->tpl->parseCurrentBlock();
00224 
00225         }
00226 
00227 
00231         function insert()
00232         {
00233                 global $ilUser;
00234 
00235                 // set tabs
00236                 $this->setTabs();
00237 
00238                 // add paragraph edit template
00239                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.paragraph_edit.html", "content");
00240                 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_par"));
00241                 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00242                 $this->tpl->setVariable("REF_ID", $_GET["ref_id"]);
00243 
00244                 $this->tpl->setVariable("EDITOR_URL", ILIAS_HTTP_PATH."/content/htmlarea/");
00245                 $this->tpl->setVariable("JS_HTMLAREA", ILIAS_HTTP_PATH."/content/htmlarea/htmlarea.js");
00246                 $this->tpl->setVariable("JS_HANDLETAGS", ILIAS_HTTP_PATH."/content/js/handletags.js");
00247                 $this->ctrl->setParameter($this, "ptype", "footnote");
00248                 $this->tpl->setVariable("POPUP_TARGET_FOOTNOTE",
00249                         $this->ctrl->getLinkTarget($this, "popup"));    
00250                 $this->ctrl->setParameter($this, "ptype", "xtl");
00251                 $this->tpl->setVariable("POPUP_TARGET_XTL",
00252                         $this->ctrl->getLinkTarget($this, "popup"));    
00253 
00254                 $this->tpl->setVariable("TXT_STR", $this->lng->txt("cont_text_str"));
00255                 $this->tpl->setVariable("TXT_EMP", $this->lng->txt("cont_text_emp"));
00256                 $this->tpl->setVariable("TXT_COM", $this->lng->txt("cont_text_com"));
00257                 $this->tpl->setVariable("TXT_FN", $this->lng->txt("cont_text_fn"));
00258                 $this->tpl->setVariable("TXT_QUOT", $this->lng->txt("cont_text_quot"));
00259                 $this->tpl->setVariable("TXT_CODE", $this->lng->txt("cont_text_code"));
00260                 $this->tpl->setVariable("TXT_ILN", $this->lng->txt("cont_text_iln"));
00261                 $this->tpl->setVariable("TXT_XLN", $this->lng->txt("cont_text_xln"));
00262 
00263                 if ($this->pg_obj->getParentType() == "lm" ||
00264                         $this->pg_obj->getParentType() == "dbk")
00265                 {
00266                         $this->tpl->setVariable("TXT_FORMATERROR",$this->lng->txt("cont_format_error"));
00267                         
00268                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00269                                 ilObjStyleSheet::getContentStylePath(
00270                                         ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00271                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
00272                                 ilObjStyleSheet::getContentStylePath(
00273                                         ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())));
00274                         $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00275                                 ilUtil::getStyleSheetLocation());                       
00276 
00277                         if (!ilPageEditorGUI::_doJSEditing())
00278                         {
00279                                 $this->tpl->setCurrentBlock("bb_ilink_button");
00280                                 $this->tpl->setVariable("BB_LINK_ILINK",
00281                                         $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00282                                 $this->tpl->setVariable("BB_TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00283                                 $this->tpl->parseCurrentBlock();
00284                                 $this->tpl->setCurrentBlock("bb_buttons");
00285                                 $this->tpl->parseCurrentBlock();
00286                         }
00287                         else
00288                         {
00289                                 $this->tpl->setVariable("LINK_ILINK",
00290                                         $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
00291                                 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
00292                         }
00293                         
00294                         $this->tpl->touchBlock("internal_link_active1");
00295                         $this->tpl->touchBlock("internal_link_active2");
00296                 }
00297                 else
00298                 {
00299                         $this->tpl->setVariable("LOCATION_STYLESHEET_HTMLAREA",
00300                                 ilUtil::getStyleSheetLocation());
00301                         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET_HTMLAREA",
00302                                 ilObjStyleSheet::getContentStylePath(0));
00303                         if (!ilPageEditorGUI::_doJSEditing())
00304                         {
00305                                 $this->tpl->touchBlock("bb_buttons");
00306                         }
00307                 }
00308                 
00309                 $this->displayValidationError();
00310 
00311                 // language and characteristic selection
00312                 $this->tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
00313                 require_once("classes/class.ilMetaData.php");
00314                 $lang = ilMetaData::getLanguages();
00315 
00316                 // get values from new object (repeated form display on error)
00317                 //if (is_object($this->content_obj))
00318                 if (key($_POST["cmd"]) == "create_par")
00319                 {
00320                         $s_lang = $_POST["par_language"];
00321                         $s_char = $_POST["par_characteristic"];
00322                 }
00323                 else
00324                 {
00325                         if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
00326                         {
00327                                 $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
00328                         }
00329                         else
00330                         {
00331                                 $s_lang = $ilUser->getLanguage();
00332                         }
00333 
00334                         // set characteristic of new paragraphs in list items to "List"
00335                         $cont_obj =& $this->pg_obj->getContentObject($this->getHierId());
00336                         if (is_object($cont_obj))
00337                         {
00338                                 if ($cont_obj->getType() == "li" ||
00339                                         ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "List"))
00340                                 {
00341                                         $s_char = "List";
00342                                 }
00343                                                                 
00344                                 if ($cont_obj->getType() == "td" ||
00345                                         ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "TableContent"))
00346                                 {
00347                                         $s_char = "TableContent";
00348                                 }
00349 
00350                         }
00351                 }
00352 
00353                 require_once("classes/class.ilMetaData.php");
00354                 $lang = ilMetaData::getLanguages();
00355                 $select_lang = ilUtil::formSelect ($s_lang,"par_language",$lang,false,true);
00356                 $this->tpl->setVariable("SELECT_LANGUAGE", $select_lang);
00357                 $char = array("" => $this->lng->txt("none"),
00358                         "Headline1" => $this->lng->txt("cont_Headline1"),
00359                         "Headline2" => $this->lng->txt("cont_Headline2"),
00360                         "Headline3" => $this->lng->txt("cont_Headline3"),
00361                         "Example" => $this->lng->txt("cont_Example"),
00362                         "Citation" => $this->lng->txt("cont_Citation"),
00363                         "Mnemonic" => $this->lng->txt("cont_Mnemonic"),
00364                         "Additional" => $this->lng->txt("cont_Additional"),
00365                         "List" => $this->lng->txt("cont_List"),
00366                         "Remark" => $this->lng->txt("cont_Remark"),
00367                         //"Code" => $this->lng->txt("cont_Code"),
00368                         "TableContent" => $this->lng->txt("cont_TableContent")
00369                         );
00370                 $this->tpl->setVariable("TXT_CHARACTERISTIC", $this->lng->txt("cont_characteristic"));
00371                 $select_char = ilUtil::formSelect ($s_char,
00372                         "par_characteristic",$char,false,true);
00373                 $this->tpl->setVariable("SELECT_CHARACTERISTIC", $select_char);
00374 
00375                 // content is in utf-8, todo: set globally
00376                 // header('Content-type: text/html; charset=UTF-8');
00377 
00378                 // input text area
00379                 $this->tpl->setVariable("PAR_TA_NAME", "par_content");
00380                 if (key($_POST["cmd"]) == "create_par")
00381                 {
00382                         $this->tpl->setVariable("PAR_TA_CONTENT", stripslashes($_POST["par_content"]));
00383                 }
00384                 else
00385                 {
00386                         $this->tpl->setVariable("PAR_TA_CONTENT", "");
00387                 }
00388                 $this->tpl->parseCurrentBlock();
00389 
00390                 if (ilPageEditorGUI::_doJSEditing()) 
00391                 {
00392                         $this->tpl->touchBlock("initwysiwygeditor");
00393                 }
00394                 
00395                 // operations
00396                 $this->tpl->setCurrentBlock("commands");
00397                 $this->tpl->setVariable("BTN_NAME", "create_par");      //--
00398                 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00399                 $this->tpl->setVariable("BTN_CANCEL", "cancelCreate");
00400                 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00401                 $this->tpl->parseCurrentBlock();
00402 
00403         }
00404 
00405 
00406     
00410         function update()
00411         {
00412                 global $ilBench;
00413 
00414                 $ilBench->start("Editor","Paragraph_update");
00415                 // set language and characteristic
00416                 $this->content_obj->setLanguage($_POST["par_language"]);
00417                 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
00418 
00419 //echo "<br>PARupdate1:".$_POST["par_content"].":";
00420 //echo "<br>PARupdate2:".htmlentities($_POST["par_content"]).":";
00421 //echo "<br>PARupdate3:".htmlentities($this->content_obj->input2xml($_POST["par_content"])).":";
00422 //echo "<br>PARupdate4:".$this->content_obj->input2xml($_POST["par_content"]).":";
00423 
00424                 $this->updated = $this->content_obj->setText(
00425                         $this->content_obj->input2xml(stripslashes($_POST["par_content"]),
00426                                 $_POST["usedwsiwygeditor"]));
00427 //echo "<br>PARupdate2";
00428                 if ($this->updated !== true)
00429                 {
00430                         $ilBench->stop("Editor","Paragraph_update");
00431                         $this->edit();
00432                         return;
00433                 }
00434 
00435                 $this->updated = $this->pg_obj->update();
00436 //echo "<br>PARupdate_after:".htmlentities($this->pg_obj->dom->dump_mem(0, "UTF-8")).":";
00437 
00438                 $ilBench->stop("Editor","Paragraph_update");
00439 
00440                 if ($this->updated === true)
00441                 {
00442                         $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00443                 }
00444                 else
00445                 {
00446                         $this->edit();
00447                 }
00448         }
00449         
00450 
00454         function create()
00455         {
00456 
00457                 $this->content_obj =& new ilPCParagraph($this->dom);
00458                 $this->content_obj->create($this->pg_obj, $this->hier_id);
00459                 $this->content_obj->setLanguage($_POST["par_language"]);
00460                 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["par_language"];
00461                 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
00462 
00463                 $this->updated = $this->content_obj->setText(
00464                         $this->content_obj->input2xml(stripslashes($_POST["par_content"]),
00465                                 $_POST["usedwsiwygeditor"]));
00466 
00467                 if ($this->updated !== true)
00468                 {
00469                         $this->insert();
00470                         return;
00471                 }
00472                 $this->updated = $this->pg_obj->update();
00473 
00474                 if ($this->updated === true)
00475                 {
00476                         $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00477                 }
00478                 else
00479                 {
00480                         $this->insert();
00481                 }
00482         }
00483         
00487         function popup()
00488         {
00489                 include_once "./content/classes/Pages/class.ilWysiwygUtil.php";
00490                 $popup = new ilWysiwygUtil();
00491                 $popup->show($_GET["ptype"]);
00492                 exit;
00493         }
00494 
00495 
00499         function setTabs()
00500         {
00501                 // catch feedback message
00502                 include_once("classes/class.ilTabsGUI.php");
00503                 $tabs_gui =& new ilTabsGUI();
00504                 $this->getTabs($tabs_gui);
00505                 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00506         }
00507 
00513         function getTabs(&$tabs_gui)
00514         {
00515                 // back to upper context
00516                 /*
00517                 $tabs_gui->addTarget("cont_back",
00518                         $this->ctrl->getParentReturn($this), "",
00519                         "");
00520                 */
00521         }
00522 
00523 
00524 }
00525 ?>

Generated on Fri Dec 13 2013 10:18:30 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1