Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- #=======================================================================
- #**Narzew Script
- #**class.Error.php
- #**Narzew
- #**15.07.2014
- #**License: GPL
- #=======================================================================
- #**This file contains errors interpreting
- #=======================================================================
- #**PRIVATE VARIABLES: $errors, $error_count
- #**STATIC FUNCTIONS:
- #**clear - clears the error variables to next use
- #**add_error($text) - add an error to $errors variable
- #**get_error_count - returns error count
- #**get_errors($show_if_zero) - get formated errors string:
- #****$show_if_zero(default:false) - show errors if count = 0
- #****$print(default:true) - print errors instead of returning
- #**has_errors - checks that any errors are added
- #=======================================================================
- class Error {
- private static $errors;
- private static $error_count;
- static function clear(){
- self::$errors = "";
- self::$error_count = 0;
- }
- static function add_error($text){
- self::$errors = self::$errors."<li>".$text."</li>";
- self::$error_count = self::$error_count + 1;
- }
- static function get_error_count(){
- return self::$error_count;
- }
- static function get_errors($show_if_zero=false,$print=true){
- $tmp_str = "";
- if (self::$error_count == 0){
- if($show_if_zero==true){
- $tmp_str = "Nie wystąpił żaden błąd";
- } else {
- if($print == true){
- echo "";
- } else {
- return "";
- }
- }
- } elseif (self::$error_count == 1){
- $tmp_str = "Wystąpił 1 błąd:\n";
- $tmp_error = self::$error_count;
- } elseif (self::$error_count == 2 || $error_count == 3){
- $tmp_error = self::$error_count;
- $tmp_str = "Wystąpiły $tmp_error błędy:\n";
- } else {
- $tmp_error = self::$error_count;
- $tmp_str = "Wystąpiło $tmp_error błędów:\n";
- }
- if($tmp_str != ""){
- if($print == true){
- print $tmp_str.self::$errors;
- } else {
- return $tmp_str.self::$errors;
- }
- }
- }
- static function has_errors(){
- if(self::$error_count == 0){
- return false;
- } else {
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement