Exemplo n.º 1
0
 protected function parseArgs($args)
 {
     $attributes = array();
     $content = '';
     foreach ($args as $arg) {
         if (is_string($arg)) {
             $content .= $this->escape($arg);
         } else {
             if (is_array($arg)) {
                 foreach ($arg as $key => $subArg) {
                     if (is_numeric($key)) {
                         list($subattributes, $subcontent) = $this->parseArgs($subArg);
                         $attributes = array_merge($attributes, $subattributes);
                         $content = \arc\xml::raw($content . $subcontent);
                     } else {
                         $attributes[$key] = $subArg;
                     }
                 }
             } else {
                 $content .= $arg;
             }
         }
     }
     return [$attributes, $content];
 }
Exemplo n.º 2
0
    function testXMLWriterEscaping()
    {
        $xml = \arc\xml::item(['class' => 'in"valid<stuff>', 'inva"lid' => "this is \n just wrong"], "Escape me\" < really &copy;" . chr(8), \arc\xml::subitem(\arc\xml::raw("<subsubitem>this should work</subsubsubitem>")));
        $expectedValue = <<<EOF
<item class="in&quot;valid&lt;stuff&gt;" invalid="this is 
 just wrong">
\tEscape me" &lt; really &amp;copy;<subitem>
\t\t<subsubitem>this should work</subsubsubitem>
\t</subitem>
</item>
EOF;
        $this->assertEquals($expectedValue, (string) $xml);
    }