28 private string $id =
"asl";
75 "include_form_tag" =>
false,
117 $this->renderer = $DIC->ui()->renderer();
118 $this->
lng = $DIC->language();
119 $this->mode = self::MODE_LINKS;
122 $this->global_tpl = $DIC[
'tpl'];
129 string $a_link_class =
"" 131 $this->mode = self::MODE_LINKS;
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;
209 $this->items = array();
219 $this->listtitle = $a_listtitle;
229 $this->aria_listtitle = $a_listtitle;
234 return strip_tags($this->aria_listtitle);
243 $this->selectionheaderclass = $a_selectionheaderclass;
256 $this->style = $a_val;
269 $this->sel_head_span_class = $a_val;
279 $this->headericon = $a_headericon;
289 $this->nojslinkclass = $a_nojslinkclass;
299 $this->itemlinkclass = $a_itemlinkclass;
307 public function setId(
string $a_id): void
319 $this->useimages = $a_useimages;
329 $this->trigger_event = $a_val;
339 $this->auto_hide = $a_val;
357 string $a_onclick_form_id =
"" 359 $this->on_click = $a_val;
360 $this->on_click_form_id = $a_onclick_form_id;
370 $this->selected_value = $a_val;
385 $this->toggle = array(
"el" => $a_el,
"class_on" => $a_on);
401 $this->asynch = $a_val;
411 $this->asynch_url = $a_val;
421 $this->select_callback = $a_val;
431 $this->dd_pullright = $a_val;
444 public function getHTML(
bool $a_only_cmd_list_asynch =
false): string
453 $this->global_tpl->addJavaScript(
"./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js");
456 "tpl.adv_selection_list.html",
459 "Services/UIComponent/AdvancedSelectionList",
470 $tpl->setCurrentBlock(
"asynch_request");
472 $tpl->parseCurrentBlock();
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);
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");
505 if ($item[
"frame"]) {
506 $tpl->setCurrentBlock(
"frame");
507 $tpl->setVariable(
"TARGET_ITEM", $item[
"frame"]);
508 $tpl->parseCurrentBlock();
512 $tpl->setCurrentBlock(
"item_link_class");
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");
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"] .
"');\"" 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) {
611 $tpl->setCurrentBlock(
"selected_val");
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");
627 $tpl->setCurrentBlock(
"dd_content");
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();
638 $tpl->setCurrentBlock(
"top_img");
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();
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");
675 $cfg[
"anchor_id"] =
"ilAdvSelListAnchorElement_" . $this->
getId();
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));
692 : $this->
lng->txt(
"actions");
693 $tpl->setVariable(
"TXT_ARIA_TOP", $aria_title);
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");
724 "CLASS_SEL_TOP_SPAN",
733 $tpl->parseCurrentBlock();
736 $this->global_tpl->addOnLoadCode(
747 "tpl.adv_selection_list_js_init.js",
750 "Services/UIComponent/AdvancedSelectionList",
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"]);
800 $js_tpl->parseCurrentBlock();
804 $js_tpl->setVariable(
"ID", $this->
getId());
806 return [$js_tpl->get()];
setItemLinkClass(string $a_itemlinkclass)
setAsynchUrl(string $a_val)
const ON_ITEM_CLICK_FORM_SELECT
setAdditionalToggleElement(string $a_el, string $a_on)
Set additional toggle element.
ilGlobalTemplateInterface $global_tpl
setOnClickMode(string $a_val, string $a_onclick_form_id="")
Set "onClick"- Mode.
setUseImages(bool $a_useimages)
setAriaListTitle(string $a_listtitle)
const ON_ITEM_CLICK_FORM_SUBMIT
Class ChatMainBarProvider .
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
getAdditionalToggleElement()
Get additional toggle element.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
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())
setSelectedValue(string $a_val)
getToolbarHTML()
Get input item HTML to be inserted into ilToolbarGUI.
setLinksMode(string $a_link_class="")
Set links mode (for no js fallback)
getSelectionHeaderSpanClass()
getHTML(bool $a_only_cmd_list_asynch=false)
ilGroupedListGUI $grouped_list
string $sel_head_span_class
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setListTitle(string $a_listtitle)
setHeaderIcon(string $a_headericon)
setSelectionHeaderClass(string $a_selectionheaderclass)
DEPRECATED use set style instead.
setGroupedList(ilGroupedListGUI $a_val)
setNoJSLinkClass(string $a_nojslinkclass)
__construct(Container $dic, ilPlugin $plugin)
setSelectionHeaderSpanClass(string $a_val)
setSelectCallback(string $a_val)
addComponent(\ILIAS\UI\Component\Component $component)
setTriggerEvent(string $a_val)
string $selectionheaderclass
ILIAS UI Renderer $renderer
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
setPullRight(bool $a_val)
getSelectionHeaderClass()
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.