From 436cc0c6d111311ce043d95fbb665298c4b8f41e Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Tue, 13 Dec 2011 22:39:29 +0000 Subject: [PATCH 1/8] Tidier market check launching --- checkmarket.py | 32 ++++++++++++++++++++++++++++++++ config.sample.py | 5 +++++ marketcheck/test.java | 7 ++++--- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100755 checkmarket.py diff --git a/checkmarket.py b/checkmarket.py new file mode 100755 index 00000000..47a212bf --- /dev/null +++ b/checkmarket.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +# +# checkmarket.py - part of the FDroid server tools +# Copyright (C) 2011, Ciaran Gultnieks, ciaran@ciarang.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import subprocess + +#Read configuration... +repo_name = None +repo_description = None +repo_icon = None +repo_url = None +execfile('config.py') + +subprocess.call('./run.sh ' + market_user + ' ' + market_password + + ' ' + market_deviceid, + cwd='marketcheck', shell=True) + diff --git a/config.sample.py b/config.sample.py index bdfc022d..e6615dab 100644 --- a/config.sample.py +++ b/config.sample.py @@ -39,4 +39,9 @@ keydname = "CN=Birdman, OU=Cell, O=Alcatraz, L=Alcatraz, S=California, C=US" keyaliases = {} keyaliases['com.example.app'] = 'example' +#For the market checker, which is used only to determine a 'current' version +#that the developer recommends, for those apps that are there. +market_user = "" +market_password = "" +market_deviceid = "" diff --git a/marketcheck/test.java b/marketcheck/test.java index 68d1ddfa..28431806 100644 --- a/marketcheck/test.java +++ b/marketcheck/test.java @@ -20,13 +20,14 @@ class test { */ public static void main(String[] args) { try { - if(args.length < 2) { + if(args.length < 3) { System.out.println("Parameters :\n" + - "email password"); + "email password deviceid"); return; } String login = args[0]; String password = args[1]; + String deviceid = args[2]; // Get a list of apps we want to check - i.e. those that // we have metadata files for... @@ -45,7 +46,7 @@ class test { MarketSession session = new MarketSession(); - session.getContext().setAndroidId("353027030727248"); + session.getContext().setAndroidId(deviceid); session.getContext().setDeviceAndSdkVersion("sapphire:7"); System.out.println("Login..."); session.login(login,password); From 8a887483c7f76f3425a32644b702a4cc936342c9 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Tue, 13 Dec 2011 22:54:37 +0000 Subject: [PATCH 2/8] Metadata: another day,another version of coolreader --- metadata/org.coolreader.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metadata/org.coolreader.txt b/metadata/org.coolreader.txt index cfb3abd5..e6e338ca 100644 --- a/metadata/org.coolreader.txt +++ b/metadata/org.coolreader.txt @@ -46,7 +46,7 @@ Build Version:3.0.53-14,259,cr3.0.53-14,subdir=android,rm=android/build.properti Build Version:3.0.53-18,263,c555ecd66d18b218fb255733c8b33a0825992f76,subdir=android,rm=android/build.properties,buildjni=yes Build Version:3.0.53-19,264,cr3.0.53-19,subdir=android,rm=android/build.properties,buildjni=yes Build Version:3.0.54-5,275,cr3.0.54-5,subdir=android,rm=android/build.properties,buildjni=yes +Build Version:3.0.54-9,279,cr3.0.54-9,subdir=android,rm=android/build.properties,buildjni=yes -Market Version:3.0.54-5 -Market Version Code:275 -Build Version:3.0.53-14,259,cr3.0.53-14,subdir=android,rm=android/build.properties,buildjni=yes +Market Version:3.0.54-9 +Market Version Code:279 From cff8228b441532d3a338ab2a2dc96a9ec1493d94 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Tue, 20 Dec 2011 14:42:00 +0000 Subject: [PATCH 3/8] Better git reset --- common.py | 2 +- metadata/net.osmand.plus.txt | 5 +++-- metadata/tuioDroid.impl.txt | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common.py b/common.py index 148a383b..43630e1b 100644 --- a/common.py +++ b/common.py @@ -91,7 +91,7 @@ class vcs_git(vcs): def reset(self, rev=None): if rev is None: - rev = 'HEAD' + rev = 'origin' if subprocess.call(['git', 'reset', '--hard', rev], cwd=self.local) != 0: print "Git reset failed" diff --git a/metadata/net.osmand.plus.txt b/metadata/net.osmand.plus.txt index 49809a2f..bb7c09a1 100644 --- a/metadata/net.osmand.plus.txt +++ b/metadata/net.osmand.plus.txt @@ -20,6 +20,7 @@ Build Version:0.6.7,37,v0.6.7,subdir=OsmAnd,encoding=utf-8,prebuild=mkdir raw,pa Build Version:0.6.8,39,v0.6.8,subdir=OsmAnd,encoding=utf-8,prebuild=mkdir raw Build Version:0.6.8',41,!No corresponding source for whatever this is Build Version:0.6.9,42,v0.6.9,subdir=OsmAnd,encoding=utf-8,prebuild=mkdir raw +Build Version:0.6.9',43,!No corresponding source for whatever this is -Market Version:0.6.9 -Market Version Code:42 +Market Version:0.6.9' +Market Version Code:43 diff --git a/metadata/tuioDroid.impl.txt b/metadata/tuioDroid.impl.txt index 46187fca..2152f44e 100644 --- a/metadata/tuioDroid.impl.txt +++ b/metadata/tuioDroid.impl.txt @@ -15,3 +15,5 @@ Repo:http://tuiodroid.googlecode.com/svn/trunk/ Build Version:1.0,4,28,subdir=TUIOdroid,prebuild=rm -rf bin && rm -rf gen,target=android-11 +Market Version:1.0 +Market Version Code:4 From c915bde3889472fe1548c54e87f3d4caf4912d6d Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Tue, 20 Dec 2011 14:42:43 +0000 Subject: [PATCH 4/8] Metadata: version updates --- metadata/org.eehouse.android.xw4.txt | 6 ++++-- metadata/org.linphone.txt | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/metadata/org.eehouse.android.xw4.txt b/metadata/org.eehouse.android.xw4.txt index 900295b4..e18983b2 100644 --- a/metadata/org.eehouse.android.xw4.txt +++ b/metadata/org.eehouse.android.xw4.txt @@ -17,6 +17,8 @@ Repo:git://xwords.git.sourceforge.net/gitroot/xwords/xwords #Build Version:4.4 beta 26,19,!Missing resources? android_beta_26,subdir=xwords4/android/XWords4 Build Version:4.4 beta 33,26,android_beta_33,subdir=xwords4/android/XWords4 Build Version:4.4 beta 38,30,android_beta_38,subdir=xwords4/android/XWords4 +Build Version:4.4 beta 39,31,android_beta_39,subdir=xwords4/android/XWords4,target=android-8,prebuild=cd .. && ./scripts/genvers.sh >ant_out.txt -Market Version:4.4 beta 38 -Market Version Code:30 + +Market Version:4.4 beta 39 +Market Version Code:31 diff --git a/metadata/org.linphone.txt b/metadata/org.linphone.txt index dfefca70..9eb77350 100644 --- a/metadata/org.linphone.txt +++ b/metadata/org.linphone.txt @@ -6,5 +6,5 @@ Summary:SIP (VOIP) client Description: A SIP (VOIP) client. . -Market Version:1.2.1 -Market Version Code:1210 +Market Version:1.2.2 +Market Version Code:1220 From 3693ae5f5628230a521a8736bbd416d83826199b Mon Sep 17 00:00:00 2001 From: Hans-Emil Skogh Date: Sun, 11 Dec 2011 15:34:21 +0100 Subject: [PATCH 5/8] Added grid view when listing apps in browse repository. Also, the WP plugin will now pass on all of the relevant query arguments via generated links by default. --- wp-fdroid/wp-fdroid.php | 309 +++++++++++++++++++++++++++------------- 1 file changed, 211 insertions(+), 98 deletions(-) diff --git a/wp-fdroid/wp-fdroid.php b/wp-fdroid/wp-fdroid.php index 8a79ad6d..2cd8b98a 100644 --- a/wp-fdroid/wp-fdroid.php +++ b/wp-fdroid/wp-fdroid.php @@ -16,9 +16,10 @@ class FDroid { // Our text domain, for internationalisation - var $textdom='wp-fdroid'; + private $textdom='wp-fdroid'; - var $site_path = "/home/fdroid/public_html"; + // TODO: Fix site path... + private $site_path = "/home/hansemil/MyDocuments/f-droid"; // Constructor function FDroid() { @@ -34,6 +35,7 @@ class FDroid $qvars[]='fdfilter'; $qvars[]='fdid'; $qvars[]='fdpage'; + $qvars[]='fdstyle'; return $qvars; } @@ -55,19 +57,6 @@ class FDroid return $wp_query->query_vars[$name]; } - // Make a link to this page, with the given query parameter string added - function makelink($params) { - $link=get_permalink(); - if(strlen($params)==0) - return $link; - if(strpos($link,'?')===false) - $link.='?'; - else - $link.='&'; - $link.=$params; - return $link; - } - // Handler for the 'fdroidrepo' shortcode. // $attribs - shortcode attributes // $content - optional content enclosed between the starting and @@ -77,32 +66,37 @@ class FDroid global $wp_query,$wp_rewrite; $this->lazyinit(); - $page=1; - if(isset($wp_query->query_vars['fdpage'])) { - $page=(int)$wp_query->query_vars['fdpage']; - if($page==0) - $page=1; - } + + // Init local query vars + foreach($this->queryvars(array()) as $qv) { + if(array_key_exists($qv,$wp_query->query_vars)) { + $query_vars[$qv] = $wp_query->query_vars[$qv]; + } else { + $query_vars[$qv] = null; + } + } + + // Santiy check query vars + if(!isset($query_vars['fdpage']) || !is_numeric($query_vars['fdpage']) || $query_vars['fdpage'] <= 0) { + $query_vars['fdpage'] = 1; + } - $filter=$wp_query->query_vars['fdfilter']; - $fdid=$wp_query->query_vars['fdid']; - - if($fdid!==null) - $out=$this->get_app($fdid); + if($query_vars['fdid']!==null) + $out=$this->get_app($query_vars); else - $out=$this->get_apps($page,$filter); + $out=$this->get_apps($query_vars); return $out; } - function get_app($id) { + function get_app($query_vars) { $xml = simplexml_load_file($this->site_path."/repo/index.xml"); foreach($xml->children() as $app) { $attrs=$app->attributes(); - if($attrs['id']==$id) { + if($attrs['id']==$query_vars['fdid']) { $apks=array();; foreach($app->children() as $el) { switch($el->getName()) { @@ -199,7 +193,7 @@ class FDroid $out.="

"; } - $out.='

Index

'; + $out.='

Index

'; return $out; } @@ -208,88 +202,42 @@ class FDroid } - function get_apps($page,$filter=null) { + function get_apps($query_vars) { - if($filter===null) - $out="

All applications"; + $out=''; + + $out.='

'; + if($query_vars['fdfilter']===null) + $out.="All applications"; else - $out="

Applications matching ".$filter; - $out.="

"; + $out.="Applications matching ".$query_vars['fdfilter']; + $out.="
"; - $perpage=30; - $skipped=0; - $got=0; - $total=0; + $out.='
'; + $out.='List | '; + $out.='Grid'; + $out.='
'; + + $out.='
'; $xml = simplexml_load_file($this->site_path."/repo/index.xml"); - foreach($xml->children() as $app) { - - if($app->getName() == 'repo') continue; - $attrs=$app->attributes(); - $id=$attrs['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; - } - } - - if($filter===null || stristr($name,$filter)) { - if($skipped<($page-1)*$perpage) { - $skipped++; - } else if($got<$perpage) { - - $out.="
\n"; - $out.='
'; - - $out.='
'; - - $out.='
'; - $out.='

Details...'; - $out.="

"; - $out.="
\n"; - - $out.='

'.$name.""; - $out.="
".$summary."

\n"; - - $out.="
\n"; - - $got++; - } - $total++; - } - - } - - $numpages=ceil((float)$total/$perpage); + $out.=$this->show_apps($xml,$query_vars,$numpages); $out.='

'; - if($page==1) { + if($query_vars['fdpage']==1) { $out.="<<first "; $out.="<prev "; } else { - $out.='<<first '; - $out.='<<prev '; + $out.='<<first '; + $out.='<<prev '; } - $out.=" Page $page of $numpages "; - if($page==$numpages) { + $out.=' Page '.$query_vars['fdpage'].' of '.$numpages.' '; + if($query_vars['fdpage']==$numpages) { $out.="next> "; $out.="last>> "; } else { - $out.='next> '; - $out.='last>> '; + $out.='next> '; + $out.='last>> '; } $out.='

'; @@ -297,9 +245,174 @@ class FDroid } + function show_apps($xml,$query_vars,&$numpages) { + + $skipped=0; + $got=0; + $total=0; + if($query_vars['fdstyle']=='grid') { + $outputter = new FDOutGrid(); + } else { + $outputter = new FDOutList(); + } + + $out = ""; + + $out.=$outputter->outputStart(); + + foreach($xml->children() as $app) { + + if($app->getName() == 'repo') continue; + $appinfo['attrs']=$app->attributes(); + $appinfo['id']=$appinfo['attrs']['id']; + foreach($app->children() as $el) { + switch($el->getName()) { + case "name": + $appinfo['name']=$el; + break; + case "icon": + $appinfo['icon']=$el; + break; + case "summary": + $appinfo['summary']=$el; + break; + case "license": + $appinfo['license']=$el; + break; + } + } + + if($query_vars['fdfilter']===null || stristr($appinfo['name'],$query_vars['fdfilter'])) { + if($skipped<($query_vars['fdpage']-1)*$outputter->perpage) { + $skipped++; + } else if($got<$outputter->perpage) { + + $out.=$outputter->outputEntry($query_vars, $appinfo); + $got++; + } + $total++; + } + + } + + $out.=$outputter->outputEnd(); + + $numpages = ceil((float)$total/$outputter->perpage); + + return $out; + } } +// Class to output app entries in a detailed list format +class FDOutList +{ + var $perpage=30; + + function FDOutList() { + } + + function outputStart() { + return ''; + } + + function outputEntry($query_vars, $appinfo) { + $out=""; + $out.="
\n"; + $out.='
'; + + $out.='
'; + + $out.='
'; + $out.='

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

"; + $out.="
\n"; + + $out.='

'.$appinfo['name'].""; + $out.="
".$appinfo['summary']."

\n"; + + $out.="
\n"; + + return $out; + } + + function outputEnd() { + return ''; + } +} + +// Class to output app entries in a compact grid format +class FDOutGrid +{ + var $perpage=80; + + var $itemCount = 0; + + function FDOutGrid() { + } + + function outputStart() { + return "\n".''."\n"; + } + + function outputEntry($query_vars, $appinfo) { + $link=makelink($query_vars, array('fdid'=>$appinfo['id'])); + + $out=''; + + if($this->itemCount%4 == 0 && $this->itemCount > 0) + { + $out.=''."\n"; + } + + $out.='\n"; + + $this->itemCount++; + return $out; + } + + function outputEnd() { + return '
'; + $out.='

'; + $out.='

"; + $out.='

'; + $out.="
'."\n"; + } +} + +// Make a link to this page, with the current query vars attached and desired params added/modified +function makelink($query_vars, $params=array()) { + $link=get_permalink(); + $vars=linkify(array_merge($query_vars, $params)); + if(strlen($vars)==0) + return $link; + if(strpos($link,'?')===false) + $link.='?'; + else + $link.='&'; + return $link.$vars; +} + +// Return the key value pairs in http-get-parameter format as a string +function linkify($vars) { + $retvar = ''; + foreach($vars as $k => $v) { + if($k!==null && $v!==null && $v!='') + $retvar .= $k.'='.$v.'&'; + } + return substr($retvar,0,-1); +} + + $wp_fdroid = new FDroid(); From 7a58ab5e001f7099daa4834826010e58a0e7895d Mon Sep 17 00:00:00 2001 From: Hans-Emil Skogh Date: Mon, 12 Dec 2011 21:21:07 +0100 Subject: [PATCH 6/8] Get site path (www-root) from environment variable. (Won't work on IIS...) --- wp-fdroid/wp-fdroid.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-fdroid/wp-fdroid.php b/wp-fdroid/wp-fdroid.php index 2cd8b98a..fe05c092 100644 --- a/wp-fdroid/wp-fdroid.php +++ b/wp-fdroid/wp-fdroid.php @@ -18,8 +18,7 @@ class FDroid // Our text domain, for internationalisation private $textdom='wp-fdroid'; - // TODO: Fix site path... - private $site_path = "/home/hansemil/MyDocuments/f-droid"; + private $site_path; // Constructor function FDroid() { @@ -27,6 +26,7 @@ class FDroid add_shortcode('fdroidrepo',array($this, 'do_shortcode')); add_filter('query_vars',array($this, 'queryvars')); $this->inited=false; + $this->site_path=getenv('DOCUMENT_ROOT'); } From 6bbd2bf4097d5d2fffe86c3beec798ab10230b0e Mon Sep 17 00:00:00 2001 From: Hans-Emil Skogh Date: Sun, 18 Dec 2011 21:16:20 +0100 Subject: [PATCH 7/8] Implemented searching for apps in the repository. Adds a new shortcode attribute "search" for the shortcode "fdroidrepo". When this is set, a search field will be shown above the app listing. Uses the fdfilter search code to do the search result filtering. --- wp-fdroid/wp-fdroid.php | 113 ++++++++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 38 deletions(-) diff --git a/wp-fdroid/wp-fdroid.php b/wp-fdroid/wp-fdroid.php index fe05c092..7d1b1dfc 100644 --- a/wp-fdroid/wp-fdroid.php +++ b/wp-fdroid/wp-fdroid.php @@ -81,10 +81,20 @@ class FDroid $query_vars['fdpage'] = 1; } - if($query_vars['fdid']!==null) - $out=$this->get_app($query_vars); - else - $out=$this->get_apps($query_vars); + $out = ''; + + if(isset($attribs['search']) && $query_vars['fdfilter']===null) { + $query_vars['fdfilter'] = ''; + } + + if($query_vars['fdid']!==null) { + $out.=$this->get_app($query_vars); + } else { + if($query_vars['fdfilter'] !== null) + $out.=$this->show_search($query_vars); + + $out.=$this->get_apps($query_vars); + } return $out; } @@ -204,46 +214,74 @@ class FDroid function get_apps($query_vars) { + $xml = simplexml_load_file($this->site_path."/repo/index.xml"); + $matches = $this->show_apps($xml,$query_vars,$numpages); + $out=''; - $out.='
'; - if($query_vars['fdfilter']===null) - $out.="All applications"; - else - $out.="Applications matching ".$query_vars['fdfilter']; - $out.="
"; + if(($query_vars['fdfilter']===null || $query_vars['fdfilter']!='') && $numpages>0) + { + $out.='
'; + if($query_vars['fdfilter']===null) + $out.="All applications"; + else + $out.='Applications matching "'.$query_vars['fdfilter'].'"'; + $out.="
"; - $out.='
'; - $out.='List | '; - $out.='Grid'; - $out.='
'; + $out.='
'; + $out.='List | '; + $out.='Grid'; + $out.='
'; - $out.='
'; - - $xml = simplexml_load_file($this->site_path."/repo/index.xml"); - $out.=$this->show_apps($xml,$query_vars,$numpages); - - $out.='

'; - if($query_vars['fdpage']==1) { - $out.="<<first "; - $out.="<prev "; - } else { - $out.='<<first '; - $out.='<<prev '; - } - $out.=' Page '.$query_vars['fdpage'].' of '.$numpages.' '; - if($query_vars['fdpage']==$numpages) { - $out.="next> "; - $out.="last>> "; - } else { - $out.='next> '; - $out.='last>> '; - } - $out.='

'; + $out.='
'; + } + + if($numpages>0) { + $out.=$matches; + + $out.='

'; + if($query_vars['fdpage']==1) { + $out.="<<first "; + $out.="<prev "; + } else { + $out.='<<first '; + $out.='<<prev '; + } + $out.=' Page '.$query_vars['fdpage'].' of '.$numpages.' '; + if($query_vars['fdpage']==$numpages) { + $out.="next> "; + $out.="last>> "; + } else { + $out.='next> '; + $out.='last>> '; + } + $out.='

'; + } else if($query_vars['fdfilter']!='') { + $out.='

No matches

'; + } return $out; } + + function show_search($query_vars) { + + $out=''; + $out.='
'; + $out.='

'; + $out.='

'; + + $out.=''; + foreach($query_vars as $name => $value) { + if($value !== null && $name != 'fdfilter') + $out.=''; + } + + $out.='
'."\n"; + + return $out; + } + function show_apps($xml,$query_vars,&$numpages) { @@ -283,11 +321,10 @@ class FDroid } } - if($query_vars['fdfilter']===null || stristr($appinfo['name'],$query_vars['fdfilter'])) { + if($query_vars['fdfilter']===null || $query_vars['fdfilter']!='' && (stristr($appinfo['name'],$query_vars['fdfilter']) || stristr($appinfo['summary'],$query_vars['fdfilter']))) { if($skipped<($query_vars['fdpage']-1)*$outputter->perpage) { $skipped++; } else if($got<$outputter->perpage) { - $out.=$outputter->outputEntry($query_vars, $appinfo); $got++; } From fedb96ed9bc165a715d8a700ff951462f91be2d2 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Tue, 20 Dec 2011 14:49:11 +0000 Subject: [PATCH 8/8] Formatting fixes --- wp-fdroid/wp-fdroid.php | 346 ++++++++++++++++++++-------------------- 1 file changed, 173 insertions(+), 173 deletions(-) diff --git a/wp-fdroid/wp-fdroid.php b/wp-fdroid/wp-fdroid.php index 7d1b1dfc..ea9aa95d 100644 --- a/wp-fdroid/wp-fdroid.php +++ b/wp-fdroid/wp-fdroid.php @@ -18,7 +18,7 @@ class FDroid // Our text domain, for internationalisation private $textdom='wp-fdroid'; - private $site_path; + private $site_path; // Constructor function FDroid() { @@ -66,35 +66,35 @@ class FDroid global $wp_query,$wp_rewrite; $this->lazyinit(); - - // Init local query vars - foreach($this->queryvars(array()) as $qv) { - if(array_key_exists($qv,$wp_query->query_vars)) { - $query_vars[$qv] = $wp_query->query_vars[$qv]; - } else { - $query_vars[$qv] = null; - } - } - - // Santiy check query vars - if(!isset($query_vars['fdpage']) || !is_numeric($query_vars['fdpage']) || $query_vars['fdpage'] <= 0) { - $query_vars['fdpage'] = 1; - } + + // Init local query vars + foreach($this->queryvars(array()) as $qv) { + if(array_key_exists($qv,$wp_query->query_vars)) { + $query_vars[$qv] = $wp_query->query_vars[$qv]; + } else { + $query_vars[$qv] = null; + } + } + + // Santiy check query vars + if(!isset($query_vars['fdpage']) || !is_numeric($query_vars['fdpage']) || $query_vars['fdpage'] <= 0) { + $query_vars['fdpage'] = 1; + } - $out = ''; + $out = ''; - if(isset($attribs['search']) && $query_vars['fdfilter']===null) { - $query_vars['fdfilter'] = ''; - } + if(isset($attribs['search']) && $query_vars['fdfilter']===null) { + $query_vars['fdfilter'] = ''; + } - if($query_vars['fdid']!==null) { + if($query_vars['fdid']!==null) { $out.=$this->get_app($query_vars); - } else { - if($query_vars['fdfilter'] !== null) - $out.=$this->show_search($query_vars); + } else { + if($query_vars['fdfilter'] !== null) + $out.=$this->show_search($query_vars); $out.=$this->get_apps($query_vars); - } + } return $out; } @@ -214,91 +214,91 @@ class FDroid function get_apps($query_vars) { - $xml = simplexml_load_file($this->site_path."/repo/index.xml"); - $matches = $this->show_apps($xml,$query_vars,$numpages); - - $out=''; + $xml = simplexml_load_file($this->site_path."/repo/index.xml"); + $matches = $this->show_apps($xml,$query_vars,$numpages); + + $out=''; - if(($query_vars['fdfilter']===null || $query_vars['fdfilter']!='') && $numpages>0) - { - $out.='
'; - if($query_vars['fdfilter']===null) - $out.="All applications"; - else - $out.='Applications matching "'.$query_vars['fdfilter'].'"'; - $out.="
"; + if(($query_vars['fdfilter']===null || $query_vars['fdfilter']!='') && $numpages>0) + { + $out.='
'; + if($query_vars['fdfilter']===null) + $out.="All applications"; + else + $out.='Applications matching "'.$query_vars['fdfilter'].'"'; + $out.="
"; - $out.='
'; - $out.='List | '; - $out.='Grid'; - $out.='
'; + $out.='
'; + $out.='List | '; + $out.='Grid'; + $out.='
'; - $out.='
'; - } - - if($numpages>0) { - $out.=$matches; - - $out.='

'; - if($query_vars['fdpage']==1) { - $out.="<<first "; - $out.="<prev "; - } else { - $out.='<<first '; - $out.='<<prev '; - } - $out.=' Page '.$query_vars['fdpage'].' of '.$numpages.' '; - if($query_vars['fdpage']==$numpages) { - $out.="next> "; - $out.="last>> "; - } else { - $out.='next> '; - $out.='last>> '; - } - $out.='

'; - } else if($query_vars['fdfilter']!='') { - $out.='

No matches

'; - } + $out.='
'; + } + + if($numpages>0) { + $out.=$matches; + + $out.='

'; + if($query_vars['fdpage']==1) { + $out.="<<first "; + $out.="<prev "; + } else { + $out.='<<first '; + $out.='<<prev '; + } + $out.=' Page '.$query_vars['fdpage'].' of '.$numpages.' '; + if($query_vars['fdpage']==$numpages) { + $out.="next> "; + $out.="last>> "; + } else { + $out.='next> '; + $out.='last>> '; + } + $out.='

'; + } else if($query_vars['fdfilter']!='') { + $out.='

No matches

'; + } return $out; } - + function show_search($query_vars) { - $out=''; - $out.='
'; - $out.='

'; - $out.='

'; + $out=''; + $out.=''; + $out.='

'; + $out.='

'; - $out.=''; - foreach($query_vars as $name => $value) { - if($value !== null && $name != 'fdfilter') - $out.=''; - } - - $out.='
'."\n"; - + $out.=''; + foreach($query_vars as $name => $value) { + if($value !== null && $name != 'fdfilter') + $out.=''; + } + + $out.=''."\n"; + return $out; } - + function show_apps($xml,$query_vars,&$numpages) { - + $skipped=0; $got=0; $total=0; - if($query_vars['fdstyle']=='grid') { - $outputter = new FDOutGrid(); - } else { - $outputter = new FDOutList(); - } - - $out = ""; - - $out.=$outputter->outputStart(); - + if($query_vars['fdstyle']=='grid') { + $outputter = new FDOutGrid(); + } else { + $outputter = new FDOutList(); + } + + $out = ""; + + $out.=$outputter->outputStart(); + foreach($xml->children() as $app) { if($app->getName() == 'repo') continue; @@ -325,128 +325,128 @@ class FDroid if($skipped<($query_vars['fdpage']-1)*$outputter->perpage) { $skipped++; } else if($got<$outputter->perpage) { - $out.=$outputter->outputEntry($query_vars, $appinfo); + $out.=$outputter->outputEntry($query_vars, $appinfo); $got++; } $total++; } } - - $out.=$outputter->outputEnd(); - - $numpages = ceil((float)$total/$outputter->perpage); - - return $out; - } + + $out.=$outputter->outputEnd(); + + $numpages = ceil((float)$total/$outputter->perpage); + + return $out; + } } // Class to output app entries in a detailed list format class FDOutList { - var $perpage=30; + var $perpage=30; - function FDOutList() { - } + function FDOutList() { + } - function outputStart() { - return ''; - } - - function outputEntry($query_vars, $appinfo) { - $out=""; - $out.="
\n"; - $out.='
'; + function outputStart() { + return ''; + } + + function outputEntry($query_vars, $appinfo) { + $out=""; + $out.="
\n"; + $out.='
'; - $out.='
'; + $out.='
'; - $out.='
'; - $out.='

Details...'; - $out.="

"; - $out.="
\n"; + $out.='
'; + $out.='

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

"; + $out.="
\n"; - $out.='

'.$appinfo['name'].""; - $out.="
".$appinfo['summary']."

\n"; + $out.='

'.$appinfo['name'].""; + $out.="
".$appinfo['summary']."

\n"; - $out.="
\n"; - - return $out; - } + $out.="
\n"; + + return $out; + } - function outputEnd() { - return ''; - } + function outputEnd() { + return ''; + } } // Class to output app entries in a compact grid format class FDOutGrid { - var $perpage=80; + var $perpage=80; - var $itemCount = 0; + var $itemCount = 0; - function FDOutGrid() { - } + function FDOutGrid() { + } - function outputStart() { - return "\n".''."\n"; - } - - function outputEntry($query_vars, $appinfo) { - $link=makelink($query_vars, array('fdid'=>$appinfo['id'])); + function outputStart() { + return "\n".'
'."\n"; + } + + function outputEntry($query_vars, $appinfo) { + $link=makelink($query_vars, array('fdid'=>$appinfo['id'])); - $out=''; + $out=''; - if($this->itemCount%4 == 0 && $this->itemCount > 0) - { - $out.=''."\n"; - } + if($this->itemCount%4 == 0 && $this->itemCount > 0) + { + $out.=''."\n"; + } - $out.='\n"; - - $this->itemCount++; - return $out; - } + $out.=""; + $out.='

'; + $out.="\n"; + + $this->itemCount++; + return $out; + } - function outputEnd() { - return '
'; - $out.='

'; - $out.='

'; + $out.='
'; + $out.='

'; + $out.='

"; - $out.='

'; - $out.="
'."\n"; - } + function outputEnd() { + return ''."\n"; + } } // Make a link to this page, with the current query vars attached and desired params added/modified function makelink($query_vars, $params=array()) { - $link=get_permalink(); - $vars=linkify(array_merge($query_vars, $params)); - if(strlen($vars)==0) - return $link; - if(strpos($link,'?')===false) - $link.='?'; - else - $link.='&'; - return $link.$vars; + $link=get_permalink(); + $vars=linkify(array_merge($query_vars, $params)); + if(strlen($vars)==0) + return $link; + if(strpos($link,'?')===false) + $link.='?'; + else + $link.='&'; + return $link.$vars; } // Return the key value pairs in http-get-parameter format as a string function linkify($vars) { - $retvar = ''; - foreach($vars as $k => $v) { - if($k!==null && $v!==null && $v!='') - $retvar .= $k.'='.$v.'&'; - } - return substr($retvar,0,-1); + $retvar = ''; + foreach($vars as $k => $v) { + if($k!==null && $v!==null && $v!='') + $retvar .= $k.'='.$v.'&'; + } + return substr($retvar,0,-1); }