SF.net SVN: phpwiki:[10741] trunk/lib/plugin/PageTrail.php

vargenau--- via phpwiki-checkins <[email protected]>
Newsgroups gmane.comp.web.wiki.phpwiki.checkins
Message-ID <[email protected]>
Revision: 10741
          http://sourceforge.net/p/phpwiki/code/10741
Author:   vargenau
Date:     2021-12-06 17:47:56 +0000 (Mon, 06 Dec 2021)
Log Message:
-----------
PageTrail plugin: check it is a wiki page (to avoid wrong links in PhotoAlbum)

Modified Paths:
--------------
    trunk/lib/plugin/PageTrail.php

Modified: trunk/lib/plugin/PageTrail.php
===================================================================
--- trunk/lib/plugin/PageTrail.php	2021-12-06 17:16:51 UTC (rev 10740)
+++ trunk/lib/plugin/PageTrail.php	2021-12-06 17:47:56 UTC (rev 10741)
@@ -73,24 +73,31 @@
 
         // Get name of the current page we are on
         $thispage = $request->getArg('pagename');
-        $Pages = $request->session->get("PageTrail");
-        if (!is_array($Pages)) {
-            $Pages = array();
+        $pages = $request->session->get("PageTrail");
+        if (!is_array($pages)) {
+            $pages = array();
         }
 
-        if (!isset($Pages[0]) or ($duplicates || ($thispage != $Pages[0]))) {
-            array_unshift($Pages, $thispage);
-            $request->session->set("PageTrail", $Pages);
+        $wikipages = array();
+        foreach ($pages as $page) {
+            if ($dbi->isWikiPage($page)) {
+                $wikipages[] = $page;
+            }
         }
 
-        $numberlinks = min(count($Pages), $numberlinks);
+        if (!isset($wikipages[0]) or ($duplicates || ($thispage != $wikipages[0]))) {
+            array_unshift($wikipages, $thispage);
+            $request->session->set("PageTrail", $wikipages);
+        }
+
+        $numberlinks = min(count($wikipages), $numberlinks);
         if (!$invisible and $numberlinks) {
             $html = HTML::span(array('class' => 'pagetrail'));
-            $html->pushContent(WikiLink($Pages[$numberlinks - 1], 'auto'));
+            $html->pushContent(WikiLink($wikipages[$numberlinks - 1], 'auto'));
             for ($i = $numberlinks - 2; $i >= 0; $i--) {
-                if (!empty($Pages[$i]))
+                if (!empty($wikipages[$i]))
                     $html->pushContent(PAGETRAIL_ARROW,
-                        WikiLink($Pages[$i], 'auto'));
+                        WikiLink($wikipages[$i], 'auto'));
             }
             return $html;
         } else {

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.