ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 @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 ()
 
 readProgLangs ()
 
 initPropertyForm ($a_title, $a_cmd, $a_cmd_cancel)
 initiates property form GUI class More...
 
- Public Member Functions inherited from ilPageContentGUI
 ilPageContentGUI ($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.

Member Function Documentation

◆ cancelCreate()

ilPCSourceCodeGUI::cancelCreate ( )

cancel creating paragraph

Reimplemented from ilPageContentGUI.

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

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

◆ cancelUpdate()

ilPCSourceCodeGUI::cancelUpdate ( )

cancel update

Reimplemented from ilPageContentGUI.

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

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

◆ create()

ilPCSourceCodeGUI::create ( )

create new paragraph in dom and update page in db

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

204 {
205 $this->content_obj = new ilPCSourceCode($this->getPage());
206 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
207 $this->content_obj->setLanguage($_POST["par_language"]);
208
209 $_SESSION["il_text_lang_".$_GET["ref_id"]] = $_POST["par_language"];
210
211 $uploaded = $this->upload_source();
212
213 $this->content_obj->setCharacteristic ($_POST["par_characteristic"]);
214 $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]);
215 $this->content_obj->setDownloadTitle (str_replace('"', '', ilUtil::stripSlashes($_POST["par_downloadtitle"])));
216 $this->content_obj->setShowLineNumbers ($_POST["par_showlinenumbers"]?'y':'n');
217 $this->content_obj->setCharacteristic ('Code');
218 $this->content_obj->setAutoIndent ($_POST["par_autoindent"]?'y':'n');
219
220 if ($uploaded) {
221 $this->insert ();
222 return;
223 }
224
225 $this->updated = $this->content_obj->setText(
226 $this->content_obj->input2xml($_POST["par_content"], 0, false));
227
228 if ($this->updated !== true)
229 {
230 $this->insert();
231 return;
232 }
233
234 $this->updated = $this->pg_obj->update();
235
236 if ($this->updated === true && !$uploaded)
237 {
238 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
239 }
240 else
241 {
242 $this->insert ();
243 }
244 }
$_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
$_POST['username']
Definition: cron.php:12

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 $this->pg_obj->getParentType() == "dbk")
61 {
62 $this->tpl->setVariable("LINK_ILINK",
63 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp"));
64 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_internal_link")."]");
65 }
66
68
69 if (key($_POST["cmd"]) == "update")
70 {
71 $form->setValuesByPost();
72
73 }
74 else{
75 $form->getItemByPostVar("par_language")->setValue($this->content_obj->getLanguage());
76 $form->getItemByPostVar("par_subcharacteristic")->setValue($this->content_obj->getSubCharacteristic());
77 $form->getItemByPostVar("par_downloadtitle")->setValue( $this->content_obj->getDownloadTitle());
78 $form->getItemByPostVar("par_showlinenumbers")->setChecked(
79 $this->content_obj->getShowLineNumbers()=="y"?true:false);
80 $form->getItemByPostVar("par_autoindent")->setChecked(
81 $this->content_obj->getAutoIndent()=="y"?true:false);
82
83 $par_content = $this->content_obj->xml2output($this->content_obj->getText());
84
85 //TODO: Find a better way to convert back curly brackets
86 $par_content = str_replace("{","{", $par_content);
87 $par_content = str_replace("}","}", $par_content);
88
89 $form->getItemByPostVar("par_content")->setValue($par_content);
90 }
91
92
93 $this->tpl->setContent($form->getHTML());
94 }
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 }
$cmd
Definition: sahs_server.php:35

References $cmd, and $ret.

◆ ilPCSourceCodeGUI()

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

Constructor @access 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 }

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

298 {
299
300 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
301 $form = new ilPropertyFormGUI();
302 $form->setTitle($a_title);
303 $form->setFormAction($this->ctrl->getFormAction($this, $a_cmd));
304 $form->addCommandButton($a_cmd_cancel,$this->lng->txt("cancel"));
305 $form->addCommandButton($a_cmd,$this->lng->txt("save"));
306
307 require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
309 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
310 $lang = new ilSelectInputGUI($this->lng->txt("language"),"par_language");
311 $lang->setOptions($lang_var);
312 $form->addItem($lang);
313
314 $prog_langs = $this->readProgLangs ();
315 $code_style = new ilSelectInputGUI( $this->lng->txt("cont_src"), "par_subcharacteristic");
316 $code_style->setOptions($prog_langs);
317 $form->addItem($code_style);
318 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
319 $line_number = new ilCheckboxInputGUI($this->lng->txt("cont_show_line_numbers"), "par_showlinenumbers");
320 $form->addItem($line_number);
321 $indent = new ilCheckboxInputGUI($this->lng->txt("cont_autoindent"), "par_autoindent");
322 $form->addItem($indent);
323
324
325 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
326 $code = new ilTextAreaInputGUI("", "par_content");
327 $code->setRows(12);
328 $form->addItem($code);
329
330 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
331 $downlaod_title = new ilTextInputGUI($this->lng->txt("cont_download_title"), "par_downloadtitle");
332 $downlaod_title->setSize(40);
333 $form->addItem($downlaod_title);
334
335 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
336 $file = new ilFileInputGUI($this->lng->txt("import_file"), "userfile");
337 $form->addItem($file);
338
339 return $form;
340 }
print $file
This class represents a checkbox property in a property form.
This class represents a file property in a property form.
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

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

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

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

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:

◆ readProgLangs()

ilPCSourceCodeGUI::readProgLangs ( )

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

276 {
277 $prog_langs_ini = file ("Services/COPage/syntax_highlight/php/admin/prog_langs.ini");
278 $prog_langs = array ("" => $this->lng->txt("cont_src_other"));
279 foreach ($prog_langs_ini as $prog_lang) {
280 $prog_lang_prop = split (":", $prog_lang);
281 if ($prog_lang_prop[2] == 1) {
282 $prog_langs[$prog_lang_prop[0]] = $prog_lang_prop[1];
283 }
284 }
285
286 return $prog_langs;
287 }

Referenced by initPropertyForm().

+ Here is the caller graph for this function:

◆ update()

ilPCSourceCodeGUI::update ( )

update paragraph in dom and update page in db

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

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

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

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: