ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilExternalFeedBlockGUIGen.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("Services/Block/classes/class.ilBlockGUI.php");
25 define("IL_FORM_EDIT", 0);
26 define("IL_FORM_CREATE", 1);
27 define("IL_FORM_RE_EDIT", 2);
28 define("IL_FORM_RE_CREATE", 3);
29 
36 abstract class ilExternalFeedBlockGUIGen extends ilBlockGUI
37 {
38 
39  protected $gui_object;
40  protected $form_edit_mode;
41 
46  public function __construct()
47  {
48  global $ilCtrl;
49 
50  $this->ctrl = $ilCtrl;
51 
52 
53  include_once("Services/Block/classes/class.ilExternalFeedBlock.php");
54  if (isset($_GET["external_feed_block_id"]) && $_GET["external_feed_block_id"] > 0)
55  {
56  $this->external_feed_block = new ilExternalFeedBlock($_GET["external_feed_block_id"]);
57  }
58 
59  $this->ctrl->saveParameter($this, array("external_feed_block_id"));
60 
61 
62  }
63 
68  public function &executeCommand()
69  {
70  global $ilCtrl;
71 
72  // get next class and command
73  $next_class = $this->ctrl->getNextClass($this);
74  $cmd = $this->ctrl->getCmd();
75 
76  switch ($next_class)
77  {
78  default:
79  $html = $this->$cmd();
80  break;
81  }
82 
83  return $html;
84 
85  }
86 
92  public function setGuiObject(&$a_gui_object)
93  {
94  $this->gui_object = $a_gui_object;
95  }
96 
102  public function getGuiObject()
103  {
104  return $this->gui_object;
105  }
106 
112  public function setFormEditMode($a_form_edit_mode)
113  {
114  $this->form_edit_mode = $a_form_edit_mode;
115  }
116 
122  public function getFormEditMode()
123  {
124  return $this->form_edit_mode;
125  }
126 
131  public function createFeedBlock()
132  {
134  return $this->form_gui->getHtml();
135 
136  }
137 
142  public function editFeedBlock()
143  {
145  $this->getValuesFeedBlock();
146  return $this->form_gui->getHtml();
147 
148  }
149 
154  public function saveFeedBlock()
155  {
157  if ($this->form_gui->checkInput())
158  {
159  $this->external_feed_block = new ilExternalFeedBlock();
160  $this->external_feed_block->setTitle($this->form_gui->getInput("block_title"));
161  $this->external_feed_block->setFeedUrl($this->form_gui->getInput("block_feed_url"));
162  $this->prepareSaveFeedBlock($this->external_feed_block);
163  $this->external_feed_block->create();
164  $this->exitSaveFeedBlock();
165  }
166  else
167  {
168  $this->form_gui->setValuesByPost();
169  return $this->form_gui->getHtml();
170  }
171 
172  }
173 
178  public function updateFeedBlock()
179  {
181  if ($this->form_gui->checkInput())
182  {
183 
184  $this->external_feed_block->setTitle($this->form_gui->getInput("block_title"));
185  $this->external_feed_block->setFeedUrl($this->form_gui->getInput("block_feed_url"));
186  $this->external_feed_block->update();
187  $this->exitUpdateFeedBlock();
188  }
189  else
190  {
191  $this->form_gui->setValuesByPost();
192  return $this->form_gui->getHtml();
193  }
194 
195  }
196 
202  public function initFormFeedBlock($a_mode)
203  {
204  global $lng;
205 
206  $lng->loadLanguageModule("block");
207 
208  include("Services/Form/classes/class.ilPropertyFormGUI.php");
209 
210  $this->form_gui = new ilPropertyFormGUI();
211 
212 
213  // Property Title
214  $text_input = new ilTextInputGUI($lng->txt("block_feed_block_title"), "block_title");
215  $text_input->setInfo("");
216  $text_input->setRequired(true);
217  $text_input->setMaxLength(200);
218  $this->form_gui->addItem($text_input);
219 
220  // Property FeedUrl
221  $text_input = new ilTextInputGUI($lng->txt("block_feed_block_feed_url"), "block_feed_url");
222  $text_input->setInfo($lng->txt("block_feed_block_feed_url_info"));
223  $text_input->setRequired(true);
224  $text_input->setMaxLength(250);
225  $this->form_gui->addItem($text_input);
226 
227 
228  // save and cancel commands
229  if (in_array($a_mode, array(IL_FORM_CREATE,IL_FORM_RE_CREATE)))
230  {
231  $this->form_gui->addCommandButton("saveFeedBlock", $lng->txt("save"));
232  $this->form_gui->addCommandButton("cancelSaveFeedBlock", $lng->txt("cancel"));
233  }
234  else
235  {
236  $this->form_gui->addCommandButton("updateFeedBlock", $lng->txt("save"));
237  $this->form_gui->addCommandButton("cancelUpdateFeedBlock", $lng->txt("cancel"));
238  }
239 
240  $this->form_gui->setTitle($lng->txt("block_feed_block_head"));
241  $this->form_gui->setFormAction($this->ctrl->getFormAction($this));
242 
243  $this->prepareFormFeedBlock($this->form_gui);
244 
245  }
246 
251  public function getValuesFeedBlock()
252  {
253  $values = array();
254 
255  $values["block_title"] = $this->external_feed_block->getTitle();
256  $values["block_feed_url"] = $this->external_feed_block->getFeedUrl();
257 
258  $this->form_gui->setValuesByArray($values);
259 
260  }
261 
266  public function cancelSaveFeedBlock()
267  {
268  global $ilCtrl;
269 
270  $ilCtrl->returnToParent($this);
271  }
272 
277  public function cancelUpdateFeedBlock()
278  {
279  global $ilCtrl;
280 
281  $ilCtrl->returnToParent($this);
282  }
283 
288  public function exitSaveFeedBlock()
289  {
290  global $ilCtrl;
291 
292  $ilCtrl->returnToParent($this);
293  }
294 
299  public function exitUpdateFeedBlock()
300  {
301  global $ilCtrl;
302 
303  $ilCtrl->returnToParent($this);
304  }
305 
311  public function prepareSaveFeedBlock(&$a_external_feed_block)
312  {
313 
314  }
315 
321  public function prepareFormFeedBlock(&$a_form_gui)
322  {
323 
324  }
325 
326 
327 }
328 ?>