16a1594b7SMichael Klier<?php 26a1594b7SMichael Klier/** 36a1594b7SMichael Klier * Include plugin (editbtn header component) 46a1594b7SMichael Klier * 56a1594b7SMichael Klier * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 66a1594b7SMichael Klier * @author Michael Klier <chi@chimeric.de> 76a1594b7SMichael Klier */ 86a1594b7SMichael Klier 96a1594b7SMichael Klierif (!defined('DOKU_INC')) 106a1594b7SMichael Klier define('DOKU_INC', realpath(dirname(__FILE__) . '/../../') . '/'); 116a1594b7SMichael Klierif (!defined('DOKU_PLUGIN')) 126a1594b7SMichael Klier define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 136a1594b7SMichael Klierrequire_once (DOKU_PLUGIN . 'syntax.php'); 146a1594b7SMichael Klier 156a1594b7SMichael Klierclass syntax_plugin_include_editbtn extends DokuWiki_Syntax_Plugin { 166a1594b7SMichael Klier 176a1594b7SMichael Klier function getInfo() { 186a1594b7SMichael Klier return array ( 196a1594b7SMichael Klier 'author' => 'Gina Häußge, Michael Klier', 206a1594b7SMichael Klier 'email' => 'dokuwiki@chimeric.de', 216a1594b7SMichael Klier 'date' => @file_get_contents(DOKU_PLUGIN . 'blog/VERSION'), 226a1594b7SMichael Klier 'name' => 'Include Plugin (permalink header component)', 236a1594b7SMichael Klier 'desc' => 'Provides a header instruction which renders a permalink to the included page', 246a1594b7SMichael Klier 'url' => 'http://wiki.splitbrain.org/plugin:include', 256a1594b7SMichael Klier ); 266a1594b7SMichael Klier } 276a1594b7SMichael Klier 286a1594b7SMichael Klier function getType() { 296a1594b7SMichael Klier return 'formatting'; 306a1594b7SMichael Klier } 316a1594b7SMichael Klier 326a1594b7SMichael Klier function getSort() { 336a1594b7SMichael Klier return 50; 346a1594b7SMichael Klier } 356a1594b7SMichael Klier 366a1594b7SMichael Klier function handle($match, $state, $pos, &$handler) { 376a1594b7SMichael Klier // this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser 386a1594b7SMichael Klier } 396a1594b7SMichael Klier 406a1594b7SMichael Klier /** 416a1594b7SMichael Klier * Renders an include edit button 426a1594b7SMichael Klier * 436a1594b7SMichael Klier * @author Michael Klier <chi@chimeric.de> 446a1594b7SMichael Klier */ 456a1594b7SMichael Klier function render($mode, &$renderer, $data) { 46225daccdSMichael Klier global $lang; 476a1594b7SMichael Klier list($page, $sect, $sect_title, $redirect_id) = $data; 486a1594b7SMichael Klier if ($mode == 'xhtml') { 49225daccdSMichael Klier $title = ($sect) ? $sect_title : $page; 50225daccdSMichael Klier $params = array('do' => 'edit', 516a1594b7SMichael Klier 'redirect_id' => $redirect_id, 52225daccdSMichael Klier 'id' => $page); 53225daccdSMichael Klier $xhtml .= '<div class="secedit">' . DOKU_LF; 54*c8a489faSMichael Klier $xhtml .= '<form class="button btn_incledit" method="post" action="' . DOKU_SCRIPT . '"><div class="no">' . DOKU_LF; 55225daccdSMichael Klier foreach($params as $key => $val) { 56225daccdSMichael Klier $xhtml .= '<input type="hidden" name="'.$key.'" '; 57225daccdSMichael Klier $xhtml .= 'value="'.htmlspecialchars($val).'" />'; 58225daccdSMichael Klier } 5912121da4SMichael Klier $xhtml .= '<input type="submit" value="'.htmlspecialchars($lang['btn_secedit']).' (' . $page . ')" class="button" title="'.$title.'"/>' . DOKU_LF; 60225daccdSMichael Klier $xhtml .= '</div></form>' . DOKU_LF; 61225daccdSMichael Klier $xhtml .= '</div>' . DOKU_LF; 626a1594b7SMichael Klier $renderer->doc .= $xhtml; 636a1594b7SMichael Klier return true; 646a1594b7SMichael Klier } 656a1594b7SMichael Klier return false; 666a1594b7SMichael Klier } 676a1594b7SMichael Klier} 686a1594b7SMichael Klier// vim:ts=4:sw=4:et:enc=utf-8: 69