1 | <?php |
||||||||||
2 | namespace Inji; |
||||||||||
3 | /** |
||||||||||
4 | * Msg |
||||||||||
5 | * |
||||||||||
6 | * @author Alexey Krupskiy <[email protected]> |
||||||||||
7 | * @link http://inji.ru/ |
||||||||||
8 | * @copyright 2015 Alexey Krupskiy |
||||||||||
9 | * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
||||||||||
10 | */ |
||||||||||
11 | class Msg extends Module { |
||||||||||
12 | |||||||||||
13 | /** |
||||||||||
14 | * Add message to query |
||||||||||
15 | * |
||||||||||
16 | * @param string $text |
||||||||||
17 | * @param string $status |
||||||||||
18 | */ |
||||||||||
19 | public static function add($text = false, $status = 'info') { |
||||||||||
20 | if ($text !== false) { |
||||||||||
21 | if (!empty($_SESSION['_INJI_MSG'])) { |
||||||||||
22 | foreach ($_SESSION['_INJI_MSG'] as $key => $msg) { |
||||||||||
23 | if ($msg['text'] == $text) { |
||||||||||
24 | $msg['count']++; |
||||||||||
25 | return true; |
||||||||||
26 | } |
||||||||||
27 | } |
||||||||||
28 | } |
||||||||||
29 | $_SESSION['_INJI_MSG'][] = [ |
||||||||||
30 | 'text' => $text, |
||||||||||
31 | 'status' => $status, |
||||||||||
32 | 'count' => 1 |
||||||||||
33 | ]; |
||||||||||
34 | } |
||||||||||
35 | return true; |
||||||||||
36 | } |
||||||||||
37 | |||||||||||
38 | /** |
||||||||||
39 | * Show messages query |
||||||||||
40 | */ |
||||||||||
41 | public static function show() { |
||||||||||
42 | App::$cur->view->widget('msgList'); |
||||||||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() The method
widget() does not exist on Inji\Module . It seems like you code against a sub-type of Inji\Module such as Inji\View or Inji\Db .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The method
widget() does not exist on null .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||||||
43 | } |
||||||||||
44 | |||||||||||
45 | /** |
||||||||||
46 | * Get cur messages query |
||||||||||
47 | * |
||||||||||
48 | * @param boolean $clean |
||||||||||
49 | * @return array |
||||||||||
50 | */ |
||||||||||
51 | public static function get($clean = false) { |
||||||||||
52 | if (empty($_SESSION['_INJI_MSG'])) |
||||||||||
53 | return []; |
||||||||||
54 | $msgs = $_SESSION['_INJI_MSG']; |
||||||||||
55 | if ($clean) { |
||||||||||
56 | $_SESSION['_INJI_MSG'] = []; |
||||||||||
57 | } |
||||||||||
58 | return $msgs; |
||||||||||
59 | } |
||||||||||
60 | |||||||||||
61 | /** |
||||||||||
62 | * Clean messages query |
||||||||||
63 | */ |
||||||||||
64 | public static function flush() { |
||||||||||
65 | $_SESSION['_INJI_MSG'] = []; |
||||||||||
66 | } |
||||||||||
67 | |||||||||||
68 | } |
||||||||||
69 |