1 <?php
3 class msgPool
4 {
5 public static function permDelete($name= "")
6 {
7 if ($name == "") {
8 return (_("You have no permission to delete this object!"));
9 }
11 if (!is_array($name)){
12 return (_("You have no permission to delete the object:")."<br><br><i>$name</i>");
13 }
15 msgPool::buildList($name);
16 if (count($name) == 1){
17 return (_("You have no permission to delete the object:")."<br>".msgPool::buildList($name));
18 }
20 return (_("You have no permission to delete these objects:")."<br>".msgPool::buildList($name));
21 }
24 public static function permCreate($name= "")
25 {
26 if ($name == "") {
27 return (_("You have no permission to create this object!"));
28 }
30 if (!is_array($name)){
31 return (_("You have no permission to create the object:")."<br><br><i>$name</i>");
32 }
34 if (count($name) == 1){
35 return (_("You have no permission to create the object:")."<br>".msgPool::buildList($name));
36 }
38 return (_("You have no permission to create these objects:")."<br>".msgPool::buildList($name));
39 }
42 public static function permModify($name= "")
43 {
44 if ($name == "") {
45 return (_("You have no permission to modify this object!"));
46 }
48 if (!is_array($name)){
49 return (_("You have no permission to modify the object:")."<br><br><i>$name</i>");
50 }
52 if (count($name) == 1){
53 return (_("You have no permission to modify the object:")."<br>".msgPool::buildList($name));
54 }
56 return (_("You have no permission to modify these objects:")."<br>".msgPool::buildList($name));
57 }
60 public static function permView($name= "")
61 {
62 if ($name == "") {
63 return (_("You have no permission to view this object!"));
64 }
66 if (!is_array($name)){
67 return (_("You have no permission to view the object:")."<br><br><i>$name</i>");
68 }
70 if (count($name) == 1){
71 return (_("You have no permission to view the object:")."<br>".msgPool::buildList($name));
72 }
74 return (_("You have no permission to view these objects:")."<br>".msgPool::buildList($name));
75 }
78 public static function permMove($name= "")
79 {
80 if ($name == "") {
81 return (_("You have no permission to move this object!"));
82 }
84 if (!is_array($name)){
85 return (_("You have no permission to move the object:")."<br><br><i>$name</i>");
86 }
88 if (count($name) == 1){
89 return (_("You have no permission to move the object:")."<br>".msgPool::buildList($name));
90 }
92 return (_("You have no permission to move these objects:")."<br>".msgPool::buildList($name));
93 }
96 public static function dbconnect($name, $error= "", $dbinfo= "")
97 {
98 if ($error != ""){
99 $error= "<br><br><i>"._("Error").":</i> ".$error;
100 }
101 if ($dbinfo != ""){
102 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
103 }
104 return (sprintf(_("Cannot connect to server %s!"), $name).$error);
105 }
108 public static function dbselect($name, $error= "", $dbinfo= "")
109 {
110 if ($error != ""){
111 $error= "<br><br><i>"._("Error").":</i> ".$error;
112 }
113 if ($dbinfo != ""){
114 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
115 }
116 return (sprintf(_("Cannot select %s database!"), $name).$error);
117 }
120 public static function dbquery($name, $error= "", $dbinfo= "")
121 {
122 if ($error != ""){
123 $error= "<br><br><i>"._("Error").":</i> ".$error;
124 }
125 if ($dbinfo != ""){
126 $error.= "<br><br><i>"._("Connection information").":</i> ".$dbinfo;
127 }
128 return (sprintf(_("Cannot query %s database!"), $name).$error);
129 }
132 public static function reserved($name)
133 {
134 return (sprintf(_("The field '%s' contains a reserved keyword!"), $name));
135 }
138 public static function cmdnotfound($type, $plugin)
139 {
140 return (sprintf(_("Command specified as %s hook for plugin '%s' does not exist!"), $type, $plugin));
141 }
144 public static function toobig($name, $min= "")
145 {
146 if ($min == ""){
147 return (sprintf(_("Value for '%s' is too big!"), $name));
148 } else {
149 return (sprintf(_("'%s' must be smaller than %d!"), $name, $min));
150 }
151 }
154 public static function toosmall($name, $min= "")
155 {
156 if ($min == ""){
157 return (sprintf(_("Value for '%s' is too small!"), $name));
158 } else {
159 return (sprintf(_("'%s' must be %d or above!"), $name, $min));
160 }
161 }
164 public static function bigger($name1, $name2)
165 {
166 return (sprintf(_("'%s' should be bigger than '%s'!"), $name1, $name2));
167 }
170 public static function smaller($name1, $name2)
171 {
172 return (sprintf(_("'%s' should be smaller than '%s'!"), $name1, $name2));
173 }
176 public static function depends($name1, $name2)
177 {
178 return (sprintf(_("'%s' depends on '%s' - please provide both values!"), $name1, $name2));
179 }
182 public static function duplicated($name)
183 {
184 return (sprintf(_("There is already an entry with this '%s' attribute in the system!"), $name));
185 }
188 public static function required($name)
189 {
190 return (sprintf(_("The required field '%s' is empty!"), $name));
191 }
194 public static function invalid($name, $data= "", $regex= "", $example= "")
195 {
196 /* Stylize example */
197 if ($example != ""){
198 $example= "<br><br><i>"._("Example").":</i> ".$example;
199 }
201 /* If validChars are posted, take data and paint all invalid
202 characters... */
203 if ($regex) {
204 $result= "";
205 $mismatch= "";
206 foreach (str_split($data) as $currentChar){
207 if (preg_match("$regex", $currentChar)){
208 $result.= $currentChar;
209 } else {
210 $result.= "<font style='color:red;text-decoration:underline;'>".htmlentities($currentChar)."</font>";
211 $mismatch.= $currentChar;
212 }
213 }
215 return sprintf(_("The Field '%s' contains invalid characters"), $name).". ".
216 (strlen($mismatch)==1?sprintf(_("'%s' is not allowed:"), htmlentities($mismatch)):sprintf(_("'%s' are not allowed."), htmlentities($mismatch))).
217 "<br><br> \"$result\"$example";
218 } else {
219 return sprintf(_("The Field '%s' contains invalid characters"), $name)."!$example";
220 }
221 }
224 public static function missingext($name)
225 {
226 return sprintf(_("Missing %s PHP extension!"), $name);
227 }
230 public static function cancelButton()
231 {
232 return sprintf(_("Cancel"));
233 }
236 public static function okButton()
237 {
238 return sprintf(_("Ok"));
239 }
242 public static function applyButton()
243 {
244 return sprintf(_("Apply"));
245 }
248 public static function saveButton()
249 {
250 return sprintf(_("Save"));
251 }
254 public static function addButton($what= "")
255 {
256 return $what == "" ? sprintf(_("Add")): sprintf(_("Add %s"), $what);
257 }
260 public static function delButton($what= "")
261 {
262 return $what == "" ? sprintf(_("Delete")): sprintf(_("Delete %s"), $what);
263 }
266 public static function setButton($what= "")
267 {
268 return $what == "" ? sprintf(_("Set")): sprintf(_("Set %s"), $what);
269 }
272 public static function editButton($what= "")
273 {
274 return $what == "" ? sprintf(_("Edit...")): sprintf(_("Edit %s..."), $what);
275 }
278 public static function buildList($data)
279 {
280 $objects= "";
281 foreach ($name as $key => $value){
282 if (is_numeric($key)){
283 $objects.= "<br>\n<i>$value</i>";
284 } else {
285 $objects.= "<br>\n$value (<i>$key</i>)";
286 }
287 }
288 }
291 }