ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilPCDataTableGUI Class Reference

Class ilPCTableGUI. More...

+ Inheritance diagram for ilPCDataTableGUI:
+ Collaboration diagram for ilPCDataTableGUI:

Public Member Functions

 __construct (&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
 Constructor public. More...
 
 executeCommand ()
 execute command More...
 
 editDataCl ()
 Edit data of table. More...
 
 update ($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 ()
 Set tabs. More...
 
 editData ()
 Edit data of table. More...
 
- Public Member Functions inherited from ilPCTableGUI
 __construct (&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
 Constructor public. More...
 
 setBasicTableCellStyles ()
 Set basic table cell styles. More...
 
 executeCommand ()
 execute command More...
 
 setTabs ()
 Set tabs. More...
 
 setCellPropertiesSubTabs ()
 Set tabs. More...
 
 getTemplateOptions ($a_type="")
 Get table templates. More...
 
 edit ()
 edit properties form More...
 
 initPropertiesForm ($a_mode="edit")
 Init properties form. More...
 
 getPropertiesFormValues ()
 Get properties form. More...
 
 renderTable ($a_mode="table_edit", $a_submode="")
 Render the table. More...
 
 editCellStyle ()
 Edit cell styles. More...
 
 editCellWidth ()
 Edit cell widths. More...
 
 editCellSpan ()
 Edit cell spans. More...
 
 setStyles ()
 Set cell styles and. 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 ()
 align table to right More...
 
 leftAlign ()
 align table to left More...
 
 centerAlign ()
 align table to left More...
 
 leftFloatAlign ()
 align table to left float More...
 
 rightFloatAlign ()
 align table to left More...
 
 insert ()
 insert new table form More...
 
 getNewTableObject ()
 Get new table object. More...
 
 create ()
 create new table in dom and update page in db More...
 
 afterCreation ()
 After creation processing. More...
 
 editCellAlignment ()
 Edit cell styles. More...
 
 setAlignment ()
 Set cell alignments. More...
 
- Public Member Functions inherited from ilPageContentGUI
 __construct ($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...
 

Protected Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from ilPCTableGUI
static _renderTable ($content, $a_mode="table_edit", $a_submode="", $a_table_obj=null, $unmask=true)
 Static render table function. More...
 
static _addStyleCheckboxes ($a_output, $a_table)
 Add style checkboxes in edit mode. More...
 
static _addAlignmentCheckboxes ($a_output, $a_table)
 Add alignment checkboxes in edit mode. More...
 
static _addWidthInputs ($a_output, $a_table)
 Add width inputs. More...
 
static _addSpanInputs ($a_output, $a_table)
 Add span inputs. More...
 
- 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 ilPCTableGUI.

User Interface for Data Table 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.ilPCDataTableGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilPCDataTableGUI::__construct ( $a_pg_obj,
$a_content_obj,
  $a_hier_id,
  $a_pc_id = "" 
)

Constructor public.

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

References $DIC, array, and ilPageContentGUI\setCharacteristics().

31  {
32  global $DIC;
33 
34  $this->lng = $DIC->language();
35  $this->ctrl = $DIC->ctrl();
36  $this->tabs = $DIC->tabs();
37  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
38  $this->setCharacteristics(array("StandardTable" => $this->lng->txt("cont_StandardTable")));
39  }
global $DIC
Definition: saml.php:7
setCharacteristics($a_chars)
Set Characteristics.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Member Function Documentation

◆ afterCreation()

ilPCDataTableGUI::afterCreation ( )

After creation processing.

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

References ilPageContentGUI\$ctrl, $ilCtrl, editData(), and ilPageContentGUI\setHierId().

386  {
388 
389  $this->pg_obj->stripHierIDs();
390  $this->pg_obj->addHierIDs();
391  $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
392  $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
393  $this->content_obj->setHierId($this->content_obj->readHierId());
394  $this->setHierId($this->content_obj->readHierId());
395  $this->content_obj->setPCId($this->content_obj->readPCId());
396  $this->editData();
397  }
global $ilCtrl
Definition: ilias.php:18
editData()
Edit data of table.
setHierId($a_hier_id)
get hierarchical id in dom object
+ Here is the call graph for this function:

◆ editData()

ilPCDataTableGUI::editData ( )

Edit data of table.

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

References $_POST, $cfg, ilPageContentGUI\$ctrl, $GLOBALS, $i, $ilCtrl, ilPageContentGUI\$lng, $path, $res, $type, ilPageEditorGUI\_doJSEditing(), array, ilPageContentGUI\displayValidationError(), editDataCl(), ilObjStyleSheet\getContentStylePath(), ilPageContentGUI\getHierId(), ilUtil\getImagePath(), ilInternalLinkGUI\getInitHTML(), ilPageContentGUI\getPageConfig(), ilPageContentGUI\getStyleId(), ilUtil\getStyleSheetLocation(), ilPageObjectGUI\getTinyMenu(), ilYuiUtil\initConnection(), ilYuiUtil\initDragDrop(), ilYuiUtil\initPanel(), setTabs(), ilUtil\stripSlashes(), ilPCParagraph\xml2output(), ilPCParagraphGUI\xml2outputJS(), xpath_eval(), and xpath_new_context().

Referenced by afterCreation(), update(), and updateJS().

448  {
449  $lng = $this->lng;
451 
452 
454  return $this->editDataCl();
455  }
456 
457  //var_dump($_GET);
458  //var_dump($_POST);
459 
460  $this->setTabs();
461 
462  $this->displayValidationError();
463 
464 
465  include_once("./Services/COPage/classes/class.ilPCParagraph.php");
466 
467  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tabledata2.html", "Services/COPage");
468  //$dtpl = $this->tpl;
469  $dtpl = new ilTemplate("tpl.tabledata2.html", true, true, "Services/COPage");
470  $dtpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "tableAction"));
471 
472 
473  $dtpl->setVariable(
474  "WYSIWYG_ACTION",
475  $ilCtrl->getFormAction($this, "updateJS")
476  );
477 
478  // get all rows
479  $xpc = xpath_new_context($this->dom);
480  $path = "//PageContent[@HierId='" . $this->getHierId() . "']" .
481  "/Table/TableRow";
482  $res = xpath_eval($xpc, $path);
483 
484  for ($i = 0; $i < count($res->nodeset); $i++) {
485  $xpc2 = xpath_new_context($this->dom);
486  $path2 = "//PageContent[@HierId='" . $this->getHierId() . "']" .
487  "/Table/TableRow[$i+1]/TableData";
488  $res2 = xpath_eval($xpc2, $path2);
489 
490  // if this is the first row -> col icons
491  if ($i == 0) {
492  for ($j = 0; $j < count($res2->nodeset); $j++) {
493  if ($j == 0) {
494  $dtpl->touchBlock("empty_td");
495  }
496 
497  if ($j == 0) {
498  if (count($res2->nodeset) == 1) {
499  $move_type = "none";
500  } else {
501  $move_type = "forward";
502  }
503  } elseif ($j == (count($res2->nodeset) - 1)) {
504  $move_type = "backward";
505  } else {
506  $move_type = "both";
507  }
508  $dtpl->setCurrentBlock("col_icon");
509  $dtpl->setVariable("COL_ICON_ALT", $lng->txt("content_column"));
510  $dtpl->setVariable("COL_ICON", ilUtil::getImagePath("col.svg"));
511  $dtpl->setVariable("COL_ONCLICK", "COL_" . $move_type);
512  $dtpl->setVariable("NR", $j);
513  $dtpl->parseCurrentBlock();
514  }
515  $dtpl->setCurrentBlock("row");
516  $dtpl->parseCurrentBlock();
517  }
518 
519 
520  for ($j = 0; $j < count($res2->nodeset); $j++) {
521  // first col: row icons
522  if ($j == 0) {
523  if ($i == 0) {
524  if (count($res->nodeset) == 1) {
525  $move_type = "none";
526  } else {
527  $move_type = "forward";
528  }
529  } elseif ($i == (count($res->nodeset) - 1)) {
530  $move_type = "backward";
531  } else {
532  $move_type = "both";
533  }
534  $dtpl->setCurrentBlock("row_icon");
535  $dtpl->setVariable("ROW_ICON_ALT", $lng->txt("content_row"));
536  $dtpl->setVariable("ROW_ICON", ilUtil::getImagePath("row.svg"));
537  $dtpl->setVariable("ROW_ONCLICK", "ROW_" . $move_type);
538  $dtpl->setVariable("NR", $i);
539  $dtpl->parseCurrentBlock();
540  }
541 
542  // cell
543  if ($res2->nodeset[$j]->get_attribute("Hidden") != "Y") {
544  $dtpl->setCurrentBlock("cell");
545 
546  if (is_array($_POST["cmd"]) && key($_POST["cmd"]) == "update") {
547  $s_text = ilUtil::stripSlashes("cell_" . $i . "_" . $j, false);
548  } else {
549  $s_text = ilPCParagraph::xml2output(
550  $this->content_obj->getCellText($i, $j),
551  true,
552  false
553  );
554  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
556  $s_text,
557  "TableContent",
558  $this->content_obj->readPCId() . "_" . $i . "_" . $j
559  );
560  }
561 
562  // #20628
563  $s_text = str_replace("{", "&#123;", $s_text);
564  $s_text = str_replace("}", "&#125;", $s_text);
565 
566  $dtpl->setVariable("PAR_TA_NAME", "cell[" . $i . "][" . $j . "]");
567  $dtpl->setVariable("PAR_TA_ID", "cell_" . $i . "_" . $j);
568 
569  $dtpl->setVariable("PAR_TA_CONTENT", $s_text);
570 
571  $cs = $res2->nodeset[$j]->get_attribute("ColSpan");
572  $rs = $res2->nodeset[$j]->get_attribute("RowSpan");
573  $dtpl->setVariable("WIDTH", "140");
574  $dtpl->setVariable("HEIGHT", "80");
575  if ($cs > 1) {
576  $dtpl->setVariable("COLSPAN", 'colspan="' . $cs . '"');
577  $dtpl->setVariable("WIDTH", (140 + ($cs - 1) * 146));
578  }
579  if ($rs > 1) {
580  $dtpl->setVariable("ROWSPAN", 'rowspan="' . $rs . '"');
581  $dtpl->setVariable("HEIGHT", (80 + ($rs - 1) * 86));
582  }
583  $dtpl->parseCurrentBlock();
584  }
585  }
586  $dtpl->setCurrentBlock("row");
587  $dtpl->parseCurrentBlock();
588  }
589 
590  // init menues
591  $types = array("row", "col");
592  $moves = array("none", "backward", "both", "forward");
593  $commands = array(
594  "row" => array( "newRowAfter" => "cont_ed_new_row_after",
595  "newRowBefore" => "cont_ed_new_row_before",
596  "moveRowUp" => "cont_ed_row_up",
597  "moveRowDown" => "cont_ed_row_down",
598  "deleteRow" => "cont_ed_delete_row"),
599  "col" => array( "newColAfter" => "cont_ed_new_col_after",
600  "newColBefore" => "cont_ed_new_col_before",
601  "moveColLeft" => "cont_ed_col_left",
602  "moveColRight" => "cont_ed_col_right",
603  "deleteCol" => "cont_ed_delete_col")
604  );
605 
606  foreach ($types as $type) {
607  foreach ($moves as $move) {
608  foreach ($commands[$type] as $command => $lang_var) {
609  if ($move == "none" && (substr($command, 0, 4) == "move" || substr($command, 0, 6) == "delete")) {
610  continue;
611  }
612  if (($move == "backward" && (in_array($command, array("movedown", "moveright")))) ||
613  ($move == "forward" && (in_array($command, array("moveup", "moveleft"))))) {
614  continue;
615  }
616  $dtpl->setCurrentBlock("menu_item");
617  $dtpl->setVariable("MENU_ITEM_TITLE", $lng->txt($lang_var));
618  $dtpl->setVariable("CMD", $command);
619  $dtpl->setVariable("TYPE", $type);
620  $dtpl->parseCurrentBlock();
621  }
622  $dtpl->setCurrentBlock("menu");
623  $dtpl->setVariable("TYPE", $type);
624  $dtpl->setVariable("MOVE", $move);
625  $dtpl->parseCurrentBlock();
626  }
627  }
628 
629 
630  $dtpl->setVariable(
631  "FORMACTION2",
632  $ilCtrl->getFormAction($this, "tableAction")
633  );
634  $dtpl->setVariable("TXT_ACTION", $this->lng->txt("cont_table"));
635 
636  // js editing preparation
637  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
640  ilYuiUtil::initPanel(false);
641  //$GLOBALS["tpl"]->addJavascript("Services/COPage/tiny/4_2_4/tinymce.js");
642  $GLOBALS["tpl"]->addJavascript("./libs/bower/bower_components/tinymce/tinymce.min.js");
643  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilcopagecallback.js");
644  $GLOBALS["tpl"]->addJavascript("Services/COPage/js/page_editing.js");
645 
646  $GLOBALS["tpl"]->addOnloadCode("var preloader = new Image();
647  preloader.src = './templates/default/images/loader.svg';
648  ilCOPage.setContentCss('" .
650  ", " . ilUtil::getStyleSheetLocation() . ", ./Services/COPage/css/tiny_extra.css');
651  ilCOPage.editTD('cell_0_0');
652  ");
653 
654  $cfg = $this->getPageConfig();
655 
656  $dtpl->setVariable(
657  "IL_TINY_MENU",
659  $this->pg_obj->getParentType(),
660  $cfg->getEnableInternalLinks(),
661  $cfg->getEnableWikiLinks(),
662  $cfg->getEnableKeywords(),
663  $this->getStyleId(),
664  false,
665  true,
666  $cfg->getEnableAnchors(),
667  false
668  )
669  );
670 
671  // add int link parts
672  if ($cfg->getEnableInternalLinks() || $cfg->getEnableWikiLinks()) {
673  include_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
674  $dtpl->setCurrentBlock("int_link_prep");
675  $dtpl->setVariable("INT_LINK_PREP", ilInternalLinkGUI::getInitHTML(
676  $ilCtrl->getLinkTargetByClass(
677  array("ilpageeditorgui", "ilinternallinkgui"),
678  "",
679  false,
680  true,
681  false
682  )
683  ));
684  }
685 
686  $this->tpl->setContent($dtpl->get());
687  }
static getInitHTML($a_url)
Get initialisation HTML to use interna link editing.
static xml2outputJS($s_text, $char, $a_pc_id)
Prepare content for js output.
xpath_new_context($dom_document)
$type
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static initConnection(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
xpath_eval($xpath_context, $eval_str, $contextnode=null)
getHierId()
get hierarchical id in dom object
getPageConfig()
Get Page Config.
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true, $unmask=true)
Converts xml from DB to output in edit textarea.
global $ilCtrl
Definition: ilias.php:18
foreach($_POST as $key=> $value) $res
static getTinyMenu( $a_par_type, $a_int_links=false, $a_wiki_links=false, $a_keywords=false, $a_style_id=0, $a_paragraph_styles=true, $a_save_return=true, $a_anchors=false, $a_save_new=true, $a_user_links=false)
Get Tiny Menu.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
static _doJSEditing()
checks if current user has activated js editing and if browser is js capable
displayValidationError()
display validation errors
getStyleId()
Get Style Id.
catch(Exception $e) if(isset($_POST['cancel'])) if(isset($_POST['continue'])) $cfg
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getContentStylePath($a_style_id, $add_random=true)
get content style path
Create styles array
The data for the language used.
editDataCl()
Edit data of table.
static initDragDrop()
Init YUI Drag and Drop.
$i
Definition: disco.tpl.php:19
static initPanel($a_resize=false, ilTemplate $a_main_tpl=null)
Init yui panel.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editDataCl()

ilPCDataTableGUI::editDataCl ( )

Edit data of table.

(classic version)

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

References $_POST, ilPageContentGUI\$ctrl, $i, $ilCtrl, ilPageContentGUI\$lng, $path, $res, ilPageContentGUI\$tpl, $type, array, ilPageContentGUI\displayValidationError(), ilPageContentGUI\getBBMenu(), ilPageContentGUI\getHierId(), ilUtil\getImagePath(), ilYuiUtil\initConnection(), ilYuiUtil\initDragDrop(), ilYuiUtil\initPanel(), setTabs(), ilUtil\stripSlashes(), ilPCParagraph\xml2output(), xpath_eval(), and xpath_new_context().

Referenced by editData().

72  {
73  $lng = $this->lng;
75  //var_dump($_GET);
76  //var_dump($_POST);
77 
78  $this->setTabs();
79 
80  $this->displayValidationError();
81 
82  include_once("./Services/COPage/classes/class.ilPCParagraph.php");
83 
84  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tabledata.html", "Services/COPage");
85  $dtpl = $this->tpl;
86  //$dtpl = new ilTemplate("tpl.tabledata.html", true, true, "Services/COPage");
87  $dtpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "tableAction"));
88  $dtpl->setVariable("BB_MENU", $this->getBBMenu("cell_0_0"));
89 
92  ilYuiUtil::initPanel(false);
93  $this->tpl->addJavascript("./Services/COPage/phpBB/3_0_5/editor.js");
94  $this->tpl->addJavascript("./Services/COPage/js/page_editing.js");
95  $this->tpl->addJavascript("./Services/COPage/js/paragraph_editing.js");
96 
97  // get all rows
98  $xpc = xpath_new_context($this->dom);
99  $path = "//PageContent[@HierId='" . $this->getHierId() . "']" .
100  "/Table/TableRow";
101  $res = xpath_eval($xpc, $path);
102 
103  for ($i = 0; $i < count($res->nodeset); $i++) {
104  $xpc2 = xpath_new_context($this->dom);
105  $path2 = "//PageContent[@HierId='" . $this->getHierId() . "']" .
106  "/Table/TableRow[$i+1]/TableData";
107  $res2 = xpath_eval($xpc2, $path2);
108 
109  // if this is the first row -> col icons
110  if ($i == 0) {
111  for ($j = 0; $j < count($res2->nodeset); $j++) {
112  if ($j == 0) {
113  $dtpl->touchBlock("empty_td");
114  }
115 
116  if ($j == 0) {
117  if (count($res2->nodeset) == 1) {
118  $move_type = "none";
119  } else {
120  $move_type = "forward";
121  }
122  } elseif ($j == (count($res2->nodeset) - 1)) {
123  $move_type = "backward";
124  } else {
125  $move_type = "both";
126  }
127  $dtpl->setCurrentBlock("col_icon");
128  $dtpl->setVariable("COL_ICON_ALT", $lng->txt("content_column"));
129  $dtpl->setVariable("COL_ICON", ilUtil::getImagePath("col.svg"));
130  $dtpl->setVariable("COL_ONCLICK", "COL_" . $move_type);
131  $dtpl->setVariable("NR", $j);
132  $dtpl->parseCurrentBlock();
133  }
134  $dtpl->setCurrentBlock("row");
135  $dtpl->parseCurrentBlock();
136  }
137 
138 
139  for ($j = 0; $j < count($res2->nodeset); $j++) {
140  // first col: row icons
141  if ($j == 0) {
142  if ($i == 0) {
143  if (count($res->nodeset) == 1) {
144  $move_type = "none";
145  } else {
146  $move_type = "forward";
147  }
148  } elseif ($i == (count($res->nodeset) - 1)) {
149  $move_type = "backward";
150  } else {
151  $move_type = "both";
152  }
153  $dtpl->setCurrentBlock("row_icon");
154  $dtpl->setVariable("ROW_ICON_ALT", $lng->txt("content_row"));
155  $dtpl->setVariable("ROW_ICON", ilUtil::getImagePath("row.svg"));
156  $dtpl->setVariable("ROW_ONCLICK", "ROW_" . $move_type);
157  $dtpl->setVariable("NR", $i);
158  $dtpl->parseCurrentBlock();
159  }
160 
161  // cell
162  if ($res2->nodeset[$j]->get_attribute("Hidden") != "Y") {
163  $dtpl->setCurrentBlock("cell");
164 
165  if (is_array($_POST["cmd"]) && key($_POST["cmd"]) == "update") {
166  $s_text = ilUtil::stripSlashes("cell_" . $i . "_" . $j, false);
167  } else {
168  $s_text = ilPCParagraph::xml2output($this->content_obj->getCellText($i, $j));
169  }
170 
171  $dtpl->setVariable("PAR_TA_NAME", "cell[" . $i . "][" . $j . "]");
172  $dtpl->setVariable("PAR_TA_ID", "cell_" . $i . "_" . $j);
173  $dtpl->setVariable("PAR_TA_CONTENT", $s_text);
174 
175  $cs = $res2->nodeset[$j]->get_attribute("ColSpan");
176  $rs = $res2->nodeset[$j]->get_attribute("RowSpan");
177  // $dtpl->setVariable("WIDTH", "140");
178  // $dtpl->setVariable("HEIGHT", "80");
179  if ($cs > 1) {
180  $dtpl->setVariable("COLSPAN", 'colspan="' . $cs . '"');
181  $dtpl->setVariable("WIDTH", (140 + ($cs - 1) * 146));
182  }
183  if ($rs > 1) {
184  $dtpl->setVariable("ROWSPAN", 'rowspan="' . $rs . '"');
185  $dtpl->setVariable("HEIGHT", (80 + ($rs - 1) * 86));
186  }
187  $dtpl->parseCurrentBlock();
188  }
189  }
190  $dtpl->setCurrentBlock("row");
191  $dtpl->parseCurrentBlock();
192  }
193 
194  // init menues
195  $types = array("row", "col");
196  $moves = array("none", "backward", "both", "forward");
197  $commands = array(
198  "row" => array( "newRowAfter" => "cont_ed_new_row_after",
199  "newRowBefore" => "cont_ed_new_row_before",
200  "moveRowUp" => "cont_ed_row_up",
201  "moveRowDown" => "cont_ed_row_down",
202  "deleteRow" => "cont_ed_delete_row"),
203  "col" => array( "newColAfter" => "cont_ed_new_col_after",
204  "newColBefore" => "cont_ed_new_col_before",
205  "moveColLeft" => "cont_ed_col_left",
206  "moveColRight" => "cont_ed_col_right",
207  "deleteCol" => "cont_ed_delete_col")
208  );
209  foreach ($types as $type) {
210  foreach ($moves as $move) {
211  foreach ($commands[$type] as $command => $lang_var) {
212  if ($move == "none" && (substr($command, 0, 4) == "move" || substr($command, 0, 6) == "delete")) {
213  continue;
214  }
215  if (($move == "backward" && (in_array($command, array("movedown", "moveright")))) ||
216  ($move == "forward" && (in_array($command, array("moveup", "moveleft"))))) {
217  continue;
218  }
219  $this->tpl->setCurrentBlock("menu_item");
220  $this->tpl->setVariable("MENU_ITEM_TITLE", $lng->txt($lang_var));
221  $this->tpl->setVariable("CMD", $command);
222  $this->tpl->setVariable("TYPE", $type);
223  $this->tpl->parseCurrentBlock();
224  }
225  $this->tpl->setCurrentBlock("menu");
226  $this->tpl->setVariable("TYPE", $type);
227  $this->tpl->setVariable("MOVE", $move);
228  $this->tpl->parseCurrentBlock();
229  }
230  }
231 
232  // update/cancel
233  $this->tpl->setCurrentBlock("commands");
234  $this->tpl->setVariable("BTN_NAME", "update");
235  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
236  $this->tpl->parseCurrentBlock();
237 
238  $this->tpl->setVariable(
239  "FORMACTION2",
240  $ilCtrl->getFormAction($this, "tableAction")
241  );
242  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_table"));
243  }
xpath_new_context($dom_document)
$type
static initConnection(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
xpath_eval($xpath_context, $eval_str, $contextnode=null)
getHierId()
get hierarchical id in dom object
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true, $unmask=true)
Converts xml from DB to output in edit textarea.
global $ilCtrl
Definition: ilias.php:18
getBBMenu($a_ta_name="par_content")
Get the bb menu incl.
foreach($_POST as $key=> $value) $res
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
displayValidationError()
display validation errors
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
static initDragDrop()
Init YUI Drag and Drop.
$i
Definition: disco.tpl.php:19
static initPanel($a_resize=false, ilTemplate $a_main_tpl=null)
Init yui panel.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPCDataTableGUI::executeCommand ( )

execute command

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

References $ret, and ilPageContentGUI\getCharacteristicsOfCurrentStyle().

45  {
46  $this->getCharacteristicsOfCurrentStyle("table"); // scorm-2004
47 
48  // get next class that processes or forwards current command
49  $next_class = $this->ctrl->getNextClass($this);
50 
51  // get current command
52  $cmd = $this->ctrl->getCmd();
53 
54  switch ($next_class) {
55  default:
56  $ret = $this->$cmd();
57  break;
58  }
59 
60  return $ret;
61  }
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
$ret
Definition: parser.php:6
+ Here is the call graph for this function:

◆ getNewTableObject()

ilPCDataTableGUI::getNewTableObject ( )

Get new table object.

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

References ilPageContentGUI\getPage().

378  {
379  return new ilPCDataTable($this->getPage());
380  }
Class ilPCDataTable.
+ Here is the call graph for this function:

◆ setTabs()

ilPCDataTableGUI::setTabs ( )

Set tabs.

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

References ilPageContentGUI\$ctrl, $ilCtrl, and $tabs.

Referenced by editData(), and editDataCl().

425  {
427  $ilTabs = $this->tabs;
428 
429  parent::setTabs();
430 
431  $ilTabs->addTarget(
432  "cont_ed_edit_data",
433  $ilCtrl->getLinkTarget($this, "editData"),
434  "editData",
435  get_class($this)
436  );
437  }
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ tableAction()

ilPCDataTableGUI::tableAction ( )

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

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

References $_POST, $_SESSION, $action, ilPageContentGUI\$ctrl, $ilCtrl, string, and update().

403  {
405 
406  $this->update(false);
407  $this->pg_obj->addHierIDs();
408 
409  $cell_hier_id = ($_POST["type"] == "col")
410  ? $this->hier_id . "_1_" . ($_POST["id"] + 1)
411  : $this->hier_id . "_" . ($_POST["id"] + 1) . "_1";
412  $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
413  if (is_object($cell_obj)) {
414  $action = (string) ($_POST["action"]);
415  $cell_obj->$action();
416  $_SESSION["il_pg_error"] = $this->pg_obj->update();
417  }
418  $ilCtrl->redirect($this, "editData");
419  }
Add rich text string
$_SESSION["AccountId"]
$action
update($a_redirect=true)
Update table data in dom and update page in db.
global $ilCtrl
Definition: ilias.php:18
$_POST["username"]
+ Here is the call graph for this function:

◆ update()

ilPCDataTableGUI::update (   $a_redirect = true)

Update table data in dom and update page in db.

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

References $_POST, $data, $i, ilPageContentGUI\$lng, $row, ilPCParagraph\_input2xml(), array, editData(), and ilUtil\sendSuccess().

Referenced by tableAction().

249  {
250  $lng = $this->lng;
251 
252  // handle input data
253  include_once("./Services/COPage/classes/class.ilPCParagraph.php");
254  $data = array();
255  //var_dump($_POST["cell"]);
256  //var_dump($_GET);
257  if (is_array($_POST["cell"])) {
258  foreach ($_POST["cell"] as $i => $row) {
259  if (is_array($row)) {
260  foreach ($row as $j => $cell) {
261  $data[$i][$j] =
263  $cell,
264  $this->content_obj->getLanguage()
265  );
266  }
267  }
268  }
269  }
270 
271  $this->updated = $this->content_obj->setData($data);
272 
273  if ($this->updated !== true) {
274  $this->editData();
275  return;
276  }
277 
278  $this->updated = $this->pg_obj->update();
279 
280  if ($a_redirect) {
281  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
282  $this->ctrl->redirect($this, "editData");
283  }
284  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
editData()
Edit data of table.
Create styles array
The data for the language used.
static _input2xml($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
converts user input to xml
$i
Definition: disco.tpl.php:19
$_POST["username"]
+ 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 289 of file class.ilPCDataTableGUI.php.

References $_POST, ilPageContentGUI\$ctrl, $data, $failed, $id, $ilCtrl, ilPageContentGUI\$lng, $ret, $text, ilPCParagraph\_input2xml(), array, editData(), ilPCParagraph\handleAjaxContent(), ilPCParagraph\handleAjaxContentPost(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and ilUtil\stripSlashes().

290  {
291  $lng = $this->lng;
293 
294  if ($_POST["cancel_update"]) {
295  // $this->ctrl->redirect($this, "editData");
296  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
297  }
298 
299  // handle input data
300  include_once("./Services/COPage/classes/class.ilPCParagraph.php");
301  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
302  $data = array();
303  foreach ($_POST as $k => $content) {
304  if (substr($k, 0, 5) != "cell_") {
305  continue;
306  }
307 
308  // determine cell content
309  $div = ilUtil::stripSlashes($content, false);
310  $p1 = strpos($div, '>');
311  $div = substr($div, $p1 + 1);
312  $div = "<div class='ilc_text_block_TableContent'>" . $div;
314  if ($text === false) {
315  $ilCtrl->returnToParent($this, "jump" . $this->hier_id);
316  }
317  $text = $text["text"];
318 
320  $text,
321  $this->content_obj->getLanguage(),
322  true,
323  false
324  );
326 
327  // set content in data array
328  $id = explode("_", $k);
329  $data[(int) $id[1]][(int) $id[2]] = $text;
330  }
331 
332  // update data
333  $this->updated = $this->content_obj->setData($data);
334 
335  if ($this->updated !== true) {
336  $this->editData();
337  return;
338  }
339 
340  $this->updated = $this->pg_obj->update();
341 
342 
343  // perform table action? (move...?)
344  //$this->update(false);
345  $this->pg_obj->addHierIDs();
346  $failed = false;
347  if ($_POST["tab_cmd"] != "") {
348  $cell_hier_id = ($_POST["tab_cmd_type"] == "col")
349  ? $this->hier_id . "_1_" . ($_POST["tab_cmd_id"] + 1)
350  : $this->hier_id . "_" . ($_POST["tab_cmd_id"] + 1) . "_1";
351  $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
352  if (is_object($cell_obj)) {
353  $tab_cmd = $_POST["tab_cmd"];
354  $cell_obj->$tab_cmd();
355  $ret = $this->pg_obj->update();
356  if ($ret !== true) {
357  ilUtil::sendFailure($ret[0][1], true);
358  $failed = true;
359  }
360  }
361  }
362 
363  if (!$failed) {
364  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
365  }
366  if ($_POST["save_return"]) {
367  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
368  } else {
369  $this->ctrl->redirect($this, "editData");
370  }
371  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static handleAjaxContentPost($text)
Post input2xml handling of ajax content.
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
static handleAjaxContent($a_content)
Handle ajax content.
$text
Definition: errorreport.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
editData()
Edit data of table.
$failed
Definition: Utf8Test.php:85
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _input2xml($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
converts user input to xml
$ret
Definition: parser.php:6
$_POST["username"]
+ Here is the call graph for this function:

Field Documentation

◆ $tabs

ilPCDataTableGUI::$tabs
protected

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

Referenced by setTabs().


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