1<?php 2/** 3 * Force Preview Action Plugin: Force users to hit preview before saving changes to a wiki page 4 * 5 * @author Pascal Bihler <bihler@cs.uni-bonn.de> 6 */ 7 8if(!defined('DOKU_INC')) die(); 9if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 10require_once(DOKU_PLUGIN.'action.php'); 11 12class action_plugin_forcepreview extends DokuWiki_Action_Plugin { 13 14 /** 15 * return some info 16 */ 17 function getInfo(){ 18 return array( 19 'author' => 'Pascal Bihler', 20 'email' => 'bihler@cs.uni-bonn.de', 21 'date' => '2012-02-09', 22 'name' => 'Force preview', 23 'desc' => 'Force users to hit preview before saving changes to a wiki page', 24 'url' => 'http://wiki.splitbrain.org/plugin:forcepreview', 25 ); 26 } 27 28 /* 29 * Register its handlers with the dokuwiki's event controller 30 */ 31 function register(&$controller) { 32 $controller->register_hook('TPL_ACT_RENDER', 'AFTER', $this, '_controlSaveButton'); 33 } 34 35 /** 36 * Relocates the css-loading to own method 37 */ 38 function _controlSaveButton(&$event, $param) { 39 global $ACT; 40 global $lang; 41 42 $disable_save_button = ''; 43 if ($ACT == 'edit') { 44 $disable_save_button = 'true'; 45 } elseif ($ACT == 'preview') { 46 $disable_save_button = 'false'; 47 } 48 if ($disable_save_button != '') { 49 print "<script type=\"text/javascript\">\n"; 50 print " var saveBtn = document.getElementById('edbtn__save');\n"; 51 print " saveBtn.disabled = $disable_save_button;\n"; 52 if ($disable_save_button == 'true') { 53 print " saveBtn.style.color = 'gray';\n"; 54 print " saveBtn.style.backgroundColor = '#EEEEEE';\n"; 55 print " saveBtn.value = '" . $lang['btn_save'] . " (Click \'" . $lang['btn_preview'] . "\' first)';\n"; 56 } 57 print "</script>"; 58 } 59 } 60 61 62}