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 10class syntax_plugin_include_wrap extends DokuWiki_Syntax_Plugin { 11 12 function getType() { 13 return 'formatting'; 14 } 15 16 function getSort() { 17 return 50; 18 } 19 20 function handle($match, $state, $pos, Doku_Handler $handler) { 21 // this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser 22 } 23 24 /** 25 * Wraps the included page in a div and writes section edits for the action component 26 * so it can detect where an included page starts/ends. 27 * 28 * @author Michael Klier <chi@chimeric.de> 29 * @author Michael Hamann <michael@content-space.de> 30 */ 31 function render($mode, Doku_Renderer $renderer, $data) { 32 if ($mode == 'xhtml') { 33 list($state, $page, $redirect, $secid) = $data; 34 switch($state) { 35 case 'open': 36 if ($redirect) { 37 if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions 38 $renderer->startSectionEdit(0, array('target' => 'plugin_include_start', 'name' => $page)); 39 } else { 40 $renderer->startSectionEdit(0, 'plugin_include_start', $page); 41 } 42 } else { 43 if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions 44 $renderer->startSectionEdit(0, array('target' => 'plugin_include_start_noredirect', 'name' => $page)); 45 } else { 46 $renderer->startSectionEdit(0, 'plugin_include_start_noredirect', $page); 47 } 48 } 49 $renderer->finishSectionEdit(); 50 // Start a new section with type != section so headers in the included page 51 // won't print section edit buttons of the parent page 52 if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions 53 $renderer->startSectionEdit(0, array('target' => 'plugin_include_end', 'name' => $page)); 54 } else { 55 $renderer->startSectionEdit(0, 'plugin_include_end', $page); 56 } 57 if ($secid === NULL) { 58 $id = ''; 59 } else { 60 $id = ' id="'.$secid.'"'; 61 } 62 $renderer->doc .= '<div class="plugin_include_content plugin_include__' . $page .'"'.$id.'>' . DOKU_LF; 63 if (is_a($renderer,'renderer_plugin_dw2pdf')) { 64 $renderer->doc .= '<a name="'.$secid.'" />'; 65 } 66 break; 67 case 'close': 68 $renderer->finishSectionEdit(); 69 $renderer->doc .= '</div>' . DOKU_LF; 70 break; 71 } 72 return true; 73 } 74 return false; 75 } 76} 77// vim:ts=4:sw=4:et: 78