1<?php
2
3if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
4if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
5require_once(DOKU_PLUGIN.'syntax.php');
6
7/**
8 * All DokuWiki plugins to extend the parser/rendering mechanism
9 * need to inherit from this class
10 */
11class syntax_plugin_isns extends DokuWiki_Syntax_Plugin {
12
13    /**
14     * return some info
15     */
16    function getInfo(){
17        return array(
18            'author' => 'iDo',
19            'email'  => 'iDo@woow-fr.com',
20            'date'   => '18.01.2006',
21            'name'   => 'isns Plugin',
22            'desc'   => 'If the page doesnt exist, try to open the index. The syntax: {{isns}}',
23            'url'    => 'https://www.dokuwiki.org/plugin:isns',
24        );
25    }
26
27    /**
28     * What kind of syntax are we?
29     */
30    function getType(){
31        return 'substition';
32    }
33
34    /**
35     * Where to sort in?
36     */
37    function getSort(){
38        return 1;
39    }
40
41    /**
42     * Connect pattern to lexer
43     */
44    function connectTo($mode) {
45      $this->Lexer->addSpecialPattern("{{isns}}",$mode,'plugin_isns');
46    }
47
48    /**
49     * Handle the match
50     */
51    function handle($match, $state, $pos, &$handler){
52        return true;
53    }
54
55    /**
56     * Create output
57     */
58    function render($mode, &$renderer, $data) {
59        if($mode == 'xhtml'){
60            $n=$this->_IsNs();
61            if (@$n)
62                $renderer->doc = $n;
63            return true;
64        }
65        return false;
66    }
67
68    function _IsNs() {
69        global $conf;
70        global $ID;
71        $pn=wikiFN($ID);
72        if ((!file_exists($pn)) && (is_dir(substr($pn,0,-4)))) {
73            ob_start();
74            html_index($ID);
75            return ob_get_clean();;
76        }
77        return false;
78    }
79}
80
81//Setup VIM: ex: et ts=4 enc=utf-8 :