ILIAS  Release_5_0_x_branch Revision 61816
 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
 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_source ()
 readProgLangs ()
 initPropertyForm ($a_title, $a_cmd, $a_cmd_cancel)
 initiates property form GUI class
- Public Member Functions inherited from ilPageContentGUI
 ilPageContentGUI ($a_pg_obj, $a_content_obj, $a_hier_id=0, $a_pc_id="")
 Constructor public.
 setContentObject ($a_val)
 Set content object.
 getContentObject ()
 Get content object.
 setPage ($a_val)
 Set page.
 getPage ()
 Get page.
 setPageConfig ($a_val)
 Set Page Config.
 getPageConfig ()
 Get Page Config.
 setStyleId ($a_styleid)
 Set Style Id.
 getStyleId ()
 Get Style Id.
 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
 cancel ()
 Cancel.
 deactivate ()
 gui function set enabled if is not enabled and vice versa
 cut ()
 Cut single element.
 copy ()
 Copy single element.
 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
 $page_config = null
- Static Public Attributes inherited from ilPageContentGUI
static $style_selector_reset = "margin-top:2px; margin-bottom:2px; text-indent:0px; position:static; float:none; width: auto;"
- 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 54786 2014-11-04 10:45:58Z fwolf

Definition at line 18 of file class.ilPCSourceCodeGUI.php.

Member Function Documentation

ilPCSourceCodeGUI::cancelCreate ( )

cancel creating paragraph

Reimplemented from ilPageContentGUI.

Definition at line 249 of file class.ilPCSourceCodeGUI.php.

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

cancel update

Reimplemented from ilPageContentGUI.

Definition at line 195 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 203 of file class.ilPCSourceCodeGUI.php.

References $_POST, $_SESSION, ilPageContentGUI\getPage(), insert(), ilUtil\stripSlashes(), and upload_source().

{
$this->content_obj = new ilPCSourceCode($this->getPage());
$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 (str_replace('"', '', ilUtil::stripSlashes($_POST["par_downloadtitle"])));
$this->content_obj->setShowLineNumbers ($_POST["par_showlinenumbers"]?'y':'n');
$this->content_obj->setCharacteristic ('Code');
$this->content_obj->setAutoIndent ($_POST["par_autoindent"]?'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 55 of file class.ilPCSourceCodeGUI.php.

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

Referenced by update().

{
$form = $this->initPropertyForm($this->lng->txt("cont_edit_src"), "update", "cancelCreate");
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")."]");
}
if (key($_POST["cmd"]) == "update")
{
$form->setValuesByPost();
}
else{
$form->getItemByPostVar("par_language")->setValue($this->content_obj->getLanguage());
$form->getItemByPostVar("par_subcharacteristic")->setValue($this->content_obj->getSubCharacteristic());
$form->getItemByPostVar("par_downloadtitle")->setValue( $this->content_obj->getDownloadTitle());
$form->getItemByPostVar("par_showlinenumbers")->setChecked(
$this->content_obj->getShowLineNumbers()=="y"?true:false);
$form->getItemByPostVar("par_autoindent")->setChecked(
$this->content_obj->getAutoIndent()=="y"?true:false);
$par_content = $this->content_obj->xml2output($this->content_obj->getText());
//TODO: Find a better way to convert back curly brackets
$par_content = str_replace("{","{", $par_content);
$par_content = str_replace("}","}", $par_content);
$form->getItemByPostVar("par_content")->setValue($par_content);
}
$this->tpl->setContent($form->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilPCSourceCodeGUI::executeCommand ( )

execute command

Definition at line 34 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 25 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::initPropertyForm (   $a_title,
  $a_cmd,
  $a_cmd_cancel 
)

initiates property form GUI class

Parameters
string$a_title
string$a_cmd
string$a_cmd_cancel
Returns
ilPropertyFormGUI form class

Definition at line 297 of file class.ilPCSourceCodeGUI.php.

References $file, $lang, ilMDLanguageItem\_getLanguages(), readProgLangs(), ilSelectInputGUI\setOptions(), and ilTextInputGUI\setSize().

Referenced by edit(), and insert().

{
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setTitle($a_title);
$form->setFormAction($this->ctrl->getFormAction($this, $a_cmd));
$form->addCommandButton($a_cmd_cancel,$this->lng->txt("cancel"));
$form->addCommandButton($a_cmd,$this->lng->txt("save"));
require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
$lang = new ilSelectInputGUI($this->lng->txt("language"),"par_language");
$lang->setOptions($lang_var);
$form->addItem($lang);
$prog_langs = $this->readProgLangs ();
$code_style = new ilSelectInputGUI( $this->lng->txt("cont_src"), "par_subcharacteristic");
$code_style->setOptions($prog_langs);
$form->addItem($code_style);
include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
$line_number = new ilCheckboxInputGUI($this->lng->txt("cont_show_line_numbers"), "par_showlinenumbers");
$form->addItem($line_number);
$indent = new ilCheckboxInputGUI($this->lng->txt("cont_autoindent"), "par_autoindent");
$form->addItem($indent);
include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
$code = new ilTextAreaInputGUI("", "par_content");
$code->setRows(12);
$form->addItem($code);
include_once("./Services/Form/classes/class.ilTextInputGUI.php");
$downlaod_title = new ilTextInputGUI($this->lng->txt("cont_download_title"), "par_downloadtitle");
$downlaod_title->setSize(40);
$form->addItem($downlaod_title);
include_once("./Services/Form/classes/class.ilFileInputGUI.php");
$file = new ilFileInputGUI($this->lng->txt("import_file"), "userfile");
$form->addItem($file);
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCSourceCodeGUI::insert ( )

insert paragraph form

Definition at line 99 of file class.ilPCSourceCodeGUI.php.

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

Referenced by create().

{
global $ilUser;
$form = $this->initPropertyForm($this->lng->txt("cont_insert_src"), "create_src", "cancelCreate");
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")."]");
}
if (key($_POST["cmd"]) == "create_src")
{
$form->setValuesByPost();
}
else{
if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
{
$form->getItemByPostVar("par_language")->setValue($_SESSION["il_text_lang_".$_GET["ref_id"]]);
}
else
{
$form->getItemByPostVar("par_language")->setValue($ilUser->getLanguage());
}
$form->getItemByPostVar("par_showlinenumbers")->setChecked(true);
$form->getItemByPostVar("par_autoindent")->setChecked(true);
$form->getItemByPostVar("par_subcharacteristic")->setValue("");
$form->getItemByPostVar("par_content")->setValue("");
}
$this->tpl->setContent($form->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCSourceCodeGUI::readProgLangs ( )

Definition at line 276 of file class.ilPCSourceCodeGUI.php.

Referenced by initPropertyForm().

{
$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::update ( )

update paragraph in dom and update page in db

Definition at line 143 of file class.ilPCSourceCodeGUI.php.

References $_POST, $ilBench, edit(), ilUtil\stripSlashes(), and upload_source().

{
global $ilBench;
$this->upload_source();
$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(str_replace('"', '', ilUtil::stripSlashes($_POST["par_downloadtitle"])));
$this->content_obj->setShowLineNumbers($_POST["par_showlinenumbers"]?"y":"n");
$this->content_obj->setAutoIndent($_POST["par_autoindent"]?"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:

ilPCSourceCodeGUI::upload_source ( )

Definition at line 254 of file class.ilPCSourceCodeGUI.php.

References $_POST.

Referenced by create(), and update().

{
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: