ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 

Protected Attributes

 $user
 
- Protected Attributes inherited from ilPageContentGUI
 $error
 
 $log
 

Additional Inherited Members

- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 Get common bb buttons. More...
 
- Data Fields inherited from ilPageContentGUI
 $content_obj
 
 $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...
 
- 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 30 of file class.ilPCSourceCodeGUI.php.

31 {
32 global $DIC;
33
34 $this->user = $DIC->user();
35 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
36 }
user()
Definition: user.php:4
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ cancelCreate()

ilPCSourceCodeGUI::cancelCreate ( )

cancel creating paragraph

Reimplemented from ilPageContentGUI.

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

237 {
238 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
239 }

◆ cancelUpdate()

ilPCSourceCodeGUI::cancelUpdate ( )

cancel update

Reimplemented from ilPageContentGUI.

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

186 {
187 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
188 }

◆ create()

ilPCSourceCodeGUI::create ( )

create new paragraph in dom and update page in db

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

194 {
195 $this->content_obj = new ilPCSourceCode($this->getPage());
196 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
197 $this->content_obj->setLanguage($_POST["par_language"]);
198
199 $_SESSION["il_text_lang_" . $_GET["ref_id"]] = $_POST["par_language"];
200
201 $uploaded = $this->upload_source();
202
203 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
204 $this->content_obj->setSubCharacteristic($_POST["par_subcharacteristic"]);
205 $this->content_obj->setDownloadTitle(str_replace('"', '', ilUtil::stripSlashes($_POST["par_downloadtitle"])));
206 $this->content_obj->setShowLineNumbers($_POST["par_showlinenumbers"]?'y':'n');
207 $this->content_obj->setCharacteristic('Code');
208 //$this->content_obj->setAutoIndent ($_POST["par_autoindent"]?'y':'n');
209
210 if ($uploaded) {
211 $this->insert();
212 return;
213 }
214
215 $this->updated = $this->content_obj->setText(
216 $this->content_obj->input2xml($_POST["par_content"], 0, false)
217 );
218
219 if ($this->updated !== true) {
220 $this->insert();
221 return;
222 }
223
224 $this->updated = $this->pg_obj->update();
225
226 if ($this->updated === true && !$uploaded) {
227 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
228 } else {
229 $this->insert();
230 }
231 }
$_GET["client_id"]
$_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 $_GET, $_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 62 of file class.ilPCSourceCodeGUI.php.

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

43 {
44 // get next class that processes or forwards current command
45 $next_class = $this->ctrl->getNextClass($this);
46
47 // get current command
48 $cmd = $this->ctrl->getCmd();
49
50 switch ($next_class) {
51 default:
52 $ret = $this->$cmd();
53 break;
54 }
55
56 return $ret;
57 }
$ret
Definition: parser.php:6

References $ret.

◆ getProgLangOptions()

ilPCSourceCodeGUI::getProgLangOptions ( )

Get selectable programming languages.

Returns
string[]

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

268 {
269 $prog_langs = array(
270 "" => "other");
271 include_once("./Services/UIComponent/SyntaxHighlighter/classes/class.ilSyntaxHighlighter.php");
272 foreach (ilSyntaxHighlighter::getSupportedLanguagesV51() as $k => $v) {
273 $prog_langs[$k] = $v;
274 }
275 return $prog_langs;
276 }
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 286 of file class.ilPCSourceCodeGUI.php.

287 {
288 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
289 $form = new ilPropertyFormGUI();
290 $form->setTitle($a_title);
291 $form->setFormAction($this->ctrl->getFormAction($this, $a_cmd));
292 $form->addCommandButton($a_cmd, $this->lng->txt("save"));
293 $form->addCommandButton($a_cmd_cancel, $this->lng->txt("cancel"));
294
295
296 require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
298 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
299 $lang = new ilSelectInputGUI($this->lng->txt("language"), "par_language");
300 $lang->setOptions($lang_var);
301 $form->addItem($lang);
302
303 $prog_langs = $this->getProgLangOptions();
304 $code_style = new ilSelectInputGUI($this->lng->txt("cont_src"), "par_subcharacteristic");
305 $code_style->setOptions($prog_langs);
306 $form->addItem($code_style);
307 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
308 $line_number = new ilCheckboxInputGUI($this->lng->txt("cont_show_line_numbers"), "par_showlinenumbers");
309 $form->addItem($line_number);
310 //$indent = new ilCheckboxInputGUI($this->lng->txt("cont_autoindent"), "par_autoindent");
311 //$form->addItem($indent);
312
313
314 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
315 $code = new ilTextAreaInputGUI("", "par_content");
316 $code->setRows(12);
317 $form->addItem($code);
318
319 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
320 $downlaod_title = new ilTextInputGUI($this->lng->txt("cont_download_title"), "par_downloadtitle");
321 $downlaod_title->setSize(40);
322 $form->addItem($downlaod_title);
323
324 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
325 $file = new ilFileInputGUI($this->lng->txt("import_file"), "userfile");
326 $form->addItem($file);
327
328 return $form;
329 }
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.
$lang
Definition: xapiexit.php:8

References $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 104 of file class.ilPCSourceCodeGUI.php.

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

References $_GET, $_POST, $_SESSION, $ilUser, $user, 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 142 of file class.ilPCSourceCodeGUI.php.

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

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

+ Here is the call graph for this function:

◆ upload_source()

ilPCSourceCodeGUI::upload_source ( )

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

242 {
243 if (isset($_FILES['userfile']['name'])) {
244 $userfile = $_FILES['userfile']['tmp_name'];
245
246 if ($userfile == "" || !is_uploaded_file($userfile)) {
247 $error_str = "<b>Error(s):</b><br>Upload error: file name must not be empty!";
248 $this->tpl->setVariable("MESSAGE", $error_str);
249 $this->content_obj->setText($this->content_obj->input2xml(stripslashes($_POST["par_content"]), 0, false));
250 return false;
251 }
252
253 $_POST["par_content"] = file_get_contents($userfile);
254 $_POST["par_downloadtitle"] = $_FILES['userfile']['name'];
255 return true;
256 }
257
258 return false;
259 }

References $_POST.

Referenced by create(), and update().

+ Here is the caller graph for this function:

Field Documentation

◆ $user

ilPCSourceCodeGUI::$user
protected

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

Referenced by insert().


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