예제 #1
0
        }
        // endforeach
    }
    // endforeach
    return $macros;
}
$macros = parse_xml();
if (!$macros) {
    $w->result('reeder.result', 'na', 'No results found', 'No search results found matching your query', 'icon.png', 'no');
} elseif ($filter) {
    // If keyword is given, do a filter
    foreach ($macros as $macro) {
        // Very simple filtering, but works quite well.
        // Real fuzzy matching would be nice, but thats a wishlist item.
        $match = strpos($macro['match'], $filter);
        if ($match !== false) {
            $w->result($macro['uid'], $macro['uid'], $macro['name'], $macro['name'], 'icon.png', 'yes');
        }
    }
    // If no matches, return this.
    if (!$w->results()) {
        $w->result('reeder.result', 'na', 'No results found', 'No macros matched your query', 'icon.png', 'no');
    }
} else {
    // Return all available macros
    foreach ($macros as $macro) {
        $w->result($macro['uid'], $macro['uid'], $macro['name'], $macro['name'], 'icon.png', 'yes');
    }
}
echo $w->toXML();