3 declare(strict_types=1);
50 return $this->
renderButton($component, $default_renderer);
58 $tpl_name =
"tpl.primary.html";
61 $tpl_name =
"tpl.standard.html";
64 $tpl_name =
"tpl.shy.html";
67 $tpl_name =
"tpl.tag.html";
70 $tpl_name =
"tpl.bulky.html";
75 $action = $component->getAction();
78 if (is_string($action)) {
79 $tpl->setCurrentBlock(
"with_data_action");
80 $tpl->setVariable(
"ACTION", $action);
81 $tpl->parseCurrentBlock();
84 $label = $component->getLabel();
85 if ($label !== null) {
86 $tpl->setVariable(
"LABEL", $component->getLabel());
88 if ($component->isActive()) {
91 if (is_string($action) && $action !=
"") {
92 $component = $component->withAdditionalOnLoadCode(
function (
$id) use ($action) {
93 $action = str_replace(
"&",
"&", $action);
95 return "$('#$id').on('click', function(event) { 96 window.location = '$action'; 103 $component = $component->withAdditionalOnLoadCode(fn (
$id) =>
"$('#$id').click(function(e) { il.UI.button.activateLoadingAnimation('$id')});");
106 $tpl->touchBlock(
"disabled");
108 $aria_label = $component->getAriaLabel();
109 if ($aria_label != null) {
110 $tpl->setCurrentBlock(
"with_aria_label");
111 $tpl->setVariable(
"ARIA_LABEL", $aria_label);
112 $tpl->parseCurrentBlock();
116 && $component->isEngageable()
118 if ($component->isEngaged()) {
119 $tpl->touchBlock(
"engaged");
120 $aria_pressed =
'true';
122 $aria_pressed =
'false';
126 if (!($component instanceof Bulky)) {
127 $tpl->setCurrentBlock(
"with_aria_pressed");
128 $tpl->setVariable(
"ARIA_PRESSED", $aria_pressed);
129 $tpl->parseCurrentBlock();
151 parent::registerResources($registry);
152 $registry->
register(
'./src/UI/templates/js/Button/button.js');
153 $registry->
register(
"./node_modules/moment/min/moment-with-locales.min.js");
154 $registry->
register(
"./node_modules/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js");
162 $tpl->setVariable(
"FORCE_RENDERING",
"");
163 $tpl->setVariable(
"ARIA_LABEL", $this->
txt(
"close"));
171 $tpl->setVariable(
"ARIA_LABEL", $this->
txt(
"minimize"));
180 $on_action = $component->getActionOn();
181 $off_action = $component->getActionOff();
183 $on_url = (is_string($on_action))
187 $off_url = (is_string($off_action))
193 foreach ($component->getTriggeredSignals() as $s) {
195 "signal_id" => $s->getSignal()->getId(),
196 "event" => $s->getEvent(),
197 "options" => $s->getSignal()->getOptions()
201 $signals = json_encode($signals);
203 $button_status =
'off';
204 if ($component->isEngaged()) {
205 $button_status =
'on';
208 if ($component->isActive()) {
209 $component = $component->withAdditionalOnLoadCode(fn (
$id) =>
"$('#$id').on('click', function(event) { 210 il.UI.button.handleToggleClick(event, '$id', '$on_url', '$off_url', $signals); 211 return false; // stop event propagation 213 $tpl->setCurrentBlock(
"with_on_off_label");
214 $tpl->setVariable(
"ON_LABEL", $this->
txt(
"toggle_on"));
215 $tpl->setVariable(
"OFF_LABEL", $this->
txt(
"toggle_off"));
216 $tpl->parseCurrentBlock();
218 $tpl->touchBlock(
"disabled");
219 $button_status =
'unavailable';
222 $tpl->touchBlock($button_status);
224 $label = $component->getLabel();
225 if (!empty($label)) {
226 $tpl->setCurrentBlock(
"with_label");
227 $tpl->setVariable(
"LABEL", $label);
228 $tpl->parseCurrentBlock();
230 $aria_label = $component->getAriaLabel();
231 if ($aria_label != null) {
232 $tpl->setCurrentBlock(
"with_aria_label");
233 $tpl->setVariable(
"ARIA_LABEL", $aria_label);
234 $tpl->parseCurrentBlock();
252 $def = $component->getDefault();
254 for (
$i = 1;
$i <= 12;
$i++) {
255 $this->
toJS(array(
"month_" . str_pad((
string)
$i, 2,
"0", STR_PAD_LEFT) .
"_short"));
260 $month = explode(
"-", $def);
261 $tpl->setVariable(
"DEFAULT_LABEL", $this->
txt(
"month_" . str_pad($month[0], 2,
"0", STR_PAD_LEFT) .
"_short") .
" " . $month[1]);
262 $tpl->setVariable(
"DEF_DATE", $month[0] .
"/1/" . $month[1]);
264 $lang_key = in_array($this->
getLangKey(), array(
"ar",
"bg",
"cs",
"da",
"de",
"el",
"en",
"es",
"et",
"fa",
"fr",
"hu",
"it",
265 "ja",
"ka",
"lt",
"nl",
"pl",
"pt",
"ro",
"ru",
"sk",
"sq",
"sr",
"tr",
"uk",
"vi",
"zh"))
268 if ($lang_key ==
"zh") {
271 $tpl->setVariable(
"LANG", $lang_key);
273 $component = $component->withAdditionalOnLoadCode(fn (
$id) =>
"il.UI.button.initMonth('$id');");
283 $tpl->
touchBlock(
'rel_' . $component->getRelevance());
285 $classes = trim(join(
' ', $component->getClasses()));
286 if ($classes !==
'') {
290 $bgcol = $component->getBackgroundColor();
294 $forecol = $component->getForegroundColor();
305 $renderer = $default_renderer->withAdditionalContext($component);
306 $tpl->
setVariable(
"ICON_OR_GLYPH", $renderer->render($component->getIconOrGlyph()));
307 $label = $component->getLabel();
308 if ($label !== null) {
312 $aria_role = $component->getAriaRole();
313 if ($aria_role != null) {
318 if ($component->isEngageable()) {
324 if ($component->isEngaged()) {
Registry for resources required by rendered output like Javascript or CSS.
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $id)
Get a text from the language file.
toJS($key)
Add language var to client side (il.Language)
setCurrentBlock(string $name)
Set the block to work on.
setVariable(string $name, $value)
Set a variable in the current block.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
register(string $name)
Add a dependency.
parseCurrentBlock()
Parse the block that is currently worked on.
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
touchBlock(string $name)
Touch a block without working further on it.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
getLangKey()
Get current language key.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Base class for all component renderers.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.