4 require_once(
"./Services/COPage/classes/class.ilPCDataTable.php");
5 require_once(
"./Services/COPage/classes/class.ilPCTableGUI.php");
6 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
36 public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id =
"")
40 $this->main_tpl = $DIC->ui()->mainTemplate();
41 $this->lng = $DIC->language();
42 $this->ctrl = $DIC->ctrl();
43 $this->tabs = $DIC->tabs();
45 $this->
setCharacteristics(array(
"StandardTable" => $this->lng->txt(
"cont_StandardTable")));
46 $this->tool_context = $DIC->globalScreen()->tool()->context();
57 $next_class = $this->ctrl->getNextClass($this);
60 $cmd = $this->ctrl->getCmd();
62 switch ($next_class) {
90 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
92 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.tabledata.html",
"Services/COPage");
95 $dtpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"tableAction"));
96 $dtpl->setVariable(
"BB_MENU", $this->
getBBMenu(
"cell_0_0"));
101 $this->tpl->addJavascript(
"./Services/COPage/phpBB/3_0_5/editor.js");
103 $this->tpl->addJavascript(
"./Services/COPage/js/paragraph_editing.js");
107 $path =
"//PageContent[@HierId='" . $this->
getHierId() .
"']" .
111 for (
$i = 0;
$i < count(
$res->nodeset);
$i++) {
113 $path2 =
"//PageContent[@HierId='" . $this->
getHierId() .
"']" .
114 "/Table/TableRow[$i+1]/TableData";
119 for ($j = 0; $j < count($res2->nodeset); $j++) {
121 $dtpl->touchBlock(
"empty_td");
125 if (count($res2->nodeset) == 1) {
128 $move_type =
"forward";
130 } elseif ($j == (count($res2->nodeset) - 1)) {
131 $move_type =
"backward";
135 $dtpl->setCurrentBlock(
"col_icon");
136 $dtpl->setVariable(
"COL_ICON_ALT",
$lng->txt(
"content_column"));
138 $dtpl->setVariable(
"COL_ONCLICK",
"COL_" . $move_type);
139 $dtpl->setVariable(
"NR", $j);
140 $dtpl->parseCurrentBlock();
142 $dtpl->setCurrentBlock(
"row");
143 $dtpl->parseCurrentBlock();
147 for ($j = 0; $j < count($res2->nodeset); $j++) {
151 if (count(
$res->nodeset) == 1) {
154 $move_type =
"forward";
156 } elseif (
$i == (count(
$res->nodeset) - 1)) {
157 $move_type =
"backward";
161 $dtpl->setCurrentBlock(
"row_icon");
162 $dtpl->setVariable(
"ROW_ICON_ALT",
$lng->txt(
"content_row"));
164 $dtpl->setVariable(
"ROW_ONCLICK",
"ROW_" . $move_type);
165 $dtpl->setVariable(
"NR",
$i);
166 $dtpl->parseCurrentBlock();
170 if ($res2->nodeset[$j]->get_attribute(
"Hidden") !=
"Y") {
171 $dtpl->setCurrentBlock(
"cell");
173 if (is_array(
$_POST[
"cmd"]) && key(
$_POST[
"cmd"]) ==
"update") {
179 $dtpl->setVariable(
"PAR_TA_NAME",
"cell[" .
$i .
"][" . $j .
"]");
180 $dtpl->setVariable(
"PAR_TA_ID",
"cell_" .
$i .
"_" . $j);
181 $dtpl->setVariable(
"PAR_TA_CONTENT", $s_text);
183 $cs = $res2->nodeset[$j]->get_attribute(
"ColSpan");
184 $rs = $res2->nodeset[$j]->get_attribute(
"RowSpan");
188 $dtpl->setVariable(
"COLSPAN",
'colspan="' . $cs .
'"');
189 $dtpl->setVariable(
"WIDTH", (140 + ($cs - 1) * 146));
192 $dtpl->setVariable(
"ROWSPAN",
'rowspan="' . $rs .
'"');
193 $dtpl->setVariable(
"HEIGHT", (80 + ($rs - 1) * 86));
195 $dtpl->parseCurrentBlock();
198 $dtpl->setCurrentBlock(
"row");
199 $dtpl->parseCurrentBlock();
203 $types = array(
"row",
"col");
204 $moves = array(
"none",
"backward",
"both",
"forward");
206 "row" => array(
"newRowAfter" =>
"cont_ed_new_row_after",
207 "newRowBefore" =>
"cont_ed_new_row_before",
208 "moveRowUp" =>
"cont_ed_row_up",
209 "moveRowDown" =>
"cont_ed_row_down",
210 "deleteRow" =>
"cont_ed_delete_row"),
211 "col" => array(
"newColAfter" =>
"cont_ed_new_col_after",
212 "newColBefore" =>
"cont_ed_new_col_before",
213 "moveColLeft" =>
"cont_ed_col_left",
214 "moveColRight" =>
"cont_ed_col_right",
215 "deleteCol" =>
"cont_ed_delete_col")
217 foreach ($types as
$type) {
218 foreach ($moves as $move) {
219 foreach ($commands[$type] as $command => $lang_var) {
220 if ($move ==
"none" && (substr($command, 0, 4) ==
"move" || substr($command, 0, 6) ==
"delete")) {
223 if (($move ==
"backward" && (in_array($command, array(
"movedown",
"moveright")))) ||
224 ($move ==
"forward" && (in_array($command, array(
"moveup",
"moveleft"))))) {
227 $this->tpl->setCurrentBlock(
"menu_item");
228 $this->tpl->setVariable(
"MENU_ITEM_TITLE",
$lng->txt($lang_var));
229 $this->tpl->setVariable(
"CMD", $command);
230 $this->tpl->setVariable(
"TYPE", $type);
231 $this->tpl->parseCurrentBlock();
233 $this->tpl->setCurrentBlock(
"menu");
234 $this->tpl->setVariable(
"TYPE", $type);
235 $this->tpl->setVariable(
"MOVE", $move);
236 $this->tpl->parseCurrentBlock();
241 $this->tpl->setCurrentBlock(
"commands");
242 $this->tpl->setVariable(
"BTN_NAME",
"update");
243 $this->tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
244 $this->tpl->parseCurrentBlock();
246 $this->tpl->setVariable(
248 $ilCtrl->getFormAction($this,
"tableAction")
250 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_table"));
256 public function update($a_redirect =
true)
261 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
265 if (is_array(
$_POST[
"cell"])) {
266 foreach (
$_POST[
"cell"] as
$i => $row) {
267 if (is_array($row)) {
268 foreach ($row as $j => $cell) {
272 $this->content_obj->getLanguage()
279 $this->updated = $this->content_obj->setData(
$data);
281 if ($this->updated !==
true) {
286 $this->updated = $this->pg_obj->update();
289 ilUtil::sendSuccess(
$lng->txt(
"msg_obj_modified"),
true);
290 $this->ctrl->redirect($this,
"editData");
302 if (
$_POST[
"cancel_update"]) {
304 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
308 include_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
309 include_once(
"./Services/COPage/classes/class.ilPCParagraphGUI.php");
311 foreach (
$_POST as $k => $content) {
312 if (substr($k, 0, 5) !=
"cell_") {
318 $p1 = strpos($div,
'>');
319 $div = substr($div, $p1 + 1);
320 $div =
"<div class='ilc_text_block_TableContent'>" . $div;
322 if ($text ===
false) {
323 $ilCtrl->returnToParent($this,
"jump" . $this->hier_id);
325 $text = $text[
"text"];
329 $this->content_obj->getLanguage(),
336 $id = explode(
"_", $k);
337 $data[(int) $id[1]][(
int) $id[2]] = $text;
341 $this->updated = $this->content_obj->setData(
$data);
343 if ($this->updated !==
true) {
348 $this->updated = $this->pg_obj->update();
353 $this->pg_obj->addHierIDs();
355 if (
$_POST[
"tab_cmd"] !=
"") {
356 $cell_hier_id = (
$_POST[
"tab_cmd_type"] ==
"col")
357 ? $this->hier_id .
"_1_" . (
$_POST[
"tab_cmd_id"] + 1)
358 : $this->hier_id .
"_" . (
$_POST[
"tab_cmd_id"] + 1) .
"_1";
359 $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
360 if (is_object($cell_obj)) {
361 $tab_cmd =
$_POST[
"tab_cmd"];
362 $cell_obj->$tab_cmd();
363 $ret = $this->pg_obj->update();
372 ilUtil::sendSuccess(
$lng->txt(
"msg_obj_modified"),
true);
374 if (
$_POST[
"save_return"]) {
375 $this->ctrl->returnToParent($this,
"jump" . $this->hier_id);
377 $this->ctrl->redirect($this,
"editData");
397 $this->pg_obj->stripHierIDs();
398 $this->pg_obj->addHierIDs();
399 $ilCtrl->setParameter($this,
"hier_id", $this->content_obj->readHierId());
400 $ilCtrl->setParameter($this,
"pc_id", $this->content_obj->readPCId());
401 $ilCtrl->redirect($this,
"editData");
412 $this->pg_obj->addHierIDs();
414 $cell_hier_id = (
$_POST[
"type"] ==
"col")
415 ? $this->hier_id .
"_1_" . (
$_POST[
"id"] + 1)
416 : $this->hier_id .
"_" . (
$_POST[
"id"] + 1) .
"_1";
417 $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
418 if (is_object($cell_obj)) {
419 $action = (string) (
$_POST[
"action"]);
420 $cell_obj->$action();
421 $_SESSION[
"il_pg_error"] = $this->pg_obj->update();
423 $ilCtrl->redirect($this,
"editData");
429 public function setTabs($data_tab_txt_key =
"")
434 parent::setTabs(
"cont_ed_edit_data");
439 if (is_array(
$_POST[
"cmd"]) && key(
$_POST[
"cmd"]) ==
"update") {
443 $this->content_obj->getCellText($i, $j),
447 include_once(
"./Services/COPage/classes/class.ilPCParagraphGUI.php");
451 $this->content_obj->readPCId() .
"_" . $i .
"_" . $j
456 $s_text = str_replace(
"{",
"{", $s_text);
457 $s_text = str_replace(
"}",
"}", $s_text);
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor public.
tableAction()
Perform operation on table (adding, moving, deleting rows/cols)
editData()
Edit data of table.
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
updateJS()
Update via JavaScript.
executeCommand()
execute command
xpath_new_context($dom_document)
setTabs($data_tab_txt_key="")
Set tabs.
static xml2outputJS($s_text)
Prepare content for js output.
static handleAjaxContentPost($text)
Post input2xml handling of ajax content.
xpath_eval($xpath_context, $eval_str, $contextnode=null)
update($a_redirect=true)
Update table data in dom and update page in db.
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.
setCharacteristics($a_chars)
Set Characteristics.
getBBMenu($a_ta_name="par_content")
Get the bb menu incl.
foreach($_POST as $key=> $value) $res
afterCreation()
After creation processing.
static handleAjaxContent($a_content)
Handle ajax content.
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 sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static initDragDrop(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Drag and Drop.
editDataCl()
Edit data of table.
static _input2xml($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
converts user input to xml
getNewTableObject()
Get new table object.
__construct(Container $dic, ilPlugin $plugin)
getCellContent(int $i, int $j)