'bektek', 'email' => 'bektek@gmail.com', 'date' => '2005-07-02', 'name' => 'ISBN Plugin', 'desc' => 'ISBN - link to amazon.com and show image', 'url' => 'http://www.dokuwiki.org/plugin:isbn', ); } /** * What kind of syntax are we? */ function getType(){ return 'substition'; } /** * Where to sort in? */ function getSort(){ return 322; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern("~~isbn:.+?~~",$mode,'plugin_isbn'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ $match = substr($match,7,-2); // Strip markup $match = preg_split('/\|/u',$match,2); // Split title from URL // Check alignment $ralign = (bool)preg_match('/^ /',$match[0]); $lalign = (bool)preg_match('/ $/',$match[0]); if ($lalign & $ralign) $align = 'center'; else if ($ralign) $align = 'right'; else if ($lalign) $align = 'left'; else $align = NULL; if (!isset($match[1])) $match[1] = NULL; return array(trim($match[0]),trim($match[1]),$align); } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ $isbn = $data[0]; $target = '_blank'; // You may adjust this $href = 'http://www.amazon.com/exec/obidos/ISBN='.$isbn; $imglink = 'http://images.amazon.com/images/P/'.$isbn.'.01.MZZZZZZZ.gif'; $title = ($data[1] ? htmlspecialchars($data[1]) : $isbn); $src = DOKU_BASE.'lib/exe/fetch.php?media='.urlencode($imglink); $renderer->doc .= ''; $renderer->doc .= ''.$title.''; $renderer->doc .= ''; return true; } return false; } } //Setup VIM: ex: et ts=4 enc=utf-8 : ?>