summaryrefslogtreecommitdiff
path: root/includes/view/UserHintsRenderer.php
blob: 30281ea0e2618c6645170d483f486c06310fa7c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?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;
              $this->hints[] = error($hint, true);
          } else {
              $this->hints[] = info($hint, true);
          }
      }
  }

  /**
   * 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;
  }
}