====== refworks plugin ====== FIXME This Plugin breaks image rendering as the syntax is the same to images: %%{{..}}%% ---- plugin ---- description: Insert citations as links to a RefWorks RefShare author : Daniel Terry email : dt232@cornell.edu type : syntax lastupdate : 2007-10-17 compatible : depends : conflicts : similar : tags : quotes, references, !broken ---- See http://rrowv.blogspot.com/2007/10/citation-management-and-interfacing.html for more info ===== syntax.php ===== The refworks URL needs to be set in the code (render() function). */ 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_refworks extends DokuWiki_Syntax_Plugin { //Report module information function getInfo() { return array( 'author' => 'Daniel Terry', 'email' => 'dt232@cornell.edu', 'date' => '2007-10-17', 'name' => 'RefWorks Citation Module', 'desc' => 'Insert citations as links to a RefWorks RefShare', 'url' => 'http://www.dokuwiki.org/plugin:refworks', ); } // function getType() { return 'substition'; } // Just after build in links function getSort() { return 217; } // Grab everything between {{ and }} function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{.+?\}\}',$mode,'plugin_refworks'); } // function postConnect() { // $this->Lexer->addExitPattern('','plugin_test'); // } /** * Handle the match */ function handle($match, $state, $pos, &$handler) { $data = trim(substr($match,2,-2)); // strip {{RefID= from start and }} from end $data = trim($data,";"); //remove trailing ; $ids = split(";",$data); //Error checking?? //if (!$data) { // trigger_error('Bad RefWorks ID: '.htmlspecialchars($match), E_USER_WARNING); // return FALSE; //} //Lookup data from RefWorks? return $ids; } /** * Create output */ function render($mode, &$renderer, $data) { if($mode != 'xhtml') { return false; } //RefWorks share URL: //http://www.refworks.com/refshare/?site=###/RWWS###/### //USER: PUT YOUR RefShare URL HERE!!! $RWURL = "http://www.refworks.com/refshare/?site=..."; $output = ""; foreach ($data as $entry) { list($refid,$entry) = explode(" ",$entry,2); $output .= "$entry; "; } $renderer->doc .= "[". substr($output,0,-2) ."]"; return true; } } //Setup VIM: ex: et ts=4 enc=utf-8 :