[dokuwiki] Plugin now runnig

  • From: Jan-Philipp Warmers <Progamler@xxxxxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 05 Jul 2007 11:34:35 +0200

My plugin runs now
  * try to test it
  * write wikipage
  * Post Doc

//syntax
<drop link/test>link name </drop>
<drop menu/test>
  * some list
    * some more list
</drop>

//creat folder drop_me



//greets Jan-Philipp Warmers

<code>
<?php



/**
 * Plugin Drop Me (Great dropdown menüs(by click))
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Jan-Philipp Warmers <Progamler@xxxxxxxxxxxxxxxxx>
 */

// must be run within Dokuwiki
if (!defined('DOKU_INC'))
        die();

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_drop_me extends DokuWiki_Syntax_Plugin {

        /**
         * return some info
         */
        function getInfo() {
                return array (
                        'author' => 'Jan-Philipp Warmers',
                        'email' => 'Progamler@xxxxxxxxxxxxxxxxx',
                        'date' => '2007-07-04',
                        'name' => 'Drop ME',
                        'desc' => 'Creat menüs with display and js',
                        'url' => '',


                );
        }

        function getType() {
                return 'container';
        }
        function getAllowedTypes() {
                return array (
                        'formatting',
                        'substition',
                        'disabled',
                        'container'
                );
        }
        function getSort() {
                return 158;
        }
        function connectTo($mode) {
$this->Lexer->addEntryPattern('<drop.*?>(?=.*?</drop>)', $mode, 'plugin_drop_me');
        }
        function postConnect() {
                $this->Lexer->addExitPattern('</drop>', 'plugin_drop_me');
        }

        /**
         * Handle the match
         */
        function handle($match, $state, $pos, & $handler) {
                global $ende;
                switch ($state) {
                        case DOKU_LEXER_ENTER :
list ($color, $background) = preg_split("/\//u", substr($match, 5, -1), 2);
                                if ($color = $this->_link($color, $background)) 
{
                                        $color = $color;
                                        $ende = $this->_ende($color);
                                }
                                return array (
                                        $state,
                                        array (
                                                $color,
                                                $background
                                        )
                                );

                        case DOKU_LEXER_UNMATCHED :
                                return array (
                                        $state,
                                        $match
                                );
                        case DOKU_LEXER_EXIT :
                                return array (
                                        $state,
                                        $ende
                                );
                }
                return array ();
        }

        /**
         * Create output
         */
        function render($mode, & $renderer, $data) {

                if ($mode == 'xhtml') {
                        list ($state, $match) = $data;
                        switch ($state) {
                                case DOKU_LEXER_ENTER :
                                        list ($color, $background) = $match;
                                        $renderer->doc .= $color;

                                        break;

                                case DOKU_LEXER_UNMATCHED :
                                        $renderer->doc .= 
$renderer->_xmlEntities($match);
                                        break;
                                case DOKU_LEXER_EXIT :
                                        list ($ende) = $match;
                                        echo var_dump($ende);
                                        if ($ende == "a")
                                                $renderer->doc .= "</a>";
                                        if ($ende == "d")
                                                $renderer->doc .= "</div>";

                                        break;
                        }
                        return true;
                }
                return false;
        }
//creat <drop>
        function _link($c, $o) {
                $c = trim($c);
                if ($c == "link") {
                        return "<a href=javascript:showhide('$o')  
onclik=showhide('$o')>";
                }
                elseif ($c == "menu") {
                        return "<div id=\"$o\" >";
                }
        }
        //creat </drop>
        function _ende($ende) {
                $c = trim($ende);
                $c = substr($c, "1", "1");

                if ($c == "a") {

                        return "a";
                }
                elseif ($c == "d") {

                        return "d";
                }
        }
}
?>

--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts:

  • » [dokuwiki] Plugin now runnig