1<?php 2/** 3 * Mediasyntax Plugin, external link component: Mediawiki style external links 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Thorsten Staerk 7 */ 8class syntax_plugin_mediasyntax_link extends DokuWiki_Syntax_Plugin 9{ 10 11 function getType(){ return 'protected'; } 12 13 function getSort(){ return 101; } 14 15 function connectTo($mode) 16 { 17 $this->Lexer->addEntryPattern( 18 '\[http(?=.*?\])', 19 $mode, 20 'plugin_mediasyntax_link' 21 ); 22 } 23 24 function postConnect() 25 { 26 $this->Lexer->addExitPattern( 27 '\]', 28 'plugin_mediasyntax_link' 29 ); 30 } 31 32 function handle($match, $state, $pos, Doku_Handler $handler) 33 { 34 if ($state == DOKU_LEXER_UNMATCHED) 35 { 36 $target="http".$match; 37 $targets=explode(' ',$target); 38 $cleartext=preg_replace("/^(.*?) /", "", $match); 39 $handler->addCall('externallink', array($targets[0],$cleartext), $pos); 40 } 41 return true; 42 } 43 44 function render($mode, Doku_Renderer $renderer, $data) { return true; } 45} 46 47//Setup VIM: ex: et ts=4 enc=utf-8 : 48