Ejemplo n.º 1
0
function wwwtokenize($subject, $pattern)
{
    $xml = new xml();
    if (preg_match_all("/({$pattern})/", $subject, $matches)) {
        foreach ($matches[1] as $string) {
            $xml->append($xml->text($string));
        }
    }
    return $xml->get();
}
Ejemplo n.º 2
0
 function documentation()
 {
     $xml = new xml();
     $methods = $xml->element('methods');
     $xml->append($methods);
     foreach ($this->methods as $url => $group) {
         foreach ($group->schema() as $schema) {
             list($type, $get, $post) = $schema;
             $method = $xml->element('method');
             $methods->append($method);
             $method['@id'] = str_pad(dechex(crc32("{$type}:{$url}:" . implode(':', array_keys($get)) . implode(':', array_keys($post)))), 8, '0', STR_PAD_LEFT);
             $method['@url'] = $url;
             $method['@type'] = strtoupper($type);
             foreach ($get as $name => $param) {
                 $g = $xml->element('get');
                 $g['@name'] = $name;
                 $g['@type'] = $param->type;
                 $g['@min'] = isset($param->min) ? $param->min : 'default (' . datatype::min($param->type) . ')';
                 $g['@max'] = isset($param->max) ? $param->max : 'default (' . datatype::max($param->type) . ')';
                 $g['@required'] = $param->required ? 'true' : 'false';
                 !isset($param->default) or $g['@default'] = $param->default;
                 !isset($param->domains) or $g['@domain'] = implode(', ', $param->domains);
                 $method->append($g);
             }
             foreach ($post as $name => $param) {
                 $p = $xml->element('post');
                 $p['@name'] = $name;
                 $p['@type'] = $param->type;
                 $p['@min'] = isset($param->min) ? $param->min : 'default (' . datatype::min($param->type) . ')';
                 $p['@max'] = isset($param->max) ? $param->max : 'default (' . datatype::max($param->type) . ')';
                 $p['@required'] = $param->required ? 'true' : 'false';
                 !isset($param->default) or $p['@default'] = $param->default;
                 !isset($param->domains) or $p['@domain'] = implode(', ', $param->domains);
                 $method->append($p);
             }
         }
     }
     $xslt = new XSLTProcessor();
     $xsl = new DOMDocument();
     $xsl->load(www_root . 'backend/documentation.xsl');
     $xslt->importStylesheet($xsl);
     $documentation = $xslt->transformToDoc($xml->get());
     return (object) ['code' => 200, 'message' => 'OK', 'headers' => ['Content-Type' => 'text/html'], 'body' => $documentation->saveXML()];
 }