ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPCLoginPageElementGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/COPage/classes/class.ilPageContentGUI.php';
5 include_once './Services/COPage/classes/class.ilPCLoginPageElement.php';
6 
19 {
23  protected $obj_definition;
24 
29  public function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id = "")
30  {
31  global $DIC;
32 
33  $this->ctrl = $DIC->ctrl();
34  $this->tpl = $DIC["tpl"];
35  $this->lng = $DIC->language();
36  $this->obj_definition = $DIC["objDefinition"];
37  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
38 
39  if (!is_object($this->content_obj)) {
40  $this->content_obj = new ilPCLoginPageElement($this->getPage());
41  }
42  }
43 
48  public function getLoginPageElements()
49  {
50  return $this->lp_elements;
51  }
52 
56  public function executeCommand()
57  {
58  // get next class that processes or forwards current command
59  $next_class = $this->ctrl->getNextClass($this);
60 
61  // get current command
62  $cmd = $this->ctrl->getCmd();
63 
64  switch ($next_class) {
65  default:
66  $ret = $this->$cmd();
67  break;
68  }
69 
70  return $ret;
71  }
72 
76  public function insert()
77  {
78  $this->edit(true);
79  }
80 
84  public function edit($a_insert = false)
85  {
87  $tpl = $this->tpl;
88  $lng = $this->lng;
89  $objDefinition = $this->obj_definition;
90 
91  $this->displayValidationError();
92 
93  // edit form
94  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
95  $form = new ilPropertyFormGUI();
96  $form->setFormAction($ilCtrl->getFormAction($this));
97  if ($a_insert) {
98  $form->setTitle($this->lng->txt("cont_insert_login_page"));
99  } else {
100  $form->setTitle($this->lng->txt("cont_update_login_page"));
101  }
102 
103  // type selection
104  $type_prop = new ilRadioGroupInputGUI($this->lng->txt("cont_type"), "type");
105 
106  foreach (ilPCLoginPageElement::getAllTypes() as $index => $lang_key) {
107  $types[$index] = $this->lng->txt('cont_lpe_' . $lang_key);
108 
109  $option = new ilRadioOption($this->lng->txt('cont_lpe_' . $lang_key), $index);
110  $type_prop->addOption($option);
111  }
112 
113  $selected = $a_insert
114  ? ""
115  : $this->content_obj->getLoginPageElementType();
116  $type_prop->setValue($selected);
117  $form->addItem($type_prop);
118 
119  // horizonal align
120  $align_prop = new ilSelectInputGUI($this->lng->txt("cont_align"), "horizontal_align");
121  $options = array(
122  "Left" => $lng->txt("cont_left"),
123  "Center" => $lng->txt("cont_center"),
124  "Right" => $lng->txt("cont_right"));
125  # "LeftFloat" => $lng->txt("cont_left_float"),
126  # "RightFloat" => $lng->txt("cont_right_float"));
127  $align_prop->setOptions($options);
128  $align_prop->setValue($this->content_obj->getAlignment());
129  $form->addItem($align_prop);
130 
131 
132  // save/cancel buttons
133  if ($a_insert) {
134  $form->addCommandButton("create_login_page_element", $lng->txt("save"));
135  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
136  } else {
137  $form->addCommandButton("update_login_page_element", $lng->txt("save"));
138  $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
139  }
140  $html = $form->getHTML();
141  $tpl->setContent($html);
142  return $ret;
143  }
144 
145 
149  public function create()
150  {
151  $this->content_obj = new ilPCLoginPageElement($this->getPage());
152  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
153  $this->content_obj->setLoginPageElementType($_POST["type"]);
154  $this->content_obj->setAlignment($_POST['horizontal_align']);
155 
156  $this->updated = $this->pg_obj->update();
157  if ($this->updated === true) {
158  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
159  } else {
160  $this->insert();
161  }
162  }
163 
167  public function update()
168  {
169  $this->content_obj->setLoginPageElementType($_POST["type"]);
170  $this->content_obj->setAlignment($_POST['horizontal_align']);
171  $this->updated = $this->pg_obj->update();
172  if ($this->updated === true) {
173  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
174  } else {
175  $this->pg_obj->addHierIDs();
176  $this->edit();
177  }
178  }
179 }
This class represents an option in a radio group.
getLoginPageElements()
Get login page elements.
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
static getAllTypes()
Get all types.
$index
Definition: metadata.php:60
edit($a_insert=false)
Edit resources form.
global $ilCtrl
Definition: ilias.php:18
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
This class represents a property in a property form.
setValue($a_value)
Set Value.
if(isset($_POST['submit'])) $form
__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor public.
displayValidationError()
display validation errors
Class ilLoginPageElementGUI.
Create styles array
The data for the language used.
update()
Update Login page element.
Class ilPCLoginPageElement.
$ret
Definition: parser.php:6
create()
Create new Login Page Element.
insert()
Insert new resources component form.
$_POST["username"]
$html
Definition: example_001.php:87
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20