コード例 #1
0
ファイル: search.php プロジェクト: mroussel/flatpress
function search_do($keywords)
{
    global $smarty, $srchresults;
    // get parameters
    $srchkeywords = $keywords;
    $params = array();
    $params['start'] = 0;
    $params['count'] = -1;
    !empty($_GET['Date_Day']) && $_GET['Date_Day'] != '--' ? $params['d'] = $_GET['Date_Day'] : null;
    isset($_GET['Date_Month']) && $_GET['Date_Month'] != '--' ? $params['m'] = $_GET['Date_Month'] : null;
    !empty($_GET['Date_Year']) && $_GET['Date_Year'] != '--' ? $params['y'] = substr($_GET['Date_Year'], 2) : null;
    isset($_GET['cats']) ? $params = $_GET['cats'] : null;
    $params['fullparse'] = false;
    if (!empty($_GET['stype']) && $_GET['stype'] == 'full') {
        $params['fullparse'] = true;
    }
    $srchparams = $params;
    $list = array();
    $q = new FPDB_Query($params, null);
    while ($q->hasMore()) {
        list($id, $e) = $q->getEntry();
        $match = false;
        if ($keywords == '*') {
            $match = true;
        } else {
            $match = strpos(strtolower($e['subject']), $keywords) !== false;
            if (!$match && $params['fullparse']) {
                $match = strpos(strtolower($e['content']), $keywords) !== false;
            }
        }
        if ($match) {
            $list[$id] = $e;
        }
    }
    $smarty->register_block('search_result_block', 'smarty_search_results_block');
    $smarty->register_block('search_result', 'smarty_search_result');
    if (!$list) {
        $smarty->assign('noresults', true);
    }
    $srchresults = $list;
}
コード例 #2
0
 function cache_create()
 {
     $this->index = array();
     /*
     		$o =& entry_init();
     		
     		$entries = $o->getList();
     */
     $o = new FPDB_Query(array('start' => 0, 'count' => -1, 'fullparse' => false), null);
     #foreach ($entries as $id => $contents) {
     while ($o->hasMore()) {
         list($id, $contents) = $o->getEntry();
         $date = date_from_id($id);
         echo $contents['subject'], "\n";
         $md5 = md5(sanitize_title($contents['subject']));
         $this->index[$date['y']][$date['m']][$date['d']][$md5] = $id;
     }
     #}
     $this->cache_save();
     io_write_file(PRETTYURLS_CACHE, 'dummy');
 }