From abe96155b42f0f824d05d08126d0ced0d3c5ab38 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 27 Oct 2011 01:54:52 -0700 Subject: [PATCH] hmmm - why won't poco xml work --- include/api.php | 10 +--------- include/text.php | 11 ++++++++++- mod/poco.php | 14 ++++++-------- view/poco_entry_xml.tpl | 7 +++++++ view/poco_xml.tpl | 11 ++--------- 5 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 view/poco_entry_xml.tpl diff --git a/include/api.php b/include/api.php index 1334d8eae7..d94cc2942a 100644 --- a/include/api.php +++ b/include/api.php @@ -404,14 +404,6 @@ 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 @@ -424,7 +416,7 @@ 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; diff --git a/include/text.php b/include/text.php index e0f38a3a0d..8ada179dc4 100644 --- a/include/text.php +++ b/include/text.php @@ -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); +} diff --git a/mod/poco.php b/mod/poco.php index d0e32816e7..c354be863d 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -1,6 +1,5 @@ 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 index 0000000000..71ca2d13e8 --- /dev/null +++ b/view/poco_entry_xml.tpl @@ -0,0 +1,7 @@ + +{{ if $entry.id }}$entry.id{{ endif }} +{{ if $entry.displayName }}$entry.displayName{{ endif }} +{{ if $entry.preferredName }}$entry.preferredName{{ endif }} +{{ if $entry.urls }}$entry.urls.value$entry.urls.type{{ endif }} +{{ if $entry.photos }}$entry.photos.value<$entry.photos.type>{{ endif }} + diff --git a/view/poco_xml.tpl b/view/poco_xml.tpl index 59b8e8a958..218c97c5cf 100644 --- a/view/poco_xml.tpl +++ b/view/poco_xml.tpl @@ -1,6 +1,5 @@ - {{ if $response.sorted }}$response.sorted{{ endif }} {{ if $response.filtered }}$response.filtered{{ endif }} {{ if $response.updatedSince }}$response.updatedSince{{ endif }} @@ -8,14 +7,8 @@ {{ if $response.itemsPerPage }}$response.itemsPerPage{{ endif }} {{ if $response.totalResults }}$response.totalResults{{ endif }} -{{ for $response.entry as $ent }} - -{{ if $ent.id }}$ent.id{{ endif }} -{{ if $ent.displayName }}$ent.displayName{{ endif }} -{{ if $ent.preferredName }}$ent.preferredName{{ endif }} -{{ if $ent.urls }}$ent.urls.value$ent.urls.type{{ endif }} -{{ if $ent.photos }}$ent.photos.value<$ent.photos.type>{{ endif }} - +{{ for $response.entry as $entry }} +{{ inc poco_entry_xml.tpl }}{{ endinc }} {{ endfor }}