ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.ilPCLoginPageElements.php';
6 
19 {
24  public function ilPCLoginPageElementGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
25  {
26  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
27 
28  if(!is_object($this->content_obj))
29  {
30  $this->content_obj = new ilPCLoginPageElements(null);
31  }
32  }
33 
38  public function getLoginPageElements()
39  {
40  return $this->lp_elements;
41  }
42 
46  public function executeCommand()
47  {
48  // get next class that processes or forwards current command
49  $next_class = $this->ctrl->getNextClass($this);
50 
51  // get current command
52  $cmd = $this->ctrl->getCmd();
53 
54  switch($next_class)
55  {
56  default:
57  $ret =& $this->$cmd();
58  break;
59  }
60 
61  return $ret;
62  }
63 
67  public function insert()
68  {
69  $this->edit(true);
70  }
71 
75  public function edit($a_insert = false)
76  {
77  global $ilCtrl, $tpl, $lng, $objDefinition;
78 
79  $this->displayValidationError();
80 
81  // edit form
82  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
83  $form = new ilPropertyFormGUI();
84  $form->setFormAction($ilCtrl->getFormAction($this));
85  if ($a_insert)
86  {
87  $form->setTitle($this->lng->txt("cont_insert_login_page"));
88  }
89  else
90  {
91  $form->setTitle($this->lng->txt("cont_update_login_page"));
92  }
93 
94  // type selection
95  $type_prop = new ilRadioGroupInputGUI($this->lng->txt("cont_type"),"type");
96 
97  foreach(ilPCLoginPageElements::getAllTypes() as $index => $lang_key)
98  {
99  $types[$index] = $this->lng->txt('cont_lpe_'.$lang_key);
100 
101  $option = new ilRadioOption($this->lng->txt('cont_lpe_'.$lang_key), $index);
102  $type_prop->addOption($option);
103 
104  }
105 
106  $selected = $a_insert
107  ? ""
108  : $this->content_obj->getLoginPageElementType();
109  $type_prop->setValue($selected);
110  $form->addItem($type_prop);
111 
112  // horizonal align
113  $align_prop = new ilSelectInputGUI($this->lng->txt("cont_align"),"horizontal_align");
114  $options = array(
115  "Left" => $lng->txt("cont_left"),
116  "Center" => $lng->txt("cont_center"),
117  "Right" => $lng->txt("cont_right"));
118 # "LeftFloat" => $lng->txt("cont_left_float"),
119 # "RightFloat" => $lng->txt("cont_right_float"));
120  $align_prop->setOptions($options);
121  $align_prop->setValue($this->content_obj->getAlignment());
122  $form->addItem($align_prop);
123 
124 
125  // save/cancel buttons
126  if ($a_insert)
127  {
128  $form->addCommandButton("create_login_page_element", $lng->txt("save"));
129  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
130  }
131  else
132  {
133  $form->addCommandButton("update_login_page_element", $lng->txt("save"));
134  $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
135  }
136  $html = $form->getHTML();
137  $tpl->setContent($html);
138  return $ret;
139  }
140 
141 
145  public function create()
146  {
147  $this->content_obj = new ilPCLoginPageElements($this->dom);
148  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
149  $this->content_obj->setLoginPageElementType($_POST["type"]);
150  $this->content_obj->setAlignment($_POST['horizontal_align']);
151 
152  $this->updated = $this->pg_obj->update();
153  if ($this->updated === true)
154  {
155  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
156  }
157  else
158  {
159  $this->insert();
160  }
161  }
162 
166  public function update()
167  {
168  $this->content_obj->setLoginPageElementType($_POST["type"]);
169  $this->content_obj->setAlignment($_POST['horizontal_align']);
170  $this->updated = $this->pg_obj->update();
171  if ($this->updated === true)
172  {
173  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
174  }
175  else
176  {
177  $this->pg_obj->addHierIDs();
178  $this->edit();
179  }
180  }
181 }
182 ?>