diff options
author | Andreas Gohr <andi@splitbrain.org> | 2005-09-12 16:10:42 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2005-09-12 16:10:42 +0200 |
commit | 54f4c05648c376908a736854a2ad279d57ec5b19 (patch) | |
tree | 06dc8c0c3ec0124f9aed947b32afa46e21397d6e /inc/fulltext.php | |
parent | 6793fe33b8906da93fc2354dc1f3346957492295 (diff) | |
download | rpg-54f4c05648c376908a736854a2ad279d57ec5b19.tar.gz rpg-54f4c05648c376908a736854a2ad279d57ec5b19.tar.bz2 |
backlinks now use the new index based search
darcs-hash:20050912141042-7ad00-5ef43525c9fd7ba44206720c54bb566450f93250.gz
Diffstat (limited to 'inc/fulltext.php')
-rw-r--r-- | inc/fulltext.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/inc/fulltext.php b/inc/fulltext.php index 6c4e148a2..ff29f9deb 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -77,6 +77,48 @@ function ft_pageSearch($query,&$poswords){ } /** + * Returns the backlinks for a given page + * + * Does a quick lookup with the fulltext index, then + * evaluates the instructions of the found pages + */ +function ft_backlinks($id){ + global $conf; + $result = array(); + + // quick lookup of the pagename + $page = noNS($id); + $matches = idx_lookup(array($page)); + + if(!count($matches)) return $result; + require_once(DOKU_INC.'inc/parserutils.php'); + + + // check instructions for matching links + foreach(array_keys($matches[$page]) as $match){ + $instructions = p_cached_instructions(wikiFN($match),true); + if(is_null($instructions)) continue; + + $match_ns = getNS($match); + + foreach($instructions as $ins){ + if($ins[0] == 'internallink' || ($conf['camelcase'] && $ins[0] == 'camelcaselink') ){ + $link = $ins[1][0]; + resolve_pageid($match_ns,$link,$exists); //exists is not used + if($link == $id){ + //we have a match - finish + $result[] = $match; + break; + } + } + } + } + + sort($result); + return $result; +} + +/** * Quicksearch for pagenames * * By default it only matches the pagename and ignores the |