addItem(self::$table, array('message' => $message, 'type' => $type, 'module' => $module, 'time' => time())); return $result; } public static function count($types = array('info', 'notice', 'warning', 'success')){ if(!empty($types)) { foreach($types as $type){ $where .= ' type=\''.$type.'\' OR'; } $where = 'WHERE '.substr($where, 0, -2); } else { $where = ''; } $res = self::$DB->query('SELECT id FROM `'.self::$table.'` '.$where); if($res){ return count($res); } else { return 0; } } public static function getEvents($types = array('error'), $limit = 10, $sort = 'DESC'){ $where = ''; if(!empty($types)) { foreach($types as $type){ $where .= ' type=\''.$type.'\' OR'; } $where = 'WHERE '.substr($where, 0, -2); } else { $where = ''; } $res = self::$DB->query('SELECT * FROM `'.self::$table.'` '.$where.' ORDER BY `id` '.$sort.' LIMIT '.$limit, [], true); if($res){ return $res; } else { return []; } } public static function typeToClassName($type){ $result = 'info'; switch($type) { case 'warning': $result = 'danger'; break; case 'info': $result = 'info'; break; case 'notice': $result = 'warning'; break; case 'success': $result = 'success'; break; } return $result; } public static function typeToRus($type){ $result = 'Уведомление'; switch($type) { case 'warning': $result = 'Ошибка'; break; case 'info': $result = 'Уведомление'; break; case 'notice': $result = 'Предупреждение'; break; case 'success': $result = 'Выполнено'; break; } return $result; } }