Skip to content

Commit

Permalink
Add param "newpagevars" for plugin newpagetemplate
Browse files Browse the repository at this point in the history
Fixes #66

UNTESTED adaptation of commit 9785b7d
to the new preg_match()-based parser.
  • Loading branch information
dregad committed May 7, 2023
1 parent 114e382 commit 0d90564
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function connectTo($mode) {
* {{NEWPAGE#newtpl1,newtpl2}}
* {{NEWPAGE#newtpl1|Title1,newtpl2|Title1}}
* {{NEWPAGE>your:namespace#newtpl1|Title1,newtpl2|Title1}}
* {{NEWPAGE>your:namespace#newtpl1|Title1,newtpl2|Title1#@HI@,Howdy}}
*
* @param string $match The text matched by the patterns
* @param int $state The lexer state for the match
Expand All @@ -67,6 +68,7 @@ public function handle($match, $state, $pos, Doku_Handler $handler) {
$data = array(
'namespace' => '',
'newpagetemplates' => array(),
'newpagevars' => array(),
'options' => array(
'exclude' => $this->getConf('addpage_exclude'),
'showroot' => $this->getConf('addpage_showroot'),
Expand All @@ -80,8 +82,9 @@ public function handle($match, $state, $pos, Doku_Handler $handler) {
$data['namespace'] = trim($m[1]);
}

if(preg_match('/#(.*?)(\?|$)/', $match, $m)) {
if(preg_match('/#(.*?)(#.*?)?(\?|$)/', $match, $m)) {
$data['newpagetemplates'] = array_map('trim', explode(',', $m[1]));
$data['newpagevars'] = array_map('trim', explode(',', $m[2]));
}

if(preg_match('/\?(.*?)(#|$)/', $match, $m)) {
Expand Down Expand Up @@ -128,6 +131,7 @@ public function render($mode, Doku_Renderer $renderer, $data) {
. DOKU_TAB . DOKU_TAB . $namespaceinput . DOKU_LF
. DOKU_TAB . DOKU_TAB . '<input class="edit" type="'.$input.'" name="title" size="20" maxlength="255" tabindex="2" />' . DOKU_LF
. $newpagetemplateinput
. DOKU_TAB . DOKU_TAB . '<input type="hidden" name="newpagevars" value="' . $data['newpagevars'] . '"/>' . DOKU_LF
. DOKU_TAB . DOKU_TAB . '<input type="hidden" name="do" value="edit" />' . DOKU_LF
. DOKU_TAB . DOKU_TAB . '<input type="hidden" name="id" />' . DOKU_LF
. DOKU_TAB . DOKU_TAB . '<input class="button" type="submit" value="' . $this->getLang('okbutton') . '" tabindex="4" />' . DOKU_LF
Expand Down

0 comments on commit 0d90564

Please sign in to comment.