*/ 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_abb extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo() { return array ( 'author' => 'Ferdinand Soethe', 'email' => 'ferdinand@apache.org', 'date' => '2007-11-11', 'name' => 'abb - Enhanced Image Plugin', 'desc' => 'Embed images with the full power of html img-tag', 'url' => 'http://www.dokuwiki.org/wiki:abb', ); } /** * What kind of syntax are we? */ function getType() { return 'substition'; } /** * What about paragraphs? (optional) */ function getPType() { return 'block'; } /** * Where to sort in? */ function getSort() { return 999; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('~~ABB.*?~~', $mode, 'plugin_abb'); } /** * Handle the match */ function handle($match, $state, $pos, & $handler) { $resultStr = ''; $paramsArr = explode('~', $match); for ($i = 0; $i < count($paramsArr); $i++) { $paramPairArr = explode('=', $paramsArr[$i]); switch ($paramPairArr[0]) { case 'ABB' : break; case '' : break; case 'src' : $resultStr .= ' src="' . ml($paramPairArr[1], '') . '"'; break; case 'title' : $resultStr .= ' title="' . htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8') . '"'; break; case 'alt' : $resultStr .= ' alt="' . htmlspecialchars($paramPairArr[1], ENT_QUOTES, 'UTF-8') . '"'; break; default : $resultStr .= ' ' . $paramPairArr[0] . '="' . $paramPairArr[1] . '"'; break; } } return ''; } /** * Create output */ function render($mode, & $renderer, $data) { if ($mode == 'xhtml') { $renderer->doc .= $data; // ptype = 'normal' return true; } return false; } }