rabin 3 days ago
parent
commit
e61e59fb1b
1 changed files with 13 additions and 3 deletions
  1. 13 3
      lib/View.php

+ 13 - 3
lib/View.php

@@ -25,16 +25,26 @@ class View
         return $host . $info['file'];
     }
 
-    public function local($file)
+    public function local($file, $convert = false)
     {
+        if (strstr($file, '?')) {
+            $temp = explode('?', $file);
+            $file = $temp[0];
+        }
+        $base = Dever::data();
         $host = Dever::host() . 'data/';
         if (strstr($file, $host)) {
-            return str_replace($host, Dever::data(), $file);
+            $local = str_replace($host, $base, $file);
         } else {
             $local = Dever::file('tmp/' . md5($file));
             file_put_contents($local, file_get_contents($file), LOCK_EX);
-            return $local;
         }
+        if ($convert) {
+            if (strstr($base, '/www/') && !strstr($base, 'wwwroot')) {
+                $local = str_replace('/www/', '/data/dm/container/web/', $local);
+            }
+        }
+        return $local;
     }
 
     public function http($file)