diff --git a/source/lib/SihnonFramework/Config/PluginFactory.class.php b/source/lib/SihnonFramework/Config/PluginFactory.class.php index cde190c..ce71b5f 100644 --- a/source/lib/SihnonFramework/Config/PluginFactory.class.php +++ b/source/lib/SihnonFramework/Config/PluginFactory.class.php @@ -3,7 +3,7 @@ class SihnonFramework_Config_PluginFactory extends Sihnon_PluginFactory { protected static $plugin_prefix = 'Sihnon_Config_Plugin_'; - protected static $plugin_interface = 'Sihnon_Config_IPlugin'; + protected static $plugin_interface = 'SihnonFramework_Config_IPlugin'; protected static $plugin_dir = array( SihnonFramework_Lib => 'SihnonFramework/Config/Plugin', Sihnon_Lib => 'Sihnon/Config/Plugin/', diff --git a/source/lib/SihnonFramework/Exceptions.class.php b/source/lib/SihnonFramework/Exceptions.class.php index 70c0abb..c3dc0fb 100644 --- a/source/lib/SihnonFramework/Exceptions.class.php +++ b/source/lib/SihnonFramework/Exceptions.class.php @@ -2,23 +2,23 @@ class SihnonFramework_Exception extends Exception {}; -class SihnonFramework_Exception_NotImplemented extends Sihnon_Exception {}; -class SihnonFramework_Exception_MissingDefinition extends Sihnon_Exception {}; +class SihnonFramework_Exception_NotImplemented extends SihnonFramework_Exception {}; +class SihnonFramework_Exception_MissingDefinition extends SihnonFramework_Exception {}; -class SihnonFramework_Exception_DatabaseException extends Sihnon_Exception {}; -class SihnonFramework_Exception_DatabaseConfigMissing extends Sihnon_Exception_DatabaseException {}; -class SihnonFramework_Exception_DatabaseConnectFailed extends Sihnon_Exception_DatabaseException {}; -class SihnonFramework_Exception_NoDatabaseConnection extends Sihnon_Exception_DatabaseException {}; -class SihnonFramework_Exception_DatabaseQueryFailed extends Sihnon_Exception_DatabaseException {}; -class SihnonFramework_Exception_ResultCountMismatch extends Sihnon_Exception_DatabaseException {}; +class SihnonFramework_Exception_DatabaseException extends SihnonFramework_Exception {}; +class SihnonFramework_Exception_DatabaseConfigMissing extends SihnonFramework_Exception_DatabaseException {}; +class SihnonFramework_Exception_DatabaseConnectFailed extends SihnonFramework_Exception_DatabaseException {}; +class SihnonFramework_Exception_NoDatabaseConnection extends SihnonFramework_Exception_DatabaseException {}; +class SihnonFramework_Exception_DatabaseQueryFailed extends SihnonFramework_Exception_DatabaseException {}; +class SihnonFramework_Exception_ResultCountMismatch extends SihnonFramework_Exception_DatabaseException {}; -class SihnonFramework_Exception_ConfigException extends Sihnon_Exception {}; -class SihnonFramework_Exception_UnknownSetting extends Sihnon_Exception_ConfigException {}; +class SihnonFramework_Exception_ConfigException extends SihnonFramework_Exception {}; +class SihnonFramework_Exception_UnknownSetting extends SihnonFramework_Exception_ConfigException {}; -class SihnonFramework_Exception_CacheException extends Sihnon_Exception {}; -class SihnonFramework_Exception_InvalidCacheDir extends Sihnon_Exception_CacheException {}; -class SihnonFramework_Exception_CacheObjectNotFound extends Sihnon_Exception_CacheException {}; +class SihnonFramework_Exception_CacheException extends SihnonFramework_Exception {}; +class SihnonFramework_Exception_InvalidCacheDir extends SihnonFramework_Exception_CacheException {}; +class SihnonFramework_Exception_CacheObjectNotFound extends SihnonFramework_Exception_CacheException {}; -class SihnonFramework_Exception_InvalidPluginName extends Sihnon_Exception {}; +class SihnonFramework_Exception_InvalidPluginName extends SihnonFramework_Exception {}; ?> diff --git a/source/lib/SihnonFramework/Log/PluginFactory.class.php b/source/lib/SihnonFramework/Log/PluginFactory.class.php index d5e9234..35e651b 100644 --- a/source/lib/SihnonFramework/Log/PluginFactory.class.php +++ b/source/lib/SihnonFramework/Log/PluginFactory.class.php @@ -3,7 +3,7 @@ class SihnonFramework_Log_PluginFactory extends Sihnon_PluginFactory { protected static $plugin_prefix = 'Sihnon_Log_Plugin_'; - protected static $plugin_interface = 'Sihnon_Log_IPlugin'; + protected static $plugin_interface = 'SihnonFramework_Log_IPlugin'; protected static $plugin_dir = array( SihnonFramework_Lib => 'SihnonFramework/Log/Plugin/', Sihnon_Lib => 'Sihnon/Log/Plugin/', diff --git a/source/lib/SihnonFramework/Main.class.php b/source/lib/SihnonFramework/Main.class.php index 6c672b0..8d5a5e8 100644 --- a/source/lib/SihnonFramework/Main.class.php +++ b/source/lib/SihnonFramework/Main.class.php @@ -114,7 +114,7 @@ class SihnonFramework_Main { // Ensure the class to load begins with our prefix if (preg_match("/^{$class['base']}_/", $classname)) { // Special case: all related exceptions are grouped into a single file - if (preg_match("/^({$class['base']}_(?:.*_))Exception/", $classname, $matches = array())) { + if (preg_match("/^({$class['base']}_(?:.*?_)?)Exception/", $classname, $matches)) { require_once($class['base_dir_prefix'] . preg_replace('/_/', '/', $matches[1]) . 'Exceptions.class.php'); return; } @@ -124,7 +124,7 @@ class SihnonFramework_Main { // If this file exists, load it if (file_exists($filename)) { - require_once $filename; + require_once(realpath($filename)); return; } } elseif ($class['subclass'] && preg_match("/^{$class['subclass']}_/", $classname)) { @@ -132,9 +132,16 @@ class SihnonFramework_Main { // If a subclass doesn't exist, create it on the fly // Special case: all related exceptions are grouped into a single file - if (preg_match("/^({$class['subclass']}_(?:.*_))Exception/", $classname, $matches = array())) { - require_once($class['subclass_dir_prefix'] . preg_replace('/_/', '/', $matches[1]) . 'Exceptions.class.php'); - return; + if (preg_match("/^({$class['subclass']}_(?:.*?_)?)Exception/", $classname, $matches)) { + $exceptions_filename = $class['subclass_dir_prefix'] . preg_replace('/_/', '/', $matches[1]) . 'Exceptions.class.php'; + if (file_exists($exceptions_filename)) { + require_once($exceptions_filename); + } else { + // Create this class to extend the Framework parent + $parent_classname = preg_replace("/^{$class['subclass']}_/", "{$class['base']}_", $classname); + class_alias($parent_classname, $classname); + return; + } } // Replace any underscores with directory separators @@ -142,32 +149,12 @@ class SihnonFramework_Main { // If this file exists, load it if (file_exists($filename)) { - require_once $filename; + require_once(realpath($filename)); return; } else { // Create this class to extend the Framework parent $parent_classname = preg_replace("/^{$class['subclass']}_/", "{$class['base']}_", $classname); - - // Determine if the classname represents a class or an interface - $parent_class = new ReflectionClass($parent_classname); - $class_definition = ''; - if ($parent_class->isFinal()) { - // Final classes cannot be extended - return; - } - if ($parent_class->isInterface()) { - $class_definition .= 'interface '; - } else { - if ($parent_class->isAbstract()) { - $class_definition .= 'abstract '; - } - - $class_definition .= 'class '; - } - $class_definition .= "{$classname} extends {$parent_classname} {};"; - - eval($class_definition); - + class_alias($parent_classname, $classname); return; } } @@ -190,6 +177,14 @@ class SihnonFramework_Main { * @param unknown_type $subclass_dir_prefix */ public static function registerAutoloadClasses($base, $base_dir_prefix, $subclass = null, $subclass_dir_prefix = null) { + // The paths must end with a trailing slash + if ($base_dir_prefix && $base_dir_prefix[strlen($base_dir_prefix) - 1] != DIRECTORY_SEPARATOR) { + $base_dir_prefix .= DIRECTORY_SEPARATOR; + } + if ($subclass_dir_prefix && $subclass_dir_prefix[strlen($subclass_dir_prefix) - 1] != DIRECTORY_SEPARATOR) { + $subclass_dir_prefix .= DIRECTORY_SEPARATOR; + } + self::$autoload_classes[] = array( 'base' => $base, 'base_dir_prefix' => $base_dir_prefix, @@ -210,6 +205,11 @@ class SihnonFramework_Main { } } + public static function makeAbsolutePath($relative_path) { + $absolute_path = getcwd() . DIRECTORY_SEPARATOR . $relative_path; + return realpath($absolute_path); + } + public static function mkdir_recursive($directory, $permissions=0777) { $parts = explode('/', $directory); $path = '';