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