Ensure compatibility with "translation" plugin
cf. https://www.dokuwiki.org/plugin:translation
This commit is contained in:
parent
e79910dd07
commit
e137f57890
2 changed files with 22 additions and 16 deletions
11
MenuItem.php
11
MenuItem.php
|
@ -27,10 +27,16 @@ class MenuItem extends AbstractItem {
|
|||
protected function setTargetFromType() : void {
|
||||
global $INFO;
|
||||
global $plugin_controller;
|
||||
$language = null;
|
||||
// If one of the "translate" or "translation" plugins is activated, get the language code for the current page
|
||||
if ( ! $plugin_controller->isdisabled('translate') ) {
|
||||
// If the "translate" plugin is activated, the language code should stay the top-level namespace
|
||||
$translate_plugin =& $plugin_controller->load('helper', 'translate');
|
||||
$language = $translate_plugin->getPageLanguage();
|
||||
} elseif ( ! $plugin_controller->isdisabled('translation') ) {
|
||||
$translation_plugin =& $plugin_controller->load('helper', 'translation');
|
||||
$language = $translation_plugin->getLangPart($INFO['id']);
|
||||
}
|
||||
// If the top level namespace is a language one, the children namespace should be inserted inside it
|
||||
if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) {
|
||||
$this->id = preg_replace(
|
||||
"/^$language:/",
|
||||
|
@ -40,9 +46,6 @@ class MenuItem extends AbstractItem {
|
|||
} else {
|
||||
$this->id = $this->type.':'.$INFO['id'];
|
||||
}
|
||||
} else {
|
||||
$this->id = $this->type.':'.$INFO['id'];
|
||||
}
|
||||
$this->params = [];
|
||||
}
|
||||
}
|
||||
|
|
11
action.php
11
action.php
|
@ -81,17 +81,20 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
|
|||
protected function getTopLevelNamespace() : ?string {
|
||||
global $INFO;
|
||||
global $plugin_controller;
|
||||
$language = null;
|
||||
// If one of the "translate" or "translation" plugins is activated, get the language code for the current page
|
||||
if ( ! $plugin_controller->isdisabled('translate') ) {
|
||||
// Skip top-level namespace added by "translate" plugin
|
||||
$translate_plugin =& $plugin_controller->load('helper', 'translate');
|
||||
$language = $translate_plugin->getPageLanguage();
|
||||
} elseif ( ! $plugin_controller->isdisabled('translation') ) {
|
||||
$translation_plugin =& $plugin_controller->load('helper', 'translation');
|
||||
$language = $translation_plugin->getLangPart($INFO['id']);
|
||||
}
|
||||
// Skip top-level language namespace if one is in use
|
||||
if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) {
|
||||
return explode(':', $INFO['namespace'])[1];
|
||||
} else {
|
||||
return explode(':', $INFO['namespace'])[0];
|
||||
}
|
||||
} else {
|
||||
return explode(':', $INFO['namespace'])[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue