diff --git a/lib/models/WikiPage.class.php b/lib/models/WikiPage.class.php index 3d8ca9e3f69fa4080b511d8b3b87e2cbf6ac7b69..82abcd418858853aaf122926272e07d486b7083e 100644 --- a/lib/models/WikiPage.class.php +++ b/lib/models/WikiPage.class.php @@ -289,4 +289,23 @@ class WikiPage extends SimpleORMap implements PrivacyObject return $descendants; } + /** + * @param string $other_keyword + * @return bool + */ + public function isDescendantOf(string $other_keyword): bool + { + if ($other_keyword === $this->keyword) { + return false; + } + $other_page = WikiPage::findLatestPage($this->range_id, $other_keyword); + if ($other_page) { + foreach ($other_page->getDescendants() as $descendant) { + if ($descendant->keyword === $this->keyword) { + return true; + } + } + } + return false; + } } diff --git a/lib/modules/CoreWiki.class.php b/lib/modules/CoreWiki.class.php index e389a8f0b2a1506b9b701b5a94a226e756ba5e8b..7921e4ce9639393c4f44fbfaec29a2b18014f307 100644 --- a/lib/modules/CoreWiki.class.php +++ b/lib/modules/CoreWiki.class.php @@ -173,7 +173,7 @@ class CoreWiki extends CorePlugin implements StudipModule */ public static function getTOC($startPage): TOCItem { - $root = new TOCItem($startPage->keyword); + $root = new TOCItem($startPage->keyword === 'WikiWikiWeb' ? _('Wiki-Startseite') : $startPage->keyword); $root->setURL(URLHelper::getURL('wiki.php', ['keyword' => $startPage->keyword])) ->setActive($startPage->keyword == Request::get('keyword') || $startPage->keyword == 'WikiWikiWeb' && !Request::get('keyword')); diff --git a/lib/wiki.inc.php b/lib/wiki.inc.php index 70f4a2a76f11ddb56a91c2d04e67199d9c9c976b..f813d059ea23e0071f483bf14bdf5b76cb755704 100644 --- a/lib/wiki.inc.php +++ b/lib/wiki.inc.php @@ -995,6 +995,13 @@ function wikiEdit($keyword, $wikiData, $user_id, $backpage=NULL, $ancestor=NULL) $page->version, $editor); $page_string .= '<br>'; $page_string .= strftime(_('am %x, %X'), $page->chdate); + if ($page->keyword === 'WikiWikiWeb' || $page->isDescendantOf('WikiWikiWeb')) { + $toc = CoreWiki::getTOC(WikiPage::getStartPage(Context::getId())); + } else { + $toc = new TOCItem($page->keyword); + } + } else { + $toc = new TOCItem($keyword === 'WikiWikiWeb' ? _('Wiki-Startseite') : $keyword); } // Action menu for content bar. @@ -1027,7 +1034,7 @@ function wikiEdit($keyword, $wikiData, $user_id, $backpage=NULL, $ancestor=NULL) } // Create content bar. - $contentBar = new ContentBar(CoreWiki::getTOC(WikiPage::getStartPage(Context::getId())), + $contentBar = new ContentBar($toc, $page_string, Icon::create('wiki'), $actionMenu); $template = $GLOBALS['template_factory']->open('wiki/edit.php'); @@ -1540,6 +1547,13 @@ function showWikiPage($keyword, $version, $special="", $show_comments="icon", $h $page->version, $editor); $page_string .= '<br>'; $page_string .= strftime(_('am %x, %X'), $page->chdate); + if ($page->keyword === 'WikiWikiWeb' || $page->isDescendantOf('WikiWikiWeb')) { + $toc = CoreWiki::getTOC(WikiPage::getStartPage(Context::getId())); + } else { + $toc = new TOCItem($page->keyword); + } + } else { + $toc = new TOCItem($keyword === 'WikiWikiWeb' ? _('Wiki-Startseite') : $keyword); } // Action menu for content bar. @@ -1577,7 +1591,7 @@ function showWikiPage($keyword, $version, $special="", $show_comments="icon", $h } // Create content bar. - $contentBar = new ContentBar(CoreWiki::getTOC(WikiPage::getStartPage(Context::getId())), + $contentBar = new ContentBar($toc, $page_string, Icon::create('wiki'), $actionMenu); if ($hilight) {