ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  parent::__construct();
51 
52  $this->ctrl = $ilCtrl;
53 
54 
55  include_once("Services/Block/classes/class.ilExternalFeedBlock.php");
56  if (isset($_GET["external_feed_block_id"]) && $_GET["external_feed_block_id"] > 0)
57  {
58  $this->external_feed_block = new ilExternalFeedBlock($_GET["external_feed_block_id"]);
59  }
60 
61  $this->ctrl->saveParameter($this, array("external_feed_block_id"));
62 
63 
64  }
65 
70  public function executeCommand()
71  {
72  global $ilCtrl;
73 
74  // get next class and command
75  $next_class = $this->ctrl->getNextClass($this);
76  $cmd = $this->ctrl->getCmd();
77 
78  switch ($next_class)
79  {
80  default:
81  $html = $this->$cmd();
82  break;
83  }
84 
85  return $html;
86 
87  }
88 
94  public function setGuiObject(&$a_gui_object)
95  {
96  $this->gui_object = $a_gui_object;
97  }
98 
104  public function getGuiObject()
105  {
106  return $this->gui_object;
107  }
108 
114  public function setFormEditMode($a_form_edit_mode)
115  {
116  $this->form_edit_mode = $a_form_edit_mode;
117  }
118 
124  public function getFormEditMode()
125  {
126  return $this->form_edit_mode;
127  }
128 
133  public function createFeedBlock()
134  {
136  return $this->form_gui->getHtml();
137 
138  }
139 
144  public function editFeedBlock()
145  {
147  $this->getValuesFeedBlock();
148  return $this->form_gui->getHtml();
149 
150  }
151 
156  public function saveFeedBlock()
157  {
159  if ($this->form_gui->checkInput())
160  {
161  $this->external_feed_block = new ilExternalFeedBlock();
162  $this->external_feed_block->setTitle($this->form_gui->getInput("block_title"));
163  $this->external_feed_block->setFeedUrl($this->form_gui->getInput("block_feed_url"));
164  $this->prepareSaveFeedBlock($this->external_feed_block);
165  $this->external_feed_block->create();
166  $this->exitSaveFeedBlock();
167  }
168  else
169  {
170  $this->form_gui->setValuesByPost();
171  return $this->form_gui->getHtml();
172  }
173 
174  }
175 
180  public function updateFeedBlock()
181  {
183  if ($this->form_gui->checkInput())
184  {
185 
186  $this->external_feed_block->setTitle($this->form_gui->getInput("block_title"));
187  $this->external_feed_block->setFeedUrl($this->form_gui->getInput("block_feed_url"));
188  $this->external_feed_block->update();
189  $this->exitUpdateFeedBlock();
190  }
191  else
192  {
193  $this->form_gui->setValuesByPost();
194  return $this->form_gui->getHtml();
195  }
196 
197  }
198 
204  public function initFormFeedBlock($a_mode)
205  {
206  global $lng;
207 
208  $lng->loadLanguageModule("block");
209 
210  require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
211 
212  $this->form_gui = new ilPropertyFormGUI();
213 
214 
215  // Property Title
216  $text_input = new ilTextInputGUI($lng->txt("block_feed_block_title"), "block_title");
217  $text_input->setInfo("");
218  $text_input->setRequired(true);
219  $text_input->setMaxLength(200);
220  $this->form_gui->addItem($text_input);
221 
222  // Property FeedUrl
223  $text_input = new ilTextInputGUI($lng->txt("block_feed_block_feed_url"), "block_feed_url");
224  $text_input->setInfo($lng->txt("block_feed_block_feed_url_info"));
225  $text_input->setRequired(true);
226  $text_input->setMaxLength(250);
227  $this->form_gui->addItem($text_input);
228 
229 
230  // save and cancel commands
231  if (in_array($a_mode, array(IL_FORM_CREATE,IL_FORM_RE_CREATE)))
232  {
233  $this->form_gui->addCommandButton("saveFeedBlock", $lng->txt("save"));
234  $this->form_gui->addCommandButton("cancelSaveFeedBlock", $lng->txt("cancel"));
235  }
236  else
237  {
238  $this->form_gui->addCommandButton("updateFeedBlock", $lng->txt("save"));
239  $this->form_gui->addCommandButton("cancelUpdateFeedBlock", $lng->txt("cancel"));
240  }
241 
242  $this->form_gui->setTitle($lng->txt("block_feed_block_head"));
243  $this->form_gui->setFormAction($this->ctrl->getFormAction($this));
244 
245  $this->prepareFormFeedBlock($this->form_gui);
246 
247  }
248 
253  public function getValuesFeedBlock()
254  {
255  $values = array();
256 
257  $values["block_title"] = $this->external_feed_block->getTitle();
258  $values["block_feed_url"] = $this->external_feed_block->getFeedUrl();
259 
260  $this->form_gui->setValuesByArray($values);
261 
262  }
263 
268  public function cancelSaveFeedBlock()
269  {
270  global $ilCtrl;
271 
272  $ilCtrl->returnToParent($this);
273  }
274 
279  public function cancelUpdateFeedBlock()
280  {
281  global $ilCtrl;
282 
283  $ilCtrl->returnToParent($this);
284  }
285 
290  public function exitSaveFeedBlock()
291  {
292  global $ilCtrl;
293 
294  $ilCtrl->returnToParent($this);
295  }
296 
301  public function exitUpdateFeedBlock()
302  {
303  global $ilCtrl;
304 
305  $ilCtrl->returnToParent($this);
306  }
307 
313  public function prepareSaveFeedBlock(&$a_external_feed_block)
314  {
315 
316  }
317 
323  public function prepareFormFeedBlock(&$a_form_gui)
324  {
325 
326  }
327 
328 
329 }
330 ?>
createFeedBlock()
FORM FeedBlock: Create ExternalFeedBlock.
prepareFormFeedBlock(&$a_form_gui)
FORM FeedBlock: Prepare form.
This class represents a property form user interface.
$_GET["client_id"]
updateFeedBlock()
FORM FeedBlock: Update ExternalFeedBlock.
prepareSaveFeedBlock(&$a_external_feed_block)
FORM FeedBlock: Prepare Saving of ExternalFeedBlock.
$cmd
Definition: sahs_server.php:35
setGuiObject(&$a_gui_object)
Set GuiObject.
Custom block for external feeds.
GUI class for external news feed custom block.
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
This class represents a text property in a property form.
exitUpdateFeedBlock()
FORM FeedBlock: Exit update.
exitSaveFeedBlock()
FORM FeedBlock: Exit save.
Create styles array
The data for the language used.
saveFeedBlock()
FORM FeedBlock: Save ExternalFeedBlock.
global $lng
Definition: privfeed.php:17
setFormEditMode($a_form_edit_mode)
Set FormEditMode.
This class represents a block method of a block.
cancelUpdateFeedBlock()
FORM FeedBlock: Cancel update.
editFeedBlock()
FORM FeedBlock: Edit form.
getValuesFeedBlock()
FORM FeedBlock: Get current values for ExternalFeedBlock form.
$html
Definition: example_001.php:87
cancelSaveFeedBlock()
FORM FeedBlock: Cancel save.
initFormFeedBlock($a_mode)
FORM FeedBlock: Init form.