[dokuwiki] Re: Newbie needs help understanding Plugin creation
- From: Tony Steward <tony_steward@xxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Thu, 31 May 2007 01:51:38 -0800
Well I give up I can't make this plugin work.
Maybe i'm stupid but can someone please show me how to do this!!!!!!!!!
I want to type <KEYCONV|something> on a page then have it substitued with
"HelloWorld!something".
This should be simple but I just dont get it.
Thanks
Tony
<?php
/**
* Plugin Skeleton: Displays "Hello World!"
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Christopher Smith <chris@xxxxxxxxxxxxx>
*/
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_keyconv extends DokuWiki_Syntax_Plugin {
/**
* return some info
*/
function getInfo(){
return array(
'author' => 'Tony Steward',
'email' => 'tony_steward@xxxxxxxxx',
'date' => '2007-05-29',
'name' => 'Key Converter',
'desc' => 'Show keys from differant manufacturers',
'url' => 'http://www.locks.stewardclan.net/lockswiki/',
);
}
/**
* What kind of syntax are we?
*/
function getType(){
return 'substition';
}
/**
* What kind of syntax do we allow (optional)
*/
// function getAllowedTypes() {
// return array();
// }
/**
* What about paragraphs? (optional)
*/
// function getPType(){
// return 'normal';
// }
/**
* Where to sort in?
*/
function getSort(){
return 999;
}
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addPattern('<KEYCONV|.+?>',$mode,'plugin_keyconv');
// $this->Lexer->addEntryPattern('<keyconv>',$mode,'plugin_keyconv');
}
// function postConnect() {
// $this->Lexer->addExitPattern('</keyconv>','plugin_keyconv');
// }
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
switch ($state) {
case DOKU_LEXER_ENTER :
break;
case DOKU_LEXER_MATCHED :
$match = substr($match, 9, -1); // strip <~KEYCONV|
from start and ~> from end
return array($match);
case DOKU_LEXER_UNMATCHED :
break;
case DOKU_LEXER_EXIT :
break;
case DOKU_LEXER_SPECIAL :
break;
}
return array();
}
/**
* Create output
*/
function render($mode, &$renderer, $data) {
if($mode == 'xhtml'){
$renderer->doc .= "Hello World! "; // ptype = 'normal'
$renderer->doc .= $data[0];
// $renderer->doc .= "<p>Hello World!</p>"; // ptype = 'block'
return true;
}
return false;
}
}
____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your
desktop!
Check it out at http://www.inbox.com/marineaquarium
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist
- Follow-Ups:
- [dokuwiki] Re: Newbie needs help understanding Plugin creation
- From: Chris Smith
- References:
- [dokuwiki] Re: Newbie needs help understanding Plugin creation
- From: Chris Smith
Other related posts:
- » [dokuwiki] Newbie needs help understanding Plugin creation
- » [dokuwiki] Re: Newbie needs help understanding Plugin creation
- » [dokuwiki] Re: Newbie needs help understanding Plugin creation
- » [dokuwiki] Re: Newbie needs help understanding Plugin creation
- » [dokuwiki] Re: Newbie needs help understanding Plugin creation
- » [dokuwiki] Re: Newbie needs help understanding Plugin creation
- [dokuwiki] Re: Newbie needs help understanding Plugin creation
- From: Chris Smith
- [dokuwiki] Re: Newbie needs help understanding Plugin creation
- From: Chris Smith