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(
"./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js");
456 "tpl.adv_selection_list.html",
459 "Services/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");
584 if ($item[
"ttip"] !=
"") {
586 $this->
getId() .
"_" . $item[
"value"] .
"_tr",
591 $item[
"tt_use_htmlspecialchars"]
595 $tpl->parseCurrentBlock();
597 $tpl->setCurrentBlock(
'item_loop');
598 $tpl->parseCurrentBlock();
602 if ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SUBMIT) {
603 $tpl->setCurrentBlock(
"hidden_input");
604 $tpl->setVariable(
"HID", $this->
getId());
605 $tpl->parseCurrentBlock();
609 if ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SELECT) {
610 if ($this->getSelectedValue() !==
"") {
611 $tpl->setCurrentBlock(
"selected_val");
612 $tpl->setVariable(
"SEL_VAL", $this->getSelectedValue());
613 $tpl->parseCurrentBlock();
615 $tpl->setCurrentBlock(
"hidden_input");
616 $tpl->setVariable(
"HID", $this->
getId());
617 $tpl->parseCurrentBlock();
621 if ($a_only_cmd_list_asynch) {
622 $tpl->touchBlock(
"cmd_table");
623 return $tpl->get(
"item_loop");
626 if ($this->getGroupedList() ===
null) {
627 $tpl->setCurrentBlock(
"dd_content");
628 if ($this->getPullRight()) {
629 $tpl->setVariable(
"UL_CLASS",
"dropdown-menu pull-right");
631 $tpl->setVariable(
"UL_CLASS",
"dropdown-menu");
633 $tpl->setVariable(
"TABLE_ID", $this->
getId());
634 $tpl->parseCurrentBlock();
637 if ($this->getHeaderIcon() !== self::NO_ICON) {
638 $tpl->setCurrentBlock(
"top_img");
639 switch ($this->getHeaderIcon()) {
640 case self::ICON_CONFIG:
641 $tpl->setVariable(
"IMG_SPAN_STYLE", self::ICON_CONFIG);
644 case self::DOWN_ARROW_DARK:
646 $tpl->setVariable(
"IMG_SPAN_STYLE", self::ICON_ARROW);
649 $tpl->parseCurrentBlock();
653 if ($this->getAsynch()) {
654 $js_tpl = $this->getJSTemplate();
655 $js_tpl->setVariable(
"ID", $this->
getId());
656 $js_tpl->setCurrentBlock(
"asynch_bl");
657 $js_tpl->setVariable(
"ASYNCH_URL", $this->getAsynchUrl());
658 $js_tpl->setVariable(
"ASYNCH_ID", $this->
getId());
659 $js_tpl->setVariable(
"ASYNCH_TRIGGER_ID", $this->
getId());
660 $js_tpl->parseCurrentBlock();
661 $this->global_tpl->addOnloadCode(
667 $tpl->setCurrentBlock(
"js_section");
669 $cfg[
"trigger_event"] = $this->getTriggerEvent();
670 $cfg[
"auto_hide"] = $this->getAutoHide();
672 if ($this->getSelectCallback() !==
"") {
673 $cfg[
"select_callback"] = $this->getSelectCallback();
675 $cfg[
"anchor_id"] =
"ilAdvSelListAnchorElement_" . $this->
getId();
676 $cfg[
"asynch"] = $this->getAsynch();
677 $cfg[
"asynch_url"] = $this->getAsynchUrl();
678 $toggle = $this->getAdditionalToggleElement();
679 if (is_array($toggle)) {
680 $cfg[
"toggle_el"] = $toggle[
"el"];
681 $cfg[
"toggle_class_on"] = $toggle[
"class_on"];
684 $tpl->setVariable(
"CFG", json_encode($cfg, JSON_THROW_ON_ERROR));
688 $tpl->setVariable(
"TXT_SEL_TOP", $this->getListTitle());
689 if ($this->getListTitle() ===
"" || $this->getAriaListTitle() !==
"") {
690 $aria_title = ($this->getAriaListTitle() !==
"")
691 ? $this->getAriaListTitle()
692 : $this->
lng->txt(
"actions");
693 $tpl->setVariable(
"TXT_ARIA_TOP", $aria_title);
698 switch ($this->getStyle()) {
699 case self::STYLE_DEFAULT:
700 $tpl->setVariable(
"BTN_CLASS",
"btn btn-default");
701 $tpl->setVariable(
"TAG",
"button");
704 case self::STYLE_EMPH:
705 $tpl->setVariable(
"BTN_CLASS",
"btn btn-primary");
706 $tpl->setVariable(
"TAG",
"button");
709 case self::STYLE_LINK_BUTTON:
710 $tpl->setVariable(
"BTN_CLASS",
"btn btn-link");
711 $tpl->setVariable(
"TAG",
"button");
714 case self::STYLE_LINK:
715 $tpl->setVariable(
"BTN_CLASS",
"");
716 $tpl->setVariable(
"TAG",
"a");
717 $tpl->touchBlock(
"href_link");
722 if ($this->getSelectionHeaderSpanClass() !==
"") {
724 "CLASS_SEL_TOP_SPAN",
725 $this->getSelectionHeaderSpanClass()
733 $tpl->parseCurrentBlock();
735 foreach ($this->getOnloadCode() as $code) {
736 $this->global_tpl->addOnLoadCode(
747 "tpl.adv_selection_list_js_init.js",
750 "Services/UIComponent/AdvancedSelectionList",
759 $items = $this->getItems();
762 if (count($items) === 0 && !$this->getAsynch() && $this->getGroupedList() ===
null) {
766 $js_tpl = $this->getJSTemplate();
770 if (!$this->getAsynch() && $this->getGroupedList() ===
null) {
771 foreach ($items as $item) {
772 if (isset($item[
'component'])) {
777 $js_tpl->setCurrentBlock(
"js_item");
778 $js_tpl->setVariable(
"IT_ID", $this->
getId());
779 $js_tpl->setVariable(
"IT_HID_NAME", $this->form_mode[
"select_name"]);
781 $js_tpl->setVariable(
"IT_HID_VAL", $item[
"value"]);
782 $js_tpl->setVariable(
"IT_TITLE", str_replace(
"'",
"\\'", $item[
"title"]));
783 $js_tpl->parseCurrentBlock();
787 if ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SUBMIT) {
788 $js_tpl->setCurrentBlock(
"hidden_input");
789 $js_tpl->setVariable(
"HID", $this->
getId());
790 $js_tpl->parseCurrentBlock();
794 if ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SELECT) {
796 $js_tpl->setCurrentBlock(
"init_hidden_input");
797 $js_tpl->setVariable(
"H2ID", $this->
getId());
798 $js_tpl->setVariable(
"HID_NAME", $this->form_mode[
"select_name"]);
799 $js_tpl->setVariable(
"HID_VALUE", $this->getSelectedValue());
800 $js_tpl->parseCurrentBlock();
804 $js_tpl->setVariable(
"ID", $this->
getId());
806 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 $img, 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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.