ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPCDataTableGUI 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 ilPCDataTableGUI:
+ Collaboration diagram for ilPCDataTableGUI:

Public Member Functions

 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
 
 executeCommand ()
 execute command More...
 
 update (bool $a_redirect=true)
 Update table data in dom and update page in db. More...
 
 updateJS ()
 Update via JavaScript. More...
 
 getNewTableObject ()
 Get new table object. More...
 
 afterCreation ()
 After creation processing. More...
 
 tableAction ()
 Perform operation on table (adding, moving, deleting rows/cols) More...
 
 setTabs (string $data_tab_txt_key="")
 Set tabs. More...
 
 initCreationForm ()
 
 initEditingForm ()
 
 initImportForm ()
 
 initCellPropertiesForm ()
 
- Public Member Functions inherited from ilPCTableGUI
 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
 
 setBasicTableCellStyles ()
 
 executeCommand ()
 
 setTabs (string $data_tab_txt_key="")
 
 setCellPropertiesSubTabs ()
 
 getTemplateOptions (string $a_type="")
 
 edit ()
 
 editProperties ()
 
 initPropertiesForm (string $a_mode="edit")
 
 getPropertiesFormValues ()
 
 editCellStyle ()
 
 editCellWidth ()
 
 editCellSpan ()
 
 setStyles ()
 Set cell styles. More...
 
 setWidths ()
 Set cell widths. More...
 
 setSpans ()
 Set cell spans. More...
 
 setProperties ()
 Set properties from input form. More...
 
 saveProperties ()
 save table properties in db and return to page edit screen More...
 
 rightAlign ()
 
 leftAlign ()
 
 centerAlign ()
 
 leftFloatAlign ()
 
 rightFloatAlign ()
 
 insert ()
 
 getNewTableObject ()
 
 create ()
 create new table in dom and update page in db More...
 
 afterCreation ()
 
 editCellAlignment ()
 
 setAlignment ()
 Set cell alignments. More...
 
 editData ()
 Edit data of table. More...
 
- 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 ()
 
 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 Member Functions

 getFormTitle (string $a_mode="edit")
 
 getCellContent (int $i, int $j)
 
- Protected Member Functions inherited from ilPCTableGUI
 getFormTitle (string $a_mode="edit")
 
 getColumnCaption (int $nr)
 
 getCellContent (int $i, int $j)
 
 renderCell ( $content, $unmask=true, $page_object=null)
 Static render table function. More...
 
- Protected Member Functions inherited from ilPageContentGUI
 redirectToParent (string $hier_id="")
 
 getParentReturn (string $hier_id="")
 
 updateAndReturn ()
 
 setCurrentTextLang (string $lang_key)
 
 getCurrentTextLang ()
 
 setEditorToolContext ()
 
 initEditor ()
 
 getEditorScriptTag (string $form_pc_id="", string $form_cname="")
 

Protected Attributes

ILIAS HTTP Services $http
 
ilGlobalTemplateInterface $main_tpl
 
- Protected Attributes inherited from ilPCTableGUI
ILIAS COPage Dom DomUtil $dom_util
 
ILIAS COPage PC PCDefinition $pc_definition
 
ILIAS COPage Xsl XslManager $xsl
 
ilPropertyFormGUI $form
 
ilTabsGUI $tabs
 
ilObjUser $user
 
- Protected Attributes inherited from ilPageContentGUI
ILIAS COPage Editor GUIService $editor_gui
 
ILIAS COPage InternalGUIService $gui
 
EditSessionRepository $edit_repo
 
string $pc_id = ""
 
array $chars
 
ilObjStyleSheet $style = null
 
LOMServices $lom_services
 
ilLogger $log
 
int $styleid = 0
 
EditGUIRequest $request
 
string $sub_command = ""
 
int $requested_ref_id = 0
 
ILIAS GlobalScreen ScreenContext ContextServices $tool_context
 
Style Content CharacteristicManager $char_manager
 

Additional Inherited Members

- Static Public Member Functions inherited from ilPCTableGUI
static _renderTable (string $content, string $a_mode="table_edit", string $a_submode="", ?ilPCTable $a_table_obj=null, bool $unmask=true, ?ilPageObject $page_object=null)
 
static _addStyleCheckboxes (string $a_output, ilPCTable $a_table)
 Add style checkboxes in edit mode. More...
 
static _addAlignmentCheckboxes (string $a_output, ilPCTable $a_table)
 Add alignment checkboxes in edit mode. More...
 
static _addWidthInputs (string $a_output, ilPCTable $a_table)
 Add width inputs. More...
 
static _addSpanInputs (string $a_output, ilPCTable $a_table)
 Add span inputs. More...
 
- 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 = ""
 
DOMDocument $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;"
 
- 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 ilPCTableGUI User Interface for Data Table Editing

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

Definition at line 24 of file class.ilPCDataTableGUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 29 of file class.ilPCDataTableGUI.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ilPageContentGUI\setCharacteristics(), and ILIAS\Repository\tabs().

34  {
35  global $DIC;
36 
37  $this->main_tpl = $DIC->ui()->mainTemplate();
38  $this->lng = $DIC->language();
39  $this->ctrl = $DIC->ctrl();
40  $this->tabs = $DIC->tabs();
41  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
42  $this->setCharacteristics(array("StandardTable" => $this->lng->txt("cont_StandardTable")));
43  $this->tool_context = $DIC->globalScreen()->tool()->context();
44  $this->http = $DIC->http();
45  }
setCharacteristics(array $a_chars)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ afterCreation()

ilPCDataTableGUI::afterCreation ( )

After creation processing.

Definition at line 222 of file class.ilPCDataTableGUI.php.

References ilPageContentGUI\$ctrl, and ilCtrl\setParameter().

222  : void
223  {
224  $ilCtrl = $this->ctrl;
225 
226  $this->pg_obj->stripHierIDs();
227  $this->pg_obj->addHierIDs();
228  $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
229  $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
230  $ilCtrl->redirect($this, "editData");
231  }
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
+ Here is the call graph for this function:

◆ executeCommand()

ilPCDataTableGUI::executeCommand ( )

execute command

Returns
mixed

Definition at line 59 of file class.ilPCDataTableGUI.php.

References ILIAS\Repository\ctrl(), and ilPageContentGUI\getCharacteristicsOfCurrentStyle().

60  {
61  $this->getCharacteristicsOfCurrentStyle(["table"]); // scorm-2004
62 
63  // get next class that processes or forwards current command
64  $next_class = $this->ctrl->getNextClass($this);
65 
66  // get current command
67  $cmd = $this->ctrl->getCmd();
68 
69  switch ($next_class) {
70  default:
71  $ret = $this->$cmd();
72  break;
73  }
74 
75  return $ret;
76  }
getCharacteristicsOfCurrentStyle(array $a_type)
Get characteristics of current style and call setCharacteristics, if style is given.
+ Here is the call graph for this function:

◆ getCellContent()

ilPCDataTableGUI::getCellContent ( int  $i,
int  $j 
)
protected

Definition at line 266 of file class.ilPCDataTableGUI.php.

References ILIAS\Repository\ctrl(), ilUtil\stripSlashes(), ilPCParagraph\xml2output(), and ilPCParagraphGUI\xml2outputJS().

266  : string
267  {
268  $cmd = $this->ctrl->getCmd();
269  if ($cmd == "update") {
270  $s_text = ilUtil::stripSlashes("cell_" . $i . "_" . $j, false);
271  } else {
272  $s_text = ilPCParagraph::xml2output(
273  $this->content_obj->getCellText($i, $j),
274  true,
275  false
276  );
278  $s_text,
279  "TableContent",
280  $this->content_obj->readPCId() . "_" . $i . "_" . $j
281  );
282  }
283 
284  // #20628
285  $s_text = str_replace("{", "{", $s_text);
286  $s_text = str_replace("}", "}", $s_text);
287  return $s_text;
288  }
static xml2outputJS(string $s_text)
Prepare content for js output.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static xml2output(string $a_text, bool $a_wysiwyg=false, bool $a_replace_lists=true, bool $unmask=true)
Converts xml from DB to output in edit textarea.
+ Here is the call graph for this function:

◆ getFormTitle()

ilPCDataTableGUI::getFormTitle ( string  $a_mode = "edit")
protected

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

References ILIAS\Repository\lng().

Referenced by initCreationForm(), initEditingForm(), and initImportForm().

47  : string
48  {
49  if ($a_mode === "create") {
50  return $this->lng->txt("cont_ed_insert_dtab");
51  }
52  return $this->lng->txt("cont_table_properties");
53  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewTableObject()

ilPCDataTableGUI::getNewTableObject ( )

Get new table object.

Definition at line 214 of file class.ilPCDataTableGUI.php.

References ilPageContentGUI\getPage().

214  : ilPCDataTable
215  {
216  return new ilPCDataTable($this->getPage());
217  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ initCellPropertiesForm()

ilPCDataTableGUI::initCellPropertiesForm ( )

Definition at line 496 of file class.ilPCDataTableGUI.php.

References ilPageContentGUI\$chars, ilPageContentGUI\$ctrl, ilPCTableGUI\$form, ilPageContentGUI\$lng, ilPageContentGUI\$style, ilPCTableGUI\$user, ilPropertyFormGUI\addItem(), ilSubEnabledFormPropertyGUI\addSubItem(), ilPageContentGUI\getCharacteristics(), ilPageContentGUI\getCharacteristicsOfCurrentStyle(), ILIAS\Repository\lng(), ilPCTableGUI\setBasicTableCellStyles(), ilFormGUI\setFormAction(), ilSelectInputGUI\setOptions(), ilPropertyFormGUI\setShowTopButtons(), ilPropertyFormGUI\setTitle(), and ilLanguage\txt().

498 
499  $ilCtrl = $this->ctrl;
500  $lng = $this->lng;
501  $ilUser = $this->user;
502 
503  $form = new ilPropertyFormGUI();
504  $form->setFormAction($ilCtrl->getFormAction($this));
505  $form->setShowTopButtons(false);
506  $form->setTitle($this->lng->txt("cont_cell_properties"));
507 
508  $style_cb = new ilCheckboxInputGUI($lng->txt("cont_change_style"), "style_cb");
509 
510  $style = new ilSelectInputGUI(
511  $this->lng->txt("cont_style"),
512  "style"
513  );
514  //$style->setPullRight(false);
515  $this->setBasicTableCellStyles();
516  $this->getCharacteristicsOfCurrentStyle(["table_cell"]); // scorm-2004
517  $chars = $this->getCharacteristics(); // scorm-2004
518  $options = array_merge(array("" => $this->lng->txt("none")), $chars); // scorm-2004
519  foreach ($options as $k => $option) {
520  $html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="ilc_table_cell_' . $k . '">' .
521  $option . '</td></tr></table>';
522  //$style->addOption($k, $option, $html);
523  }
524 
525  if (count($options) > 1) {
526  $style->setOptions($options);
527  $style_cb->addSubItem($style);
528  $form->addItem($style_cb);
529  }
530 
531  $width_cb = new ilCheckboxInputGUI($lng->txt("cont_change_width"), "width_cb");
532  $ti = new ilTextInputGUI($lng->txt("cont_width"), "width");
533  $ti->setMaxLength(20);
534  $ti->setSize(7);
535  $width_cb->addSubItem($ti);
536  $form->addItem($width_cb);
537 
538  // alignment
539  $al_cb = new ilCheckboxInputGUI($lng->txt("cont_change_alignment"), "al_cb");
540  $options = array(
541  "" => $lng->txt("default"),
542  "Left" => $lng->txt("cont_left"),
543  "Center" => $lng->txt("cont_center"),
544  "Right" => $lng->txt("cont_right")
545  );
546  $si = new ilSelectInputGUI($lng->txt("cont_alignment"), "alignment");
547  $si->setOptions($options);
548  $al_cb->addSubItem($si);
549  $form->addItem($al_cb);
550 
551  return $form;
552  }
getCharacteristicsOfCurrentStyle(array $a_type)
Get characteristics of current style and call setCharacteristics, if style is given.
This class represents a selection list property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ilPropertyFormGUI $form
setOptions(array $a_options)
setFormAction(string $a_formaction)
+ Here is the call graph for this function:

◆ initCreationForm()

ilPCDataTableGUI::initCreationForm ( )

Definition at line 290 of file class.ilPCDataTableGUI.php.

References ilPageContentGUI\$chars, ilPageContentGUI\$ctrl, ilPCTableGUI\$form, ilPageContentGUI\$lng, ilPCTableGUI\$user, ilPropertyFormGUI\addCommandButton(), ilPropertyFormGUI\addItem(), ilPageContentGUI\getCharacteristics(), getFormTitle(), ilPCTableGUI\getTemplateOptions(), ILIAS\Repository\lng(), ilFormGUI\setFormAction(), ilSelectInputGUI\setOptions(), ilPropertyFormGUI\setShowTopButtons(), ilPropertyFormGUI\setTitle(), and ilLanguage\txt().

292 
293  $a_seleted_value = "";
294  $ilCtrl = $this->ctrl;
295  $lng = $this->lng;
296  $ilUser = $this->user;
297 
298  $form = new ilPropertyFormGUI();
299  $form->setFormAction($ilCtrl->getFormAction($this));
300  $form->setShowTopButtons(false);
301  $form->setTitle($this->getFormTitle("create"));
302 
303  $nr = array();
304  for ($i = 1; $i <= 20; $i++) {
305  $nr[$i] = $i;
306  }
307 
308  // cols
309  $cols = new ilSelectInputGUI($this->lng->txt("cont_nr_cols"), "nr_cols");
310  $cols->setOptions($nr);
311  $cols->setValue(2);
312  $form->addItem($cols);
313 
314  // rows
315  $rows = new ilSelectInputGUI($this->lng->txt("cont_nr_rows"), "nr_rows");
316  $rows->setOptions($nr);
317  $rows->setValue(2);
318  $form->addItem($rows);
319 
320  // table templates and table classes
321  $char_prop = new ilSelectInputGUI(
322  $this->lng->txt("cont_table_style"),
323  "characteristic"
324  );
325  $chars = $this->getCharacteristics();
326  $templates = $this->getTemplateOptions();
327  $chars = array_merge($templates, $chars);
328  if (is_object($this->content_obj)) {
329  if (($chars[$a_seleted_value] ?? "") == "" && ($this->content_obj->getClass() != "")) {
330  $chars = array_merge(
331  array($this->content_obj->getClass() => $this->content_obj->getClass()),
332  $chars
333  );
334  }
335  }
336  $options = [];
337  foreach ($chars as $k => $char) {
338  if (strpos($k, ":") > 0) {
339  $t = explode(":", $k);
340  $html = $this->style->lookupTemplatePreview($t[1]) . '<div style="clear:both;" class="small">' . $char . "</div>";
341  } else {
342  $html = '<table class="ilc_table_' . $k . '"><tr><td class="small">' .
343  $char . '</td></tr></table>';
344  }
345  //$char_prop->addOption($k, $char, $html);
346  $options[$k] = $char;
347  }
348  if (count($chars) > 1) {
349  $char_prop->setOptions($options);
350  $char_prop->setValue("StandardTable");
351  $form->addItem($char_prop);
352  }
353 
354  // row header
355  $cb = new ilCheckboxInputGUI($lng->txt("cont_has_row_header"), "has_row_header");
356  $form->addItem($cb);
357 
358  $form->addCommandButton("create", $lng->txt("save"));
359  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
360 
361  return $form;
362  }
This class represents a selection list property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getFormTitle(string $a_mode="edit")
ilPropertyFormGUI $form
setOptions(array $a_options)
setFormAction(string $a_formaction)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getTemplateOptions(string $a_type="")
+ Here is the call graph for this function:

◆ initEditingForm()

ilPCDataTableGUI::initEditingForm ( )

Definition at line 364 of file class.ilPCDataTableGUI.php.

References ilPageContentGUI\$chars, ilPageContentGUI\$ctrl, ilPCTableGUI\$form, ilPageContentGUI\$lng, ilPCTableGUI\$user, ilObjStyleSheet\_lookupTemplateIdByName(), ilPropertyFormGUI\addItem(), ilPageContentGUI\getCharacteristics(), getFormTitle(), ilPageContentGUI\getStyleId(), ilPCTableGUI\getTemplateOptions(), ILIAS\Repository\lng(), ilFormGUI\setFormAction(), ilPropertyFormGUI\setShowTopButtons(), ilPropertyFormGUI\setTitle(), and ilLanguage\txt().

366 
367  $a_seleted_value = "";
368  $ilCtrl = $this->ctrl;
369  $lng = $this->lng;
370  $ilUser = $this->user;
371 
372  $form = new ilPropertyFormGUI();
373  $form->setFormAction($ilCtrl->getFormAction($this));
374  $form->setShowTopButtons(false);
375  $form->setTitle($this->getFormTitle("edit"));
376 
377  // table templates and table classes
378  $char_prop = new ilSelectInputGUI(
379  $this->lng->txt("cont_table_style"),
380  "characteristic"
381  );
382  $chars = $this->getCharacteristics();
383  $templates = $this->getTemplateOptions();
384  $chars = array_merge($templates, $chars);
385  if (is_object($this->content_obj)) {
386  if (($chars[$a_seleted_value] ?? "") == "" && ($this->content_obj->getClass() != "")) {
387  $chars = array_merge(
388  array($this->content_obj->getClass() => $this->content_obj->getClass()),
389  $chars
390  );
391  }
392  }
393  $options = [];
394  foreach ($chars as $k => $char) {
395  if (strpos($k, ":") > 0) {
396  $t = explode(":", $k);
397  $html = $this->style->lookupTemplatePreview($t[1]) . '<div style="clear:both;" class="small">' . $char . "</div>";
398  } else {
399  $html = '<table class="ilc_table_' . $k . '"><tr><td class="small">' .
400  $char . '</td></tr></table>';
401  }
402  //$char_prop->addOption($k, $char, $html);
403  $options[$k] = $char;
404  }
405  $char_prop->setOptions($options);
406  if (count($chars) > 1) {
407  if ($this->content_obj->getTemplate() !== "") {
408  $val = "t:" .
409  ilObjStyleSheet::_lookupTemplateIdByName($this->getStyleId(), $this->content_obj->getTemplate()) . ":" .
410  $this->content_obj->getTemplate();
411  } else {
412  $val = $this->content_obj->getClass();
413  }
414  $char_prop->setValue($val);
415  $form->addItem($char_prop);
416  }
417 
418  // row header
419  $cb = new ilCheckboxInputGUI($lng->txt("cont_has_row_header"), "has_row_header");
420  if ($this->content_obj->getHeaderRows() > 0) {
421  $cb->setChecked(true);
422  }
423  $form->addItem($cb);
424 
425  return $form;
426  }
static _lookupTemplateIdByName(int $a_style_id, string $a_name)
Lookup table template preview.
This class represents a selection list property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getFormTitle(string $a_mode="edit")
ilPropertyFormGUI $form
setFormAction(string $a_formaction)
getTemplateOptions(string $a_type="")
+ Here is the call graph for this function:

◆ initImportForm()

ilPCDataTableGUI::initImportForm ( )

Definition at line 428 of file class.ilPCDataTableGUI.php.

References ilPageContentGUI\$chars, ilPageContentGUI\$ctrl, ilPCTableGUI\$form, ilPageContentGUI\$lng, ilPCTableGUI\$user, ilPropertyFormGUI\addCommandButton(), ilPropertyFormGUI\addItem(), ilPageContentGUI\getCharacteristics(), getFormTitle(), ilPCTableGUI\getTemplateOptions(), ILIAS\Repository\lng(), ilFormGUI\setFormAction(), ilPropertyFormGUI\setShowTopButtons(), ilPropertyFormGUI\setTitle(), and ilLanguage\txt().

430 
431  $a_seleted_value = "";
432  $ilCtrl = $this->ctrl;
433  $lng = $this->lng;
434  $ilUser = $this->user;
435 
436  $form = new ilPropertyFormGUI();
437  $form->setFormAction($ilCtrl->getFormAction($this));
438  $form->setShowTopButtons(false);
439  $form->setTitle($this->getFormTitle("create"));
440 
441  $hi = new ilHiddenInputGUI("import");
442  $hi->setValue("1");
443  $form->addItem($hi);
444 
445  $import_data = new ilTextAreaInputGUI("", "import_table");
446  $import_data->setInfo($this->lng->txt("cont_table_import_info"));
447  $import_data->setRows(8);
448  $import_data->setCols(50);
449  $form->addItem($import_data);
450 
451  // table templates and table classes
452  $char_prop = new ilSelectInputGUI(
453  $this->lng->txt("cont_table_style"),
454  "import_characteristic"
455  );
456  $chars = $this->getCharacteristics();
457  $templates = $this->getTemplateOptions();
458  $chars = array_merge($templates, $chars);
459  if (is_object($this->content_obj)) {
460  if (($chars[$a_seleted_value] ?? "") == "" && ($this->content_obj->getClass() != "")) {
461  $chars = array_merge(
462  array($this->content_obj->getClass() => $this->content_obj->getClass()),
463  $chars
464  );
465  }
466  }
467  $options = [];
468  foreach ($chars as $k => $char) {
469  if (strpos($k, ":") > 0) {
470  $t = explode(":", $k);
471  $html = $this->style->lookupTemplatePreview($t[1]) . '<div style="clear:both;" class="small">' . $char . "</div>";
472  } else {
473  $html = '<table class="ilc_table_' . $k . '"><tr><td class="small">' .
474  $char . '</td></tr></table>';
475  }
476  //$char_prop->addOption($k, $char, $html);
477  $options[$k] = $char;
478  }
479  if (count($chars) > 1) {
480  $char_prop->setOptions($options);
481  $char_prop->setValue("StandardTable");
482  $form->addItem($char_prop);
483  }
484 
485  // row header
486  $cb = new ilCheckboxInputGUI($lng->txt("cont_has_row_header"), "has_row_header");
487  $form->addItem($cb);
488 
489 
490  $form->addCommandButton("create", $lng->txt("save"));
491  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
492 
493  return $form;
494  }
This class represents a selection list property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getFormTitle(string $a_mode="edit")
ilPropertyFormGUI $form
This class represents a hidden form property in a property form.
setFormAction(string $a_formaction)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getTemplateOptions(string $a_type="")
This class represents a text area property in a property form.
+ Here is the call graph for this function:

◆ setTabs()

ilPCDataTableGUI::setTabs ( string  $data_tab_txt_key = "")

Set tabs.

Definition at line 261 of file class.ilPCDataTableGUI.php.

261  : void
262  {
263  parent::setTabs("cont_ed_edit_data");
264  }

◆ tableAction()

ilPCDataTableGUI::tableAction ( )

Perform operation on table (adding, moving, deleting rows/cols)

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

References ilPageContentGUI\$ctrl, $id, and update().

236  : void
237  {
238  $ilCtrl = $this->ctrl;
239 
240  $this->update(false);
241  $this->pg_obj->addHierIDs();
242 
243  $type = $this->request->getString("type");
244  $action = $this->request->getString("action");
245  $id = $this->request->getInt("id");
246 
247  $cell_hier_id = ($type == "col")
248  ? $this->hier_id . "_1_" . ($id + 1)
249  : $this->hier_id . "_" . ($id + 1) . "_1";
250  $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
251  if (is_object($cell_obj)) {
252  $cell_obj->$action();
253  $this->edit_repo->setPageError($this->pg_obj->update());
254  }
255  $ilCtrl->redirect($this, "editData");
256  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
update(bool $a_redirect=true)
Update table data in dom and update page in db.
+ Here is the call graph for this function:

◆ update()

ilPCDataTableGUI::update ( bool  $a_redirect = true)

Update table data in dom and update page in db.

Definition at line 86 of file class.ilPCDataTableGUI.php.

References $data, ilPageContentGUI\$lng, ilPCParagraph\_input2xml(), ILIAS\Repository\ctrl(), ilPCTableGUI\editData(), and ilLanguage\txt().

Referenced by tableAction().

86  : void
87  {
88  $lng = $this->lng;
89 
90  // handle input data
91  $data = array();
92  $cell = $this->request->getArrayArray("cell");
93  if (is_array($cell)) {
94  foreach ($cell as $i => $row) {
95  if (is_array($row)) {
96  foreach ($row as $j => $cell) {
97  $data[$i][$j] =
99  $cell,
100  $this->content_obj->getLanguage()
101  );
102  }
103  }
104  }
105  }
106 
107  $this->updated = $this->content_obj->setData($data);
108 
109  if ($this->updated !== true) {
110  $this->editData();
111  return;
112  }
113 
114  $this->updated = $this->pg_obj->update();
115 
116  if ($a_redirect) {
117  $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
118  $this->ctrl->redirect($this, "editData");
119  }
120  }
editData()
Edit data of table.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _input2xml(string $a_text, string $a_lang, bool $a_wysiwyg=false, bool $a_handle_lists=true)
Converts user input to xml User input comes as bb code information, e.g.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateJS()

ilPCDataTableGUI::updateJS ( )

Update via JavaScript.

Definition at line 125 of file class.ilPCDataTableGUI.php.

References ilPageContentGUI\$ctrl, $data, $id, ilPageContentGUI\$lng, $post, ilPCParagraph\_input2xml(), ILIAS\Repository\ctrl(), ilPCTableGUI\editData(), ilPCParagraph\handleAjaxContent(), ilPCParagraph\handleAjaxContentPost(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ilUtil\stripSlashes(), and ilLanguage\txt().

125  : void
126  {
127  $lng = $this->lng;
128  $ilCtrl = $this->ctrl;
129 
130  if ($this->request->getString("cancel_update") != "") {
131  // $this->ctrl->redirect($this, "editData");
132  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
133  }
134 
135  // handle input data
136  $data = array();
137  $post = $this->http->request()->getParsedBody();
138  foreach ($post as $k => $content) {
139  if (substr($k, 0, 5) != "cell_") {
140  continue;
141  }
142 
143  // determine cell content
144  $div = ilUtil::stripSlashes($content, false);
145  $p1 = strpos($div, '>');
146  $div = substr($div, $p1 + 1);
147  $div = "<div class='ilc_text_block_TableContent'>" . $div;
148  $text = ilPCParagraph::handleAjaxContent($div);
149  if ($text === false) {
150  $ilCtrl->returnToParent($this, "jump" . $this->hier_id);
151  }
152  $text = $text["text"];
153 
155  $text,
156  $this->content_obj->getLanguage(),
157  true,
158  false
159  );
161 
162  // set content in data array
163  $id = explode("_", $k);
164  $data[(int) $id[1]][(int) $id[2]] = $text;
165  }
166 
167  // update data
168  $this->updated = $this->content_obj->setData($data);
169 
170  if ($this->updated !== true) {
171  $this->editData();
172  return;
173  }
174 
175  $this->updated = $this->pg_obj->update();
176 
177  $tab_cmd_id = $this->request->getInt("tab_cmd_id");
178  $tab_cmd_type = $this->request->getString("tab_cmd_type");
179  $tab_cmd = $this->request->getString("tab_cmd");
180 
181  // perform table action? (move...?)
182  //$this->update(false);
183  $this->pg_obj->addHierIDs();
184  $failed = false;
185  if ($tab_cmd != "") {
186  $cell_hier_id = ($tab_cmd_type == "col")
187  ? $this->hier_id . "_1_" . ($tab_cmd_id + 1)
188  : $this->hier_id . "_" . ($tab_cmd_id + 1) . "_1";
189  $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
190  if (is_object($cell_obj)) {
191  $cell_obj->$tab_cmd();
192  $ret = $this->pg_obj->update();
193  if ($ret !== true) {
194  $this->main_tpl->setOnScreenMessage('failure', $ret[0][1], true);
195  $failed = true;
196  }
197  }
198  }
199 
200  if (!$failed) {
201  $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
202  }
203  if ($this->request->getString("save_return") != "") {
204  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
205  } else {
206  $this->ctrl->redirect($this, "editData");
207  }
208  }
editData()
Edit data of table.
static handleAjaxContent(string $a_content)
Handle ajax content.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static handleAjaxContentPost(string $text)
Post input2xml handling of ajax content.
static http()
Fetches the global http state from ILIAS.
static _input2xml(string $a_text, string $a_lang, bool $a_wysiwyg=false, bool $a_handle_lists=true)
Converts user input to xml User input comes as bb code information, e.g.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:

Field Documentation

◆ $http

ILIAS HTTP Services ilPCDataTableGUI::$http
protected

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

◆ $main_tpl

ilGlobalTemplateInterface ilPCDataTableGUI::$main_tpl
protected

Definition at line 27 of file class.ilPCDataTableGUI.php.


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