]> git.mxchange.org Git - friendica.git/commitdiff
hmmm - why won't poco xml work
authorFriendika <info@friendika.com>
Thu, 27 Oct 2011 08:54:52 +0000 (01:54 -0700)
committerFriendika <info@friendika.com>
Thu, 27 Oct 2011 08:54:52 +0000 (01:54 -0700)
include/api.php
include/text.php
mod/poco.php
view/poco_entry_xml.tpl [new file with mode: 0644]
view/poco_xml.tpl

index 1334d8eae78421778c8d683fd090d09ddd148974..d94cc2942ac071e7644f48857d590372fb2aa1b2 100644 (file)
                return $ret; 
        }
 
-       /**
-        * apply xmlify() to all values of array $val, recursively
-        */
-       function api_xmlify($val){
-               if (is_bool($val)) return $val?"true":"false";
-               if (is_array($val)) return array_map('api_xmlify', $val);
-               return xmlify((string) $val);
-       }
 
        /**
         *  load api $templatename for $type and replace $data array
                        case "atom":
                        case "rss":
                        case "xml":
-                               $data = api_xmlify($data);
+                               $data = array_xmlify($data);
                                $tpl = get_markup_template("api_".$templatename."_".$type.".tpl");
                                $ret = replace_macros($tpl, $data);
                                break;
index e0f38a3a0d4b8bf9ec53610459d7e0ca797f28b8..8ada179dc404bfe74ebefc0aab6ab9b387be2cc3 100644 (file)
@@ -1052,4 +1052,13 @@ function html2bb_video($s) {
                        '[vimeo]$2[/vimeo]', $s);
 
        return $s;
-}
\ No newline at end of file
+}
+
+/**
+ * apply xmlify() to all values of array $val, recursively
+ */
+function array_xmlify($val){
+       if (is_bool($val)) return $val?"true":"false";
+       if (is_array($val)) return array_map('array_xmlify', $val);
+       return xmlify((string) $val);
+}
index d0e32816e7066b46e37731983979471c39976282..c354be863d5d54a78004e86ab38c7ee64e6c6374 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 
-
 function poco_init(&$a) {
 
        if($a->argc > 1) {
@@ -67,9 +66,9 @@ function poco_init(&$a) {
        if(x($_GET,'updatedSince'))
                $ret['updateSince'] = 'false';
 
-       $ret['startIndex']   = $startIndex;
-       $ret['itemsPerPage'] = $itemsPerPage;
-       $ret['totalResults']  = $totalResults;
+       $ret['startIndex']   = (string) $startIndex;
+       $ret['itemsPerPage'] = (string) $itemsPerPage;
+       $ret['totalResults'] = (string) $totalResults;
        $ret['entry']        = array();
 
 
@@ -82,8 +81,8 @@ function poco_init(&$a) {
        );
 
        if((! x($_GET,'fields')) || ($_GET['fields'] === '@all'))
-               foreach($fields_ret as $f)
-                       $f = true;
+               foreach($fields_ret as $k => $v)
+                       $fields_ret[$k] = true;
        else {
                $fields_req = explode(',',$_GET['fields']);
                foreach($fields_req as $f)
@@ -115,9 +114,8 @@ function poco_init(&$a) {
 
        if($format === 'xml') {
                header('Content-type: text/xml');
-               echo replace_macros(get_markup_template('poco.xml',array('response' => $ret)));
+               echo replace_macros(get_markup_template('poco_xml.tpl',array_xmlify(array('$response' => $ret))));
                http_status_exit(500);
-
        }
        if($format === 'json') {
                header('Content-type: application/json');
diff --git a/view/poco_entry_xml.tpl b/view/poco_entry_xml.tpl
new file mode 100644 (file)
index 0000000..71ca2d1
--- /dev/null
@@ -0,0 +1,7 @@
+<entry>
+{{ if $entry.id }}<id>$entry.id</id>{{ endif }}
+{{ if $entry.displayName }}<displayName>$entry.displayName</displayName>{{ endif }}
+{{ if $entry.preferredName }}<preferredName>$entry.preferredName</preferredName>{{ endif }}
+{{ if $entry.urls }}<urls><value>$entry.urls.value</value><type>$entry.urls.type</type></urls>{{ endif }}
+{{ if $entry.photos }}<photos><value>$entry.photos.value</value><type><$entry.photos.type></type></photos>{{ endif }}
+</entry>
index 59b8e8a958bc90001a853263c3c718008eac4c43..218c97c5cf23817e6fa0f8e5dcc03ea54104597a 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <response>
-
 {{ if $response.sorted }}<sorted>$response.sorted</sorted>{{ endif }}
 {{ if $response.filtered }}<filtered>$response.filtered</filtered>{{ endif }}
 {{ if $response.updatedSince }}<updatedSince>$response.updatedSince</updatedSince>{{ endif }}
@@ -8,14 +7,8 @@
 {{ if $response.itemsPerPage }}<itemsPerPage>$response.itemsPerPage</itemsPerPage>{{ endif }}
 {{ if $response.totalResults }}<totalResults>$response.totalResults</totalResults>{{ endif }}
 
-{{ for $response.entry as $ent }}
-<entry>
-{{ if $ent.id }}<id>$ent.id</id>{{ endif }}
-{{ if $ent.displayName }}<displayName>$ent.displayName</displayName>{{ endif }}
-{{ if $ent.preferredName }}<preferredName>$ent.preferredName</preferredName>{{ endif }}
-{{ if $ent.urls }}<urls><value>$ent.urls.value</value><type>$ent.urls.type</type></urls>{{ endif }}
-{{ if $ent.photos }}<photos><value>$ent.photos.value</value><type><$ent.photos.type></type></photos>{{ endif }}
-</entry>
+{{ for $response.entry as $entry }}
+{{ inc poco_entry_xml.tpl }}{{ endinc }}
 {{ endfor }}
 
 </response>