]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/docfile.php
Added a lot more type-hints where they will happen. Please note that I found
[quix0rs-gnu-social.git] / lib / docfile.php
index ca03370d29e3df3ca42b2321bcbbd9dbd430ca30..1b7fde3cfe686741557ee817a9e70162550fd9e1 100644 (file)
@@ -57,29 +57,35 @@ class DocFile
 
     static function forTitle($title, $paths)
     {
-        if (is_string($paths)) {
+        if (!is_array($paths)) {
             $paths = array($paths);
         }
 
         $filename = null;
 
-        foreach ($paths as $path) {
+        if (Event::handle('StartDocFileForTitle', array($title, &$paths, &$filename))) {
 
-            $def = $path.'/'.$title;
-            if (!file_exists($def)) {
-                $def = null;
-            }
+            foreach ($paths as $path) {
 
-            $lang = glob($path.'/'.$title.'.*');
+                $def = $path.'/'.$title;
 
-            if ($lang === false) {
-                $lang = array();
-            }
+                if (!file_exists($def)) {
+                    $def = null;
+                }
+
+                $lang = glob($path.'/'.$title.'.*');
 
-            if (!empty($lang) || !empty($def)) {
-                $filename = self::negotiateLanguage($lang, $def);
-                break;
+                if ($lang === false) {
+                    $lang = array();
+                }
+
+                if (!empty($lang) || !empty($def)) {
+                    $filename = self::negotiateLanguage($lang, $def);
+                    break;
+                }
             }
+
+            Event::handle('EndDocFileForTitle', array($title, $paths, &$filename));
         }
 
         if (empty($filename)) {
@@ -89,13 +95,17 @@ class DocFile
         }
     }
 
-    function toHTML()
+    function toHTML(array $args=null)
     {
+        if (is_null($args)) {
+            $args = array();
+        }
+
         if (empty($this->contents)) {
             $this->contents = file_get_contents($this->filename);
         }
 
-        $this->output = common_markup_to_html($this->contents);
+        return common_markup_to_html($this->contents, $args);
     }
 
     static function defaultPaths()
@@ -108,6 +118,22 @@ class DocFile
         if (!empty($site)) {
             array_unshift($paths, INSTALLDIR.'/local/doc-src/'.$site.'/');
         }
+
+        return $paths;
+    }
+
+    static function mailPaths()
+    {
+        $paths = array(INSTALLDIR.'/local/mail-src/',
+                       INSTALLDIR.'/mail-src/');
+
+        $site = StatusNet::currentSite();
+        
+        if (!empty($site)) {
+            array_unshift($paths, INSTALLDIR.'/local/mail-src/'.$site.'/');
+        }
+
+        return $paths;
     }
 
     static function negotiateLanguage($filenames, $defaultFilename=null)