From 6fb7d0035aa91132f43eef5b092979e1cca18dd1 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 21 Aug 2010 15:18:16 +1000 Subject: [PATCH] Upstream Patch: Enable SYSMODS to hold upstream modules --- application/bootstrap.php | 20 +++++++++---------- .../kohana/system/classes/kohana/core.php | 13 +++++++++++- kh.php | 12 ++++++++++- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/application/bootstrap.php b/application/bootstrap.php index a76dfc07..f87c7454 100644 --- a/application/bootstrap.php +++ b/application/bootstrap.php @@ -67,16 +67,16 @@ Kohana::$config->attach(new Kohana_Config_File); * Enable modules. Modules are referenced by a relative or absolute path. */ Kohana::modules(array( - // 'auth' => MODPATH.'auth', // Basic authentication - // 'cache' => MODPATH.'cache', // Caching with multiple backends - // 'codebench' => MODPATH.'codebench', // Benchmarking tool - // 'database' => MODPATH.'database', // Database access - // 'image' => MODPATH.'image', // Image manipulation - // 'orm' => MODPATH.'orm', // Object Relationship Mapping - // 'oauth' => MODPATH.'oauth', // OAuth authentication - // 'pagination' => MODPATH.'pagination', // Paging of results - // 'unittest' => MODPATH.'unittest', // Unit testing - // 'userguide' => MODPATH.'userguide', // User guide and API documentation + // 'auth' => SMDPATH.'auth', // Basic authentication + // 'cache' => SMDPATH.'cache', // Caching with multiple backends + // 'codebench' => SMDPATH.'codebench', // Benchmarking tool + // 'database' => SMDPATH.'database', // Database access + // 'image' => SMDPATH.'image', // Image manipulation + // 'orm' => SMDPATH.'orm', // Object Relationship Mapping + // 'oauth' => SMDPATH.'oauth', // OAuth authentication + // 'pagination' => SMDPATH.'pagination', // Paging of results + // 'unittest' => SMDPATH.'unittest', // Unit testing + // 'userguide' => SMDPATH.'userguide', // User guide and API documentation )); /** diff --git a/includes/kohana/system/classes/kohana/core.php b/includes/kohana/system/classes/kohana/core.php index b74d0119..6de62325 100644 --- a/includes/kohana/system/classes/kohana/core.php +++ b/includes/kohana/system/classes/kohana/core.php @@ -570,6 +570,13 @@ class Kohana_Core { } // Add the module to include paths $paths[] = realpath(MODPATH.$path).DIRECTORY_SEPARATOR; + + // Add our system modules path + } + if (is_dir(SMDPATH.$path)) + { + // Add the module to include paths + $paths[] = realpath(SMDPATH.$path).DIRECTORY_SEPARATOR; } } @@ -1383,11 +1390,15 @@ class Kohana_Core { { $file = 'SYSPATH'.DIRECTORY_SEPARATOR.substr($file, strlen(SYSPATH)); } + elseif (strpos($file, SMDPATH) === 0) + { + $file = 'SMDPATH'.DIRECTORY_SEPARATOR.substr($file, strlen(SMDPATH)); + } elseif (strpos($file, MODPATH) === 0) { $file = 'MODPATH'.DIRECTORY_SEPARATOR.substr($file, strlen(MODPATH)); } - elseif (strpos($file, OVERPATH) === 0) + elseif (OVERPATH AND strpos($file, OVERPATH) === 0) { $file = 'OVERPATH/'.substr($file, strlen(OVERPATH)); } diff --git a/kh.php b/kh.php index d8cecc50..b75badeb 100644 --- a/kh.php +++ b/kh.php @@ -15,6 +15,11 @@ $application = 'application'; */ $modules = 'modules'; +/** + * The directory in which upstream Kohana resources (modules) are located. + */ +$sysmodules = 'includes/kohana/modules'; + /** * The directory in which the Kohana resources are located. The system * directory must contain the classes/kohana.php file. @@ -70,6 +75,10 @@ if ( ! is_dir($application) AND is_dir(DOCROOT.$application)) if ( ! is_dir($modules) AND is_dir(DOCROOT.$modules)) $modules = DOCROOT.$modules; +// Make the system relative to the docroot +if ( ! is_dir($sysmodules) AND is_dir(DOCROOT.$sysmodules)) + $sysmodules = DOCROOT.$sysmodules; + // Make the system relative to the docroot if ( ! is_dir($system) AND is_dir(DOCROOT.$system)) $system = DOCROOT.$system; @@ -81,6 +90,7 @@ if ( ! is_dir($override) AND is_dir(DOCROOT.$override)) // Define the absolute paths for configured directories define('APPPATH', realpath($application).DIRECTORY_SEPARATOR); define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR); +define('SMDPATH', realpath($sysmodules).DIRECTORY_SEPARATOR); define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR); if (is_dir(realpath($override))) @@ -89,7 +99,7 @@ else define('OVERPATH', ''); // Clean up the configuration vars -unset($application, $modules, $system, $override); +unset($application, $modules, $sysmodules, $system, $override); if (file_exists('install'.EXT)) {