From 0d78bb8e96d9efb1e1a7adfd50a9abbc6febe3e5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 13 Jan 2019 16:10:42 +0900 Subject: [PATCH] The links do not be shown when blogs are in nested namespace (revised) close #6 --- action.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/action.php b/action.php index d7c1761..8ef66a1 100644 --- a/action.php +++ b/action.php @@ -71,7 +71,7 @@ function handle_act_render(Doku_Event $event, $params) { return true; } - + function _getActiveNamespace() { global $ID; global $INFO; @@ -85,15 +85,26 @@ function _getActiveNamespace() { return false; $namespaces = explode(',', $this->getConf('enabled_namespaces')); + $current_id_parts = explode(':', getNS($ID)); foreach ($namespaces as $namespace) { - if (trim($namespace) && (strpos($ID, $namespace . ':') === 0)) { - return $namespace; + $namespaceparts = explode(':', $namespace); + + // number of namespace elements must be the same + if (count($namespaceparts) != count($current_id_parts)) { + continue; + } + + // mutching each elements in the order + for ($i = 0 ; $i < count($namespaceparts) ; $i++ ) { + if (!preg_match("/$namespaceparts[$i]/",$current_id_parts[$i])) { + continue 2; + } } + return getNS($ID); } - return false; } - + function _getRelatedEntries($namespace) { global $ID;