]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/backlinks.php
PhpWiki 1.2.7 backport cvs release-1_2-branch enhancements never released with 1...
[SourceForge/phpwiki.git] / lib / backlinks.php
1 <?php
2    // Backlinks: returns pages which link to a given page.
3    rcs_id('$Id: backlinks.php,v 1.1.2.4 2005-01-07 14:23:04 rurban Exp $');
4
5
6    if(get_magic_quotes_gpc())
7       $refs = stripslashes($refs);
8    $pagename = $refs;
9
10    // No HTML markup allowed in $title.    
11    $title = sprintf(gettext("Pages which link to %s"),
12                     htmlspecialchars($pagename));
13    if (IsWikiPage($dbi, $pagename))   
14       $pagelink = LinkExistingWikiWord($pagename);
15    else   
16       $pagelink = LinkUnknownWikiWord($pagename);
17       
18    $html = ( "<p><b>"
19              . sprintf(gettext("Pages which link to %s") . " .....",
20                        $pagelink)
21              . "</b></p>\n<ul>\n" );
22
23    // search matching pages
24    $query = InitBackLinkSearch($dbi, $pagename);
25    $found = 0;
26    while ($page = BackLinkSearchNextMatch($dbi, $query)) {
27       $found++;
28       $html .= "<li>" . LinkExistingWikiWord($page) . "<br />\n";
29    }
30
31    $html .= "</ul>\n<hr noshade>\n"
32             . sprintf(gettext ("%d pages link to %s."),
33                       $found, $pagelink)
34             . "\n";
35
36    GeneratePage('MESSAGE', $html, $title, 0);
37 ?>