/** * Sets the needed static variables * * @return void */ private static function _setStaticVars() { // Gets the instance of the module manager self::$_modManager = Woops_Core_Module_Manager::getInstance(); // Static variables are set self::$_hasStatic = true; }
################################################################################ # $Id$ // Sets the error reporting level to the highest possible value error_reporting(E_ALL | E_STRICT); // Checks the PHP version if ((double) PHP_VERSION < 5.2) { // We are not running PHP 5.2 or greater trigger_error('PHP version 5.2 is required to use this script (actual version is ' . PHP_VERSION . ')', E_USER_ERROR); } // Checks for the SPL if (!function_exists('spl_autoload_register')) { // The SPL is unavailable throw new Exception('The SPL (Standard PHP Library) is required to use this script'); } // Checks for the SimpleXMLElement class if (!class_exists('SimpleXMLElement')) { // SimpleXMLElement is unavailable throw new Exception('The SimpleXMLElement class is required to use this script'); } // Includes the Woops class manager require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'Woops' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Class' . DIRECTORY_SEPARATOR . 'Manager.class.php'; // Registers an SPL autoload method to use to load the classes form the Woops project spl_autoload_register(array('Woops_Core_Class_Manager', 'autoLoad')); // Sets the error and exception handlers - From now every mistake will produce a fatal error set_exception_handler(array('Woops_Core_Exception_Handler', 'handleException')); set_error_handler(array('Woops_Core_Error_Handler', 'handleError')); // Sets the default timezone date_default_timezone_set(Woops_Core_Config_Getter::getInstance()->getVar('time', 'timezone')); // Loads the active modules Woops_Core_Module_Manager::getInstance()->initModules();
/** * Gets the unique class instance * * This method is used to get the unique instance of the class * (singleton). If no instance is available, it will create it. * * @return Woops_Core_Module_Manager The unique instance of the class * @see __construct */ public static function getInstance() { // Checks if the unique instance already exists if (!is_object(self::$_instance)) { // Creates the unique instance self::$_instance = new self(); } // Returns the unique instance return self::$_instance; }
<?php ################################################################################ # # # WOOPS - Web Object Oriented Programming System # # # # COPYRIGHT NOTICE # # # # Copyright (C) 2009 Jean-David Gadina - www.xs-labs.com # # All rights reserved # ################################################################################ # $Id$ Woops_Core_Module_Manager::getInstance()->registerBlock('cms', $moduleName, 'SayHello', 'Woops_Mod_HelloWorld_SayHello');
/** * Sets the needed static variables * * @return void */ private static function _setStaticVars() { // Gets the available modules self::$_modules = Woops_Core_Module_Manager::getInstance()->getAvailableModules(); // Gets the available timezones self::$_timezones = Woops_Time_Utils::getInstance()->getTimezones(); // Gets the available languages self::$_languages = Woops_Locale_Helper::getInstance()->getLanguages(); // Gets the available database engines self::$_engines = Woops_Database_Layer::getInstance()->getRegisteredEngines(); // Static variables are set self::$_hasStatic = true; }
/** * Gets the unique class instance * * This method is used to get the unique instance of the class * (singleton). If no instance is available, it will create it. * * @return Woops_Core_ClassManager The unique instance of the class * @see __construct */ public static function getInstance() { // Checks if the unique instance already exists if (!is_object(self::$_instance)) { // Creates the unique instance self::$_instance = new self(); // Gets the instance of the WOOPS environment self::$_instance->_env = Woops_Core_Env_Getter::getInstance(); // Gets the instance of the WOOPS module manager self::$_instance->_modManager = Woops_Core_Module_Manager::getInstance(); // Checks if we must use AOP classes self::$_instance->_enableAop = Woops_Core_Config_Getter::getInstance()->getVar('aop', 'enable'); // If AOP is enabled, the class cache must also be enabled if (self::$_instance->_enableAop) { // Enables the class cache self::$_instance->_classCache = true; } else { // Checks if we must use a class cache self::$_instance->_classCache = Woops_Core_Config_Getter::getInstance()->getVar('classCache', 'enable'); } // Checks if we must use cached classes if (self::$_instance->_classCache) { // Gets the class cache directory self::$_instance->_cacheDirectory = self::$_instance->_env->getPath('cache/classes/'); // Checks if the cache directory exist, and is writeable if (!self::$_instance->_cacheDirectory || !is_dir(self::$_instance->_cacheDirectory) || !is_writeable(self::$_instance->_cacheDirectory)) { // Disables the AOP and the class cache // Maybe this should generate a fatal error, but in that // case, and if we are installing WOOPS, this could // generate a bad first impression... self::$_instance->_classCache = false; self::$_instance->_enableAop = false; define('WOOPS_CLASS_CACHE_MODE_OFF', true); } } // Adds the WOOPS version to the HTTP headers header('X-WOOPS-VERSION: ' . Woops_Core_Informations::WOOPS_VERSION . '-' . Woops_Core_Informations::WOOPS_VERSION_SUFFIX); } // Returns the unique instance return self::$_instance; }
/** * Reads a configuration file from a WOOPS module * * @param string The name of the module * @return void * @throws Woops_Core_Config_Getter_Exception If the configuration file is not readable */ private function _loadModuleConf($name) { // Gets the path to the module's configuration file $modConf = Woops_Core_Module_Manager::getInstance()->getModulePath($name) . 'config.ini.php'; // Checks if the file exists if (file_exists($modConf)) { // Checks if the file is readable if (!is_readable($modConf)) { // Error - The configuration file is not readable throw new Woops_Core_Config_Getter_Exception('The WOOPS configuration file for module \'' . $name . '\' is not readable', Woops_Core_Config_Getter_Exception::EXCEPTION_CONFIG_FILE_NOT_READABLE); } // Gets the configuration values from the file $this->_modConf[$name] = parse_ini_file($modConf, true); } // Checks if the file was parsed if (!is_array($this->_modConf[$name])) { // No - Creates an empty array $this->_modConf[$name] = array(); } }
// Creates a recursive directory iterator $ITERATOR = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($ENV->getSourcePath('classes/Woops/'))); // Process each element of the iterator foreach ($ITERATOR as $FILEPATH => $FILE) { // Checks if the file is a class if ($FILE->isFile() && substr($FILEPATH, -10) === '.class.php') { // Gets the relative class path $CLASS_RELPATH = str_replace($ENV->getSourcePath('classes/'), '', $FILEPATH); // Gets the class name $CLASSNAME = str_replace(DIRECTORY_SEPARATOR, '_', substr($CLASS_RELPATH, 0, -10)); // Builds the cached version createClassCache($CLASSNAME); } } // Gets the module manager $MOD_MANAGER = Woops_Core_Module_Manager::getInstance(); // Gets the available modules $MODULES = $MOD_MANAGER->getAvailableModules(); // Process each module foreach ($MODULES as $MODNAME => $MODINFOS) { // Checks if the module is loaded if (!$MOD_MANAGER->isLoaded($MODNAME)) { // Do not process not loaded modules continue; } // Checks if the module has a class directory if (file_exists($MODINFOS[0] . 'classes') && is_dir($MODINFOS[0] . 'classes')) { // Creates a recursive directory iterator $ITERATOR = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($MODINFOS[0] . 'classes/')); // Process each element of the iterator foreach ($ITERATOR as $FILEPATH => $FILE) {
$INSTALL_ERROR = $CHECK_ENV->hasErrors || $CHECK_FS->hasErrors || $CHECK_FS->hasWarnings; // Checks if we can run the installer if ($INSTALL_ERROR) { // Errors detected $CONTENT = '<div class="box-warning"> <h4>Problems detected</h4> <div class="message"> We detected errors or warnings that could prevent the installation of WOOPS.<br /> Please run the <a href="' . substr(str_replace('//', '/', $_SERVER['SCRIPT_NAME']), 0, -10) . '-check/" title="Installation check">installation check script</a> to find out more. </div> </div>'; } else { // Includes the initialization script require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'init.inc.php'; // Checks if the Install module is loaded if (!Woops_Core_Module_Manager::getInstance()->isLoaded('Install')) { // Install module not loaded $CONTENT = '<div class="box-error"> <h4>Installation disabled</h4> <div class="message"> The WOOPS installation module is currently disabled.<br /> In order to access the installation script, please loads the "Install" module, either from the WOOPS module manager or by editing the WOOPS configuration file. </div> </div>'; } else { // Creates an instance of the install form $INSTALL_FORM = new Woops_Mod_Install_Form(); // Gets the install form content $CONTENT = (string) $INSTALL_FORM; } }
/** * Gets the unique class instance * * This method is used to get the unique instance of the class * (singleton). If no instance is available, it will create it. * * @return Woops_Core_Env_Getter The unique instance of the class * @see __construct */ public static function getInstance() { // Checks if the unique instance already exists if (!is_object(self::$_instance)) { // Creates the unique instance self::$_instance = new self(); // Gets the module manager instance self::$_instance->_modManager = Woops_Core_Module_Manager::getInstance(); } // Returns the unique instance return self::$_instance; }
/** * Sets the needed static variables * * @return void */ private static function _setStaticVars() { self::$_conf = Woops_Core_Config_Getter::getInstance(); self::$_modManager = Woops_Core_Module_Manager::getInstance(); self::$_request = Woops_Core_Request_Getter::getInstance(); self::$_env = Woops_Core_Env_Getter::getInstance(); self::$_str = Woops_String_Utils::getInstance(); self::$_moduleVariables = self::$_request->getWoopsVar('mod'); // Static variables are set self::$_hasStatic = true; }
<?php ################################################################################ # # # WOOPS - Web Object Oriented Programming System # # # # COPYRIGHT NOTICE # # # # Copyright (C) 2009 Jean-David Gadina - www.xs-labs.com # # All rights reserved # ################################################################################ # $Id$ Woops_Core_Module_Manager::getInstance()->registerBlockType('cms', 'Woops_Mod_Cms_Block'); Woops_Xhtml_Parser::registerProcessingInstructionHandler('woops-cms-block', 'Woops_Mod_Cms_Block_ProcessingInstruction_Handler'); Woops_Page_Engine::getInstance()->registerPageEngine('Woops_Mod_Cms_Page_Engine');