ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
ilPCGridGUI Class Reference

Responsive Grid UI class. More...

+ Inheritance diagram for ilPCGridGUI:
+ Collaboration diagram for ilPCGridGUI:

Public Member Functions

 __construct (ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
 
 executeCommand ()
 
 insert ()
 
 initCreationForm ()
 Init creation form. More...
 
 create ()
 Create new grid element. More...
 
 afterCreation ()
 
 edit ()
 List all cells. More...
 
 savePositions ()
 Save positions. More...
 
 editWidths (string $id)
 
 addCell ()
 Add cell. More...
 
 confirmCellDeletion (array $tids)
 Confirm cell deletion. More...
 
 cancelCellDeletion ()
 Cancel cell deletion. More...
 
 deleteCells ()
 Delete Cells. More...
 
 setTabs ()
 
 saveCellData ()
 Save tabs properties in db and return to page edit screen. 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...
 

Data Fields

const TEMPLATE_MANUAL = 0
 
const TEMPLATE_TWO_COLUMN = 1
 
const TEMPLATE_THREE_COLUMN = 2
 
const TEMPLATE_MAIN_SIDE = 3
 
const TEMPLATE_TWO_BY_TWO = 4
 
- Data Fields inherited from ilPageContentGUI
ilPageContent $content_obj
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilPageObject $pg_obj
 
string $hier_id = ""
 
DOMDocument $dom
 
array bool null $updated = null
 
string $target_script = ""
 
string $return_location = ""
 
ilPageConfig $page_config = null
 

Protected Member Functions

 getGridTable ()
 
 getEditWidthsForm (string $id)
 
 saveWidths ()
 
- 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 COPage InternalDomainService $domain
 
ilToolbarGUI $toolbar
 
ilTabsGUI $tabs
 
- 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 ilPageContentGUI
static _getCommonBBButtons ()
 
- 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

Responsive Grid UI class.

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

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

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from ilPageContentGUI.

Definition at line 39 of file class.ilPCGridGUI.php.

44 {
45 global $DIC;
46
47 $this->ctrl = $DIC->ctrl();
48 $ilToolbar = $DIC->toolbar();
49 $ilTabs = $DIC->tabs();
50
51 $this->toolbar = $ilToolbar;
52 $this->tabs = $ilTabs;
53 $this->domain = $DIC->copage()->internal()->domain();
54 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
55 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), ILIAS\Repository\tabs(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ addCell()

ilPCGridGUI::addCell ( )

Add cell.

Definition at line 308 of file class.ilPCGridGUI.php.

308 : void
309 {
310 $this->content_obj->addCell();
311 $this->updated = $this->pg_obj->update();
312
313 $this->tpl->setOnScreenMessage('success', $this->lng->txt("cont_added_cell"), true);
314 $this->ctrl->redirect($this, "edit");
315 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ afterCreation()

ilPCGridGUI::afterCreation ( )

Definition at line 183 of file class.ilPCGridGUI.php.

183 : void
184 {
185 $this->pg_obj->stripHierIDs();
186 $this->pg_obj->addHierIDs();
187 $this->ctrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
188 $this->ctrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
189 $this->content_obj->setHierId($this->content_obj->readHierId());
190 $this->setHierId($this->content_obj->readHierId());
191 $this->content_obj->setPcId($this->content_obj->readPCId());
192 $this->edit();
193 }
edit()
List all cells.
setHierId(string $a_hier_id)
set hierarchical id in dom object

References ILIAS\Repository\ctrl(), edit(), and ilPageContentGUI\setHierId().

Referenced by create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelCellDeletion()

ilPCGridGUI::cancelCellDeletion ( )

Cancel cell deletion.

Definition at line 351 of file class.ilPCGridGUI.php.

351 : void
352 {
353 $this->ctrl->redirect($this, "edit");
354 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ confirmCellDeletion()

ilPCGridGUI::confirmCellDeletion ( array  $tids)

Confirm cell deletion.

Definition at line 320 of file class.ilPCGridGUI.php.

320 : void
321 {
322 $table = $this->getGridTable();
323 $ids = $table->getItemIds();
324
325 if (count($ids) === 0) {
326 $this->ctrl->redirect($this, "edit");
327 }
328
329 $retrieval = $this->domain->pc()->gridCellRetrieval($this->content_obj);
330 $data = $retrieval->getData([]);
331 $items = [];
332 $cnt = 1;
333 foreach ($data as $row) {
334 if (in_array($row["id"], $ids)) {
335 $items[$row["id"]] = $this->lng->txt("cont_grid_cell") . " " . $cnt;
336 }
337 $cnt++;
338 }
339
340 $table->renderDeletionConfirmation(
341 $this->lng->txt("delete"),
342 $this->lng->txt("cont_grid_cell_confirm_deletion"),
343 "deleteCells",
344 $items
345 );
346 }

References $data, ILIAS\Repository\ctrl(), getGridTable(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ create()

ilPCGridGUI::create ( )

Create new grid element.

Definition at line 154 of file class.ilPCGridGUI.php.

154 : void
155 {
156 $form = $this->initCreationForm();
157 if ($form->checkInput()) {
158 $post_layout_template = (int) $form->getInput("layout_template");
159 $this->content_obj = new ilPCGrid($this->getPage());
160 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
161 $this->content_obj->applyTemplate(
162 $post_layout_template,
163 (int) $form->getInput("number_of_cells"),
164 (int) $form->getInput("s"),
165 (int) $form->getInput("m"),
166 (int) $form->getInput("l"),
167 (int) $form->getInput("xl")
168 );
169 $this->updated = $this->pg_obj->update();
170
171 if ($this->updated === true) {
172 $this->afterCreation();
173 //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
174 } else {
175 $this->insert();
176 }
177 } else {
178 $form->setValuesByPost();
179 $this->tpl->setContent($form->getHTML());
180 }
181 }
initCreationForm()
Init creation form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References afterCreation(), ilPageContentGUI\getPage(), initCreationForm(), insert(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ deleteCells()

ilPCGridGUI::deleteCells ( )

Delete Cells.

Definition at line 359 of file class.ilPCGridGUI.php.

359 : void
360 {
361 $ilCtrl = $this->ctrl;
362
363 $table = $this->getGridTable();
364 $ids = $table->getItemIds();
365
366 foreach ($ids as $tid) {
367 $ids = explode(":", $tid);
368 $this->content_obj->deleteGridCell($ids[0], $ids[1]);
369 }
370 $this->updated = $this->pg_obj->update();
371
372 $ilCtrl->redirect($this, "edit");
373 }

References ilPageContentGUI\$ctrl, and getGridTable().

+ Here is the call graph for this function:

◆ edit()

ilPCGridGUI::edit ( )

List all cells.

Definition at line 203 of file class.ilPCGridGUI.php.

203 : void
204 {
205 $this->toolbar->addButton(
206 $this->lng->txt("cont_add_cell"),
207 $this->ctrl->getLinkTarget($this, "addCell")
208 );
209
210 $this->setTabs();
211 $this->tabs->activateTab("settings");
212
213 $table = $this->gui->pc()->gridCellTableBuilder(
214 $this->content_obj,
215 $this,
216 "edit"
217 )->getTable();
218
219 if ($table->handleCommand()) {
220 return;
221 }
222
223 $this->tpl->setContent($table->render());
224 }

References ILIAS\Repository\lng(), setTabs(), ILIAS\Repository\tabs(), and ILIAS\Repository\toolbar().

Referenced by afterCreation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editWidths()

ilPCGridGUI::editWidths ( string  $id)

Definition at line 252 of file class.ilPCGridGUI.php.

252 : void
253 {
254 $form = $this->getEditWidthsForm($id);
255 $this->gui->modal($this->lng->txt("cont_ed_grid_col_widths"))
256 ->form($form)
257 ->send();
258 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getEditWidthsForm(string $id)

References getEditWidthsForm(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ executeCommand()

ilPCGridGUI::executeCommand ( )

Definition at line 57 of file class.ilPCGridGUI.php.

57 : void
58 {
59 // get next class that processes or forwards current command
60 $next_class = $this->ctrl->getNextClass($this);
61
62 // get current command
63 $cmd = $this->ctrl->getCmd();
64
65 switch ($next_class) {
66 default:
67 $this->$cmd();
68 break;
69 }
70 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getEditWidthsForm()

ilPCGridGUI::getEditWidthsForm ( string  $id)
protected

Definition at line 260 of file class.ilPCGridGUI.php.

261 {
262 $this->ctrl->setParameter($this, "tid", $id);
263 $options = ["" => ""] + ilPCGrid::getWidths();
264
265 $data = $this->content_obj->getCellData();
266 $row_data = [];
267 foreach ($data as $row) {
268 if ($row["hier_id"] . ":" . $row["pc_id"] === $id) {
269 $row_data = $row;
270 break;
271 }
272 }
273
274 $form = $this->gui->form([self::class], "saveWidths");
275 foreach (ilPCGrid::getSizes() as $s) {
276 $form->select(
277 "width_" . $s,
278 $this->lng->txt("cont_grid_width_" . $s),
279 $options,
280 "",
281 $row_data[$s] ?? ""
282 );
283 }
284
285 return $form;
286 }
static getSizes()
Get sizes.
static getWidths()
Get widths.

References $data, $id, ILIAS\UI\Implementation\Component\Input\Field\$options, ILIAS\Repository\ctrl(), ilPCGrid\getSizes(), ilPCGrid\getWidths(), and ILIAS\Repository\lng().

Referenced by editWidths(), and saveWidths().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGridTable()

ilPCGridGUI::getGridTable ( )
protected

Definition at line 226 of file class.ilPCGridGUI.php.

227 {
228 return $this->gui->pc()->gridCellTableBuilder(
229 $this->content_obj,
230 $this,
231 "edit"
232 )->getTable();
233 }

References ILIAS\Repository\Table\TableAdapterGUI\getTable().

Referenced by confirmCellDeletion(), deleteCells(), and savePositions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initCreationForm()

ilPCGridGUI::initCreationForm ( )

Init creation form.

Definition at line 97 of file class.ilPCGridGUI.php.

98 {
100
101 // edit form
102 $form = new ilPropertyFormGUI();
103 $form->setFormAction($this->ctrl->getFormAction($this));
104 $form->setTitle($this->lng->txt("cont_ed_insert_grid"));
105 $form->setDescription($this->lng->txt("cont_ed_insert_grid_info"));
106
107 //
108 $radg = new ilRadioGroupInputGUI($lng->txt("cont_pc_grid"), "layout_template");
109 $radg->setValue(self::TEMPLATE_TWO_COLUMN);
110 $op1 = new ilRadioOption($lng->txt("cont_grid_t_two_column"), self::TEMPLATE_TWO_COLUMN, $lng->txt("cont_grid_t_two_column_info"));
111 $radg->addOption($op1);
112 $op2 = new ilRadioOption($lng->txt("cont_grid_t_three_column"), self::TEMPLATE_THREE_COLUMN, $lng->txt("cont_grid_t_three_column_info"));
113 $radg->addOption($op2);
114 $op3 = new ilRadioOption($lng->txt("cont_grid_t_main_side"), self::TEMPLATE_MAIN_SIDE, $lng->txt("cont_grid_t_main_side_info"));
115 $radg->addOption($op3);
116 $op4 = new ilRadioOption($lng->txt("cont_grid_t_two_by_two"), self::TEMPLATE_TWO_BY_TWO, $lng->txt("cont_grid_t_two_by_two_info"));
117 $radg->addOption($op4);
118 $op5 = new ilRadioOption($lng->txt("cont_grid_t_manual"), self::TEMPLATE_MANUAL, $lng->txt("cont_grid_t_manual_info"));
119 $radg->addOption($op5);
120 $form->addItem($radg);
121
122
123 // number of cells
124 $ni = new ilNumberInputGUI($this->lng->txt("cont_grid_nr_cells"), "number_of_cells");
125 $ni->setMaxLength(2);
126 $ni->setSize(2);
127 $op5->addSubItem($ni);
128
129 /*$sh = new ilFormSectionHeaderGUI();
130 $sh->setTitle($this->lng->txt("cont_ed_grid_col_width"));
131 $sh->setInfo($this->lng->txt("cont_ed_grid_col_width_info"));
132 $form->addItem($sh);*/
133
134 $options = array("" => "") + ilPCGrid::getWidths();
135
136 // widths
137 foreach (ilPCGrid::getSizes() as $s) {
138 $si = new ilSelectInputGUI($this->lng->txt("cont_grid_width_" . $s), $s);
139 $si->setInfo($this->lng->txt("cont_grid_width_" . $s . "_info"));
140 $si->setOptions($options);
141 $op5->addSubItem($si);
142 }
143
144 // save/cancel buttons
145 $form->addCommandButton("create", $this->lng->txt("save"));
146 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
147
148 return $form;
149 }
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...
This class represents a number property in a property form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.

References ilPageContentGUI\$lng, ILIAS\UI\Implementation\Component\Input\Field\$options, ILIAS\Repository\ctrl(), ilPCGrid\getSizes(), ilPCGrid\getWidths(), ILIAS\Repository\lng(), and ilLanguage\txt().

Referenced by create(), and insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

ilPCGridGUI::insert ( )

Definition at line 72 of file class.ilPCGridGUI.php.

72 : void
73 {
75 $form = $this->initCreationForm();
76 if ($this->ctrl->getCmd() == "create") {
77 $form->setValuesByPost();
78 }
79 $this->tpl->setContent($form->getHTML());
80 }

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

Referenced by create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveCellData()

ilPCGridGUI::saveCellData ( )

Save tabs properties in db and return to page edit screen.

Definition at line 392 of file class.ilPCGridGUI.php.

392 : void
393 {
394 $width_s = $this->request->getStringArray("width_s");
395 $width_m = $this->request->getStringArray("width_m");
396 $width_l = $this->request->getStringArray("width_l");
397 $width_xl = $this->request->getStringArray("width_xl");
398 $this->content_obj->saveWidths($width_s, $width_m, $width_l, $width_xl);
399
400 $pos = $this->request->getStringArray("position");
401 if (count($pos) > 0) {
402 $this->content_obj->savePositions($pos);
403 }
404 $this->updated = $this->pg_obj->update();
405 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
406 $this->ctrl->redirect($this, "edit");
407 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ savePositions()

ilPCGridGUI::savePositions ( )

Save positions.

Definition at line 238 of file class.ilPCGridGUI.php.

238 : void
239 {
240 $table = $this->getGridTable();
241
242 $ordered_ids = $table->getData();
243
244 if (is_array($ordered_ids) && count($ordered_ids) > 0) {
245 $this->content_obj->savePositions($ordered_ids);
246 }
247 $this->updated = $this->pg_obj->update();
248 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
249 $this->ctrl->redirect($this, "edit");
250 }

References ILIAS\Repository\ctrl(), getGridTable(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ saveWidths()

ilPCGridGUI::saveWidths ( )
protected

Definition at line 288 of file class.ilPCGridGUI.php.

288 : void
289 {
290 $id = $this->request->getString("tid");
291 $form = $this->getEditWidthsForm($id);
292 if ($form->isValid()) {
293 $w_s = [$id => $form->getData("width_s")];
294 $w_m = [$id => $form->getData("width_m")];
295 $w_l = [$id => $form->getData("width_l")];
296 $w_xl = [$id => $form->getData("width_xl")];
297 $this->content_obj->saveWidths($w_s, $w_m, $w_l, $w_xl);
298 $this->updated = $this->pg_obj->update();
299 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
300 $this->ctrl->redirect($this, "edit");
301 }
302 }

References $id, ILIAS\Repository\ctrl(), getEditWidthsForm(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ setTabs()

ilPCGridGUI::setTabs ( )

Definition at line 375 of file class.ilPCGridGUI.php.

375 : void
376 {
377 $this->tabs->setBackTarget(
378 $this->lng->txt("pg"),
379 $this->ctrl->getParentReturn($this)
380 );
381
382 $this->tabs->addTab(
383 "settings",
384 $this->lng->txt("settings"),
385 $this->ctrl->getLinkTarget($this, "edit")
386 );
387 }

References ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by edit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $domain

ILIAS COPage InternalDomainService ilPCGridGUI::$domain
protected

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

◆ $tabs

ilTabsGUI ilPCGridGUI::$tabs
protected

Definition at line 37 of file class.ilPCGridGUI.php.

◆ $toolbar

ilToolbarGUI ilPCGridGUI::$toolbar
protected

Definition at line 36 of file class.ilPCGridGUI.php.

◆ TEMPLATE_MAIN_SIDE

◆ TEMPLATE_MANUAL

const ilPCGridGUI::TEMPLATE_MANUAL = 0

◆ TEMPLATE_THREE_COLUMN

const ilPCGridGUI::TEMPLATE_THREE_COLUMN = 2

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

Referenced by ilPCGrid\applyTemplate().

◆ TEMPLATE_TWO_BY_TWO

const ilPCGridGUI::TEMPLATE_TWO_BY_TWO = 4

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

Referenced by ilPCGrid\applyTemplate().

◆ TEMPLATE_TWO_COLUMN


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