Force users to hit the preview button before saving changes to a wiki page by deactivating the save button first.
Removed underscore from name to support future releases of DokuWiki.
Download the plugin here (manually or via Plugin Manager): http://pb.wh4f.de/dokuwiki/forcepreview.zip
As soon as the plugin is installed (and as long as it is not deactivated), the save button will be deactivated in edit mode. By clicking “Preview”, the user can activate the save button. this assures, that no unpreviewed content is saved into the wiki.
Here is a solution without Javascript. The only problem with this solution is that you have to change the PHP code of the Dokuwiki files.
Edit the file inc/html.php, search for the following line (this is how it looks like in version 2009-02-14b).
$form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4')));
Add “if($pr)” in front of the line, it should look like this. (This shows the save button only when you have previewed the page - change the color if needed)
if($pr) $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4')));
If you want to only disable the button without removing add this line below (the save button will be rendered but not clickable and grayed out)
else $form->addElement(form_makeButton('button', '', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4', 'disabled' => 'true', 'style' => 'color: grey; cursor: default;')));
— Markus Frosch 2009/07/21 13:49
<?php /** * Force Preview Action Plugin: Force users to hit preview before saving changes to a wiki page * * @author Pascal Bihler <bihler@cs.uni-bonn.de> */ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_forcepreview extends DokuWiki_Action_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Pascal Bihler', 'email' => 'bihler@cs.uni-bonn.de', 'date' => '2012-02-09', 'name' => 'Force preview', 'desc' => 'Force users to hit preview before saving changes to a wiki page', 'url' => 'http://www.dokuwiki.org/plugin:forcepreview', ); } /* * Register its handlers with the DokuWiki's event controller */ function register(&$controller) { $controller->register_hook('TPL_ACT_RENDER', 'AFTER', $this, '_controlSaveButton'); } /** * Relocates the css-loading to own method */ function _controlSaveButton(&$event, $param) { global $ACT; global $lang; $disable_save_button = ''; if ($ACT == 'edit') { $disable_save_button = 'true'; } elseif ($ACT == 'preview') { $disable_save_button = 'false'; } if ($disable_save_button != '') { print "<script type=\"text/javascript\">\n"; print " var saveBtn = document.getElementById('edbtn__save');\n"; print " saveBtn.disabled = $disable_save_button;\n"; if ($disable_save_button == 'true') { print " saveBtn.style.color = 'gray';\n"; print " saveBtn.style.backgroundColor = '#EEEEEE';\n"; print " saveBtn.value = '" . $lang['btn_save'] . " (Click \'" . $lang['btn_preview'] . "\' first)';\n"; } print "</script>"; } } }
I like this , but Fckglite seem is not able to save sence it doesnt have the PREVIEW button.