/** * Class constructor * * The class constructor is private to avoid multiple instances of the * class (singleton). * * @return void */ private function __construct() { // Gets the instance of the environment class $this->_env = Woops_Core_Env_Getter::getInstance(); // Gets the instance of the error handler class $this->_errorReporting = Woops_Core_Error_Handler::getInstance(); // Not sure ADODB is completely error free $this->_errorReporting->disableErrorReporting(E_NOTICE | E_STRICT); require_once $this->_env->getPath('woops-mod://Adodb/resources/php/adodb5/adodb.inc.php'); // Resets the error reporting $this->_errorReporting->resetErrorReporting(); // Creates a directory iterator to find the available drivers $iterator = new DirectoryIterator($this->_env->getPath('woops-mod://Adodb/resources/php/adodb5/drivers/')); // Process each file foreach ($iterator as $file) { // Checks if the file is an ADODB driver if (substr($file->getFileName(), -8) === '.inc.php') { // Gets the driver name $driver = substr($file->getFileName(), 6, -8); // Stores the driver $this->_drivers[$driver] = true; } } // Stores additionnal drivers $this->_drivers['ifx'] = true; $this->_drivers['maxsql'] = true; $this->_drivers['pgsql'] = true; }
/** * Class constructor * * @return void */ private function __construct() { $this->_conf = Woops_Core_Config_Getter::getInstance(); $this->_env = Woops_Core_Env_Getter::getInstance(); $this->_request = Woops_Core_Request_Getter::getInstance(); $this->_db = Woops_Database_Layer::getInstance()->getEngine(); $this->_str = Woops_String_Utils::getInstance(); $this->_pageId = $this->_getPageId(); $this->_langName = $this->_getLanguage(); $this->_page = $this->_getPage($this->_pageId, $this->_langName); $this->_template = $this->_getTemplate($this->_page->id_templates); }
/** * Creates the cached version of a class * * @param string The name of the class for which to build a cached version * @return void */ function createClassCache($className) { // The environment object static $env; // The configuration object static $conf; // The path to the cache directory for the PHP classes static $cacheDir; // Whether AOP is enabled static $aop; // Whether the PHP code must be optimized static $optimize; // Checks if we already have the environment object if (!is_object($env)) { // Gets the environment object $env = Woops_Core_Env_Getter::getInstance(); // Gets the configuration object $conf = Woops_Core_Config_Getter::getInstance(); // Sets the path to the cache directory $cacheDir = $env->getPath('cache/classes/'); // Gets the AOP state $aop = $conf->getVar('aop', 'enable'); // Gets the optimize state $optimize = $conf->getVar('classCache', 'optimize'); } // Checks if the cached version already exists if (file_exists($cacheDir . $className . '.class.php')) { // Nothing to do, the cached version already exists return; } // Checks if AOP is enabled, and if the class is not an interface if ($aop && substr($className, -9) !== 'Interface') { // Creates an AOP version of the class $aopBuilder = new Woops_Core_Aop_Class_Builder($className); // Gets the code of the AOP version $classCode = (string) $aopBuilder; } else { // Creates a reflection object $reflection = Woops_Core_Reflection_Class::getInstance($className); // Gets the PHP source code $classCode = file_get_contents($reflection->getFileName()); } // Checks if the source code must be optimized if ($optimize) { // Creates a source optimizer $optimizer = new Woops_Php_Source_Optimizer($classCode); // Gets the optimized source code $classCode = (string) $optimizer; } // Writes the class in the cache file_put_contents($cacheDir . $className . '.class.php', $classCode); }
/** * Sets the needed static variables * * @return void */ private static function _setStaticVars() { // Gets the instance of the WOOPS page getter self::$_pageGetter = Woops_Page_Getter::getInstance(); // Gets the instance of the environment object self::$_env = Woops_Core_Env_Getter::getInstance(); // Gets the instance of the configuration object self::$_conf = Woops_Core_Config_Getter::getInstance(); // Gets the instance of the string utilities self::$_str = Woops_String_Utils::getInstance(); // Static variables are set self::$_hasStatic = true; }
/** * Class constructor * * @return void */ private function __construct() { $this->_conf = Woops_Core_Config_Getter::getInstance(); $this->_env = Woops_Core_Env_Getter::getInstance(); $this->_registerModuleDirectory($this->_env->getSourcePath('modules/'), $this->_env->getSourceWebPath('modules/')); $this->_registerModuleDirectory($this->_env->getPath('modules/'), $this->_env->getWebPath('modules/')); $loadedModules = $this->_conf->getVar('modules', 'loaded'); if (is_array($loadedModules)) { foreach ($loadedModules as $moduleName) { if (!isset($this->_modules[$moduleName])) { throw new Woops_Core_Module_Manager_Exception('The module \'' . $moduleName . '\' does not exist', Woops_Core_Module_Manager_Exception::EXCEPTION_NO_MODULE); } $this->_loadedModules[$moduleName] = false; } foreach ($this->_loadedModules as $moduleName => $void) { $this->_loadModuleInfos($moduleName); } } }
/** * Class constructor * * The class constructor is private to avoid multiple instances of the * class (singleton). * * If an error occurs, meaning the configuration file is not available, * this method will simply prints the error message. * No trigger_error, nor exception, as this will result in an infinite * loop between the core classes. * * @return void */ private function __construct() { // Gets the instance of the environment object $this->_env = Woops_Core_Env_Getter::getInstance(); // Gets the path to the WOOPS configuration file $confFile = $this->_env->getPath('config/woops.ini.php'); // Checks if the file exists if (!$confFile) { // Gets the path to the default WOOPS configuration file $confFile = $this->_env->getSourcePath('config.ini.php'); } // Checks if the file exists if (!$confFile) { // Error - No configuration file self::_error('The WOOPS configuration file does not exist'); } // Checks if the file is readable if (!is_readable($confFile)) { // Error - The configuration file is not readable self::_error('The WOOPS configuration file is not readable'); } // Gets the configuration values from the file $this->_conf = parse_ini_file($confFile, true); }
################################################################################ # $Id$ // As we are building cached version of classes, we don't want the WOOPS class // manager to load classes from the cache, as this will result in an // infinite number of calls to this script, through a socket. define('WOOPS_CLASS_CACHE_MODE_OFF', true); // Includes the initialization script require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'init.inc.php'; // Gets incomming GET variables $GETVARS = Woops_Core_Request_Getter::getInstance()->classCache; // Checks the GET variables if ($GETVARS && isset($GETVARS['className'])) { // Name and path of the class to build $CLASSNAME = $GETVARS['className']; // Path to the cache directory $CACHEDIR = Woops_Core_Env_Getter::getInstance()->getPath('cache/classes/'); // Checks if the class caching is enabled (or the AOP), and checks the cache directory if (Woops_Core_Config_Getter::getInstance()->getVar('classCache', 'enable') || Woops_Core_Config_Getter::getInstance()->getVar('aop', 'enable') && $CACHEDIR && is_dir($CACHEDIR) && is_writeable($CACHEDIR) && !file_exists($CACHEDIR . $CLASSNAME)) { // We don't want any error here try { // Checks if AOP is enabled, and if the class is not an interface if (Woops_Core_Config_Getter::getInstance()->getVar('aop', 'enable') && substr($CLASSNAME, -9) !== 'Interface') { // Creates an AOP version of the class $AOP = new Woops_Core_Aop_Class_Builder($CLASSNAME); // Gets the code of the AOP version $CLASSCODE = (string) $AOP; } else { // Creates a reflection object for the class $REF = Woops_Core_Reflection_Class::getInstance($CLASSNAME); // Gets the PHP source code $CLASSCODE = file_get_contents($REF->getFileName());
/** * */ private static function _createDefaultInstance() { // Sets the name of the default instance self::$_defaultInstanceName = Woops_Core_Env_Getter::getInstance()->getSourcePath('lang/default/'); // Creates the default instance return self::$_instances[self::$_defaultInstanceName] = new self(self::$_defaultInstanceName); }
/** * Class constructor * * @return void */ public function __construct() { // Calls the parent constructor parent::__construct(); // Checks if the static variables are set if (!self::$_hasStatic) { // Sets the static variables self::_setStaticVars(); } // Creates an INI file parser with the default configuration file $this->_ini = new Woops_Ini_Parser(self::$_env->getSourcePath('config.ini.php')); // Gets the ini values $this->_iniValues = $this->_ini->getIniArray(); // Creates the base form tag $this->_content = new Woops_Xhtml_Tag('form'); $this->_content['action'] = Woops_Core_Env_Getter::getInstance()->getSourceWebPath('scripts/install/'); // Adds the form method // GET is used on IIS, as I've got a strange bug on my test VM. I'll need to check this out... $this->_content['method'] = self::$_env->PHP_SAPI_NAME === 'isapi' ? 'GET' : 'POST'; // Creates the container for the menu $menu = $this->_content->div; // Current installation step $step = $this->_getModuleVar('install-step'); switch ($step) { // Welcome case false: // Creates the welcome screen $this->_welcomeScreen(); break; // General configuration // General configuration case 1: // Install step 1 $this->_installStep1(); // Creates the menu $this->_createMenu($menu); break; // Database engine // Database engine case 2: // Steps before are completed $this->_step1 = true; // Install step 2 $this->_installStep2(); // Creates the menu $this->_createMenu($menu); break; // Database parameters // Database parameters case 3: // Steps before are completed $this->_step1 = true; $this->_step2 = true; $this->_installStep3(); // Creates the menu $this->_createMenu($menu); break; // Database parameters // Database parameters case 4: // Steps before are completed $this->_step1 = true; $this->_step2 = true; $this->_step3 = true; $this->_installStep4(); // Creates the menu $this->_createMenu($menu); break; } }
<?php // Includes the initialization script require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'init.inc.php'; // Creates a new SWF parser $SWF_PARSER = new Woops_Swf_Parser(Woops_Core_Env_Getter::getInstance()->getSourcePath('tests/amf/test.swf')); ?> <!-- $Id: index.php 658 2009-03-09 16:19:21Z macmade $ --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <!-- ################################################################################ # # # WOOPS - Web Object Oriented Programming System # # # # COPYRIGHT NOTICE # # # # Copyright (C) 2009 Jean-David Gadina - www.xs-labs.com # # All rights reserved # ################################################################################ --> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>WOOPS - Web Object Oriented Programming System</title> <link rel="schema.dc" href="http://purl.org/metadata/dublin_core_elements" />
################################################################################ # # # WOOPS - Web Object Oriented Programming System # # # # COPYRIGHT NOTICE # # # # Copyright (C) 2009 Jean-David Gadina - www.xs-labs.com # # All rights reserved # ################################################################################ # $Id$ // Includes the initialization script require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'init.inc.php'; // Plain text content header('Content-Type: text/plain'); // WOOPS environment object $ENV = Woops_Core_Env_Getter::getInstance(); // URL of the test file $URL = ($ENV->HTTPS ? 'https://' : 'http://') . $ENV->HTTP_HOST . $ENV->getSourceWebPath('tests/http-client/test.php'); // Creates an HTTP client $CLIENT = new Woops_Http_Client($URL); // Adds some POST data $CLIENT->addPostData('test', array('foo' => true, 'bar' => array('fooBar' => true))); // Uploads a file $CLIENT->addFile('someFile', $ENV->getPath('woops-mod://Cms/resources/templates/woops-default/lixado.png')); // Establish the connection $CLIENT->connect(); // Writes the HTTP response body print $CLIENT->getResponse()->getBody(); // Separator print chr(10) . '-----' . chr(10) . chr(10); // Prints the cookies from the response
/** * 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; }
/** * 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() { // Gets the instance of the number utilities self::$_env = Woops_Core_Env_Getter::getInstance(); // Static variables are set self::$_hasStatic = true; }
<?php // Includes the initialization script require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'init.inc.php'; // Creates a new GZIP parser $GZIP_PARSER = new Woops_Gzip_Parser(Woops_Core_Env_Getter::getInstance()->getSourcePath('tests/gzip/test.gz')); ?> <!-- $Id: index.php 658 2009-03-09 16:19:21Z macmade $ --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <!-- ################################################################################ # # # WOOPS - Web Object Oriented Programming System # # # # COPYRIGHT NOTICE # # # # Copyright (C) 2009 Jean-David Gadina - www.xs-labs.com # # All rights reserved # ################################################################################ --> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>WOOPS - Web Object Oriented Programming System</title> <link rel="schema.dc" href="http://purl.org/metadata/dublin_core_elements" />
/** * Sets the needed static variables * * @return void */ private static function _setStaticVars() { // Gets the instance of the string utilities self::$_str = Woops_String_Utils::getInstance(); // Gets the instance of the string utilities self::$_array = Woops_Array_Utils::getInstance(); // Gets the instance of the file types class self::$_fileTypes = Woops_File_Types::getInstance(); // Gets the instance of the environment object self::$_env = Woops_Core_Env_Getter::getInstance(); // Sets the newline character (CR-LF) self::$_CRLF = self::$_str->CR . self::$_str->LF; // Sets the boundary for multipart/form-data self::$_boundary = 'WOOPS-' . self::$_str->uniqueId(); // Static variables are set self::$_hasStatic = true; }
<?php // Includes the initialization script require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'init.inc.php'; // Creates a new FLV parser $FLV_PARSER = new Woops_Flv_Parser(Woops_Core_Env_Getter::getInstance()->getSourcePath('tests/flv/test.flv')); ?> <!-- $Id: index.php 658 2009-03-09 16:19:21Z macmade $ --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <!-- ################################################################################ # # # WOOPS - Web Object Oriented Programming System # # # # COPYRIGHT NOTICE # # # # Copyright (C) 2009 Jean-David Gadina - www.xs-labs.com # # All rights reserved # ################################################################################ --> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>WOOPS - Web Object Oriented Programming System</title> <link rel="schema.dc" href="http://purl.org/metadata/dublin_core_elements" />
<?php // Includes the initialization script require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'init.inc.php'; // Creates a new ZIP parser $ZIP_PARSER = new Woops_Zip_Parser(Woops_Core_Env_Getter::getInstance()->getSourcePath('tests/zip/test.zip')); ?> <!-- $Id: index.php 658 2009-03-09 16:19:21Z macmade $ --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <!-- ################################################################################ # # # WOOPS - Web Object Oriented Programming System # # # # COPYRIGHT NOTICE # # # # Copyright (C) 2009 Jean-David Gadina - www.xs-labs.com # # All rights reserved # ################################################################################ --> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>WOOPS - Web Object Oriented Programming System</title> <link rel="schema.dc" href="http://purl.org/metadata/dublin_core_elements" />
<?php // Includes the initialization script require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'init.inc.php'; // Creates a new TIFF parser $TIFF_PARSER = new Woops_Tiff_Parser(Woops_Core_Env_Getter::getInstance()->getSourcePath('tests/tiff/test.tif')); ?> <!-- $Id: index.php 658 2009-03-09 16:19:21Z macmade $ --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <!-- ################################################################################ # # # WOOPS - Web Object Oriented Programming System # # # # COPYRIGHT NOTICE # # # # Copyright (C) 2009 Jean-David Gadina - www.xs-labs.com # # All rights reserved # ################################################################################ --> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>WOOPS - Web Object Oriented Programming System</title> <link rel="schema.dc" href="http://purl.org/metadata/dublin_core_elements" />
/** * 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; }