1<?php 2/** 3 * Include plugin (wrapper component) 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Michael Klier <chi@chimeric.de> 7 * @author Michael Hamann <michael@content-space.de> 8 */ 9 10if (!defined('DOKU_INC')) 11 define('DOKU_INC', realpath(dirname(__FILE__) . '/../../') . '/'); 12if (!defined('DOKU_PLUGIN')) 13 define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 14require_once (DOKU_PLUGIN . 'syntax.php'); 15 16class syntax_plugin_include_wrap extends DokuWiki_Syntax_Plugin { 17 18 function getType() { 19 return 'formatting'; 20 } 21 22 function getSort() { 23 return 50; 24 } 25 26 function handle($match, $state, $pos, &$handler) { 27 // this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser 28 } 29 30 /** 31 * Wraps the included page in a div and writes section edits for the action component 32 * so it can detect where an included page starts/ends. 33 * 34 * @author Michael Klier <chi@chimeric.de> 35 * @author Michael Hamann <michael@content-space.de> 36 */ 37 function render($mode, &$renderer, $data) { 38 if ($mode == 'xhtml') { 39 switch($data[0]) { 40 case 'open': 41 $renderer->startSectionEdit(0, 'plugin_include_start', $data[1]); 42 $renderer->finishSectionEdit(); 43 // Start a new section with type != section so headers in the included page 44 // won't print section edit buttons of the parent page 45 $renderer->startSectionEdit(0, 'plugin_include_end', $data[1]); 46 $renderer->doc .= '<div class="plugin_include_content plugin_include__' . $data[1] . '">' . DOKU_LF; 47 break; 48 case 'close': 49 $renderer->finishSectionEdit(); 50 $renderer->doc .= '</div>' . DOKU_LF; 51 break; 52 } 53 return true; 54 } 55 return false; 56 } 57} 58// vim:ts=4:sw=4:et: 59