DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:forcepreview

forcepreview Plugin

Compatible with DokuWiki

2012-01-25, 2010-11-07, 2008-05-05, 2006-11-06, 2007-05-24, 2007-06-26b

plugin Force users to hit the preview button before saving changes to a wiki page by deactivating the save button first.

Last updated on
2012-02-09
Provides
Action
Conflicts with
enforcesummary, livepreview

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to enforcesummary

Tagged with editing, preview, users

Update Feb. 2012

Removed underscore from name to support future releases of DokuWiki.

Download / Installation

Download the plugin here (manually or via Plugin Manager): http://pb.wh4f.de/dokuwiki/forcepreview.zip

Usage

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.

non-Javascript solution

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

Code

action.php

action.php
<?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(Doku_Event_Handler $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>";
	}
  }
 
 
}

Translations

  • How to have/manage some translation files?

Troubleshooting

I like this , but Fckglite seem is not able to save sence it doesnt have the PREVIEW button.

plugin/forcepreview.txt · Last modified: 2016-01-26 17:24 by Aleksandr