Changeset 2153564
- Timestamp:
- 09/09/2019 01:04:23 PM (6 years ago)
- Location:
- z-inventory-manager/trunk
- Files:
-
- 10 added
- 4 deleted
- 85 edited
-
hc4/app/events.php (modified) (3 diffs)
-
hc4/app/events2.php (deleted)
-
hc4/app/factory (added)
-
hc4/app/factory.php (modified) (15 diffs)
-
hc4/app/factory/wrapper.php (added)
-
hc4/app/index.php (modified) (10 diffs)
-
hc4/app/profiler.php (modified) (9 diffs)
-
hc4/app/router.php (modified) (5 diffs)
-
hc4/app/slugcheck.php (added)
-
hc4/assets/hc4-theme.css (modified) (6 diffs)
-
hc4/auth/wordpress/boot.php (modified) (1 diff)
-
hc4/csrf/wordpress/boot.php (modified) (1 diff)
-
hc4/database/boot.php (modified) (1 diff)
-
hc4/database/profiled.php (modified) (2 diffs)
-
hc4/database/wordpress/boot.php (modified) (1 diff)
-
hc4/email/wordpress/boot.php (modified) (1 diff)
-
hc4/html/href/abstract.php (modified) (1 diff)
-
hc4/html/href/boot.php (modified) (1 diff)
-
hc4/html/href/wordpress/boot.php (modified) (1 diff)
-
hc4/html/input/boot.php (modified) (1 diff)
-
hc4/html/input/radio.php (modified) (2 diffs)
-
hc4/html/input/wordpress/boot.php (modified) (1 diff)
-
hc4/html/screen/abstract.php (deleted)
-
hc4/html/screen/boot.php (modified) (1 diff)
-
hc4/html/screen/config.php (modified) (8 diffs)
-
hc4/html/screen/content.php (added)
-
hc4/html/screen/interface.php (modified) (1 diff)
-
hc4/html/screen/layout.php (added)
-
hc4/html/screen/layout/breadcrumb.php (added)
-
hc4/html/screen/layout/interface.php (deleted)
-
hc4/html/screen/layout/menu.php (added)
-
hc4/html/screen/layout/menuitem.php (added)
-
hc4/html/screen/wordpress/boot.php (modified) (1 diff)
-
hc4/html/screen/wordpress/implementation.php (modified) (4 diffs)
-
hc4/html/screen/wordpress/layout (added)
-
hc4/html/screen/wordpress/layout/menuitem.php (added)
-
hc4/migration/boot.php (modified) (1 diff)
-
hc4/migration/settings.php (modified) (1 diff)
-
hc4/redirect/ajax.php (modified) (1 diff)
-
hc4/redirect/boot.php (modified) (1 diff)
-
hc4/redirect/header.php (modified) (1 diff)
-
hc4/redirect/interface.php (modified) (1 diff)
-
hc4/redirect/wordpress/boot.php (modified) (1 diff)
-
hc4/redirect/wordpress/implementation.php (modified) (1 diff)
-
hc4/session/boot.php (modified) (1 diff)
-
hc4/settings/database/boot.php (modified) (1 diff)
-
hc4/settings/database/implementation.php (modified) (1 diff)
-
hc4/time/boot.php (modified) (1 diff)
-
hc4/translate/wordpress/boot.php (modified) (1 diff)
-
modules-zim.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
z-inventory-manager2.php (modified) (1 diff)
-
zi2/01users/boot.php (modified) (1 diff)
-
zi2/02conf/boot.php (modified) (5 diffs)
-
zi2/02conf/ui/admin/datetime.php (modified) (1 diff)
-
zi2/02conf/ui/admin/email.php (modified) (1 diff)
-
zi2/02conf/ui/admin/index.php (modified) (1 diff)
-
zi2/03acl/boot.php (modified) (4 diffs)
-
zi2/03acl/ui/admin/settings.php (modified) (1 diff)
-
zi2/03acl/ui/notallowed.php (modified) (1 diff)
-
zi2/04finance/boot.php (modified) (2 diffs)
-
zi2/04finance/ui/admin/conf/finance.php (modified) (1 diff)
-
zi2/11items/boot.php (modified) (1 diff)
-
zi2/12wooitems/boot.php (modified) (3 diffs)
-
zi2/12wooitems/ui/admin/inventory.php (modified) (1 diff)
-
zi2/21purchases/boot.php (modified) (10 diffs)
-
zi2/21purchases/ui/admin/conf/purchases.php (modified) (1 diff)
-
zi2/21purchases/ui/admin/id.php (modified) (1 diff)
-
zi2/21purchases/ui/admin/id/delete.php (modified) (1 diff)
-
zi2/21purchases/ui/admin/id/items.php (modified) (1 diff)
-
zi2/21purchases/ui/admin/id/items/new.php (modified) (1 diff)
-
zi2/21purchases/ui/admin/id/receipts.php (modified) (1 diff)
-
zi2/21purchases/ui/admin/id/receipts/id.php (modified) (1 diff)
-
zi2/21purchases/ui/admin/id/receipts/new.php (modified) (1 diff)
-
zi2/21purchases/ui/admin/index.php (modified) (1 diff)
-
zi2/21purchases/ui/admin/new.php (modified) (1 diff)
-
zi2/22sales/boot.php (modified) (8 diffs)
-
zi2/22sales/ui/admin/conf/sales.php (modified) (1 diff)
-
zi2/22sales/ui/admin/id.php (modified) (1 diff)
-
zi2/22sales/ui/admin/id/delete.php (modified) (1 diff)
-
zi2/22sales/ui/admin/id/items.php (modified) (1 diff)
-
zi2/22sales/ui/admin/id/items/new.php (modified) (1 diff)
-
zi2/22sales/ui/admin/id/shipments.php (modified) (1 diff)
-
zi2/22sales/ui/admin/id/shipments/id.php (modified) (1 diff)
-
zi2/22sales/ui/admin/id/shipments/new.php (modified) (1 diff)
-
zi2/22sales/ui/admin/index.php (modified) (1 diff)
-
zi2/22sales/ui/admin/new.php (modified) (1 diff)
-
zi2/31inventory/boot.php (modified) (4 diffs)
-
zi2/31inventory/ui/admin/id.php (modified) (1 diff)
-
zi2/31inventory/ui/admin/id/delete.php (modified) (1 diff)
-
zi2/31inventory/ui/admin/index.php (modified) (1 diff)
-
zi2/31inventory/ui/admin/new.php (modified) (1 diff)
-
zi2/31inventory/ui/admin/purchases/selector.php (modified) (1 diff)
-
zi2/31inventory/ui/admin/sales/selector.php (modified) (1 diff)
-
zi2/99app/boot.php (modified) (2 diffs)
-
zi2/99app/ui/admin/publish.php (modified) (2 diffs)
-
zi2/99app/ui/index.php (modified) (1 diff)
-
zi2/99app/ui/layout.php (deleted)
-
zi2/99app/ui/upgrade.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
z-inventory-manager/trunk/hc4/app/events.php
r2149267 r2153564 2 2 interface HC4_App_Events_ 3 3 { 4 /* REGISTER TO LISTEN EVENT*/5 public function listen( $eventName, $handler);4 /* NOTIFY ABOUT EVENTS */ 5 public function filter( $eventName, $return, $args ); 6 6 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 ); 13 9 } 14 10 … … 17 13 { 18 14 protected $listeners = array(); 15 protected $filters = array(); 16 protected $debug = FALSE; 19 17 20 18 public function __construct( 21 19 HC4_App_Factory $factory, 22 HC4_App_Profiler $profiler ,20 HC4_App_Profiler $profiler = NULL, 23 21 $debug = FALSE 24 22 ) 25 {} 23 { 24 $this->factory = $factory; 25 $this->profiler = $profiler; 26 $this->debug = $debug; 27 } 26 28 27 /* REGISTER TO LISTEN EVENT */ 28 public function listen( $eventName, $handler ) 29 public function listen( $eventClassName, $listenerClassName ) 29 30 { 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 30 40 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; 34 44 } 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; 71 48 } 72 49 } 73 50 74 if( ! isset($this->listeners[$event Name]) ){75 $this->listeners[$event Name] = array();51 if( ! isset($this->listeners[$eventClassName]) ){ 52 $this->listeners[$eventClassName] = array(); 76 53 } 77 $this->listeners[$event Name][] = $handler;54 $this->listeners[$eventClassName][$listenerClassName] = $listenerClassName; 78 55 79 56 return $this; 80 57 } 81 58 82 /* REGISTER TO MODIFY THE EVENT OUTPUT */ 83 public function registerFilter( $eventName, $handler ) 59 public function filter( $eventName, $return, $args ) 84 60 { 85 $eventName = 'filter:' . $eventName; 86 return $this->listen( $eventName, $handler ); 87 } 61 $eventName = strtolower( $eventName ); 88 62 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(); 94 64 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['*'] ); 99 67 } 100 68 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] ); 106 71 } 107 72 108 return $this; 109 } 73 foreach( $listeners as $listener ){ 74 if( $listener === $eventName ){ 75 continue; 76 } 110 77 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 } 121 86 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; 133 91 } 134 92 } … … 137 95 } 138 96 139 public function getListeners( $eventName )97 public function checkExists( $eventName ) 140 98 { 141 $return = array(); 142 if( ! isset($this->listeners[$eventName]) ){ 99 $return = TRUE; 100 101 if( '*' === $eventName ){ 143 102 return $return; 144 103 } 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 ); 148 107 } 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 149 123 return $return; 150 124 } 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 }165 125 } -
z-inventory-manager/trunk/hc4/app/factory.php
r2149267 r2153564 2 2 class HC4_App_Factory 3 3 { 4 protected $modules = array(); 4 5 protected $bind = array(); 5 protected $appModules = array(); 6 protected $profiler = NULL; 6 7 public $profiler = NULL; 8 protected $events = NULL; 7 9 8 10 public function __construct( 9 array $ bind= array(),10 array $appModules = array()11 array $modules = array(), 12 $profiler 11 13 ) 12 14 { 15 $bind = array(); 13 16 $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(); 14 35 15 36 reset( $bind ); … … 17 38 $k = strtolower( $k ); 18 39 if( is_array($v) ){ 19 20 40 } 21 41 elseif( ! is_object($v) ){ … … 25 45 } 26 46 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 48 67 49 68 /** … … 51 70 * 52 71 * @param string $className A class name to make object. 53 * @param string $callingClassName Who tries to make it.54 72 * 55 73 * @return object 56 74 */ 57 public function make( $className, $ callingClassName)75 public function make( $className, $wrap = TRUE ) 58 76 { 59 77 // if( $this->profiler ){ … … 62 80 static $_reflections = array(); 63 81 64 if( __CLASS__ == $className ){ 82 $className = strtolower( trim($className) ); 83 84 if( strtolower(__CLASS__) === $className ){ 65 85 return $this; 66 86 } 67 68 $className = strtolower( trim($className) );69 $callingClassName = strtolower( trim($callingClassName) );70 87 71 88 // maybe scalar (as param name like Class_Name->param1) … … 83 100 $chain = $this->bind[$className]; 84 101 while( $rexClassName = array_shift($chain) ){ 85 $rex = $this->make( $rexClassName, $ callingClassName);102 $rex = $this->make( $rexClassName, $wrap ); 86 103 $this->bind[ $className ] = $rex; 87 104 } 88 105 } 89 106 107 // ALREADY INSTANTIATED 90 108 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 } 98 117 99 118 if( $this->profiler ){ 100 $this->profiler->mark Start( __METHOD__);119 $this->profiler->markFactoryStackStart( $realClassName ); 101 120 } 102 121 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 103 155 if( $this->profiler ){ 104 $this->profiler->markFactory ( $realClassName);156 $this->profiler->markFactoryStackEnd(); 105 157 } 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 ){ 127 168 $return->{$argName} = $arg; 128 169 } 129 170 } 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 150 172 return $return; 151 173 } … … 177 199 } 178 200 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 181 213 $return = array(); 182 214 183 $className = strtolower( $className );184 215 $needArgs = $this->getArgs( $className, $methodName ); 185 216 … … 202 233 203 234 // CHECK CIRCULAR REFERENCE 204 if( $needArgClassName === $c allingClassName ){205 echo __CLASS__ . ': circular reference<br>' . $ callingClassName . ' -> ' . $className . ' -> ' . $needArgClassName . '<br>';235 if( $needArgClassName === $className ){ 236 echo __CLASS__ . ': circular reference<br>' . $needArgClassName . ' -> ' . $className . ' -> ' . $needArgClassName . '<br>'; 206 237 exit; 207 238 } … … 214 245 } 215 246 216 $arg = $this->make( $needArgClassName, $ className);247 $arg = $this->make( $needArgClassName, $wrap ); 217 248 $argCreated = TRUE; 218 249 } … … 221 252 $makeName = $className . '->' . $needArgName; 222 253 223 $arg = $this->make( $makeName, $ className);254 $arg = $this->make( $makeName, $wrap ); 224 255 if( NULL !== $arg ){ 225 256 $argCreated = TRUE; … … 250 281 // } 251 282 283 // echo "SET CACHE FOR '$cacheKey'<br>"; 284 $cache[$cacheKey] = $return; 285 252 286 return $return; 253 287 } … … 268 302 269 303 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 ){ 272 306 if( $parentModuleIndex < 0 ){ 273 307 if( substr($parentClassName, 0, strlen($moduleName) + 1 ) == $moduleName . '_' ){ … … 293 327 if( $parentModuleIndex == -1 ){ 294 328 echo __CLASS__ . ': module is unknown for ' . $parentClassName . '<br>'; 295 _print_r( $this-> appModules );329 _print_r( $this->modules ); 296 330 exit; 297 331 } … … 299 333 if( $childModuleIndex == -1 ){ 300 334 echo __CLASS__ . ': module is unknown for ' . $childClassName . '<br>'; 301 _print_r( $this-> appModules );335 _print_r( $this->modules ); 302 336 exit; 303 337 } 304 338 305 339 // echo "$parentClassName:$parentModuleIndex VS $childClassName:$childModuleIndex<br>"; 306 // _print_r( $this-> appModules );340 // _print_r( $this->modules ); 307 341 308 342 $return = ( $parentModuleIndex >= $childModuleIndex ); … … 310 344 if( ! $return ){ 311 345 // echo "$parentClassName:$parentModuleIndex VS $childClassName:$childModuleIndex<br>"; 312 // _print_r( $this-> appModules );346 // _print_r( $this->modules ); 313 347 } 314 348 -
z-inventory-manager/trunk/hc4/app/index.php
r2149267 r2153564 11 11 class HC4_App_Index 12 12 { 13 public $profiler = NULL;14 13 protected $logFile = NULL; 15 14 … … 17 16 protected $factory = NULL; 18 17 protected $myConfig = array(); 18 protected $profiler = NULL; 19 20 protected $router = NULL; 21 protected $slugCheck = NULL; 19 22 20 23 /** 21 24 * $modulesConfig 22 25 * ['hc4_app'] 23 * ['debug_post'] boolean 24 * ['debug_events'] boolean 26 * ['debug_post'] boolean 27 * ['events']['debug'] boolean 28 * ['profiler'] boolean 25 29 * 26 30 * @param array $config … … 30 34 public function __construct( array $modulesConfig ) 31 35 { 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 47 if( $this->profiler ){ 48 $this->profiler->markFactoryStackStart( __CLASS__ ); 49 } 50 32 51 $finalModules = array(); 33 52 // if submodule, also include parent module(s) … … 45 64 } 46 65 $this->modules = $finalModules; 47 48 if( isset($this->modules['hc4_app']) ){49 $this->myConfig = $this->modules['hc4_app'];50 }51 66 } 52 67 53 68 public function boot() 54 69 { 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'); 70 if( $this->profiler ){ 71 $this->profiler->markFactoryStackStart( __CLASS__ . '@' . __FUNCTION__ ); 72 } 73 // init factory 74 $this->factory = new HC4_App_Factory( $this->modules, $this->profiler ); 75 80 76 reset( $this->modules ); 81 77 foreach( array_keys($this->modules) as $moduleName ){ 82 78 if( 'hc4_' == substr($moduleName, 0, strlen('hc4_')) ){ 83 continue;79 // continue; 84 80 } 85 81 86 82 $moduleClassName = $moduleName . '_Boot'; 87 83 if( class_exists($moduleClassName) ){ 88 $module = call_user_func( $this->factory, $moduleClassName, __CLASS__ ); 84 $moduleBoot = $this->factory->make( $moduleClassName ); 85 call_user_func( $moduleBoot ); 89 86 } 90 87 } … … 92 89 // MIGRATIONS 93 90 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' ); 95 92 $migration->up(); 96 93 } 97 94 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 98 if( $this->profiler ){ 99 $this->profiler->markFactoryStackEnd(); 100 } 126 101 } 127 102 128 103 public function handleRequest( $defaultSlug = NULL ) 129 104 { 105 // if( $this->profiler ){ 106 // $this->profiler->markFactoryStackStart( __CLASS__ . '@' . __FUNCTION__ ); 107 // } 130 108 $uri = new HC4_App_Uri(); 131 109 $slug = $uri->getSlug(); … … 137 115 $requestMethod = $request->getMethod(); 138 116 117 $findSlug = $slug; 139 118 $isAjax = $request->isAjax(); 140 119 if( ':ajax' == substr($slug, -strlen(':ajax')) ){ 141 120 $isAjax = TRUE; 121 $findSlug = substr($slug, 0, -strlen(':ajax')); 142 122 } 143 123 … … 148 128 149 129 // 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 { 153 if( $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>"; 168 if( $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 222 if( $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 ); 179 234 } 180 235 181 236 // IF STRING THEN SHOW IT 182 if( ! is_array($re turn) ){237 if( ! is_array($result) ){ 183 238 $this->close(); 184 return $re turn;239 return $result; 185 240 } 186 241 187 242 // REDIRECT OR HEADER STATUS 188 $to = array_shift( $re turn);189 $msg = array_shift( $re turn);190 $error = array_shift( $re turn);191 192 // HEADER STATUS243 $to = array_shift( $result ); 244 $msg = array_shift( $result); 245 $error = array_shift( $result ); 246 247 // HEADER WITH HTTP STATUS 193 248 if( is_numeric($to) ){ 194 249 $out = array(); … … 210 265 } 211 266 267 // SET ERRORS IN SESSION 212 268 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 ); 223 282 } 224 283 225 284 // 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 ); 264 301 exit; 265 302 } 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 { 307 if( $this->profiler ){ 308 $this->profiler->markFactoryStackStart( __CLASS__ . '@' . __FUNCTION__ ); 309 } 294 310 $return = TRUE; 295 311 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__ );301 312 $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 383 315 foreach( $handlers as $h ){ 384 316 list( $handler, $args ) = $h; 385 $this->profiler->markHandler( $handler );386 317 387 318 // ADD POST TO ARGUMENTS … … 393 324 394 325 $handler = trim( $handler ); 395 if( FALSE === strpos($handler, '@') ){ 396 $method = 'call'; 397 } 398 else { 326 $method = NULL; 327 328 if( FALSE !== strpos($handler, '@') ){ 399 329 list( $handler, $method ) = explode( '@', $handler ); 400 330 } 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 ); 405 334 } 406 335 407 336 // 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 ); 431 338 if( NULL !== $return ){ 432 339 break; 433 340 } 434 341 } 342 343 if( $this->profiler ){ 344 $this->profiler->markFactoryStackEnd(); 345 } 435 346 436 347 return $return; … … 443 354 $moduleClassName = $moduleName . '_Close'; 444 355 if( class_exists($moduleClassName) ){ 445 $module = call_user_func( $this->factory, $moduleClassName, __CLASS__);356 $module = $this->factory->make( $moduleClassName ); 446 357 } 447 358 } 448 359 return $this; 449 360 } 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 4 4 private $benchmark = NULL; 5 5 protected $_available_sections = array( 6 'handlers',7 'benchmarks',8 6 'memory_usage', 7 'factory', 9 8 'queries', 10 9 'events', 11 'factory',12 10 'get', 13 11 'post', … … 15 13 'session_data', 16 14 'config', 15 'benchmarks', 17 16 ); 18 17 … … 22 21 protected $lastQuery = array(); 23 22 protected $events = array(); 23 24 protected $factoryStack = array(); 24 25 protected $factory = array(); 25 protected $handlers = array();26 26 27 27 public function __construct() … … 38 38 } 39 39 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 40 68 public function markEvent( $event, $handler ) 41 69 { … … 47 75 { 48 76 $this->factory[] = $className; 49 return $this;50 }51 52 public function markHandler( $handler )53 {54 $this->handlers[] = $handler;55 77 return $this; 56 78 } … … 95 117 96 118 foreach( $this->benchmark->getMarkers() as $key ){ 119 if( '__factory:' == substr($key, 0, strlen('__factory:')) ){ 120 continue; 121 } 97 122 $profile[ $key ] = array( $this->benchmark->getTime($key), $this->benchmark->getCount($key) ); 98 123 } … … 117 142 $output .= "\n\n<table style='width:100%;'>\n"; 118 143 119 $decimals = 6;144 $decimals = 4; 120 145 $total = $profile['total'][0]; 121 146 reset( $profile ); … … 383 408 } 384 409 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;"> </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 385 557 protected function _compile_factory() 386 558 { 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 387 592 $output = "\n\n"; 388 593 $output .= '<fieldset id="ci_profiler_events" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; 389 594 $output .= "\n"; 390 $output .= '<legend style="color:#cd6e00;"> '.'profiler_factory: ' . count($this->factory) .' </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;"> '.'profiler_handlers: ' .' </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;"> '.'profiler_factory: ' . 'classes: ' . $countClassesView . ', ' . 'methods: ' . $countMethodsView . ', ' . 'functors: ' . $countFunctorsView .' </legend>'; 596 $output .= "\n"; 597 598 $output .= $this->_renderFactory( $superNode ); 599 600 $output .= "</fieldset>"; 427 601 return $output; 428 602 } … … 430 604 public function render( $content ) 431 605 { 606 while( $this->factoryStack ){ 607 $this->markFactoryStackEnd(); 608 } 609 432 610 $out = $content . $this->run(); 433 611 return $out; -
z-inventory-manager/trunk/hc4/app/router.php
r2149267 r2153564 15 15 16 16 public function __construct( 17 HC4_App_Profiler $profiler18 17 ) 19 18 {} … … 25 24 } 26 25 27 // $this->profiler->markStart( __METHOD__ );28 29 26 $return = array(); 30 27 $context = strtoupper( $context ); 31 28 32 29 if( ! isset($this->routes[$context]) ){ 33 $this->profiler->markEnd( __METHOD__ );34 30 return $return; 35 31 } … … 71 67 } 72 68 73 // $this->profiler->markEnd( __METHOD__ );74 69 return $return; 75 70 } … … 130 125 public function close( array $contexts = array() ) 131 126 { 132 $this->profiler->markStart( __METHOD__ );133 127 $this->closed = TRUE; 134 128 … … 172 166 } 173 167 174 $this->profiler->markEnd( __METHOD__ );175 168 return $this; 176 169 } -
z-inventory-manager/trunk/hc4/assets/hc4-theme.css
r2149267 r2153564 204 204 } 205 205 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 { 211 211 padding-left: .5em; 212 212 padding-right: .5em; … … 227 227 } 228 228 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 { 231 233 /* display: block; */ 232 234 cursor: pointer; … … 234 236 color: #000; 235 237 } 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 { 238 243 color: #fff; 239 244 background-color: #0074d9; … … 263 268 264 269 /* LAYOUT */ 265 .hc4- admin-page-header {270 .hc4-page-header { 266 271 padding: 0 0; 267 272 margin: 0 0 1em 0; 268 273 /* border-bottom: #bbb 1px solid; */ 269 274 } 270 .hc4- admin-page-subheader {275 .hc4-page-subheader { 271 276 padding: .5em .5em; 272 277 margin: 0 0 1em 0; … … 275 280 } 276 281 @media (max-width: 48em) { 277 .hc4- admin-page-subheader {282 .hc4-page-subheader { 278 283 padding: .5em 0; 279 284 border-left-width: 0; … … 332 337 } 333 338 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 { 336 343 display: block; 337 344 } -
z-inventory-manager/trunk/hc4/auth/wordpress/boot.php
r2149267 r2153564 8 8 return $bind; 9 9 } 10 11 public function __invoke() 12 {} 10 13 } -
z-inventory-manager/trunk/hc4/csrf/wordpress/boot.php
r2149267 r2153564 8 8 return $bind; 9 9 } 10 11 public function __invoke() 12 {} 10 13 } -
z-inventory-manager/trunk/hc4/database/boot.php
r2149267 r2153564 2 2 class HC4_Database_Boot 3 3 { 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 {} 47 6 } -
z-inventory-manager/trunk/hc4/database/profiled.php
r2149267 r2153564 8 8 public function __construct( 9 9 HC4_Database_Interface $db, 10 HC4_App_Profiler $profiler 10 HC4_App_Profiler $profiler = NULL 11 11 ) 12 12 { … … 17 17 public function query( $sql ) 18 18 { 19 $this->profiler->markQueryStart( $sql ); 19 if( $this->profiler ){ 20 $this->profiler->markQueryStart( $sql ); 21 } 22 20 23 $return = $this->db->query( $sql ); 21 $this->profiler->markQueryEnd(); 24 25 if( $this->profiler ){ 26 $this->profiler->markQueryEnd(); 27 } 28 22 29 return $return; 23 30 } -
z-inventory-manager/trunk/hc4/database/wordpress/boot.php
r2149267 r2153564 16 16 return $bind; 17 17 } 18 19 public function __invoke() 20 {} 18 21 } -
z-inventory-manager/trunk/hc4/email/wordpress/boot.php
r2149267 r2153564 8 8 return $bind; 9 9 } 10 11 public function __invoke() 12 {} 10 13 } -
z-inventory-manager/trunk/hc4/html/href/abstract.php
r2149267 r2153564 4 4 protected $assetSrc = array(); 5 5 protected $currentSlug = NULL; 6 protected $aliases = array(); 7 8 public function alias( $from, $to ) 9 { 10 $this->aliases[ $from ] = $to; 11 return $this; 12 } 6 13 7 14 public function fromTemplate( $template, $slug ) 8 15 { 16 if( isset($this->aliases[$slug]) ){ 17 $slug = $this->aliases[$slug]; 18 } 19 9 20 if( HC4_App_Uri::isFullUrl($slug) ){ 10 21 $return = $slug; -
z-inventory-manager/trunk/hc4/html/href/boot.php
r2149267 r2153564 2 2 class HC4_Html_Href_Boot 3 3 { 4 public function __invoke() 5 {} 4 6 } -
z-inventory-manager/trunk/hc4/html/href/wordpress/boot.php
r2149267 r2153564 29 29 return $bind; 30 30 } 31 32 public function __invoke() 33 {} 31 34 } -
z-inventory-manager/trunk/hc4/html/input/boot.php
r2149267 r2153564 8 8 return $bind; 9 9 } 10 11 public function __invoke() 12 {} 10 13 } -
z-inventory-manager/trunk/hc4/html/input/radio.php
r2149267 r2153564 7 7 {} 8 8 9 public function render( $name, $ k, $checked = FALSE, $label = NULL, $moreClass = '' )9 public function render( $name, $value, $checked = FALSE, $label = NULL, $moreClass = '' ) 10 10 { 11 11 // $checked = $this->helper->getValue( $name, $checked ); … … 24 24 } 25 25 26 $out[] = '<input type="radio" class="' . $class . '" name="' . $name . '" value="' . $ k. '"';26 $out[] = '<input type="radio" class="' . $class . '" name="' . $name . '" value="' . $value . '"'; 27 27 if( $checked ){ 28 28 $out[] = ' checked="checked"'; -
z-inventory-manager/trunk/hc4/html/input/wordpress/boot.php
r2149267 r2153564 8 8 return $bind; 9 9 } 10 11 public function __invoke() 12 {} 10 13 } -
z-inventory-manager/trunk/hc4/html/screen/boot.php
r2149267 r2153564 2 2 class HC4_Html_Screen_Boot 3 3 { 4 public function __invoke() 5 {} 4 6 } -
z-inventory-manager/trunk/hc4/html/screen/config.php
r2149267 r2153564 7 7 public function breadcrumbTitle( $slugPreg, $value ); 8 8 public function menu( $slugPreg, $menuLink ); 9 public function layout( $slugPreg, $layout );10 9 11 10 public function getCss( $slug ); … … 13 12 public function getTitle( $slug ); 14 13 public function getMenu( $slug ); 15 public function getBreadcrumb( $slug );14 public function getBreadcrumb( $slug, $limit = NULL ); 16 15 } 17 16 … … 70 69 } 71 70 72 // LAYOUT73 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 84 71 // TITLE 85 72 public function title( $slug, $value ) … … 120 107 return $return; 121 108 } 109 122 110 123 111 $explicitParent = $this->getBreadcrumbExplicit( $slug ); … … 223 211 224 212 // HELPERS 225 protected function _routerFindOne( $context, $slug )213 protected function _routerFindOne( $context, $slug, $autorun = TRUE ) 226 214 { 227 215 $return = NULL; … … 229 217 $results = $this->router->find( $context, $slug, 1 ); 230 218 if( $results ){ 231 $results = $this->_processRouterResults( $slug, $results );219 $results = $this->_processRouterResults( $slug, $results, $autorun ); 232 220 $return = array_shift( $results ); 233 221 } … … 246 234 } 247 235 248 protected function _processRouterResults( $slug, array $results )236 protected function _processRouterResults( $slug, array $results, $autorun = TRUE ) 249 237 { 250 238 $return = array(); … … 259 247 if( strpos($thisOne, '@') !== FALSE ){ 260 248 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 ){ 264 252 $args = $params; 265 253 // $args = array_slice( $args, 1 ); 266 254 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 ); 269 259 } 270 260 } -
z-inventory-manager/trunk/hc4/html/screen/interface.php
r2149267 r2153564 2 2 interface HC4_Html_Screen_Interface 3 3 { 4 public function render( $slug, $result );4 public function __invoke( $slug, $result ); 5 5 } -
z-inventory-manager/trunk/hc4/html/screen/wordpress/boot.php
r2149267 r2153564 4 4 public static function bind() 5 5 { 6 $ns = 'HC4_Html_Screen_WordPress_'; 7 6 8 $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 9 12 return $bind; 10 13 } 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 } 11 28 } -
z-inventory-manager/trunk/hc4/html/screen/wordpress/implementation.php
r2149267 r2153564 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class HC4_Html_Screen_WordPress_Implementation 3 extends HC4_Html_Screen_Abstract4 3 implements HC4_Html_Screen_Interface 5 4 { 5 public function _import( 6 HC4_Html_Screen_Content $content 7 ) 8 {} 9 6 10 public function __construct( 7 11 HC4_Html_Screen_Config $config, 8 12 9 13 HC4_Html_Screen_Enqueuer_Interface $enqueuer, 10 HC4_App_Profiler $profiler,11 14 HC4_Session_Interface $session, 12 15 HC4_Translate_Interface $translate, … … 16 19 {} 17 20 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 ) 32 22 { 33 23 $isAjax = FALSE; … … 39 29 } 40 30 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 42 41 if( $isAjax ){ 43 42 return $result; … … 68 67 $return = ob_get_clean(); 69 68 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 77 69 return $return; 78 70 } -
z-inventory-manager/trunk/hc4/migration/boot.php
r2149267 r2153564 8 8 return $bind; 9 9 } 10 11 public function __invoke() 12 {} 10 13 } -
z-inventory-manager/trunk/hc4/migration/settings.php
r2149267 r2153564 36 36 37 37 if( ! is_object($handler[0]) ){ 38 $handler[0] = $this->factory->make( $handler[0] , __CLASS__);38 $handler[0] = $this->factory->make( $handler[0] ); 39 39 } 40 40 -
z-inventory-manager/trunk/hc4/redirect/ajax.php
r2149267 r2153564 3 3 implements HC4_Redirect_Interface 4 4 { 5 public function call( $to )5 public function __invoke( $to ) 6 6 { 7 7 $out = '<hc4redirect>' . $to . '</hc4redirect>'; -
z-inventory-manager/trunk/hc4/redirect/boot.php
r2149267 r2153564 8 8 return $bind; 9 9 } 10 11 public function __invoke() 12 {} 10 13 } -
z-inventory-manager/trunk/hc4/redirect/header.php
r2149267 r2153564 3 3 implements HC4_Redirect_Interface 4 4 { 5 public function call( $to )5 public function __invoke( $to ) 6 6 { 7 7 if( ! headers_sent() ){ -
z-inventory-manager/trunk/hc4/redirect/interface.php
r2061857 r2153564 2 2 interface HC4_Redirect_Interface 3 3 { 4 public function call( $to );4 public function __invoke( $to ); 5 5 } -
z-inventory-manager/trunk/hc4/redirect/wordpress/boot.php
r2149267 r2153564 8 8 return $bind; 9 9 } 10 11 public function __invoke() 12 {} 10 13 } -
z-inventory-manager/trunk/hc4/redirect/wordpress/implementation.php
r2149267 r2153564 3 3 implements HC4_Redirect_Interface 4 4 { 5 public function call( $to )5 public function __invoke( $to ) 6 6 { 7 7 if( ! headers_sent() ){ -
z-inventory-manager/trunk/hc4/session/boot.php
r2149267 r2153564 21 21 return $bind; 22 22 } 23 24 public function __invoke() 25 {} 23 26 } -
z-inventory-manager/trunk/hc4/settings/database/boot.php
r2149267 r2153564 21 21 return $bind; 22 22 } 23 24 public function __invoke() 25 {} 23 26 } -
z-inventory-manager/trunk/hc4/settings/database/implementation.php
r2149267 r2153564 7 7 8 8 public function __construct( 9 HC4_App_Profiler $profiler,10 9 HC4_Settings_Database_Crud $crud 11 10 ) -
z-inventory-manager/trunk/hc4/time/boot.php
r2149267 r2153564 8 8 return $bind; 9 9 } 10 11 public function __invoke() 12 {} 10 13 } -
z-inventory-manager/trunk/hc4/translate/wordpress/boot.php
r2149267 r2153564 29 29 return $bind; 30 30 } 31 32 public function __invoke() 33 {} 31 34 } -
z-inventory-manager/trunk/modules-zim.php
r2149267 r2153564 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 return array( 3 '_version' => '2.0. 2',3 '_version' => '2.0.3', 4 4 'hc4_app' => array(), 5 5 'hc4_assets' => array(), -
z-inventory-manager/trunk/readme.txt
r2149267 r2153564 69 69 == Changelog == 70 70 71 = 2.0.3 = 72 * BUG: Fatal error if used together with WooCommerce. 73 71 74 = 2.0.2 = 72 75 * Added delete actions for items, purchases and sales. -
z-inventory-manager/trunk/z-inventory-manager2.php
r2149267 r2153564 4 4 * Plugin URI: https://www.z-inventory-manager.com/ 5 5 * Description: Manage your inventory - keep track of purchases, sales, transfers. 6 * Version: 2.0. 26 * Version: 2.0.3 7 7 * Author: hitcode.com 8 8 * Author URI: https://www.hitcode.com/ -
z-inventory-manager/trunk/zi2/01users/boot.php
r2149267 r2153564 2 2 class ZI2_01Users_Boot 3 3 { 4 public function _ _construct(4 public function _import( 5 5 HC4_App_Router $router, 6 6 HC4_Html_Screen_Config $screen 7 7 ) 8 {} 9 10 public function __invoke() 8 11 { 9 $ screen12 $this->screen 10 13 ->menu( 'admin/users', array( admin_url('user-new.php'), '+ __Add New__') ) 11 14 ; -
z-inventory-manager/trunk/zi2/02conf/boot.php
r2149267 r2153564 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 class ZI2_02Conf_Boot_CrudTable3 implements HC4_Settings_Database_Crud_Table4 {5 protected $table = 'zi2_conf';6 public function __toString()7 {8 return $this->table;9 }10 }11 12 2 class ZI2_02Conf_Boot 13 3 { 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( 23 5 HC4_Migration_Interface $migration, 24 6 HC4_Settings_Interface $settings, … … 26 8 HC4_Html_Screen_Config $screen 27 9 ) 10 {} 11 12 public function __invoke() 28 13 { 29 14 // DATA 30 $ migration15 $this->migration 31 16 ->register( 'conf', 1, 'ZI2_02Conf_Data_Migration@version1' ) 32 17 ; 33 18 34 19 // DEFAULTS 35 $ settings20 $this->settings 36 21 ->init( 'datetime_date_format', 'j M Y' ) 37 22 ->init( 'datetime_time_format', 'g:ia' ) … … 40 25 41 26 // UI 42 $ router27 $this->router 43 28 ->add( 'GET/admin/conf', 'ZI2_02Conf_Ui_Admin_Index@get' ) 44 29 … … 50 35 ; 51 36 52 $ screen37 $this->screen 53 38 ->menu( '', array( 'admin/conf', '__Settings__', 1000) ) 54 39 ->menu( 'admin/conf', array( '../datetime', '__Date and Time__') ) … … 61 46 62 47 $defaultEmail = 'info@' . $_SERVER['SERVER_NAME']; 63 $ settings48 $this->settings 64 49 ->init( 'email_from', $defaultEmail ) 65 50 ->init( 'email_fromname', 'Z Inventory Manager' ) -
z-inventory-manager/trunk/zi2/02conf/ui/admin/datetime.php
r2149267 r2153564 37 37 38 38 $return = $this->render( $slug, $values ); 39 $return = $this->screen->render($slug, $return );39 $return = call_user_func( $this->screen, $slug, $return ); 40 40 return $return; 41 41 } -
z-inventory-manager/trunk/zi2/02conf/ui/admin/email.php
r2149267 r2153564 36 36 37 37 $return = $this->render( $values ); 38 $return = $this->screen->render($slug, $return );38 $return = call_user_func( $this->screen, $slug, $return ); 39 39 return $return; 40 40 } -
z-inventory-manager/trunk/zi2/02conf/ui/admin/index.php
r2061857 r2153564 11 11 // $return = $this->render(); 12 12 $return = NULL; 13 $return = $this->screen->render($slug, $return );13 $return = call_user_func( $this->screen, $slug, $return ); 14 14 return $return; 15 15 } -
z-inventory-manager/trunk/zi2/03acl/boot.php
r2149267 r2153564 2 2 class ZI2_03Acl_Boot 3 3 { 4 public function _ _construct(4 public function _import( 5 5 ZI2_03Acl_Data_Repo $repoAcl, 6 6 … … 10 10 HC4_Html_Screen_Config $screen 11 11 ) 12 {} 13 14 public function __invoke() 12 15 { 13 16 // DEFAULTS 14 $ settings17 $this->settings 15 18 ; 16 19 17 $ router20 $this->router 18 21 ->add( 'GET/notallowed', 'ZI2_03Acl_Ui_NotAllowed@get' ) 19 22 ; 20 23 21 $ screen24 $this->screen 22 25 ->title( 'notallowed', '__Not Allowed__' ) 23 26 ; 24 27 25 28 // GENERAL 26 $ router29 $this->router 27 30 ->add( 'CHECK:GET/admin', 'ZI2_03Acl_Ui_Check@checkAdmin' ) 28 31 ->add( 'CHECK:GET/admin*', 'ZI2_03Acl_Ui_Check@checkAdmin' ) … … 35 38 ; 36 39 37 $ router40 $this->router 38 41 ->add( 'GET/admin/conf/acl', 'ZI2_03Acl_Ui_Admin_Settings@get' ) 39 42 ->add( 'POST/admin/conf/acl', 'ZI2_03Acl_Ui_Admin_Settings@post' ) 40 43 ; 41 44 42 $ screen45 $this->screen 43 46 ->title( 'admin/conf/acl', '__Access Permissions__' ) 44 47 ->menu( 'admin/conf', array('admin/conf/acl', '__Access Permissions__') ) … … 57 60 } 58 61 59 $defaultAdmins = $ repoAcl->getDefaultAdminRoles();62 $defaultAdmins = $this->repoAcl->getDefaultAdminRoles(); 60 63 foreach( array_keys($wpRoles) as $wpRoleName ){ 61 64 $pName = 'users_wp_' . $wpRoleName . '_' . 'admin'; 62 65 $pValue = in_array($wpRoleName, $defaultAdmins) ? 1 : 0; 63 $ settings->init( $pName, $pValue );66 $this->settings->init( $pName, $pValue ); 64 67 } 65 68 } -
z-inventory-manager/trunk/zi2/03acl/ui/admin/settings.php
r2149267 r2153564 63 63 64 64 $return = $this->render( $values ); 65 $return = $this->screen->render($slug, $return );65 $return = call_user_func( $this->screen, $slug, $return ); 66 66 return $return; 67 67 } -
z-inventory-manager/trunk/zi2/03acl/ui/notallowed.php
r2061857 r2153564 10 10 { 11 11 $return = $this->render(); 12 $return = $this->screen->render($slug, $return );12 $return = call_user_func( $this->screen, $slug, $return ); 13 13 return $return; 14 14 } -
z-inventory-manager/trunk/zi2/04finance/boot.php
r2149267 r2153564 2 2 class ZI2_04Finance_Boot 3 3 { 4 public function _ _construct(4 public function _import( 5 5 HC4_Settings_Interface $settings, 6 6 HC4_App_Router $router, 7 7 HC4_Html_Screen_Config $screen 8 8 ) 9 {} 10 11 public function __invoke() 9 12 { 10 13 // DEFAULTS 11 $ settings14 $this->settings 12 15 ->init( 'finance_price_format_before', '$' ) 13 16 ->init( 'finance_price_format_number', array('.', ',') ) … … 16 19 17 20 // UI 18 $ router21 $this->router 19 22 ->add( 'GET/admin/conf/finance', 'ZI2_04Finance_Ui_Admin_Conf_Finance@get' ) 20 23 ->add( 'POST/admin/conf/finance', 'ZI2_04Finance_Ui_Admin_Conf_Finance@post' ) 21 24 ; 22 25 23 $ screen26 $this->screen 24 27 ->menu( 'admin/conf', array( '../finance', '__Finance__') ) 25 28 ->title( 'admin/conf/finance', '__Finance__' ) -
z-inventory-manager/trunk/zi2/04finance/ui/admin/conf/finance.php
r2149267 r2153564 38 38 39 39 $return = $this->render( $values ); 40 $return = $this->screen->render($slug, $return );40 $return = call_user_func( $this->screen, $slug, $return ); 41 41 return $return; 42 42 } -
z-inventory-manager/trunk/zi2/11items/boot.php
r2149267 r2153564 9 9 } 10 10 11 public function _ _construct(11 public function _import( 12 12 HC4_Migration_Interface $migration, 13 13 HC4_App_Router $router, 14 14 HC4_Html_Screen_Config $screen 15 15 ) 16 {} 17 18 public function __invoke() 16 19 { 17 $ migration20 $this->migration 18 21 ->register( 'items', 1, 'ZI2_11Items_Data_Migration@version1' ) 19 ;20 21 // UI22 $router23 ;24 25 $screen26 22 ; 27 23 } -
z-inventory-manager/trunk/zi2/12wooitems/boot.php
r2149267 r2153564 2 2 class ZI2_12WooItems_Boot 3 3 { 4 public function _ _construct(4 public function _import( 5 5 HC4_App_Factory $factory, 6 6 HC4_Settings_Interface $settings, … … 9 9 HC4_Html_Screen_Config $screen 10 10 ) 11 {} 12 13 public function __invoke() 11 14 { 12 15 if ( ! class_exists( 'WooCommerce' ) ) { … … 16 19 $ns = 'ZI2_12WooItems_'; 17 20 18 $ settings21 $this->settings 19 22 ->init( 'use_woo_inventory', 1 ) 20 23 ; 21 24 22 if( $ settings->get('use_woo_inventory') ){23 $ factory25 if( $this->settings->get('use_woo_inventory') ){ 26 $this->factory 24 27 ->bind( 'ZI2_11Items_Data_Repo', 'ZI2_12WooItems_Data_Repo' ) 25 28 ; 26 $ href29 $this->href 27 30 ->alias( 'admin/inventory/new', admin_url('post-new.php?post_type=product') ) 28 31 ; 29 32 } 30 33 31 $ router34 $this->router 32 35 ->add( 'GET/admin/conf/inventory', $ns . 'Ui_Admin_Inventory@get' ) 33 36 ->add( 'POST/admin/conf/inventory', $ns . 'Ui_Admin_Inventory@post' ) 34 37 ; 35 38 36 $ screen39 $this->screen 37 40 ->menu( 'admin/conf', array( '../inventory', '__Inventory__') ) 38 41 ->title( 'admin/conf/inventory', '__Inventory__' ) -
z-inventory-manager/trunk/zi2/12wooitems/ui/admin/inventory.php
r2149267 r2153564 32 32 33 33 $return = $this->render( $values ); 34 $return = $this->screen->render($slug, $return );34 $return = call_user_func( $this->screen, $slug, $return ); 35 35 return $return; 36 36 } -
z-inventory-manager/trunk/zi2/21purchases/boot.php
r2149267 r2153564 2 2 class ZI2_21Purchases_Boot 3 3 { 4 public function _ _construct(4 public function _import( 5 5 HC4_Settings_Interface $settings, 6 6 HC4_Migration_Interface $migration, … … 9 9 HC4_Html_Screen_Config $screen 10 10 ) 11 {} 12 13 public function __invoke() 11 14 { 12 15 $ns = 'ZI2_21Purchases_'; 13 16 14 $ migration17 $this->migration 15 18 ->register( 'purchases', 1, 'ZI2_21Purchases_Data_Migration@version1' ) 16 19 ; 17 20 18 21 // CONF 19 $ settings22 $this->settings 20 23 ->init( 'purchases_numbers_auto', TRUE ) 21 24 ->init( 'purchases_numbers_auto_prefix', 'PO-' ) … … 23 26 ; 24 27 25 $ screen28 $this->screen 26 29 ->menu( 'admin/conf', array( '../purchases', '__Purchases__') ) 27 30 ->title( 'admin/conf/purchases', '__Purchases__' ) 28 31 ; 29 $ router32 $this->router 30 33 ->add( 'GET/admin/conf/purchases', 'ZI2_21Purchases_Ui_Admin_Conf_Purchases@get' ) 31 34 ->add( 'POST/admin/conf/purchases', 'ZI2_21Purchases_Ui_Admin_Conf_Purchases@post' ) … … 33 36 34 37 // DELETE 35 $ router38 $this->router 36 39 ->add( 'GET/admin/purchases/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@get' ) 37 40 ->add( 'POST/admin/purchases/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@post' ) 38 41 ; 39 $ screen42 $this->screen 40 43 ->menu( 'admin/purchases/[:id]', array('../delete', '× ' . '__Delete__', 900) ) 41 44 ->title( 'admin/purchases/[:id]/delete', '__Delete__' ) … … 43 46 44 47 // UI 45 $ router48 $this->router 46 49 ->add( 'GET/admin/purchases', 'ZI2_21Purchases_Ui_Admin_Index@get' ) 47 50 … … 58 61 ; 59 62 60 $ screen63 $this->screen 61 64 ->menu( '', array('admin/purchases', '__Purchases__') ) 62 65 … … 74 77 75 78 // NEW 76 $ router79 $this->router 77 80 ->add( 'GET/admin/purchases/new', 'ZI2_21Purchases_Ui_Admin_New@get' ) 78 81 ->add( 'POST/admin/purchases/new', 'ZI2_21Purchases_Ui_Admin_New@post' ) 79 82 ; 80 $ screen83 $this->screen 81 84 ->menu( 'admin/purchases', array('../new', '__New Purchase__') ) 82 85 ->title( 'admin/purchases/new', '__New Purchase__' ) … … 84 87 85 88 // ITEMS 86 $ router89 $this->router 87 90 ->add( 'GET/admin/purchases/[:id]/items', 'ZI2_21Purchases_Ui_Admin_Id_Items@get' ) 88 91 ->add( 'POST/admin/purchases/[:id]/items', 'ZI2_21Purchases_Ui_Admin_Id_Items@post' ) … … 92 95 ; 93 96 94 $ screen97 $this->screen 95 98 ->title( 'admin/purchases/[:id]/items', '__Edit Items__' ) 96 99 ->menu( 'admin/purchases/:id/items', array( '../new', '__Add Item__') ) … … 100 103 101 104 // LISTEN TO ITEM DELETE 102 $ events105 $this->events 103 106 ->listen( 'ZI2_11Items_Data_Repo@delete', $ns . 'Data_Listen@itemDeleted' ) 104 107 ; -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/conf/purchases.php
r2149267 r2153564 37 37 38 38 $return = $this->render( $values ); 39 $return = $this->screen->render($slug, $return );39 $return = call_user_func( $this->screen, $slug, $return ); 40 40 return $return; 41 41 } -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id.php
r2149267 r2153564 33 33 } 34 34 35 $return = $this->screen->render($slug, $return );35 $return = call_user_func( $this->screen, $slug, $return ); 36 36 return $return; 37 37 } -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/delete.php
r2149267 r2153564 13 13 14 14 $return = $this->render( $model ); 15 $return = $this->screen->render($slug, $return );15 $return = call_user_func( $this->screen, $slug, $return ); 16 16 return $return; 17 17 } -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/items.php
r2149267 r2153564 20 20 21 21 $return = $this->render( $model ); 22 $return = $this->screen->render($slug, $return );22 $return = call_user_func( $this->screen, $slug, $return ); 23 23 return $return; 24 24 } -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/items/new.php
r2149267 r2153564 24 24 $item = $this->repoItems->findById( $itemId ); 25 25 $return = $this->render( $item ); 26 $return = $this->screen->render($slug, $return );26 $return = call_user_func( $this->screen, $slug, $return ); 27 27 return $return; 28 28 } -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts.php
r2149267 r2153564 17 17 18 18 $return = $this->render( $model ); 19 $return = $this->screen->render($slug, $return );19 $return = call_user_func( $this->screen, $slug, $return ); 20 20 return $return; 21 21 } -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts/id.php
r2149267 r2153564 25 25 26 26 $return = $this->render( $model ); 27 $return = $this->screen->render($slug, $return );27 $return = call_user_func( $this->screen, $slug, $return ); 28 28 return $return; 29 29 } -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts/new.php
r2149267 r2153564 22 22 23 23 $return = $this->render( $model ); 24 $return = $this->screen->render($slug, $return );24 $return = call_user_func( $this->screen, $slug, $return ); 25 25 return $return; 26 26 } -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/index.php
r2149267 r2153564 19 19 20 20 $return = $this->render( $slug, $entries ); 21 $return = $this->screen->render($slug, $return );21 $return = call_user_func( $this->screen, $slug, $return ); 22 22 return $return; 23 23 } -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/new.php
r2149267 r2153564 20 20 { 21 21 $return = $this->render(); 22 $return = $this->screen->render($slug, $return );22 $return = call_user_func( $this->screen, $slug, $return ); 23 23 return $return; 24 24 } -
z-inventory-manager/trunk/zi2/22sales/boot.php
r2149267 r2153564 8 8 HC4_Html_Screen_Config $screen 9 9 ) 10 {} 11 12 public function __invoke() 10 13 { 11 14 $ns = 'ZI2_22Sales_'; 12 15 13 $ migration16 $this->migration 14 17 ->register( 'sales', 1, 'ZI2_22Sales_Data_Migration@version1' ) 15 18 ; 16 19 17 20 // CONF 18 $ settings21 $this->settings 19 22 ->init( 'sales_numbers_auto', TRUE ) 20 23 ->init( 'sales_numbers_auto_prefix', 'SO-' ) … … 22 25 ; 23 26 24 $ screen27 $this->screen 25 28 ->menu( 'admin/conf', array( '../sales', '__Sales__') ) 26 29 ->title( 'admin/conf/sales', '__Sales__' ) 27 30 ; 28 $ router31 $this->router 29 32 ->add( 'GET/admin/conf/sales', 'ZI2_22Sales_Ui_Admin_Conf_Sales@get' ) 30 33 ->add( 'POST/admin/conf/sales', 'ZI2_22Sales_Ui_Admin_Conf_Sales@post' ) … … 32 35 33 36 // DELETE 34 $ router37 $this->router 35 38 ->add( 'GET/admin/sales/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@get' ) 36 39 ->add( 'POST/admin/sales/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@post' ) 37 40 ; 38 $ screen41 $this->screen 39 42 ->menu( 'admin/sales/[:id]', array('../delete', '× ' . '__Delete__', 900) ) 40 43 ->title( 'admin/sales/[:id]/delete', '__Delete__' ) … … 42 45 43 46 // UI 44 $ router47 $this->router 45 48 ->add( 'GET/admin/sales', 'ZI2_22Sales_Ui_Admin_Index@get' ) 46 49 … … 57 60 ; 58 61 59 $ screen62 $this->screen 60 63 ->menu( '', array('admin/sales', '__Sales__') ) 61 64 … … 73 76 74 77 // NEW 75 $ router78 $this->router 76 79 ->add( 'GET/admin/sales/new', 'ZI2_22Sales_Ui_Admin_New@get' ) 77 80 ->add( 'POST/admin/sales/new', 'ZI2_22Sales_Ui_Admin_New@post' ) 78 81 ; 79 82 80 $ screen83 $this->screen 81 84 ->menu( 'admin/sales', array('../new', '__New Sale__') ) 82 85 ->title( 'admin/sales/new', '__New Sale__' ) … … 84 87 85 88 // ITEMS 86 $ router89 $this->router 87 90 ->add( 'GET/admin/sales/[:id]/items', 'ZI2_22Sales_Ui_Admin_Id_Items@get' ) 88 91 ->add( 'POST/admin/sales/[:id]/items', 'ZI2_22Sales_Ui_Admin_Id_Items@post' ) … … 92 95 ; 93 96 94 $ screen97 $this->screen 95 98 ->title( 'admin/sales/[:id]/items', '__Edit Items__' ) 96 99 ->menu( 'admin/sales/:id/items', array( '../new', '__Add Item__') ) -
z-inventory-manager/trunk/zi2/22sales/ui/admin/conf/sales.php
r2149267 r2153564 37 37 38 38 $return = $this->render( $values ); 39 $return = $this->screen->render($slug, $return );39 $return = call_user_func( $this->screen, $slug, $return ); 40 40 return $return; 41 41 } -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id.php
r2149267 r2153564 33 33 } 34 34 35 $return = $this->screen->render($slug, $return );35 $return = call_user_func( $this->screen, $slug, $return ); 36 36 return $return; 37 37 } -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/delete.php
r2149267 r2153564 13 13 14 14 $return = $this->render( $model ); 15 $return = $this->screen->render($slug, $return );15 $return = call_user_func( $this->screen, $slug, $return ); 16 16 return $return; 17 17 } -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/items.php
r2149267 r2153564 20 20 21 21 $return = $this->render( $model ); 22 $return = $this->screen->render($slug, $return );22 $return = call_user_func( $this->screen, $slug, $return ); 23 23 return $return; 24 24 } -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/items/new.php
r2149267 r2153564 24 24 $item = $this->repoItems->findById( $itemId ); 25 25 $return = $this->render( $item ); 26 $return = $this->screen->render($slug, $return );26 $return = call_user_func( $this->screen, $slug, $return ); 27 27 return $return; 28 28 } -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments.php
r2149267 r2153564 17 17 18 18 $return = $this->render( $model ); 19 $return = $this->screen->render($slug, $return );19 $return = call_user_func( $this->screen, $slug, $return ); 20 20 return $return; 21 21 } -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments/id.php
r2149267 r2153564 25 25 26 26 $return = $this->render( $model ); 27 $return = $this->screen->render($slug, $return );27 $return = call_user_func( $this->screen, $slug, $return ); 28 28 return $return; 29 29 } -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments/new.php
r2149267 r2153564 22 22 23 23 $return = $this->render( $model ); 24 $return = $this->screen->render($slug, $return );24 $return = call_user_func( $this->screen, $slug, $return ); 25 25 return $return; 26 26 } -
z-inventory-manager/trunk/zi2/22sales/ui/admin/index.php
r2149267 r2153564 19 19 20 20 $return = $this->render( $entries ); 21 $return = $this->screen->render($slug, $return );21 $return = call_user_func( $this->screen, $slug, $return ); 22 22 return $return; 23 23 } -
z-inventory-manager/trunk/zi2/22sales/ui/admin/new.php
r2149267 r2153564 20 20 { 21 21 $return = $this->render(); 22 $return = $this->screen->render($slug, $return );22 $return = call_user_func( $this->screen, $slug, $return ); 23 23 return $return; 24 24 } -
z-inventory-manager/trunk/zi2/31inventory/boot.php
r2149267 r2153564 2 2 class ZI2_31Inventory_Boot 3 3 { 4 public function _ _construct(4 public function _import( 5 5 HC4_App_Router $router, 6 6 HC4_Html_Screen_Config $screen 7 7 ) 8 {} 9 10 public function __invoke() 8 11 { 9 12 $ns = 'ZI2_31Inventory_'; 10 13 11 14 // UI 12 $ router15 $this->router 13 16 ->add( 'GET/admin/inventory', $ns . 'Ui_Admin_Index@get' ) 14 17 ->add( 'GET/admin/inventory/status/[:s]', $ns . 'Ui_Admin_Index@get' ) … … 21 24 ; 22 25 23 $ screen26 $this->screen 24 27 ->title( 'admin/inventory', '__Inventory__' ) 25 28 … … 32 35 33 36 // DELETE 34 $ router37 $this->router 35 38 ->add( 'GET/admin/inventory/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@get' ) 36 39 ->add( 'POST/admin/inventory/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@post' ) 37 40 ; 38 $ screen41 $this->screen 39 42 ->menu( 'admin/inventory/[:id]', array( '../delete', '× ' . '__Delete__', 900 ) ) 40 43 ->title( 'admin/inventory/[:id]/delete', '__Delete__' ) … … 42 45 43 46 // PURCHASES ITEM SELECTOR 44 $ router47 $this->router 45 48 ->add( 'GET/admin/purchases/[:id]/items/new', $ns . 'Ui_Admin_Purchases_Selector@get' ) 46 49 ; 47 50 48 51 // SALES ITEM SELECTOR 49 $ router52 $this->router 50 53 ->add( 'GET/admin/sales/[:id]/items/new', $ns . 'Ui_Admin_Sales_Selector@get' ) 51 54 ; -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/id.php
r2149267 r2153564 22 22 $model = $this->repo->findById( $id ); 23 23 $return = $this->render( $model ); 24 $return = $this->screen->render($slug, $return );24 $return = call_user_func( $this->screen, $slug, $return ); 25 25 return $return; 26 26 } -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/id/delete.php
r2149267 r2153564 13 13 14 14 $return = $this->render( $model ); 15 $return = $this->screen->render($slug, $return );15 $return = call_user_func( $this->screen, $slug, $return ); 16 16 return $return; 17 17 } -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/index.php
r2149267 r2153564 65 65 66 66 $return = $this->render( $entries ); 67 $return = $this->screen->render($slug, $return );67 $return = call_user_func( $this->screen, $slug, $return ); 68 68 return $return; 69 69 } -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/new.php
r2149267 r2153564 17 17 $model = new ZI2_11Items_Data_Model; 18 18 $return = $this->render( $model ); 19 $return = $this->screen->render($slug, $return );19 $return = call_user_func( $this->screen, $slug, $return ); 20 20 return $return; 21 21 } -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/purchases/selector.php
r2149267 r2153564 34 34 35 35 $return = $this->render( $parentSlug, $entries ); 36 $return = $this->screen->render($slug, $return );36 $return = call_user_func( $this->screen, $slug, $return ); 37 37 return $return; 38 38 } -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/sales/selector.php
r2149267 r2153564 34 34 35 35 $return = $this->render( $parentSlug, $entries ); 36 $return = $this->screen->render($slug, $return );36 $return = call_user_func( $this->screen, $slug, $return ); 37 37 return $return; 38 38 } -
z-inventory-manager/trunk/zi2/99app/boot.php
r2149267 r2153564 9 9 } 10 10 11 public function _ _construct(11 public function _import( 12 12 HC4_Migration_Interface $migration, 13 13 … … 19 19 HC4_Html_Screen_Config $screen 20 20 ) 21 {} 22 23 public function __invoke() 21 24 { 22 $ migration25 $this->migration 23 26 ->register( 'app', 1, 'ZI2_99App_Data_Migration@version1' ) 24 27 ; 25 28 26 $t f->dateFormat = $settings->get( 'datetime_date_format', 'j M Y' );27 $t f->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 ); 29 32 30 $ screen33 $this->screen 31 34 ->css( '*', 'hc4/assets/hc.css' ) 32 35 ->css( '*', 'hc4/assets/hc4-theme.css' ) 33 ->layout( '*', 'ZI2_99App_Ui_Layout@' )34 36 ; 35 37 36 $ router38 $this->router 37 39 ->add( 'GET', 'ZI2_99App_Ui_Index@get' ) 38 40 ; 39 41 40 $ screen42 $this->screen 41 43 ->title( '', 'ZI2_99App_Ui_Index@title' ) 42 44 ; 43 45 44 $ router46 $this->router 45 47 ->add( 'GET/upgrade', 'ZI2_99App_Ui_Upgrade@get' ) 46 48 ; -
z-inventory-manager/trunk/zi2/99app/ui/admin/publish.php
r2061857 r2153564 26 26 $return = $this->render( $pagesWithShortcode ); 27 27 28 $return = $this->screen->render($slug, $return );28 $return = call_user_func( $this->screen, $slug, $return ); 29 29 return $return; 30 30 } … … 60 60 61 61 <div> 62 <a target="_blank" class="hc 4-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> 63 63 </div> 64 64 -
z-inventory-manager/trunk/zi2/99app/ui/index.php
r2149267 r2153564 12 12 { 13 13 $return = ''; 14 $return = $this->screen->render($slug, $return );14 $return = call_user_func( $this->screen, $slug, $return ); 15 15 return $return; 16 16 } -
z-inventory-manager/trunk/zi2/99app/ui/upgrade.php
r2061857 r2153564 13 13 14 14 $return = ''; 15 $return = $this->screen->render($slug, $return );15 $return = call_user_func( $this->screen, $slug, $return ); 16 16 return $return; 17 17 }
Note: See TracChangeset
for help on using the changeset viewer.