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
23
MenuItem.php
23
MenuItem.php
|
@ -27,19 +27,22 @@ class MenuItem extends AbstractItem {
|
||||||
protected function setTargetFromType() : void {
|
protected function setTargetFromType() : void {
|
||||||
global $INFO;
|
global $INFO;
|
||||||
global $plugin_controller;
|
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 ( ! $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');
|
$translate_plugin =& $plugin_controller->load('helper', 'translate');
|
||||||
$language = $translate_plugin->getPageLanguage();
|
$language = $translate_plugin->getPageLanguage();
|
||||||
if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) {
|
} elseif ( ! $plugin_controller->isdisabled('translation') ) {
|
||||||
$this->id = preg_replace(
|
$translation_plugin =& $plugin_controller->load('helper', 'translation');
|
||||||
"/^$language:/",
|
$language = $translation_plugin->getLangPart($INFO['id']);
|
||||||
"$language:".$this->type.':',
|
}
|
||||||
$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']) ) {
|
||||||
} else {
|
$this->id = preg_replace(
|
||||||
$this->id = $this->type.':'.$INFO['id'];
|
"/^$language:/",
|
||||||
}
|
"$language:".$this->type.':',
|
||||||
|
$INFO['id']
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->id = $this->type.':'.$INFO['id'];
|
$this->id = $this->type.':'.$INFO['id'];
|
||||||
}
|
}
|
||||||
|
|
15
action.php
15
action.php
|
@ -81,15 +81,18 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
|
||||||
protected function getTopLevelNamespace() : ?string {
|
protected function getTopLevelNamespace() : ?string {
|
||||||
global $INFO;
|
global $INFO;
|
||||||
global $plugin_controller;
|
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 ( ! $plugin_controller->isdisabled('translate') ) {
|
||||||
// Skip top-level namespace added by "translate" plugin
|
|
||||||
$translate_plugin =& $plugin_controller->load('helper', 'translate');
|
$translate_plugin =& $plugin_controller->load('helper', 'translate');
|
||||||
$language = $translate_plugin->getPageLanguage();
|
$language = $translate_plugin->getPageLanguage();
|
||||||
if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) {
|
} elseif ( ! $plugin_controller->isdisabled('translation') ) {
|
||||||
return explode(':', $INFO['namespace'])[1];
|
$translation_plugin =& $plugin_controller->load('helper', 'translation');
|
||||||
} else {
|
$language = $translation_plugin->getLangPart($INFO['id']);
|
||||||
return explode(':', $INFO['namespace'])[0];
|
}
|
||||||
}
|
// Skip top-level language namespace if one is in use
|
||||||
|
if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) {
|
||||||
|
return explode(':', $INFO['namespace'])[1];
|
||||||
} else {
|
} else {
|
||||||
return explode(':', $INFO['namespace'])[0];
|
return explode(':', $INFO['namespace'])[0];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue