1<?php 2/** 3 * DokuWiki Plugin nosecedit (Syntax Component) 4 * 5 * 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author lisps 8 */ 9 10if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 12require_once(DOKU_PLUGIN.'syntax.php'); 13 14/* 15 * All DokuWiki plugins to extend the parser/rendering mechanism 16 * need to inherit from this class 17 */ 18class syntax_plugin_nosecedit extends DokuWiki_Syntax_Plugin 19 { 20 21 /* 22 * enable sectionedit by default 23 */ 24 function syntax_plugin_nosecedit() 25 { 26 global $ID; 27 28 if ($ID != "") 29 { 30 p_set_metadata($ID,array("sectionedit"=>"on"),FALSE,TRUE); 31 } 32 } 33 34 /* 35 * What kind of syntax are we? 36 */ 37 function getType() 38 { 39 return 'substition'; 40 } 41 42 /* 43 * Where to sort in? 44 */ 45 function getSort() 46 { 47 return 155; 48 } 49 50 /* 51 * Paragraph Type 52 */ 53 function getPType() 54 { 55 return 'normal'; 56 } 57 58 /* 59 * Connect pattern to lexer 60 */ 61 function connectTo($mode) 62 { 63 $this->Lexer->addSpecialPattern("~~NOSECTIONEDIT~~",$mode,'plugin_nosecedit'); 64 } 65 66 67 /* 68 * Handle the matches 69 */ 70 function handle($match, $state, $pos, &$handler) 71 { 72 global $ID; 73 return (array($ID=>TRUE)); 74 } 75 76 /* 77 * Create output 78 */ 79 function render($mode, &$renderer, $opt) 80 { 81 global $ID; 82 83 //save flags to metadata 84 //if($mode == 'metadata') 85 { 86 if (isset($opt[$ID])==TRUE) 87 { 88 p_set_metadata($ID,array("sectionedit"=>"off"),FALSE,TRUE); 89 } 90 else 91 { 92 p_set_metadata($ID,array("sectionedit"=>"on"),FALSE,TRUE); 93 } 94 } 95 return (TRUE); 96 } 97 } 98//Setup VIM: ex: et ts=4 enc=utf-8 : 99