summaryrefslogtreecommitdiffstats
path: root/inc/message.inc.php
blob: 238ed939515f638a8a7362b618b5a4dab79e389a (plain) (blame)
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
<?php

// TODO: Move to extra file
$error_text = array(
	'loginfail'      => 'Benutzername oder Kennwort falsch',
	'token'          => 'Ungültiges Token. CSRF Angriff?',
);

class Message
{
	private static $list = array();

	public static function addError($id)
	{
		self::$list[] = array(
			'type' => 'error',
			'id'    => $id
		);
	}

	public static function addWarning($id)
	{
		self::$list[] = array(
			'type' => 'warning',
			'id'    => $id
		);
	}

	public static function addInfo($id)
	{
		self::$list[] = array(
			'type' => 'info',
			'id'    => $id
		);
	}

	public static function addSuccess($id)
	{
		self::$list[] = array(
			'type' => 'success',
			'id'    => $id
		);
	}

	public static function renderList()
	{
		global $error_text;
		foreach (self::$list as $item) {
			Render::addTemplate('messagebox-' . $item['type'], array('message' => $error_text[$item['id']]));
		}
	}

}