ILIAS  release_8 Revision v8.23
ilPCSourceCodeGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
 
 executeCommand ()
 
 edit ()
 
 insert ()
 
 update ()
 
 cancelUpdate ()
 
 create ()
 
 cancelCreate ()
 
 upload_source ()
 
 getProgLangOptions ()
 Get selectable programming languages. More...
 
 initPropertyForm (string $a_title, string $a_cmd, string $a_cmd_cancel)
 
- Public Member Functions inherited from ilPageContentGUI
 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id="", string $a_pc_id="0")
 
 setContentObject (ilPageContent $a_val)
 
 getContentObject ()
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 setPageConfig (ilPageConfig $a_val)
 
 getPageConfig ()
 
 setStyleId (int $a_styleid)
 
 getStyleId ()
 
 getStyle ()
 
 getCharacteristicsOfCurrentStyle (array $a_type)
 Get characteristics of current style and call setCharacteristics, if style is given. More...
 
 setCharacteristics (array $a_chars)
 
 getCharacteristics ()
 
 getHierId ()
 
 setHierId (string $a_hier_id)
 set hierarchical id in dom object More...
 
 delete ()
 
 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 ()
 
 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 (string $a_type="")
 Get table templates. More...
 

Protected Attributes

string $requested_par_downloadtitle
 
string $requested_par_content
 
ilObjUser $user
 
- Protected Attributes inherited from ilPageContentGUI
EditSessionRepository $edit_repo
 
string $pc_id = ""
 
array $chars
 
ilObjStyleSheet $style = null
 
ilLogger $log
 
int $styleid = 0
 
EditGUIRequest $request
 
string $sub_command = ""
 
int $requested_ref_id = 0
 
Style Content CharacteristicManager $char_manager
 

Additional Inherited Members

- Static Public Member Functions inherited from ilPageContentGUI
static _getCommonBBButtons ()
 
- Data Fields inherited from ilPageContentGUI
ilPageContent $content_obj
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilPageObject $pg_obj
 
string $hier_id = ""
 
php4DOMDocument $dom
 
 $updated
 
string $target_script = ""
 
string $return_location = ""
 
ilPageConfig $page_config = null
 
- Static Public Attributes inherited from ilPageContentGUI
static string $style_selector_reset = "margin-top:2px; margin-bottom:2px; text-indent:0px; position:static; float:none; width: auto;"
 
- Protected Member Functions inherited from ilPageContentGUI
 redirectToParent (string $hier_id="")
 
 getParentReturn (string $hier_id="")
 
 updateAndReturn ()
 
 setCurrentTextLang (string $lang_key)
 
 getCurrentTextLang ()
 
- Static Protected Attributes inherited from ilPageContentGUI
static array $common_bb_buttons
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilPCSourcecodeGUI

User Interface for Paragraph Editing

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilPCSourceCodeGUI::__construct ( ilPageObject  $a_pg_obj,
?ilPageContent  $a_content_obj,
string  $a_hier_id,
string  $a_pc_id = "" 
)

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

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

40  {
41  global $DIC;
42 
43  $this->user = $DIC->user();
44  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
45  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ cancelCreate()

ilPCSourceCodeGUI::cancelCreate ( )

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

References ILIAS\Repository\ctrl().

235  : void
236  {
237  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
238  }
+ Here is the call graph for this function:

◆ cancelUpdate()

ilPCSourceCodeGUI::cancelUpdate ( )

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

References ILIAS\Repository\ctrl().

182  : void
183  {
184  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
185  }
+ Here is the call graph for this function:

◆ create()

ilPCSourceCodeGUI::create ( )

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

References ILIAS\Repository\ctrl(), ilPageContentGUI\getPage(), insert(), ilPageContentGUI\setCurrentTextLang(), and upload_source().

187  : void
188  {
189  $this->content_obj = new ilPCSourceCode($this->getPage());
190  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
191  $this->content_obj->setLanguage($this->request->getString("par_language"));
192 
193  $this->setCurrentTextLang($this->request->getString("par_language"));
194 
195  $this->requested_par_content = $this->request->getRaw("par_content");
196  $this->requested_par_downloadtitle = str_replace('"', '', $this->request->getString("par_downloadtitle"));
197 
198  $uploaded = $this->upload_source();
199 
200  $this->content_obj->setCharacteristic(
201  $this->request->getString("par_characteristic")
202  );
203  $this->content_obj->setSubCharacteristic(
204  $this->request->getString("par_subcharacteristic")
205  );
206  $this->content_obj->setDownloadTitle(str_replace('"', '', $this->requested_par_downloadtitle));
207  $this->content_obj->setShowLineNumbers(
208  $this->request->getString("par_showlinenumbers") ? 'y' : 'n'
209  );
210  $this->content_obj->setCharacteristic('Code');
211 
212  if ($uploaded) {
213  $this->insert();
214  return;
215  }
216 
217  $this->updated = $this->content_obj->setText(
218  $this->content_obj->input2xml($this->requested_par_content, 0, false)
219  );
220 
221  if ($this->updated !== true) {
222  $this->insert();
223  return;
224  }
225 
226  $this->updated = $this->pg_obj->update();
227 
228  if ($this->updated === true) {
229  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
230  } else {
231  $this->insert();
232  }
233  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setCurrentTextLang(string $lang_key)
+ Here is the call graph for this function:

◆ edit()

ilPCSourceCodeGUI::edit ( )

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

References ILIAS\Repository\ctrl(), ilPageContentGUI\displayValidationError(), initPropertyForm(), and ILIAS\Repository\lng().

Referenced by update().

62  : void
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 
74  $this->displayValidationError();
75 
76  $cmd = $this->ctrl->getCmd();
77  if ($cmd == "update") {
78  $form->setValuesByPost();
79  } else {
80  $form->getItemByPostVar("par_language")->setValue($this->content_obj->getLanguage());
81  $form->getItemByPostVar("par_subcharacteristic")->setValue($this->content_obj->getSubCharacteristic());
82  $form->getItemByPostVar("par_downloadtitle")->setValue($this->content_obj->getDownloadTitle());
83  $form->getItemByPostVar("par_showlinenumbers")->setChecked(
84  $this->content_obj->getShowLineNumbers() == "y"
85  );
86  // $form->getItemByPostVar("par_autoindent")->setChecked(
87  // $this->content_obj->getAutoIndent()=="y"?true:false);
88 
89  $par_content = $this->content_obj->xml2output($this->content_obj->getText());
90 
91  //TODO: Find a better way to convert back curly brackets
92  $par_content = str_replace("{", "{", $par_content);
93  $par_content = str_replace("}", "}", $par_content);
94 
95  $form->getItemByPostVar("par_content")->setValue($par_content);
96  }
97 
98 
99  $this->tpl->setContent($form->getHTML());
100  }
initPropertyForm(string $a_title, string $a_cmd, string $a_cmd_cancel)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPCSourceCodeGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

47  : void
48  {
49  // get next class that processes or forwards current command
50  $next_class = $this->ctrl->getNextClass($this);
51 
52  // get current command
53  $cmd = $this->ctrl->getCmd();
54 
55  switch ($next_class) {
56  default:
57  $this->$cmd();
58  break;
59  }
60  }
+ Here is the call graph for this function:

◆ getProgLangOptions()

ilPCSourceCodeGUI::getProgLangOptions ( )

Get selectable programming languages.

Returns
string[]

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

References ilSyntaxHighlighter\getSupportedLanguagesV51().

Referenced by initPropertyForm().

271  : array
272  {
273  $prog_langs = array(
274  "" => "other");
275  foreach (ilSyntaxHighlighter::getSupportedLanguagesV51() as $k => $v) {
276  $prog_langs[$k] = $v;
277  }
278  return $prog_langs;
279  }
static getSupportedLanguagesV51()
Get supported languages (keys are ILIAS <= 5.1 internal values, values are for representation) ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initPropertyForm()

ilPCSourceCodeGUI::initPropertyForm ( string  $a_title,
string  $a_cmd,
string  $a_cmd_cancel 
)

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

References $lang, ilMDLanguageItem\_getLanguages(), ILIAS\Repository\ctrl(), getProgLangOptions(), and ILIAS\Repository\lng().

Referenced by edit(), and insert().

286  $form = new ilPropertyFormGUI();
287  $form->setTitle($a_title);
288  $form->setFormAction($this->ctrl->getFormAction($this, $a_cmd));
289  $form->addCommandButton($a_cmd, $this->lng->txt("save"));
290  $form->addCommandButton($a_cmd_cancel, $this->lng->txt("cancel"));
291 
292  $lang_var = ilMDLanguageItem::_getLanguages();
293  $lang = new ilSelectInputGUI($this->lng->txt("language"), "par_language");
294  $lang->setOptions($lang_var);
295  $form->addItem($lang);
296 
297  $prog_langs = $this->getProgLangOptions();
298  $code_style = new ilSelectInputGUI($this->lng->txt("cont_src"), "par_subcharacteristic");
299  $code_style->setOptions($prog_langs);
300  $form->addItem($code_style);
301  $line_number = new ilCheckboxInputGUI($this->lng->txt("cont_show_line_numbers"), "par_showlinenumbers");
302  $form->addItem($line_number);
303 
304  $code = new ilTextAreaInputGUI("", "par_content");
305  $code->setRows(12);
306  $form->addItem($code);
307 
308  $downlaod_title = new ilTextInputGUI($this->lng->txt("cont_download_title"), "par_downloadtitle");
309  $downlaod_title->setSize(40);
310  $form->addItem($downlaod_title);
311 
312  $file = new ilFileInputGUI($this->lng->txt("import_file"), "userfile");
313  $form->addItem($file);
314 
315  return $form;
316  }
This class represents a file property in a property form.
This class represents a checkbox property in a property form.
$lang
Definition: xapiexit.php:26
This class represents a text area property in a property form.
getProgLangOptions()
Get selectable programming languages.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

ilPCSourceCodeGUI::insert ( )

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

References $ilUser, $user, ILIAS\Repository\ctrl(), ilPageContentGUI\displayValidationError(), ilPageContentGUI\getCurrentTextLang(), initPropertyForm(), and ILIAS\Repository\lng().

Referenced by create().

102  : void
103  {
105 
106  $form = $this->initPropertyForm($this->lng->txt("cont_insert_src"), "create_src", "cancelCreate");
107 
108  if ($this->pg_obj->getParentType() == "lm") {
109  $this->tpl->setVariable(
110  "LINK_ILINK",
111  $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp")
112  );
113  $this->tpl->setVariable("TXT_ILINK", "[" . $this->lng->txt("cont_internal_link") . "]");
114  }
115 
116  $this->displayValidationError();
117 
118  $cmd = $this->ctrl->getCmd();
119  if ($cmd == "create_src") {
120  $form->setValuesByPost();
121  } else {
122  if ($this->getCurrentTextLang() != "") {
123  $form->getItemByPostVar("par_language")->setValue($this->getCurrentTextLang());
124  } else {
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  }
$ilUser
Definition: imgupload.php:34
initPropertyForm(string $a_title, string $a_cmd, string $a_cmd_cancel)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilPCSourceCodeGUI::update ( )

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

References ILIAS\Repository\ctrl(), edit(), and upload_source().

137  : void
138  {
139  $this->requested_par_content = $this->request->getRaw("par_content");
140  $this->requested_par_downloadtitle = str_replace('"', '', $this->request->getString("par_downloadtitle"));
141 
142  $this->upload_source();
143 
144  // set language and characteristic
145 
146  $this->content_obj->setLanguage(
147  $this->request->getString("par_language")
148  );
149  $this->content_obj->setCharacteristic($this->request->getString("par_characteristic"));
150 
151  // set language and characteristic
152  $this->content_obj->setLanguage($this->request->getString("par_language"));
153  $this->content_obj->setSubCharacteristic($this->request->getString("par_subcharacteristic"));
154  $this->content_obj->setDownloadTitle(
155  str_replace('"', '', $this->requested_par_downloadtitle)
156  );
157  $this->content_obj->setShowLineNumbers(
158  $this->request->getString("par_showlinenumbers") ? "y" : "n"
159  );
160  $this->content_obj->setSubCharacteristic($this->request->getString("par_subcharacteristic"));
161  $this->content_obj->setCharacteristic("Code");
162 
163  $this->updated = $this->content_obj->setText(
164  $this->content_obj->input2xml($this->requested_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  }
+ Here is the call graph for this function:

◆ upload_source()

ilPCSourceCodeGUI::upload_source ( )

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

Referenced by create(), and update().

240  : bool
241  {
242  if (isset($_FILES['userfile']['name'])) {
243  $userfile = $_FILES['userfile']['tmp_name'];
244 
245  if ($userfile == "" || !is_uploaded_file($userfile)) {
246  $error_str = "<b>Error(s):</b><br>Upload error: file name must not be empty!";
247  $this->tpl->setVariable("MESSAGE", $error_str);
248  $this->content_obj->setText(
249  $this->content_obj->input2xml(
250  $this->request->getRaw("par_content"),
251  0,
252  false
253  )
254  );
255  return false;
256  }
257 
258  $this->requested_par_content = file_get_contents($userfile);
259  $this->requested_par_downloadtitle = $_FILES['userfile']['name'];
260  return true;
261  }
262 
263  return false;
264  }
+ Here is the caller graph for this function:

Field Documentation

◆ $requested_par_content

string ilPCSourceCodeGUI::$requested_par_content
protected

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

◆ $requested_par_downloadtitle

string ilPCSourceCodeGUI::$requested_par_downloadtitle
protected

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

◆ $user

ilObjUser ilPCSourceCodeGUI::$user
protected

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

Referenced by insert().


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