ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilPCSourceCodeGUI Class Reference

Class ilPCSourcecodeGUI. More...

+ Inheritance diagram for ilPCSourceCodeGUI:
+ Collaboration diagram for ilPCSourceCodeGUI:

Public Member Functions

 __construct ($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
 Constructor @access public. More...
 
 executeCommand ()
 execute command More...
 
 edit ()
 edit paragraph form More...
 
 insert ()
 insert paragraph form More...
 
 update ()
 update paragraph in dom and update page in db More...
 
 cancelUpdate ()
 cancel update More...
 
 create ()
 create new paragraph in dom and update page in db More...
 
 cancelCreate ()
 cancel creating paragraph More...
 
 upload_source ()
 
 getProgLangOptions ()
 Get selectable programming languages. More...
 
 initPropertyForm ($a_title, $a_cmd, $a_cmd_cancel)
 initiates property form GUI class More...
 
- Public Member Functions inherited from ilPageContentGUI
 __construct ($a_pg_obj, $a_content_obj, $a_hier_id=0, $a_pc_id="")
 Constructor @access public. More...
 
 setContentObject ($a_val)
 Set content object. More...
 
 getContentObject ()
 Get content object. More...
 
 setPage ($a_val)
 Set page. More...
 
 getPage ()
 Get page. More...
 
 setPageConfig ($a_val)
 Set Page Config. More...
 
 getPageConfig ()
 Get Page Config. More...
 
 setStyleId ($a_styleid)
 Set Style Id. More...
 
 getStyleId ()
 Get Style Id. More...
 
 getStyle ()
 Get style object. More...
 
 setCharacteristics ($a_chars)
 Set Characteristics. More...
 
 getCharacteristics ()
 Get characteristics. More...
 
 getHierId ()
 get hierarchical id in dom object More...
 
 setHierId ($a_hier_id)
 get hierarchical id in dom object More...
 
 getBBMenu ($a_ta_name="par_content")
 Get the bb menu incl. More...
 
 delete ()
 delete content element More...
 
 moveAfter ()
 move content element after another element More...
 
 moveBefore ()
 move content element before another element More...
 
 splitPage ()
 split page to new page at specified position More...
 
 splitPageNext ()
 split page to next page at specified position More...
 
 displayValidationError ()
 display validation errors More...
 
 cancelCreate ()
 cancel creating page content More...
 
 cancelUpdate ()
 cancel update More...
 
 cancel ()
 Cancel. More...
 
 deactivate ()
 gui function set enabled if is not enabled and vice versa More...
 
 cut ()
 Cut single element. More...
 
 copy ()
 Copy single element. More...
 
 getTemplateOptions ($a_type)
 Get table templates. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 Get common bb buttons. More...
 
- 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. More...
 
- Protected Attributes inherited from ilPageContentGUI
 $log
 
- 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$

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

Constructor & Destructor Documentation

◆ __construct()

ilPCSourceCodeGUI::__construct (   $a_pg_obj,
  $a_content_obj,
  $a_hier_id,
  $a_pc_id = "" 
)

Constructor @access public.

Reimplemented from ilPageContentGUI.

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

26 {
27 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
28 }

Member Function Documentation

◆ cancelCreate()

ilPCSourceCodeGUI::cancelCreate ( )

cancel creating paragraph

Reimplemented from ilPageContentGUI.

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

248 {
249 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
250 }

◆ cancelUpdate()

ilPCSourceCodeGUI::cancelUpdate ( )

cancel update

Reimplemented from ilPageContentGUI.

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

194 {
195 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
196 }

◆ create()

ilPCSourceCodeGUI::create ( )

create new paragraph in dom and update page in db

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

202 {
203 $this->content_obj = new ilPCSourceCode($this->getPage());
204 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
205 $this->content_obj->setLanguage($_POST["par_language"]);
206
207 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["par_language"];
208
209 $uploaded = $this->upload_source();
210
211 $this->content_obj->setCharacteristic ($_POST["par_characteristic"]);
212 $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]);
213 $this->content_obj->setDownloadTitle (str_replace('"', '', ilUtil::stripSlashes($_POST["par_downloadtitle"])));
214 $this->content_obj->setShowLineNumbers ($_POST["par_showlinenumbers"]?'y':'n');
215 $this->content_obj->setCharacteristic ('Code');
216 //$this->content_obj->setAutoIndent ($_POST["par_autoindent"]?'y':'n');
217
218 if ($uploaded) {
219 $this->insert ();
220 return;
221 }
222
223 $this->updated = $this->content_obj->setText(
224 $this->content_obj->input2xml($_POST["par_content"], 0, false));
225
226 if ($this->updated !== true)
227 {
228 $this->insert();
229 return;
230 }
231
232 $this->updated = $this->pg_obj->update();
233
234 if ($this->updated === true && !$uploaded)
235 {
236 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
237 }
238 else
239 {
240 $this->insert ();
241 }
242 }
$_POST["username"]
$_SESSION["AccountId"]
insert()
insert paragraph form
Class ilPCSourceCode.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

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

+ Here is the call graph for this function:

◆ edit()

ilPCSourceCodeGUI::edit ( )

edit paragraph form

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

56 {
57 $form = $this->initPropertyForm($this->lng->txt("cont_edit_src"), "update", "cancelCreate");
58
59 if ($this->pg_obj->getParentType() == "lm")
60 {
61 $this->tpl->setVariable("LINK_ILINK",
62 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
63 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
64 }
65
67
68 if (key($_POST["cmd"]) == "update")
69 {
70 $form->setValuesByPost();
71
72 }
73 else{
74 $form->getItemByPostVar("par_language")->setValue($this->content_obj->getLanguage());
75 $form->getItemByPostVar("par_subcharacteristic")->setValue($this->content_obj->getSubCharacteristic());
76 $form->getItemByPostVar("par_downloadtitle")->setValue( $this->content_obj->getDownloadTitle());
77 $form->getItemByPostVar("par_showlinenumbers")->setChecked(
78 $this->content_obj->getShowLineNumbers()=="y"?true:false);
79// $form->getItemByPostVar("par_autoindent")->setChecked(
80// $this->content_obj->getAutoIndent()=="y"?true:false);
81
82 $par_content = $this->content_obj->xml2output($this->content_obj->getText());
83
84 //TODO: Find a better way to convert back curly brackets
85 $par_content = str_replace("{","{", $par_content);
86 $par_content = str_replace("}","}", $par_content);
87
88 $form->getItemByPostVar("par_content")->setValue($par_content);
89 }
90
91
92 $this->tpl->setContent($form->getHTML());
93 }
initPropertyForm($a_title, $a_cmd, $a_cmd_cancel)
initiates property form GUI class
displayValidationError()
display validation errors

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

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPCSourceCodeGUI::executeCommand ( )

execute command

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

35 {
36 // get next class that processes or forwards current command
37 $next_class = $this->ctrl->getNextClass($this);
38
39 // get current command
40 $cmd = $this->ctrl->getCmd();
41
42 switch($next_class)
43 {
44 default:
45 $ret = $this->$cmd();
46 break;
47 }
48
49 return $ret;
50 }
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35

References $cmd, and $ret.

◆ getProgLangOptions()

ilPCSourceCodeGUI::getProgLangOptions ( )

Get selectable programming languages.

Returns
string[]

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

280 {
281 $prog_langs = array(
282 "" => "other");
283 include_once("./Services/UIComponent/SyntaxHighlighter/classes/class.ilSyntaxHighlighter.php");
285 {
286 $prog_langs[$k] = $v;
287 }
288 return $prog_langs;
289 }
static getSupportedLanguagesV51()
Get supported languages (keys are ILIAS <= 5.1 internal values, values are for representation)

References ilSyntaxHighlighter\getSupportedLanguagesV51().

Referenced by initPropertyForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initPropertyForm()

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 299 of file class.ilPCSourceCodeGUI.php.

300 {
301
302 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
303 $form = new ilPropertyFormGUI();
304 $form->setTitle($a_title);
305 $form->setFormAction($this->ctrl->getFormAction($this, $a_cmd));
306 $form->addCommandButton($a_cmd,$this->lng->txt("save"));
307 $form->addCommandButton($a_cmd_cancel,$this->lng->txt("cancel"));
308
309
310 require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
312 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
313 $lang = new ilSelectInputGUI($this->lng->txt("language"),"par_language");
314 $lang->setOptions($lang_var);
315 $form->addItem($lang);
316
317 $prog_langs = $this->getProgLangOptions();
318 $code_style = new ilSelectInputGUI( $this->lng->txt("cont_src"), "par_subcharacteristic");
319 $code_style->setOptions($prog_langs);
320 $form->addItem($code_style);
321 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
322 $line_number = new ilCheckboxInputGUI($this->lng->txt("cont_show_line_numbers"), "par_showlinenumbers");
323 $form->addItem($line_number);
324 //$indent = new ilCheckboxInputGUI($this->lng->txt("cont_autoindent"), "par_autoindent");
325 //$form->addItem($indent);
326
327
328 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
329 $code = new ilTextAreaInputGUI("", "par_content");
330 $code->setRows(12);
331 $form->addItem($code);
332
333 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
334 $downlaod_title = new ilTextInputGUI($this->lng->txt("cont_download_title"), "par_downloadtitle");
335 $downlaod_title->setSize(40);
336 $form->addItem($downlaod_title);
337
338 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
339 $file = new ilFileInputGUI($this->lng->txt("import_file"), "userfile");
340 $form->addItem($file);
341
342 return $form;
343 }
This class represents a checkbox property in a property form.
This class represents a file property in a property form.
getProgLangOptions()
Get selectable programming languages.
This class represents a property form user interface.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
$code
Definition: example_050.php:99
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $code, $file, $lang, ilMDLanguageItem\_getLanguages(), and getProgLangOptions().

Referenced by edit(), and insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

ilPCSourceCodeGUI::insert ( )

insert paragraph form

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

99 {
100 global $ilUser;
101
102 $form = $this->initPropertyForm($this->lng->txt("cont_insert_src"), "create_src", "cancelCreate");
103
104 if ($this->pg_obj->getParentType() == "lm")
105 {
106 $this->tpl->setVariable("LINK_ILINK",
107 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
108 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
109 }
110
111 $this->displayValidationError();
112
113 if (key($_POST["cmd"]) == "create_src")
114 {
115 $form->setValuesByPost();
116
117 }
118 else{
119 if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
120 {
121 $form->getItemByPostVar("par_language")->setValue($_SESSION["il_text_lang_".$_GET["ref_id"]]);
122 }
123 else
124 {
125 $form->getItemByPostVar("par_language")->setValue($ilUser->getLanguage());
126 }
127
128 $form->getItemByPostVar("par_showlinenumbers")->setChecked(true);
129// $form->getItemByPostVar("par_autoindent")->setChecked(true);
130 $form->getItemByPostVar("par_subcharacteristic")->setValue("");
131 $form->getItemByPostVar("par_content")->setValue("");
132 }
133
134 $this->tpl->setContent($form->getHTML());
135 }
$_GET["client_id"]
$ilUser
Definition: imgupload.php:18

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

Referenced by create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilPCSourceCodeGUI::update ( )

update paragraph in dom and update page in db

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

142 {
143 global $ilBench;
144
145 $this->upload_source();
146
147 $ilBench->start("Editor","Paragraph_update");
148 // set language and characteristic
149
150 $this->content_obj->setLanguage($_POST["par_language"]);
151 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
152
153 //echo "PARupdate:".htmlentities($this->content_obj->input2xml($_POST["par_content"])).":<br>"; exit;
154
155
156 // set language and characteristic
157 $this->content_obj->setLanguage($_POST["par_language"]);
158 $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]);
159 $this->content_obj->setDownloadTitle(str_replace('"', '', ilUtil::stripSlashes($_POST["par_downloadtitle"])));
160 $this->content_obj->setShowLineNumbers($_POST["par_showlinenumbers"]?"y":"n");
161 //$this->content_obj->setAutoIndent($_POST["par_autoindent"]?"y":"n");
162 $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]);
163 $this->content_obj->setCharacteristic("Code");
164
165 $this->updated = $this->content_obj->setText(
166 $this->content_obj->input2xml($_POST["par_content"], 0, false));
167
168 if ($this->updated !== true)
169 {
170 //echo "Did not update!";
171 $ilBench->stop("Editor","Paragraph_update");
172 $this->edit();
173 return;
174 }
175
176 $this->updated = $this->pg_obj->update();
177
178 $ilBench->stop("Editor","Paragraph_update");
179
180 if ($this->updated === true && $this->ctrl->getCmd () != "upload" )
181 {
182 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
183 }
184 else
185 {
186 $this->edit();
187 }
188 }
edit()
edit paragraph form
global $ilBench
Definition: ilias.php:18

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

+ Here is the call graph for this function:

◆ upload_source()

ilPCSourceCodeGUI::upload_source ( )

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

252 {
253 if (isset($_FILES['userfile']['name']))
254 {
255 $userfile = $_FILES['userfile']['tmp_name'];
256
257 if ($userfile == "" || !is_uploaded_file($userfile))
258 {
259 $error_str = "<b>Error(s):</b><br>Upload error: file name must not be empty!";
260 $this->tpl->setVariable("MESSAGE", $error_str);
261 $this->content_obj->setText($this->content_obj->input2xml(stripslashes($_POST["par_content"]), 0, false));
262 return false;
263 }
264
265 $_POST["par_content"] = file_get_contents($userfile);
266 $_POST["par_downloadtitle"] = $_FILES['userfile']['name'];
267 return true;
268 }
269
270 return false;
271 }

References $_POST.

Referenced by create(), and update().

+ Here is the caller graph for this function:

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