====== Add New Page Plugin ====== ---- plugin ---- description: author : iDo email : ido@idotech.info type : syntax lastupdate : 2008-01-10 compatible : 2006-11-06 depends : conflicts : addnewpage_old similar : tags : add, button, form, create ---- This is the new RELEASE for the dokuwiki 2006-11-06 version. If you want the old version see [[plugin:addnewpage_old]] This plugin adds a selection box and an input box for adding a new page. \\ The selection box contains all namespaces of your wiki. \\ This plugin was inspired from [[plugin:newpagebutton]]. ====== Demo ====== You can [[http://www.wikistuce.info/doku.php?id=nouvelle_page| see the plugin in action here]]. ====== syntax ====== Just write {{NEWPAGE}} {{NEWPAGE}} or {{NEWPAGE>[namespace]}} {{NEWPAGE>[namespace]}} \\ \\ where "namespace" is your namespace. If you use a namespace in the line, you can : * hide the select box * or show only subnamespace To configure it, use the config manager. ====== Installation ====== With plugin manager, use this zip : http://dokuplugins.idotech.info/addnewpage.zip \\ ====== Configuration ====== You can configure the plugin in the Config Manager of dokuwiki. ====== Tips ====== If you want to show the add new page forms out of a page (for example in your template), put this line where you want to see the plugin : ====== Language ====== * French * English * Italian (uncomplete) * Russian (uncomplete) * German * Spanish * Traditional Chinese * Japanese * Swedish * Other ? add here or mail me : [[ido@woow-fr.com|ido@woow-fr.com]] ===== Language files ===== ==== French ==== === lang.php === === settings.php === [ns]}} : Cache la selection de namespace (décoché: affiche uniquement les sous-namespaces)"; $lang['addpage_hideACL']="Si non cochée, affiche un message lorsque l'utlisateur n'a pas les droits d'ajout de page. Sinon, cache simplement {{NEWPAGE}}"; ?> ==== English ==== I made a few linguistic fixes to make it more English :-) === lang.php === === settings.php === [ns]}} syntax: Hide namespace selection (unchecked: show only subnamespaces)"; $lang['addpage_hideACL']="Hide {{NEWPAGE}} if user does not have rights to add pages (show message if unchecked)" ?> ==== German ==== === lang.php === === settings.php === [ns]}} Syntax: Ausgewählt, diese Namespace-Selektion verbergen. Nicht ausgewählt, nur diese Namespace-Selektion anzeigen."; $lang['addpage_hideACL']="Wenn ein Benutzer keine Berechtigung hat: Ausgewählt, Anzeige wird verborgen. Nicht ausgewählt, Es wird eine Fehlermeldung ausgegeben." ?> ==== Spanish ==== === lang.php === === settings.php === [dir]}}: se oculta el selector de directorio (desmarcado: muestra solo sub-directorios (sub-namespaces))"; $lang['addpage_hideACL'] = "si esta desmarcado, muesta un mensaje de error de privilegios. Si el usuario no tiene permiso de crear una pagina, simplemente se oculta el codigo {{NEWPAGE}}" ?> ==== Portuguese ==== === lang.php === === settings.php === [ns]}} sintaxe : esconde a seleção do namespace (desmarcado : mostra sub-namespace ativo)"; $lang['addpage_hideACL'] ="se desmarcado, mostra mensagem sobre direitos senão simplismente esconde {{NEWPAGE}} quando o usuário não possui permissões para incluir uma página." ?> ==== Traditional Chinese ==== === lang.php === === settings.php === [ns]}} 語法時不要顯示出命名空間(namespace)的選項, 沒有打勾就會列出指定命名空間(namespace)底下所有的子命名空間(subnamespace)項目"; $lang['addpage_hideACL'] ="沒有打勾 : 表示當使用者沒有新增頁面權限時就顯示沒有權限的訊息而不會顯示出新增頁面的輸入欄." ?> ==== Italian ==== === lang.php === === settings.php === [ns]}} : Nascondi il namespace selezionato (deseleziona: mostra solo i sotto-namespaces)"; $lang['addpage_hideACL']="Nascondi {{NEWPAGE}} se l'utente non ha i diritti per visualizzare la pagina (mostra il messaggio se deselezionato)" ?> ==== Japanese ==== === lang.php === === settings.php === [ns]}} 構文使用時: 名前空間選択リストを表示しない(チェックなし: 下位名前空間のみを表示)"; $lang['addpage_hideACL']="ページ追加の権限を持たないユーザーに対しては {{NEWPAGE}} を表示しない(チェックなしの場合にはメッセージを表示)" ?> ==== Swedish ==== === lang.php === === settings.php === [ns]}} syntax: Dölj val av namnrymd (ej ikryssad: visa bara undernamnrymder)"; $lang['addpage_hideACL'] = "Dölj {{NEWPAGE}} om användaren inte har rättighet att skapa sidor (visa meddelande om ej ikryssad)" ?> ====== History ====== * 2008-01-10 : New zip file with some correction (the submit bug in ie, the namespace ".") and all new language are added * 2007-05-19 : portuguese language definicions added fot completely hide NEWPAGE by GibaPhp * 2007-01-21 : Can configure if you want to add some message about rights or completely hide NEWPAGE * 2007-01-21 : Now support ACL (thanks to 66[dot]7[dot]118[dot]82 (FIXME) ) * 2007-01-13 : Add new functionnality with the syntax {{NEWPAGE[>namespace]}} (thanks to Martin) * 2007-01-12 : Remove 4 invisible hex chars in script.js, adding italian and russian (uncomplete) * 2007-01-11 : Fix encoding problem (with old noaccent function) * 2006-12-20 : New Release, old version on : [[plugin:addnewpage_old]] ====== Discussion ====== I am not sure where exactly to put the above php code (from the [[plugin:addnewpage#tips|Tips]] section) into my template. Can anyone please advise? [[jsb@greatertalent.com|help me]] >Put it where you want to see the new page forms. (\lib\tpl\default\main.php)\\ >>I'm new to XHTML, PHP and DokuWiki, and I'm trying to add the addnewpage plugin to the bar_ _topleft. When I add the PHP code from the [[plugin:addnewpage#tips|Tips section]] it always wraps it in

...

, and having a two line top bar really breaks the lay-out. Here's my research up until now:\\ When using the plugin within the Wiki page itself, the

is not added. So I started looking at the php echo command, but a plain text echo command does not add the

either. Next I looked into the syntax.php of the plugin, and p_render/p_get_instructions in the DokuWiki PHP x-ref, but am still at a loss on where the

is added. I'm assuming it is the difference between block and in-line rendering, but I don't know how to influence that.\\ Any help on where to start looking, or how to prevent the

from being generated is greatly appreciated. --- //[[dokuwiki@dsslib.com|Arnoud]] 2007-01-27 19:27// >>>The

are added by dokuwiki... I don't know if there is a tips include in dokuwiki to remove it, but you can use php : $out = p_render('xhtml',p_get_instructions('{{NEWPAGE}}'),$info); echo str_replace(array("

","

"),array("",""),$out);
>>> or if it doesn't work : ob_start(); echo p_render('xhtml',p_get_instructions('{{NEWPAGE}}'),$info); $out = ob_get_clean(); echo str_replace(array("

","

"),array("",""),$out);
>>>> OK, I got it working now, but I had to change a few small things. This is the code I added to the bar_ _topleft in the main.php of my template: ","

"),array("",""),p_render('xhtml',p_get_instructions('{{NEWPAGE}}'),$info))?>
>>>> Secondly I needed to change the
..
pair in the plugin/addnewpage/syntax.php with their .. counterparts. All this together works like a charm! Thanks for the code snippet, and plug-in. --- //[[dokuwiki@dsslib.com|Arnoud]] 2007-01-31 22:28// ===== Enhancements ===== I would like to use the plugin in a wiki with a lot of namespaces and it would be great if the syntax would allow to preset the namespace where the new page should be created in! e.g. {{NEWPAGE>[namespace]}} \\ this would be benefit so that the users of the wiki do not need to understand the structure of the wiki. \\ \\ the idea of how to implement this would be that you could use the same code as today... but you fill the [namespace] parameter as an default into the field. In addition you hide the field. this should work! \\ what do you think about this?\\ Martin > Hello, I think about this functionnality. But i don't now what's better between your option and this option : the {{NEWPAGE>[namespace]}} use [namesapce] as root and only show namespace and subnamespace... >> Hi, I implemented to code already... so if you want to use it please give me your email and i can send it to you... I do not have any preferences for the option : or > ===== Script Bug ===== Also the new version contains the same bug. I found now the problem:\\ script does not contain an error, it is a 3 character long prefix in the file, which is not indicated by normal text editors (probably a code-head, "EFBBBF"). use a hexeditor to see and delete it. The script mash by pure Ascii-text, without binary head.\\ (i put a german translation, it was deteted, why?) > I update again the zip without this invisible hex code... It works better ? > I never see you translation, could you add here again ? or direct mail me it => ido@woow-fr.com >> Now it works :-). >> (i think it is the editor you use, i found this head too in the php files, "EFBBBF" is a UTF8 Head (http://www.fileformat.info/info/unicode/char/feff/index.htm). only Opera seems to have the script-problem, if you want test it once.) >> the German text is already Unicode coded, you can copy it as Ascii. (ß => ß, ü => ü) By testing the new release, now with %%{{NEWPAGE}}%% its only the root in the list, nothing else. \\ >Ok, i've just fix it ! sorry ;) I'm always getting an error after I've put the {{NEWPAGE[>namespace]}} into the page and save, here's the error I get: Fatal error: Call to undefined function: getconf() in /../lib/plugins/addnewpage/syntax.php on line 56 Is there any particular reason why I would be getting this?\\ > Do you use the lastest dokuwiki release ? I have a bunch of users on my wiki, each with there own namespace that they can put stuff in. It gets really confusing for them to see all the namespaces, especially when they can only create pages in just a few of them. Here is the patch that I made that will restrict the selection box to namespaces in which the current user can actually create a new page. If the showroot option is true, then the root will always be shown, but may be disabled if the permissions aren't right. (The disabling seems to work in Firefox, but not in Safari). --- syntax.php 2007-01-13 10:36:42.000000000 -0700 +++ syntax.php 2007-01-17 18:33:13.000000000 -0700 @@ -66,15 +66,19 @@ $ret=''; $renderer->doc .= ''; - $renderer->doc .= ''; + if(strlen($data[1])>1) { + $t=explode("&",$data[1]); + foreach($t as $value) { + $parameter=explode("=",$value,2); + $renderer->doc .= ''; + } + } + + $renderer->doc .= ''; $renderer->doc .= ''; $renderer->doc .= ''; If you'd like to roll this into the official addnewpage plugin, that'd be great! If you'd like to incorporate the action plugin [[plugin:newpagetemplate]] that I wrote into the addnewpage plugin, that'd be great too. Thanks again for such a great plugin! ---- Regarding this patch: How can I apply it? I tried cat the-patch.diff | patch -p0 in the plugin directory, but all three hunks were rejected. Any idea why? -- Niklas Volbers you should run it within the addnewpage plugin directory; it modifies the syntax.php file; or you can [[https://www.cnaf.infn.it/~andreozzi/tmp/syntax.php.txt|get the modified syntax.php]] (remove the .txt at the end). -- Sergio I have a problem with the combination of addnewpage and newpagetemplate. On their own, both plugins works well. I am using the modified syntax.php vor the addnewpage-plugin, that I downloaded from above. When using the "special" Syntax for addnewpage with newpagetemplate, I will be linked to the editbox of the page (containg the link). Some idea whats going wrong? Thanks! Found the problem: There may only be on "addnewpage" on a page. -- Freight Is there any way to make it so that not only the namespace is is shown as a combo box but the pagename as well? Better yet make it like an ajax enabled history enabled text field. I always find it a pain to find the name of the link before I get insert it, i.e. I have to leave the page I'm editing and goto the page I want to link to find it's correct link name. -- Stef I found there was a problem with the javascript being overridden in Internet Explorer. I couldn't track down the source of the problem, so I modified the code slightly. In Syntax I made the following changes: $renderer->doc .= '
'; $renderer->doc .= '
'; $renderer->doc .= 'Section (namespace):'; $renderer->doc .= $this->_makecombo(); $renderer->doc .= '
Page shortname:'; $renderer->doc .= ''; $renderer->doc .= ''; $renderer->doc .= '
'; $renderer->doc .= '
';
And I made a page called newpage.php that I put in the wiki directory (where I keep my wiki). That file contains the following: Change the 'intranet.local' to your server name. Hope this helps someone. Obviously, incredibly quick and dirty and not at all secure - don't use it anywhere public would be my advice - I plan to clean it up when I've sorted out a couple of other issues. ---- Does anyone know where to get the plugin code described [[plugin:newpagebutton|here]]? I need a combo namespace + page adder. -TLL 6/26/07 --- Teh combo only shows "root" is does not show the other namespaces - any reason why? ==== Add New Page Redirect to Current Page ==== ---- When I click the "Add new page"-Button I get always redirected to the page where I placed the NewPage-Field and can edit that page but no new one - can anyone confirm that? I'm using Dokuwiki-2007-06-26 ---- Same here, same DokuWiki version (2007-06-26b). Plugin "addnewpage" (2007-01) opens only the current page. ---- That´s what I get, too (same version). > I had this problem, but I realized it was because I had two NEWPAGE buttons on the same page. They both receive the same name so the the second one would not work and only opened the current page for editing. ---- I had the problem with "Add new page" redirect to current page. I was able to twinkle some settings to make it work. All changes are related to script.js which is in charge of creating the correct action in formular posted to web server. I had to change: "?id="+document.getElementById('np_cat').value+':'+document.getElementById('addnewpage_title').value by "/{SERVERBASEADRESS}/doku.php/"+document.getElementById('np_cat').value+':'+document.getElementById('addnewpage_tit le').value where ''SERVERBASEADRESS'' is the absolute path in the URL before doku.php. For example in my case, with URL, http://gandalf/wikitris/doku.php... SERVERBASEADDRESS is 'wikitris' (ie. replace __?id=__ by __/**wikitris**/doku.php/__ ) ---- i had the same issue with redirection (v. 2007-06-26b) to the current page and i tried the above workaround. however i had to replace ?id= with /{SERVERBASEADRESS}/doku.php/?id= --- I had the exact same issue (but with again a slightly different solution :); I replaced ?id= with /dokuwiki/doku.php?id= I have the dokuwiki folder installed in the root folder of my Web server (I'm using Apache, so in my case this is htdocs/) :?: **UPDATE:** i think the problem is related to the dokuwiki dir not being in the "DocumentRoot" of the webserver, i installed the plugin on another server, which is accessed via a "http://wiki" "VirtualHost", and the problem doesn't appear there. ---- I've tried all of these fixes here, and it still doesn't work. I can confirm that the problem is NOT related to the dokuwiki dir not being in the "DocumentRoot" of the webserver, because mine is in the DocumentRoot of the server. To me, it seems that the problem is that the plugin isn't picking up the text that I write into the editbox. I can't figure out how I could fix that if that would be the case. Any ideas? Thanks! --jasonskipper 01/22/08 **UPDATE** This is strange, but I tried putting everything back to NORMAL, and it just suddenly worked. It didn't work at first, and it didn't work with any of the changes, but now it works with just __?id=__... --jasonskipper 01/22/08 ---- Same problem here, but only in IE6. The plugin works "out of the box" in Firefox, in IE6 the current page is opened for editing. Have tried suggested workarounds above without success. DokuWiki 2007-06-26b in IIS6. - Daniel Lindgren 2008-02-05 **UPDATE** A day later it works in IE6 too. Haven't done a thing. Is there some kind of time period that has to pass in DokuWiki before the plugin functions properly? --- Daniel Lindgren 2008-02-06 ---- I use Dokuwiki 2008-03-31 with firefox, and I have the same problem. I'll try to solve it. Any idea of where the problem is?? ---- >This is strange, but I tried putting everything back to NORMAL, and it just suddenly worked. It didn't work at first, and it didn't work with any of >the changes, but now it works with just ?id=… –jasonskipper 01/22/08 I can confirm this. I started debugging the problem by sticking alerts, and commenting out the do=edit in render. Then, once I took them all back out, it started working. I even did a diff between my local install and a new download just to make sure I didn't change anything. The ONLY thing that is different is whitespace. So strange... ~TommyWang 08/29/08 ---- I had this problem too! After clearing browser's offline repository and all the other infos like cookies, caches, etc, then it works! It seems like javascript problem..~Samsee 10/07/09 ===== Namespace Fix ===== Syntax {{ADDNEWPAGE>.}} not work because script don't interpret dot as current namespace. here fix (code i take from indexmenu plugin): I add this function in **/lib/plugins/addnewpage/syntax.php** /** * Parse namespace request * * @author Samuele Tognini */ function _parse_ns ($ns) { global $ID; $ns=preg_replace("/^\.(:|$)/",dirname(str_replace(':','/',$ID))."$1",$ns); $ns=str_replace("/",":",$ns); $ns = cleanID($ns); return $ns; } and change in function **_makecombo**: -- if (($data != "") && ($hide)) return ''; ++ if (($data != "") && ($hide)) return ''; FIXME This works only if namespace separator not "/" -- //Ramirez// ==== Namespace Fix - Combo box fix ==== Rather than changing this line like so: if(($data != "") && ($hide)) return ''; I left it alone and simply added this: $data = $this->_parse_ns($data); In function **_makecombo** after the line: $hide=$this->getConf('addpage_hide'); >Hello, I am trying to define a newpage button with a certain namespaces af a certain namespace showing on a combo box, but it is not working. The only way I can see a combo box is if I use {{NEWPAGE}} alone. Is it possible? I am trying the following sintax, where temadigital is a namespace that contains the namespaces that I would like the user to choose when creating a new page: {{NEWPAGE>[:temadigital]}} >And also, I have noticed that the latest version of this plugin allready have the changes made by Samuele Tognini. I have tryed to apply the fix proposed just above, but it did not worked neither way. Thank you! [[felipe.uderman@gmail.com | uderman]] ===== submit with ENTER in IE BUG===== if you submit the form clicking in the button **hitting enter key** it works in FF, not in IE there is a solution... Function setname() never fired in this case.. because it´s bind to buttom.onclick event. I think it must be binded to form.onsubmit So in syntax.php: find $renderer->doc .= '
'; change to: $renderer->doc .= ''; 2008/01/08 miguelito... ---- ===== do=addnewpage ===== Useful plugin. How about a addnewpage command action. 'Peter Niebling', 'email' => 'peter.niebling@co-met.info', 'date' => '5.7.2008', 'name' => 'addnewpage (action component)', 'desc' => 'Provides do=addnewpage command action', 'url' => 'http://www.co-met.info', ); } function register ( & $controller ) { $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, '_handle_act', array()); $controller->register_hook('TPL_ACT_UNKNOWN', 'BEFORE', $this, '_handle_tpl_act', array()); } function _handle_act( & $event, $param ) { if ( $event->data != 'addnewpage' ) return; $event->preventDefault(); } function _handle_tpl_act ( & $event, $param ) { if ( $event->data != 'addnewpage' ) return; $event->preventDefault(); $this->doc = ''; if ( auth_quickaclcheck($_REQUEST['id']) >= AUTH_CREATE and ( $syntax = plugin_load('syntax','addnewpage') ) and $syntax->render('xhtml',$this,trim($_REQUEST['ns'])) and $this->doc ) print('
'.$syntax->getLang('okbutton').'
'.$this->doc); // Title could be better ?! else print p_locale_xhtml('denied'); } }
Just copy the code into action.php in the addnewpage directory. //5.7.2008 Peter// ---- ==== Russian ==== === lang.php === === settings.php === [ns]}} синакис: спрятать выделение пространства имен (не отмеченно: показывать только подпространства имен')"; $lang['addpage_hideACL']="Спрятать {{NEWPAGE}} если пользователь не имеет прав на добавление страниц (показать сообщение если не отмеченно)" ?>