1<?php 2/** 3 * MELLEL Plugin: Exports to MELLEL 4 * 5 * @author Simon Bruechner 6 */ 7 8// must be run within Dokuwiki 9if(!defined('DOKU_INC')) die(); 10 11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 12require_once(DOKU_PLUGIN.'syntax.php'); 13 14class syntax_plugin_mellelexport extends DokuWiki_Syntax_Plugin { 15 16 /** 17 * return some info 18 */ 19 function getInfo(){ 20 return confToHash(dirname(__FILE__).'/plugin.info.txt'); 21 } 22 23 /** 24 * What kind of syntax are we? 25 */ 26 function getType(){ 27 return 'substition'; 28 } 29 30 /** 31 * What about paragraphs? 32 */ 33 function getPType(){ 34 return 'normal'; 35 } 36 37 /** 38 * Where to sort in? 39 */ 40 function getSort(){ 41 return 318; // Before image detection, which uses {{...}} and is 320 42 } 43 44 /** 45 * Connect pattern to lexer 46 */ 47 function connectTo($mode) { 48 $this->Lexer->addSpecialPattern('~~MELLEL~~', $mode, 'plugin_mellelexport'); 49 } 50 51 /** 52 * Handle the match 53 */ 54 function handle($match, $state, $pos, Doku_Handler $handler){ 55 // Export button 56 if ($match == '~~MELLEL~~') { return array(); } 57 } 58 59 /** 60 * Create output 61 */ 62 function render($format, Doku_Renderer $renderer, $data) { 63 global $ID, $REV; 64 if (!$data) { // Export button 65 if($format != 'xhtml') { 66 return false; 67 } 68 $renderer->doc .= '<a href="'.exportlink($ID, 'mellelexport', ($REV != '' ? 'rev='.$REV : '')).'?purge=1&dummy='.microtime(true).'" title="Export page to Redit Mellel format">'; 69 $renderer->doc .= '<img src="'.DOKU_BASE.'lib/plugins/mellelexport/MellelDocument.png" align="right" alt="Export page to Redit Mellel format" width="48" height="48" />'; 70 $renderer->doc .= '</a>'; 71 return true; 72 } else { // Extended info 73 list($info_type, $info_value) = $data; 74 if ($info_type == "template") { // Template-based export 75 $renderer->template = $info_value; 76 } 77 } 78 return false; 79 } 80 81}