ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPCSourcecodeGUI Class Reference

Class ilPCSourcecodeGUI. More...

+ Inheritance diagram for ilPCSourcecodeGUI:
+ Collaboration diagram for ilPCSourcecodeGUI:

Public Member Functions

 ilPCSourcecodeGUI (&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_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
 upload ()
 upload_source ()
 readProgLangs ()
- Public Member Functions inherited from ilPageContentGUI
 ilPageContentGUI (&$a_pg_obj, &$a_content_obj, $a_hier_id=0, $a_pc_id="")
 Constructor public.
 setStyleId ($a_styleid)
 Set Style Id.
 getStyleId ()
 Get Style Id.
 setEnableInternalLinks ($a_val)
 Set enable internal links.
 getEnableInternalLinks ()
 Get enable internal links.
 setEnableKeywords ($a_val)
 Set enable keywords handling.
 getEnableKeywords ()
 Get enable keywords handling.
 setEnableAnchors ($a_val)
 Set enable anchors.
 getEnableAnchors ()
 Get enable anchors.
 getStyle ()
 Get style object.
 setCharacteristics ($a_chars)
 Set Characteristics.
 getCharacteristics ()
 Get characteristics.
 getHierId ()
 get hierarchical id in dom object
 setHierId ($a_hier_id)
 get hierarchical id in dom object
 getBBMenu ($a_ta_name="par_content")
 Get the bb menu incl.
 delete ()
 delete content element
 moveAfter ()
 move content element after another element
 moveBefore ()
 move content element before another element
 splitPage ()
 split page to new page at specified position
 splitPageNext ()
 split page to next page at specified position
 displayValidationError ()
 display validation errors
 deactivate ()
 gui function set enabled if is not enabled and vice versa
 getTemplateOptions ($a_type)
 Get table templates.

Additional Inherited Members

- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 Get common bb buttons.
- Data Fields inherited from ilPageContentGUI
 $content_obj
 $ilias
 $tpl
 $lng
 $ctrl
 $pg_obj
 $hier_id
 $dom
 $updated
 $target_script
 $return_location
- Protected Member Functions inherited from ilPageContentGUI
 getCharacteristicsOfCurrentStyle ($a_type)
 Get characteristics of current style.
- Static Protected Attributes inherited from ilPageContentGUI
static $common_bb_buttons

Detailed Description

Class ilPCSourcecodeGUI.

User Interface for Paragraph Editing

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilPCSourcecodeGUI.php 17809 2008-11-03 10:59:54Z akill

Definition at line 37 of file class.ilPCSourcecodeGUI.php.

Member Function Documentation

ilPCSourcecodeGUI::cancelCreate ( )

cancel creating paragraph

Reimplemented from ilPageContentGUI.

Definition at line 370 of file class.ilPCSourcecodeGUI.php.

{
$this->ctrl->returnToParent($this, "jump".$this->hier_id);
}
ilPCSourcecodeGUI::cancelUpdate ( )

cancel update

Reimplemented from ilPageContentGUI.

Definition at line 316 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 324 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->pc_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"], 0, false));
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 ();
}
}

+ Here is the call graph for this function:

ilPCSourcecodeGUI::edit ( )

edit paragraph form

Definition at line 74 of file class.ilPCSourcecodeGUI.php.

References $_POST, ilPageContentGUI\displayValidationError(), and setTemplateText().

Referenced by update().

{
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.sourcecode_edit.html", "Services/COPage");
//$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")."]");
}
// 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);
//var_dump($this->tpl);
// $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();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilPCSourcecodeGUI::executeCommand ( )

execute command

Definition at line 53 of file class.ilPCSourcecodeGUI.php.

References $cmd, and $ret.

{
// get next class that processes or forwards current command
$next_class = $this->ctrl->getNextClass($this);
// get current command
$cmd = $this->ctrl->getCmd();
switch($next_class)
{
default:
$ret =& $this->$cmd();
break;
}
return $ret;
}
ilPCSourcecodeGUI::ilPCSourcecodeGUI ( $a_pg_obj,
$a_content_obj,
  $a_hier_id,
  $a_pc_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, $a_pc_id);
}

+ Here is the call graph for this function:

ilPCSourcecodeGUI::insert ( )

insert paragraph form

Definition at line 179 of file class.ilPCSourcecodeGUI.php.

References $_GET, $_POST, $_SESSION, ilPageContentGUI\displayValidationError(), and setTemplateText().

Referenced by create().

{
global $ilUser;
// add paragraph edit template
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.sourcecode_edit.html", "Services/COPage");
$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")."]");
}
// 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();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCSourcecodeGUI::readProgLangs ( )

Definition at line 402 of file class.ilPCSourcecodeGUI.php.

Referenced by setTemplateText().

{
$prog_langs_ini = file ("Services/COPage/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;
}

+ Here is the caller graph for this function:

ilPCSourcecodeGUI::setTemplateText (   $s_lang,
  $s_proglang 
)

Definition at line 151 of file class.ilPCSourcecodeGUI.php.

References $lang, ilMDLanguageItem\_getLanguages(), formSelect(), 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("Services/MetaData/classes/class.ilMDLanguageItem.php");
$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);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCSourcecodeGUI::update ( )

update paragraph in dom and update page in db

Definition at line 266 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($_POST["par_content"], 0, false));
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();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCSourcecodeGUI::upload ( )

Definition at line 375 of file class.ilPCSourcecodeGUI.php.

References update(), and upload_source().

{
$this->upload_source();
$this->update ();
}

+ Here is the call graph for this function:

ilPCSourcecodeGUI::upload_source ( )

Definition at line 380 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"]), 0, false));
return false;
}
$_POST["par_content"] = file_get_contents($userfile);
$_POST["par_downloadtitle"] = $_FILES['userfile']['name'];
return true;
}
return false;
}

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: