Skip to content

Commit

Permalink
The links do not be shown when blogs are in nested namespace (revised)
Browse files Browse the repository at this point in the history
…close dokufreaks#6
  • Loading branch information
Your Name committed Jan 13, 2019
1 parent 2e6f87c commit 0d78bb8
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function handle_act_render(Doku_Event $event, $params) {

return true;
}

function _getActiveNamespace() {
global $ID;
global $INFO;
Expand All @@ -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;

Expand Down

0 comments on commit 0d78bb8

Please sign in to comment.