ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilOrgUnitAuthorityInputGUI.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
14  protected $value;
15 
16 
23  public function __construct($a_title, $a_postvar)
24  {
25  parent::__construct($a_title, $a_postvar);
30  $a = ilOrgUnitAuthority::find($id);
31  $data = array( 'id' => $id, 'over' => $a->getOver(), 'scope' => $a->getScope() );
32 
33  return json_encode($data);
34  });
35  }
36 
37 
41  public function insert(ilTemplate $a_tpl)
42  {
43  $html = $this->render();
44 
45  $a_tpl->setCurrentBlock("prop_generic");
46  $a_tpl->setVariable("PROP_GENERIC", $html);
47  $a_tpl->parseCurrentBlock();
48  }
49 
50 
54  public function setValueByArray(array $values)
55  {
56  $authorities = $values[$this->getPostVar()];
57  if (!is_array($authorities)) {
58  $authorities = [];
59  }
60  foreach ($authorities as $authority) {
61  assert($authority instanceof ilOrgUnitAuthority);
62  }
63  $this->setValue($authorities);
64  }
65 
66 
70  public function setValue($a_value)
71  {
72  $this->value = $a_value;
73  }
74 
75 
79  public function getValue()
80  {
81  return $this->value;
82  }
83 
84 
85  protected function render()
86  {
87  $tpl = new ilTemplate("tpl.authority_input.html", true, true, "Modules/OrgUnit");
88  // if (strlen($this->getValue())) {
89  // $tpl->setCurrentBlock("prop_text_propval");
90  // $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
91  // $tpl->parseCurrentBlock();
92  // }
93 
94  //$tpl->setVariable("POSITION_ID", $this->getFieldId());
95 
96  $postvar = $this->getPostVar();
97  // if ($this->getMulti() && substr($postvar, - 2) != "[]") {
98  // $postvar .= "[]";
99  // }
100 
101  $tpl->setVariable("POST_VAR", $postvar);
102 
103  // SCOPE
104  $scope_html = "";
105  foreach (ilOrgUnitAuthority::getScopes() as $scope) {
106  $txt = $this->dic()->language()->txt('scope_' . $scope);
107  $scope_html .= "<option value='{$scope}'>{$txt}</option>";
108  }
109  $tpl->setVariable("SCOPE_OPTIONS", $scope_html);
110 
111  // Over
112  $over_everyone = ilOrgUnitAuthority::OVER_EVERYONE;
113  $title = $this->lang()->txt('over_' . $over_everyone);
114  $over_html = "<option value='{$over_everyone}'>{$title}</option>";
115  foreach (ilOrgUnitPosition::getArray('id', 'title') as $id => $title) {
116  $over_html .= "<option value='{$id}'>{$title}</option>";
117  }
118  $tpl->setVariable("OVER_OPTIONS", $over_html);
122  if ($this->getMultiValues()) {
123  foreach ($this->getMultiValues() as $ilOrgUnitAuthority) {
124  // $tpl->setVariable("OVER_OPTIONS", $over_html);
125  }
126  }
127 
128  if ($this->getRequired()) {
129  // $tpl->setVariable("REQUIRED", "required=\"required\"");
130  }
131 
132  $tpl->touchBlock("inline_in_bl");
133  $tpl->setVariable("MULTI_ICONS", $this->getMultiIconsHTML());
134  $this->initJS();
135 
136  return $tpl->get();
137  }
138 
139 
143  protected function dic()
144  {
145  return $GLOBALS["DIC"];
146  }
147 
148 
152  protected function lang()
153  {
154  static $loaded;
155  $lang = $this->dic()->language();
156  if (!$loaded) {
157  $lang->loadLanguageModule('orgu');
158  $loaded = true;
159  }
160 
161  return $lang;
162  }
163 
164 
168  public function getMulti()
169  {
170  return false;
171  }
172 
173 
174  protected function initJS()
175  {
176  // Global JS
180  $globalTpl = $GLOBALS['DIC'] ? $GLOBALS['DIC']['tpl'] : $GLOBALS['tpl'];
181  $globalTpl->addJavascript("./Modules/OrgUnit/templates/default/authority.js");
182  $config = json_encode(array());
183  $data = json_encode($this->getValue());
184  $globalTpl->addOnLoadCode("ilOrgUnitAuthorityInput.init({$config}, {$data});");
185  }
186 }
$config
Definition: bootstrap.php:15
$tpl
Definition: ilias.php:10
getPostVar()
Get Post Variable.
if(!array_key_exists('StateId', $_REQUEST)) $id
getMultiIconsHTML()
Get HTML for multiple value icons.
getMultiValues()
Get multi values.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:613
$values
special template class to simplify handling of ITX/PEAR
static replaceNameRenderer(Closure $closure)
$txt
Definition: error.php:11
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
Interface for multi values support.
__construct($a_title="", $a_postvar="")
Constructor.
This class represents a property in a property form.
Class ilOrgUnitAuthorityInputGUI.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
static getArray($key=null, $values=null)
Class ilOrguAuthority.
$authority
$html
Definition: example_001.php:87
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt public...
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
$data
Definition: bench.php:6