1<?php 2/** 3 * @author Myron Turner <turnermm02@shaw.ca> 4 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 5*/ 6// must be run within Dokuwiki 7if(!defined('DOKU_INC')) die(); 8 if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 9class action_plugin_nodisp extends DokuWiki_Action_Plugin { 10 public function register(Doku_Event_Handler $controller) { 11 $controller->register_hook('TPL_CONTENT_DISPLAY', 'BEFORE', $this, 'handle_wiki_content'); 12 } 13 14 function __construct() { 15 16 if(file_exists(DOKU_PLUGIN . 'nodisp/syntax.php')) { 17 msg("Please remove syntax.php from lib/plugins/nodisp or remove the plugin and reinstall"); 18 } 19 20 } 21 22 function handle_wiki_content(Doku_Event $event, $param) { 23 global $ACT; 24 $act = act_clean($ACT); 25 if($act == 'source') { 26 $event->data = preg_replace_callback( 27 '|<nodisp (\d+)>.*?<\/nodisp>|ms', 28 function($matches) { 29 global $ID; 30 $acl = auth_quickaclcheck($ID); 31 if($acl < $matches[1]) { 32 return ""; 33 } 34 return $matches[0]; 35 },$event->data 36 ) ; 37 38 $event->data = preg_replace_callback( 39 '|\{nodisp (\d+)\}.*?\{\/nodisp\}|ms', 40 function($matches) { 41 global $ID; 42 $acl = auth_quickaclcheck($ID); 43 if($acl < $matches[1]) { 44 return ""; 45 } 46 return $matches[0]; 47 },$event->data 48 ) ; 49 return; 50 } 51 52 $event->data = preg_replace_callback( 53 '|<div class = "nodisp_(\d+)"><!-- nodisp -->(.*?)<!-- nodisp -->.*?<\/div>|ms', 54 function($matches) { 55 global $ID; 56 $acl = auth_quickaclcheck($ID); 57 if($acl < $matches[1]) { 58 return ""; 59 } 60 return $matches[0]; 61 },$event->data 62 ) ; 63 } 64 65 } 66