aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV.Krishn <vkrishn4@gmail.com>2016-06-22 03:29:47 +0530
committerV.Krishn <vkrishn4@gmail.com>2016-06-22 03:29:47 +0530
commit8d4c887848a47a7141cccb026941759e5c061092 (patch)
treef06bf1f0156863bea61bd70009aeb355bfb181d5
parent3276e3775b5a18107450d8743669b5503920420c (diff)
downloadaport-api-8d4c887848a47a7141cccb026941759e5c061092.tar.bz2
add get2filter for simple search
-rw-r--r--index.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/index.php b/index.php
index 41a3edb..fdeb190 100644
--- a/index.php
+++ b/index.php
@@ -179,7 +179,7 @@ The Aports API consists of the following methods: # TODO - clean text import fro
3. maintainer/<maintainerName> ( wildcard recognized '_' )
4. flagged/[yes|no]
*/
-$app->get('/search/{where:[a-z0-9\_]+}/{filters:.*}', function($where, $filters) use ($app) {
+$app->get('/search/{where:[a-z0-9\_]+}{filters:.*}', function($where, $filters) use ($app) {
$data = initJapiData($app, 'search');
$_w = array('packages', 'contents');
@@ -187,11 +187,12 @@ $app->get('/search/{where:[a-z0-9\_]+}/{filters:.*}', function($where, $filters)
if ( ! in_array($where, $_w)) return;
//$filter = (array)sanitize_filters($filters, $where, $app);
- $f = explode('/', single_slash(urldecode($filters)));
+ $f = explode('/', trim(single_slash(urldecode($filters)), '/'));
for($c=0; $c<=count($f); $c=$c+2) { # limit key/value to 56 chars each
if($f[$c]) $filter[mb_substr(@$f[$c], 0, 56)] = mb_substr(@$f[$c+1], 0, 56);
}
unset($f);
+ $filter = get2filter($filter);
$filter['filter'] = array();
# Create customs filters # TODO
@@ -214,6 +215,13 @@ $app->get('/search/{where:[a-z0-9\_]+}/{filters:.*}', function($where, $filters)
});
+function get2filter($f) {
+ $_k = array('category', 'name', 'maintainer', 'flagged', 'sort');
+ //$_k = array('name', 'branch', 'repo', 'arch', 'maintainer', 'flagged', 'sort');
+ foreach($_k as $v) { if(array_key_exists($v, $_GET)) $f[$v] = mb_substr($_GET[$v], 0, 56); }
+ return $f;
+}
+
/*
Advance Search by POST (expects simple key/value pairs in post data)
eg. '{"name":"bas_","category":"edge:main:x86"}'