fruffl icon

Untitled

fruffl | 03/19/13 04:56:59 PM UTC | 0 ⭐ | 338 👁️ | Never ⏰ | []
PHP |

4.58 KB

|

None

|

0 👍

/

0 👎

<?PHP
    NAMESPACE tri4m\Wp;
    USE ILLI\Core\Std\Def\__const_Type;
    
    CLASS __config_Theme EXTENDS \ILLI\Core\Std\Def\ADVTuple
    {
        CONST slug      = 0x01;
        CONST name      = 0x02;
        CONST fullName      = 0x03;
        CONST themeName     = 0x04;
        CONST version       = 0x05;
        CONST versionId     = 0x06;
        CONST debug     = 0x07;
        CONST themePath     = 0x08;
        CONST themeUri      = 0x09;
        CONST wpIncPath     = 0x0A;
        CONST wpIncUri      = 0x0B;
        CONST config        = 0x0C;
        
        public function __construct(array $__setup = [])
        {
            parent::__construct
            (
                [
                    self::slug      => __const_Type::SPL_STRING,
                    self::name      => __const_Type::SPL_STRING,
                    self::fullName      => __const_Type::SPL_STRING,
                    self::themeName     => __const_Type::SPL_STRING,
                    self::version       => __const_Type::SPL_LONG,
                    self::versionId     => __const_Type::SPL_STRING,
                    self::debug     => __const_Type::SPL_BOOLEAN,
                    self::themePath     => __const_Type::SPL_STRING,
                    self::themeUri      => __const_Type::SPL_DIRECTORY,
                    self::wpIncPath     => __const_Type::SPL_STRING,
                    self::wpIncUri      => __const_Type::SPL_DIRECTORY,
                    self::config        => __const_Type::SPL_ARRAY
                ],
                $__setup
            );
        }
    }
 
<?PHP
    NAMESPACE tri4m\Wp;
    USE tri4m\Wp\__config_Theme;
    USE tri4m\Wp\Application;
    USE tri4m\Wp\Hook;
    USE tri4m\Wp\Trap;
    USE ILLI\Core\Util\Inflector;
    USE ILLI\Core\Util\String;
    
    CLASS Theme
    {
        protected static $__Setup       = NULL;
        protected static $__Hook        = NULL;
        protected static $__Application     = NULL;
        protected static $__pathScheme      =
        [
            'root'      => '{:root}',
            'core'      => '{:root}/core',
            'coreLib'   => '{:root}/core/lib',
            'coreJs'    => '{:root}/core/lib/js',
            'coreCss'   => '{:root}/core/lib/css',
            'coreImg'   => '{:root}/core/lib/img',
            'coreIetf'  => '{:root}/core/lib/ietf',
            'corePie'   => '{:root}/core/lib/pie',
            'std'       => '{:root}/core/std',
            'stdLib'    => '{:root}/core/std/lib',
            'stdImg'    => '{:root}/core/std/lib/mg',
            'wp'        => '{:wp}',
            'wpJs'      => '{:wp}/js',
            'wpCss'     => '{:wp}/css',
        ];
        
        function __construct(__config_Theme $__Setup)
        {
            static::$__Setup    = $__Setup;
            static::$__Application  = new Application;
            static::$__Application->boot();
        }
        
        static function __callStatic($__name, $__parameters)
        {
            $r = explode('_', $n = Inflector::underscore($__name));
            switch($prefix = $r[0]):
                case 'slug':
                    $__parameters += [NULL, '_'];
                    list($__value, $__delimeter) = $__parameters;
                    
                    return NULL !== $__value
                        ? is_array($__value)
                            ? static::$__Setup->slug.$__delimeter.implode($__delimeter, $__value)
                            : static::$__Setup->slug.$__delimeter.$__value
                        : static::$__Setup->slug;
                    break;
                case 'path':
                case 'uri':
                    array_shift($r);
                    $__parameters += [[]];
                    list($__args) = $__parameters;
                    
                    return TRUE === isset(static::$__pathScheme[$r = lcfirst(Inflector::camelize(implode('_', $r)))])
                        ? String::insert(static::$__pathScheme[$r], [
                            'root'  => static::$__Setup->{'theme'.('uri' === $prefix ? 'Uri' : 'Path')},
                            'wp'    => static::$__Setup->{'wpInc'.('uri' === $prefix ? 'Uri' : 'Path')}
                            ]).(NULL !== $__args && [] !== $__args
                            ? '/'.(TRUE === is_array($__args)
                                ? implode('/', array_map(function(&$n) { $n = trim($n, '/'); return $n; }, $__args))
                                : trim($__args, '/'))
                            : NULL)
                        : NULL;
                    break;
            endswitch;
            
            return FALSE === ('__Setup' === ($n = '__'.$__name))
                && (TRUE === isset(static::$$n) || TRUE === property_exists(__CLASS__, $n))
                    ? static::$$n
                    : static::$__Setup->$__name;
        }
    }
 
<?PHP
    NAMESPACE tri4m\Wp;
    USE ILLI\Core\Std\Invoke;
    USE ILLI\Core\Util\Inflector;
    
    CLASS Inv
    {
        static function __callStatic($__name, array $__parameters = [])
        {
            return static::call($__name, $__parameters);
        }
        
        static function call($__name, array $__parameters = [])
        {
            return function_exists($__name)
                ? Invoke::emitFunction($__name, $__parameters)
                : function_exists($__name = Inflector::underscore(Inflector::camelize($__name)))
                    ? Invoke::emitFunction($__name, $__parameters)
                    : NULL;
        }
        
        static function glob($__name)
        {
            global $$__name;
            return $$__name;
        }
    }
 
<?PHP
    NAMESPACE tri4m\Wp;
    USE ILLI\Core\Std\Invoke;
    USE ILLI\Core\Util\String;
    
    CLASS Log
    {
        protected static $__log = [];
        
        static function add()
        {
            static::$__log[] = Invoke::emitStatic('ILLI\Core\Util\String', 'format', func_get_args());
        }
        
        static function show()
        {
            return implode(PHP_EOL, static::$__log);
        }
    }

Comments