28 private string $id =
"asl";
75 "include_form_tag" =>
false,
117 $this->
renderer = $DIC->ui()->renderer();
118 $this->
lng = $DIC->language();
122 $this->global_tpl =
$DIC[
'tpl'];
129 string $a_link_class =
""
132 $this->links_mode = array(
133 "link_class" => $a_link_class);
141 string $a_select_name,
142 string $a_select_class =
"",
143 bool $a_include_form_tag =
false,
144 string $a_form_action =
"",
145 string $a_form_id =
"",
146 string $a_form_class =
"",
147 string $a_form_target =
"_top",
148 string $a_button_text =
"",
149 string $a_button_class =
"",
150 string $a_button_cmd =
""
152 $this->mode = self::MODE_FORM_SELECT;
153 $this->form_mode = array(
154 "select_name" => $a_select_name,
155 "select_class" => $a_select_class,
156 "include_form_tag" => $a_include_form_tag,
157 "form_action" => $a_form_action,
158 "form_id" => $a_form_id,
159 "form_class" => $a_form_class,
160 "form_target" => $a_form_target,
161 "button_text" => $a_button_text,
162 "button_class" => $a_button_class,
163 "button_cmd" => $a_button_cmd
169 string $a_value =
"",
173 string $a_frame =
"",
175 bool $a_prevent_background_click =
false,
176 string $a_onclick =
"",
178 string $a_tt_my =
"right center",
179 string $a_tt_at =
"left center",
180 bool $a_tt_use_htmlspecialchars =
true,
181 array $a_data = array()
183 $this->items[] = array(
"title" => $a_title,
"value" => $a_value,
184 "link" => $a_link,
"img" => $a_img,
"alt" => $a_alt,
"frame" => $a_frame,
185 "html" => $a_html,
"prevent_background_click" => $a_prevent_background_click,
186 "onclick" => $a_onclick,
"ttip" => $a_ttip,
"tt_my" => $a_tt_my,
"tt_at" => $a_tt_at,
187 "tt_use_htmlspecialchars" => $a_tt_use_htmlspecialchars,
"data" => $a_data);
193 'component' => $component,
199 $this->grouped_list = $a_val;
204 return $this->grouped_list;
209 $this->items = array();
219 $this->listtitle = $a_listtitle;
224 return $this->listtitle;
229 $this->aria_listtitle = $a_listtitle;
234 return strip_tags($this->aria_listtitle);
243 $this->selectionheaderclass = $a_selectionheaderclass;
248 return $this->selectionheaderclass;
256 $this->style = $a_val;
269 $this->sel_head_span_class = $a_val;
274 return $this->sel_head_span_class;
279 $this->headericon = $a_headericon;
284 return $this->headericon;
289 $this->nojslinkclass = $a_nojslinkclass;
294 return $this->nojslinkclass;
299 $this->itemlinkclass = $a_itemlinkclass;
304 return $this->itemlinkclass;
307 public function setId(
string $a_id): void
319 $this->useimages = $a_useimages;
324 return $this->useimages;
329 $this->trigger_event = $a_val;
334 return $this->trigger_event;
339 $this->auto_hide = $a_val;
344 return $this->auto_hide;
357 string $a_onclick_form_id =
""
359 $this->on_click = $a_val;
360 $this->on_click_form_id = $a_onclick_form_id;
365 return $this->on_click;
370 $this->selected_value = $a_val;
375 return $this->selected_value;
385 $this->toggle = array(
"el" => $a_el,
"class_on" => $a_on);
393 return $this->toggle;
401 $this->asynch = $a_val;
406 return $this->asynch;
411 $this->asynch_url = $a_val;
416 return $this->asynch_url;
421 $this->select_callback = $a_val;
426 return $this->select_callback;
431 $this->dd_pullright = $a_val;
436 return $this->dd_pullright;
441 return $this->getHTML();
444 public function getHTML(
bool $a_only_cmd_list_asynch =
false): string
446 $items = $this->getItems();
449 if (count($items) === 0 && !$this->getAsynch() && $this->getGroupedList() ===
null) {
453 $this->global_tpl->addJavaScript(
"assets/js/AdvancedSelectionList.js");
456 "tpl.adv_selection_list.html",
459 "components/ILIAS/UIComponent/AdvancedSelectionList",
469 if ($this->getAsynch()) {
470 $tpl->setCurrentBlock(
"asynch_request");
472 $tpl->parseCurrentBlock();
473 } elseif ($this->getGroupedList() !==
null) {
474 $tpl->setVariable(
"GROUPED_LIST_HTML", $this->getGroupedList()->getHTML());
476 foreach ($items as $item) {
477 $this->css_row = ($this->css_row !==
"tblrow1_mo")
481 if (isset($item[
'component'])) {
482 $tpl->setCurrentBlock(
'component');
483 $tpl->setVariable(
'COMPONENT', $this->
renderer->render([$item[
'component']]));
484 $tpl->parseCurrentBlock();
486 $tpl->setCurrentBlock(
'item_loop');
487 $tpl->parseCurrentBlock();
491 $item[
"value"] = htmlspecialchars($item[
"value"] ??
'', ENT_QUOTES);
493 if ($this->getUseImages()) {
495 $tpl->setCurrentBlock(
"image");
496 $tpl->setVariable(
"IMG_ITEM", $item[
"img"]);
497 $tpl->setVariable(
"ALT_ITEM", $item[
"alt"]);
498 $tpl->parseCurrentBlock();
500 $tpl->touchBlock(
"no_image");
504 if ($this->getOnClickMode() === self::ON_ITEM_CLICK_HREF || $this->getItemLinkClass() !==
"") {
505 if ($item[
"frame"]) {
506 $tpl->setCurrentBlock(
"frame");
507 $tpl->setVariable(
"TARGET_ITEM", $item[
"frame"]);
508 $tpl->parseCurrentBlock();
511 if ($this->getItemLinkClass() !==
"") {
512 $tpl->setCurrentBlock(
"item_link_class");
513 $tpl->setVariable(
"ITEM_LINK_CLASS", $this->getItemLinkClass());
514 $tpl->parseCurrentBlock();
517 if (is_array($item[
"data"])) {
518 foreach ($item[
"data"] as $k => $v) {
519 $tpl->setCurrentBlock(
"f_data");
520 $tpl->setVariable(
"DATA_KEY", $k);
522 $tpl->parseCurrentBlock();
525 if ($item[
"value"] !=
"") {
526 $tpl->setCurrentBlock(
"item_id");
527 $tpl->setVariable(
"ID_ITEM", $this->
getId() .
"_" . $item[
"value"]);
528 $tpl->parseCurrentBlock();
531 $tpl->setCurrentBlock(
"href_s");
532 $tpl->setVariable(
"HREF_ITEM",
'href="' . $item[
"link"] .
'"');
533 $tpl->parseCurrentBlock();
535 $tpl->touchBlock(
"href_e");
538 $tpl->setCurrentBlock(
"item");
539 if ($this->getOnClickMode() === self::ON_ITEM_CLICK_HREF) {
540 if ($item[
"prevent_background_click"]) {
541 $tpl->setVariable(
"ONCLICK_ITEM",
'');
542 } elseif ($item[
"onclick"] ==
"" && $item[
"frame"] !=
"") {
545 'onclick="' .
"return il.AdvancedSelectionList.openTarget('" . $item[
"link"] .
"','" . $item[
"frame"] .
"');" .
'"'
547 } elseif ($item[
"onclick"] !=
"") {
550 'onclick="' .
"return " . $item[
"onclick"] .
";" .
'"'
553 } elseif ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SUBMIT) {
556 'onclick="return il.AdvancedSelectionList.submitForm(\'' . $this->
getId() .
'\'' .
557 ", '" . $this->form_mode[
"select_name"] .
"','" . $item[
"value"] .
"'," .
558 "'" . $this->on_click_form_id .
"','" . $this->form_mode[
"button_cmd"] .
"');\""
560 } elseif ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SELECT) {
563 'onclick="return il.AdvancedSelectionList.selectForm(\'' . $this->
getId() .
'\'' .
564 ", '" . $this->form_mode[
"select_name"] .
"','" . $item[
"value"] .
"'," .
565 "'" . $item[
"title"] .
"');\""
567 } elseif ($this->getOnClickMode() === self::ON_ITEM_CLICK_NOP) {
570 'onclick="il.AdvancedSelectionList.clickNop(\'' . $this->
getId() .
'\'' .
571 ", '" . $this->form_mode[
"select_name"] .
"','" . $item[
"value"] .
"'," .
572 "'" . $item[
"title"] .
"');\""
576 $tpl->setVariable(
"CSS_ROW", $this->css_row);
577 if ($item[
"html"] ==
"") {
578 $tpl->setVariable(
"TXT_ITEM", $item[
"title"]);
580 $tpl->setVariable(
"TXT_ITEM", $item[
"html"]);
583 $tpl->setVariable(
"ID_ITEM_TR", $this->
getId() .
"_" . $item[
"value"] .
"_tr");
585 $tpl->parseCurrentBlock();
587 $tpl->setCurrentBlock(
'item_loop');
588 $tpl->parseCurrentBlock();
592 if ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SUBMIT) {
593 $tpl->setCurrentBlock(
"hidden_input");
594 $tpl->setVariable(
"HID", $this->
getId());
595 $tpl->parseCurrentBlock();
599 if ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SELECT) {
600 if ($this->getSelectedValue() !==
"") {
601 $tpl->setCurrentBlock(
"selected_val");
602 $tpl->setVariable(
"SEL_VAL", $this->getSelectedValue());
603 $tpl->parseCurrentBlock();
605 $tpl->setCurrentBlock(
"hidden_input");
606 $tpl->setVariable(
"HID", $this->
getId());
607 $tpl->parseCurrentBlock();
611 if ($a_only_cmd_list_asynch) {
612 $tpl->touchBlock(
"cmd_table");
613 return $tpl->get(
"item_loop");
616 if ($this->getGroupedList() ===
null) {
617 $tpl->setCurrentBlock(
"dd_content");
618 if ($this->getPullRight()) {
619 $tpl->setVariable(
"UL_CLASS",
"dropdown-menu pull-right");
621 $tpl->setVariable(
"UL_CLASS",
"dropdown-menu");
623 $tpl->setVariable(
"TABLE_ID", $this->
getId());
624 $tpl->parseCurrentBlock();
627 if ($this->getHeaderIcon() !== self::NO_ICON) {
628 $tpl->setCurrentBlock(
"top_img");
629 switch ($this->getHeaderIcon()) {
630 case self::ICON_CONFIG:
631 $tpl->setVariable(
"IMG_SPAN_STYLE", self::ICON_CONFIG);
634 case self::DOWN_ARROW_DARK:
636 $tpl->setVariable(
"IMG_SPAN_STYLE", self::ICON_ARROW);
639 $tpl->parseCurrentBlock();
643 if ($this->getAsynch()) {
644 $js_tpl = $this->getJSTemplate();
645 $js_tpl->setVariable(
"ID", $this->
getId());
646 $js_tpl->setCurrentBlock(
"asynch_bl");
647 $js_tpl->setVariable(
"ASYNCH_URL", $this->getAsynchUrl());
648 $js_tpl->setVariable(
"ASYNCH_ID", $this->
getId());
649 $js_tpl->setVariable(
"ASYNCH_TRIGGER_ID", $this->
getId());
650 $js_tpl->parseCurrentBlock();
651 $this->global_tpl->addOnloadCode(
657 $tpl->setCurrentBlock(
"js_section");
659 $cfg[
"trigger_event"] = $this->getTriggerEvent();
660 $cfg[
"auto_hide"] = $this->getAutoHide();
662 if ($this->getSelectCallback() !==
"") {
663 $cfg[
"select_callback"] = $this->getSelectCallback();
665 $cfg[
"anchor_id"] =
"ilAdvSelListAnchorElement_" . $this->
getId();
666 $cfg[
"asynch"] = $this->getAsynch();
667 $cfg[
"asynch_url"] = $this->getAsynchUrl();
668 $toggle = $this->getAdditionalToggleElement();
669 if (is_array($toggle)) {
670 $cfg[
"toggle_el"] = $toggle[
"el"];
671 $cfg[
"toggle_class_on"] = $toggle[
"class_on"];
674 $tpl->setVariable(
"CFG", json_encode($cfg, JSON_THROW_ON_ERROR));
678 if ($this->getListTitle() !==
"") {
679 $tpl->setVariable(
"TXT_SEL_TOP", $this->getListTitle());
681 if ($this->getListTitle() ===
"" || $this->getAriaListTitle() !==
"") {
682 $aria_title = ($this->getAriaListTitle() !==
"")
683 ? $this->getAriaListTitle()
684 : $this->
lng->txt(
"actions");
685 $tpl->setVariable(
"TXT_ARIA_TOP", $aria_title);
687 $tpl->setVariable(
"ID", $this->
getId());
690 switch ($this->getStyle()) {
691 case self::STYLE_DEFAULT:
692 $tpl->setVariable(
"BTN_CLASS",
"btn btn-default");
693 $tpl->setVariable(
"TAG",
"button");
696 case self::STYLE_EMPH:
697 $tpl->setVariable(
"BTN_CLASS",
"btn btn-primary");
698 $tpl->setVariable(
"TAG",
"button");
701 case self::STYLE_LINK_BUTTON:
702 $tpl->setVariable(
"BTN_CLASS",
"btn btn-link");
703 $tpl->setVariable(
"TAG",
"button");
706 case self::STYLE_LINK:
707 $tpl->setVariable(
"BTN_CLASS",
"");
708 $tpl->setVariable(
"TAG",
"a");
709 $tpl->touchBlock(
"href_link");
714 if ($this->getSelectionHeaderSpanClass() !==
"") {
716 "CLASS_SEL_TOP_SPAN",
717 $this->getSelectionHeaderSpanClass()
725 $tpl->parseCurrentBlock();
727 foreach ($this->getOnloadCode() as $code) {
728 $this->global_tpl->addOnLoadCode(
739 "tpl.adv_selection_list_js_init.js",
742 "components/ILIAS/UIComponent/AdvancedSelectionList",
751 $items = $this->getItems();
754 if (count($items) === 0 && !$this->getAsynch() && $this->getGroupedList() ===
null) {
758 $js_tpl = $this->getJSTemplate();
762 if (!$this->getAsynch() && $this->getGroupedList() ===
null) {
763 foreach ($items as $item) {
764 if (isset($item[
'component'])) {
769 $js_tpl->setCurrentBlock(
"js_item");
770 $js_tpl->setVariable(
"IT_ID", $this->
getId());
771 $js_tpl->setVariable(
"IT_HID_NAME", $this->form_mode[
"select_name"]);
773 $js_tpl->setVariable(
"IT_HID_VAL", $item[
"value"]);
774 $js_tpl->setVariable(
"IT_TITLE", str_replace(
"'",
"\\'", $item[
"title"]));
775 $js_tpl->parseCurrentBlock();
779 if ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SUBMIT) {
780 $js_tpl->setCurrentBlock(
"hidden_input");
781 $js_tpl->setVariable(
"HID", $this->
getId());
782 $js_tpl->parseCurrentBlock();
786 if ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SELECT) {
788 $js_tpl->setCurrentBlock(
"init_hidden_input");
789 $js_tpl->setVariable(
"H2ID", $this->
getId());
790 $js_tpl->setVariable(
"HID_NAME", $this->form_mode[
"select_name"]);
791 $js_tpl->setVariable(
"HID_VALUE", $this->getSelectedValue());
792 $js_tpl->parseCurrentBlock();
796 $js_tpl->setVariable(
"ID", $this->
getId());
798 return [$js_tpl->get()];
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGroupedListGUI $grouped_list
const ON_ITEM_CLICK_FORM_SELECT
setTriggerEvent(string $a_val)
setGroupedList(ilGroupedListGUI $a_val)
getAdditionalToggleElement()
Get additional toggle element.
setSelectedValue(string $a_val)
const ON_ITEM_CLICK_FORM_SUBMIT
setPullRight(bool $a_val)
ILIAS UI Renderer $renderer
setSelectionHeaderSpanClass(string $a_val)
getSelectionHeaderClass()
setAsynchUrl(string $a_val)
string $selectionheaderclass
setAdditionalToggleElement(string $a_el, string $a_on)
Set additional toggle element.
addComponent(\ILIAS\UI\Component\Component $component)
setSelectionHeaderClass(string $a_selectionheaderclass)
DEPRECATED use set style instead.
getSelectionHeaderSpanClass()
getToolbarHTML()
Get input item HTML to be inserted into ilToolbarGUI.
setLinksMode(string $a_link_class="")
Set links mode (for no js fallback)
setItemLinkClass(string $a_itemlinkclass)
setFormSelectMode(string $a_select_name, string $a_select_class="", bool $a_include_form_tag=false, string $a_form_action="", string $a_form_id="", string $a_form_class="", string $a_form_target="_top", string $a_button_text="", string $a_button_class="", string $a_button_cmd="")
Set form mode (for no js fallback) Outputs form selection including surrounding form.
setAriaListTitle(string $a_listtitle)
setNoJSLinkClass(string $a_nojslinkclass)
ilGlobalTemplateInterface $global_tpl
getHTML(bool $a_only_cmd_list_asynch=false)
addItem(string $a_title, string $a_value="", string $a_link="", string $a_img="", string $a_alt="", string $a_frame="", string $a_html="", bool $a_prevent_background_click=false, string $a_onclick="", string $a_ttip="", string $a_tt_my="right center", string $a_tt_at="left center", bool $a_tt_use_htmlspecialchars=true, array $a_data=array())
setListTitle(string $a_listtitle)
setOnClickMode(string $a_val, string $a_onclick_form_id="")
Set "onClick"- Mode.
setUseImages(bool $a_useimages)
string $sel_head_span_class
setSelectCallback(string $a_val)
setHeaderIcon(string $a_headericon)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.