engelsystem/includes/view/UserHintsRenderer.php

59 lines
1.2 KiB
PHP
Raw Normal View History

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