Code

Moved
[gosa.git] / gosa-core / include / utils / class_msgPool.inc
1 <?php
3 class msgPool
4 {
6   public static function toobig($name, $min= "")
7   {
8     if ($min == ""){
9       return (sprintf(_("Value for '%s' is too big!"), $name));
10     } else {
11       return (sprintf(_("'%s' must be smaller than %d!"), $name, $min));
12     }
13   }
16   public static function toosmall($name, $min= "")
17   {
18     if ($min == ""){
19       return (sprintf(_("Value for '%s' is too small!"), $name));
20     } else {
21       return (sprintf(_("'%s' must be %d or above!"), $name, $min));
22     }
23   }
26   public static function bigger($name1, $name2)
27   {
28     return (sprintf(_("'%s' should be bigger than '%s'!"), $name1, $name2));
29   }
32   public static function smaller($name1, $name2)
33   {
34     return (sprintf(_("'%s' should be smaller than '%s'!"), $name1, $name2));
35   }
38   public static function depends($name1, $name2)
39   {
40     return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
41   }
44   public static function duplicated($name)
45   {
46     return (sprintf(_("There is already an entry named '%s' in the system!"), $name));
47   }
50   public static function required($name)
51   {
52     return (sprintf(_("The required field '%s' is empty!"), $name));
53   }
56   public static function invalid($name, $data= "", $regex= "", $example= "")
57   {
58     /* Stylize example */
59     if ($example != ""){
60       $example= "<br><br>"._("Example:")." ".$example;
61     }
63     /* If validChars are posted, take data and paint all invalid
64        characters... */
65     if ($regex) {
66       $result= "";
67       $mismatch= "";
68       foreach (str_split($data) as $currentChar){
69         if (preg_match("$regex", $currentChar)){
70           $result.= $currentChar;
71         } else {
72           $result.= "<font style='color:red;'>".htmlentities($currentChar)."</font>";
73           $mismatch.= $currentChar;
74         }
75       }
77       return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
78              (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed."), htmlentities($mismatch))).
79              "<br><br> \"$result\"$example";
80     } else {
81       return sprintf(_("The Field '%s' contains invalid characters"), $name)."!$example";
82     }
83   }
85 }