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