2011-06-02 00:48:29 +02:00
|
|
|
<?php
|
|
|
|
|
2017-12-12 21:57:57 +01:00
|
|
|
/**
|
|
|
|
* Render a stat for dashborad (big number with label).
|
|
|
|
* If no style given, style is danger if number > 0, and success if number == 0.
|
2017-12-25 23:12:52 +01:00
|
|
|
*
|
2017-12-12 21:57:57 +01:00
|
|
|
* @param string $label
|
|
|
|
* @param string $number
|
|
|
|
* @param string $style default, warning, danger or success. Optional.
|
2017-12-25 23:12:52 +01:00
|
|
|
* @return string
|
2017-12-12 21:57:57 +01:00
|
|
|
*/
|
|
|
|
function stats($label, $number, $style = null)
|
|
|
|
{
|
2017-12-25 23:12:52 +01:00
|
|
|
if (empty($style)) {
|
|
|
|
if ($number > 0) {
|
2017-12-12 21:57:57 +01:00
|
|
|
$style = 'danger';
|
|
|
|
} else {
|
|
|
|
$style = 'success';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return div('stats stats-' . $style, [
|
|
|
|
$label,
|
|
|
|
div('number', [
|
|
|
|
$number
|
|
|
|
])
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2017-11-24 12:01:19 +01:00
|
|
|
/**
|
|
|
|
* Renders tabs from the array. Array key is tab name, array value is tab content.
|
2017-12-25 23:12:52 +01:00
|
|
|
*
|
2017-11-24 12:01:19 +01:00
|
|
|
* @param array $tabs
|
2017-12-25 23:12:52 +01:00
|
|
|
* @param int $selected The selected tab, default 0
|
2017-11-24 12:01:19 +01:00
|
|
|
* @return string HTML
|
|
|
|
*/
|
2017-11-24 12:09:28 +01:00
|
|
|
function tabs($tabs, $selected = 0)
|
2017-11-24 12:01:19 +01:00
|
|
|
{
|
|
|
|
$tab_header = [];
|
|
|
|
$tab_content = [];
|
2017-12-25 23:12:52 +01:00
|
|
|
foreach ($tabs as $header => $content) {
|
2021-07-24 00:33:55 +02:00
|
|
|
$active = false;
|
2020-11-24 01:18:05 +01:00
|
|
|
$id = $header;
|
|
|
|
$href = '#' . $id;
|
2017-12-25 23:12:52 +01:00
|
|
|
if (count($tab_header) == $selected) {
|
2021-07-24 00:33:55 +02:00
|
|
|
$active = true;
|
2017-11-24 12:01:19 +01:00
|
|
|
}
|
2020-11-24 01:18:05 +01:00
|
|
|
if (is_array($content)) {
|
|
|
|
$href = $content['href'];
|
|
|
|
$content = null;
|
|
|
|
$id = null;
|
|
|
|
}
|
2021-07-24 00:33:55 +02:00
|
|
|
$tab_header[] = '<li role="presentation" class="nav-item">
|
|
|
|
<a href="'. $href . '" class="nav-link' . ($active ? ' active' : '') . '" role="tab"'
|
|
|
|
. ($id ? ' id="' . $id . '-tab"' : '')
|
|
|
|
. ($id ? ' aria-controls="' . $id . '" data-bs-target="#' . $id . '" data-bs-toggle="tab" role="tab"' : '')
|
|
|
|
. ($id && $active ? ' aria-selected="true"' : ' aria-selected="false"')
|
2020-11-24 01:18:05 +01:00
|
|
|
. '>'
|
2017-12-25 23:12:52 +01:00
|
|
|
. $header . '</a></li>';
|
2021-07-24 00:33:55 +02:00
|
|
|
$tab_content[] = $content
|
|
|
|
? '<div role="tabpanel" class="tab-pane' . ($active ? ' show active' : '') . '" id="' . $id . '"'
|
|
|
|
. ' aria-labelledby="' . $id . '-tab"'
|
|
|
|
. '>'
|
2017-12-25 23:12:52 +01:00
|
|
|
. $content
|
2021-07-24 00:33:55 +02:00
|
|
|
. '</div>'
|
|
|
|
: '';
|
2017-11-24 12:01:19 +01:00
|
|
|
}
|
|
|
|
return div('', [
|
|
|
|
'<ul class="nav nav-tabs" role="tablist">' . join($tab_header) . '</ul>',
|
|
|
|
'<div class="tab-content">' . join($tab_content) . '</div>'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2014-12-22 20:06:37 +01:00
|
|
|
/**
|
|
|
|
* Display muted (grey) text.
|
|
|
|
*
|
2017-01-02 03:57:23 +01:00
|
|
|
* @param string $text
|
2017-01-03 03:22:48 +01:00
|
|
|
* @return string
|
2014-12-22 20:06:37 +01:00
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function mute($text)
|
|
|
|
{
|
|
|
|
return '<span class="text-muted">' . $text . '</span>';
|
2014-12-22 20:06:37 +01:00
|
|
|
}
|
|
|
|
|
2016-11-14 17:58:15 +01:00
|
|
|
/**
|
|
|
|
* Renders a bootstrap label with given content and class.
|
|
|
|
*
|
2017-01-03 03:22:48 +01:00
|
|
|
* @param string $content The text
|
|
|
|
* @param string $class default, primary, info, success, warning, danger
|
|
|
|
* @return string
|
2016-11-14 17:58:15 +01:00
|
|
|
*/
|
2021-07-23 15:37:11 +02:00
|
|
|
function badge($content, $class = 'default')
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2021-07-23 15:37:11 +02:00
|
|
|
return '<span class="badge rounded-pill bg-' . $class . '">' . $content . '</span>';
|
2016-11-14 17:58:15 +01:00
|
|
|
}
|
|
|
|
|
2017-01-03 03:22:48 +01:00
|
|
|
/**
|
|
|
|
* @param int $valuemin
|
|
|
|
* @param int $valuemax
|
|
|
|
* @param int $valuenow
|
|
|
|
* @param string $class
|
|
|
|
* @param string $content
|
|
|
|
* @return string
|
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '')
|
|
|
|
{
|
2017-01-03 03:22:48 +01:00
|
|
|
return '<div class="progress">'
|
|
|
|
. '<div class="progress-bar ' . $class . '" role="progressbar" '
|
|
|
|
. 'aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" '
|
|
|
|
. 'style="width: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%"'
|
|
|
|
. '>'
|
|
|
|
. $content . ''
|
|
|
|
. '</div>'
|
|
|
|
. '</div>';
|
2014-12-19 22:41:55 +01:00
|
|
|
}
|
|
|
|
|
2014-09-28 14:50:08 +02:00
|
|
|
/**
|
2021-07-22 21:22:21 +02:00
|
|
|
* Render bootstrap icon
|
|
|
|
*
|
|
|
|
* @param string $icon_name
|
|
|
|
* @param string $class
|
2014-09-28 14:50:08 +02:00
|
|
|
*
|
2017-01-03 03:22:48 +01:00
|
|
|
* @return string
|
2014-09-28 14:50:08 +02:00
|
|
|
*/
|
2021-07-22 21:22:21 +02:00
|
|
|
function icon(string $icon_name, string $class = ''): string
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2021-07-22 21:22:21 +02:00
|
|
|
return ' <span class="bi bi-' . $icon_name . ($class ? ' ' . $class : '') . '"></span> ';
|
2014-09-28 14:50:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a tick or a cross by given boolean
|
|
|
|
*
|
2017-01-02 03:57:23 +01:00
|
|
|
* @param boolean $boolean
|
2017-01-03 03:22:48 +01:00
|
|
|
* @return string
|
2014-09-28 14:50:08 +02:00
|
|
|
*/
|
2021-07-22 21:22:21 +02:00
|
|
|
function icon_bool($boolean)
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2017-12-25 23:12:52 +01:00
|
|
|
return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">'
|
2021-07-22 21:22:21 +02:00
|
|
|
. icon($boolean ? 'check-lg' : 'x-lg')
|
2017-12-25 23:12:52 +01:00
|
|
|
. '</span>';
|
2014-09-28 14:50:08 +02:00
|
|
|
}
|
|
|
|
|
2017-01-03 03:22:48 +01:00
|
|
|
/**
|
|
|
|
* @param string $class
|
|
|
|
* @param array $content
|
|
|
|
* @param string $dom_id
|
|
|
|
* @return string
|
|
|
|
*/
|
2017-01-03 14:12:17 +01:00
|
|
|
function div($class, $content = [], $dom_id = '')
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
|
|
|
if (is_array($content)) {
|
|
|
|
$content = join("\n", $content);
|
|
|
|
}
|
|
|
|
$dom_id = $dom_id != '' ? ' id="' . $dom_id . '"' : '';
|
|
|
|
return '<div' . $dom_id . ' class="' . $class . '">' . $content . '</div>';
|
2014-08-23 01:55:18 +02:00
|
|
|
}
|
|
|
|
|
2017-01-03 03:22:48 +01:00
|
|
|
/**
|
|
|
|
* @param string $content
|
|
|
|
* @param int $number
|
|
|
|
* @return string
|
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function heading($content, $number = 1)
|
|
|
|
{
|
2017-01-03 14:12:17 +01:00
|
|
|
return '<h' . $number . '>' . $content . '</h' . $number . '>';
|
2014-12-16 03:38:30 +01:00
|
|
|
}
|
|
|
|
|
2017-01-03 03:22:48 +01:00
|
|
|
/**
|
|
|
|
* @param string[] $items
|
|
|
|
* @return string
|
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function toolbar_pills($items)
|
|
|
|
{
|
|
|
|
return '<ul class="nav nav-pills">' . join("\n", $items) . '</ul>';
|
2016-10-05 18:56:50 +02:00
|
|
|
}
|
|
|
|
|
2013-10-13 00:52:44 +02:00
|
|
|
/**
|
|
|
|
* Render a link for a toolbar.
|
2014-03-26 20:04:11 +01:00
|
|
|
*
|
2017-01-02 03:57:23 +01:00
|
|
|
* @param string $href
|
2021-04-17 14:49:53 +02:00
|
|
|
* @param string $icon
|
2017-01-02 03:57:23 +01:00
|
|
|
* @param string $label
|
2021-04-17 14:49:53 +02:00
|
|
|
* @param bool $active
|
2013-10-13 00:52:44 +02:00
|
|
|
* @return string
|
|
|
|
*/
|
2021-04-17 14:49:53 +02:00
|
|
|
function toolbar_item_link($href, $icon, $label, $active = false)
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2021-04-17 14:49:53 +02:00
|
|
|
return '<li class="nav-item">'
|
|
|
|
. '<a class="nav-link ' . ($active ? 'active' : '') . '" href="' . $href . '">'
|
|
|
|
. ($icon != '' ? '<span class="bi bi-' . $icon . '"></span> ' : '')
|
2017-01-03 03:22:48 +01:00
|
|
|
. $label
|
|
|
|
. '</a>'
|
|
|
|
. '</li>';
|
2014-08-22 22:34:13 +02:00
|
|
|
}
|
|
|
|
|
2021-04-17 14:49:53 +02:00
|
|
|
function toolbar_dropdown_item(string $href, string $label, bool $active, string $icon = null): string
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2021-04-17 14:49:53 +02:00
|
|
|
return strtr(
|
2021-07-22 21:22:21 +02:00
|
|
|
'<li><a class="dropdown-item{active}" href="{href}">{icon} {label}</a></li>',
|
2021-04-17 14:49:53 +02:00
|
|
|
[
|
|
|
|
'{href}' => $href,
|
2021-07-22 21:22:21 +02:00
|
|
|
'{icon}' => $icon === null ? '' : '<i class="bi bi-' . $icon . '"></i>',
|
2021-04-17 14:49:53 +02:00
|
|
|
'{label}' => $label,
|
|
|
|
'{active}' => $active ? ' active' : ''
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function toolbar_dropdown_item_divider(): string
|
|
|
|
{
|
|
|
|
return '<li><hr class="dropdown-divider"></li>';
|
2014-09-24 15:11:50 +02:00
|
|
|
}
|
|
|
|
|
2017-01-03 03:22:48 +01:00
|
|
|
/**
|
2021-04-17 14:49:53 +02:00
|
|
|
* @param string $icon
|
2017-01-03 03:22:48 +01:00
|
|
|
* @param string $label
|
|
|
|
* @param array $submenu
|
|
|
|
* @param string $class
|
|
|
|
* @return string
|
|
|
|
*/
|
2021-04-17 14:49:53 +02:00
|
|
|
function toolbar_dropdown($icon, $label, $submenu, $class = ''): string
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2021-04-17 14:49:53 +02:00
|
|
|
$template =<<<EOT
|
|
|
|
<li class="nav-item dropdown {class}">
|
|
|
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
|
|
{icon} {label}
|
|
|
|
</a>
|
|
|
|
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
|
|
|
{submenu}
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
EOT;
|
|
|
|
|
|
|
|
return strtr(
|
|
|
|
$template,
|
|
|
|
[
|
|
|
|
'{class}' => $class,
|
|
|
|
'{label}' => $label,
|
|
|
|
'{icon}' => empty($icon) ? '' : '<i class="bi ' . $icon . '"></i>',
|
|
|
|
'{submenu}' => join("\n", $submenu)
|
|
|
|
]
|
|
|
|
);
|
2014-08-23 02:16:12 +02:00
|
|
|
}
|
|
|
|
|
2017-01-03 03:22:48 +01:00
|
|
|
/**
|
2021-07-22 21:22:21 +02:00
|
|
|
* @param string $icon
|
2017-01-03 03:22:48 +01:00
|
|
|
* @param string $label
|
|
|
|
* @param string[] $content
|
|
|
|
* @param string $class
|
2021-07-22 21:22:21 +02:00
|
|
|
*
|
2017-01-03 03:22:48 +01:00
|
|
|
* @return string
|
|
|
|
*/
|
2021-07-22 21:22:21 +02:00
|
|
|
function toolbar_popover($icon, $label, $content, $class = '')
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2021-07-22 21:22:21 +02:00
|
|
|
$dom_id = md5(microtime() . $icon . $label);
|
2021-07-24 12:38:23 +02:00
|
|
|
return '<li class="nav-item nav-item--userhints d-flex align-items-center ' . $class . '">'
|
|
|
|
. '<a id="' . $dom_id . '" href="#" tabindex="0" class="nav-link">'
|
2021-07-22 21:22:21 +02:00
|
|
|
. ($icon ? icon($icon) : '')
|
2017-01-03 03:22:48 +01:00
|
|
|
. $label
|
2021-07-24 12:38:23 +02:00
|
|
|
. '<small class="bi bi-caret-down-fill"></small>'
|
|
|
|
. '</a>'
|
2020-05-13 18:26:32 +02:00
|
|
|
. '<script type="text/javascript">
|
2021-07-24 12:38:23 +02:00
|
|
|
new bootstrap.Popover(document.getElementById(\'' . $dom_id . '\'), {
|
|
|
|
container: \'body\',
|
|
|
|
html: true,
|
|
|
|
content: \'' . addslashes(join('', $content)) . '\',
|
|
|
|
placement: \'bottom\',
|
|
|
|
customClass: \'popover--userhints\'
|
|
|
|
})
|
2020-05-13 18:26:32 +02:00
|
|
|
</script></li>';
|
2014-12-06 22:26:56 +01:00
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
2013-10-13 00:52:44 +02:00
|
|
|
* Generiert HTML Code für eine "Seite".
|
|
|
|
* Fügt dazu die übergebenen Elemente zusammen.
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param string[] $elements
|
|
|
|
* @return string
|
2011-12-21 22:20:06 +01:00
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function page($elements)
|
|
|
|
{
|
|
|
|
return join($elements);
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
2014-08-22 22:34:13 +02:00
|
|
|
/**
|
|
|
|
* Generiert HTML Code für eine "Seite" mit zentraler Überschrift
|
|
|
|
* Fügt dazu die übergebenen Elemente zusammen.
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param string $title
|
|
|
|
* @param string[] $elements
|
2019-12-14 10:35:42 +01:00
|
|
|
* @param bool $container
|
2017-01-03 03:22:48 +01:00
|
|
|
* @return string
|
2014-08-22 22:34:13 +02:00
|
|
|
*/
|
2019-12-14 10:35:42 +01:00
|
|
|
function page_with_title($title, $elements, bool $container = false)
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2019-12-14 10:35:42 +01:00
|
|
|
if ($container) {
|
|
|
|
$html = '<div class="container">';
|
|
|
|
} else {
|
|
|
|
$html = '<div class="col-md-12">';
|
|
|
|
}
|
|
|
|
return $html . '<h1>' . $title . '</h1>' . join($elements) . '</div>';
|
2014-08-22 22:34:13 +02:00
|
|
|
}
|
|
|
|
|
2017-11-24 10:02:52 +01:00
|
|
|
/**
|
|
|
|
* Renders a description based on the data arrays key and values as label an description.
|
2017-12-25 23:12:52 +01:00
|
|
|
*
|
2017-11-24 10:02:52 +01:00
|
|
|
* @param array $data
|
2017-12-25 23:12:52 +01:00
|
|
|
* @return string
|
2017-11-24 10:02:52 +01:00
|
|
|
*/
|
2017-12-25 23:12:52 +01:00
|
|
|
function description($data)
|
|
|
|
{
|
2017-11-24 10:02:52 +01:00
|
|
|
$elements = [];
|
2017-12-25 23:12:52 +01:00
|
|
|
foreach ($data as $label => $description) {
|
|
|
|
if (!empty($label) && !empty($description)) {
|
2017-11-24 10:02:52 +01:00
|
|
|
$elements[] = '<dt>' . $label . '</dt><dd>' . $description . '</dd>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '<dl class="dl-horizontal">' . join($elements) . '</dl>';
|
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Rendert eine Datentabelle
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param array|string $columns
|
|
|
|
* @param array[] $rows_raw
|
|
|
|
* @param bool $data
|
|
|
|
* @return string
|
2011-12-21 22:20:06 +01:00
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function table($columns, $rows_raw, $data = true)
|
|
|
|
{
|
|
|
|
// If only one column is given
|
2017-01-02 15:43:36 +01:00
|
|
|
if (!is_array($columns)) {
|
|
|
|
$rows = [];
|
|
|
|
foreach ($rows_raw as $row) {
|
|
|
|
$rows[] = [
|
|
|
|
'col' => $row
|
|
|
|
];
|
|
|
|
}
|
|
|
|
return render_table([
|
|
|
|
'col' => $columns
|
|
|
|
], $rows, $data);
|
|
|
|
}
|
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
return render_table($columns, $rows_raw, $data);
|
2016-09-30 17:38:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for rendering a html-table.
|
|
|
|
* use table()
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param string[] $columns
|
|
|
|
* @param array[] $rows
|
|
|
|
* @param bool $data
|
|
|
|
* @return string
|
2016-09-30 17:38:26 +02:00
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function render_table($columns, $rows, $data = true)
|
|
|
|
{
|
|
|
|
if (count($rows) == 0) {
|
2018-08-29 21:55:32 +02:00
|
|
|
return info(__('No data found.'), true);
|
2017-01-02 03:57:23 +01:00
|
|
|
}
|
2017-01-02 15:43:36 +01:00
|
|
|
|
2017-01-02 03:57:23 +01:00
|
|
|
$html = '<table class="table table-striped' . ($data ? ' data' : '') . '">';
|
|
|
|
$html .= '<thead><tr>';
|
2016-09-29 11:28:42 +02:00
|
|
|
foreach ($columns as $key => $column) {
|
2017-01-02 03:57:23 +01:00
|
|
|
$html .= '<th class="column_' . $key . '">' . $column . '</th>';
|
2016-09-29 11:28:42 +02:00
|
|
|
}
|
2017-01-02 03:57:23 +01:00
|
|
|
$html .= '</tr></thead>';
|
|
|
|
$html .= '<tbody>';
|
|
|
|
foreach ($rows as $row) {
|
|
|
|
$html .= '<tr>';
|
|
|
|
foreach ($columns as $key => $column) {
|
|
|
|
$value = " ";
|
|
|
|
if (isset($row[$key])) {
|
|
|
|
$value = $row[$key];
|
|
|
|
}
|
|
|
|
$html .= '<td class="column_' . $key . '">' . $value . '</td>';
|
|
|
|
}
|
|
|
|
$html .= '</tr>';
|
|
|
|
}
|
|
|
|
$html .= '</tbody>';
|
|
|
|
$html .= '</table>';
|
|
|
|
return $html;
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert einen Knopf
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param string $href
|
|
|
|
* @param string $label
|
|
|
|
* @param string $class
|
|
|
|
* @return string
|
2011-12-21 22:20:06 +01:00
|
|
|
*/
|
2017-01-03 14:12:17 +01:00
|
|
|
function button($href, $label, $class = '')
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2021-07-23 01:52:19 +02:00
|
|
|
return '<a href="' . $href . '" class="btn btn-primary ' . $class . '">' . $label . '</a>';
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|
|
|
|
|
2017-12-13 17:50:52 +01:00
|
|
|
/**
|
|
|
|
* Rendert einen Knopf mit JavaScript onclick Handler
|
|
|
|
*
|
|
|
|
* @param string $javascript
|
|
|
|
* @param string $label
|
|
|
|
* @param string $class
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function button_js($javascript, $label, $class = '')
|
|
|
|
{
|
2021-07-23 01:52:19 +02:00
|
|
|
return '<a onclick="' . $javascript . '" href="#" class="btn btn-primary ' . $class . '">' . $label . '</a>';
|
2017-12-13 17:50:52 +01:00
|
|
|
}
|
|
|
|
|
2014-12-06 17:41:16 +01:00
|
|
|
/**
|
2021-07-22 21:22:21 +02:00
|
|
|
* Renders a button with an icon
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param string $href
|
2021-07-22 21:22:21 +02:00
|
|
|
* @param string $icon
|
2017-01-03 03:22:48 +01:00
|
|
|
* @param string $class
|
2021-07-22 21:22:21 +02:00
|
|
|
*
|
2017-01-03 03:22:48 +01:00
|
|
|
* @return string
|
2014-12-06 17:41:16 +01:00
|
|
|
*/
|
2021-07-22 21:22:21 +02:00
|
|
|
function button_icon($href, $icon, $class = '')
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2021-07-22 21:22:21 +02:00
|
|
|
return button($href, icon($icon), $class);
|
2014-12-06 22:26:56 +01:00
|
|
|
}
|
2014-12-06 17:41:16 +01:00
|
|
|
|
2019-05-05 15:23:13 +02:00
|
|
|
/**
|
|
|
|
* Rendert einen Knopf, der zur Hilfe eines bestimmten Themas führt.
|
2019-05-31 04:03:19 +02:00
|
|
|
*
|
2019-05-05 15:23:13 +02:00
|
|
|
* @param string $topic documentation resource (like user/), is appended to documentation url.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function button_help($topic = '')
|
|
|
|
{
|
2021-07-22 21:22:21 +02:00
|
|
|
return button(config('documentation_url') . $topic, icon('question-circle'), 'btn-sm');
|
2019-05-05 15:23:13 +02:00
|
|
|
}
|
|
|
|
|
2011-12-21 22:20:06 +01:00
|
|
|
/**
|
|
|
|
* Rendert eine Toolbar mit Knöpfen
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param array $buttons
|
|
|
|
* @return string
|
2011-12-21 22:20:06 +01:00
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function buttons($buttons = [])
|
|
|
|
{
|
|
|
|
return '<div class="form-group">' . table_buttons($buttons) . '</div>';
|
2014-09-28 14:50:08 +02:00
|
|
|
}
|
|
|
|
|
2017-01-03 03:22:48 +01:00
|
|
|
/**
|
|
|
|
* @param array $buttons
|
|
|
|
* @return string
|
|
|
|
*/
|
2017-01-02 03:57:23 +01:00
|
|
|
function table_buttons($buttons = [])
|
|
|
|
{
|
|
|
|
return '<div class="btn-group">' . join(' ', $buttons) . '</div>';
|
2011-12-21 22:20:06 +01:00
|
|
|
}
|