Don't force platal core to be in core/ directory
[platal.git] / include / platal.inc.php
index 900220c..7fbdc08 100644 (file)
@@ -54,9 +54,11 @@ function pl_autoload($cls, array $pathes = array())
     } else if (starts_with($cls, 'pldbtable')) {
         $cls = 'pldbtableentry';
     }
-    $basepath = dirname(dirname(dirname(__FILE__)));
+    $corebasepath = dirname(dirname(__FILE__));
+    $basepath = dirname($corebasepath);
+    $corebasename = basename($corebasepath);
 
-    array_unshift($pathes, 'core/classes', 'classes');
+    array_unshift($pathes, $corebasename . '/classes', 'classes');
     foreach ($pathes as $path) {
         if (file_exists("$basepath/$path/$cls.php")) {
             if (include_once "$basepath/$path/$cls.php") {
@@ -67,6 +69,7 @@ function pl_autoload($cls, array $pathes = array())
     return false;
 }
 pl_autoload('Env');
+pl_autoload('PlBacktrace');
 
 function pl_core_include($file)
 {
@@ -107,7 +110,6 @@ function pl_error_handler($errno, $errstr, $errfile, $errline)
     $type = isset($errortype[$errno]) ? $errortype[$errno] : $errno;
     $error = strpos($type, 'Warning') !== false || strpos($type, 'Error') !==false;
 
-    pl_autoload('PlBacktrace');
     if (!isset(PlBacktrace::$bt['PHP Errors'])) {
         new PlBacktrace('PHP Errors');
     }
@@ -261,7 +263,7 @@ function pl_content_headers($content_type, $encoding = 'utf-8')
  * cache duration defaults to the global static_cache_duration. No encoding is
  * applied by default.
  */
-function pl_cached_content_headers($content_type, $encoding = null, $cache_duration = -1)
+function pl_cached_content_headers($content_type, $encoding = null, $cache_duration = -1, $filename = null)
 {
     global $globals;
     $cache_duration = ($cache_duration < 0 ? $globals->static_cache_duration : $cache_duration);
@@ -270,6 +272,9 @@ function pl_cached_content_headers($content_type, $encoding = null, $cache_durat
     header("Expires: " . gmdate('D, d M Y H:i:s', time() + $cache_duration) . " GMT");
     header("Pragma: ");
     pl_content_headers($content_type, $encoding);
+    if (!is_null($filename)) {
+         header('Content-Disposition: attachment; filename=' . $filename);
+    }
 }
 
 /**
@@ -282,5 +287,13 @@ function pl_cached_dynamic_content_headers($content_type, $encoding = null)
     pl_cached_content_headers($content_type, $encoding, $globals->dynamic_cache_duration);
 }
 
+function pl_var_dump()
+{
+    echo '<pre>';
+    $array = func_get_args();
+    call_user_func_array('var_dump', $array);
+    echo '</pre>';
+}
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>