ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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  {
35  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
36  $this->settingsTemplate = new ilSettingsTemplate($templateId, ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
37  }
38  }
39 
40  protected function getTemplateSettingValue($settingName)
41  {
42  if( !$this->settingsTemplate )
43  {
44  return null;
45  }
46 
47  $templateSettings = $this->settingsTemplate->getSettings();
48 
49  if( !isset($templateSettings[$settingName]) )
50  {
51  return false;
52  }
53 
54  return $templateSettings[$settingName]['value'];
55  }
56 
57  protected function isHiddenFormItem($formFieldId)
58  {
59  if( !$this->settingsTemplate )
60  {
61  return false;
62  }
63 
64  $settings = $this->settingsTemplate->getSettings();
65 
66  if( !isset($settings[$formFieldId]) )
67  {
68  return false;
69  }
70 
71  if( !$settings[$formFieldId]['hide'] )
72  {
73  return false;
74  }
75 
76  return true;
77  }
78 
79  protected function isSectionHeaderRequired($fields)
80  {
81  foreach($fields as $field)
82  {
83  if( !$this->isHiddenFormItem($field) )
84  {
85  return true;
86  }
87  }
88 
89  return false;
90  }
91 
92  protected function formPropertyExists(ilPropertyFormGUI $form, $propertyId)
93  {
94  return $form->getItemByPostVar($propertyId) instanceof ilFormPropertyGUI;
95  }
96 
97  protected function removeHiddenItems(ilPropertyFormGUI $form)
98  {
99  if( $this->settingsTemplate )
100  {
101  foreach ($this->settingsTemplate->getSettings() as $id => $item)
102  {
103  if ($item["hide"])
104  {
105  $form->removeItemByPostVar($id);
106  }
107  }
108  }
109  }
110 }
removeItemByPostVar($a_post_var)
Remove Item.
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a property form user interface.
__construct(ilObjTest $testOBJ)
removeHiddenItems(ilPropertyFormGUI $form)
getTemplateSettingValue($settingName)
This class represents a property in a property form.
formPropertyExists(ilPropertyFormGUI $form, $propertyId)
Settings template application class.