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 .= ''; return true; } return false; } function renderpageList(&$renderer, $pageList) { if (empty ($pageList)) { return; } $renderer->doc .= ''; } /** * Corrects relative internal links and media */ function _correctRelNS($instr,$incl){ global $ID; // check if included page is in same namespace $iNS = getNS($incl); if (getNS($ID) == $iNS) return $instr; // convert internal links and media from relative to absolute $n = count($instr); for($i = 0; $i < $n; $i++){ if (substr($instr[$i][0], 0, 8) == 'internal'){ // relative subnamespace if ($instr[$i][1][0]{0} == '.'){ $instr[$i][1][0] = $iNS.':'.substr($instr[$i][1][0], 1); // relative link } elseif (strpos($instr[$i][1][0],':') === false) { $instr[$i][1][0] = $iNS.':'.$instr[$i][1][0]; } } } return $instr; } } //Setup VIM: ex: et ts=4 enc=utf-8 :