Exemple #1
0
function wikiplugin_list($data, $params)
{
    global $prefs;
    static $i;
    $i++;
    $unifiedsearchlib = TikiLib::lib('unifiedsearch');
    $query = new Search_Query();
    if (!isset($params['searchable_only']) || $params['searchable_only'] == 1) {
        $query->filterIdentifier('y', 'searchable');
    }
    $unifiedsearchlib->initQuery($query);
    $matches = WikiParser_PluginMatcher::match($data);
    $tsret = applyTablesorter($matches, $query);
    $builder = new Search_Query_WikiBuilder($query);
    $builder->enableAggregate();
    if (!empty($tsret['max']) || !empty($_GET['numrows'])) {
        $max = !empty($_GET['numrows']) ? $_GET['numrows'] : $tsret['max'];
        $builder->wpquery_pagination_max($query, $max);
    }
    $builder->apply($matches);
    $paginationArguments = $builder->getPaginationArguments();
    if (!empty($_REQUEST[$paginationArguments['sort_arg']])) {
        $query->setOrder($_REQUEST[$paginationArguments['sort_arg']]);
    }
    if (!($index = $unifiedsearchlib->getIndex())) {
        return '';
    }
    $result = $query->search($index);
    $result->setId('wplist-' . $i);
    $resultBuilder = new Search_ResultSet_WikiBuilder($result);
    $resultBuilder->setPaginationArguments($paginationArguments);
    $resultBuilder->apply($matches);
    $builder = new Search_Formatter_Builder();
    $builder->setPaginationArguments($paginationArguments);
    $builder->setId('wplist-' . $i);
    $builder->setCount($result->count());
    $builder->setTsOn($tsret['tsOn']);
    $builder->apply($matches);
    $result->setTsSettings($builder->getTsSettings());
    $formatter = $builder->getFormatter();
    $result->setTsOn($tsret['tsOn']);
    $out = $formatter->format($result);
    return $out;
}