You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
engelsystem/includes/view/UserHintsRenderer.php

62 lines
1.3 KiB
PHTML

<?php
namespace Engelsystem;
8 years ago
class UserHintsRenderer
{
private $hints = [];
8 years ago
private $important = false;
/**
* Render the added hints to a popover for the toolbar.
*/
8 years ago
public function render()
{
if (count($this->hints) > 0) {
$hint_class = $this->important ? 'danger' : 'info';
$glyphicon = $this->important ? 'warning-sign' : 'info-sign';
8 years ago
return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class);
}
8 years ago
return '';
}
/**
* Add a hint to the list, if its not null and a not empty string.
*
* @param string $hint
* The hint
* @param boolean $important
* Is the hint important?
*/
8 years ago
public function addHint($hint, $important = false)
{
if ($hint != null && $hint != '') {
if ($important) {
$this->important = true;
$this->hints[] = error($hint, true);
} else {
$this->hints[] = info($hint, true);
}
}
}
/**
* Get all hints.
*/
8 years ago
public function getHints()
{
return $this->hints;
}
/**
* Are there important hints? This leads to a more intensive icon.
*/
8 years ago
public function isImportant()
{
return $this->important;
}
}