1<?php 2/** 3 * Plugin XSLT : Perform XSL Transformation on provided XML data 4 * 5 * To be run with Dokuwiki only 6 * 7 * Sample data provided at the end of the file 8 * 9 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 10 * @author R�mi Peyronnet <remi+xslt@via.ecp.fr> 11 12 onmouseover : ouvre un popup au dessus, et affiche url contenant le texte 13 14 {[url:mode!http://toto?value=]} 15 {[url:mode!inline]} 16 {[url:mode!wiki]} 17 {[ignore:cam]} 18 {[style:]} 19 {[mode!texte|affich�]} 20 21 tri dvd invers� (sort) 22 23 Shift + Refresh pour raffraichir sous firefox 24 25 */ 26 27if(!defined('DOKU_INC')) die(); 28if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 29require_once(DOKU_PLUGIN.'syntax.php'); 30 31class syntax_plugin_embedover extends DokuWiki_Syntax_Plugin { 32 33 public $urls = array(); 34 public $styles = array(); 35 36 function getInfo(){ 37 return array( 38 'author' => 'R�mi Peyronnet', 39 'email' => 'remi+embedover@via.ecp.fr', 40 'date' => '2009-05-03', 41 'name' => 'EmbedOver Plugin', 42 'desc' => 'Embed in an overlay a remote web/wiki page', 43 'url' => 'http://people.via.ecp.fr/~remi/', 44 ); 45 } 46 47 function getType() { return 'substition'; } 48 function getPType() { return 'normal'; } 49 function getSort() { return 4212; } 50 function connectTo($mode) { $this->Lexer->addSpecialPattern('{\([^}]*\)}',$mode,'plugin_embedover'); } 51 52 function handle($match, $state, $pos, Doku_Handler $handler) 53 { 54 switch ($state) { 55 case DOKU_LEXER_SPECIAL : 56 $data = ''; 57 // URLs 58 if (preg_match('/{\(url\:((?<mode>.*)!)?(?<text>[^|]*)\)}/', $match, $matches)) 59 { 60 if (!$matches[mode]) $matches[mode] = 'default'; 61 $this->urls[$matches[mode]] = $matches[text]; 62 $data = '{[embedover_div]}'; 63 } 64 // Style 65 else if (preg_match('/{\(style\:((?<mode>.*)!)?(?<text>[^|]*)\)}/', $match, $matches)) 66 { 67 if (!$matches[mode]) $matches[mode] = 'default'; 68 $this->styles[$matches[mode]] = $matches[text]; 69 } 70 // Items 71 else if (preg_match('/{\(((?<mode>.*)!)?(?<text>[^|]*)(\|(?<aff>.*))?\)}/', $match, $matches)) 72 { 73 if (!$matches[aff]) $matches[aff] = $matches[text]; 74 if (!$matches[mode]) $matches[mode] = 'default'; 75 $dest = $this->urls[$matches[mode]] . urlencode($matches[text]); 76 $style = $this->styles[$matches[mode]]; 77 if ($matches[aff]) $data = "<span class='embedover' onclick='embedover_click(event, \"$dest\", \"$style\");'>${matches[aff]}</span>"; 78 } 79 return array($state, $data); 80 81 case DOKU_LEXER_UNMATCHED : return array($state, $match); 82 case DOKU_LEXER_ENTRY : return array($state, ''); 83 case DOKU_LEXER_EXIT : return array($state, ''); 84 } 85 return array(); 86 } 87 88 function render($mode, Doku_Renderer $renderer, $data) 89 { 90 if($mode == 'xhtml'){ 91 list($state, $match) = $data; 92 switch ($state) { 93 case DOKU_LEXER_SPECIAL : 94 if ($match == '{[embedover_div]}') 95 { 96 $renderer->doc .= "<iframe id='embedover_div' scrolling='no' marginwidth='0' marginheight='0' frameborder='0' vspace='0' hspace='0'></iframe>"; 97 } 98 else 99 { 100 $renderer->doc .= $match; 101 } 102 break; 103 104 case DOKU_LEXER_UNMATCHED : $renderer->doc .= $renderer->_xmlEntities($match); break; 105 case DOKU_LEXER_EXIT : $renderer->doc .= ""; break; 106 } 107 return true; 108 } 109 return false; 110 } 111} 112 113 114/* 115 116Sample data : 117 118*/ 119 120?>