ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilManualPlaceholderInputGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once 'Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php';
5
11{
15 protected $placeholders = array();
16
20 protected $rerenderUrl;
21
26
31
35 protected $instructionText = '';
36
40 protected $adviseText = '';
41
45 protected $tpl;
46
50 protected $lng;
51
57 {
58 global $DIC;
59
60 $this->tpl = $DIC->ui()->mainTemplate();
61 $this->lng = $DIC->language();
62
64
65 $this->dependencyElementId = $dependencyElementId;
66
67 $this->tpl->addJavaScript('Services/Mail/js/ilMailComposeFunctions.js');
68 }
69
73 public function getRerenderUrl()
74 {
75 return $this->rerenderUrl;
76 }
77
82 {
84 }
85
90 public function supportsRerenderSignal($elementId, $url)
91 {
92 $this->rerenderTriggerElementName = $elementId;
93 $this->rerenderUrl = $url;
94 }
95
99 public function getAdviseText()
100 {
101 return $this->adviseText;
102 }
103
107 public function setAdviseText($adviseText)
108 {
109 $this->adviseText = $adviseText;
110 }
111
115 public function getInstructionText()
116 {
118 }
119
124 {
125 $this->instructionText = $instructionText;
126 }
127
132 public function addPlaceholder($placeholder, $title)
133 {
134 $this->placeholders[$placeholder]['placeholder'] = $placeholder;
135 $this->placeholders[$placeholder]['title'] = $title;
136 }
137
141 public function insert($a_tpl)
142 {
143 $html = $this->render();
144
145 $a_tpl->setCurrentBlock("prop_generic");
146 $a_tpl->setVariable("PROP_GENERIC", $html);
147 $a_tpl->parseCurrentBlock();
148 }
149
154 public function render($ajax = false)
155 {
156 $subtpl = new ilTemplate("tpl.mail_manual_placeholders.html", true, true, "Services/Mail");
157 $subtpl->setVariable('TXT_USE_PLACEHOLDERS', $this->lng->txt('mail_nacc_use_placeholder'));
158 $subtpl->setVariable('DEPENDENCY_ELM_ID_OUTER', $this->dependencyElementId);
159 if ($this->getAdviseText()) {
160 $subtpl->setVariable('TXT_PLACEHOLDERS_ADVISE', $this->getAdviseText());
161 }
162
163 if (count($this->placeholders) > 0) {
164 foreach ($this->placeholders as $placeholder) {
165 $subtpl->setCurrentBlock('man_placeholder');
166 $subtpl->setVariable('DEPENDENCY_ELM_ID', $this->dependencyElementId);
167 $subtpl->setVariable('PLACEHOLDER', '[' . $placeholder['placeholder'] . ']');
168 $subtpl->setVariable('PLACEHOLDER_INTERACTION_INFO', sprintf(
169 $this->lng->txt('mail_hint_add_placeholder_x'),
170 '[' . $placeholder['placeholder'] . ']'
171 ));
172 $subtpl->setVariable('PLACEHOLDER_DESCRIPTION', $placeholder['title']);
173 $subtpl->parseCurrentBlock();
174 }
175 }
176
177 if ($this->getRerenderTriggerElementName() && $this->getRerenderUrl()) {
178 $subtpl->setVariable('RERENDER_URL', $this->getRerenderUrl());
179 $subtpl->setVariable('RERENDER_TRIGGER_ELM_NAME', $this->getRerenderTriggerElementName());
180 }
181
182 if ($ajax) {
183 echo $subtpl->get();
184 exit();
185 }
186
187 return $subtpl->get();
188 }
189
195 public function setValueByArray($a_values)
196 {
197 $this->setValue($a_values[$this->getPostVar()]);
198 }
204 public function setValue($a_value)
205 {
206 if ($this->getMulti() && is_array($a_value)) {
207 $this->setMultiValues($a_value);
208 $a_value = array_shift($a_value);
209 }
210 $this->value = $a_value;
211 }
212
213 public function checkInput()
214 {
215 return true;
216 }
217}
An exception for terminatinating execution or to throw for unit testing.
getPostVar()
Get Post Variable.
setMultiValues(array $a_values)
Set multi values.
Class ilManualPlaceholderInputGUI.
checkInput()
Check input, strip slashes etc.
setValueByArray($a_values)
Set value by array.
__construct($dependencyElementId)
ilManualPlaceholderInputGUI constructor.
This class represents a property that may include a sub form.
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: goto.php:24
exit
Definition: login.php:29
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url