ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 
 $main_tpl
 
 $tool_context
 
- 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, $page_object=null)
 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 40 of file class.ilPCDataTableGUI.php.

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

41  {
42  global $DIC;
43 
44  $this->main_tpl = $DIC->ui()->mainTemplate();
45  $this->lng = $DIC->language();
46  $this->ctrl = $DIC->ctrl();
47  $this->tabs = $DIC->tabs();
48  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
49  $this->setCharacteristics(array("StandardTable" => $this->lng->txt("cont_StandardTable")));
50  $this->tool_context = $DIC->globalScreen()->tool()->context();
51  }
setCharacteristics($a_chars)
Set Characteristics.
__construct(Container $dic, ilPlugin $plugin)
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ afterCreation()

ilPCDataTableGUI::afterCreation ( )

After creation processing.

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

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

398  {
400 
401  $this->pg_obj->stripHierIDs();
402  $this->pg_obj->addHierIDs();
403  $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
404  $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
405  $this->content_obj->setHierId($this->content_obj->readHierId());
406  $this->setHierId($this->content_obj->readHierId());
407  $this->content_obj->setPCId($this->content_obj->readPCId());
408  $this->editData();
409  }
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 459 of file class.ilPCDataTableGUI.php.

References $_POST, Vendor\Package\$c, ilPageContentGUI\$ctrl, $GLOBALS, $i, $ilCtrl, ilPageContentGUI\$lng, $main_tpl, $res, $type, ilPageEditorGUI\_doJSEditing(), ilPCParagraphGUI\_getTextCharacteristics(), 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(), ilCOPageEditGSToolProvider\SHOW_EDITOR, ilUtil\stripSlashes(), ilPCParagraph\xml2output(), ilPCParagraphGUI\xml2outputJS(), xpath_eval(), and xpath_new_context().

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

460  {
461  $lng = $this->lng;
464 
465 
466  $this->tool_context->current()->addAdditionalData(ilCOPageEditGSToolProvider::SHOW_EDITOR, true);
467 
469  return $this->editDataCl();
470  }
471 
472  //var_dump($_GET);
473  //var_dump($_POST);
474 
475  $this->setTabs();
476 
477  $this->displayValidationError();
478 
479 
480  include_once("./Services/COPage/classes/class.ilPCParagraph.php");
481 
482  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tabledata2.html", "Services/COPage");
483  //$dtpl = $this->tpl;
484  $dtpl = new ilTemplate("tpl.tabledata2.html", true, true, "Services/COPage");
485  $dtpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "tableAction"));
486 
487 
488  $dtpl->setVariable(
489  "WYSIWYG_ACTION",
490  $ilCtrl->getFormAction($this, "updateJS")
491  );
492 
493  // get all rows
494  $xpc = xpath_new_context($this->dom);
495  $path = "//PageContent[@HierId='" . $this->getHierId() . "']" .
496  "/Table/TableRow";
497  $res = xpath_eval($xpc, $path);
498 
499  for ($i = 0; $i < count($res->nodeset); $i++) {
500  $xpc2 = xpath_new_context($this->dom);
501  $path2 = "//PageContent[@HierId='" . $this->getHierId() . "']" .
502  "/Table/TableRow[$i+1]/TableData";
503  $res2 = xpath_eval($xpc2, $path2);
504 
505  // if this is the first row -> col icons
506  if ($i == 0) {
507  for ($j = 0; $j < count($res2->nodeset); $j++) {
508  if ($j == 0) {
509  $dtpl->touchBlock("empty_td");
510  }
511 
512  if ($j == 0) {
513  if (count($res2->nodeset) == 1) {
514  $move_type = "none";
515  } else {
516  $move_type = "forward";
517  }
518  } elseif ($j == (count($res2->nodeset) - 1)) {
519  $move_type = "backward";
520  } else {
521  $move_type = "both";
522  }
523  $dtpl->setCurrentBlock("col_icon");
524  $dtpl->setVariable("COL_ICON_ALT", $lng->txt("content_column"));
525  $dtpl->setVariable("COL_ICON", ilUtil::getImagePath("col.svg"));
526  $dtpl->setVariable("COL_ONCLICK", "COL_" . $move_type);
527  $dtpl->setVariable("NR", $j);
528  $dtpl->parseCurrentBlock();
529  }
530  $dtpl->setCurrentBlock("row");
531  $dtpl->parseCurrentBlock();
532  }
533 
534 
535  for ($j = 0; $j < count($res2->nodeset); $j++) {
536  // first col: row icons
537  if ($j == 0) {
538  if ($i == 0) {
539  if (count($res->nodeset) == 1) {
540  $move_type = "none";
541  } else {
542  $move_type = "forward";
543  }
544  } elseif ($i == (count($res->nodeset) - 1)) {
545  $move_type = "backward";
546  } else {
547  $move_type = "both";
548  }
549  $dtpl->setCurrentBlock("row_icon");
550  $dtpl->setVariable("ROW_ICON_ALT", $lng->txt("content_row"));
551  $dtpl->setVariable("ROW_ICON", ilUtil::getImagePath("row.svg"));
552  $dtpl->setVariable("ROW_ONCLICK", "ROW_" . $move_type);
553  $dtpl->setVariable("NR", $i);
554  $dtpl->parseCurrentBlock();
555  }
556 
557  // cell
558  if ($res2->nodeset[$j]->get_attribute("Hidden") != "Y") {
559  $dtpl->setCurrentBlock("cell");
560 
561  if (is_array($_POST["cmd"]) && key($_POST["cmd"]) == "update") {
562  $s_text = ilUtil::stripSlashes("cell_" . $i . "_" . $j, false);
563  } else {
564  $s_text = ilPCParagraph::xml2output(
565  $this->content_obj->getCellText($i, $j),
566  true,
567  false
568  );
569  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
571  $s_text,
572  "TableContent",
573  $this->content_obj->readPCId() . "_" . $i . "_" . $j
574  );
575  }
576 
577  // #20628
578  $s_text = str_replace("{", "&#123;", $s_text);
579  $s_text = str_replace("}", "&#125;", $s_text);
580 
581  $dtpl->setVariable("PAR_TA_NAME", "cell[" . $i . "][" . $j . "]");
582  $dtpl->setVariable("PAR_TA_ID", "cell_" . $i . "_" . $j);
583 
584  $dtpl->setVariable("PAR_TA_CONTENT", $s_text);
585 
586  $cs = $res2->nodeset[$j]->get_attribute("ColSpan");
587  $rs = $res2->nodeset[$j]->get_attribute("RowSpan");
588  $dtpl->setVariable("WIDTH", "140");
589  $dtpl->setVariable("HEIGHT", "80");
590  if ($cs > 1) {
591  $dtpl->setVariable("COLSPAN", 'colspan="' . $cs . '"');
592  $dtpl->setVariable("WIDTH", (140 + ($cs - 1) * 146));
593  }
594  if ($rs > 1) {
595  $dtpl->setVariable("ROWSPAN", 'rowspan="' . $rs . '"');
596  $dtpl->setVariable("HEIGHT", (80 + ($rs - 1) * 86));
597  }
598  $dtpl->parseCurrentBlock();
599  }
600  }
601  $dtpl->setCurrentBlock("row");
602  $dtpl->parseCurrentBlock();
603  }
604 
605  // init menues
606  $types = array("row", "col");
607  $moves = array("none", "backward", "both", "forward");
608  $commands = array(
609  "row" => array( "newRowAfter" => "cont_ed_new_row_after",
610  "newRowBefore" => "cont_ed_new_row_before",
611  "moveRowUp" => "cont_ed_row_up",
612  "moveRowDown" => "cont_ed_row_down",
613  "deleteRow" => "cont_ed_delete_row"),
614  "col" => array( "newColAfter" => "cont_ed_new_col_after",
615  "newColBefore" => "cont_ed_new_col_before",
616  "moveColLeft" => "cont_ed_col_left",
617  "moveColRight" => "cont_ed_col_right",
618  "deleteCol" => "cont_ed_delete_col")
619  );
620 
621  foreach ($types as $type) {
622  foreach ($moves as $move) {
623  foreach ($commands[$type] as $command => $lang_var) {
624  if ($move == "none" && (substr($command, 0, 4) == "move" || substr($command, 0, 6) == "delete")) {
625  continue;
626  }
627  if (($move == "backward" && (in_array($command, array("movedown", "moveright")))) ||
628  ($move == "forward" && (in_array($command, array("moveup", "moveleft"))))) {
629  continue;
630  }
631  $dtpl->setCurrentBlock("menu_item");
632  $dtpl->setVariable("MENU_ITEM_TITLE", $lng->txt($lang_var));
633  $dtpl->setVariable("CMD", $command);
634  $dtpl->setVariable("TYPE", $type);
635  $dtpl->parseCurrentBlock();
636  }
637  $dtpl->setCurrentBlock("menu");
638  $dtpl->setVariable("TYPE", $type);
639  $dtpl->setVariable("MOVE", $move);
640  $dtpl->parseCurrentBlock();
641  }
642  }
643 
644 
645  $dtpl->setVariable(
646  "FORMACTION2",
647  $ilCtrl->getFormAction($this, "tableAction")
648  );
649  $dtpl->setVariable("TXT_ACTION", $this->lng->txt("cont_table"));
650 
651  // js editing preparation
652  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
655  ilYuiUtil::initPanel(false);
656  $main_tpl->addJavascript("./libs/bower/bower_components/tinymce/tinymce.min.js");
657  $main_tpl->addJavaScript("./Services/COPage/js/ilcopagecallback.js");
658  $main_tpl->addJavascript("Services/COPage/js/page_editing.js");
659 
660  $main_tpl->addOnloadCode("var preloader = new Image();
661  preloader.src = './templates/default/images/loader.svg';
662  ilCOPage.setContentCss('" .
664  ", " . ilUtil::getStyleSheetLocation() . ", ./Services/COPage/css/tiny_extra.css');
665  ilCOPage.editTD('cell_0_0');
666  ");
668  $GLOBALS["tpl"]->addOnloadCode("ilCOPage.addTextFormat('" . $c . "');");
669  }
670 
671  $cfg = $this->getPageConfig();
672 
673  $dtpl->setVariable(
674  "IL_TINY_MENU",
676  $this->pg_obj->getParentType(),
677  $cfg->getEnableInternalLinks(),
678  $cfg->getEnableWikiLinks(),
679  $cfg->getEnableKeywords(),
680  $this->getStyleId(),
681  false,
682  true,
683  $cfg->getEnableAnchors(),
684  false
685  )
686  );
687 
688  // add int link parts
689  if ($cfg->getEnableInternalLinks() || $cfg->getEnableWikiLinks()) {
690  include_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
691  $dtpl->setCurrentBlock("int_link_prep");
692  $dtpl->setVariable("INT_LINK_PREP", ilInternalLinkGUI::getInitHTML(
693  $ilCtrl->getLinkTargetByClass(
694  array("ilpageeditorgui", "ilinternallinkgui"),
695  "",
696  false,
697  true,
698  false
699  )
700  ));
701  }
702 
703  $this->tpl->setContent($dtpl->get());
704  }
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
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
xpath_eval($xpath_context, $eval_str, $contextnode=null)
getHierId()
get hierarchical id in dom object
static initConnection(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
static _getTextCharacteristics($a_style_id, $a_include_core=false)
Get text characteristics.
static initPanel($a_resize=false, ilGlobalTemplateInterface $a_main_tpl=null)
Init yui panel.
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)
static _doJSEditing()
checks if current user has activated js editing and if browser is js capable
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
displayValidationError()
display validation errors
getStyleId()
Get Style Id.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static initDragDrop(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Drag and Drop.
editDataCl()
Edit data of table.
$_POST["username"]
$i
Definition: metadata.php:24
+ 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 83 of file class.ilPCDataTableGUI.php.

References $_POST, ilPageContentGUI\$ctrl, $i, $ilCtrl, ilPageContentGUI\$lng, $res, ilPageContentGUI\$tpl, $type, 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().

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

◆ executeCommand()

ilPCDataTableGUI::executeCommand ( )

execute command

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

References $ret, and ilPageContentGUI\getCharacteristicsOfCurrentStyle().

57  {
58  $this->getCharacteristicsOfCurrentStyle("table"); // scorm-2004
59 
60  // get next class that processes or forwards current command
61  $next_class = $this->ctrl->getNextClass($this);
62 
63  // get current command
64  $cmd = $this->ctrl->getCmd();
65 
66  switch ($next_class) {
67  default:
68  $ret = $this->$cmd();
69  break;
70  }
71 
72  return $ret;
73  }
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 389 of file class.ilPCDataTableGUI.php.

References ilPageContentGUI\getPage().

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

◆ setTabs()

ilPCDataTableGUI::setTabs ( )

Set tabs.

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

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

Referenced by editData(), and editDataCl().

437  {
439  $ilTabs = $this->tabs;
440 
441  parent::setTabs();
442 
443  $ilTabs->addTarget(
444  "cont_ed_edit_data",
445  $ilCtrl->getLinkTarget($this, "editData"),
446  "editData",
447  get_class($this)
448  );
449  }
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 414 of file class.ilPCDataTableGUI.php.

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

415  {
417 
418  $this->update(false);
419  $this->pg_obj->addHierIDs();
420 
421  $cell_hier_id = ($_POST["type"] == "col")
422  ? $this->hier_id . "_1_" . ($_POST["id"] + 1)
423  : $this->hier_id . "_" . ($_POST["id"] + 1) . "_1";
424  $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
425  if (is_object($cell_obj)) {
426  $action = (string) ($_POST["action"]);
427  $cell_obj->$action();
428  $_SESSION["il_pg_error"] = $this->pg_obj->update();
429  }
430  $ilCtrl->redirect($this, "editData");
431  }
$_SESSION["AccountId"]
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 260 of file class.ilPCDataTableGUI.php.

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

Referenced by tableAction().

261  {
262  $lng = $this->lng;
263 
264  // handle input data
265  include_once("./Services/COPage/classes/class.ilPCParagraph.php");
266  $data = array();
267  //var_dump($_POST["cell"]);
268  //var_dump($_GET);
269  if (is_array($_POST["cell"])) {
270  foreach ($_POST["cell"] as $i => $row) {
271  if (is_array($row)) {
272  foreach ($row as $j => $cell) {
273  $data[$i][$j] =
275  $cell,
276  $this->content_obj->getLanguage()
277  );
278  }
279  }
280  }
281  }
282 
283  $this->updated = $this->content_obj->setData($data);
284 
285  if ($this->updated !== true) {
286  $this->editData();
287  return;
288  }
289 
290  $this->updated = $this->pg_obj->update();
291 
292  if ($a_redirect) {
293  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
294  $this->ctrl->redirect($this, "editData");
295  }
296  }
$data
Definition: storeScorm.php:23
editData()
Edit data of table.
static _input2xml($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
converts user input to xml
$_POST["username"]
$i
Definition: metadata.php:24
+ 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 301 of file class.ilPCDataTableGUI.php.

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

302  {
303  $lng = $this->lng;
305 
306  if ($_POST["cancel_update"]) {
307  // $this->ctrl->redirect($this, "editData");
308  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
309  }
310 
311  // handle input data
312  include_once("./Services/COPage/classes/class.ilPCParagraph.php");
313  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
314  $data = array();
315  foreach ($_POST as $k => $content) {
316  if (substr($k, 0, 5) != "cell_") {
317  continue;
318  }
319 
320  // determine cell content
321  $div = ilUtil::stripSlashes($content, false);
322  $p1 = strpos($div, '>');
323  $div = substr($div, $p1 + 1);
324  $div = "<div class='ilc_text_block_TableContent'>" . $div;
325  $text = ilPCParagraph::handleAjaxContent($div);
326  if ($text === false) {
327  $ilCtrl->returnToParent($this, "jump" . $this->hier_id);
328  }
329  $text = $text["text"];
330 
332  $text,
333  $this->content_obj->getLanguage(),
334  true,
335  false
336  );
338 
339  // set content in data array
340  $id = explode("_", $k);
341  $data[(int) $id[1]][(int) $id[2]] = $text;
342  }
343 
344  // update data
345  $this->updated = $this->content_obj->setData($data);
346 
347  if ($this->updated !== true) {
348  $this->editData();
349  return;
350  }
351 
352  $this->updated = $this->pg_obj->update();
353 
354 
355  // perform table action? (move...?)
356  //$this->update(false);
357  $this->pg_obj->addHierIDs();
358  $failed = false;
359  if ($_POST["tab_cmd"] != "") {
360  $cell_hier_id = ($_POST["tab_cmd_type"] == "col")
361  ? $this->hier_id . "_1_" . ($_POST["tab_cmd_id"] + 1)
362  : $this->hier_id . "_" . ($_POST["tab_cmd_id"] + 1) . "_1";
363  $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
364  if (is_object($cell_obj)) {
365  $tab_cmd = $_POST["tab_cmd"];
366  $cell_obj->$tab_cmd();
367  $ret = $this->pg_obj->update();
368  if ($ret !== true) {
369  ilUtil::sendFailure($ret[0][1], true);
370  $failed = true;
371  }
372  }
373  }
374 
375  if (!$failed) {
376  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
377  }
378  if ($_POST["save_return"]) {
379  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
380  } else {
381  $this->ctrl->redirect($this, "editData");
382  }
383  }
$data
Definition: storeScorm.php:23
static handleAjaxContentPost($text)
Post input2xml handling of ajax content.
global $ilCtrl
Definition: ilias.php:18
static handleAjaxContent($a_content)
Handle ajax content.
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
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

◆ $main_tpl

ilPCDataTableGUI::$main_tpl
protected

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

Referenced by editData().

◆ $tabs

ilPCDataTableGUI::$tabs
protected

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

Referenced by setTabs().

◆ $tool_context

ilPCDataTableGUI::$tool_context
protected

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


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