function link_to($path, $caption, $options = array()) { set_if_not_set($options["goto"], false); if (!in_array(substr($path, 0, 7), array("mailto:", "http://", "https:/")) && substr($path, 0, 1) != "#") { $path = "/" . $path; } if (isset($GLOBALS["full_path_links"]) && $GLOBALS["full_path_links"]) { $path = full_path($path); } if ($options["goto"]) { $parameters = array_intersect_key($options, array_flip(array("class", "id", "title"))); return insert_properties_in_html_tag(str_replace("\n", "", $caption), array_merge($parameters, array("onclick" => "goto('" . $path . "')", "style" => "cursor:pointer"))); } else { if (!is_empty($options['modal'])) { set_if_not_set($options['modal']['title'], ""); // The message should be set if the 'modal' options is used, but we provide a default one set_if_not_set($options['modal']['message'], " Es-tu sûr de vouloir faire cela ?"); // A modal toggle should at least be a button and not only a text in a div set_if_not_set($options['modal']['class'], "btn"); $modal_id = is_empty($options['modal']["id"]) ? $options["id"] . "_modal_auto_id" : $options['modal']["id"]; $button_in_modal = link_to($path, "<div> Confirmer </div>", array("class" => "btn")); $content = $options['modal']['message'] . "<div class=\"button-container\">" . $button_in_modal . "</div>"; $modal = modal($modal_id, array("title" => $options['modal']["title"]), $content); return modal_toggle($options["id"], $caption, $options["class"], $modal_id) . "\n" . $modal; } else { $parameters = is_empty($options["class"]) ? "" : " class=\"" . $options["class"] . "\""; $parameters .= is_empty($options["id"]) ? "" : " id=\"" . $options["id"] . "\""; $parameters .= is_empty($options["title"]) ? "" : " title=\"" . $options["title"] . "\""; return "<a href=\"" . $path . "\"" . $parameters . ">" . $caption . "</a>"; } } }
function make_collapse_control($html_tag, $id, $aria_hidden = "true") { return insert_properties_in_html_tag($html_tag, array("data-toggle" => "collapse", "data-target" => "#" . $id, "aria-hidden" => $aria_hidden, "aria-controls" => $id, "style" => "cursor : pointer")); }