Plugin Directory

Changeset 2153564


Ignore:
Timestamp:
09/09/2019 01:04:23 PM (6 years ago)
Author:
hitcode
Message:

2.0.3

Location:
z-inventory-manager/trunk
Files:
10 added
4 deleted
85 edited

Legend:

Unmodified
Added
Removed
  • z-inventory-manager/trunk/hc4/app/events.php

    r2149267 r2153564  
    22interface HC4_App_Events_
    33{
    4 /* REGISTER TO LISTEN EVENT */
    5     public function listen( $eventName, $handler );
     4/* NOTIFY ABOUT EVENTS */
     5    public function filter( $eventName, $return, $args );
    66
    7 /* LET KNOW THAT EVENT OCCURS */
    8     public function publish( $eventName, $return = NULL, array $args = array() );
    9 
    10 /* MODIFY OUTPUT */
    11     public function filter( $eventName, $return, array $args );
    12     public function registerFilter( $eventName, $handler );
     7/* register listener */
     8    public function listen( $eventClassName, $listenerClassName );
    139}
    1410
     
    1713{
    1814    protected $listeners = array();
     15    protected $filters = array();
     16    protected $debug = FALSE;
    1917
    2018    public function __construct(
    2119        HC4_App_Factory $factory,
    22         HC4_App_Profiler $profiler,
     20        HC4_App_Profiler $profiler = NULL,
    2321        $debug = FALSE
    2422    )
    25     {}
     23    {
     24        $this->factory = $factory;
     25        $this->profiler = $profiler;
     26        $this->debug = $debug;
     27    }
    2628
    27     /* REGISTER TO LISTEN EVENT */
    28     public function listen( $eventName, $handler )
     29    public function listen( $eventClassName, $listenerClassName )
    2930    {
     31        // $constructorArgs = $this->factory->getArgs( $listenerClassName, '__construct' );
     32        // if( ! $constructorArgs ){
     33            // return $this;
     34        // }
     35        // $eventClassName = $constructorArgs[0]->getClass()->getName();
     36
     37        $eventClassName = strtolower( $eventClassName );
     38        $listenerClassName = strtolower( $listenerClassName );
     39
    3040        if( $this->debug ){
    31             $checkEventName = $eventName;
    32             if( 'filter:' == substr($checkEventName, 0, strlen('filter:')) ){
    33                 $checkEventName = substr($checkEventName, strlen('filter:'));
     41            if( ! $this->checkExists($eventClassName) ){
     42                echo __CLASS__ . ": event '$eventClassName' doesn't exist<br>";
     43                return $this;
    3444            }
    35 
    36             // check if event exists
    37             if( FALSE === strpos($checkEventName, '@') ){
    38                 if( ! class_exists($checkEventName) ){
    39                     echo __CLASS__ . ": event '$eventName' doesn't exist<br>";
    40                     return $this;
    41                 }
    42             }
    43             else {
    44                 list( $className, $methodName ) = explode( '@', $checkEventName );
    45                 if( ! method_exists($className, $methodName) ){
    46                     echo __CLASS__ . ": event '$eventName' doesn't exist<br>";
    47                     return $this;
    48                 }
    49             }
    50 
    51             // check handler
    52             if( is_string($handler) ){
    53                 $checkHandler = $handler;
    54                 if( 'filter:' == substr($checkHandler, 0, strlen('filter:')) ){
    55                     $checkHandler = substr($checkHandler, strlen('filter:'));
    56                 }
    57                 $checkHandler = trim( $checkHandler );
    58 
    59                 if( FALSE === strpos($checkHandler, '@') ){
    60                     $className = $checkHandler;
    61                     $methodName = '__invoke';
    62                 }
    63                 else {
    64                     list( $className, $methodName ) = explode( '@', $checkHandler );
    65                 }
    66 
    67                 if( ! method_exists($className, $methodName) ){
    68                     echo __CLASS__ . ": event handler '$checkHandler' doesn't exist<br>";
    69                     return $this;
    70                 }
     45            if( ! $this->checkExists($listenerClassName) ){
     46                echo __CLASS__ . ": event listener '$listenerClassName' doesn't exist<br>";
     47                return $this;
    7148            }
    7249        }
    7350
    74         if( ! isset($this->listeners[$eventName]) ){
    75             $this->listeners[$eventName] = array();
     51        if( ! isset($this->listeners[$eventClassName]) ){
     52            $this->listeners[$eventClassName] = array();
    7653        }
    77         $this->listeners[$eventName][] = $handler;
     54        $this->listeners[$eventClassName][$listenerClassName] = $listenerClassName;
    7855
    7956        return $this;
    8057    }
    8158
    82     /* REGISTER TO MODIFY THE EVENT OUTPUT */
    83     public function registerFilter( $eventName, $handler )
     59    public function filter( $eventName, $return, $args )
    8460    {
    85         $eventName = 'filter:' . $eventName;
    86         return $this->listen( $eventName, $handler );
    87     }
     61        $eventName = strtolower( $eventName );
    8862
    89     /* LET KNOW THAT EVENT OCCURS */
    90     public function publish( $eventName, $return = NULL, array $args = array() )
    91     {
    92         $eventName = str_replace( '::', '@', $eventName );
    93         $listeners = $this->getListeners( $eventName );
     63        $listeners = array();
    9464
    95         array_unshift( $args, $return );
    96         reset( $listeners );
    97         foreach( $listeners as $handler ){
    98             call_user_func_array( $handler, $args );
     65        if( isset($this->listeners['*']) ){
     66            $listeners = array_merge( $listeners, $this->listeners['*'] );
    9967        }
    10068
    101         if( $this->debug ){
    102             reset( $listeners );
    103             foreach( $listeners as $handler ){
    104                 $this->profiler->markEvent( $eventName, get_class($handler[0]) . '@' . $handler[1] );
    105             }
     69        if( isset($this->listeners[$eventName]) ){
     70            $listeners = array_merge( $listeners, $this->listeners[$eventName] );
    10671        }
    10772
    108         return $this;
    109     }
     73        foreach( $listeners as $listener ){
     74            if( $listener === $eventName ){
     75                continue;
     76            }
    11077
    111     /* MODIFY OUTPUT */
    112     public function filter( $eventName, $return, array $args )
    113     {
    114         $eventName = str_replace( '::', '@', $eventName );
    115         $eventName = 'filter:' . $eventName;
    116         $listeners = $this->getListeners( $eventName );
    117        
    118         if( ! $listeners ){
    119             return $return;
    120         }
     78            if( FALSE === strpos($listener, '@') ){
     79                $listener = $this->factory->make( $listener );
     80            }
     81            else {
     82                list( $listenerClassName, $listenerMethodName ) = explode( '@', $listener );
     83                $listener = $this->factory->make( $listenerClassName );
     84                $listener = array( $listener, $listenerMethodName );
     85            }
    12186
    122         reset( $listeners );
    123         foreach( $listeners as $handler ){
    124             $thisArgs = $args;
    125             array_unshift( $thisArgs, $return );
    126             $return = call_user_func_array( $handler, $thisArgs );
    127         }
    128 
    129         if( $this->debug ){
    130             reset( $listeners );
    131             foreach( $listeners as $handler ){
    132                 $this->profiler->markEvent( $eventName, get_class($handler[0]) . '@' . $handler[1] );
     87            $argsToListener = array_merge( array($eventName, $return), $args );
     88            $thisReturn = call_user_func_array( $listener, $argsToListener );
     89            if( NULL !== $thisReturn ){
     90                $return = $thisReturn;
    13391            }
    13492        }
     
    13795    }
    13896
    139     public function getListeners( $eventName )
     97    public function checkExists( $eventName )
    14098    {
    141         $return = array();
    142         if( ! isset($this->listeners[$eventName]) ){
     99        $return = TRUE;
     100
     101        if( '*' === $eventName ){
    143102            return $return;
    144103        }
    145         foreach( $this->listeners[$eventName] as $handler ){
    146             $handler = $this->_makeHandler( $handler );
    147             $return[] = $handler;
     104
     105        if( FALSE !== strpos($eventName, '@') ){
     106            list( $className, $methodName ) = explode( '@', $eventName );
    148107        }
     108        else {
     109            $className = $eventName;
     110            $methodName = NULL;
     111        }
     112
     113        if( ! (class_exists($className) OR interface_exists($className)) ){
     114            $return = FALSE;
     115            return $return;
     116        }
     117
     118        if( (NULL !== $methodName) && (! method_exists($className, $methodName)) ){
     119            $return = FALSE;
     120            return $return;
     121        }
     122
    149123        return $return;
    150124    }
    151 
    152     protected function _makeHandler( $handler )
    153     {
    154         if( is_string($handler) ){
    155             $handler = trim( $handler );
    156             list( $handler, $method ) = explode( '@', $handler );
    157             $handler = array( $handler, $method );
    158             if( ! is_object($handler[0]) ){
    159                 $handler[0] = $this->factory->make( $handler[0], __CLASS__ );
    160             }
    161         }
    162 
    163         return $handler;
    164     }
    165125}
  • z-inventory-manager/trunk/hc4/app/factory.php

    r2149267 r2153564  
    22class HC4_App_Factory
    33{
     4    protected $modules = array();
    45    protected $bind = array();
    5     protected $appModules = array();
    6     protected $profiler = NULL;
     6
     7    public $profiler = NULL;
     8    protected $events = NULL;
    79
    810    public function __construct(
    9         array $bind = array(),
    10         array $appModules = array()
     11        array $modules = array(),
     12        $profiler
    1113    )
    1214    {
     15        $bind = array();
    1316        $bind[ __CLASS__ ] = $this;
     17
     18        $this->profiler = $profiler;
     19        $bind[ 'hc4_app_profiler' ] = $this->profiler;
     20
     21    // find bind configurations in modules
     22        $this->modules = array();
     23        $ii = 0;
     24        foreach( $modules as $moduleName => $moduleConfig ){
     25            $this->modules[ $moduleName ] = $ii++;
     26            $moduleClassName = $moduleName . '_Boot';
     27            if( class_exists($moduleClassName) && method_exists($moduleClassName, 'bind') ){
     28                $thisBind = call_user_func( array($moduleClassName, 'bind'), $moduleConfig );
     29                $bind = array_merge( $bind, $thisBind );
     30            }
     31        }
     32
     33    // finalize bind
     34        $this->bind = array();
    1435
    1536        reset( $bind );
     
    1738            $k = strtolower( $k );
    1839            if( is_array($v) ){
    19                
    2040            }
    2141            elseif( ! is_object($v) ){
     
    2545        }
    2646
    27 if( 0 && defined('HC4_DEBUG') ){
    28     if( isset($this->bind['hc4_app_profiler']) && is_object($this->bind['hc4_app_profiler']) ){
    29         $this->profiler = $this->bind['hc4_app_profiler'];
    30     }
    31 }
    32 
    33         $ii = 0;
    34         foreach( $appModules as $m ){
    35             $this->appModules[ $m ] = $ii++;
    36         }
    37     }
    38 
    39     // public function bind( $k, $v )
    40     // {
    41         // $k = strtolower( $k );
    42         // if( ! is_object($v) ){
    43             // $v = strtolower( $v );
    44         // }
    45         // $this->bind[ $k ] = $v;
    46         // return $this;
    47     // }
     47        foreach( $modules['hc4_app'] as $k => $v ){
     48            if( is_array($v) ){
     49                foreach( $v as $k2 => $v2 ){
     50                    $bindK = 'hc4_app_' . $k . '->' . $k2;
     51                    $this->bind[ $bindK ] = $v2;
     52                }
     53            }
     54        }
     55    }
     56
     57    public function bind( $k, $v )
     58    {
     59        $k = strtolower( $k );
     60        if( ! is_object($v) ){
     61            $v = strtolower( $v );
     62        }
     63        $this->bind[ $k ] = $v;
     64        return $this;
     65    }
     66
    4867
    4968/**
     
    5170*
    5271* @param string $className      A class name to make object.
    53 * @param string $callingClassName       Who tries to make it.
    5472*
    5573* @return object
    5674*/
    57     public function make( $className, $callingClassName )
     75    public function make( $className, $wrap = TRUE )
    5876    {
    5977// if( $this->profiler ){
     
    6280        static $_reflections = array();
    6381
    64         if( __CLASS__ == $className ){
     82        $className = strtolower( trim($className) );
     83
     84        if( strtolower(__CLASS__) === $className ){
    6585            return $this;
    6686        }
    67 
    68         $className = strtolower( trim($className) );
    69         $callingClassName = strtolower( trim($callingClassName) );
    7087
    7188    // maybe scalar (as param name like Class_Name->param1)
     
    83100            $chain = $this->bind[$className];
    84101            while( $rexClassName = array_shift($chain) ){
    85                 $rex = $this->make( $rexClassName, $callingClassName );
     102                $rex = $this->make( $rexClassName, $wrap );
    86103                $this->bind[ $className ] = $rex;
    87104            }
    88105        }
    89106
     107    // ALREADY INSTANTIATED
    90108        if( is_object($this->bind[$className]) ){
    91             return $this->bind[$className];
    92         }
    93 
    94         $realClassName = $this->bind[$className];
    95         if( ! strlen($realClassName) ){
    96             return;
    97         }
     109            $return = $this->bind[$className];
     110        }
     111    // CONSTRUCT NEW
     112        else {
     113            $realClassName = $this->bind[$className];
     114            if( ! strlen($realClassName) ){
     115                return;
     116            }
    98117
    99118if( $this->profiler ){
    100     $this->profiler->markStart( __METHOD__ );
     119    $this->profiler->markFactoryStackStart( $realClassName );
    101120}
    102121
     122        // __construct
     123            $args = $this->_makeArgs( $realClassName, '__construct', FALSE );
     124            if( $args ){
     125                $class = new ReflectionClass( $realClassName );
     126                $return = $class->newInstanceArgs( $args );
     127
     128            //  automatically assign internal properties
     129                foreach( $args as $argName => $arg ){
     130                    if( property_exists($return, $argName) ){
     131                        continue;
     132                    }
     133                    $return->{$argName} = $arg;
     134                }
     135            }
     136            else {
     137                $return = new $realClassName;
     138            }
     139
     140        // _import
     141            $importMethod = '_import';
     142            if( method_exists($return, $importMethod) ){
     143                $args = $this->_makeArgs( $realClassName, $importMethod, TRUE );
     144
     145                foreach( $args as $argName => $arg ){
     146                    if( property_exists($return, $argName) ){
     147                        continue;
     148                    }
     149                    $return->{$argName} = $arg;
     150                }
     151
     152                // call_user_func_array( array($return, $importMethod), $args );
     153            }
     154
    103155if( $this->profiler ){
    104     $this->profiler->markFactory( $realClassName );
     156    $this->profiler->markFactoryStackEnd();
    105157}
    106 
    107     // __construct
    108         $args = $this->makeArgs( $realClassName, '__construct', $callingClassName );
    109         if( $args ){
    110 // echo "JO '$realClassName'<br>";
    111             $class = new ReflectionClass( $realClassName );
    112             $return = $class->newInstanceArgs( $args );
    113 
    114             // $constructor = $class->getConstructor();
    115             // $constructor->setAccessible( TRUE );
    116             // $return = $class->newInstanceWithoutConstructor();
    117             // $constructor->invokeArgs( $return, $args );
    118 
    119         /*
    120             automatically assign internal properties like
    121             $this->varName1 = $hooks->wrap( $varName1 );
    122         */
    123             foreach( $args as $argName => $arg ){
    124                 if( property_exists($return, $argName) ){
    125                     continue;
    126                 }
     158        }
     159
     160        $this->bind[$className] = $return;
     161
     162        if( $wrap ){
     163            $importMethod = '_import';
     164            $wrapperArgs = $this->_makeArgs( 'HC4_App_Factory_Wrapper', $importMethod, FALSE );
     165
     166            $return = new HC4_App_Factory_Wrapper( $return );
     167            foreach( $wrapperArgs as $argName => $arg ){
    127168                $return->{$argName} = $arg;
    128169            }
    129170        }
    130         else {
    131             $return = new $realClassName;
    132         }
    133 
    134     // _init
    135         if( method_exists($return, '_init') ){
    136             $args = $this->makeArgs( $realClassName, '_init', $callingClassName );
    137             call_user_func_array( array($return, '_init'), $args );
    138             foreach( $args as $argName => $arg ){
    139                 if( property_exists($return, $argName) ){
    140                     continue;
    141                 }
    142                 $return->{$argName} = $arg;
    143             }
    144         }
    145 
    146         $this->bind[$className] = $return;
    147 if( $this->profiler ){
    148     $this->profiler->markEnd( __METHOD__ );
    149 }
     171
    150172        return $return;
    151173    }
     
    177199    }
    178200
    179     public function makeArgs( $className, $methodName, $callingClassName )
    180     {
     201    protected function _makeArgs( $className, $methodName, $wrap = TRUE )
     202    {
     203        static $cache = array();
     204
     205        $className = strtolower( $className );
     206        // $methodName = strtolower( $methodName );
     207
     208        $cacheKey = $className . '::' . $methodName;
     209        if( isset($cache[$cacheKey]) ){
     210            return $cache[$cacheKey];
     211        }
     212
    181213        $return = array();
    182214
    183         $className = strtolower( $className );
    184215        $needArgs = $this->getArgs( $className, $methodName );
    185216
     
    202233
    203234                // CHECK CIRCULAR REFERENCE
    204                     if( $needArgClassName === $callingClassName ){
    205                         echo __CLASS__ . ': circular reference<br>' . $callingClassName . ' -> ' . $className . ' -> ' . $needArgClassName . '<br>';
     235                    if( $needArgClassName === $className ){
     236                        echo __CLASS__ . ': circular reference<br>' . $needArgClassName . ' -> ' . $className . ' -> ' . $needArgClassName . '<br>';
    206237                        exit;
    207238                    }
     
    214245                    }
    215246
    216                     $arg = $this->make( $needArgClassName, $className );
     247                    $arg = $this->make( $needArgClassName, $wrap );
    217248                    $argCreated = TRUE;
    218249                }
     
    221252                    $makeName = $className . '->' . $needArgName;
    222253
    223                     $arg = $this->make( $makeName, $className );
     254                    $arg = $this->make( $makeName, $wrap );
    224255                    if( NULL !== $arg ){
    225256                        $argCreated = TRUE;
     
    250281// }
    251282
     283// echo "SET CACHE FOR '$cacheKey'<br>";
     284        $cache[$cacheKey] = $return;
     285
    252286        return $return;
    253287    }
     
    268302
    269303        if( ($parentModuleIndex < 0) OR ($childModuleIndex < 0) ){
    270             reset( $this->appModules );
    271             foreach( $this->appModules as $moduleName => $jj ){
     304            reset( $this->modules );
     305            foreach( $this->modules as $moduleName => $jj ){
    272306                if( $parentModuleIndex < 0 ){
    273307                    if( substr($parentClassName, 0, strlen($moduleName) + 1 ) == $moduleName . '_' ){
     
    293327        if( $parentModuleIndex == -1 ){
    294328            echo __CLASS__ . ': module is unknown for ' . $parentClassName . '<br>';
    295             _print_r( $this->appModules );
     329            _print_r( $this->modules );
    296330            exit;
    297331        }
     
    299333        if( $childModuleIndex == -1 ){
    300334            echo __CLASS__ . ': module is unknown for ' . $childClassName . '<br>';
    301             _print_r( $this->appModules );
     335            _print_r( $this->modules );
    302336            exit;
    303337        }
    304338
    305339// echo "$parentClassName:$parentModuleIndex VS $childClassName:$childModuleIndex<br>";
    306 // _print_r( $this->appModules );
     340// _print_r( $this->modules );
    307341
    308342        $return = ( $parentModuleIndex >= $childModuleIndex );
     
    310344        if( ! $return ){
    311345// echo "$parentClassName:$parentModuleIndex VS $childClassName:$childModuleIndex<br>";
    312 // _print_r( $this->appModules );
     346// _print_r( $this->modules );
    313347        }
    314348
  • z-inventory-manager/trunk/hc4/app/index.php

    r2149267 r2153564  
    1111class HC4_App_Index
    1212{
    13     public $profiler = NULL;
    1413    protected $logFile = NULL;
    1514
     
    1716    protected $factory = NULL;
    1817    protected $myConfig = array();
     18    protected $profiler = NULL;
     19
     20    protected $router = NULL;
     21    protected $slugCheck = NULL;
    1922
    2023/**
    2124*   $modulesConfig
    2225*       ['hc4_app']
    23 *           ['debug_post']      boolean
    24 *           ['debug_events']    boolean
     26*           ['debug_post']          boolean
     27*           ['events']['debug'] boolean
     28*           ['profiler']            boolean
    2529*
    2630*   @param array $config
     
    3034    public function __construct( array $modulesConfig )
    3135    {
     36        if( isset($modulesConfig['hc4_app']) ){
     37            $this->myConfig = $modulesConfig['hc4_app'];
     38        }
     39
     40        if(
     41            ( isset($this->myConfig['profiler']) && $this->myConfig['profiler'] ) OR
     42            ( array_key_exists('hcprofiler', $_GET) && $_GET['hcprofiler'] )
     43            ){
     44                $this->profiler = new HC4_App_Profiler;
     45            }
     46
     47if( $this->profiler ){
     48    $this->profiler->markFactoryStackStart( __CLASS__ );
     49}
     50
    3251        $finalModules = array();
    3352    // if submodule, also include parent module(s)
     
    4564        }
    4665        $this->modules = $finalModules;
    47 
    48         if( isset($this->modules['hc4_app']) ){
    49             $this->myConfig = $this->modules['hc4_app'];
    50         }
    5166    }
    5267
    5368    public function boot()
    5469    {
    55         $bind = array();
    56         $bind[ get_class($this) ] = $this;
    57 
    58         $profiler = new HC4_App_Profiler;
    59         $this->profiler = $profiler;
    60         $bind[ get_class($profiler) ] = $profiler;
    61 
    62     // init bind
    63 $this->profiler->markStart('before_handle_bind');
    64         reset( $this->modules );
    65         foreach( $this->modules as $moduleName => $moduleConfig ){
    66             $moduleClassName = $moduleName . '_Boot';
    67             if( class_exists($moduleClassName) && method_exists($moduleClassName, 'bind') ){
    68                 $thisBind = call_user_func( array($moduleClassName, 'bind'), $moduleConfig );
    69                 $bind = array_merge( $bind, $thisBind );
    70             }
    71         }
    72 $this->profiler->markEnd('before_handle_bind');
    73 
    74         if( isset($this->myConfig['debug_events']) ){
    75             $bind['HC4_App_Events->debug'] = $this->myConfig['debug_events'];
    76         }
    77         $this->factory = array( new HC4_App_Factory($bind, array_keys($this->modules)), 'make' );
    78 
    79 $this->profiler->markStart('before_handle_boot');
     70if( $this->profiler ){
     71    $this->profiler->markFactoryStackStart( __CLASS__ . '@' . __FUNCTION__ );
     72}
     73    // init factory
     74        $this->factory = new HC4_App_Factory( $this->modules, $this->profiler );
     75
    8076        reset( $this->modules );
    8177        foreach( array_keys($this->modules) as $moduleName ){
    8278            if( 'hc4_' == substr($moduleName, 0, strlen('hc4_')) ){
    83                 continue;
     79                // continue;
    8480            }
    8581
    8682            $moduleClassName = $moduleName . '_Boot';
    8783            if( class_exists($moduleClassName) ){
    88                 $module = call_user_func( $this->factory, $moduleClassName, __CLASS__ );
     84                $moduleBoot = $this->factory->make( $moduleClassName );
     85                call_user_func( $moduleBoot );
    8986            }
    9087        }
     
    9289    // MIGRATIONS
    9390        if( isset($this->modules['hc4_migration']) ){
    94             $migration = call_user_func( $this->factory, 'HC4_Migration_Interface', __CLASS__ );
     91            $migration = $this->factory->make( 'HC4_Migration_Interface' );
    9592            $migration->up();
    9693        }
    9794
    98 $this->profiler->markEnd('before_handle_boot');
    99     }
    100 
    101     public function factory( $className )
    102     {
    103         return call_user_func( $this->factory, $className, __CLASS__ );
    104     }
    105 
    106     public function log( array $log = array() )
    107     {
    108         if( ! $this->logFile ){
    109             return;
    110         }
    111 
    112         if( ! $log ){
    113             return;
    114         }
    115 
    116         $now = date( 'j M Y g:ia', time() );
    117         array_unshift( $log, $now );
    118 
    119         $out = join( "\t", $log );
    120 
    121         $fp = fopen( $this->logFile, 'a' );
    122         fwrite( $fp, $out . "\n" );
    123         fclose( $fp );
    124 
    125         return $this;
     95        $this->slugCheck = $this->factory->make( 'HC4_App_SlugCheck' );
     96        $this->router = $this->factory->make( 'HC4_App_Router' );
     97
     98if( $this->profiler ){
     99    $this->profiler->markFactoryStackEnd();
     100}
    126101    }
    127102
    128103    public function handleRequest( $defaultSlug = NULL )
    129104    {
     105// if( $this->profiler ){
     106    // $this->profiler->markFactoryStackStart( __CLASS__ . '@' . __FUNCTION__ );
     107// }
    130108        $uri = new HC4_App_Uri();
    131109        $slug = $uri->getSlug();
     
    137115        $requestMethod = $request->getMethod();
    138116
     117        $findSlug = $slug;
    139118        $isAjax = $request->isAjax();
    140119        if( ':ajax' == substr($slug, -strlen(':ajax')) ){
    141120            $isAjax = TRUE;
     121            $findSlug = substr($slug, 0, -strlen(':ajax'));
    142122        }
    143123
     
    148128
    149129    // LOG
    150         if( $this->logFile ){
    151             $out = array();
    152             $out[] = $request->getIpAddress();
    153             $out[] = $requestMethod;
    154             $out[] = $slug;
    155             if( $postData ){
    156                 $out[] = http_build_query( $postData );
    157             }
    158 
    159             $this->log( $out );
    160         }
    161 
    162         if( isset($this->modules['hc4_session']) ){
    163             $session = call_user_func( $this->factory, 'HC4_Session_Interface', __CLASS__ );
    164         }
    165 
    166     // ACL CHECK
    167         $checkResult = $this->check( $requestMethod, $slug );
    168         if( is_array($checkResult) ){
    169             $return = $checkResult;
    170             // return $return;
    171         }
    172         elseif( FALSE === $checkResult ){
    173             $to = 'notallowed';
    174             $return = array( $to, NULL );
    175             // return $return;
    176         }
    177         else {
    178             $return = $this->handle( $requestMethod, $slug, $postData );
     130        $this->logRequest( $request, $slug );
     131
     132        $result = NULL;
     133
     134        $result = $this->handle( $requestMethod, $slug, $postData );
     135        $result = $this->_processResult( $result, $postData, $isAjax );
     136
     137        if( $this->profiler ){
     138            $this->profiler->markEnd( 'handle' );
     139            $result = $this->profiler->render( $result );
     140            // $return = $this->profiler->run();
     141        }
     142
     143        return $result;
     144    }
     145
     146    public function factory( $className )
     147    {
     148        return $this->factory->make( $className );
     149    }
     150
     151    public function handle( $requestMethod, $slug, $postData = NULL )
     152    {
     153if( $this->profiler ){
     154    $this->profiler->markFactoryStackStart( __CLASS__ . '@' . __FUNCTION__ );
     155}
     156        $return = NULL;
     157
     158        $return = call_user_func( $this->slugCheck, $requestMethod, $slug, $postData );
     159        if( FALSE === $return ){
     160            $return = FALSE;
     161            return $return;
     162        }
     163
     164        $handlers = $this->router->find( $requestMethod, $slug );
     165
     166        if( ! $handlers ){
     167            $return = "NOTHING TO HANDLE THIS REQUEST: '$requestMethod:$slug'<br>";
     168if( $this->profiler ){
     169    $this->profiler->markFactoryStackEnd();
     170}
     171            return $return;
     172        }
     173
     174        foreach( $handlers as $h ){
     175            list( $handler, $args ) = $h;
     176
     177        // ADD POST TO ARGUMENTS
     178            if( NULL !== $postData ){
     179                array_unshift( $args, $postData );
     180            }
     181        // ADD SLUG TO ARGUMENTS
     182            array_unshift( $args, $slug );
     183
     184            $handler = trim( $handler );
     185            $method = NULL;
     186
     187            if( FALSE !== strpos($handler, '@') ){
     188                list( $handler, $method ) = explode( '@', $handler );
     189            }
     190            $handler = $this->factory->make( $handler );
     191            if( NULL !== $method ){
     192                $handler = array( $handler, $method );
     193            }
     194
     195        // HANDLE
     196            try {
     197                $return = call_user_func_array( $handler, $args );
     198            }
     199            catch( HC4_App_Exception_DataError $e ){
     200                if( isset($this->modules['hc4_session']) ){
     201                    $session = $this->factory->make( 'HC4_Session_Interface' );
     202                    $error = $e->getMessage();
     203                    $session->setFlashdata( 'error', $error );
     204                    $session->setFlashdata( 'post', $postData );
     205                }
     206                $return = array( $slug, NULL, $error );
     207            }
     208            catch( HC4_App_Exception_FormErrors $e ){
     209                if( isset($this->modules['hc4_session']) ){
     210                    $session = $this->factory->make( 'HC4_Session_Interface' );
     211                    $session->setFlashdata( 'form_errors', $e->getErrors() );
     212                    $session->setFlashdata( 'post', $postData );
     213                }
     214                $return = array( $slug, NULL );
     215            }
     216
     217            if( NULL !== $return ){
     218                break;
     219            }
     220        }
     221
     222if( $this->profiler ){
     223    $this->profiler->markFactoryStackEnd();
     224}
     225
     226        return $return;
     227    }
     228
     229    protected function _processResult( $result, $postData, $isAjax )
     230    {
     231    // AUTH CHECK FAILED
     232        if( FALSE === $result ){
     233            $result = array( 'notallowed', NULL );
    179234        }
    180235
    181236    // IF STRING THEN SHOW IT
    182         if( ! is_array($return) ){
     237        if( ! is_array($result) ){
    183238            $this->close();
    184             return $return;
     239            return $result;
    185240        }
    186241
    187242    // REDIRECT OR HEADER STATUS
    188         $to = array_shift( $return );
    189         $msg = array_shift( $return );
    190         $error = array_shift( $return );
    191 
    192     // HEADER STATUS
     243        $to = array_shift( $result );
     244        $msg = array_shift( $result);
     245        $error = array_shift( $result );
     246
     247    // HEADER WITH HTTP STATUS
    193248        if( is_numeric($to) ){
    194249            $out = array();
     
    210265        }
    211266
     267    // SET ERRORS IN SESSION
    212268        if( isset($this->modules['hc4_session']) ){
    213             $session = call_user_func( $this->factory, 'HC4_Session_Interface', __CLASS__ );
    214             if( $session ){
    215                 if( $error ){
    216                     $session->setFlashdata( 'error', $error );
    217                     $session->setFlashdata( 'post', $postData );
    218                 }
    219                 if( $msg ){
    220                     $session->setFlashdata( 'message', $msg );
    221                 }
    222             }
     269            $session = $this->factory->make( 'HC4_Session_Interface' );
     270            if( $error ){
     271                $session->setFlashdata( 'error', $error );
     272                $session->setFlashdata( 'post', $postData );
     273            }
     274            if( $msg ){
     275                $session->setFlashdata( 'message', $msg );
     276            }
     277        }
     278
     279    // IF GET THEN SHOW THE NEW TARGET
     280        if( NULL === $postData ){
     281            return $this->handle( 'get', $to );
    223282        }
    224283
    225284    // IF POST THEN REDIRECT
    226         if( NULL !== $postData ){
    227         // CLOSING
    228             $this->close();
    229 
    230             $uri = new HC4_App_Uri();
    231 
    232             if( '-referrer-' == $to ){
    233                 $to = $slug;
    234                 $to = $uri->makeUrl( $to );
    235 
    236                 if( isset($postData['hcs']) ){
    237                     $to .= ( FALSE === strpos($to, '?') ) ? '?' : '&';
    238                     // $myAppShortName = isset( $this->appConfig['app-short-name'] ) ? $this->appConfig['app-short-name'] : 'hc4';
    239                     // $to .= 'hcs=' . $myAppShortName;
    240                     $to .= 'hcs=' . $postData['hcs'];
    241                 }
    242             }
    243             else {
    244                 $to = $uri->makeUrl( $to );
    245             }
    246 
    247             $out = array( 'to' => $to );
    248 
    249             if( isset($this->myConfig['debug_post']) && $this->myConfig['debug_post'] && (! $isAjax) ){
    250                 $return = 'DEBUG POST<br>';
    251                 $return .= '<a href="' . $to . '">' . $to . '</a>';
    252                 $screen = call_user_func( $this->factory, 'HC4_Html_Screen_Interface', __CLASS__ );
    253                 $return = $screen->render( 'debug', $return );
    254                 return $return;
    255             }
    256             else {
    257                 if( $isAjax ){
    258                     $redirect = call_user_func( $this->factory, 'HC4_Redirect_Ajax', __CLASS__ );
    259                 } else {
    260                     $redirect = call_user_func( $this->factory, 'HC4_Redirect_Interface', __CLASS__ );
    261                 }
    262                 $redirect->call( $to );
    263             }
     285        $this->close();
     286
     287        $uri = new HC4_App_Uri();
     288        $to = $uri->makeUrl( $to );
     289
     290        if( isset($this->myConfig['debug_post']) && $this->myConfig['debug_post'] && (! $isAjax) ){
     291            $return = 'DEBUG POST<br>';
     292            $return .= '<a href="' . $to . '">' . $to . '</a>';
     293            $screen = $this->factory->make( 'HC4_Html_Screen_Interface' );
     294            $return = call_user_func( $screen, 'debug', $return );
     295            return $return;
     296        }
     297        else {
     298            $redirectClass = $isAjax ? 'HC4_Redirect_Ajax' : 'HC4_Redirect_Interface';
     299            $redirect = $this->factory->make( $redirectClass );
     300            call_user_func( $redirect, $to );
    264301            exit;
    265302        }
    266     /* IF GET THEN JUST SHOW THE TARGET */
    267         else {
    268             return $this->handle( 'get', $to );
    269 
    270             $to = $uri->makeUrl( $to );
    271             if( isset($this->myConfig['debug_post']) && $this->myConfig['debug_post'] && (! $isAjax) ){
    272                 $return = 'DEBUG REDIRECT<br>';
    273                 $return .= '<a href="' . $to . '">' . $to . '</a>';
    274                 $screen = call_user_func( $this->factory, 'HC4_Html_Screen_Interface', __CLASS__ );
    275                 $return = $screen->render( 'debug', $return );
    276                 return $return;
    277             }
    278             else {
    279                 if( $isAjax ){
    280                     $redirect = call_user_func( $this->factory, 'HC4_Redirect_Ajax', __CLASS__ );
    281                 } else {
    282                     $redirect = call_user_func( $this->factory, 'HC4_Redirect_Interface', __CLASS__ );
    283                 }
    284                 $redirect->call( $to );
    285             }
    286             exit;
    287         }
    288 
    289         return $return;
    290     }
    291 
    292     public function check( $method, $slug )
    293     {
     303    }
     304
     305    public function check( $method, $slug, $postData = NULL )
     306    {
     307if( $this->profiler ){
     308    $this->profiler->markFactoryStackStart( __CLASS__ . '@' . __FUNCTION__ );
     309}
    294310        $return = TRUE;
    295311
    296         if( ':ajax' == substr($slug, -strlen(':ajax')) ){
    297             $slug = substr($slug, 0, -strlen(':ajax'));
    298         }
    299 
    300         $router = call_user_func( $this->factory, 'HC4_App_Router', __CLASS__ );
    301312        $method = 'CHECK:' . $method;
    302         $checkers = $router->find( $method, $slug );
    303 
    304 // _print_r( $checkers );
    305 // return $return;
    306         if( ! $checkers ){
    307             return $return;
    308         }
    309 
    310         foreach( $checkers as $h ){
    311             list( $checker, $args ) = $h;
    312 
    313             if( is_bool($checker) ){
    314                 $return = $checker;
    315                 break;
    316             }
    317 
    318         // ADD SLUG TO ARGUMENTS
    319             array_unshift( $args, $slug );
    320 
    321             $checker = trim( $checker );
    322             if( FALSE === strpos($checker, '@') ){
    323                 $method = 'call';
    324             }
    325             else {
    326                 list( $checker, $method ) = explode( '@', $checker );
    327             }
    328             $checker = array( $checker, $method );
    329 
    330             if( ! is_object($checker[0]) ){
    331                 $checker[0] = call_user_func( $this->factory, $checker[0], __CLASS__ );
    332             }
    333 
    334         // HANDLE
    335             try {
    336                 $return = call_user_func_array( $checker, $args );
    337             }
    338             catch( HC4_App_Exception_DataError $e ){
    339                 if( $session ){
    340                     $error = $e->getMessage();
    341                     $session->setFlashdata( 'error', $error );
    342                     $session->setFlashdata( 'post', $postData );
    343                 }
    344                 $return = array( '-referrer-', NULL, $error );
    345                 break;
    346             }
    347 
    348             if( NULL !== $return ){
    349                 break;
    350             }
    351         }
    352 
    353         if( NULL === $return ){
    354             $return = TRUE;
    355         }
    356 
    357         return $return;
    358     }
    359 
    360     public function handle( $method, $slug, $postData = NULL )
    361     {
    362         $return = NULL;
    363 
    364         $router = call_user_func( $this->factory, 'HC4_App_Router', __CLASS__ );
    365 
    366         $findSlug = $slug;
    367         if( ':ajax' == substr($slug, -strlen(':ajax')) ){
    368             $findSlug = substr($slug, 0, -strlen(':ajax'));
    369         }
    370 
    371         $handlers = $router->find( $method, $findSlug, 1 );
    372 // _print_r( $handlers );
    373 // exit;
    374 
    375         if( ! $handlers ){
    376             $return = "NOTHING TO HANDLE THIS REQUEST: '$method:$slug'<br>";
    377             // echo $return;
    378             // exit;
    379             return $return;
    380         }
    381 
    382 $this->profiler->markStart('handle');
     313        $handlers = $this->router->find( $method, $slug );
     314
    383315        foreach( $handlers as $h ){
    384316            list( $handler, $args ) = $h;
    385 $this->profiler->markHandler( $handler );
    386317
    387318        // ADD POST TO ARGUMENTS
     
    393324
    394325            $handler = trim( $handler );
    395             if( FALSE === strpos($handler, '@') ){
    396                 $method = 'call';
    397             }
    398             else {
     326            $method = NULL;
     327
     328            if( FALSE !== strpos($handler, '@') ){
    399329                list( $handler, $method ) = explode( '@', $handler );
    400330            }
    401             $handler = array( $handler, $method );
    402 
    403             if( ! is_object($handler[0]) ){
    404                 $handler[0] = call_user_func( $this->factory, $handler[0], __CLASS__ );
     331            $handler = $this->factory->make( $handler );
     332            if( NULL !== $method ){
     333                $handler = array( $handler, $method );
    405334            }
    406335
    407336        // HANDLE
    408             try {
    409                 $return = call_user_func_array( $handler, $args );
    410             }
    411             catch( HC4_App_Exception_DataError $e ){
    412                 if( isset($this->modules['hc4_session']) ){
    413                     $session = call_user_func( $this->factory, 'HC4_Session_Interface', __CLASS__ );
    414                     $error = $e->getMessage();
    415                     $session->setFlashdata( 'error', $error );
    416                     $session->setFlashdata( 'post', $postData );
    417                 }
    418                 $return = array( '-referrer-', NULL, $error );
    419                 break;
    420             }
    421             catch( HC4_App_Exception_FormErrors $e ){
    422                 if( isset($this->modules['hc4_session']) ){
    423                     $session = call_user_func( $this->factory, 'HC4_Session_Interface', __CLASS__ );
    424                     $session->setFlashdata( 'form_errors', $e->getErrors() );
    425                     $session->setFlashdata( 'post', $postData );
    426                 }
    427                 $return = array( '-referrer-', NULL );
    428                 break;
    429             }
    430 
     337            $return = call_user_func_array( $handler, $args );
    431338            if( NULL !== $return ){
    432339                break;
    433340            }
    434341        }
     342
     343if( $this->profiler ){
     344    $this->profiler->markFactoryStackEnd();
     345}
    435346
    436347        return $return;
     
    443354            $moduleClassName = $moduleName . '_Close';
    444355            if( class_exists($moduleClassName) ){
    445                 $module = call_user_func( $this->factory, $moduleClassName, __CLASS__ );
     356                $module = $this->factory->make( $moduleClassName );
    446357            }
    447358        }
    448359        return $this;
    449360    }
    450 }
     361
     362    public function logRequest( $request, $slug )
     363    {
     364        if( ! $this->logFile ){
     365            return;
     366        }
     367
     368        $out = array();
     369        $out[] = $request->getIpAddress();
     370        $out[] = $request->getMethod();
     371        $out[] = $slug;
     372
     373        $postData = $request->getPost();
     374        if( $postData ){
     375            $out[] = http_build_query( $postData );
     376        }
     377
     378        $this->log( $out );
     379        return $this;
     380    }
     381
     382    public function log( array $log = array() )
     383    {
     384        if( ! $this->logFile ){
     385            return;
     386        }
     387
     388        if( ! $log ){
     389            return;
     390        }
     391
     392        $now = date( 'j M Y g:ia', time() );
     393        array_unshift( $log, $now );
     394
     395        $out = join( "\t", $log );
     396
     397        $fp = fopen( $this->logFile, 'a' );
     398        fwrite( $fp, $out . "\n" );
     399        fclose( $fp );
     400
     401        return $this;
     402    }
     403}
  • z-inventory-manager/trunk/hc4/app/profiler.php

    r2149267 r2153564  
    44    private $benchmark = NULL;
    55    protected $_available_sections = array(
    6         'handlers',
    7         'benchmarks',
    86        'memory_usage',
     7        'factory',
    98        'queries',
    109        'events',
    11         'factory',
    1210        'get',
    1311        'post',
     
    1513        'session_data',
    1614        'config',
     15        'benchmarks',
    1716        );
    1817
     
    2221    protected $lastQuery = array();
    2322    protected $events = array();
     23
     24    protected $factoryStack = array();
    2425    protected $factory = array();
    25     protected $handlers = array();
    2626
    2727    public function __construct()
     
    3838    }
    3939
     40    public function markFactoryStackStart( $name )
     41    {
     42        $this->factoryStack[] = $name;
     43        $fullName = join( '/', $this->factoryStack );
     44
     45        if( ! isset($this->factory[$fullName]) ){
     46            $this->factory[$fullName] = array( 0, 0 );
     47        }
     48
     49        $this->factory[$fullName][0] -= microtime( TRUE );
     50        $this->factory[$fullName][1] += 1;
     51
     52        $this->benchmark->markStart( '__factory:' . $name );
     53
     54        // echo __FUNCTION__ . ': ' . $fullName . '<br>';
     55    }
     56
     57    public function markFactoryStackEnd()
     58    {
     59        $fullName = join( '/', $this->factoryStack );
     60        $this->factory[$fullName][0] += microtime( TRUE );
     61
     62        $name = array_pop( $this->factoryStack );
     63        $this->benchmark->markEnd( '__factory:' . $name );
     64
     65        return $this;
     66    }
     67
    4068    public function markEvent( $event, $handler )
    4169    {
     
    4775    {
    4876        $this->factory[] = $className;
    49         return $this;
    50     }
    51 
    52     public function markHandler( $handler )
    53     {
    54         $this->handlers[] = $handler;
    5577        return $this;
    5678    }
     
    95117
    96118        foreach( $this->benchmark->getMarkers() as $key ){
     119            if( '__factory:' == substr($key, 0, strlen('__factory:')) ){
     120                continue;
     121            }
    97122            $profile[ $key ] = array( $this->benchmark->getTime($key), $this->benchmark->getCount($key) );
    98123        }
     
    117142        $output .= "\n\n<table style='width:100%;'>\n";
    118143
    119         $decimals = 6;
     144        $decimals = 4;
    120145        $total = $profile['total'][0];
    121146        reset( $profile );
     
    383408    }
    384409
     410    protected function _renderFactory( $node, $parentNode = '' )
     411    {
     412        static $childrenId = 1;
     413
     414        $out = '';
     415        $out .= '<div style="">';
     416
     417        $decimals = 4;
     418
     419        $nodeStats = $this->factory[$node];
     420
     421        $keys = array_keys( $this->factory );
     422        $superNode = $keys[0];
     423        $superTotalTime = $this->benchmark->getTime( '__factory:' . $superNode );
     424
     425        $nodeLabel = strlen($parentNode) ? substr( $node, strlen($parentNode) + 1 ) : $node;
     426
     427        $time = $nodeStats[0];
     428        $count = $nodeStats[1];
     429
     430        $totalTime = $this->benchmark->getTime( '__factory:' . $nodeLabel );
     431        $totalCount = $this->benchmark->getCount( '__factory:' . $nodeLabel );
     432
     433        $timeView = number_format( $time, $decimals );
     434        $totalTimeView = number_format( $totalTime, $decimals );
     435
     436        $valPercent = $totalTime / $superTotalTime;
     437        $valPercentView = $valPercent * 100;
     438        $valPercentView = number_format( $valPercentView, 2 );
     439        $valPercentView .= '%';
     440
     441        $threshold = 3 / count($this->factory);
     442        $color = ( $valPercent > $threshold ) ? '#900' : '#999';
     443        $labelColor = '#61380B';
     444        if( $this->_factoryIsFunctor($nodeLabel) ){
     445            $labelColor = '#0b0';
     446        }
     447        elseif( $this->_factoryIsMethod($nodeLabel) ){
     448            $labelColor = '#00b';
     449        }
     450
     451        $childrenView = '';
     452        reset( $this->factory );
     453        foreach( array_keys($this->factory) as $childNode ){
     454            if( substr($childNode, 0, strlen($node) + 1) !== $node . '/' ){
     455                continue;
     456            }
     457
     458            $childKey = substr( $childNode, strlen($node) + 1 );
     459            if( FALSE !== strpos($childKey, '/') ){
     460                continue;
     461            }
     462
     463            $childrenView .= $this->_renderFactory( $childNode, $node );
     464        }
     465
     466        if( $childrenView ){
     467            $nodeLabel = '<span style="text-decoration: underline;">' . $nodeLabel . '</span>';
     468        }
     469
     470        $stuffingCount = substr_count( $node, '/' );
     471        $stuffing = '<div style="display: inline-block; padding: 0 5px; margin: 0 10px; border-right: #bbb 1px solid;">&nbsp;</div>';
     472        $stuffing = str_repeat( $stuffing, $stuffingCount );
     473
     474        $nodeView = '';
     475        $nodeView .= '<table width="100%" style="border-bottom: #bbb 1px solid;">';
     476        $nodeView .= '<tr>';
     477        $nodeView .= '<td style="overflow: hidden;width: 70%; color: ' . $labelColor . '; border-right: #bbb 1px solid; padding: 5px;">';
     478        $nodeView .= $stuffing . $nodeLabel;
     479        $nodeView .= '</td>';
     480
     481        $nodeView .= '<td style="width: 4%; color: ' . $color . '; border-right: #bbb 1px solid; padding: 5px; text-align: center;">';
     482        if( $totalCount > $count ){
     483            $nodeView .= $count;
     484        }
     485        $nodeView .= '</td>';
     486        $nodeView .= '<td style="width: 7%; color: ' . $color . '; border-right: #bbb 1px solid; padding: 5px; text-align: center;">';
     487        if( $totalCount > $count ){
     488            $nodeView .= $timeView;
     489        }
     490        $nodeView .= '</td>';
     491
     492        $nodeView .= '<td style="width: 4%; color: ' . $color . '; border-right: #bbb 1px solid; padding: 5px; text-align: center;">';
     493        $nodeView .= $totalCount;
     494        $nodeView .= '</td>';
     495        $nodeView .= '<td style="width: 7%; color: ' . $color . '; border-right: #bbb 1px solid; padding: 5px; text-align: center;">';
     496        $nodeView .= $totalTimeView;
     497        $nodeView .= '</td>';
     498
     499        $nodeView .= '<td style="width: 8%; color: ' . $color . '; border-right: #bbb 1px solid; padding: 5px; text-align: center;">';
     500        $nodeView .= $valPercentView;
     501        $nodeView .= '</td>';
     502
     503        $nodeView .= '<tr>';
     504        $nodeView .= '</table>';
     505
     506        if( $childrenView ){
     507            $childrenContainerId = 'ci_profiler_factory_children_' . $childrenId++;
     508            // $showHideJs = '<span style="cursor: pointer; padding: 0 5px;" onclick="var s=document.getElementById(\''.$childrenContainerId.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.'[-]'.'\'?\''.'[+]'.'\':\''.'[-]'.'\';">'.'[+]'.'</span> ';
     509
     510            $nodeView = '<div style="cursor: pointer; text-decoration: underline;" onclick="var s=document.getElementById(\''.$childrenContainerId.'\').style;s.display=s.display==\'none\'?\'\':\'none\';">'. $nodeView . '</div> ';
     511
     512            // $out .= $showHideJs . $nodeView;
     513            $out .= $nodeView;
     514            $out .= '<div style="display: none;" id="' . $childrenContainerId . '">';
     515            $out .= $childrenView;
     516            $out .= '</div>';
     517        }
     518        else {
     519            $out .= $nodeView;
     520        }
     521
     522        $out .= '</div>';
     523        return $out;
     524    }
     525
     526    protected function _factoryIsClass( $node )
     527    {
     528        $dogPos = strpos( $node, '@' );
     529        $return = ( FALSE === $dogPos ) ? TRUE : FALSE;
     530        return $return;
     531    }
     532
     533    protected function _factoryIsMethod( $node )
     534    {
     535        $dogPos = strpos( $node, '@' );
     536        if( FALSE === $dogPos ){
     537            $return = FALSE;
     538        }
     539        else {
     540            $return = ( $dogPos === (strlen($node) - 1) ) ? FALSE : TRUE;
     541        }
     542        return $return;
     543    }
     544
     545    protected function _factoryIsFunctor( $node )
     546    {
     547        $dogPos = strpos( $node, '@' );
     548        if( FALSE === $dogPos ){
     549            $return = FALSE;
     550        }
     551        else {
     552            $return = ( $dogPos === (strlen($node) - 1) ) ? TRUE : FALSE;
     553        }
     554        return $return;
     555    }
     556
    385557    protected function _compile_factory()
    386558    {
     559// _print_r( $this->factory );
     560        $keys = array_keys( $this->factory );
     561        $superNode = $keys[0];
     562
     563        $countClasses = $countMethods = $countFunctors = array();
     564        foreach( $keys as $k ){
     565            $ka = explode( '/', $k );
     566            $k = array_pop( $ka );
     567
     568            if( $this->_factoryIsClass($k) ){
     569                if( ! isset($countClasses[$k]) ){
     570                    $countClasses[$k] = 0;
     571                }
     572                $countClasses[$k]++;
     573            }
     574            elseif( $this->_factoryIsMethod($k) ){
     575                if( ! isset($countMethods[$k]) ){
     576                    $countMethods[$k] = 0;
     577                }
     578                $countMethods[$k]++;
     579            }
     580            elseif( $this->_factoryIsFunctor($k) ){
     581                if( ! isset($countFunctors[$k]) ){
     582                    $countFunctors[$k] = 0;
     583                }
     584                $countFunctors[$k]++;
     585            }
     586        }
     587
     588        $countClassesView = count( $countClasses );
     589        $countMethodsView = count( $countMethods ) . '/' . array_sum( $countMethods );
     590        $countFunctorsView = count( $countFunctors ) . '/' . array_sum( $countFunctors );
     591
    387592        $output  = "\n\n";
    388593        $output .= '<fieldset id="ci_profiler_events" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
    389594        $output .= "\n";
    390         $output .= '<legend style="color:#cd6e00;">&nbsp;&nbsp;'.'profiler_factory: ' . count($this->factory) .'&nbsp;&nbsp;</legend>';
    391         $output .= "\n";
    392 
    393         $classNames = $this->factory;
    394         sort( $classNames );
    395 
    396         $output .= "\n\n<table style='width:100%;'>\n";
    397         foreach( $classNames as $className ){
    398             $output .= "<tr><td style='padding:3px;border:#bbb 1px solid;'>";
    399             $output .= $className;
    400             $output .= "</td></tr>\n";
    401         }
    402         $output .= "</table>\n";
    403 
    404         $output .= "</fieldset>";
    405 
    406         return $output;
    407     }
    408 
    409     protected function _compile_handlers()
    410     {
    411         $output  = "\n\n";
    412         $output .= '<fieldset id="ci_profiler_events" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
    413         $output .= "\n";
    414         $output .= '<legend style="color:#cd6e00;">&nbsp;&nbsp;'.'profiler_handlers: ' .'&nbsp;&nbsp;</legend>';
    415         $output .= "\n";
    416 
    417         $output .= "\n\n<table style='width:100%;'>\n";
    418         foreach( $this->handlers as $handler ){
    419             $output .= "<tr><td style='padding:3px;border:#bbb 1px solid;'>";
    420             $output .= $handler;
    421             $output .= "</td></tr>\n";
    422         }
    423         $output .= "</table>\n";
    424 
    425         $output .= "</fieldset>";
    426 
     595        $output .= '<legend style="color:#cd6e00;">&nbsp;&nbsp;'.'profiler_factory: ' . 'classes: ' . $countClassesView . ', ' . 'methods: ' . $countMethodsView . ', ' . 'functors: ' . $countFunctorsView .'&nbsp;&nbsp;</legend>';
     596        $output .= "\n";
     597
     598        $output .= $this->_renderFactory( $superNode );
     599
     600        $output .= "</fieldset>";
    427601        return $output;
    428602    }
     
    430604    public function render( $content )
    431605    {
     606        while( $this->factoryStack ){
     607            $this->markFactoryStackEnd();
     608        }
     609
    432610        $out = $content . $this->run();
    433611        return $out;
  • z-inventory-manager/trunk/hc4/app/router.php

    r2149267 r2153564  
    1515
    1616    public function __construct(
    17         HC4_App_Profiler $profiler
    1817    )
    1918    {}
     
    2524        }
    2625
    27 // $this->profiler->markStart( __METHOD__ );
    28 
    2926        $return = array();
    3027        $context = strtoupper( $context );
    3128
    3229        if( ! isset($this->routes[$context]) ){
    33             $this->profiler->markEnd( __METHOD__ );
    3430            return $return;
    3531        }
     
    7167        }
    7268
    73 // $this->profiler->markEnd( __METHOD__ );
    7469        return $return;
    7570    }
     
    130125    public function close( array $contexts = array() )
    131126    {
    132 $this->profiler->markStart( __METHOD__ );
    133127        $this->closed = TRUE;
    134128
     
    172166        }
    173167
    174 $this->profiler->markEnd( __METHOD__ );
    175168        return $this;
    176169    }
  • z-inventory-manager/trunk/hc4/assets/hc4-theme.css

    r2149267 r2153564  
    204204}
    205205
    206 button.hc4-admin-link-ternary,
    207 a.hc4-admin-link-ternary,
    208 button.hc4-admin-link-secondary,
    209 a.hc4-admin-link-secondary,
    210 .hc4-admin-label {
     206.hc4-page-menu a,
     207.hc4-page-menu button,
     208.hc4-page-breadcrumb a,
     209.hc4-admin-label
     210{
    211211    padding-left: .5em;
    212212    padding-right: .5em;
     
    227227}
    228228
    229 .hc4-admin-link-ternary,
    230 .hc4-admin-link-secondary {
     229.hc4-page-menu a,
     230.hc4-page-menu button,
     231.hc4-page-breadcrumb a
     232{
    231233    /* display: block; */
    232234    cursor: pointer;
     
    234236    color: #000;
    235237}
    236 .hc4-admin-link-ternary:hover,
    237 .hc4-admin-link-secondary:hover {
     238
     239.hc4-page-menu a:hover,
     240.hc4-page-menu button:hover,
     241.hc4-page-breadcrumb a:hover
     242{
    238243    color: #fff;
    239244    background-color: #0074d9;
     
    263268
    264269/* LAYOUT */
    265 .hc4-admin-page-header {
     270.hc4-page-header {
    266271    padding: 0 0;
    267272    margin: 0 0 1em 0;
    268273    /* border-bottom: #bbb 1px solid; */
    269274}
    270 .hc4-admin-page-subheader {
     275.hc4-page-subheader {
    271276    padding: .5em .5em;
    272277    margin: 0 0 1em 0;
     
    275280}
    276281@media (max-width: 48em) {
    277     .hc4-admin-page-subheader {
     282    .hc4-page-subheader {
    278283        padding: .5em 0;
    279284        border-left-width: 0;
     
    332337    }
    333338
    334     .hc4-admin-link-ternary,
    335     .hc4-admin-link-secondary {
     339    .hc4-page-menu a,
     340    .hc4-page-menu button,
     341    .hc4-page-breadcrumb a
     342    {
    336343        display: block;
    337344    }
  • z-inventory-manager/trunk/hc4/auth/wordpress/boot.php

    r2149267 r2153564  
    88        return $bind;
    99    }
     10
     11    public function __invoke()
     12    {}
    1013}
  • z-inventory-manager/trunk/hc4/csrf/wordpress/boot.php

    r2149267 r2153564  
    88        return $bind;
    99    }
     10
     11    public function __invoke()
     12    {}
    1013}
  • z-inventory-manager/trunk/hc4/database/boot.php

    r2149267 r2153564  
    22class HC4_Database_Boot
    33{
    4     public static function bind2( array $appConfig )
    5     {
    6         $bind = array();
    7 
    8         $prefix = NULL;
    9         switch( $appConfig['platform'] ){
    10             case 'standalone':
    11                 $dbConfig = $appConfig['database'];
    12                 if( isset($dbConfig['dbdriver']) && ('sqlite3' == $dbConfig['dbdriver']) ){
    13                     if( (strpos($dbConfig['database'], '/') === FALSE) && (strpos($dbConfig['database'], '\\') === FALSE) ){
    14                         $dbConfig['database'] = $appConfig['app-dir'] . '/' . $dbConfig['database'];
    15                     }
    16                 }
    17 
    18                 if( isset($dbConfig['prefix']) ){
    19                     $prefix = $dbConfig['prefix'];
    20                 }
    21 
    22                 $db = new HC4_Database_Standalone( $dbConfig );
    23                 break;
    24 
    25             case 'joomla':
    26                 $db = new HC4_Database_Joomla();
    27                 $prefix = '#__';
    28                 break;
    29 
    30             case 'wordpress':
    31                 $db = new HC4_Database_WordPress();
    32                 global $wpdb;
    33                 $prefix = $wpdb->prefix;
    34                 break;
    35         }
    36 
    37         if( isset($appConfig['HC4_App_Profiler']) ){
    38             $profiler = $appConfig['HC4_App_Profiler'];
    39             $db = new HC4_Database_Profiled( $db, $profiler );
    40         }
    41 
    42         $db = new HC4_Database_Prefixed( $db, $prefix );
    43         $bind['HC4_Database_Interface'] = $db;
    44 
    45         return $bind;
    46     }
     4    public function __invoke()
     5    {}
    476}
  • z-inventory-manager/trunk/hc4/database/profiled.php

    r2149267 r2153564  
    88    public function __construct(
    99        HC4_Database_Interface $db,
    10         HC4_App_Profiler $profiler
     10        HC4_App_Profiler $profiler = NULL
    1111    )
    1212    {
     
    1717    public function query( $sql )
    1818    {
    19         $this->profiler->markQueryStart( $sql );
     19        if( $this->profiler ){
     20            $this->profiler->markQueryStart( $sql );
     21        }
     22
    2023        $return = $this->db->query( $sql );
    21         $this->profiler->markQueryEnd();
     24
     25        if( $this->profiler ){
     26            $this->profiler->markQueryEnd();
     27        }
     28
    2229        return $return;
    2330    }
  • z-inventory-manager/trunk/hc4/database/wordpress/boot.php

    r2149267 r2153564  
    1616        return $bind;
    1717    }
     18
     19    public function __invoke()
     20    {}
    1821}
  • z-inventory-manager/trunk/hc4/email/wordpress/boot.php

    r2149267 r2153564  
    88        return $bind;
    99    }
     10
     11    public function __invoke()
     12    {}
    1013}
  • z-inventory-manager/trunk/hc4/html/href/abstract.php

    r2149267 r2153564  
    44    protected $assetSrc = array();
    55    protected $currentSlug = NULL;
     6    protected $aliases = array();
     7
     8    public function alias( $from, $to )
     9    {
     10        $this->aliases[ $from ] = $to;
     11        return $this;
     12    }
    613
    714    public function fromTemplate( $template, $slug )
    815    {
     16        if( isset($this->aliases[$slug]) ){
     17            $slug = $this->aliases[$slug];
     18        }
     19
    920        if( HC4_App_Uri::isFullUrl($slug) ){
    1021            $return = $slug;
  • z-inventory-manager/trunk/hc4/html/href/boot.php

    r2149267 r2153564  
    22class HC4_Html_Href_Boot
    33{
     4    public function __invoke()
     5    {}
    46}
  • z-inventory-manager/trunk/hc4/html/href/wordpress/boot.php

    r2149267 r2153564  
    2929        return $bind;
    3030    }
     31
     32    public function __invoke()
     33    {}
    3134}
  • z-inventory-manager/trunk/hc4/html/input/boot.php

    r2149267 r2153564  
    88        return $bind;
    99    }
     10
     11    public function __invoke()
     12    {}
    1013}
  • z-inventory-manager/trunk/hc4/html/input/radio.php

    r2149267 r2153564  
    77    {}
    88
    9     public function render( $name, $k, $checked = FALSE, $label = NULL, $moreClass = '' )
     9    public function render( $name, $value, $checked = FALSE, $label = NULL, $moreClass = '' )
    1010    {
    1111        // $checked = $this->helper->getValue( $name, $checked );
     
    2424        }
    2525
    26         $out[] = '<input type="radio" class="' . $class . '" name="' . $name . '" value="' . $k . '"';
     26        $out[] = '<input type="radio" class="' . $class . '" name="' . $name . '" value="' . $value . '"';
    2727        if( $checked ){
    2828            $out[] = ' checked="checked"';
  • z-inventory-manager/trunk/hc4/html/input/wordpress/boot.php

    r2149267 r2153564  
    88        return $bind;
    99    }
     10
     11    public function __invoke()
     12    {}
    1013}
  • z-inventory-manager/trunk/hc4/html/screen/boot.php

    r2149267 r2153564  
    22class HC4_Html_Screen_Boot
    33{
     4    public function __invoke()
     5    {}
    46}
  • z-inventory-manager/trunk/hc4/html/screen/config.php

    r2149267 r2153564  
    77    public function breadcrumbTitle( $slugPreg, $value );
    88    public function menu( $slugPreg, $menuLink );
    9     public function layout( $slugPreg, $layout );
    109
    1110    public function getCss( $slug );
     
    1312    public function getTitle( $slug );
    1413    public function getMenu( $slug );
    15     public function getBreadcrumb( $slug );
     14    public function getBreadcrumb( $slug, $limit = NULL );
    1615}
    1716
     
    7069    }
    7170
    72 // LAYOUT
    73     public function layout( $slug, $layout )
    74     {
    75         $this->router->add( 'LAYOUT/' . $slug, $layout );
    76         return $this;
    77     }
    78 
    79     public function getLayout( $slug )
    80     {
    81         return $this->_routerFindOne( 'LAYOUT', $slug );
    82     }
    83 
    8471// TITLE
    8572    public function title( $slug, $value )
     
    120107            return $return;
    121108        }
     109
    122110
    123111        $explicitParent = $this->getBreadcrumbExplicit( $slug );
     
    223211
    224212// HELPERS
    225     protected function _routerFindOne( $context, $slug )
     213    protected function _routerFindOne( $context, $slug, $autorun = TRUE )
    226214    {
    227215        $return = NULL;
     
    229217        $results = $this->router->find( $context, $slug, 1 );
    230218        if( $results ){
    231             $results = $this->_processRouterResults( $slug, $results );
     219            $results = $this->_processRouterResults( $slug, $results, $autorun );
    232220            $return = array_shift( $results );
    233221        }
     
    246234    }
    247235
    248     protected function _processRouterResults( $slug, array $results )
     236    protected function _processRouterResults( $slug, array $results, $autorun = TRUE )
    249237    {
    250238        $return = array();
     
    259247                if( strpos($thisOne, '@') !== FALSE ){
    260248                    list( $className, $method ) = explode( '@', $thisOne );
    261                     $thisOne = $this->factory->make( $className, __CLASS__ );
    262 
    263                     if( strlen($method) ){
     249                    $thisOne = $this->factory->make( $className );
     250
     251                    if( $autorun ){
    264252                        $args = $params;
    265253                        // $args = array_slice( $args, 1 );
    266254                        array_unshift( $args, $slug );
    267 
    268                         $thisOne = call_user_func_array( array($thisOne, $method), $args );
     255                        if( strlen($method) ){
     256                            $thisOne = array($thisOne, $method);
     257                        }
     258                        $thisOne = call_user_func_array( $thisOne, $args );
    269259                    }
    270260                }
  • z-inventory-manager/trunk/hc4/html/screen/interface.php

    r2149267 r2153564  
    22interface HC4_Html_Screen_Interface
    33{
    4     public function render( $slug, $result );
     4    public function __invoke( $slug, $result );
    55}
  • z-inventory-manager/trunk/hc4/html/screen/wordpress/boot.php

    r2149267 r2153564  
    44    public static function bind()
    55    {
     6        $ns = 'HC4_Html_Screen_WordPress_';
     7
    68        $bind = array();
    7         $bind['HC4_Html_Screen_Interface'] = 'HC4_Html_Screen_WordPress_Implementation';
    8         $bind['HC4_Html_Screen_Enqueuer_Interface'] = 'HC4_Html_Screen_WordPress_Enqueuer';
     9        $bind['HC4_Html_Screen_Interface'] = $ns . 'Implementation';
     10        $bind['HC4_Html_Screen_Enqueuer_Interface'] = $ns . 'Enqueuer';
     11
    912        return $bind;
    1013    }
     14
     15    public function _import(
     16        HC4_App_Events $events
     17    )
     18    {}
     19
     20    public function __invoke()
     21    {
     22        $ns = 'HC4_Html_Screen_WordPress_';
     23
     24        $this->events
     25            ->listen( 'HC4_Html_Screen_Layout_MenuItem', $ns . 'Layout_MenuItem' )
     26            ;
     27    }
    1128}
  • z-inventory-manager/trunk/hc4/html/screen/wordpress/implementation.php

    r2149267 r2153564  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class HC4_Html_Screen_WordPress_Implementation
    3     extends HC4_Html_Screen_Abstract
    43    implements HC4_Html_Screen_Interface
    54{
     5    public function _import(
     6        HC4_Html_Screen_Content $content
     7    )
     8    {}
     9
    610    public function __construct(
    711        HC4_Html_Screen_Config $config,
    812
    913        HC4_Html_Screen_Enqueuer_Interface $enqueuer,
    10         HC4_App_Profiler $profiler,
    1114        HC4_Session_Interface $session,
    1215        HC4_Translate_Interface $translate,
     
    1619    {}
    1720
    18     public function renderWidget( $slug, $return, $isAjax = FALSE )
    19     {
    20         $return = parent::renderWidget( $slug, $return, $isAjax );
    21         $cssReplace = array(
    22             'hc4-admin-btn-primary' => 'button button-primary button-large',
    23             'hc4-admin-link-secondary'  => 'hc-block page-title-action hc-top-auto',
    24             );
    25         foreach( $cssReplace as $from => $to ){
    26             $return = str_replace( $from, $to, $return );
    27         }
    28         return $return;
    29     }
    30 
    31     public function render( $slug, $result )
     21    public function __invoke( $slug, $result )
    3222    {
    3323        $isAjax = FALSE;
     
    3929        }
    4030
    41         $result = $this->renderWidget( $slug, $result, $isAjax );
     31        $result = call_user_func( $this->content, $slug, $result );
     32
     33        $cssReplace = array(
     34            'hc4-admin-btn-primary' => 'button button-primary button-large',
     35            'hc4-admin-link-secondary'  => 'hc-block page-title-action hc-top-auto',
     36            );
     37        foreach( $cssReplace as $from => $to ){
     38            $result = str_replace( $from, $to, $result );
     39        }
     40
    4241        if( $isAjax ){
    4342            return $result;
     
    6867        $return = ob_get_clean();
    6968
    70         if( $this->profiler ){
    71             $this->profiler->markEnd( 'handle' );
    72             if( defined('HC4_DEBUG') && HC4_DEBUG ){
    73                 $return = $this->profiler->render( $return );
    74             }
    75         }
    76 
    7769        return $return;
    7870    }
  • z-inventory-manager/trunk/hc4/migration/boot.php

    r2149267 r2153564  
    88        return $bind;
    99    }
     10
     11    public function __invoke()
     12    {}
    1013}
  • z-inventory-manager/trunk/hc4/migration/settings.php

    r2149267 r2153564  
    3636
    3737                if( ! is_object($handler[0]) ){
    38                     $handler[0] = $this->factory->make( $handler[0], __CLASS__ );
     38                    $handler[0] = $this->factory->make( $handler[0] );
    3939                }
    4040
  • z-inventory-manager/trunk/hc4/redirect/ajax.php

    r2149267 r2153564  
    33    implements HC4_Redirect_Interface
    44{
    5     public function call( $to )
     5    public function __invoke( $to )
    66    {
    77        $out = '<hc4redirect>' . $to . '</hc4redirect>';
  • z-inventory-manager/trunk/hc4/redirect/boot.php

    r2149267 r2153564  
    88        return $bind;
    99    }
     10
     11    public function __invoke()
     12    {}
    1013}
  • z-inventory-manager/trunk/hc4/redirect/header.php

    r2149267 r2153564  
    33    implements HC4_Redirect_Interface
    44{
    5     public function call( $to )
     5    public function __invoke( $to )
    66    {
    77        if( ! headers_sent() ){
  • z-inventory-manager/trunk/hc4/redirect/interface.php

    r2061857 r2153564  
    22interface HC4_Redirect_Interface
    33{
    4     public function call( $to );
     4    public function __invoke( $to );
    55}
  • z-inventory-manager/trunk/hc4/redirect/wordpress/boot.php

    r2149267 r2153564  
    88        return $bind;
    99    }
     10
     11    public function __invoke()
     12    {}
    1013}
  • z-inventory-manager/trunk/hc4/redirect/wordpress/implementation.php

    r2149267 r2153564  
    33    implements HC4_Redirect_Interface
    44{
    5     public function call( $to )
     5    public function __invoke( $to )
    66    {
    77        if( ! headers_sent() ){
  • z-inventory-manager/trunk/hc4/session/boot.php

    r2149267 r2153564  
    2121        return $bind;
    2222    }
     23
     24    public function __invoke()
     25    {}
    2326}
  • z-inventory-manager/trunk/hc4/settings/database/boot.php

    r2149267 r2153564  
    2121        return $bind;
    2222    }
     23
     24    public function __invoke()
     25    {}
    2326}
  • z-inventory-manager/trunk/hc4/settings/database/implementation.php

    r2149267 r2153564  
    77
    88    public function __construct(
    9         HC4_App_Profiler $profiler,
    109        HC4_Settings_Database_Crud $crud
    1110    )
  • z-inventory-manager/trunk/hc4/time/boot.php

    r2149267 r2153564  
    88        return $bind;
    99    }
     10
     11    public function __invoke()
     12    {}
    1013}
  • z-inventory-manager/trunk/hc4/translate/wordpress/boot.php

    r2149267 r2153564  
    2929        return $bind;
    3030    }
     31
     32    public function __invoke()
     33    {}
    3134}
  • z-inventory-manager/trunk/modules-zim.php

    r2149267 r2153564  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22return array(
    3 '_version'  => '2.0.2',
     3'_version'  => '2.0.3',
    44'hc4_app'   => array(),
    55'hc4_assets'    => array(),
  • z-inventory-manager/trunk/readme.txt

    r2149267 r2153564  
    6969== Changelog ==
    7070
     71= 2.0.3 =
     72* BUG: Fatal error if used together with WooCommerce.
     73
    7174= 2.0.2 =
    7275* Added delete actions for items, purchases and sales.
  • z-inventory-manager/trunk/z-inventory-manager2.php

    r2149267 r2153564  
    44* Plugin URI: https://www.z-inventory-manager.com/
    55* Description: Manage your inventory - keep track of purchases, sales, transfers.
    6 * Version: 2.0.2
     6* Version: 2.0.3
    77* Author: hitcode.com
    88* Author URI: https://www.hitcode.com/
  • z-inventory-manager/trunk/zi2/01users/boot.php

    r2149267 r2153564  
    22class ZI2_01Users_Boot
    33{
    4     public function __construct(
     4    public function _import(
    55        HC4_App_Router $router,
    66        HC4_Html_Screen_Config $screen
    77    )
     8    {}
     9
     10    public function __invoke()
    811    {
    9         $screen
     12        $this->screen
    1013            ->menu( 'admin/users',      array( admin_url('user-new.php'), '+ __Add New__') )
    1114            ;
  • z-inventory-manager/trunk/zi2/02conf/boot.php

    r2149267 r2153564  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    2 class ZI2_02Conf_Boot_CrudTable
    3     implements HC4_Settings_Database_Crud_Table
    4 {
    5     protected $table = 'zi2_conf';
    6     public function __toString()
    7     {
    8         return $this->table;
    9     }
    10 }
    11 
    122class ZI2_02Conf_Boot
    133{
    14     public static function bind()
    15     {
    16         $bind = array();
    17         $bind['HC4_Settings_Database_Crud_Table'] = 'ZI2_02Conf_Boot_CrudTable';
    18         // $bind['HC4_Settings_Interface'] = 'HC4_Settings_Database_Implementation';
    19         return $bind;
    20     }
    21 
    22     public function __construct(
     4    public function _import(
    235        HC4_Migration_Interface $migration,
    246        HC4_Settings_Interface $settings,
     
    268        HC4_Html_Screen_Config $screen
    279    )
     10    {}
     11
     12    public function __invoke()
    2813    {
    2914    // DATA
    30         $migration
     15        $this->migration
    3116            ->register( 'conf', 1, 'ZI2_02Conf_Data_Migration@version1' )
    3217            ;
    3318
    3419    // DEFAULTS
    35         $settings
     20        $this->settings
    3621            ->init( 'datetime_date_format', 'j M Y' )
    3722            ->init( 'datetime_time_format', 'g:ia' )
     
    4025
    4126    // UI
    42         $router
     27        $this->router
    4328            ->add( 'GET/admin/conf',                'ZI2_02Conf_Ui_Admin_Index@get' )
    4429
     
    5035            ;
    5136
    52         $screen
     37        $this->screen
    5338            ->menu( '',             array( 'admin/conf', '__Settings__', 1000) )
    5439            ->menu( 'admin/conf',   array( '../datetime', '__Date and Time__') )
     
    6146
    6247        $defaultEmail = 'info@' . $_SERVER['SERVER_NAME'];
    63         $settings
     48        $this->settings
    6449            ->init( 'email_from', $defaultEmail )
    6550            ->init( 'email_fromname', 'Z Inventory Manager' )
  • z-inventory-manager/trunk/zi2/02conf/ui/admin/datetime.php

    r2149267 r2153564  
    3737
    3838        $return = $this->render( $slug, $values );
    39         $return = $this->screen->render( $slug, $return );
     39        $return = call_user_func( $this->screen, $slug, $return );
    4040        return $return;
    4141    }
  • z-inventory-manager/trunk/zi2/02conf/ui/admin/email.php

    r2149267 r2153564  
    3636
    3737        $return = $this->render( $values );
    38         $return = $this->screen->render( $slug, $return );
     38        $return = call_user_func( $this->screen, $slug, $return );
    3939        return $return;
    4040    }
  • z-inventory-manager/trunk/zi2/02conf/ui/admin/index.php

    r2061857 r2153564  
    1111        // $return = $this->render();
    1212        $return = NULL;
    13         $return = $this->screen->render( $slug, $return );
     13        $return = call_user_func( $this->screen, $slug, $return );
    1414        return $return;
    1515    }
  • z-inventory-manager/trunk/zi2/03acl/boot.php

    r2149267 r2153564  
    22class ZI2_03Acl_Boot
    33{
    4     public function __construct(
     4    public function _import(
    55        ZI2_03Acl_Data_Repo $repoAcl,
    66
     
    1010        HC4_Html_Screen_Config $screen
    1111    )
     12    {}
     13
     14    public function __invoke()
    1215    {
    1316    // DEFAULTS
    14         $settings
     17        $this->settings
    1518            ;
    1619
    17         $router
     20        $this->router
    1821            ->add( 'GET/notallowed',    'ZI2_03Acl_Ui_NotAllowed@get' )
    1922            ;
    2023
    21         $screen
     24        $this->screen
    2225            ->title( 'notallowed',  '__Not Allowed__' )
    2326            ;
    2427
    2528    // GENERAL
    26         $router
     29        $this->router
    2730            ->add( 'CHECK:GET/admin',       'ZI2_03Acl_Ui_Check@checkAdmin' )
    2831            ->add( 'CHECK:GET/admin*',      'ZI2_03Acl_Ui_Check@checkAdmin' )
     
    3538            ;
    3639
    37         $router
     40        $this->router
    3841            ->add( 'GET/admin/conf/acl',        'ZI2_03Acl_Ui_Admin_Settings@get' )
    3942            ->add( 'POST/admin/conf/acl',       'ZI2_03Acl_Ui_Admin_Settings@post' )
    4043            ;
    4144
    42         $screen
     45        $this->screen
    4346            ->title(    'admin/conf/acl',       '__Access Permissions__' )
    4447            ->menu( 'admin/conf',           array('admin/conf/acl', '__Access Permissions__') )
     
    5760        }
    5861
    59         $defaultAdmins = $repoAcl->getDefaultAdminRoles();
     62        $defaultAdmins = $this->repoAcl->getDefaultAdminRoles();
    6063        foreach( array_keys($wpRoles) as $wpRoleName ){
    6164            $pName = 'users_wp_' . $wpRoleName . '_' . 'admin';
    6265            $pValue = in_array($wpRoleName, $defaultAdmins) ? 1 : 0;
    63             $settings->init( $pName, $pValue );
     66            $this->settings->init( $pName, $pValue );
    6467        }
    6568    }
  • z-inventory-manager/trunk/zi2/03acl/ui/admin/settings.php

    r2149267 r2153564  
    6363
    6464        $return = $this->render( $values );
    65         $return = $this->screen->render( $slug, $return );
     65        $return = call_user_func( $this->screen, $slug, $return );
    6666        return $return;
    6767    }
  • z-inventory-manager/trunk/zi2/03acl/ui/notallowed.php

    r2061857 r2153564  
    1010    {
    1111        $return = $this->render();
    12         $return = $this->screen->render( $slug, $return );
     12        $return = call_user_func( $this->screen, $slug, $return );
    1313        return $return;
    1414    }
  • z-inventory-manager/trunk/zi2/04finance/boot.php

    r2149267 r2153564  
    22class ZI2_04Finance_Boot
    33{
    4     public function __construct(
     4    public function _import(
    55        HC4_Settings_Interface $settings,
    66        HC4_App_Router $router,
    77        HC4_Html_Screen_Config $screen
    88    )
     9    {}
     10
     11    public function __invoke()
    912    {
    1013    // DEFAULTS
    11         $settings
     14        $this->settings
    1215            ->init( 'finance_price_format_before', '$' )
    1316            ->init( 'finance_price_format_number', array('.', ',') )
     
    1619
    1720    // UI
    18         $router
     21        $this->router
    1922            ->add( 'GET/admin/conf/finance',        'ZI2_04Finance_Ui_Admin_Conf_Finance@get' )
    2023            ->add( 'POST/admin/conf/finance',   'ZI2_04Finance_Ui_Admin_Conf_Finance@post' )
    2124            ;
    2225
    23         $screen
     26        $this->screen
    2427            ->menu( 'admin/conf',   array( '../finance', '__Finance__') )
    2528            ->title(    'admin/conf/finance',   '__Finance__' )
  • z-inventory-manager/trunk/zi2/04finance/ui/admin/conf/finance.php

    r2149267 r2153564  
    3838
    3939        $return = $this->render( $values );
    40         $return = $this->screen->render( $slug, $return );
     40        $return = call_user_func( $this->screen, $slug, $return );
    4141        return $return;
    4242    }
  • z-inventory-manager/trunk/zi2/11items/boot.php

    r2149267 r2153564  
    99    }
    1010
    11     public function __construct(
     11    public function _import(
    1212        HC4_Migration_Interface $migration,
    1313        HC4_App_Router $router,
    1414        HC4_Html_Screen_Config $screen
    1515    )
     16    {}
     17
     18    public function __invoke()
    1619    {
    17         $migration
     20        $this->migration
    1821            ->register( 'items', 1, 'ZI2_11Items_Data_Migration@version1' )
    19             ;
    20 
    21     // UI
    22         $router
    23             ;
    24 
    25         $screen
    2622            ;
    2723    }
  • z-inventory-manager/trunk/zi2/12wooitems/boot.php

    r2149267 r2153564  
    22class ZI2_12WooItems_Boot
    33{
    4     public function __construct(
     4    public function _import(
    55        HC4_App_Factory $factory,
    66        HC4_Settings_Interface $settings,
     
    99        HC4_Html_Screen_Config $screen
    1010    )
     11    {}
     12
     13    public function __invoke()
    1114    {
    1215        if ( ! class_exists( 'WooCommerce' ) ) {
     
    1619        $ns = 'ZI2_12WooItems_';
    1720
    18         $settings
     21        $this->settings
    1922            ->init( 'use_woo_inventory', 1 )
    2023            ;
    2124
    22         if( $settings->get('use_woo_inventory') ){
    23             $factory
     25        if( $this->settings->get('use_woo_inventory') ){
     26            $this->factory
    2427                ->bind( 'ZI2_11Items_Data_Repo', 'ZI2_12WooItems_Data_Repo' )
    2528                ;
    26             $href
     29            $this->href
    2730                ->alias( 'admin/inventory/new', admin_url('post-new.php?post_type=product') )
    2831                ;
    2932        }
    3033
    31         $router
     34        $this->router
    3235            ->add( 'GET/admin/conf/inventory',  $ns . 'Ui_Admin_Inventory@get' )
    3336            ->add( 'POST/admin/conf/inventory', $ns . 'Ui_Admin_Inventory@post' )
    3437            ;
    3538
    36         $screen
     39        $this->screen
    3740            ->menu( 'admin/conf',   array( '../inventory', '__Inventory__') )
    3841            ->title(    'admin/conf/inventory', '__Inventory__' )
  • z-inventory-manager/trunk/zi2/12wooitems/ui/admin/inventory.php

    r2149267 r2153564  
    3232
    3333        $return = $this->render( $values );
    34         $return = $this->screen->render( $slug, $return );
     34        $return = call_user_func( $this->screen, $slug, $return );
    3535        return $return;
    3636    }
  • z-inventory-manager/trunk/zi2/21purchases/boot.php

    r2149267 r2153564  
    22class ZI2_21Purchases_Boot
    33{
    4     public function __construct(
     4    public function _import(
    55        HC4_Settings_Interface $settings,
    66        HC4_Migration_Interface $migration,
     
    99        HC4_Html_Screen_Config $screen
    1010    )
     11    {}
     12
     13    public function __invoke()
    1114    {
    1215        $ns = 'ZI2_21Purchases_';
    1316
    14         $migration
     17        $this->migration
    1518            ->register( 'purchases', 1, 'ZI2_21Purchases_Data_Migration@version1' )
    1619            ;
    1720
    1821    // CONF
    19         $settings
     22        $this->settings
    2023            ->init( 'purchases_numbers_auto', TRUE )
    2124            ->init( 'purchases_numbers_auto_prefix', 'PO-' )
     
    2326            ;
    2427
    25         $screen
     28        $this->screen
    2629            ->menu( 'admin/conf',   array( '../purchases', '__Purchases__') )
    2730            ->title(    'admin/conf/purchases', '__Purchases__' )
    2831            ;
    29         $router
     32        $this->router
    3033            ->add( 'GET/admin/conf/purchases',  'ZI2_21Purchases_Ui_Admin_Conf_Purchases@get' )
    3134            ->add( 'POST/admin/conf/purchases', 'ZI2_21Purchases_Ui_Admin_Conf_Purchases@post' )
     
    3336
    3437    // DELETE
    35         $router
     38        $this->router
    3639            ->add( 'GET/admin/purchases/[:id]/delete',  $ns . 'Ui_Admin_Id_Delete@get' )
    3740            ->add( 'POST/admin/purchases/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@post' )
    3841            ;
    39         $screen
     42        $this->screen
    4043            ->menu( 'admin/purchases/[:id]',        array('../delete', '&times; ' . '__Delete__', 900) )
    4144            ->title(    'admin/purchases/[:id]/delete', '__Delete__' )
     
    4346
    4447    // UI
    45         $router
     48        $this->router
    4649            ->add( 'GET/admin/purchases',           'ZI2_21Purchases_Ui_Admin_Index@get' )
    4750
     
    5861            ;
    5962
    60         $screen
     63        $this->screen
    6164            ->menu( '',         array('admin/purchases', '__Purchases__') )
    6265
     
    7477
    7578    // NEW
    76         $router
     79        $this->router
    7780            ->add( 'GET/admin/purchases/new',   'ZI2_21Purchases_Ui_Admin_New@get' )
    7881            ->add( 'POST/admin/purchases/new',  'ZI2_21Purchases_Ui_Admin_New@post' )
    7982            ;
    80         $screen
     83        $this->screen
    8184            ->menu( 'admin/purchases',      array('../new', '__New Purchase__') )
    8285            ->title(    'admin/purchases/new',  '__New Purchase__' )
     
    8487
    8588    // ITEMS
    86         $router
     89        $this->router
    8790            ->add( 'GET/admin/purchases/[:id]/items',   'ZI2_21Purchases_Ui_Admin_Id_Items@get' )
    8891            ->add( 'POST/admin/purchases/[:id]/items',  'ZI2_21Purchases_Ui_Admin_Id_Items@post' )
     
    9295            ;
    9396
    94         $screen
     97        $this->screen
    9598            ->title( 'admin/purchases/[:id]/items',         '__Edit Items__' )
    9699            ->menu( 'admin/purchases/:id/items',    array( '../new', '__Add Item__') )
     
    100103
    101104    // LISTEN TO ITEM DELETE
    102         $events
     105        $this->events
    103106            ->listen( 'ZI2_11Items_Data_Repo@delete', $ns . 'Data_Listen@itemDeleted' )
    104107            ;
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/conf/purchases.php

    r2149267 r2153564  
    3737
    3838        $return = $this->render( $values );
    39         $return = $this->screen->render( $slug, $return );
     39        $return = call_user_func( $this->screen, $slug, $return );
    4040        return $return;
    4141    }
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id.php

    r2149267 r2153564  
    3333        }
    3434
    35         $return = $this->screen->render( $slug, $return );
     35        $return = call_user_func( $this->screen, $slug, $return );
    3636        return $return;
    3737    }
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/delete.php

    r2149267 r2153564  
    1313
    1414        $return = $this->render( $model );
    15         $return = $this->screen->render( $slug, $return );
     15        $return = call_user_func( $this->screen, $slug, $return );
    1616        return $return;
    1717    }
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/items.php

    r2149267 r2153564  
    2020
    2121        $return = $this->render( $model );
    22         $return = $this->screen->render( $slug, $return );
     22        $return = call_user_func( $this->screen, $slug, $return );
    2323        return $return;
    2424    }
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/items/new.php

    r2149267 r2153564  
    2424        $item = $this->repoItems->findById( $itemId );
    2525        $return = $this->render( $item );
    26         $return = $this->screen->render( $slug, $return );
     26        $return = call_user_func( $this->screen, $slug, $return );
    2727        return $return;
    2828    }
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts.php

    r2149267 r2153564  
    1717
    1818        $return = $this->render( $model );
    19         $return = $this->screen->render( $slug, $return );
     19        $return = call_user_func( $this->screen, $slug, $return );
    2020        return $return;
    2121    }
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts/id.php

    r2149267 r2153564  
    2525
    2626        $return = $this->render( $model );
    27         $return = $this->screen->render( $slug, $return );
     27        $return = call_user_func( $this->screen, $slug, $return );
    2828        return $return;
    2929    }
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts/new.php

    r2149267 r2153564  
    2222
    2323        $return = $this->render( $model );
    24         $return = $this->screen->render( $slug, $return );
     24        $return = call_user_func( $this->screen, $slug, $return );
    2525        return $return;
    2626    }
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/index.php

    r2149267 r2153564  
    1919
    2020        $return = $this->render( $slug, $entries );
    21         $return = $this->screen->render( $slug, $return );
     21        $return = call_user_func( $this->screen, $slug, $return );
    2222        return $return;
    2323    }
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/new.php

    r2149267 r2153564  
    2020    {
    2121        $return = $this->render();
    22         $return = $this->screen->render( $slug, $return );
     22        $return = call_user_func( $this->screen, $slug, $return );
    2323        return $return;
    2424    }
  • z-inventory-manager/trunk/zi2/22sales/boot.php

    r2149267 r2153564  
    88        HC4_Html_Screen_Config $screen
    99    )
     10    {}
     11
     12    public function __invoke()
    1013    {
    1114        $ns = 'ZI2_22Sales_';
    1215
    13         $migration
     16        $this->migration
    1417            ->register( 'sales', 1, 'ZI2_22Sales_Data_Migration@version1' )
    1518            ;
    1619
    1720    // CONF
    18         $settings
     21        $this->settings
    1922            ->init( 'sales_numbers_auto', TRUE )
    2023            ->init( 'sales_numbers_auto_prefix', 'SO-' )
     
    2225            ;
    2326
    24         $screen
     27        $this->screen
    2528            ->menu( 'admin/conf',   array( '../sales', '__Sales__') )
    2629            ->title(    'admin/conf/sales', '__Sales__' )
    2730            ;
    28         $router
     31        $this->router
    2932            ->add( 'GET/admin/conf/sales',  'ZI2_22Sales_Ui_Admin_Conf_Sales@get' )
    3033            ->add( 'POST/admin/conf/sales', 'ZI2_22Sales_Ui_Admin_Conf_Sales@post' )
     
    3235
    3336    // DELETE
    34         $router
     37        $this->router
    3538            ->add( 'GET/admin/sales/[:id]/delete',  $ns . 'Ui_Admin_Id_Delete@get' )
    3639            ->add( 'POST/admin/sales/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@post' )
    3740            ;
    38         $screen
     41        $this->screen
    3942            ->menu( 'admin/sales/[:id]',        array('../delete', '&times; ' . '__Delete__', 900) )
    4043            ->title(    'admin/sales/[:id]/delete', '__Delete__' )
     
    4245
    4346    // UI
    44         $router
     47        $this->router
    4548            ->add( 'GET/admin/sales',           'ZI2_22Sales_Ui_Admin_Index@get' )
    4649
     
    5760            ;
    5861
    59         $screen
     62        $this->screen
    6063            ->menu( '',         array('admin/sales', '__Sales__') )
    6164
     
    7376
    7477    // NEW
    75         $router
     78        $this->router
    7679            ->add( 'GET/admin/sales/new',       'ZI2_22Sales_Ui_Admin_New@get' )
    7780            ->add( 'POST/admin/sales/new',  'ZI2_22Sales_Ui_Admin_New@post' )
    7881            ;
    7982
    80         $screen
     83        $this->screen
    8184            ->menu( 'admin/sales',      array('../new', '__New Sale__') )
    8285            ->title(    'admin/sales/new',  '__New Sale__' )
     
    8487
    8588    // ITEMS
    86         $router
     89        $this->router
    8790            ->add( 'GET/admin/sales/[:id]/items',   'ZI2_22Sales_Ui_Admin_Id_Items@get' )
    8891            ->add( 'POST/admin/sales/[:id]/items',  'ZI2_22Sales_Ui_Admin_Id_Items@post' )
     
    9295            ;
    9396
    94         $screen
     97        $this->screen
    9598            ->title( 'admin/sales/[:id]/items',         '__Edit Items__' )
    9699            ->menu( 'admin/sales/:id/items',    array( '../new', '__Add Item__') )
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/conf/sales.php

    r2149267 r2153564  
    3737
    3838        $return = $this->render( $values );
    39         $return = $this->screen->render( $slug, $return );
     39        $return = call_user_func( $this->screen, $slug, $return );
    4040        return $return;
    4141    }
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id.php

    r2149267 r2153564  
    3333        }
    3434
    35         $return = $this->screen->render( $slug, $return );
     35        $return = call_user_func( $this->screen, $slug, $return );
    3636        return $return;
    3737    }
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/delete.php

    r2149267 r2153564  
    1313
    1414        $return = $this->render( $model );
    15         $return = $this->screen->render( $slug, $return );
     15        $return = call_user_func( $this->screen, $slug, $return );
    1616        return $return;
    1717    }
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/items.php

    r2149267 r2153564  
    2020
    2121        $return = $this->render( $model );
    22         $return = $this->screen->render( $slug, $return );
     22        $return = call_user_func( $this->screen, $slug, $return );
    2323        return $return;
    2424    }
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/items/new.php

    r2149267 r2153564  
    2424        $item = $this->repoItems->findById( $itemId );
    2525        $return = $this->render( $item );
    26         $return = $this->screen->render( $slug, $return );
     26        $return = call_user_func( $this->screen, $slug, $return );
    2727        return $return;
    2828    }
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments.php

    r2149267 r2153564  
    1717
    1818        $return = $this->render( $model );
    19         $return = $this->screen->render( $slug, $return );
     19        $return = call_user_func( $this->screen, $slug, $return );
    2020        return $return;
    2121    }
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments/id.php

    r2149267 r2153564  
    2525
    2626        $return = $this->render( $model );
    27         $return = $this->screen->render( $slug, $return );
     27        $return = call_user_func( $this->screen, $slug, $return );
    2828        return $return;
    2929    }
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments/new.php

    r2149267 r2153564  
    2222
    2323        $return = $this->render( $model );
    24         $return = $this->screen->render( $slug, $return );
     24        $return = call_user_func( $this->screen, $slug, $return );
    2525        return $return;
    2626    }
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/index.php

    r2149267 r2153564  
    1919
    2020        $return = $this->render( $entries );
    21         $return = $this->screen->render( $slug, $return );
     21        $return = call_user_func( $this->screen, $slug, $return );
    2222        return $return;
    2323    }
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/new.php

    r2149267 r2153564  
    2020    {
    2121        $return = $this->render();
    22         $return = $this->screen->render( $slug, $return );
     22        $return = call_user_func( $this->screen, $slug, $return );
    2323        return $return;
    2424    }
  • z-inventory-manager/trunk/zi2/31inventory/boot.php

    r2149267 r2153564  
    22class ZI2_31Inventory_Boot
    33{
    4     public function __construct(
     4    public function _import(
    55        HC4_App_Router $router,
    66        HC4_Html_Screen_Config $screen
    77    )
     8    {}
     9
     10    public function __invoke()
    811    {
    912        $ns = 'ZI2_31Inventory_';
    1013
    1114    // UI
    12         $router
     15        $this->router
    1316            ->add( 'GET/admin/inventory',                   $ns . 'Ui_Admin_Index@get' )
    1417            ->add( 'GET/admin/inventory/status/[:s]',   $ns . 'Ui_Admin_Index@get' )
     
    2124            ;
    2225
    23         $screen
     26        $this->screen
    2427            ->title(    'admin/inventory',                  '__Inventory__' )
    2528
     
    3235
    3336    // DELETE
    34         $router
     37        $this->router
    3538            ->add( 'GET/admin/inventory/[:id]/delete',  $ns . 'Ui_Admin_Id_Delete@get' )
    3639            ->add( 'POST/admin/inventory/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@post' )
    3740            ;
    38         $screen
     41        $this->screen
    3942            ->menu( 'admin/inventory/[:id]',        array( '../delete', '&times; ' . '__Delete__', 900 ) )
    4043            ->title( 'admin/inventory/[:id]/delete',    '__Delete__' )
     
    4245
    4346    // PURCHASES ITEM SELECTOR
    44         $router
     47        $this->router
    4548            ->add( 'GET/admin/purchases/[:id]/items/new',   $ns . 'Ui_Admin_Purchases_Selector@get' )
    4649            ;
    4750
    4851    // SALES ITEM SELECTOR
    49         $router
     52        $this->router
    5053            ->add( 'GET/admin/sales/[:id]/items/new',           $ns . 'Ui_Admin_Sales_Selector@get' )
    5154            ;
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/id.php

    r2149267 r2153564  
    2222        $model = $this->repo->findById( $id );
    2323        $return = $this->render( $model );
    24         $return = $this->screen->render( $slug, $return );
     24        $return = call_user_func( $this->screen, $slug, $return );
    2525        return $return;
    2626    }
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/id/delete.php

    r2149267 r2153564  
    1313
    1414        $return = $this->render( $model );
    15         $return = $this->screen->render( $slug, $return );
     15        $return = call_user_func( $this->screen, $slug, $return );
    1616        return $return;
    1717    }
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/index.php

    r2149267 r2153564  
    6565
    6666        $return = $this->render( $entries );
    67         $return = $this->screen->render( $slug, $return );
     67        $return = call_user_func( $this->screen, $slug, $return );
    6868        return $return;
    6969    }
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/new.php

    r2149267 r2153564  
    1717        $model = new ZI2_11Items_Data_Model;
    1818        $return = $this->render( $model );
    19         $return = $this->screen->render( $slug, $return );
     19        $return = call_user_func( $this->screen, $slug, $return );
    2020        return $return;
    2121    }
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/purchases/selector.php

    r2149267 r2153564  
    3434
    3535        $return = $this->render( $parentSlug, $entries );
    36         $return = $this->screen->render( $slug, $return );
     36        $return = call_user_func( $this->screen, $slug, $return );
    3737        return $return;
    3838    }
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/sales/selector.php

    r2149267 r2153564  
    3434
    3535        $return = $this->render( $parentSlug, $entries );
    36         $return = $this->screen->render( $slug, $return );
     36        $return = call_user_func( $this->screen, $slug, $return );
    3737        return $return;
    3838    }
  • z-inventory-manager/trunk/zi2/99app/boot.php

    r2149267 r2153564  
    99    }
    1010
    11     public function __construct(
     11    public function _import(
    1212        HC4_Migration_Interface $migration,
    1313
     
    1919        HC4_Html_Screen_Config $screen
    2020    )
     21    {}
     22
     23    public function __invoke()
    2124    {
    22         $migration
     25        $this->migration
    2326            ->register( 'app', 1, 'ZI2_99App_Data_Migration@version1' )
    2427            ;
    2528
    26         $tf->dateFormat = $settings->get( 'datetime_date_format', 'j M Y' );
    27         $tf->timeFormat = $settings->get( 'datetime_time_format', 'g:ia' );
    28         $t->weekStartsOn = $settings->get( 'datetime_week_starts', 0 );
     29        $this->tf->dateFormat = $this->settings->get( 'datetime_date_format', 'j M Y' );
     30        $this->tf->timeFormat = $this->settings->get( 'datetime_time_format', 'g:ia' );
     31        $this->t->weekStartsOn = $this->settings->get( 'datetime_week_starts', 0 );
    2932
    30         $screen
     33        $this->screen
    3134            ->css( '*', 'hc4/assets/hc.css' )
    3235            ->css( '*', 'hc4/assets/hc4-theme.css' )
    33             ->layout( '*',  'ZI2_99App_Ui_Layout@' )
    3436            ;
    3537
    36         $router
     38        $this->router
    3739            ->add( 'GET',   'ZI2_99App_Ui_Index@get' )
    3840            ;
    3941
    40         $screen
     42        $this->screen
    4143            ->title( '',    'ZI2_99App_Ui_Index@title' )
    4244            ;
    4345
    44         $router
     46        $this->router
    4547            ->add( 'GET/upgrade',   'ZI2_99App_Ui_Upgrade@get' )
    4648            ;
  • z-inventory-manager/trunk/zi2/99app/ui/admin/publish.php

    r2061857 r2153564  
    2626        $return = $this->render( $pagesWithShortcode );
    2727
    28         $return = $this->screen->render( $slug, $return );
     28        $return = call_user_func( $this->screen, $slug, $return );
    2929        return $return;
    3030    }
     
    6060
    6161                <div>
    62                     <a target="_blank" class="hc4-admin-link-secondary hc-block" href="<?php echo admin_url('post-new.php'); ?>">__Add New__</a>
     62                    <a target="_blank" class="hc-block" href="<?php echo admin_url('post-new.php'); ?>">__Add New__</a>
    6363                </div>
    6464
  • z-inventory-manager/trunk/zi2/99app/ui/index.php

    r2149267 r2153564  
    1212    {
    1313        $return = '';
    14         $return = $this->screen->render( $slug, $return );
     14        $return = call_user_func( $this->screen, $slug, $return );
    1515        return $return;
    1616    }
  • z-inventory-manager/trunk/zi2/99app/ui/upgrade.php

    r2061857 r2153564  
    1313
    1414        $return = '';
    15         $return = $this->screen->render( $slug, $return );
     15        $return = call_user_func( $this->screen, $slug, $return );
    1616        return $return;
    1717    }
Note: See TracChangeset for help on using the changeset viewer.