1<?php 2/** 3 * Include Plugin: displays a wiki page within another 4 * Usage: 5 * {{page>page}} for "page" in same namespace 6 * {{page>:page}} for "page" in top namespace 7 * {{page>namespace:page}} for "page" in namespace "namespace" 8 * {{page>.namespace:page}} for "page" in subnamespace "namespace" 9 * {{page>page#section}} for a section of "page" 10 * 11 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 12 * @author Esther Brunner <wikidesign@gmail.com> 13 * @author Christopher Smith <chris@jalakai.co.uk> 14 * @author Gina Häußge, Michael Klier <dokuwiki@chimeric.de> 15 */ 16 17if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 18if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 19require_once(DOKU_PLUGIN.'syntax.php'); 20 21/** 22 * All DokuWiki plugins to extend the parser/rendering mechanism 23 * need to inherit from this class 24 */ 25class syntax_plugin_include_include extends DokuWiki_Syntax_Plugin { 26 27 var $helper = null; 28 29 function getInfo() { 30 return array( 31 'author' => 'Gina Häußge, Michael Klier, Esther Brunner', 32 'email' => 'dokuwiki@chimeric.de', 33 'date' => @file_get_contents(DOKU_PLUGIN . 'blog/VERSION'), 34 'name' => 'Include Plugin', 35 'desc' => 'Displays a wiki page (or a section thereof) within another', 36 'url' => 'http://dokuwiki.org/plugin:include', 37 ); 38 } 39 40 function getType() { return 'substition'; } 41 function getSort() { return 303; } 42 function getPType() { return 'block'; } 43 44 function connectTo($mode) { 45 $this->Lexer->addSpecialPattern("{{page>.+?}}", $mode, 'plugin_include_include'); 46 $this->Lexer->addSpecialPattern("{{section>.+?}}", $mode, 'plugin_include_include'); 47 } 48 49 function handle($match, $state, $pos, &$handler) { 50 51 $match = substr($match, 2, -2); // strip markup 52 list($match, $flags) = explode('&', $match, 2); 53 54 // break the pattern up into its parts 55 list($mode, $page, $sect) = preg_split('/>|#/u', $match, 3); 56 return array($mode, $page, cleanID($sect), explode('&', $flags)); 57 } 58 59 function render($format, &$renderer, $data) { 60 if($format == 'metadata') { 61 list($mode, $page, $sect, $flags, $scope) = $data; 62 resolve_pageid(curNS($scope), $page, $exists); 63 $renderer->meta['relation']['haspart'][$page] = true; 64 return true; 65 } 66 return false; 67 } 68} 69// vim:ts=4:sw=4:et:enc=utf-8: 70