ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilFMSettingsGUI.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/WebServices/FileManager/classes/class.ilFMSettings.php';
5 
15 {
16 
17  private $parent_obj = null;
18 
22  public function __construct($a_parent_gui)
23  {
24  $this->parent_obj = $a_parent_gui;
25  }
26 
31  public function executeCommand()
32  {
33  global $ilCtrl;
34 
35  $next_class = $ilCtrl->getNextClass();
36  $cmd = $ilCtrl->getCmd();
37  switch($next_class)
38  {
39  default:
40  if(!$cmd)
41  {
42  $cmd = 'settings';
43  }
44  $this->$cmd();
45  break;
46 
47  }
48  }
49 
54  public function getParentObject()
55  {
56  return $this->parent_obj;
57  }
58 
62  protected function settings()
63  {
64  $form = $this->initSettingsForm();
65 
66  $GLOBALS['tpl']->setContent($form->getHTML());
67  }
68 
72  protected function update()
73  {
74  include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
75  $settings = ilFMSettings::getInstance();
76 
77  $form = $this->initSettingsForm();
78  if($form->checkInput())
79  {
80  $settings->enable($form->getInput('active'));
81  $settings->enableLocalFS($form->getInput('local'));
82  $settings->setMaxFileSize($form->getInput('filesize'));
83  $settings->update();
84 
85  ilUtil::sendSuccess($GLOBALS['lng']->txt('settings_saved'), true);
86  $GLOBALS['ilCtrl']->redirect($this,'settings');
87  }
88  }
89 
93  protected function initSettingsForm()
94  {
95  global $ilCtrl;
96 
97  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
98  $form = new ilPropertyFormGUI();
99  $form->setFormAction($ilCtrl->getFormAction($this));
100  $form->setTitle($GLOBALS['lng']->txt('settings'));
101  $form->addCommandButton('update', $GLOBALS['lng']->txt('save'));
102  $form->addCommandButton('settings', $GLOBALS['lng']->txt('cancel'));
103 
104  // activation
105  $active = new ilCheckboxInputGUI($GLOBALS['lng']->txt('fm_settings_active'), 'active');
106  $active->setInfo($GLOBALS['lng']->txt('fm_settings_active_info'));
107  $active->setValue(1);
108  $active->setChecked(ilFMSettings::getInstance()->isEnabled());
109  $form->addItem($active);
110 
111  // one frame
112  $local = new ilCheckboxInputGUI($GLOBALS['lng']->txt('fm_settings_local'), 'local');
113  $local->setInfo($GLOBALS['lng']->txt('fm_settings_local_info'));
114  $local->setValue(1);
115  $local->setChecked(ilFMSettings::getInstance()->IsLocalFSEnabled());
116  $form->addItem($local);
117 
118  $fs = new ilNumberInputGUI($GLOBALS['lng']->txt('fm_settings_filesize'),'filesize');
119  $fs->setSuffix('MiB');
120  $fs->setSize(3);
121  $fs->setMaxLength(3);
122  $fs->setMinValue(1);
123  $fs->setMaxValue(999);
124  $fs->setInfo($GLOBALS['lng']->txt('fm_settings_filesize_info'));
125  $fs->setValue(ilFMSettings::getInstance()->getMaxFileSize());
126  $form->addItem($fs);
127 
128  return $form;
129  }
130 }
131 ?>