Example #1
0
function _update()
{
    global $conf;
    $data = array();
    _quietecho("Searching pages... ");
    search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true));
    _quietecho(count($data) . " pages found.\n");
    foreach ($data as $val) {
        _index($val['id']);
    }
}
function _update()
{
    global $conf;
    // upgrade to version 2
    if (!@file_exists($conf['indexdir'] . '/pageword.idx')) {
        _lock();
        idx_upgradePageWords();
        _unlock();
    }
    $data = array();
    _quietecho("Searching pages... ");
    search($data, $conf['datadir'], 'search_allpages', array());
    _quietecho(count($data) . " pages found.\n");
    foreach ($data as $val) {
        _index($val['id']);
    }
}
Example #3
0
function macro_BackLinks($formatter, $value = '', $params = array())
{
    global $Config;
    // setup dynamic macro
    if ($formatter->_macrocache and empty($params['call'])) {
        return $formatter->macro_cache_repl('BackLinks', $value);
    }
    if (empty($params['call'])) {
        $formatter->_dynamic_macros['@BackLinks'] = 1;
    }
    if (!isset($value[0]) || $value === true) {
        $value = $formatter->page->name;
    }
    $params['backlinks'] = 1;
    $params['call'] = 1;
    $hits = macro_FullSearch($formatter, $value, $params);
    // $hits is sorted array
    $out = '';
    $title = '';
    // check the internal category parameter
    if (!isset($params['.category'])) {
        if (isset($Config['category_regex'][0]) && preg_match('@' . $Config['category_regex'] . '@', $value, $m, PREG_OFFSET_CAPTURE)) {
            if (isset($m[1])) {
                $params['.category'] = $m[1];
            } else {
                $params['.category'] = substr($value, strlen($m[0][0]));
            }
            // FIXME
        }
    }
    if (isset($params['.category'][0])) {
        // check subcategories
        $category = $params['.category'];
        $title = '<h2>' . sprintf(_("Pages in category \"%s\"."), _html_escape($category)) . '</h2>';
        $cats = array();
        foreach ($hits as $p => $c) {
            if (preg_match('@' . $Config['category_regex'] . '@', $p, $m, PREG_OFFSET_CAPTURE)) {
                if (isset($m[1])) {
                    $cats[$p] = $m[1];
                } else {
                    $cats[$p] = substr($p, strlen($m[0][0]));
                }
                // FIXME
                unset($hits[$p]);
            }
        }
        if (count($cats) > 0) {
            $params['.count'] = true;
            $out = '<h2>' . _("Subcategories") . '</h2>';
            $out .= _index($formatter, $cats, $params);
            $params['.count'] = false;
        }
    } else {
        if (empty($params['.notitle'])) {
            $title = '<h2>' . sprintf(_("BackLinks of \"%s\"."), _html_escape($value)) . '</h2>' . "\n";
        }
    }
    $index = _index($formatter, $hits, $params);
    if ($index !== false) {
        return $out . $title . $index;
    }
    if (empty($out)) {
        if (isset($params['.category'][0])) {
            return '<h2>' . sprintf(_("No pages found in category \"%s\"."), _html_escape($params['.category'])) . '</h2>';
        } else {
            return '<h2>' . _("No backlinks found.") . '</h2>';
        }
    }
    return $out;
}