page: article method to find handler code
[minimedit.git] / article.inc.php
index da1836890a7c096dfc77b48d18da2705ce791326..d8ddf77b990b374d25586da8a01501ad030d21b3 100644 (file)
@@ -50,6 +50,30 @@ class ArchiveArticle
                return $this->$col = $this->$col();  # run method and cache
        }
 
+       function handler()
+       {
+               $path = $this->link;
+               $this->path = '';
+               $this->restricted = FALSE;
+               while (TRUE) {
+                       if (file_exists("$path/.private")) {
+                               $this->restricted = $path;
+                       }
+
+                       if (file_exists("$path/index.php")) {
+                               return $path;
+                       }
+
+                       $up = strrpos($path, '/');
+                       $this->path = substr($path, $up) . $this->path;
+                       $path = substr($path, 0, $up);
+                       if ($up === FALSE) {
+                               break;
+                       }
+               }
+               return;
+       }
+
        function safetitle()
        {
                return trim($this->meta['og:title'] ?? strip_tags($this->title));