Exemplo n.º 1
0
 /**
 	Initialize automatically the various components of the application
 	according to the configuration data.
 
 	@param $aConfig The configuration data for this application.
 */
 public function __construct($aConfig)
 {
     $this->aConfig = $aConfig;
     // Add path to autoload
     // - All path are separated by : like in PATH environment variable
     // - A // in the path means ROOT_PATH
     if (!empty($this->aConfig['app.autoload.path'])) {
         $aPath = explode(':', $this->aConfig['app.autoload.path']);
         foreach ($aPath as $s) {
             weeAutoload::addPath(str_replace('//', ROOT_PATH, $s));
         }
     }
     // Timezone settings
     if (!empty($this->aConfig['app.timezone'])) {
         date_default_timezone_set($this->aConfig['app.timezone']);
     }
     // Define the default error page from the configuration
     if (!empty($this->aConfig['app.error.default'])) {
         weeException::setErrorPage(str_replace('//', ROOT_PATH, $this->aConfig['app.error.default']));
     }
     // Force selected drivers to start
     $aStart = $this->cnfArray('start');
     foreach ($aStart as $sName => $b) {
         if (!empty($b)) {
             $this->__get($sName);
         }
     }
 }
Exemplo n.º 2
0
    	@param $sFilename The autoload cache filename.
    */
    public static function saveToCache($sFilename)
    {
        $sCache = '<?php self::$aPaths = ' . var_export(self::$aPaths, true) . '; self::$aPathsLoaded = ' . var_export(self::$aPathsLoaded, true) . ';';
        file_put_contents($sFilename, $sCache);
        chmod($sFilename, 0600);
    }
}
// Register autoload functions
ini_set('unserialize_callback_func', 'spl_autoload_call');
spl_autoload_register(array('weeAutoload', 'loadClass'));
if (function_exists('__autoload')) {
    spl_autoload_register('__autoload');
}
// Handle cache loading and saving
if (defined('WEE_AUTOLOAD_CACHE')) {
    if (defined('DEBUG') || defined('NO_CACHE')) {
        // Delete the cache file if it exists and DEBUG or NO_CACHE is enabled.
        // This eases the transition from one mode to another without having to clean-up files manually.
        if (is_file(WEE_AUTOLOAD_CACHE)) {
            unlink(WEE_AUTOLOAD_CACHE);
        }
    } else {
        if (is_readable(WEE_AUTOLOAD_CACHE)) {
            weeAutoload::loadFromCache(WEE_AUTOLOAD_CACHE);
        } else {
            register_shutdown_function(array('weeAutoload', 'saveToCache'), WEE_AUTOLOAD_CACHE);
        }
    }
}
Exemplo n.º 3
0
Arquivo: wee.php Projeto: extend/wee
	entities back to characters.

	@param	$sText	The text to decode.
	@return	string	The decoded text.
*/
function xmlspecialchars_decode($sText)
{
    return htmlspecialchars_decode(str_replace('&apos;', '&#039;', $sText), ENT_QUOTES);
}
// Core components
/**
	Interface for mappable objects.
	Mappable are objects that can be mapped to an array using the toArray method.
*/
interface Mappable
{
    public function toArray();
}
/**
	Interface for printable objects.
	Printable objects are objects that can be converted to string using the toString method.

	We have to use this instead of __toString since we can't throw any exception in __toString...
*/
interface Printable
{
    public function toString();
}
require WEE_PATH . 'weeAutoload' . CLASS_EXT;
weeAutoload::addPath(WEE_PATH);
require WEE_PATH . 'exceptions/weeException' . CLASS_EXT;
Exemplo n.º 4
0
<?php

weeAutoload::addPath(dirname(__FILE__) . '/classes.inc');
weeAutoload::loadClass('weeAutoload_test');
$this->isTrue(class_exists('weeAutoload_test', false), _WT('weeAutoload::loadClass failed to load the given class even though the current directory is in the autoload paths.'));