DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:new_page_dialog

This is an old revision of the document!


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
2008-07-11
Provides
Action

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

Extension name contains underscore, will not generate popularity points.

Similar to addnewpage, addnewpagedeluxe, newpagebutton, npd

Tagged with button, create, form

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

The zip can be found here FIXME ULR does not work any more

Alternate Download: http://src.chimeric.de/plugin-npd.tgz

Add Button to Template

Decide where you want to insert the “Create New Page” button in your template and insert the 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

  • 2008-07-11 Version 0.4:
    • fixed compatibility with DokuWiki 2008-05-05
  • 2008-05-27 Version 0.3:
    • added many localisations
    • added configuration in order to choose either bottom or link
  • 2007-02-18 Version 0.2:
    • added German language (thanks to Tblue)
    • bugfix for “empty namespaces”
  • 2007-02-17 Version 0.1:
    • initial upload

Known Issues

Please report bugs here:

  • Since I updated DokuWiki to the latest release 2009-12-25 “Lemming” this plugin (version 0.5 2008-01-10) doesn't work anymore. The plugin-link /doku.php?id=start&idx=:&npd=1& open a new window, but show the startpage of DokuWiki. Any suggestions?
    • The same has happened in my case.
    • I've to the same problem in my DokuWiki and was unable to find a solution yet.
    • me too here
  • It seems this plugin is not compatible with the indexmenu plugin as it attaches events to the standard index menu tree of DokuWiki and not the indexmenu tree. If there could be any chance to disable the indexmenu plugin in the 'new page' window shown by npd then the problem would be solved, using the standard index tree for the 'new page' window and the indexmenu tree for the rest of the wiki.
  • Hi, I am having the same problem as that described below with DokuWiki 2008-05-05 and npd version 0.4 - pages are not created in the sub-namespace selected but directly under wiki. Any suggestions ?
  • Hi with version DokuWiki-2008-05-05.tgz the plugin doesn't work. When I want to add a new page for example to wiki:test12:test1 called test5 then the page is created in wiki: any ideas? could not reproduce in version 0.4
  • Same problem as above with DokuWiki-2008-05-05, npd 0.4 and dokubook template
  • Cannot I create a new page within an existing folder?? can not reproduce - more info?
  • JS error when creating folder in “empty namespaces” fixed in version 0.2
  • I installed the plugin from the Plugin Manager, using your link to zip file (http://wiki.caillou.ch/_media/playground:npd_v0.2.zip?id=playground%3Aplayground). Installation reported that plugin installed fine, and it is enabled. However, * When clicking on “info” in the plugin manager I get “This plugin returned no information, it may be invalid.”.
    • I cannot create the button for it as described above (I place it in div <html>class=“bar-right” id=“barbottomright”</html>, just as it is done in the example above); but nothing happens at all. I can place some regular text there, e.g. “a button”, and I then see it in the bar; however, the code to create the new page dialog button does nothing. * My DokuWiki version is 2007-06-26b if this helps.</del> (Possible) SOLUTION (22-02-2008): probably your plugin is not well installed. I got at first the same
      result. Just unpack the zip file manually to /lib/plugins/ and then it has to work fine.Remember to
      change the main.php in the directory of your current theme which can differ from the default theme.
      For example: /lib/tpl/mytheme/main.php.
      (When your current theme is another theme than the default theme, this plugin will probably look
      different than the one in the example here, because of another stylesheet.)
      ==== Added: How to get rid of the default createpage button?==== After you have installed this plugin, users still see the default createpage button of DokuWiki
      next to the createpagebutton of this plugin. They will also try to use the default createpage button
      which leads to pages without namespaces. If you want your users to maintain namespaces in your
      DokuWiki when they are creating a page, you must in that case get rid of the default createpage button.
      Here's how to do that:
      Locate the /inc/template.php file. Locate the following code in the function tpl_button($type) :
      <code php> case 'edit': #most complicated type - we need to decide on current action if($ACT == 'show' || $ACT == 'search'){ if($INFO['writable']){ if(!empty($INFO['draft'])){ echo html_btn('draft',$ID,'e',array('do' ⇒ 'draft'),'post'); }else{ if($INFO['exists']){ echo html_btn('edit',$ID,'e',array('do' ⇒ 'edit','rev' ⇒ $REV),'post'); }else{ echo html_btn('create',$ID,'e',array('do' ⇒ 'edit','rev' ⇒ $REV),'post'); } } }else{ if(!actionOK('source')) return false; pseudo action echo html_btn('source',$ID,'v',array('do' ⇒ 'edit','rev' ⇒ $REV),'post'); } }else{ echo html_btn('show',$ID,'v',array('do' ⇒ 'show')); } break; </code>
      And then change it to this (ie. comment the create button):

      <code php> case 'edit': #most complicated type - we need to decide on current action if($ACT == 'show' || $ACT == 'search'){ if($INFO['writable']){ if(!empty($INFO['draft'])){ echo html_btn('draft',$ID,'e',array('do' ⇒ 'draft'),'post'); }else{ if($INFO['exists']){ echo html_btn('edit',$ID,'e',array('do' ⇒ 'edit','rev' ⇒ $REV),'post'); /* }else{ echo html_btn('create',$ID,'e',array('do' ⇒ 'edit','rev' ⇒ $REV),'post');*/ } } }else{ if(!actionOK('source')) return false;
      pseudo action echo html_btn('source',$ID,'v',array('do' ⇒ 'edit','rev' ⇒ $REV),'post'); } }else{ echo html_btn('show',$ID,'v',array('do' ⇒ 'show')); } break; </code>
      That's all folks!

      > What about simply not calling tpl_button('edit') in the main.php of the template in case of the “show” action? <code php> if($ACT != 'show') tpl_button('edit'); </code> — Michael Klier 2008/04/19 01:29 > I get rid from default button in so manner. <code php> . . . . . . <div class=“bar-left” id=“bar
      topleft”>

<?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>

Demo

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

screen shots

Localization

For now, localization only exists for English,German and Dutch. Please feel free too add your localizations here, I'll add them into the plugin ASAP.

There are two files for localization.

The lang.php file:

/**
 * English language file for the "New Page Dialog" plugin
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Pierre Spring <pierre.spring[curly thing]liip[full stop]ch>
 */
 
/* buttons */
$lang['btn_create_new_page'] = 'Create New Page';
$lang['btn_create_page'] = 'Create Page';
$lang['btn_new_folder']  = 'New Folder';
$lang['btn_ok'] = 'OK';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = 'Are you sure you want to \ncreate a page called:\n';
$lang['dlg_new_folder'] = 'Enter new folder name:';
 
/* misc */
$lang['msc_page_title'] = 'Page Title';

The dialog_folder_name.txt:

Please enter the folder Name.\\
Note that a folder will **NOT** be created before a page\\
within the folder is **SAVED**.

Polish translation

Plik lang.php:

/**
 * Polish language file for the "New Page Dialog" plugin
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Łukasz Czerski
 */
 
/* buttons */
$lang['btn_create_new_page'] = 'Utwórz nową stronę';
$lang['btn_create_page'] = 'Utwórz stronę';
$lang['btn_new_folder']  = 'Nowy katalog';
$lang['btn_ok'] = 'OK';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = 'Czy na pewno utworzyć stronę:\n';
$lang['dlg_new_folder'] = 'Podaj nazwę katalogu:';
 
/* misc */
$lang['msc_page_title'] = 'Tytuł strony';

Plik dialog_folder_name.txt:

Podaj nazwę katalogu.\\
Katalog **NIE** zostanie utworzony dopóki strona\\
znajdująca się w nim nie zostanie **ZAPISANA**.

German translation

lang.php:

/**
 * German language file for the "New Page Dialog" plugin
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Tilman Blumenbach <tilman [AT] tblue [DOT] de>
 */
 
 
/* buttons */
$lang['btn_create_new_page'] = 'Neue Seite anlegen';
$lang['btn_create_page'] = 'Seite anlegen';
$lang['btn_new_folder']  = 'Neuer Ordner';
$lang['btn_ok'] = 'OK';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = 'Sind Sie sicher, dass Sie\neine Seite mit dem folgenden\nTitel anlegen wollen?\n';
$lang['dlg_new_folder'] = 'Namen für neuen Ordner eingeben:';
 
/* misc */
$lang['msc_page_title'] = 'Seitentitel';

dialog_folder_name.txt:

Bitte geben Sie den Ordnernamen ein.\\
Beachten Sie, dass ein Ordner **NICHT** angelegt wird,\\
bevor eine Seite in dem Ordner **GESPEICHERT** ist.

Dutch translation

lang.php:

/**
 * dutch language file for the "New Page Dialog" plugin
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Harro Schuringa 
 */
 
/* buttons */
$lang['btn_create_new_page'] = 'Maak nieuwe pagina aan';
$lang['btn_create_page'] = 'Maak pagina aan';
$lang['btn_new_folder']  = 'Nieuwe map aanmaken';
$lang['btn_ok'] = 'OK';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = 'Weet u zeker dat u een pagina\naan wilt maken met de naam:\n';
$lang['dlg_new_folder'] = 'Geef de naam van de nieuwe map op:';
 
/* misc */
$lang['msc_page_title'] = 'Pagina Titel';

dialog_folder_name.txt:

Geef de naam van de map.\\
NB!: Denk eraan dat een map **NIET** aangemaakt wordt voordat de pagina\\
binnenin die map is **OPGESLAGEN**.\\

Korean translation

lang.php:

<?php
/**
 * Korean language file for the "New Page Dialog" plugin
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Heesu Yoon <cppigX[atSign]gmail[fullStop]com> (where X=3*5*7*19)
 */
 
/* buttons */
$lang['btn_create_new_page'] = '새 페이지 만들기';
$lang['btn_create_page'] = '페이지 만들기';
$lang['btn_new_folder']  = '새 폴더';
$lang['btn_ok'] = '확인';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = '다음 페이지를\n만드시겠습니까?\n';
$lang['dlg_new_folder'] = '새 폴더 이름:';
 
/* misc */
$lang['msc_page_title'] = '페이지 제목';
?>

dialog_folder_name.txt:

폴더 이름을 입력하십시요.\\
참고 - 새 폴더는 폴더 내의 파일이 **저장**될 때까지\\
생성되지 **않습니다.**

Norwegian translation

lang.php

/**
 * norsk språkfil for plugin "New Page Dialog"
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Torkill Bruland
 */
 
/* buttons */
$lang['btn_create_new_page'] = 'Opprett Ny Side';
$lang['btn_create_page'] = 'Lag side';
$lang['btn_new_folder']  = 'Ny mappe';
$lang['btn_ok'] = 'OK';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = 'Er du sikker på at du ønsker å \n opprette en side med navnet:\n';
$lang['dlg_new_folder'] = 'Før inn nytt mappenavn:';
 
/* misc */
$lang['msc_page_title'] = 'Sidetittel';

Fila dialog_folder_name.txt:

Før inn navnet på mappa.\\
Merk at mappe **IKKE** opprettes før det\\
**LAGRES** en side i vedkommende mappe.

Italian translation

lang.php

/**
 * italian language file for the "New Page Dialog" plugin
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Andrea Papotti <genome[snail shell]cheerful[youknowwhat]com>
 */
 
/* buttons */
$lang['btn_create_new_page'] = 'Crea Nuova Pagina';
$lang['btn_create_page'] = 'Crea Pagina';
$lang['btn_new_folder']  = 'Nuova Cartella';
$lang['btn_ok'] = 'OK';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = 'Sei sicuro di voler \ncreare una pagina chiamata:\n';
$lang['dlg_new_folder'] = 'Inserisci nome nuova cartella:';
 
/* misc */
$lang['msc_page_title'] = 'Titolo Pagina';

Fila dialog_folder_name.txt:

Prego inserire il mome della cartella.\\
Nota: La cartella viene creata solamente quando contiene\\
ALMENO UNA pagina.

Spanish translation

lang.php

<?php
/**
 * Spanish language file for the "New Page Dialog" plugin
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Digna González <digna.gonzalezotero[at]gmail[dot]com
 */
 
/* buttons */
$lang['btn_create_new_page'] = 'Crear nueva página';
$lang['btn_create_page'] = 'Crear Página';
$lang['btn_new_folder']  = 'Nueva Carpeta';
$lang['btn_ok'] = 'Aceptar';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = '¿Está seguro de que desea \n crear una página llamada:\n?';
$lang['dlg_new_folder'] = 'Introduzca el nombre de la carpeta:';
 
/* misc */
$lang['msc_page_title'] = 'Título de la página:';
 
//Setup VIM: ex: et ts=4 enc=utf-8 :

Archivo dialog_folder_name.txt

Por favor, introduzca el nombre de la carpeta.\\
Atención: **NO** se creará una carpeta hasta que se **GUARDE**\\
una página dentro de esa carpeta

Russian translation

lang.php

<?php
/**
 * Russian language file for the "New Page Dialog" plugin
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Ilya Paramonov
 */
 
/* buttons */
$lang['btn_create_new_page'] = 'Создать новую страницу';
$lang['btn_create_page'] = 'Создать страницу';
$lang['btn_new_folder']  = 'Создать пространство имён';
$lang['btn_ok'] = 'OK';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = 'Вы действительно хотите\nсоздать страницу с именем:\n';
$lang['dlg_new_folder'] = 'Введите имя нового пространства имён:';
 
/* misc */
$lang['msc_page_title'] = 'Имя страницы';
 
//Setup VIM: ex: et ts=4 enc=utf-8 :

dialog_folder_name.txt

Введите название пространства имён.\\
Заметьте, что пространство имён **НЕ** будет создано,\\
пока страница внутри него не будет **СОХРАНЕНА**.

Czech translation

lang.php

/**
 * Česká verze pluginu "New Page Dialog"
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     2046
 */
 
/* buttons */
$lang['btn_create_new_page'] = 'Vytvoř novou stránku';
$lang['btn_create_page'] = 'Vytvoř stránku';
$lang['btn_new_folder']  = 'Nový adresář';
$lang['btn_ok'] = 'OK';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = 'Jseš si jistý, \nže chceš vytvořit stránku s názvem:\n';
$lang['dlg_new_folder'] = 'Zvol název adresáře:';
 
/* misc */
$lang['msc_page_title'] = 'Název stránky';

lang.php

<?php
/**
 * český jazykový soubor pro plugin "New Page Dialog"
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Tomas Safarik <safarik[curly thing]server[full stop]cz>
 */
 
/* buttons */
$lang['btn_create_new_page'] = 'Vytvořit novou stránku';
$lang['btn_create_page'] = 'Vytvořit stránku';
$lang['btn_new_folder']  = 'Nová složka';
$lang['btn_ok'] = 'OK';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = 'Určitě chcete vytvořit \nstránku s názvem:\n';
$lang['dlg_new_folder'] = 'Zadejte název nové složky:';
 
/* misc */
$lang['msc_page_title'] = 'Název stránky';

dialog_folder_name.txt

Prosím zadejte Název složky.\\
Pamatujte, že složka **NEBUDE** vytvořena, dokud nebude\\
v ní vytvářená stránka **ULOŽENA**.

Japanese translation

lang.php:

/**
 * Japanese language file for the "New Page Dialog" plugin
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     smeghead <smeghead[at]users.sourceforge.jp>
 */
 
/* buttons */
$lang['btn_create_new_page'] = '新しいページの作成';
$lang['btn_create_page'] = 'ページの作成';
$lang['btn_new_folder']  = '新しいフォルダ';
$lang['btn_ok'] = 'OK';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = '新しいページを作成します。よろしいですか? \nページ名:\n';
$lang['dlg_new_folder'] = '新しいフォルダ名を入力してください。:';
 
/* misc */
$lang['msc_page_title'] = 'ページタイトル';

dialog_folder_name.txt:

フォルダ名を入力してください。\\
\\
注意:フォルダーの中のページが保存されるまで、\\
フォルダーは作成されません。\\

Slovenian translation

lang.php:

/**
 * Slovenian language file for the "New Page Dialog" plugin
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     paxman <paxmanpwnz [AT] gmail [DOT] com>
 */
 
 
/* buttons */
$lang['btn_create_new_page'] = 'Ustvari novo stran';
$lang['btn_create_page'] = 'Ustvari stran';
$lang['btn_new_folder']  = 'Nova mapa';
$lang['btn_ok'] = 'Potrdi';
 
/* dialogs */
$lang['dlg_confirm_page_name'] = 'Ste prepričani, da želite\n ustvariti stran:\n';
$lang['dlg_new_folder'] = 'Vnesite ime nove mape:';
 
/* misc */
$lang['msc_page_title'] = 'Naslov strani';

dialog_folder_name.txt:

Prosim, vnesite ime mape.\\
Opomba: mapa **NE** bo ustvarjena, dokler ni\\
stran iz le-te **SHRANJENA**.

Discussion

  • Ditto. It simply doesn't work deeper than 2 sub-namespaces (DokuWiki 2008-05-05 & 2009-02-14). The good news is, that the code snipped doesn't make it worse :-) ,André 2009/04/20
  • I am having the same problem as Thomas (on DokuWiki 2008-05-05). Any ideas on how to get this working? John, 2009/03/03
  • For some reason, I cannot descend deeper than 2 sub-namespaces. When I click on the third namspace (no matter if I click on the “+” or the name itself), the focus where the new page is created, is back on the root namespace (similar to felix's and glufu's problem). The code snippet glufu provided doesn't work either. I use the latest version (via SVN). Is there a solution? - Thomas, 2009/01/15
  • Zip file download link 404s, at least as of 2008/06/07. Don't know about SVN, since SVN isn't working right on my server. But could someone please fix the zip link? Thx much. — Matt Landry 2008/06/07
  • Hi, it would be great if this plugin would also support an actionlink style link. I would happily integrate support for this plugin into the Arctic Template ;-) which supports both types of actionlinks. — Michael Klier 2008/04/19 01:27
  • Same here, I'm using Arctic Template and the button is simply ugly =)Benoit P. 2008/05/13 14:26
  • Hi chimeric and benoit: i added the config in version 0.3 … install the plugin, go to
    admin → configuration settings → npd plugin settings
    and choose link — pierre spring 2008/06/27 23:25
  • Hey, I'm using artic template, too. It really looks fine with 'link' :-) But there is another Problem. I can't create new pages in subdirectories. The new page will be created at the Namespace “Start - NewPage”, where Start is my Index page. — Felix Weber 2008/08/13 16:42
  • Fine work but i have the same problem like Felix. The value of npd_ns is empty in function npd_save (main.php). BTW: it would be nice if you could implement a exclude function to hide some namespaces in a future version? — Glufu 2008/08/14 10:19
  • You must not click on the name of the namespace but on the little '+' on the left of the namespace. 2008/27/14 10:44
  • my whishlist (14-set-2008)
    • if you click on + of a namespace, the page is created in that namespace. Please do the same if the user click on the namespace name. Because the page is created on the root folder if the user click on a namespace name
    • when the user is editing a page, do not show the “Create new page” button, it does confuse some users
    • it does not work in Google Chrome browser
    • a __MACOSX plugin is installed, but there is no info about it. For what is that plugin?
  • I'm not sure if this solution is okay, but I fixed the problem of felix and me with this snipped of code:
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

  • It would if the dialog would open and expand/focus on the current namespace/path when “Create new page” is pressed.
  • To resolve the problem with the creation after 2 sub-namespaces (DokuWiki 2008-05-05 & 2009-02-14) :

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

  • Here below you can find a patch (shown as result of a “diff” command) that solves most issues we could find in this plugin
    • All namespace structure levels are reachable
    • All “clics” have a correct behavior
    • Tested with Firefox and IE

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

  • If you need multiple buttons on page, change the
 $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 = '';
    }

}
plugin/new_page_dialog.1295813597.txt.gz · Last modified: 2011-01-23 21:13 by 93.127.113.117

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki