ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilPCLoginPageElementGUI.php
Go to the documentation of this file.
1 <?php
2 
26 {
28 
29  public function __construct(
30  ilPageObject $a_pg_obj,
31  ?ilPageContent $a_content_obj,
32  string $a_hier_id,
33  string $a_pc_id = ""
34  ) {
35  global $DIC;
36 
37  $this->ctrl = $DIC->ctrl();
38  $this->tpl = $DIC["tpl"];
39  $this->lng = $DIC->language();
40  $this->obj_definition = $DIC["objDefinition"];
41  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
42 
43  if (!is_object($this->content_obj)) {
44  $this->content_obj = new ilPCLoginPageElement($this->getPage());
45  }
46  }
47 
48  public function executeCommand(): void
49  {
50  // get next class that processes or forwards current command
51  $next_class = $this->ctrl->getNextClass($this);
52 
53  // get current command
54  $cmd = $this->ctrl->getCmd();
55 
56  switch ($next_class) {
57  default:
58  $this->$cmd();
59  break;
60  }
61  }
62 
63  public function insert(): void
64  {
65  $this->edit(true);
66  }
67 
68  public function edit(bool $a_insert = false): void
69  {
70  $ilCtrl = $this->ctrl;
71  $tpl = $this->tpl;
72  $lng = $this->lng;
73 
74  $this->displayValidationError();
75 
76  // edit form
77  $form = new ilPropertyFormGUI();
78  $form->setFormAction($ilCtrl->getFormAction($this));
79  if ($a_insert) {
80  $form->setTitle($this->lng->txt("cont_insert_login_page"));
81  } else {
82  $form->setTitle($this->lng->txt("cont_update_login_page"));
83  }
84 
85  // type selection
86  $type_prop = new ilRadioGroupInputGUI($this->lng->txt("cont_type"), "type");
87 
88  foreach (ilPCLoginPageElement::getAllTypes() as $index => $lang_key) {
89  $types[$index] = $this->lng->txt('cont_lpe_' . $lang_key);
90 
91  $option = new ilRadioOption($this->lng->txt('cont_lpe_' . $lang_key), $index);
92  $type_prop->addOption($option);
93  }
94 
95  $selected = $a_insert
96  ? ""
97  : $this->content_obj->getLoginPageElementType();
98  $type_prop->setValue($selected);
99  $form->addItem($type_prop);
100 
101  // horizonal align
102  $align_prop = new ilSelectInputGUI($this->lng->txt("cont_align"), "horizontal_align");
103  $options = array(
104  "Left" => $lng->txt("cont_left"),
105  "Center" => $lng->txt("cont_center"),
106  "Right" => $lng->txt("cont_right"));
107  # "LeftFloat" => $lng->txt("cont_left_float"),
108  # "RightFloat" => $lng->txt("cont_right_float"));
109  $align_prop->setOptions($options);
110  $align_prop->setValue($this->content_obj->getAlignment());
111  $form->addItem($align_prop);
112 
113 
114  // save/cancel buttons
115  if ($a_insert) {
116  $form->addCommandButton("create", $lng->txt("save"));
117  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
118  } else {
119  $form->addCommandButton("update_login_page_element", $lng->txt("save"));
120  $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
121  }
122  $html = $form->getHTML();
123  $tpl->setContent($html);
124  }
125 
126 
130  public function create(): void
131  {
132  $this->content_obj = new ilPCLoginPageElement($this->getPage());
133  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
134  $this->content_obj->setLoginPageElementType(
135  $this->request->getString("type")
136  );
137  $this->content_obj->setAlignment(
138  $this->request->getString("horizontal_align")
139  );
140 
141  $this->updated = $this->pg_obj->update();
142  if ($this->updated === true) {
143  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
144  } else {
145  $this->insert();
146  }
147  }
148 
152  public function update(): void
153  {
154  $this->content_obj->setLoginPageElementType(
155  $this->request->getString("type")
156  );
157  $this->content_obj->setAlignment(
158  $this->request->getString("horizontal_align")
159  );
160  $this->updated = $this->pg_obj->update();
161  if ($this->updated === true) {
162  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
163  } else {
164  $this->pg_obj->addHierIDs();
165  $this->edit();
166  }
167  }
168 }
This class represents an option in a radio group.
This class represents a selection list property in a property form.
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...
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
setContent(string $a_html)
Sets content for standard template.
static getAllTypes()
Get all types.
setOptions(array $a_options)
Content object of ilPageObject (see ILIAS DTD).
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
This class represents a property in a property form.
setValue(string $a_value)
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
global $DIC
Definition: shib_login.php:22
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
update()
Update Login page element.
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
create()
Create new Login Page Element.