Advertisement
fruffl

Untitled

Mar 19th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.58 KB | None | 0 0
  1. <?PHP
  2.     NAMESPACE tri4m\Wp;
  3.     USE ILLI\Core\Std\Def\__const_Type;
  4.    
  5.     CLASS __config_Theme EXTENDS \ILLI\Core\Std\Def\ADVTuple
  6.     {
  7.         CONST slug      = 0x01;
  8.         CONST name      = 0x02;
  9.         CONST fullName      = 0x03;
  10.         CONST themeName     = 0x04;
  11.         CONST version       = 0x05;
  12.         CONST versionId     = 0x06;
  13.         CONST debug     = 0x07;
  14.         CONST themePath     = 0x08;
  15.         CONST themeUri      = 0x09;
  16.         CONST wpIncPath     = 0x0A;
  17.         CONST wpIncUri      = 0x0B;
  18.         CONST config        = 0x0C;
  19.        
  20.         public function __construct(array $__setup = [])
  21.         {
  22.             parent::__construct
  23.             (
  24.                 [
  25.                     self::slug      => __const_Type::SPL_STRING,
  26.                     self::name      => __const_Type::SPL_STRING,
  27.                     self::fullName      => __const_Type::SPL_STRING,
  28.                     self::themeName     => __const_Type::SPL_STRING,
  29.                     self::version       => __const_Type::SPL_LONG,
  30.                     self::versionId     => __const_Type::SPL_STRING,
  31.                     self::debug     => __const_Type::SPL_BOOLEAN,
  32.                     self::themePath     => __const_Type::SPL_STRING,
  33.                     self::themeUri      => __const_Type::SPL_DIRECTORY,
  34.                     self::wpIncPath     => __const_Type::SPL_STRING,
  35.                     self::wpIncUri      => __const_Type::SPL_DIRECTORY,
  36.                     self::config        => __const_Type::SPL_ARRAY
  37.                 ],
  38.                 $__setup
  39.             );
  40.         }
  41.     }
  42.  
  43. <?PHP
  44.     NAMESPACE tri4m\Wp;
  45.     USE tri4m\Wp\__config_Theme;
  46.     USE tri4m\Wp\Application;
  47.     USE tri4m\Wp\Hook;
  48.     USE tri4m\Wp\Trap;
  49.     USE ILLI\Core\Util\Inflector;
  50.     USE ILLI\Core\Util\String;
  51.    
  52.     CLASS Theme
  53.     {
  54.         protected static $__Setup       = NULL;
  55.         protected static $__Hook        = NULL;
  56.         protected static $__Application     = NULL;
  57.         protected static $__pathScheme      =
  58.         [
  59.             'root'      => '{:root}',
  60.             'core'      => '{:root}/core',
  61.             'coreLib'   => '{:root}/core/lib',
  62.             'coreJs'    => '{:root}/core/lib/js',
  63.             'coreCss'   => '{:root}/core/lib/css',
  64.             'coreImg'   => '{:root}/core/lib/img',
  65.             'coreIetf'  => '{:root}/core/lib/ietf',
  66.             'corePie'   => '{:root}/core/lib/pie',
  67.             'std'       => '{:root}/core/std',
  68.             'stdLib'    => '{:root}/core/std/lib',
  69.             'stdImg'    => '{:root}/core/std/lib/mg',
  70.             'wp'        => '{:wp}',
  71.             'wpJs'      => '{:wp}/js',
  72.             'wpCss'     => '{:wp}/css',
  73.         ];
  74.        
  75.         function __construct(__config_Theme $__Setup)
  76.         {
  77.             static::$__Setup    = $__Setup;
  78.             static::$__Application  = new Application;
  79.             static::$__Application->boot();
  80.         }
  81.        
  82.         static function __callStatic($__name, $__parameters)
  83.         {
  84.             $r = explode('_', $n = Inflector::underscore($__name));
  85.             switch($prefix = $r[0]):
  86.                 case 'slug':
  87.                     $__parameters += [NULL, '_'];
  88.                     list($__value, $__delimeter) = $__parameters;
  89.                    
  90.                     return NULL !== $__value
  91.                         ? is_array($__value)
  92.                             ? static::$__Setup->slug.$__delimeter.implode($__delimeter, $__value)
  93.                             : static::$__Setup->slug.$__delimeter.$__value
  94.                         : static::$__Setup->slug;
  95.                     break;
  96.                 case 'path':
  97.                 case 'uri':
  98.                     array_shift($r);
  99.                     $__parameters += [[]];
  100.                     list($__args) = $__parameters;
  101.                    
  102.                     return TRUE === isset(static::$__pathScheme[$r = lcfirst(Inflector::camelize(implode('_', $r)))])
  103.                         ? String::insert(static::$__pathScheme[$r], [
  104.                             'root'  => static::$__Setup->{'theme'.('uri' === $prefix ? 'Uri' : 'Path')},
  105.                             'wp'    => static::$__Setup->{'wpInc'.('uri' === $prefix ? 'Uri' : 'Path')}
  106.                             ]).(NULL !== $__args && [] !== $__args
  107.                             ? '/'.(TRUE === is_array($__args)
  108.                                 ? implode('/', array_map(function(&$n) { $n = trim($n, '/'); return $n; }, $__args))
  109.                                 : trim($__args, '/'))
  110.                             : NULL)
  111.                         : NULL;
  112.                     break;
  113.             endswitch;
  114.            
  115.             return FALSE === ('__Setup' === ($n = '__'.$__name))
  116.                 && (TRUE === isset(static::$$n) || TRUE === property_exists(__CLASS__, $n))
  117.                     ? static::$$n
  118.                     : static::$__Setup->$__name;
  119.         }
  120.     }
  121.  
  122. <?PHP
  123.     NAMESPACE tri4m\Wp;
  124.     USE ILLI\Core\Std\Invoke;
  125.     USE ILLI\Core\Util\Inflector;
  126.    
  127.     CLASS Inv
  128.     {
  129.         static function __callStatic($__name, array $__parameters = [])
  130.         {
  131.             return static::call($__name, $__parameters);
  132.         }
  133.        
  134.         static function call($__name, array $__parameters = [])
  135.         {
  136.             return function_exists($__name)
  137.                 ? Invoke::emitFunction($__name, $__parameters)
  138.                 : function_exists($__name = Inflector::underscore(Inflector::camelize($__name)))
  139.                     ? Invoke::emitFunction($__name, $__parameters)
  140.                     : NULL;
  141.         }
  142.        
  143.         static function glob($__name)
  144.         {
  145.             global $$__name;
  146.             return $$__name;
  147.         }
  148.     }
  149.  
  150. <?PHP
  151.     NAMESPACE tri4m\Wp;
  152.     USE ILLI\Core\Std\Invoke;
  153.     USE ILLI\Core\Util\String;
  154.    
  155.     CLASS Log
  156.     {
  157.         protected static $__log = [];
  158.        
  159.         static function add()
  160.         {
  161.             static::$__log[] = Invoke::emitStatic('ILLI\Core\Util\String', 'format', func_get_args());
  162.         }
  163.        
  164.         static function show()
  165.         {
  166.             return implode(PHP_EOL, static::$__log);
  167.         }
  168.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement