ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
class.ilStudyProgrammeTypeFormGUI.php
Go to the documentation of this file.
1 <?php
2 require_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
3 
11 
15  protected $type;
16 
20  protected $tpl;
21 
25  protected $lng;
26 
30  protected $ctrl;
31 
35  protected $parent_gui;
36 
37 
39  global $tpl, $ilCtrl, $lng;
40  $this->parent_gui = $parent_gui;
41  $this->type = $type;
42  $this->tpl = $tpl;
43  $this->ctrl = $ilCtrl;
44  $this->lng = $lng;
45  $this->lng->loadLanguageModule('meta');
46  $this->lng->loadLanguageModule('prg');
47 
48  $this->initForm();
49  }
50 
51 
57  public function saveObject() {
58  if (!$this->fillObject()) {
59  return false;
60  }
61  try {
62  $this->type->save();
63  return true;
64  } catch (ilException $e) {
65  ilUtil::sendFailure($e->getMessage());
66  return false;
67  }
68  }
69 
73  protected function initForm() {
74  $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
75  $title = $this->type->getId() ? $this->lng->txt('prg_type_edit') : $this->lng->txt('prg_type_add');
76  $this->setTitle($title);
77  $item = new ilSelectInputGUI($this->lng->txt('default_language'), 'default_lang');
78  $item->setValue($this->type->getDefaultLang());
79  $languages = $this->lng->getInstalledLanguages();
80  $options = array();
81  foreach ($languages as $lang_code) {
82  $options[$lang_code] = $this->lng->txt("meta_l_{$lang_code}");
83  }
84  $item->setOptions($options);
85  $item->setRequired(true);
86  $this->addItem($item);
87 
88  foreach ($languages as $lang_code) {
89  $this->addTranslationInputs($lang_code);
90  }
91 
92  if ($this->type->getId()) {
93  $this->addCommandButton('update', $this->lng->txt('save'));
94  } else {
95  $this->addCommandButton('create', $this->lng->txt('create'));
96  }
97  $this->addCommandButton('cancel', $this->lng->txt('cancel'));
98  }
99 
105  protected function fillObject() {
106  $this->setValuesByPost();
107  if (!$this->checkInput()) {
108  return false;
109  }
110 
111  $success = true;
112  try {
113  $this->type->setDefaultLang($this->getInput('default_lang'));
114  foreach ($this->lng->getInstalledLanguages() as $lang_code) {
115  $title = $this->getInput("title_{$lang_code}");
116  $description = $this->getInput("description_{$lang_code}");
117  $this->type->setTitle($title, $lang_code);
118  $this->type->setDescription($description, $lang_code);
119  }
121  ilUtil::sendFailure($e->getMessage());
122  $success = false;
123  }
124  return $success;
125  }
126 
132  protected function addTranslationInputs($a_lang_code) {
134  $section->setTitle($this->lng->txt("meta_l_{$a_lang_code}"));
135  $this->addItem($section);
136  $item = new ilTextInputGUI($this->lng->txt('title'), "title_{$a_lang_code}");
137  $item->setValue($this->type->getTitle($a_lang_code));
138  $this->addItem($item);
139  $item = new ilTextAreaInputGUI($this->lng->txt('description'), "description_{$a_lang_code}");
140  $item->setValue($this->type->getDescription($a_lang_code));
141  $this->addItem($item);
142  }
143 
144 
145 }
Base class for ILIAS Exception handling.
addTranslationInputs($a_lang_code)
Add a text and textarea input per language.
This class represents a selection list property in a property form.
saveObject()
Save object (create or update)
This class represents a property form user interface.
This class represents a section header in a property form.
setValue($a_value)
Set Value.
setFormAction($a_formaction)
Set FormAction.
Class ilStudyProgrammeTypeFormGUI.
addItem($a_item)
Add Item (Property, SectionHeader).
global $ilCtrl
Definition: ilias.php:18
$section
Definition: Utf8Test.php:84
fillObject()
Check validity of form and pass values from form to object.
setTitle($a_title)
Set Title.
$success
Definition: Utf8Test.php:87
if(!is_array($argv)) $options
setValue($a_value)
Set Value.
This class represents a text property in a property form.
checkInput()
Check Post Input.
Exception is thrown when errors occurs relating the plugin type-hook.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
addCommandButton($a_cmd, $a_text)
Add Command button.
setValuesByPost()
Set form values from POST values.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilStudyProgrammeType.
This class represents a text area property in a property form.
setValue($a_value)
Set Value.
__construct($parent_gui, ilStudyProgrammeType $type)