1 <?php
3 class msgPool
4 {
5 public static function dbconnect($name, $error= "", $dbinfo= "")
6 {
7 if ($error != ""){
8 $error= "<br><br><i>"._("Error").":</i> ".$error;
9 }
10 if ($dbinfo != ""){
11 $error= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
12 }
13 return (sprintf(_("Cannot connect to %s database!"), $name).$error);
14 }
17 public static function dbselect($name, $error= "", $dbinfo= "")
18 {
19 if ($error != ""){
20 $error= "<br><br><i>"._("Error").":</i> ".$error;
21 }
22 if ($dbinfo != ""){
23 $error= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
24 }
25 return (sprintf(_("Cannot select %s database!"), $name).$error);
26 }
29 public static function dbquery($name, $error= "", $dbinfo= "")
30 {
31 if ($error != ""){
32 $error= "<br><br><i>"._("Error").":</i> ".$error;
33 }
34 if ($dbinfo != ""){
35 $error= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
36 }
37 return (sprintf(_("Cannot query %s database!"), $name).$error);
38 }
41 public static function reserved($name)
42 {
43 return (sprintf(_("The field '%s' contains a reserved keyword!"), $name));
44 }
47 public static function cmdnotfound($type, $plugin)
48 {
49 return (sprintf(_("Command specified as %s hook for plugin '%s' does not exist!"), $type, $plugin));
50 }
53 public static function toobig($name, $min= "")
54 {
55 if ($min == ""){
56 return (sprintf(_("Value for '%s' is too big!"), $name));
57 } else {
58 return (sprintf(_("'%s' must be smaller than %d!"), $name, $min));
59 }
60 }
63 public static function toosmall($name, $min= "")
64 {
65 if ($min == ""){
66 return (sprintf(_("Value for '%s' is too small!"), $name));
67 } else {
68 return (sprintf(_("'%s' must be %d or above!"), $name, $min));
69 }
70 }
73 public static function bigger($name1, $name2)
74 {
75 return (sprintf(_("'%s' should be bigger than '%s'!"), $name1, $name2));
76 }
79 public static function smaller($name1, $name2)
80 {
81 return (sprintf(_("'%s' should be smaller than '%s'!"), $name1, $name2));
82 }
85 public static function depends($name1, $name2)
86 {
87 return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
88 }
91 public static function duplicated($name)
92 {
93 return (sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name));
94 }
97 public static function required($name)
98 {
99 return (sprintf(_("The required field '%s' is empty!"), $name));
100 }
103 public static function invalid($name, $data= "", $regex= "", $example= "")
104 {
105 /* Stylize example */
106 if ($example != ""){
107 $example= "<br><br><i>"._("Example").":</i> ".$example;
108 }
110 /* If validChars are posted, take data and paint all invalid
111 characters... */
112 if ($regex) {
113 $result= "";
114 $mismatch= "";
115 foreach (str_split($data) as $currentChar){
116 if (preg_match("$regex", $currentChar)){
117 $result.= $currentChar;
118 } else {
119 $result.= "<font style='color:red;text-decoration:underline;'>".htmlentities($currentChar)."</font>";
120 $mismatch.= $currentChar;
121 }
122 }
124 return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
125 (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed."), htmlentities($mismatch))).
126 "<br><br> \"$result\"$example";
127 } else {
128 return sprintf(_("The Field '%s' contains invalid characters"), $name)."!$example";
129 }
130 }
133 public static function missingext($name)
134 {
135 return sprintf(_("Missing %s PHP extension!"), $name);
136 }
139 public static function cancelButton()
140 {
141 return sprintf(_("Cancel"));
142 }
145 public static function okButton()
146 {
147 return sprintf(_("Ok"));
148 }
151 public static function applyButton()
152 {
153 return sprintf(_("Apply"));
154 }
157 public static function saveButton()
158 {
159 return sprintf(_("Save"));
160 }
163 public static function addButton($what= "")
164 {
165 return $what == "" ? sprintf(_("Add"): sprintf(_("Add %s"), $what));
166 }
169 public static function delButton($what= "")
170 {
171 return $what == "" ? sprintf(_("Delete"): sprintf(_("Delete %s"), $what));
172 }
175 public static function setButton($what= "")
176 {
177 return $what == "" ? sprintf(_("Set"): sprintf(_("Set %s"), $what));
178 }
181 public static function editButton($what= "")
182 {
183 return $what == "" ? sprintf(_("Edit..."): sprintf(_("Edit %s..."), $what));
184 }
186 }