Table of Contents

new page dialog Plugin

Compatible with DokuWiki

2008-05-05

plugin Yet another “New Page Dialog”, with focus on the way people are used to store files. It aims to resemble a regular “Save As” dialog with “Add Folder” functionality.

Last updated on
2011-04-04
Provides
Action
Repository
Source

This extension is marked as obsoleted. Therefore it is hidden in the Extension Manager and the extension listing. Furthermore, it is candidate for removal.

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

The following security issue was reported for this extension: XSS vulnerability, not escaped properly.

It is not recommended to use this extension until this issue was fixed. Extension authors should read the plugin security guidelines

Extension name contains underscore, will not generate popularity points.

Similar to addnewpage, addnewpagedeluxe, npd

Tagged with !obsolete, button, create, form

:!: Deprecated :!: - For usage with current versions of DokuWiki, please use the new New Page Dialog Plugin, an adopted and forked version of this plugin.

Installation

Install via SVN

go into the /lib/plugins directory and type:

svn co http://svn.bitflux.org/repos/public/misc/dokuwiki/plugins/npd

Download Zip/Tar

Add Button to Template

Decide where you want to insert the “Create New Page” button in your template and insert the following code:

if (!plugin_isdisabled('npd') && ($npd = plugin_load('helper', 'npd'))) { 
    $npd->html_new_page_button();
}

Most likely you want to do that in the /lib/tpl/default/main.php inside the <div id="bar__bottomright"/> as follows:

<div class="bar-right" id="bar__bottomright">
  <?php if (!plugin_isdisabled('npd') && ($npd = plugin_load('helper', 'npd'))) $npd->html_new_page_button(); ?>
  <?php tpl_button('subscription')?>
  <?php tpl_button('admin')?>
  <?php tpl_button('profile')?>
  <?php tpl_button('login')?>
  <?php tpl_button('index')?>
  <?php tpl_button('top')?>&nbsp;
</div>

Note that the button will only be shown, if the browser is JavaScript enabled.

Changelog

Demo

A demo of this plugin can be seen at the fckw plugin demo wiki. FIXME

Screenshots

Localization

Please feel free too add your localizations here, I'll add them into the plugin ASAP.

Known Issues

Please report bugs here:

<?php # tpl_button('edit')?>

      <?php  
      		if( $INFO['exists'] === true ) tpl_button('edit') ;
      		
      		if (!plugin_isdisabled('npd') && ($npd = plugin_load('helper', 'npd'))) { 
  				$npd->html_new_page_button();
			}
	?>
      <?php tpl_button('history')?>
    </div>
     .  .  .  .  .  .

</code> — Vasiliy Pedak 2011/01/23 22:13

Discussion

function setNameSpace(node){
	var nameSpace = '';
	
	nameSpace = node.parentNode.parentNode.innerHTML;
	if (nameSpace.substring(0,8) == '<A href='){
		nameSpace = nameSpace.substring(nameSpace.indexOf('href=')+6);
		nameSpace = nameSpace.substring(0,nameSpace.indexOf('\"'));
		nameSpace = nameSpace.replace(/&amp;/g,'&');
		window.location.href = nameSpace;
	}

	return nameSpace;
}

just add ist to the main.php of this template and add the following line at the and of the function getEventElement(e)

	setNameSpace(node);

Glufu 2008/09/23 12:09

Replace in the file plugins/npd/tpl/main.php

-        <input type="text" class="" style="display: none;" id="npd_ns" value="<?php echo trim($_REQUEST['idx'], ":"); ?>"/>
+        <input type="text" class="" style="display: none;" id="npd_ns" value="<?php echo urlencode(trim($_REQUEST['idx'],':')); ?>"/>

and in the function npd_save :

-    opener.location.href = "doku.php?do=editfckw&id=" + $('npd_ns').value + ":" + page_name;
+    opener.location.href = "doku.php?do=editfckw&id=" + $('npd_ns').value + "%3A" + page_name;

SoX 2009/05/29 17:51

Some of the presented code lines come from tips found on the web, thanks to their respective authors

diff -r npd_original/helper.php npd_patch/helper.php
4a5
>  * @author     Patched by Benoît Locher <benoit.locher(at)skf(dot)com> and Matthieu Rioteau <matthieu.rioteau(at)skf(dot)com>
80c81
<             $ret .= '<a rel="nofollow" url="'.$url.'" style="display:none;" id="npd_create_button" class="action npd" href="#">'.$label.'</a>';
---
>             $ret .= '<a rel="nofollow" href="'.$url.'" style="display:none;" id="npd_create_button" class="action npd">'.$label.'</a>';
83c84
<             $ret .= '<form class="button"><div class="no">';
---
>             $ret .= '<form class="button" action="'.$url.'"><div class="no">';
89,90d89
<             // the url attribute will be used by the JavaScript
<             $ret .= 'url="'.$url.'" ';
diff -r npd_original/js/button.js npd_patch/js/button.js
6,7c6,12
<
<     npd_clicked_url = button.getAttribute('url');
---
>
>     if (button.nodeName.toLowerCase() == 'a') {
>         npd_clicked_url = button.getAttribute('href');
>     } else {
>         npd_clicked_url = button.parentNode.parentNode.getAttribute('action');
>     }
>
diff -r npd_original/tpl/main.php npd_patch/tpl/main.php
12a13
>  * @author Patched by Benoît Locher <benoit.locher(at)skf(dot)com> and Matthieu Rioteau <matthieu.rioteau(at)skf(dot)com>
104c105
<     opener.location.href = "doku.php?do=edit&id=" + $('npd_ns').value + ":" + page_name;
---
>     opener.location.href = "doku.php?do=edit&id=" + $('npd_ns').value + "%3A" + page_name;
217a219,226
>     switch (li.nodeName.toLowerCase()) {
>       case "strong":
>             li = li.parentNode.parentNode.parentNode;
>             break;
>         case "a":
>             li = li.parentNode.parentNode;
>             break;
>     }
238c247,248
<             if (a == $('npd_ns').value) {
---
>             var a = a.replace(/%3A/gi, ":");
>             if (a == $('npd_ns').value.replace(/%3A/gi, ":")) {
374c384
<         <input type="text" class="" style="display: none;" id="npd_ns" value="<?php echo trim($_REQUEST['idx'], ":"); ?>"/>
---
>         <input type="text" class="" style="display: none;" id="npd_ns" value="<?php echo urlencode(trim($_REQUEST['idx'],':')); ?>"/>

BL & MR 2009/06/16 14:23

 $ret .= '<a rel="nofollow" href="'.$url.'" style="display:none;" id="npd_create_button" class="action npd">'.$label.'</a>';
 ...
  $ret .= '<input id="npd_create_button" type="submit" value="'.htmlspecialchars($label).'" class="button" ';

lines in helper.php to

 $ret .= '<a name="npd_button" rel="nofollow"href="'.$url.'" style="display:none;" id="npd_create_button" class="action npd">'.$label.'</a>';
 ...
 $ret .= '<input name="npd_button" id="npd_create_button" type="submit" value="'.htmlspecialchars($label).'" class="button" ';

and the init_npd() function in /js/button.js to

 function init_npd()
{
    var links = document.getElementsByName('npd_button');
    var links_length = links.length;

    for(i=0; i<links_length; i++) 
    {
           if (links[i].nodeName.toLowerCase() == 'a') 
           {
               npd_clicked_url = links[i].getAttribute('href');
	    } else {
		npd_clicked_url = links[i].parentNode.parentNode.getAttribute('action');
	    }
	    
	    addEvent(links[i], "click", npd_clicked);

	    // show the button
	    links[i].style.display = '';
    }

}