This is an old revision of the document!
Table of Contents
NewPage
Compatible with DokuWiki
No compatibility info given!
The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.
This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.
This plugin allows you to embed an input box that, when submitted, will create a new page on your wiki.
How to use
Simply write {{ANP>filename|link text}} in the page source.
Example: {{ANP>noname|Add new page}} will embed a form to create a page named “noname”
How to install
Create a file named 'lib/plugins/addpage/syntax.php'
Put this code into that file:
<?php if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_addpage extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'iDo', 'email' => 'iDo@woow-fr.com', 'date' => '12/08/2005', 'name' => 'AddNewPage Plugin', 'desc' => 'Ajoute une page a un wiki', 'url' => 'http://www.dokuwiki.org/plugin:newpage', ); } /** * What kind of syntax are we? */ function getType(){ return 'substition'; } /** * Where to sort in? */ function getSort(){ return 106; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern("{{ANP>.+?}}",$mode,'plugin_addpage'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ $match = substr($match,6,-2); // Strip markup $match = preg_split('/\|/u',$match,2); // Split title from URL if (!isset($match[1])) $match[1] = NULL; return $match; } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ //$renderer->info['cache'] = FALSE; $renderer->doc .= '<div class="new">'; $renderer->doc .= $this->AddNP($data); $renderer->doc .= '</div>'; return true; } return false; } function AddNP($data) { $mRet=''; $mRet.='<script type="text/javascript">'; $mRet.='function ANPadd() {'; $mRet.='var yourname= prompt(\'nom de la nouvelle page :\', \''.$data[0].'\');'; $mRet.='if ( (yourname==\''.$data[0].'\') || (yourname==null) ) { '; $mRet.='alert(\'Merci de saisir un nom de page\');}'; $mRet.='else { location.href = "doku.php?id="+escape(yourname); }}'; $mRet.='</script>'; $mRet.='<a href="#" onClick="ANPadd();">'.$data[1].'</a>'; return $mRet; } } //Setup VIM: ex: et ts=4 enc=utf-8 : ?>
Contact
ido [at] woow-fr [dot] com
Translation (French -> English)
French | English |
---|---|
nom de la nouvelle page | New page name |
Merci de saisir un nom de page | Please write a page name |
Translation (French -> Spanish)
French | Spanish |
---|---|
nom de la nouvelle page | Nombre de la nueva página |
Merci de saisir un nom de page | Por favor, escriba el nombre de la página |
Comments
Your comments:
Simply write {{ANP>filename|link text}} in the page source. Example: {{ANP>noname|Add new page}} will embed a form to create a page named “noname”
I don't understand.
which is the page source?
The comment was badly formated. It is corrected now.