DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:refworks

refworks plugin

FIXME This Plugin breaks image rendering as the syntax is the same to images: {{..}}

Compatible with DokuWiki

No compatibility info given!

plugin Insert citations as links to a RefWorks RefShare

Last updated on
2007-10-17
Provides
Syntax

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to wikindx

Tagged with !broken, quotes, references

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).

<?php
/**
 * RefWorks Citation Module
 * Derived from: Plugin Skeleton, "cite" plugin
 * 
 * @license    GPL (http://www.gnu.org/licenses/gpl.html)
 * @author     Daniel Terry <dt232@cornell.edu>
 */
 
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('</TEST>','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 .= "<a href=\"$RWURL&rn=$refid\">$entry</a>; ";
        }
 
        $renderer->doc .= "[". substr($output,0,-2) ."]";
 
        return true;
    }
}
 
//Setup VIM: ex: et ts=4 enc=utf-8 :
plugin/refworks.txt · Last modified: 2011-06-18 17:10 by ach

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki