From fedb96ed9bc165a715d8a700ff951462f91be2d2 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Tue, 20 Dec 2011 14:49:11 +0000 Subject: [PATCH] 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); }