glpi / src / plugins / vigilo / Vigilo / VigiloXml.php @ 7101a8d8
History | View | Annotate | Download (792 Bytes)
1 | bef4271a | Thibault Louet | <?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 | a5c9df40 | Thibault Louet | } elseif (is_array($arg)) { |
17 | bef4271a | Thibault Louet | $acc = ''; |
18 | foreach ($arg as $sub) { |
||
19 | a5c9df40 | Thibault Louet | if (is_object($sub)) { |
20 | bef4271a | Thibault Louet | $acc .= (string) $sub; |
21 | a5c9df40 | Thibault Louet | } |
22 | bef4271a | Thibault Louet | } |
23 | $new_args[] = $acc; |
||
24 | } else {
|
||
25 | $new_args[] = (string) $arg; |
||
26 | } |
||
27 | } |
||
28 | |||
29 | return vsprintf($s, $new_args); |
||
30 | } |
||
31 | } |