From 9451824bb3a66fd6d36315a44b0fc0b905af9a07 Mon Sep 17 00:00:00 2001 From: Szymon Olewniczak Date: Mon, 19 Jun 2017 09:56:21 +0200 Subject: [PATCH 1/2] added optional option skipns for simplenavi call --- syntax.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/syntax.php b/syntax.php index 691ed76..e561ab1 100644 --- a/syntax.php +++ b/syntax.php @@ -4,6 +4,7 @@ * * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html * @author Andreas Gohr + * @author Szymon Olewniczak <(my first name) [at] imz [dot] re> */ // must be run within Dokuwiki @@ -35,7 +36,18 @@ function connectTo($mode) { } function handle($match, $state, $pos, Doku_Handler $handler){ - $data = array(cleanID(substr($match,13,-2))); + list($nsstr, $optsstr) = explode('|', substr($match,13,-2), 2); + + //defaults + $opts = array( + 'skipns' => '' + ); + + if(preg_match('/skipns=(\S+)/u', $optsstr, $sns) > 0) { + $opts['skipns'] = $sns[1]; + } + + $data = array(cleanID($nsstr), $opts); return $data; } @@ -46,10 +58,13 @@ function render($mode, Doku_Renderer $R, $pass) { global $conf; global $INFO; $R->info['cache'] = false; + + list($nsstr, $opts) = $pass; - $ns = utf8_encodeFN(str_replace(':','/',$pass[0])); + $ns = utf8_encodeFN(str_replace(':','/',$nsstr)); $data = array(); - search($data,$conf['datadir'],array($this,'_search'),array('ns' => $INFO['id']),$ns,1,'natural'); + $opts['ns'] = $INFO['id']; + search($data,$conf['datadir'],array($this,'_search'),$opts,$ns,1,'natural'); if ($this->getConf('sortByTitle') == true) { $this->_sortByTitle($data,"id"); } else { @@ -133,6 +148,11 @@ function _search(&$data,$base,$file,$type,$lvl,$opts){ if($type=='f' && auth_quickaclcheck($id) < AUTH_READ){ return false; } + + //check skipns + if(!empty($opts['skipns']) && preg_match('/'.$opts['skipns'].'/ui',':'.$id)){ + return false; + } $data[$id]=array( 'id' => $id, 'type' => $type, From e3e81f92c57a07197ddfaf9562b7340dacfa2ec4 Mon Sep 17 00:00:00 2001 From: Szymon Olewniczak Date: Mon, 19 Jun 2017 10:10:59 +0200 Subject: [PATCH 2/2] fix indentation --- syntax.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/syntax.php b/syntax.php index e561ab1..9909912 100644 --- a/syntax.php +++ b/syntax.php @@ -4,7 +4,7 @@ * * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html * @author Andreas Gohr - * @author Szymon Olewniczak <(my first name) [at] imz [dot] re> + * @author Szymon Olewniczak */ // must be run within Dokuwiki @@ -40,12 +40,12 @@ function handle($match, $state, $pos, Doku_Handler $handler){ //defaults $opts = array( - 'skipns' => '' + 'skipns' => '' ); if(preg_match('/skipns=(\S+)/u', $optsstr, $sns) > 0) { - $opts['skipns'] = $sns[1]; - } + $opts['skipns'] = $sns[1]; + } $data = array(cleanID($nsstr), $opts); @@ -151,8 +151,8 @@ function _search(&$data,$base,$file,$type,$lvl,$opts){ //check skipns if(!empty($opts['skipns']) && preg_match('/'.$opts['skipns'].'/ui',':'.$id)){ - return false; - } + return false; + } $data[$id]=array( 'id' => $id, 'type' => $type,