From 53d3e0148d583595fecaaeb9bd345a1ff83566ff Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Sun, 5 Dec 2010 11:30:11 +0000 Subject: [PATCH] WordPress plugin: now with app detail pages --- updateplugin.sh | 1 + wp-fdroid/wp-fdroid.php | 66 +++++++++++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 13 deletions(-) create mode 100755 updateplugin.sh diff --git a/updateplugin.sh b/updateplugin.sh new file mode 100755 index 00000000..fe798e93 --- /dev/null +++ b/updateplugin.sh @@ -0,0 +1 @@ +scp -r wp-fdroid/ fdroid@f-droid.org:/home/fdroid/public_html/wp-content/plugins diff --git a/wp-fdroid/wp-fdroid.php b/wp-fdroid/wp-fdroid.php index b36a0ee2..2aaba2e8 100644 --- a/wp-fdroid/wp-fdroid.php +++ b/wp-fdroid/wp-fdroid.php @@ -81,16 +81,60 @@ class FDroid $page=1; } - $filter=null; - if(isset($wp_query->query_vars['fdfilter'])) - $filter=$wp_query->query_vars['fdfilter']; + $filter=$wp_query->query_vars['fdfilter']; + $fdid=$wp_query->query_vars['fdid']; - $out=$this->get_apps($page,$filter); + if($fdid!==null) + $out=$this->get_app($fdid); + else + $out=$this->get_apps($page,$filter); return $out; } + function get_app($id) { + + $xml = simplexml_load_file("/home/fdroid/public_html/repo/index.xml"); + foreach($xml->children() as $app) { + + $attrs=$app->attributes(); + if($attrs['id']==$id) { + foreach($app->children() as $el) { + switch($el->getName()) { + case "name": + $name=$el; + break; + case "icon": + $icon=$el; + break; + case "summary": + $summary=$el; + break; + case "license": + $license=$el; + break; + case "source": + $source=$el; + break; + case "issues": + $issues=$el; + break; + case "web": + $web=$el; + break; + } + } + $out="

".$name."

"; + $out.='

'; + $out.=$summary; + $out.="

"; + return $out; + } + } + return "

Application not found

"; + } + function get_apps($page,$filter=null) { @@ -108,6 +152,8 @@ class FDroid $xml = simplexml_load_file("/home/fdroid/public_html/repo/index.xml"); foreach($xml->children() as $app) { + $attrs=$app->attributes(); + $id=$attrs['id']; foreach($app->children() as $el) { switch($el->getName()) { case "name": @@ -122,15 +168,6 @@ class FDroid case "license": $license=$el; break; - case "source": - $source=$el; - break; - case "issues": - $issues=$el; - break; - case "web": - $web=$el; - break; } } @@ -141,6 +178,9 @@ class FDroid $out.="

".$name."

"; $out.='

'; $out.=$summary; + $out.='
Details...'; $out.="

"; $got++; } -- 2.30.2