1<?php 2/** 3 * Siteexport Plugin 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author i-net software <tools@inetsoftware.de> 7 * @author Gerry Weissbach <gweissbach@inetsoftware.de> 8 */ 9 10if (!defined('DOKU_INC')) die(); 11if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 12require_once(DOKU_PLUGIN . 'syntax.php'); 13 14/** 15 * All DokuWiki plugins to extend the parser/rendering mechanism 16 * need to inherit from this class 17 */ 18class syntax_plugin_siteexport_siteexport extends DokuWiki_Syntax_Plugin { 19 20 private $headers = array(); 21 22 public function getType() { return 'substition'; } 23 public function getPType() { return 'block'; } 24 public function getSort() { return 300; } 25 26 public function connectTo($mode) { 27 $this->Lexer->addSpecialPattern('\{\{siteexport .*?\}\}', $mode, 'plugin_siteexport_siteexport'); 28 } 29 30 public function handle($match, $state, $pos, Doku_Handler $handler) { 31 32 $options = explode(' ', trim(substr($match, 2, -2)?:"")); 33 return $options; 34 } 35 36 public function render($mode, Doku_Renderer $renderer, $data) { 37 global $ID, $conf, $INFO; 38 39 $namespace = $INFO['id'] != $ID ? $INFO['id'] : $ID; 40 $id = $INFO['id'] != $ID ? $INFO['id'] : $ID; 41 42 if ($mode == 'xhtml'){ 43 44 $renderer->info['toc'] = false; 45 $renderer->nocache(); 46 47 $formParams = array( 'id' => sectionID('siteexport_siteexporter', $this->headers), 'action' => wl($id), 'class' => 'siteexport siteexporter' ); 48 $form = new Doku_Form($formParams); 49 50 $form->addHidden('ns', $id); 51 $form->addHidden('site', $id); 52 $form->addHidden('baseID', $id); 53 54 $submitLabel = $this->getLang('SiteSubmitLabel'); 55 foreach( $data as $option ) { 56 57 list($key, $value) = explode('=', $option); 58 switch ($key) { 59 case "buttonTitle": 60 $submitLabel = urldecode($value); 61 break; 62 default: 63 $form->addHidden($key, $value); 64 break; 65 } 66 } 67 68 $renderer->doc .= '<div class="siteexporter">'; 69 $form->addElement(form_makeButton('submit', 'siteexport', $submitLabel, array('class' => 'button download'))); 70 71 ob_start(); 72 $form->printForm(); 73 $renderer->doc .= ob_get_contents(); 74 ob_end_clean(); 75 76 $renderer->doc .= '</div>'; 77 return false; 78 } else if ($mode == 'metadata') { 79 $renderer->meta['siteexport']['siteexporter'] = true; 80 $renderer->meta['siteexport']['baseID'] = $namespace; 81 } 82 83 return false; 84 } 85} 86 87//Setup VIM: ex: et ts=4 enc=utf-8 : 88