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 $state = array_shift($data); 34 switch($state) { 35 case 'open': 36 list($page, $redirect, $secid) = $data; 37 if ($redirect) { 38 if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions 39 $renderer->startSectionEdit(0, array('target' => 'plugin_include_start', 'name' => $page, 'hid' => '')); 40 } else { 41 $renderer->startSectionEdit(0, 'plugin_include_start', $page); 42 } 43 } else { 44 if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions 45 $renderer->startSectionEdit(0, array('target' => 'plugin_include_start_noredirect', 'name' => $page, 'hid' => '')); 46 } else { 47 $renderer->startSectionEdit(0, 'plugin_include_start_noredirect', $page); 48 } 49 } 50 $renderer->finishSectionEdit(); 51 // Start a new section with type != section so headers in the included page 52 // won't print section edit buttons of the parent page 53 if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions 54 $renderer->startSectionEdit(0, array('target' => 'plugin_include_end', 'name' => $page, 'hid' => '')); 55 } else { 56 $renderer->startSectionEdit(0, 'plugin_include_end', $page); 57 } 58 if ($secid === NULL) { 59 $id = ''; 60 } else { 61 $id = ' id="'.$secid.'"'; 62 } 63 $renderer->doc .= '<div class="plugin_include_content plugin_include__' . $page .'"'.$id.'>' . DOKU_LF; 64 if (is_a($renderer,'renderer_plugin_dw2pdf')) { 65 $renderer->doc .= '<a name="'.$secid.'" />'; 66 } 67 break; 68 case 'close': 69 $renderer->finishSectionEdit(); 70 $renderer->doc .= '</div>' . DOKU_LF; 71 break; 72 } 73 return true; 74 } 75 return false; 76 } 77} 78// vim:ts=4:sw=4:et: 79