url|texte]] (comme un lien normal...) * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Etienne Mauvais */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_piclens extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Etienne M.', 'email' => 'emauvaisfr@yahoo.fr', 'date' => '2008-10-07', 'name' => 'piclens Plugin', 'desc' => html_entity_decode($this->getLang('pic_description')), 'url' => 'http://www.dokuwiki.org/plugin:piclens', ); } /** * What kind of syntax are we? */ function getType(){ return 'disabled'; } /** * What kind of syntax do we allow (optional) */ function getAllowedTypes() { return array('disabled'); } /** * What about paragraphs? (optional) */ function getPType(){ return 'normal'; } /** * Where to sort in? */ function getSort(){ return 30; } /** * Connect pattern to lexer */ function connectTo($mode) { //$this->Lexer->addEntryPattern('\x3Cpiclens (?=.*/\x3E)',$mode,'plugin_piclens'); $this->Lexer->addEntryPattern('\x5B\x5Bpiclens>(?=.*\x5D\x5D)',$mode,'plugin_piclens'); } function postConnect() { $this->Lexer->addExitPattern('\x5D\x5D', 'plugin_piclens'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ switch ($state) { case DOKU_LEXER_ENTER : break; case DOKU_LEXER_MATCHED : break; case DOKU_LEXER_UNMATCHED : break; case DOKU_LEXER_EXIT : break; case DOKU_LEXER_SPECIAL : break; } return array($match, $state); } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ if ($data[1] == DOKU_LEXER_ENTER){ //Inclusion des scripts piclens $renderer->doc .= ''; } else if ($data[1] == DOKU_LEXER_UNMATCHED){ //Création du lien //Récupération du feedUrl et du texte $val=split("\|", $data[0]); if ($val[0]) { if ($val[1]=="") $val[1]=$val[0]; $val[1]=preg_replace("/ *?$/","",$val[1]); $renderer->doc .= ''.$val[1].''; } } else if ($data[1] == DOKU_LEXER_EXIT){ //Si le client piclens n'est pas installé, on ajoute un lien qui renvoie vers la page de téléchargement $renderer->doc .= ''; } return true; } return false; } }