Public Member Functions | |
ilPCSourcecodeGUI (&$a_pg_obj, &$a_content_obj, $a_hier_id) | |
Constructor public. | |
& | executeCommand () |
execute command | |
edit () | |
edit paragraph form | |
setTemplateText ($s_lang, $s_proglang) | |
insert () | |
insert paragraph form | |
update () | |
update paragraph in dom and update page in db | |
cancelUpdate () | |
cancel update | |
create () | |
create new paragraph in dom and update page in db | |
cancelCreate () | |
cancel creating paragraph | |
setTabs () | |
output tabs | |
getTabs (&$tabs_gui) | |
adds tabs to tab gui object | |
upload () | |
upload_source () | |
readProgLangs () |
Definition at line 37 of file class.ilPCSourcecodeGUI.php.
ilPCSourcecodeGUI::cancelCreate | ( | ) |
cancel creating paragraph
Reimplemented from ilPageContentGUI.
Definition at line 374 of file class.ilPCSourcecodeGUI.php.
{
$this->ctrl->returnToParent($this, "jump".$this->hier_id);
}
ilPCSourcecodeGUI::cancelUpdate | ( | ) |
cancel update
Reimplemented from ilPageContentGUI.
Definition at line 321 of file class.ilPCSourcecodeGUI.php.
{
$this->ctrl->returnToParent($this, "jump".$this->hier_id);
}
ilPCSourcecodeGUI::create | ( | ) |
create new paragraph in dom and update page in db
Definition at line 329 of file class.ilPCSourcecodeGUI.php.
References $_POST, $_SESSION, insert(), and upload_source().
{ $this->content_obj =& new ilPCParagraph($this->dom); $this->content_obj->create($this->pg_obj, $this->hier_id); $this->content_obj->setLanguage($_POST["par_language"]); $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["par_language"]; $uploaded = $this->upload_source(); $this->content_obj->setCharacteristic ($_POST["par_characteristic"]); $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]); $this->content_obj->setDownloadTitle ($_POST["par_downloadtitle"]); $this->content_obj->setShowLineNumbers (($_POST["par_showlinenumbers"]=='on')?'y':'n'); $this->content_obj->setCharacteristic ('Code'); $this->content_obj->setAutoIndent (($_POST["par_indent"]=='on')?'y':'n'); if ($uploaded) { $this->insert (); return; } $this->updated = $this->content_obj->setText($this->content_obj->input2xml($_POST["par_content"])); if ($this->updated !== true) { $this->insert(); return; } $this->updated = $this->pg_obj->update(); if ($this->updated === true && !$uploaded) { $this->ctrl->returnToParent($this, "jump".$this->hier_id); } else { $this->insert (); } }
ilPCSourcecodeGUI::edit | ( | ) |
edit paragraph form
Definition at line 74 of file class.ilPCSourcecodeGUI.php.
References $_POST, ilPageContentGUI::displayValidationError(), setTabs(), and setTemplateText().
Referenced by update().
{ // set tabs $this->setTabs(); $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.sourcecode_edit.html", "content"); //$content = $this->pg_obj->getContent(); //$cnt = 1; $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_src")); if ($this->pg_obj->getParentType() == "lm" || $this->pg_obj->getParentType() == "dbk") { $this->tpl->setVariable("LINK_ILINK", $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp")); $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]"); } $this->displayValidationError(); // language and characteristic selection if (key($_POST["cmd"]) == "update") { $s_lang = $_POST["par_language"]; $s_char = $_POST["par_characteristic"]; $s_subchar = $_POST["par_subcharacteristic"]; $s_downloadtitle = $_POST["par_downloadtitle"]; $s_showlinenumbers = ($_POST["par_showlinenumbers"]=="on")?'y':'n'; $s_autoindent = ($_POST["par_autoindent"]=="on")?'y':'n'; } else { $s_lang = $this->content_obj->getLanguage(); $s_char = $this->content_obj->getCharacteristic(); $s_subchar = $this->content_obj->getSubCharacteristic(); $s_downloadtitle = $this->content_obj->getDownloadTitle(); $s_showlinenumbers = $this->content_obj->getShowLineNumbers(); $s_autoindent = $this->content_obj->getAutoIndent (); } $this->setTemplateText($s_lang, $s_subchar); if (key($_POST["cmd"]) == "update") { $s_text = stripslashes($_POST["par_content"]); } else { $s_text = $this->content_obj->xml2output($this->content_obj->getText()); } $this->tpl->setVariable("PAR_TA_NAME", "par_content"); $this->tpl->setVariable("PAR_TA_CONTENT", $s_text); $this->tpl->parseCurrentBlock(); if (strcmp($s_showlinenumbers,"y")==0) { $this->tpl->setVariable("SHOWLINENUMBERS", "checked=\"checked\""); } if (strcmp($s_autoindent,"y") == 0) { $this->tpl->setVariable("AUTOINDENT", "checked=\"checked\""); } $this->tpl->setVariable("DOWNLOAD_TITLE_VALUE", $s_downloadtitle); // operations $this->tpl->setCurrentBlock("commands"); $this->tpl->setVariable("BTN_NAME", "update"); $this->tpl->setVariable("UPLOAD_BTN_NAME", "upload"); $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save")); $this->tpl->setVariable("BTN_CANCEL", "cancelUpdate"); $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel")); $this->tpl->parseCurrentBlock(); }
& ilPCSourcecodeGUI::executeCommand | ( | ) |
ilPCSourcecodeGUI::getTabs | ( | &$ | tabs_gui | ) |
adds tabs to tab gui object
object | $tabs_gui ilTabsGUI object |
Definition at line 398 of file class.ilPCSourcecodeGUI.php.
Referenced by setTabs().
{ // back to upper context /* $tabs_gui->addTarget("cont_back", $this->ctrl->getParentReturn($this), "", ""); */ }
ilPCSourcecodeGUI::ilPCSourcecodeGUI | ( | &$ | a_pg_obj, | |
&$ | a_content_obj, | |||
$ | a_hier_id | |||
) |
Constructor public.
Definition at line 44 of file class.ilPCSourcecodeGUI.php.
References ilPageContentGUI::ilPageContentGUI().
{ parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id); }
ilPCSourcecodeGUI::insert | ( | ) |
insert paragraph form
Definition at line 182 of file class.ilPCSourcecodeGUI.php.
References $_GET, $_POST, $_SESSION, ilPageContentGUI::displayValidationError(), setTabs(), and setTemplateText().
Referenced by create().
{ global $ilUser; // set tabs $this->setTabs(); // add paragraph edit template $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.sourcecode_edit.html", "content"); $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_src")); if ($this->pg_obj->getParentType() == "lm" || $this->pg_obj->getParentType() == "dbk") { $this->tpl->setVariable("LINK_ILINK", $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp")); $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]"); } $this->displayValidationError(); // get values from new object (repeated form display on error) //echo key ($_POST["cmd"]); if (key($_POST["cmd"]) == "create_src") { $s_lang = $_POST["par_language"]; $s_subchar = $_POST["par_subcharacteristic"]; $s_downloadtitle = $_POST["par_downloadtitle"]; $s_showlinenumbers = strcmp($_POST["par_showlinenumbers"],'on')==0?'checked=\"true\"':''; $s_autoindent = strcmp($_POST["par_autoindent"],'on')==0?'checked=\"true\"':''; $s_isexample = strcmp($_POST["par_isexample"],"on")==0?'checked=\"true\"':''; } else { if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "") { $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]]; } else { $s_lang = $ilUser->getLanguage(); } $s_showlinenumbers = 'CHECKED'; $s_autoindent = 'CHECKED'; $s_isexample = ''; $s_subchar = ''; } $this->setTemplateText($s_lang, $s_subchar); $this->tpl->setVariable("SHOWLINENUMBERS", $s_showlinenumbers); $this->tpl->setVariable("AUTOINDENT", $s_autoindent); $this->tpl->setVariable("DOWNLOAD_TITLE_VALUE", $s_downloadtitle); $this->tpl->setVariable("ISEXAMPLE", $s_isexample); // content is in utf-8, todo: set globally // header('Content-type: text/html; charset=UTF-8'); // input text area $this->tpl->setVariable("PAR_TA_NAME", "par_content"); if (key($_POST["cmd"]) == "create_src") { $this->tpl->setVariable("PAR_TA_CONTENT", stripslashes($_POST["par_content"])); } else { $this->tpl->setVariable("PAR_TA_CONTENT", ""); } $this->tpl->parseCurrentBlock(); // operations $this->tpl->setCurrentBlock("commands"); $this->tpl->setVariable("BTN_NAME", "create_src"); //-- $this->tpl->setVariable("UPLOAD_BTN_NAME", "create_src"); $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save")); $this->tpl->setVariable("BTN_CANCEL", "cancelCreate"); $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel")); $this->tpl->parseCurrentBlock(); }
ilPCSourcecodeGUI::readProgLangs | ( | ) |
Definition at line 435 of file class.ilPCSourcecodeGUI.php.
Referenced by setTemplateText().
{ $prog_langs_ini = file ("syntax_highlight/php/admin/prog_langs.ini"); $prog_langs = array ("" => $this->lng->txt("cont_src_other")); foreach ($prog_langs_ini as $prog_lang) { $prog_lang_prop = split (":", $prog_lang); if ($prog_lang_prop[2] == 1) { $prog_langs[$prog_lang_prop[0]] = $prog_lang_prop[1]; } } return $prog_langs; }
ilPCSourcecodeGUI::setTabs | ( | ) |
output tabs
Definition at line 383 of file class.ilPCSourcecodeGUI.php.
References getTabs().
Referenced by edit(), and insert().
{ global $ilTabs; // catch feedback message #include_once("classes/class.ilTabsGUI.php"); #$tabs_gui =& new ilTabsGUI(); $this->getTabs($ilTabs); #$this->tpl->setVariable("TABS", $tabs_gui->getHTML()); }
ilPCSourcecodeGUI::setTemplateText | ( | $ | s_lang, | |
$ | s_proglang | |||
) |
Definition at line 154 of file class.ilPCSourcecodeGUI.php.
References $lang, formSelect(), ilMetaData::getLanguages(), and readProgLangs().
Referenced by edit(), and insert().
{ $this->tpl->setVariable ("TXT_CREATEFILE", $this->lng->txt("create_download_link")); $this->tpl->setVariable ("TXT_DOWNLOADTITLE", $this->lng->txt("cont_download_title")); $this->tpl->setVariable ("TXT_IMPORTFILE", $this->lng->txt("import_file")); $this->tpl->setVariable ("TXT_UPLOAD_BTN", $this->lng->txt("import")); $this->tpl->setVariable ("TXT_SUBCHARACTERISTIC", $this->lng->txt("cont_src")); $this->tpl->setVariable ("TXT_LANGUAGE", $this->lng->txt("language")); $this->tpl->setVariable ("TXT_SHOWLINENUMBERS", $this->lng->txt("cont_show_line_numbers")); $this->tpl->setVariable ("TXT_AUTOINDENT", $this->lng->txt("cont_autoindent")); $this->tpl->setVariable ("FORMACTION", $this->ctrl->getFormAction($this)); require_once("classes/class.ilMetaData.php"); $lang = ilMetaData::getLanguages(); $select_lang = ilUtil::formSelect ($s_lang,"par_language",$lang,false,true); $this->tpl->setVariable ("SELECT_LANGUAGE", $select_lang); $prog_langs = $this->readProgLangs (); $select_subchar = ilUtil::formSelect ($s_proglang, "par_subcharacteristic",$prog_langs,false,true); $this->tpl->setVariable ("SELECT_SUBCHARACTERISTIC", $select_subchar); }
ilPCSourcecodeGUI::update | ( | ) |
update paragraph in dom and update page in db
Definition at line 272 of file class.ilPCSourcecodeGUI.php.
References $_POST, $ilBench, and edit().
Referenced by upload().
{ global $ilBench; $ilBench->start("Editor","Paragraph_update"); // set language and characteristic $this->content_obj->setLanguage($_POST["par_language"]); $this->content_obj->setCharacteristic($_POST["par_characteristic"]); //echo "PARupdate:".htmlentities($this->content_obj->input2xml($_POST["par_content"])).":<br>"; exit; // set language and characteristic $this->content_obj->setLanguage($_POST["par_language"]); $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]); $this->content_obj->setDownloadTitle($_POST["par_downloadtitle"]); $this->content_obj->setShowLineNumbers(($_POST["par_showlinenumbers"]=="on")?"y":"n"); $this->content_obj->setAutoIndent(($_POST["par_autoindent"]=="on")?"y":"n"); $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]); $this->content_obj->setCharacteristic("Code"); $this->updated = $this->content_obj->setText($this->content_obj->input2xml(stripslashes($_POST["par_content"]))); if ($this->updated !== true) { //echo "Did not update!"; $ilBench->stop("Editor","Paragraph_update"); $this->edit(); return; } $this->updated = $this->pg_obj->update(); $ilBench->stop("Editor","Paragraph_update"); if ($this->updated === true && $this->ctrl->getCmd () != "upload" ) { $this->ctrl->returnToParent($this, "jump".$this->hier_id); } else { $this->edit(); } }
ilPCSourcecodeGUI::upload | ( | ) |
Definition at line 408 of file class.ilPCSourcecodeGUI.php.
References update(), and upload_source().
{ $this->upload_source(); $this->update (); }
ilPCSourcecodeGUI::upload_source | ( | ) |
Definition at line 413 of file class.ilPCSourcecodeGUI.php.
References $_POST.
Referenced by create(), and upload().
{ if (isset($_FILES['userfile']['name'])) { $userfile = $_FILES['userfile']['tmp_name']; if ($userfile == "" || !is_uploaded_file($userfile)) { $error_str = "<b>Error(s):</b><br>Upload error: file name must not be empty!"; $this->tpl->setVariable("MESSAGE", $error_str); $this->content_obj->setText($this->content_obj->input2xml(stripslashes($_POST["par_content"]))); return false; } $_POST["par_content"] = file_get_contents($userfile); $_POST["par_downloadtitle"] = $_FILES['userfile']['name']; return true; } return false; }