mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-04 14:30:11 +01:00
Added filtering of applications based on category to the F-Droid wordpress plugin.
This commit is contained in:
parent
05e7146de0
commit
c8d96efc8f
@ -36,6 +36,7 @@ class FDroid
|
|||||||
// Register additional query variables. (Handler for the 'query_vars' filter)
|
// Register additional query variables. (Handler for the 'query_vars' filter)
|
||||||
function queryvars($qvars) {
|
function queryvars($qvars) {
|
||||||
$qvars[]='fdfilter';
|
$qvars[]='fdfilter';
|
||||||
|
$qvars[]='fdcategory';
|
||||||
$qvars[]='fdid';
|
$qvars[]='fdid';
|
||||||
$qvars[]='fdpage';
|
$qvars[]='fdpage';
|
||||||
$qvars[]='fdstyle';
|
$qvars[]='fdstyle';
|
||||||
@ -89,11 +90,20 @@ class FDroid
|
|||||||
$query_vars['fdfilter'] = '';
|
$query_vars['fdfilter'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($query_vars['fdcategory'] == 'All applications') {
|
||||||
|
unset($query_vars['fdcategory']);
|
||||||
|
}
|
||||||
|
|
||||||
if($query_vars['fdid']!==null) {
|
if($query_vars['fdid']!==null) {
|
||||||
$out.=$this->get_app($query_vars);
|
$out.=$this->get_app($query_vars);
|
||||||
} else {
|
} else {
|
||||||
if($query_vars['fdfilter'] !== null)
|
if($query_vars['fdfilter'] !== null) {
|
||||||
$out.=$this->show_search($query_vars);
|
$out.='<form name="searchform" action="" method="get">';
|
||||||
|
$out.='<p><input name="fdfilter" type="text" value="'.$query_vars['fdfilter'].'" size="30"> ';
|
||||||
|
$out.='<input type="submit" value="Search"></p>';
|
||||||
|
$out.=$this->makeformdata($query_vars);
|
||||||
|
$out.='</form>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
$out.=$this->get_apps($query_vars);
|
$out.=$this->get_apps($query_vars);
|
||||||
}
|
}
|
||||||
@ -454,10 +464,26 @@ class FDroid
|
|||||||
if(($query_vars['fdfilter']===null || $query_vars['fdfilter']!='') && $numpages>0)
|
if(($query_vars['fdfilter']===null || $query_vars['fdfilter']!='') && $numpages>0)
|
||||||
{
|
{
|
||||||
$out.='<div style="float:left;">';
|
$out.='<div style="float:left;">';
|
||||||
if($query_vars['fdfilter']===null)
|
if($query_vars['fdfilter']===null) {
|
||||||
$out.="All applications";
|
$categories = array('All applications','Games','Internet','Multimedia','Navigation','Office','System');
|
||||||
else
|
|
||||||
|
$out.='<form name="categoryform" action="" method="get">';
|
||||||
|
$out.=$this->makeformdata($query_vars);
|
||||||
|
|
||||||
|
$out.='<select name="fdcategory" style="color:#333333;" onChange="document.categoryform.submit();">';
|
||||||
|
foreach($categories as $category) {
|
||||||
|
$out.='<option';
|
||||||
|
if(isset($query_vars['fdcategory']) && $category==$query_vars['fdcategory'])
|
||||||
|
$out.=' selected';
|
||||||
|
$out.='>'.$category.'</option>';
|
||||||
|
}
|
||||||
|
$out.='</select>';
|
||||||
|
|
||||||
|
$out.='</form>'."\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
$out.='Applications matching "'.$query_vars['fdfilter'].'"';
|
$out.='Applications matching "'.$query_vars['fdfilter'].'"';
|
||||||
|
}
|
||||||
$out.="</div>";
|
$out.="</div>";
|
||||||
|
|
||||||
$out.='<div style="float:right;">';
|
$out.='<div style="float:right;">';
|
||||||
@ -508,12 +534,9 @@ class FDroid
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function show_search($query_vars) {
|
function makeformdata($query_vars) {
|
||||||
|
|
||||||
$out='';
|
$out='';
|
||||||
$out.='<form name="searchform" action="" method="get">';
|
|
||||||
$out.='<p><input name="fdfilter" type="text" value="'.$query_vars['fdfilter'].'" size="30"> ';
|
|
||||||
$out.='<input type="submit" value="Search"></p>';
|
|
||||||
|
|
||||||
$out.='<input type="hidden" name="page_id" value="'.get_query_var('page_id').'">';
|
$out.='<input type="hidden" name="page_id" value="'.get_query_var('page_id').'">';
|
||||||
foreach($query_vars as $name => $value) {
|
foreach($query_vars as $name => $value) {
|
||||||
@ -521,8 +544,6 @@ class FDroid
|
|||||||
$out.='<input type="hidden" name="'.$name.'" value="'.$value.'">';
|
$out.='<input type="hidden" name="'.$name.'" value="'.$value.'">';
|
||||||
}
|
}
|
||||||
|
|
||||||
$out.='</form>'."\n";
|
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -565,10 +586,13 @@ class FDroid
|
|||||||
case "license":
|
case "license":
|
||||||
$appinfo['license']=$el;
|
$appinfo['license']=$el;
|
||||||
break;
|
break;
|
||||||
|
case "category":
|
||||||
|
$appinfo['category']=$el;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($query_vars['fdfilter']===null || $query_vars['fdfilter']!='' && (stristr($appinfo['name'],$query_vars['fdfilter']) || stristr($appinfo['summary'],$query_vars['fdfilter']) || stristr($appinfo['description'],$query_vars['fdfilter']))) {
|
if(($query_vars['fdfilter']===null || $query_vars['fdfilter']!='' && (stristr($appinfo['name'],$query_vars['fdfilter']) || stristr($appinfo['summary'],$query_vars['fdfilter']) || stristr($appinfo['description'],$query_vars['fdfilter']))) && (!isset($query_vars['fdcategory']) || $query_vars['fdcategory'] && $query_vars['fdcategory']==$appinfo['category'])) {
|
||||||
if($skipped<($query_vars['fdpage']-1)*$outputter->perpage) {
|
if($skipped<($query_vars['fdpage']-1)*$outputter->perpage) {
|
||||||
$skipped++;
|
$skipped++;
|
||||||
} else if($got<$outputter->perpage) {
|
} else if($got<$outputter->perpage) {
|
||||||
|
Loading…
Reference in New Issue
Block a user