4require_once(
"./Services/COPage/classes/class.ilPCGrid.php");
5require_once(
"./Services/COPage/classes/class.ilPCGridCell.php");
6require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
33 public function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id =
"")
37 $this->ctrl =
$DIC->ctrl();
38 $ilToolbar =
$DIC->toolbar();
39 $ilTabs =
$DIC->tabs();
41 $this->toolbar = $ilToolbar;
42 $this->tabs = $ilTabs;
52 $next_class = $this->ctrl->getNextClass($this);
55 $cmd = $this->ctrl->getCmd();
57 switch ($next_class) {
73 if ($this->ctrl->getCmd() ==
"create") {
74 $form->setValuesByPost();
76 $this->tpl->setContent($form->getHTML());
87 $form = $this->initForm();
88 $this->getFormValues($form);
89 $html = $form->getHTML();
90 $this->tpl->setContent($html);
102 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
104 $form->setFormAction($this->ctrl->getFormAction($this));
105 $form->setTitle($this->lng->txt(
"cont_ed_insert_grid"));
106 $form->setDescription($this->lng->txt(
"cont_ed_insert_grid_info"));
110 $radg->setValue(self::TEMPLATE_TWO_COLUMN);
111 $op1 =
new ilRadioOption(
$lng->txt(
"cont_grid_t_two_column"), self::TEMPLATE_TWO_COLUMN,
$lng->txt(
"cont_grid_t_two_column_info"));
112 $radg->addOption($op1);
113 $op2 =
new ilRadioOption(
$lng->txt(
"cont_grid_t_three_column"), self::TEMPLATE_THREE_COLUMN,
$lng->txt(
"cont_grid_t_three_column_info"));
114 $radg->addOption($op2);
115 $op3 =
new ilRadioOption(
$lng->txt(
"cont_grid_t_main_side"), self::TEMPLATE_MAIN_SIDE,
$lng->txt(
"cont_grid_t_main_side_info"));
116 $radg->addOption($op3);
117 $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"));
118 $radg->addOption($op4);
119 $op5 =
new ilRadioOption(
$lng->txt(
"cont_grid_t_manual"), self::TEMPLATE_MANUAL,
$lng->txt(
"cont_grid_t_manual_info"));
120 $radg->addOption($op5);
121 $form->addItem($radg);
125 $ni =
new ilNumberInputGUI($this->lng->txt(
"cont_grid_nr_cells"),
"number_of_cells");
126 $ni->setMaxLength(2);
128 $op5->addSubItem($ni);
140 $si->setInfo($this->lng->txt(
"cont_grid_width_" . $s .
"_info"));
141 $si->setOptions($options);
142 $op5->addSubItem(
$si);
146 $form->addCommandButton(
"create_grid", $this->lng->txt(
"save"));
147 $form->addCommandButton(
"cancelCreate", $this->lng->txt(
"cancel"));
158 if ($form->checkInput()) {
159 $post_layout_template = (int)
$_POST[
"layout_template"];
161 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
163 switch ($post_layout_template) {
165 $this->content_obj->addGridCell(12, 6, 6, 6);
166 $this->content_obj->addGridCell(12, 6, 6, 6);
170 $this->content_obj->addGridCell(12, 4, 4, 4);
171 $this->content_obj->addGridCell(12, 4, 4, 4);
172 $this->content_obj->addGridCell(12, 4, 4, 4);
176 $this->content_obj->addGridCell(12, 6, 8, 9);
177 $this->content_obj->addGridCell(12, 6, 4, 3);
181 $this->content_obj->addGridCell(12, 6, 6, 3);
182 $this->content_obj->addGridCell(12, 6, 6, 3);
183 $this->content_obj->addGridCell(12, 6, 6, 3);
184 $this->content_obj->addGridCell(12, 6, 6, 3);
189 for (
$i = 0;
$i < (int)
$_POST[
"number_of_cells"];
$i++) {
195 $this->updated = $this->pg_obj->update();
197 if ($this->updated ===
true) {
204 $form->setValuesByPost();
205 $this->tpl->setContent($form->getHTML());
214 $this->pg_obj->stripHierIDs();
215 $this->pg_obj->addHierIDs();
216 $this->ctrl->setParameter($this,
"hier_id", $this->content_obj->readHierId());
217 $this->ctrl->setParameter($this,
"pc_id", $this->content_obj->readPCId());
218 $this->content_obj->setHierId($this->content_obj->readHierId());
219 $this->
setHierId($this->content_obj->readHierId());
220 $this->content_obj->setPCId($this->content_obj->readPCId());
234 $this->toolbar->addButton(
235 $this->lng->txt(
"cont_add_cell"),
236 $this->ctrl->getLinkTarget($this,
"addCell")
240 $this->tabs->activateTab(
"settings");
241 include_once(
"./Services/COPage/classes/class.ilPCGridCellTableGUI.php");
243 $this->tpl->setContent($table_gui->getHTML());
251 if (is_array(
$_POST[
"position"])) {
253 $this->content_obj->savePositions($positions);
255 $this->updated = $this->pg_obj->update();
256 ilUtil::sendSuccess($this->lng->txt(
"msg_obj_modified"),
true);
257 $this->ctrl->redirect($this,
"edit");
265 $this->content_obj->addCell(
"",
"",
"",
"");
266 $this->updated = $this->pg_obj->update();
268 ilUtil::sendSuccess($this->lng->txt(
"cont_added_cell"),
true);
269 $this->ctrl->redirect($this,
"edit");
279 if (!is_array(
$_POST[
"tid"]) || count(
$_POST[
"tid"]) == 0) {
281 $this->ctrl->redirect($this,
"edit");
283 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
285 $cgui->setFormAction($this->ctrl->getFormAction($this));
286 $cgui->setHeaderText($this->lng->txt(
"cont_grid_cell_confirm_deletion"));
287 $cgui->setCancel($this->lng->txt(
"cancel"),
"cancelCellDeletion");
288 $cgui->setConfirm($this->lng->txt(
"delete"),
"deleteCells");
290 foreach (
$_POST[
"tid"] as $k =>
$i) {
291 $id = explode(
":", $k);
292 $id = explode(
"_", $id[0]);
293 $cgui->addItem(
"tid[]", $k, $this->lng->txt(
"cont_grid_cell") .
" " . $id[count($id) - 1]);
296 $this->tpl->setContent($cgui->getHTML());
305 $this->ctrl->redirect($this,
"edit");
315 if (is_array(
$_POST[
"tid"])) {
316 foreach (
$_POST[
"tid"] as $tid) {
317 $ids = explode(
":", $tid);
318 $this->content_obj->deleteGridCell($ids[0], $ids[1]);
321 $this->updated = $this->pg_obj->update();
323 $ilCtrl->redirect($this,
"edit");
332 $this->tabs->setBackTarget(
333 $this->lng->txt(
"pg"),
334 $this->ctrl->getParentReturn($this)
339 $this->lng->txt(
"settings"),
340 $this->ctrl->getLinkTarget($this,
"edit")
353 $this->content_obj->saveWidths($width_s, $width_m, $width_l, $width_xl);
355 if (is_array(
$_POST[
"position"])) {
357 $this->content_obj->savePositions($positions);
359 $this->updated = $this->pg_obj->update();
360 ilUtil::sendSuccess($this->lng->txt(
"msg_obj_modified"),
true);
361 $this->ctrl->redirect($this,
"edit");
An exception for terminatinating execution or to throw for unit testing.
Confirmation screen class.
Responsive Grid UI class.
confirmCellDeletion()
Confirm cell deletion.
create()
Create new grid element.
editProperties()
Edit grid cells.
const TEMPLATE_TWO_COLUMN
cancelCellDeletion()
Cancel cell deletion.
const TEMPLATE_TWO_BY_TWO
executeCommand()
Execute command.
initCreationForm()
Init creation form.
saveCells()
Save cell properties.
deleteCells()
Delete Cells.
saveCellData()
Save tabs properties in db and return to page edit screen.
__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor.
afterCreation()
After creation processing.
const TEMPLATE_THREE_COLUMN
static getSizes()
Get sizes.
static getWidths()
Get widths.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
displayValidationError()
display validation errors
setHierId($a_hier_id)
get hierarchical id in dom object
This class represents an option in a radio group.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc