DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:toplist

This is an old revision of the document!


Toplist Plugin

Compatible with DokuWiki

No compatibility info given!

plugin Insert Toplist.cz status image into your DokuWiki page

Last updated on
2006-04-09
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.

Tagged with status

Description

With this plugin you can insert a Toplist status image (counter) to your page. The format is

~~toplist:#####~~

This will insert code

<img SRC="http://toplist.cz/count.asp?id=#####&amp;logo=mc" border="0" alt="TOPlist" WIDTH="88" HEIGHT="60"/>

Installation

Plugin

Create a new folder lib/plugin/toplist/ and place the following file in it: syntax.php.

lib/plugin/toplist/syntax.php:

<?php
/**
 * Plugin Toplist: Show Toplist Status.
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Mario Lacko <mario [dot] lacko [at] gmail [dot] com>
 */
 
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_toplist extends DokuWiki_Syntax_Plugin {
 
    /**
     * return some info
     */
    function getInfo(){
        return array(
                'author' => 'Mario Lacko',
                'email'  => 'mario [dot] lacko [at] gmail [dot] com',
                'date'   => '2006-04-09',
                'name'   => 'Toplist Plugin',
                'desc'   => 'Show your statistic from toplist.cz . Syntax: ~~toplist:000000~~',
                'url'    => 'http://www.dokuwiki.org/wiki:plugins',
                );
    }
 
    /**
     * What kind of syntax are we?
     */
    function getType(){
        return 'substition';
    }
 
    function getSort(){ return 129; }
 
    function connectTo($mode) {
      $this->Lexer->addSpecialPattern("~~toplist:\w+~~",$mode,'plugin_toplist');
    }
 
 
    /**
     * Handle the match
     */
    function handle($match, $state, $pos, &$handler){
        $match = substr($match,10,-2); // Strip markup
        // Check alignment
        $ralign = (bool)preg_match('/^ /',$match);
        $lalign = (bool)preg_match('/ $/',$match);
        if ($lalign & $ralign) $align = 'center';
        else if ($ralign)      $align = 'right';
        else if ($lalign)      $align = 'left';
        else                   $align = NULL;
 
        return array(trim($match),$align);
    }
 
    /**
     * Create output
     */
    function render($mode, &$renderer, $data) {
        if($mode == 'xhtml'){
            $renderer->doc .= '<img SRC="http://toplist.cz/count.asp?id='.$data[0].'&amp;logo=mc" border="0" alt="TOPlist" WIDTH="88" HEIGHT="60"/>';
 
            return true;
        }
        return false;
    }
}
 
//Setup VIM: ex: et ts=4 enc=utf-8 :

Discussion

It's insert counter image from www.toplist.cz , like this ⇒ http://www.toplist.cz/images/counter.asp?a=mc&ID=1

Hello, There's so many plug-ins, so please, think to include a Demo Link, just to have an idea…
plugin/toplist.1254849887.txt.gz · Last modified: 2009-10-06 19:24 by laynee

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