1<?php
2/**
3 * Plugin ICQ: Show if some ICQ user is online.
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Jakob Jensen <koeppe@kazur.dk>
7 */
8
9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11require_once(DOKU_PLUGIN.'syntax.php');
12
13/**
14 * All DokuWiki plugins to extend the parser/rendering mechanism
15 * need to inherit from this class
16 */
17class syntax_plugin_icq extends DokuWiki_Syntax_Plugin {
18
19    /**
20     * return some info
21     */
22    function getInfo(){
23        return array(
24                'author' => 'Jakob Jensen',
25                'email'  => 'koeppe@kazur.dk',
26                'date'   => '2006-03-28',
27                'name'   => 'ICQ plugin',
28                'desc'   => 'Show if some ICQ user is online. Syntax: [[icq>0000000]]',
29                'url'    => 'http://www.dokuwiki.org/plugin:icq',
30                );
31    }
32
33    /**
34     * What kind of syntax are we?
35     */
36    function getType(){
37        return 'substition';
38    }
39
40    function getSort(){ return 298; }
41
42    function connectTo($mode) {
43        $this->Lexer->addSpecialPattern('\[\[icq>\w+\]\]',$mode,'plugin_icq');
44    }
45
46
47    /**
48     * Handle the match
49     */
50    function handle($match, $state, $pos, Doku_Handler $handler){
51        $match = substr($match,6,-2);
52        return array(strtolower($match));
53    }
54
55    /**
56     * Create output
57     */
58    function render($mode, Doku_Renderer $renderer, $data) {
59        if($mode == 'xhtml'){
60            $renderer->doc .= '<a href="http://wwp.icq.com/' . $data[0] . '">';
61            $renderer->doc .= '<img border="0" alt="Online?" src="http://web.icq.com/whitepages/online?icq=' . $data[0] . '&amp;img=5" />';
62            $renderer->doc .= '</a>';
63            return true;
64        }
65        return false;
66    }
67}
68?>