.
*/
namespace Fisharebest\Webtrees;
/**
* Helper functions to generate markup for Bootstrap 4.
*
* @deprecated Replace with view('components/...')
*/
class Bootstrap4 extends Html
{
/**
* Generate a badge containing a count of items.
*
* @param array $items
*
* @return string
*/
public static function badgeCount(array $items)
{
if (empty($items)) {
return '';
} else {
return '' . I18N::number(count($items)) . '';
}
}
/**
* Generate a checkbox.
*
* @param string $label
* @param bool $inline
* @param string[] $attributes
*
* @return string
*/
public static function checkbox($label, $inline, $attributes = []): string
{
if ($inline) {
$class = 'form-check form-check-inline';
} else {
$class = 'form-check';
}
$input_attributes = self::attributes([
'class' => 'form-check-input',
'type' => 'checkbox',
'value' => '1',
] + $attributes);
return
'
' .
' ' . e($label) .
'' .
'
';
}
/**
* Create a set of radio buttons for a form
*
* @param string $name The ID for the form element
* @param string[] $values Array of value=>display items
* @param string|null $selected The currently selected item
* @param bool $inline
* @param string[] $attributes
*
* @return string
*/
public static function radioButtons($name, $values, $selected, $inline, $attributes = []): string
{
// An empty string is not the same as zero (but is the same as NULL).
if ($selected === null) {
$selected = '0';
}
if ($inline) {
$class = 'form-check form-check-inline';
} else {
$class = 'form-check';
}
$html = '';
foreach ($values as $value => $label) {
$input_attributes = self::attributes([
'class' => 'form-check-input',
'type' => 'radio',
'name' => $name,
'value' => $value,
'checked' => (string)$value === (string)$selected,
] + $attributes);
$html .=
'