page: quote link name fallback
[minimedit.git] / article.inc.php
index 2396f2be6e078e12af9d1ea2933ca25cafe6d49e..8600658954243ed9fbb1d99e58f72a0b5a857345 100644 (file)
@@ -65,6 +65,18 @@ class ArchiveArticle
                return;
        }
 
+       function index()
+       {
+               $this->handler;
+               if (empty($this->handler)) {
+                       return;
+               }
+               $User = NULL;
+               $Page = $this;
+               $res = include "./{$this->handler}/index.php";
+               return $res;
+       }
+
        function restricted()
        {
                $this->handler;
@@ -77,7 +89,7 @@ class ArchiveArticle
        }
        function name()
        {
-               return $this->safetitle ?: $this->link;
+               return $this->safetitle ?: htmlspecialchars($this->link);
        }
 
        function last()
@@ -264,12 +276,12 @@ class PageSearch
        function files()
        {
                # order alphabetically by link
-               $dir = iterator_to_array(new RecursiveIteratorIterator($this->iterator));
-               array_walk($dir, function (&$row, $name) {
-                       # prepare values for sorting (directory index first)
-                       $row = preg_replace('{/index\.html$}', '', $name);
-               });
-               asort($dir);
+               $dir = [];
+               foreach (new RecursiveIteratorIterator($this->iterator) as $name) {
+                       $article = new ArchiveArticle($name);
+                       $dir[$article->link] = $article;
+               }
+               ksort($dir);
                return $dir;
        }
 }