ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilManualPlaceholderInputGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
25{
30 protected array $placeholders = [];
31 protected string $rerender_url = '';
32 protected string $rerender_trigger_element_name = '';
33 protected string $instruction_text = '';
34 protected string $advise_text = '';
37 protected $value;
38
39 public function __construct(string $label, string $http_post_param_name, protected string $dependency_element_id)
40 {
41 global $DIC;
42
43 $this->tpl = $DIC->ui()->mainTemplate();
44 $this->http_state = $DIC->http();
45
46 parent::__construct($label, $http_post_param_name);
47
48 $this->tpl->addJavaScript('assets/js/ilMailComposeFunctions.js');
49 }
50
51 public function getRerenderUrl(): ?string
52 {
54 }
55
56 public function getRerenderTriggerElementName(): string
57 {
59 }
60
61 public function supportsRerenderSignal(string $element_id, string $url): void
62 {
63 $this->rerender_trigger_element_name = $element_id;
64 $this->rerender_url = $url;
65 }
66
67 public function getAdviseText(): string
68 {
69 return $this->advise_text;
70 }
71
72 public function setAdviseText(string $advise_text): void
73 {
74 $this->advise_text = $advise_text;
75 }
76
77 public function getInstructionText(): string
78 {
80 }
81
82 public function setInstructionText(string $instruction_text): void
83 {
84 $this->instruction_text = $instruction_text;
85 }
86
87 public function addPlaceholder(string $placeholder, string $title): void
88 {
89 $this->placeholders[$placeholder]['placeholder'] = $placeholder;
90 $this->placeholders[$placeholder]['title'] = $title;
91 }
92
93 public function insert(ilTemplate $a_tpl): void
94 {
95 $html = $this->render();
96
97 $a_tpl->setCurrentBlock('prop_generic');
98 $a_tpl->setVariable('PROP_GENERIC', $html);
99 $a_tpl->parseCurrentBlock();
100 }
101
102 public function render(bool $ajax = false): string
103 {
104 $subtpl = new ilTemplate(
105 'tpl.mail_manual_placeholders.html',
106 true,
107 true,
108 'components/ILIAS/Mail'
109 );
110 $subtpl->setVariable('TXT_USE_PLACEHOLDERS', $this->lng->txt('mail_nacc_use_placeholder'));
111 $subtpl->setVariable('DEPENDENCY_ELM_ID_OUTER', $this->dependency_element_id);
112 if ($this->getAdviseText() !== '') {
113 $subtpl->setVariable('TXT_PLACEHOLDERS_ADVISE', $this->getAdviseText());
114 }
115
116 foreach ($this->placeholders as $placeholder) {
117 $subtpl->setCurrentBlock('man_placeholder');
118 $subtpl->setVariable('DEPENDENCY_ELM_ID', $this->dependency_element_id);
119 $subtpl->setVariable('PLACEHOLDER', '&lbrace;&lbrace;' . $placeholder['placeholder'] . '&rbrace;&rbrace;');
120 $subtpl->setVariable('PLACEHOLDER_INTERACTION_INFO', sprintf(
121 $this->lng->txt('mail_hint_add_placeholder_x'),
122 '&lbrace;&lbrace;' . $placeholder['placeholder'] . '&rbrace;&rbrace;'
123 ));
124 $subtpl->setVariable('PLACEHOLDER_DESCRIPTION', $placeholder['title']);
125 $subtpl->parseCurrentBlock();
126 }
127
128 if (!$ajax && $this->getRerenderTriggerElementName() && $this->getRerenderUrl()) {
129 $subtpl->setVariable('RERENDER_URL', $this->getRerenderUrl());
130 $subtpl->setVariable('RERENDER_DEPENDENCY_ELM_ID_OUTER', $this->dependency_element_id);
131 $subtpl->setVariable('RERENDER_TRIGGER_ELM_NAME', $this->getRerenderTriggerElementName());
132 }
133
134 if ($ajax) {
135 $this->http_state->saveResponse(
136 $this->http_state
137 ->response()
138 ->withBody(Streams::ofString($subtpl->get()))
139 );
140 $this->http_state->sendResponse();
141 $this->http_state->close();
142 }
143
144 return $subtpl->get();
145 }
146
147 public function setValueByArray(array $a_values): void
148 {
149 $this->setValue($a_values[$this->getPostVar()] ?? null);
150 }
151
152 public function setValue($a_value): void
153 {
154 if (is_array($a_value) && $this->getMulti()) {
155 $this->setMultiValues($a_value);
156 $a_value = array_shift($a_value);
157 }
158 $this->value = $a_value;
159 }
160
161 public function checkInput(): bool
162 {
163 return true;
164 }
165}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Definition: Streams.php:32
setMultiValues(array $a_values)
__construct(string $label, string $http_post_param_name, protected string $dependency_element_id)
supportsRerenderSignal(string $element_id, string $url)
checkInput()
Check input, strip slashes etc.
addPlaceholder(string $placeholder, string $title)
This class represents a property that may include a sub form.
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Interface GlobalHttpState.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68