ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 abstract class ilTestSettingsGUI
14 {
18  protected $testOBJ = null;
19 
25  protected $settingsTemplate = null;
26 
27  public function __construct(ilObjTest $testOBJ)
28  {
29  $this->testOBJ = $testOBJ;
30 
31  $templateId = $this->testOBJ->getTemplate();
32 
33  if ($templateId) {
34  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
35  $this->settingsTemplate = new ilSettingsTemplate($templateId, ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
36  }
37  }
38 
39  protected function getTemplateSettingValue($settingName)
40  {
41  if (!$this->settingsTemplate) {
42  return null;
43  }
44 
45  $templateSettings = $this->settingsTemplate->getSettings();
46 
47  if (!isset($templateSettings[$settingName])) {
48  return false;
49  }
50 
51  return $templateSettings[$settingName]['value'];
52  }
53 
54  protected function isHiddenFormItem($formFieldId)
55  {
56  if (!$this->settingsTemplate) {
57  return false;
58  }
59 
60  $settings = $this->settingsTemplate->getSettings();
61 
62  if (!isset($settings[$formFieldId])) {
63  return false;
64  }
65 
66  if (!$settings[$formFieldId]['hide']) {
67  return false;
68  }
69 
70  return true;
71  }
72 
73  protected function isSectionHeaderRequired($fields)
74  {
75  foreach ($fields as $field) {
76  if (!$this->isHiddenFormItem($field)) {
77  return true;
78  }
79  }
80 
81  return false;
82  }
83 
84  protected function formPropertyExists(ilPropertyFormGUI $form, $propertyId)
85  {
86  return $form->getItemByPostVar($propertyId) instanceof ilFormPropertyGUI;
87  }
88 
90  {
91  if ($this->settingsTemplate) {
92  foreach ($this->settingsTemplate->getSettings() as $id => $item) {
93  if ($item["hide"]) {
94  $form->removeItemByPostVar($id);
95  }
96  }
97  }
98  }
99 }
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a property form user interface.
if(!array_key_exists('StateId', $_REQUEST)) $id
__construct(ilObjTest $testOBJ)
removeHiddenItems(ilPropertyFormGUI $form)
if(isset($_POST['submit'])) $form
getTemplateSettingValue($settingName)
This class represents a property in a property form.
removeItemByPostVar($a_post_var, $a_remove_unused_headers=false)
Remove Item.
formPropertyExists(ilPropertyFormGUI $form, $propertyId)
Settings template application class.