glpi / src / Vigilo / VigiloXml.php @ e809466b
History | View | Annotate | Download (792 Bytes)
1 |
<?php
|
---|---|
2 |
|
3 |
abstract class VigiloXml |
4 |
{ |
5 |
abstract public function __toString(); |
6 |
|
7 |
public static function sprintf($s) |
8 |
{ |
9 |
$args = func_get_args(); |
10 |
array_shift($args); // pop $s |
11 |
|
12 |
$new_args = array(); |
13 |
foreach ($args as $arg) { |
14 |
if (is_string($arg)) { |
15 |
$new_args[] = htmlspecialchars($arg, ENT_XML1 | ENT_QUOTES, "utf-8"); |
16 |
} elseif (is_array($arg)) { |
17 |
$acc = ''; |
18 |
foreach ($arg as $sub) { |
19 |
if (is_object($sub)) { |
20 |
$acc .= (string) $sub; |
21 |
} |
22 |
} |
23 |
$new_args[] = $acc; |
24 |
} else {
|
25 |
$new_args[] = (string) $arg; |
26 |
} |
27 |
} |
28 |
|
29 |
return vsprintf($s, $new_args); |
30 |
} |
31 |
} |