Show
Ignore:
Timestamp:
10/24/06 16:45:25 (4 years ago)
Author:
mbonetti
Message:

Initial work to implement OpenSearch? capabilities in Gregarius.
See:
http://developer.mozilla.org/en/docs/Supporting_search_suggestions_in_search_plugins

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/api.php

    r1544 r1613  
    4949        blGetItems($cid,$date,$markread); 
    5050        break; 
    51     } 
     51    case 'search': 
     52        rss_require('extlib/JSON.php'); 
     53        $json = new Services_JSON(); 
     54        $query = sanitize(@$_REQUEST['q'], RSS_SANITIZER_WORDS); 
     55        if ($query) { 
     56            $res = osSearch($query); 
     57        } else { 
     58            $res = array($query,array()); 
     59        } 
     60        header('Content-Type: application/json'); 
     61        die ($json->encode($res)); 
     62        break; 
     63    } 
     64 
    5265} 
    5366 
     
    195208 
    196209} 
     210 
     211function osSearch($q) { 
     212    rss_require('cls/search.php'); 
     213    $sil = new SearchItemList($q,5); 
     214    $results = array(); 
     215    foreach($sil -> feeds as $feed) { 
     216        foreach($feed -> items as $item) { 
     217            $results[] = $item -> title; 
     218        } 
     219    } 
     220    return array($q,$results); 
     221} 
    197222?>