engelsystem/includes/view/UserHintsRenderer.php

62 lines
1.3 KiB
PHP
Raw Normal View History

2016-11-15 16:28:20 +01:00
<?php
namespace Engelsystem;
2017-01-02 03:57:23 +01:00
class UserHintsRenderer
{
private $hints = [];
2016-11-15 16:28:20 +01:00
2017-01-02 03:57:23 +01:00
private $important = false;
2016-11-15 16:28:20 +01:00
/**
* Render the added hints to a popover for the toolbar.
*/
2017-01-02 03:57:23 +01:00
public function render()
{
if (count($this->hints) > 0) {
$hint_class = $this->important ? 'danger' : 'info';
$glyphicon = $this->important ? 'warning-sign' : 'info-sign';
2016-11-15 16:28:20 +01:00
2017-01-02 03:57:23 +01:00
return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class);
}
2016-11-15 16:28:20 +01:00
2017-01-02 03:57:23 +01:00
return '';
2016-11-15 16:28:20 +01:00
}
/**
* 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?
*/
2017-01-02 03:57:23 +01:00
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);
}
2016-11-15 16:28:20 +01:00
}
}
/**
* Get all hints.
*/
2017-01-02 03:57:23 +01:00
public function getHints()
{
return $this->hints;
2016-11-15 16:28:20 +01:00
}
/**
* Are there important hints? This leads to a more intensive icon.
*/
2017-01-02 03:57:23 +01:00
public function isImportant()
{
return $this->important;
2016-11-15 16:28:20 +01:00
}
}