ILIAS  release_4-4 Revision
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. More...
 
executeCommand ()
 execute command More...
 
 edit ()
 edit paragraph form More...
 
 setTemplateText ($s_lang, $s_proglang)
 
 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 ()
 
 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. 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
 
- Protected Member Functions inherited from ilPageContentGUI
 getCharacteristicsOfCurrentStyle ($a_type)
 Get characteristics of current style. More...
 
- 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.

Member Function Documentation

◆ cancelCreate()

ilPCSourceCodeGUI::cancelCreate ( )

cancel creating paragraph

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

352  {
353  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
354  }

◆ cancelUpdate()

ilPCSourceCodeGUI::cancelUpdate ( )

cancel update

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

298  {
299  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
300  }

◆ create()

ilPCSourceCodeGUI::create ( )

create new paragraph in dom and update page in db

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

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

306  {
307  $this->content_obj = new ilPCSourceCode($this->getPage());
308  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
309  $this->content_obj->setLanguage($_POST["par_language"]);
310 
311  $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["par_language"];
312 
313  $uploaded = $this->upload_source();
314 
315  $this->content_obj->setCharacteristic ($_POST["par_characteristic"]);
316  $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]);
317  $this->content_obj->setDownloadTitle (str_replace('"', '', ilUtil::stripSlashes($_POST["par_downloadtitle"])));
318  $this->content_obj->setShowLineNumbers (($_POST["par_showlinenumbers"]=='on')?'y':'n');
319  $this->content_obj->setCharacteristic ('Code');
320  $this->content_obj->setAutoIndent (($_POST["par_indent"]=='on')?'y':'n');
321 
322  if ($uploaded) {
323  $this->insert ();
324  return;
325  }
326 
327  $this->updated = $this->content_obj->setText(
328  $this->content_obj->input2xml($_POST["par_content"], 0, false));
329 
330  if ($this->updated !== true)
331  {
332  $this->insert();
333  return;
334  }
335 
336  $this->updated = $this->pg_obj->update();
337 
338  if ($this->updated === true && !$uploaded)
339  {
340  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
341  }
342  else
343  {
344  $this->insert ();
345  }
346  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
$_POST['username']
Definition: cron.php:12
Class ilPCParagraph.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
insert()
insert paragraph form
+ Here is the call graph for this function:

◆ edit()

ilPCSourceCodeGUI::edit ( )

edit paragraph form

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

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

Referenced by update().

56  {
57  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.sourcecode_edit.html", "Services/COPage");
58  //$content = $this->pg_obj->getContent();
59  //$cnt = 1;
60  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_src"));
61 
62  if ($this->pg_obj->getParentType() == "lm" ||
63  $this->pg_obj->getParentType() == "dbk")
64  {
65  $this->tpl->setVariable("LINK_ILINK",
66  $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
67  $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
68  }
69 
70  $this->displayValidationError();
71 
72  // language and characteristic selection
73  if (key($_POST["cmd"]) == "update")
74  {
75  $s_lang = $_POST["par_language"];
76  $s_char = $_POST["par_characteristic"];
77  $s_subchar = $_POST["par_subcharacteristic"];
78  $s_downloadtitle = str_replace('"', '', ilUtil::stripSlashes($_POST["par_downloadtitle"]));
79  $s_showlinenumbers = ($_POST["par_showlinenumbers"]=="on")?'y':'n';
80  $s_autoindent = ($_POST["par_autoindent"]=="on")?'y':'n';
81  }
82  else
83  {
84  $s_lang = $this->content_obj->getLanguage();
85  $s_char = $this->content_obj->getCharacteristic();
86  $s_subchar = $this->content_obj->getSubCharacteristic();
87  $s_downloadtitle = $this->content_obj->getDownloadTitle();
88  $s_showlinenumbers = $this->content_obj->getShowLineNumbers();
89  $s_autoindent = $this->content_obj->getAutoIndent ();
90  }
91 
92  $this->setTemplateText($s_lang, $s_subchar);
93 
94  if (key($_POST["cmd"]) == "update")
95  {
96  $s_text = stripslashes($_POST["par_content"]);
97  }
98  else
99  {
100  $s_text = $this->content_obj->xml2output($this->content_obj->getText());
101  }
102 
103  $this->tpl->setVariable("PAR_TA_NAME", "par_content");
104  $this->tpl->setVariable("PAR_TA_CONTENT", ilUtil::prepareFormOutput($s_text));
105 //var_dump($this->tpl);
106 // $this->tpl->parseCurrentBlock();
107 
108  if (strcmp($s_showlinenumbers,"y")==0)
109  {
110  $this->tpl->setVariable("SHOWLINENUMBERS", "checked=\"checked\"");
111  }
112 
113  if (strcmp($s_autoindent,"y") == 0)
114  {
115  $this->tpl->setVariable("AUTOINDENT", "checked=\"checked\"");
116  }
117 
118 
119  $this->tpl->setVariable("DOWNLOAD_TITLE_VALUE", $s_downloadtitle);
120 
121  // operations
122  $this->tpl->setCurrentBlock("commands");
123  $this->tpl->setVariable("BTN_NAME", "update");
124  $this->tpl->setVariable("UPLOAD_BTN_NAME", "upload");
125  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
126  $this->tpl->setVariable("BTN_CANCEL", "cancelUpdate");
127  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
128  $this->tpl->parseCurrentBlock();
129  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$_POST['username']
Definition: cron.php:12
displayValidationError()
display validation errors
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setTemplateText($s_lang, $s_proglang)
+ 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.

References $cmd, and $ret.

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  }
$cmd
Definition: sahs_server.php:35

◆ ilPCSourceCodeGUI()

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.

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

◆ insert()

ilPCSourceCodeGUI::insert ( )

insert paragraph form

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

References $_GET, $_POST, $_SESSION, $ilUser, ilPageContentGUI\displayValidationError(), ilUtil\prepareFormOutput(), setTemplateText(), and ilUtil\stripSlashes().

Referenced by create().

161  {
162  global $ilUser;
163 
164  // add paragraph edit template
165  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.sourcecode_edit.html", "Services/COPage");
166  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_src"));
167 
168  if ($this->pg_obj->getParentType() == "lm" ||
169  $this->pg_obj->getParentType() == "dbk")
170  {
171  $this->tpl->setVariable("LINK_ILINK",
172  $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
173  $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
174  }
175 
176  $this->displayValidationError();
177 
178  // get values from new object (repeated form display on error)
179 
180  //echo key ($_POST["cmd"]);
181 
182  if (key($_POST["cmd"]) == "create_src")
183  {
184  $s_lang = $_POST["par_language"];
185  $s_subchar = $_POST["par_subcharacteristic"];
186  $s_downloadtitle = str_replace('"', '', ilUtil::stripSlashes($_POST["par_downloadtitle"]));
187  $s_showlinenumbers = strcmp($_POST["par_showlinenumbers"],'on')==0?'checked=\"true\"':'';
188  $s_autoindent = strcmp($_POST["par_autoindent"],'on')==0?'checked=\"true\"':'';
189  $s_isexample = strcmp($_POST["par_isexample"],"on")==0?'checked=\"true\"':'';
190  }
191  else
192  {
193  if ($_SESSION["il_text_lang_".$_GET["ref_id"]] != "")
194  {
195  $s_lang = $_SESSION["il_text_lang_".$_GET["ref_id"]];
196  }
197  else
198  {
199  $s_lang = $ilUser->getLanguage();
200  }
201 
202  $s_showlinenumbers = 'CHECKED';
203  $s_autoindent = 'CHECKED';
204  $s_isexample = '';
205  $s_subchar = '';
206  }
207 
208  $this->setTemplateText($s_lang, $s_subchar);
209 
210  $this->tpl->setVariable("SHOWLINENUMBERS", $s_showlinenumbers);
211  $this->tpl->setVariable("AUTOINDENT", $s_autoindent);
212  $this->tpl->setVariable("DOWNLOAD_TITLE_VALUE", $s_downloadtitle);
213  $this->tpl->setVariable("ISEXAMPLE", $s_isexample);
214 
215 
216  // content is in utf-8, todo: set globally
217  // header('Content-type: text/html; charset=UTF-8');
218 
219  // input text area
220  $this->tpl->setVariable("PAR_TA_NAME", "par_content");
221 
222  if (key($_POST["cmd"]) == "create_src")
223  {
224  $this->tpl->setVariable("PAR_TA_CONTENT", ilUtil::prepareFormOutput(stripslashes($_POST["par_content"])));
225  }
226  else
227  {
228  $this->tpl->setVariable("PAR_TA_CONTENT", "");
229  }
230 // $this->tpl->parseCurrentBlock();
231 
232  // operations
233  $this->tpl->setCurrentBlock("commands");
234  $this->tpl->setVariable("BTN_NAME", "create_src"); //--
235  $this->tpl->setVariable("UPLOAD_BTN_NAME", "create_src");
236  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
237  $this->tpl->setVariable("BTN_CANCEL", "cancelCreate");
238  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
239  $this->tpl->parseCurrentBlock();
240 
241  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
displayValidationError()
display validation errors
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilUser
Definition: imgupload.php:15
setTemplateText($s_lang, $s_proglang)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readProgLangs()

ilPCSourceCodeGUI::readProgLangs ( )

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

Referenced by setTemplateText().

383  {
384  $prog_langs_ini = file ("Services/COPage/syntax_highlight/php/admin/prog_langs.ini");
385  $prog_langs = array ("" => $this->lng->txt("cont_src_other"));
386  foreach ($prog_langs_ini as $prog_lang) {
387  $prog_lang_prop = split (":", $prog_lang);
388  if ($prog_lang_prop[2] == 1) {
389  $prog_langs[$prog_lang_prop[0]] = $prog_lang_prop[1];
390  }
391  }
392 
393  return $prog_langs;
394  }
+ Here is the caller graph for this function:

◆ setTemplateText()

ilPCSourceCodeGUI::setTemplateText (   $s_lang,
  $s_proglang 
)

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

References $lang, ilMDLanguageItem\_getLanguages(), ilUtil\formSelect(), and readProgLangs().

Referenced by edit(), and insert().

132  {
133  $this->tpl->setVariable ("TXT_CREATEFILE", $this->lng->txt("create_download_link"));
134  $this->tpl->setVariable ("TXT_DOWNLOADTITLE", $this->lng->txt("cont_download_title"));
135  $this->tpl->setVariable ("TXT_IMPORTFILE", $this->lng->txt("import_file"));
136  $this->tpl->setVariable ("TXT_UPLOAD_BTN", $this->lng->txt("import"));
137  $this->tpl->setVariable ("TXT_SUBCHARACTERISTIC", $this->lng->txt("cont_src"));
138  $this->tpl->setVariable ("TXT_LANGUAGE", $this->lng->txt("language"));
139  $this->tpl->setVariable ("TXT_SHOWLINENUMBERS", $this->lng->txt("cont_show_line_numbers"));
140  $this->tpl->setVariable ("TXT_AUTOINDENT", $this->lng->txt("cont_autoindent"));
141 
142 
143  $this->tpl->setVariable ("FORMACTION", $this->ctrl->getFormAction($this));
144 
145  require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
147  $select_lang = ilUtil::formSelect ($s_lang,"par_language",$lang,false,true);
148  $this->tpl->setVariable ("SELECT_LANGUAGE", $select_lang);
149 
150  $prog_langs = $this->readProgLangs ();
151 
152  $select_subchar = ilUtil::formSelect ($s_proglang, "par_subcharacteristic",$prog_langs,false,true);
153  $this->tpl->setVariable ("SELECT_SUBCHARACTERISTIC", $select_subchar);
154 
155  }
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
+ 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 247 of file class.ilPCSourceCodeGUI.php.

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

Referenced by upload().

248  {
249  global $ilBench;
250 
251  $ilBench->start("Editor","Paragraph_update");
252  // set language and characteristic
253 
254  $this->content_obj->setLanguage($_POST["par_language"]);
255  $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
256 
257  //echo "PARupdate:".htmlentities($this->content_obj->input2xml($_POST["par_content"])).":<br>"; exit;
258 
259 
260  // set language and characteristic
261  $this->content_obj->setLanguage($_POST["par_language"]);
262  $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]);
263  $this->content_obj->setDownloadTitle(str_replace('"', '', ilUtil::stripSlashes($_POST["par_downloadtitle"])));
264  $this->content_obj->setShowLineNumbers(($_POST["par_showlinenumbers"]=="on")?"y":"n");
265  $this->content_obj->setAutoIndent(($_POST["par_autoindent"]=="on")?"y":"n");
266  $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]);
267  $this->content_obj->setCharacteristic("Code");
268 
269  $this->updated = $this->content_obj->setText(
270  $this->content_obj->input2xml($_POST["par_content"], 0, false));
271 
272  if ($this->updated !== true)
273  {
274  //echo "Did not update!";
275  $ilBench->stop("Editor","Paragraph_update");
276  $this->edit();
277  return;
278  }
279 
280  $this->updated = $this->pg_obj->update();
281 
282  $ilBench->stop("Editor","Paragraph_update");
283 
284  if ($this->updated === true && $this->ctrl->getCmd () != "upload" )
285  {
286  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
287  }
288  else
289  {
290  $this->edit();
291  }
292  }
$_POST['username']
Definition: cron.php:12
edit()
edit paragraph form
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilBench
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ upload()

ilPCSourceCodeGUI::upload ( )

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

References update(), and upload_source().

356  {
357  $this->upload_source();
358  $this->update ();
359  }
update()
update paragraph in dom and update page in db
+ Here is the call graph for this function:

◆ upload_source()

ilPCSourceCodeGUI::upload_source ( )

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

References $_POST.

Referenced by create(), and upload().

361  {
362  if (isset($_FILES['userfile']['name']))
363  {
364  $userfile = $_FILES['userfile']['tmp_name'];
365 
366  if ($userfile == "" || !is_uploaded_file($userfile))
367  {
368  $error_str = "<b>Error(s):</b><br>Upload error: file name must not be empty!";
369  $this->tpl->setVariable("MESSAGE", $error_str);
370  $this->content_obj->setText($this->content_obj->input2xml(stripslashes($_POST["par_content"]), 0, false));
371  return false;
372  }
373 
374  $_POST["par_content"] = file_get_contents($userfile);
375  $_POST["par_downloadtitle"] = $_FILES['userfile']['name'];
376  return true;
377  }
378 
379  return false;
380  }
$_POST['username']
Definition: cron.php:12
+ Here is the caller graph for this function:

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