page}} to display the backlinks page in the current namespace * {{backlinks>:page}} for "page" in top namespace * {{backlinks>namespace:page}} for "page" in namespace "namespace" * {{backlinks>.namespace:page}} for "page" in subnamespace "namespace" * */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); require_once(DOKU_INC.'inc/fulltext.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_backlinks extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Jonathan Arkell', 'email' => 'jonnay@jonnay.net', 'date' => '2005-10-24', 'name' => 'Backlink Plugin', 'desc' => 'Displays the backlinks for the given wikipage', 'url' => 'https://www.dokuwiki.org/plugin:backlinks', ); } /** * What kind of syntax are we? */ function getType(){ return 'substition'; } /** * Where to sort in? */ function getSort(){ return 30; } /** * Paragraph Type */ function getPType(){ return 'block'; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern("{{backlinks}}",$mode,'plugin_backlinks'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ global $ID; $syntax = substr($match,12,-2); // strip markup $page = $ID; resolve_pageid(getNS($ID),$page,$exists); // resolve shortcuts // check for permission if (auth_quickaclcheck($page) < 1) return false; $links = ft_backlinks($page); foreach ($links as $link) { $backlinks[substr($link, strrpos($link, ':')+1)] = $link; } ksort($backlinks); return array($page,$backlinks); } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ $file = wikiFN($data[0]); $renderer->doc .= '