Don't force platal core to be in core/ directory
authorNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Mon, 14 Oct 2013 19:20:42 +0000 (21:20 +0200)
committerNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Fri, 1 Nov 2013 15:20:17 +0000 (16:20 +0100)
* Add a $globals->coreroot variable
* pl_autoload searches in core first, then in spoolroot

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
classes/plerrorreport.php
classes/plglobals.php
classes/plmodule.php
classes/plpage.php
include/platal.inc.php

index 8d9b8a8..56545e2 100644 (file)
@@ -128,7 +128,7 @@ class PlErrorReportFeed extends PlFeed
                             $globals->baseurl . '/site_errors',
                             'Erreurs d\'exĂ©cution',
                             $globals->baseurl . '/images/logo.png',
-                            $globals->spoolroot . '/core/templates/site_errors.feed.tpl');
+                            $globals->coreroot . '/templates/site_errors.feed.tpl');
     }
 
     protected function fetch(PlUser $user)
index fd11a25..6f71bbf 100644 (file)
@@ -103,6 +103,7 @@ class PlGlobals
     public $baseurl_http;
 
     /** paths */
+    public $coreroot;
     public $spoolroot;
 
     /** Localization configuration.
@@ -127,7 +128,8 @@ class PlGlobals
      */
     public function __construct(array $files)
     {
-        $this->spoolroot = dirname(dirname(dirname(__FILE__)));
+        $this->coreroot = dirname(dirname(__FILE__));
+        $this->spoolroot = dirname($this->coreroot);
 
         $this->readConfig($files);
         if (isset($_SERVER) && isset($_SERVER['SERVER_NAME'])) {
index d6ad810..1797abe 100644 (file)
@@ -122,7 +122,7 @@ abstract class PLModule
     {
         global $globals;
         if ($modname == 'core') {
-            $mod_path = $globals->spoolroot  . '/core/modules/' . $modname;
+            $mod_path = $globals->coreroot  . '/modules/' . $modname;
         } else {
             $mod_path = $globals->spoolroot . '/modules/' . $modname;
         }
index c2cd19e..9841123 100644 (file)
@@ -45,7 +45,7 @@ abstract class PlPage extends Smarty
         $this->template_dir  = $globals->spoolroot . '/templates/';
         $this->compile_dir   = $globals->spoolroot . '/spool/templates_c/';
         array_unshift($this->plugins_dir,
-                      $globals->spoolroot . '/core/plugins/',
+                      $globals->coreroot . '/plugins/',
                       $globals->spoolroot . '/plugins/');
         $this->config_dir    = $globals->spoolroot . '/configs/';
 
@@ -79,7 +79,7 @@ abstract class PlPage extends Smarty
     public static function getCoreTpl($tpl)
     {
         global $globals;
-        return $globals->spoolroot . '/core/templates/' . $tpl;
+        return $globals->coreroot . '/templates/' . $tpl;
     }
 
     // }}}
@@ -516,7 +516,7 @@ function core_include($source, $smarty)
 {
     global $globals;
     return preg_replace('/\{include( [^}]*)? core=([^} ]+)(.*?)\}/ui',
-                        '{include\1 file="' . $globals->spoolroot . '/core/templates/\2"\3}',
+                        '{include\1 file="' . $globals->coreroot . '/templates/\2"\3}',
                         $source);
 }
 
index f314932..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") {