Changeset 2149267
- Timestamp:
- 09/01/2019 10:31:43 PM (6 years ago)
- Location:
- z-inventory-manager/trunk
- Files:
-
- 53 added
- 25 deleted
- 95 edited
-
autoloader.php (added)
-
hc4/app.php (deleted)
-
hc4/app/config.php (deleted)
-
hc4/app/events.php (modified) (6 diffs)
-
hc4/app/events2.php (added)
-
hc4/app/factory.php (modified) (10 diffs)
-
hc4/app/functions.php (modified) (3 diffs)
-
hc4/app/index.php (added)
-
hc4/app/module (deleted)
-
hc4/app/profiler.php (modified) (8 diffs)
-
hc4/app/request.php (modified) (1 diff)
-
hc4/app/router.php (modified) (2 diffs)
-
hc4/app/uri.php (modified) (1 diff)
-
hc4/assets/ajax.js (added)
-
hc4/assets/css (deleted)
-
hc4/assets/hc.css (added)
-
hc4/assets/hc4-theme.css (added)
-
hc4/auth/boot.php (deleted)
-
hc4/auth/wordpress (added)
-
hc4/auth/wordpress.php (deleted)
-
hc4/auth/wordpress/boot.php (added)
-
hc4/auth/wordpress/implementation.php (added)
-
hc4/crud/abstractsql.php (deleted)
-
hc4/crud/index.php (deleted)
-
hc4/crud/sql (added)
-
hc4/crud/sql/abstract.php (added)
-
hc4/crud/sql/table.php (added)
-
hc4/crud/sqltable.php (deleted)
-
hc4/csrf/boot.php (deleted)
-
hc4/csrf/wordpress (added)
-
hc4/csrf/wordpress.php (deleted)
-
hc4/csrf/wordpress/boot.php (added)
-
hc4/csrf/wordpress/implementation.php (added)
-
hc4/database/boot.php (modified) (1 diff)
-
hc4/database/prefixed.php (modified) (1 diff)
-
hc4/database/profiled.php (modified) (1 diff)
-
hc4/database/wordpress (added)
-
hc4/database/wordpress.php (deleted)
-
hc4/database/wordpress/boot.php (added)
-
hc4/database/wordpress/implementation.php (added)
-
hc4/email/boot.php (deleted)
-
hc4/email/wordpress (added)
-
hc4/email/wordpress.php (deleted)
-
hc4/email/wordpress/boot.php (added)
-
hc4/email/wordpress/implementation.php (added)
-
hc4/html/href/abstract.php (added)
-
hc4/html/href/boot.php (modified) (1 diff)
-
hc4/html/href/implementation.php (deleted)
-
hc4/html/href/wordpress (added)
-
hc4/html/href/wordpress/boot.php (added)
-
hc4/html/href/wordpress/implementation.php (added)
-
hc4/html/input/boot.php (modified) (1 diff)
-
hc4/html/input/checkbox.php (modified) (3 diffs)
-
hc4/html/input/checkboxdetails.php (modified) (2 diffs)
-
hc4/html/input/checkboxset.php (modified) (1 diff)
-
hc4/html/input/daysofweek.php (added)
-
hc4/html/input/multiset.php (modified) (5 diffs)
-
hc4/html/input/radio.php (modified) (2 diffs)
-
hc4/html/input/radioset.php (modified) (3 diffs)
-
hc4/html/input/text.php (modified) (1 diff)
-
hc4/html/input/wordpress/boot.php (added)
-
hc4/html/input/wordpress/richtextarea.php (modified) (3 diffs)
-
hc4/html/screen/abstract.php (modified) (3 diffs)
-
hc4/html/screen/boot.php (modified) (1 diff)
-
hc4/html/screen/config.php (added)
-
hc4/html/screen/enqueuer (added)
-
hc4/html/screen/enqueuer/interface.php (added)
-
hc4/html/screen/interface.php (modified) (1 diff)
-
hc4/html/screen/layout/interface.php (modified) (1 diff)
-
hc4/html/screen/wordpress (added)
-
hc4/html/screen/wordpress.php (deleted)
-
hc4/html/screen/wordpress/boot.php (added)
-
hc4/html/screen/wordpress/enqueuer.php (added)
-
hc4/html/screen/wordpress/implementation.php (added)
-
hc4/migration/boot.php (modified) (1 diff)
-
hc4/migration/settings.php (modified) (4 diffs)
-
hc4/redirect/ajax.php (modified) (1 diff)
-
hc4/redirect/boot.php (modified) (1 diff)
-
hc4/redirect/header.php (added)
-
hc4/redirect/wordpress (added)
-
hc4/redirect/wordpress.php (deleted)
-
hc4/redirect/wordpress/boot.php (added)
-
hc4/redirect/wordpress/implementation.php (added)
-
hc4/session/boot.php (modified) (1 diff)
-
hc4/settings/boot.php (deleted)
-
hc4/settings/database.php (deleted)
-
hc4/settings/database/boot.php (added)
-
hc4/settings/database/crud (added)
-
hc4/settings/database/crud.php (modified) (1 diff)
-
hc4/settings/database/crud/table.php (added)
-
hc4/settings/database/implementation.php (added)
-
hc4/settings/wordpress.php (deleted)
-
hc4/time/boot.php (modified) (1 diff)
-
hc4/time/format.php (modified) (2 diffs)
-
hc4/time/implementation.php (modified) (2 diffs)
-
hc4/time/interface.php (modified) (1 diff)
-
hc4/translate/boot.php (deleted)
-
hc4/translate/wordpress (added)
-
hc4/translate/wordpress.php (deleted)
-
hc4/translate/wordpress/boot.php (added)
-
hc4/translate/wordpress/config.php (added)
-
hc4/translate/wordpress/implementation.php (added)
-
hc4/ui/enqueuer (deleted)
-
hc4/ui/enqueuer.php (deleted)
-
modules-zim.php (added)
-
readme.txt (modified) (1 diff)
-
z-inventory-manager2.php (modified) (2 diffs)
-
zi2-base.php (modified) (5 diffs)
-
zi2/01users/boot.php (modified) (1 diff)
-
zi2/02conf/boot.php (modified) (3 diffs)
-
zi2/02conf/ui/admin/datetime.php (modified) (1 diff)
-
zi2/02conf/ui/admin/email.php (modified) (1 diff)
-
zi2/03acl/boot.php (modified) (2 diffs)
-
zi2/03acl/ui/admin/settings.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) (2 diffs)
-
zi2/11items/data/crud.php (modified) (1 diff)
-
zi2/11items/data/repo.php (modified) (2 diffs)
-
zi2/12wooitems/boot.php (modified) (3 diffs)
-
zi2/12wooitems/ui/admin/inventory.php (modified) (1 diff)
-
zi2/21purchases/boot.php (modified) (7 diffs)
-
zi2/21purchases/data/crud.php (modified) (1 diff)
-
zi2/21purchases/data/crud/lines.php (modified) (1 diff)
-
zi2/21purchases/data/crud/receipts.php (modified) (1 diff)
-
zi2/21purchases/data/crud/receipts/lines.php (modified) (1 diff)
-
zi2/21purchases/data/listen.php (added)
-
zi2/21purchases/data/repo.php (modified) (3 diffs)
-
zi2/21purchases/data/repo/lines.php (modified) (2 diffs)
-
zi2/21purchases/data/repo/receipts/lines.php (modified) (2 diffs)
-
zi2/21purchases/ui/admin/conf/purchases.php (modified) (1 diff)
-
zi2/21purchases/ui/admin/id.php (modified) (5 diffs)
-
zi2/21purchases/ui/admin/id/delete.php (added)
-
zi2/21purchases/ui/admin/id/items.php (modified) (2 diffs)
-
zi2/21purchases/ui/admin/id/items/new.php (modified) (3 diffs)
-
zi2/21purchases/ui/admin/id/receipts.php (modified) (2 diffs)
-
zi2/21purchases/ui/admin/id/receipts/id.php (modified) (2 diffs)
-
zi2/21purchases/ui/admin/id/receipts/new.php (modified) (2 diffs)
-
zi2/21purchases/ui/admin/index.php (modified) (2 diffs)
-
zi2/21purchases/ui/admin/new.php (modified) (2 diffs)
-
zi2/22sales/boot.php (modified) (7 diffs)
-
zi2/22sales/data/crud.php (modified) (1 diff)
-
zi2/22sales/data/crud/lines.php (modified) (1 diff)
-
zi2/22sales/data/crud/shipments.php (modified) (1 diff)
-
zi2/22sales/data/crud/shipments/lines.php (modified) (1 diff)
-
zi2/22sales/data/listen.php (added)
-
zi2/22sales/data/repo.php (modified) (3 diffs)
-
zi2/22sales/data/repo/lines.php (modified) (2 diffs)
-
zi2/22sales/data/repo/shipments/lines.php (modified) (2 diffs)
-
zi2/22sales/ui/admin/conf/sales.php (modified) (1 diff)
-
zi2/22sales/ui/admin/id.php (modified) (5 diffs)
-
zi2/22sales/ui/admin/id/delete.php (added)
-
zi2/22sales/ui/admin/id/items.php (modified) (2 diffs)
-
zi2/22sales/ui/admin/id/items/new.php (modified) (3 diffs)
-
zi2/22sales/ui/admin/id/shipments.php (modified) (2 diffs)
-
zi2/22sales/ui/admin/id/shipments/id.php (modified) (2 diffs)
-
zi2/22sales/ui/admin/id/shipments/new.php (modified) (2 diffs)
-
zi2/22sales/ui/admin/index.php (modified) (2 diffs)
-
zi2/22sales/ui/admin/new.php (modified) (2 diffs)
-
zi2/31inventory/boot.php (modified) (1 diff)
-
zi2/31inventory/ui/admin/id (added)
-
zi2/31inventory/ui/admin/id.php (modified) (3 diffs)
-
zi2/31inventory/ui/admin/id/delete.php (added)
-
zi2/31inventory/ui/admin/index.php (modified) (3 diffs)
-
zi2/31inventory/ui/admin/new.php (modified) (3 diffs)
-
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) (4 diffs)
-
zi2/99app/data/upgrade.php (modified) (1 diff)
-
zi2/99app/ui/index.php (modified) (1 diff)
-
zi2/99app/ui/layout.php (modified) (5 diffs)
-
zi2/99app/ui/promo/promo.php (modified) (3 diffs)
-
zi2/config.php (deleted)
Legend:
- Unmodified
- Added
- Removed
-
z-inventory-manager/trunk/hc4/app/events.php
r2107074 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 interface HC4_App_Events_ 3 { 4 /* REGISTER TO LISTEN EVENT */ 5 public function listen( $eventName, $handler ); 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 ); 13 } 14 2 15 class HC4_App_Events 16 implements HC4_App_Events_ 3 17 { 4 18 protected $listeners = array(); 5 public $debug = FALSE;6 19 7 20 public function __construct( 8 21 HC4_App_Factory $factory, 9 HC4_App_Profiler $profiler 22 HC4_App_Profiler $profiler, 23 $debug = FALSE 10 24 ) 11 25 {} 12 26 27 /* REGISTER TO LISTEN EVENT */ 13 28 public function listen( $eventName, $handler ) 14 29 { 15 30 if( $this->debug ){ 31 $checkEventName = $eventName; 32 if( 'filter:' == substr($checkEventName, 0, strlen('filter:')) ){ 33 $checkEventName = substr($checkEventName, strlen('filter:')); 34 } 35 16 36 // check if event exists 17 if( FALSE === strpos($ eventName, '@') ){18 if( ! class_exists($ eventName) ){37 if( FALSE === strpos($checkEventName, '@') ){ 38 if( ! class_exists($checkEventName) ){ 19 39 echo __CLASS__ . ": event '$eventName' doesn't exist<br>"; 20 40 return $this; … … 22 42 } 23 43 else { 24 list( $className, $methodName ) = explode( '@', $ eventName );44 list( $className, $methodName ) = explode( '@', $checkEventName ); 25 45 if( ! method_exists($className, $methodName) ){ 26 46 echo __CLASS__ . ": event '$eventName' doesn't exist<br>"; … … 31 51 // check handler 32 52 if( is_string($handler) ){ 33 $handler = trim( $handler ); 53 $checkHandler = $handler; 54 if( 'filter:' == substr($checkHandler, 0, strlen('filter:')) ){ 55 $checkHandler = substr($checkHandler, strlen('filter:')); 56 } 57 $checkHandler = trim( $checkHandler ); 34 58 35 if( FALSE === strpos($ eventName, '@') ){36 $className = $ eventName;59 if( FALSE === strpos($checkHandler, '@') ){ 60 $className = $checkHandler; 37 61 $methodName = '__invoke'; 38 62 } 39 63 else { 40 list( $className, $methodName ) = explode( '@', $ handler );64 list( $className, $methodName ) = explode( '@', $checkHandler ); 41 65 } 42 66 43 67 if( ! method_exists($className, $methodName) ){ 44 echo __CLASS__ . ": event handler '$ handler' doesn't exist<br>";68 echo __CLASS__ . ": event handler '$checkHandler' doesn't exist<br>"; 45 69 return $this; 46 70 } … … 56 80 } 57 81 58 public function publish( $eventName, array $args = array() ) 82 /* REGISTER TO MODIFY THE EVENT OUTPUT */ 83 public function registerFilter( $eventName, $handler ) 59 84 { 85 $eventName = 'filter:' . $eventName; 86 return $this->listen( $eventName, $handler ); 87 } 88 89 /* LET KNOW THAT EVENT OCCURS */ 90 public function publish( $eventName, $return = NULL, array $args = array() ) 91 { 92 $eventName = str_replace( '::', '@', $eventName ); 60 93 $listeners = $this->getListeners( $eventName ); 61 94 95 array_unshift( $args, $return ); 62 96 reset( $listeners ); 63 97 foreach( $listeners as $handler ){ … … 73 107 74 108 return $this; 109 } 110 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 } 121 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] ); 133 } 134 } 135 136 return $return; 75 137 } 76 138 … … 95 157 $handler = array( $handler, $method ); 96 158 if( ! is_object($handler[0]) ){ 97 $handler[0] = $this->factory->make( $handler[0] );159 $handler[0] = $this->factory->make( $handler[0], __CLASS__ ); 98 160 } 99 161 } -
z-inventory-manager/trunk/hc4/app/factory.php
r2107074 r2149267 4 4 protected $bind = array(); 5 5 protected $appModules = array(); 6 protected $profiler = NULL; 6 7 7 8 public function __construct( … … 15 16 foreach( $bind as $k => $v ){ 16 17 $k = strtolower( $k ); 17 if( ! is_object($v) ){ 18 if( is_array($v) ){ 19 20 } 21 elseif( ! is_object($v) ){ 18 22 $v = strtolower( $v ); 19 23 } … … 21 25 } 22 26 23 $this->appModules = $appModules; 24 } 25 26 public function bind( $k, $v ) 27 { 28 $k = strtolower( $k ); 29 if( ! is_object($v) ){ 30 $v = strtolower( $v ); 31 } 32 $this->bind[ $k ] = $v; 33 return $this; 34 } 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 // } 35 48 36 49 /** 37 50 * Makes a functor object of a class. All of them are singletons. 38 51 * 39 * @param string $wantClassName A class name to make object. 52 * @param string $className A class name to make object. 53 * @param string $callingClassName Who tries to make it. 40 54 * 41 55 * @return object 42 56 */ 43 public function make() 44 { 57 public function make( $className, $callingClassName ) 58 { 59 // if( $this->profiler ){ 60 // $this->profiler->markStart( __METHOD__ ); 61 // } 45 62 static $_reflections = array(); 46 47 $args = $originalArgs = func_get_args();48 $className = array_shift( $args );49 63 50 64 if( __CLASS__ == $className ){ … … 53 67 54 68 $className = strtolower( trim($className) ); 69 $callingClassName = strtolower( trim($callingClassName) ); 70 71 // maybe scalar (as param name like Class_Name->param1) 72 if( FALSE !== strpos($className, '->') ){ 73 $return = isset($this->bind[$className]) ? $this->bind[$className] : NULL; 74 return $return; 75 } 55 76 56 77 if( ! isset($this->bind[$className]) ){ 57 78 $this->bind[$className] = $className; 79 } 80 81 // chain of implementations 82 if( is_array($this->bind[$className]) ){ 83 $chain = $this->bind[$className]; 84 while( $rexClassName = array_shift($chain) ){ 85 $rex = $this->make( $rexClassName, $callingClassName ); 86 $this->bind[ $className ] = $rex; 87 } 58 88 } 59 89 … … 67 97 } 68 98 69 $args = $this->makeArgs( $realClassName, '__construct', $args ); 70 99 if( $this->profiler ){ 100 $this->profiler->markStart( __METHOD__ ); 101 } 102 103 if( $this->profiler ){ 104 $this->profiler->markFactory( $realClassName ); 105 } 106 107 // __construct 108 $args = $this->makeArgs( $realClassName, '__construct', $callingClassName ); 71 109 if( $args ){ 110 // echo "JO '$realClassName'<br>"; 72 111 $class = new ReflectionClass( $realClassName ); 73 // echo "JO '$realClassName'<br>";74 112 $return = $class->newInstanceArgs( $args ); 75 113 … … 94 132 } 95 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 96 146 $this->bind[$className] = $return; 147 if( $this->profiler ){ 148 $this->profiler->markEnd( __METHOD__ ); 149 } 97 150 return $return; 98 151 } 99 152 100 public function makeArgs( $className, $methodName, array $args = array())153 public function getArgs( $className, $methodName ) 101 154 { 102 155 static $_reflections = array(); 103 156 157 $return = array(); 158 159 if( is_object($className) ){ 160 $className = get_class( $className ); 161 } 104 162 $className = strtolower( $className ); 163 105 164 if( ! isset($_reflections[$className]) ){ 106 165 $_reflections[$className] = new ReflectionClass( $className ); … … 108 167 $classReflection = $_reflections[$className]; 109 168 110 try { 111 $methodReflection = $classReflection->getMethod( $methodName ); 112 } 113 catch( ReflectionException $e ){ 114 return $args; 115 } 116 169 if( ! $classReflection->hasMethod($methodName) ){ 170 return $return; 171 } 172 173 $methodReflection = $classReflection->getMethod( $methodName ); 174 $return = $methodReflection->getParameters(); 175 176 return $return; 177 } 178 179 public function makeArgs( $className, $methodName, $callingClassName ) 180 { 117 181 $return = array(); 118 182 119 $needArgs = $methodReflection->getParameters(); 183 $className = strtolower( $className ); 184 $needArgs = $this->getArgs( $className, $methodName ); 185 120 186 $numberOfArgs = count( $needArgs ); 121 $suppliedNumberOfArgs = count( $args );122 187 123 188 for( $ii = 0; $ii < $numberOfArgs; $ii++ ){ … … 125 190 $needArgName = $needArg->getName(); 126 191 127 if( $ii < $suppliedNumberOfArgs ){128 $return[ $needArgName ] = $args[ $ii ];129 continue;130 }131 132 192 // NEED TO INJECT MISSING ARGS 133 193 $isOptional = $needArg->isOptional(); 134 135 194 $argCreated = FALSE; 136 195 … … 142 201 $needArgClassName = strtolower( $needArgClassName ); 143 202 203 // CHECK CIRCULAR REFERENCE 204 if( $needArgClassName === $callingClassName ){ 205 echo __CLASS__ . ': circular reference<br>' . $callingClassName . ' -> ' . $className . ' -> ' . $needArgClassName . '<br>'; 206 exit; 207 } 208 144 209 /* NOW CHECK IF THE PARENT CLASS IS ALLOWED TO MAKE ITS ARGUMENT */ 145 210 // FIND THE MODULE OF PARENT 146 $parentModuleIndex = -1; 147 $childModuleIndex = -1; 148 $jj = -1; 149 reset( $this->appModules ); 150 foreach( $this->appModules as $moduleName ){ 151 $jj++; 152 153 if( substr($className, 0, strlen($moduleName) ) == $moduleName ){ 154 $parentModuleIndex = $jj; 211 if( ! $this->_isImportAllowed($className, $needArgClassName) ){ 212 echo "FACTORY: '$className' IS NOT ALLOWED TO MAKE '$needArgClassName'<br>"; 213 exit; 214 } 215 216 $arg = $this->make( $needArgClassName, $className ); 217 $argCreated = TRUE; 218 } 219 else { 220 // if we have scalar binded 221 $makeName = $className . '->' . $needArgName; 222 223 $arg = $this->make( $makeName, $className ); 224 if( NULL !== $arg ){ 225 $argCreated = TRUE; 226 } 227 else { 228 if( $isOptional ){ 229 $arg = $needArg->getDefaultValue(); 230 $argCreated = TRUE; 155 231 } 156 157 if( substr($needArgClassName, 0, strlen($moduleName) ) == $moduleName ){ 158 $childModuleIndex = $jj; 159 } 160 161 // if( ($childModuleIndex > -1) && ($parentModuleIndex > -1) ){ 162 // break; 163 // } 164 } 165 166 if( $childModuleIndex > $parentModuleIndex ){ 167 echo "FACTORY: '$className' IS NOT ALLOWED TO MAKE '$needArgClassName'<br>"; 168 // echo "$childModuleIndex VS $parentModuleIndex<br>"; 169 // _print_r( $this->appModules ); 170 exit; 171 } 172 173 $arg = $this->make( $needArgClassName ); 174 $argCreated = TRUE; 175 } 176 elseif( $isOptional ){ 177 $arg = $needArg->getDefaultValue(); 178 $argCreated = TRUE; 232 } 179 233 } 180 234 } 181 235 catch( ReflectionException $e ){ 182 echo __CLASS__ . ": class is unknown for '$needArgName' $ii argument of '$className::$methodName'!<br>"; 236 echo __CLASS__ . ": can't create '$needArgName' $ii argument of '$className::$methodName'!<br>"; 237 echo $e->getMessage(); 183 238 exit; 184 239 } … … 191 246 $return[ $needArgName ] = $arg; 192 247 } 248 // if( $this->profiler ){ 249 // $this->profiler->markEnd( __METHOD__ ); 250 // } 193 251 194 252 return $return; 195 253 } 196 } 254 255 protected function _isImportAllowed( $parentClassName, $childClassName ) 256 { 257 static $classesToModules = array(); 258 259 $parentModuleIndex = -1; 260 $childModuleIndex = -1; 261 262 if( isset($classesToModules[$parentClassName]) ){ 263 $parentModuleIndex = $classesToModules[$parentClassName]; 264 } 265 if( isset($classesToModules[$childClassName]) ){ 266 $childModuleIndex = $classesToModules[$childClassName]; 267 } 268 269 if( ($parentModuleIndex < 0) OR ($childModuleIndex < 0) ){ 270 reset( $this->appModules ); 271 foreach( $this->appModules as $moduleName => $jj ){ 272 if( $parentModuleIndex < 0 ){ 273 if( substr($parentClassName, 0, strlen($moduleName) + 1 ) == $moduleName . '_' ){ 274 $parentModuleIndex = $jj; 275 } 276 } 277 278 if( $childModuleIndex < 0 ){ 279 if( substr($childClassName, 0, strlen($moduleName) + 1 ) == $moduleName . '_' ){ 280 $childModuleIndex = $jj; 281 } 282 } 283 284 if( ($parentModuleIndex >= 0) && ($childModuleIndex >= 0) ){ 285 break; 286 } 287 } 288 289 $classesToModules[$parentClassName] = $parentModuleIndex; 290 $classesToModules[$childClassName] = $childModuleIndex; 291 } 292 293 if( $parentModuleIndex == -1 ){ 294 echo __CLASS__ . ': module is unknown for ' . $parentClassName . '<br>'; 295 _print_r( $this->appModules ); 296 exit; 297 } 298 299 if( $childModuleIndex == -1 ){ 300 echo __CLASS__ . ': module is unknown for ' . $childClassName . '<br>'; 301 _print_r( $this->appModules ); 302 exit; 303 } 304 305 // echo "$parentClassName:$parentModuleIndex VS $childClassName:$childModuleIndex<br>"; 306 // _print_r( $this->appModules ); 307 308 $return = ( $parentModuleIndex >= $childModuleIndex ); 309 310 if( ! $return ){ 311 // echo "$parentClassName:$parentModuleIndex VS $childClassName:$childModuleIndex<br>"; 312 // _print_r( $this->appModules ); 313 } 314 315 return $return; 316 } 317 } -
z-inventory-manager/trunk/hc4/app/functions.php
r2107074 r2149267 214 214 } 215 215 216 public static function listFilesRecursive( $dirname ) 217 { 218 $return = array(); 219 $this_subfolders = static::listSubfolders( $dirname ); 220 foreach( $this_subfolders as $sf ){ 221 $subfolder_return = static::listFilesRecursive( $dirname . '/' . $sf ); 222 foreach( $subfolder_return as $sfr ){ 223 $return[] = $sf . '/' . $sfr; 224 } 225 } 226 227 $this_files = static::listFiles( $dirname ); 228 $return = array_merge( $return, $this_files ); 229 return $return; 230 } 231 232 public static function listSubfolders( $dirName ) 233 { 234 if( ! is_array($dirName) ) 235 $dirName = array( $dirName ); 236 237 $return = array(); 238 reset( $dirName ); 239 foreach( $dirName as $thisDirName ){ 240 if ( file_exists($thisDirName) && ($handle = opendir($thisDirName)) ){ 241 while ( false !== ($f = readdir($handle)) ){ 242 if( substr($f, 0, 1) == '.' ) 243 continue; 244 if( is_dir( $thisDirName . '/' . $f ) ){ 245 if( ! in_array($f, $return) ) 246 $return[] = $f; 247 } 248 } 249 closedir($handle); 250 } 251 } 252 253 sort( $return ); 254 return $return; 255 } 256 216 257 public static function makeCombos( $array ) 217 258 { … … 240 281 } 241 282 242 public static function getCombinations( array $options )283 public static function getCombinations( array $options, $withNull = FALSE, $withTotalNull = FALSE ) 243 284 { 244 285 $combinations = array( array() ); … … 250 291 $tmp[] = array_merge( $v1, array($v2) ); 251 292 } 293 if( $withNull ){ 294 $tmp[] = $v1; 295 } 252 296 } 253 297 $combinations = $tmp; 254 298 } 299 300 if( $withNull && (! $withTotalNull) ){ 301 $combinations = array_filter( $combinations, function($e){ 302 return count($e); 303 }); 304 } 305 306 // remove duplicates 307 $combinations = array_filter( $combinations, function($e){ 308 $ok = TRUE; 309 $count = count($e); 310 for( $ii = 0; $ii < ($count - 1); $ii++ ){ 311 for( $jj = ($ii + 1); $jj < $count; $jj++ ){ 312 if( $e[$ii] === $e[$jj] ){ 313 $ok = FALSE; 314 break; 315 } 316 } 317 if( ! $ok ){ 318 break; 319 } 320 } 321 return $ok; 322 }); 255 323 256 324 return $combinations; -
z-inventory-manager/trunk/hc4/app/profiler.php
r2107074 r2149267 4 4 private $benchmark = NULL; 5 5 protected $_available_sections = array( 6 'handlers', 6 7 'benchmarks', 7 8 'memory_usage', 8 'uri_string',9 'controller_info',10 9 'queries', 11 10 'events', 11 'factory', 12 12 'get', 13 13 'post', … … 22 22 protected $lastQuery = array(); 23 23 protected $events = array(); 24 protected $factory = array(); 25 protected $handlers = array(); 24 26 25 27 public function __construct() … … 39 41 { 40 42 $this->events[] = array( $event, $handler ); 43 return $this; 44 } 45 46 public function markFactory( $className ) 47 { 48 $this->factory[] = $className; 49 return $this; 50 } 51 52 public function markHandler( $handler ) 53 { 54 $this->handlers[] = $handler; 41 55 return $this; 42 56 } … … 103 117 $output .= "\n\n<table style='width:100%;'>\n"; 104 118 105 $decimals = 4;119 $decimals = 6; 106 120 $total = $profile['total'][0]; 107 121 reset( $profile ); … … 266 280 } 267 281 268 protected function _compile_uri_string()269 {270 return;271 $output = "\n\n";272 $output .= '<fieldset id="ci_profiler_uri_string" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';273 $output .= "\n";274 $output .= '<legend style="color:#000;"> '.'profiler_uri_string'.' </legend>';275 $output .= "\n";276 277 if ($this->CI->uri->uri_string == ''){278 $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".'profiler_no_uri'."</div>";279 }280 else {281 $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->uri->uri_string."</div>";282 }283 284 $output .= "</fieldset>";285 return $output;286 }287 288 protected function _compile_controller_info()289 {290 return;291 $output = "\n\n";292 $output .= '<fieldset id="ci_profiler_controller_info" style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';293 $output .= "\n";294 $output .= '<legend style="color:#995300;"> '.'profiler_controller_info'.' </legend>';295 $output .= "\n";296 297 $output .= "<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class()."/".$this->CI->router->fetch_method()."</div>";298 299 $output .= "</fieldset>";300 301 return $output;302 }303 304 282 protected function _compile_memory_usage() 305 283 { … … 370 348 $output .= "\n\n<table style='width:100%; border:none'>\n"; 371 349 350 // foreach ( $this->events as $e ){ 351 // list( $eventName, $handlerName ) = $e; 352 // $output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>".$eventName." </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>"; 353 // $output .= $handlerName; 354 // $output .= "</td></tr>\n"; 355 // } 356 357 $events = array(); 372 358 foreach ( $this->events as $e ){ 373 359 list( $eventName, $handlerName ) = $e; 374 375 $output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>".$eventName." </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>"; 360 $key = $eventName . '-' . $handlerName; 361 if( ! isset($events[$key]) ){ 362 $events[$key] = 0; 363 } 364 $events[$key]++; 365 } 366 367 foreach ( $events as $key => $count ){ 368 list( $eventName, $handlerName ) = explode( '-', $key ); 369 $viewEventName = $eventName; 370 if( $count > 1 ){ 371 $viewEventName .= ' [' . $count . ']'; 372 } 373 $output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>".$viewEventName." </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>"; 376 374 $output .= $handlerName; 377 375 $output .= "</td></tr>\n"; … … 380 378 $output .= "</table>\n"; 381 379 } 380 $output .= "</fieldset>"; 381 382 return $output; 383 } 384 385 protected function _compile_factory() 386 { 387 $output = "\n\n"; 388 $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 $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 382 425 $output .= "</fieldset>"; 383 426 … … 438 481 public function markEnd( $name ) 439 482 { 440 $this->marker[$name] += microtime( TRUE ); 483 if( isset($this->marker[$name]) ){ 484 $this->marker[$name] += microtime( TRUE ); 485 } 441 486 } 442 487 -
z-inventory-manager/trunk/hc4/app/request.php
r2061857 r2149267 45 45 } 46 46 47 return $return; 48 } 49 50 public function getGet() 51 { 52 $return = array(); 53 foreach( array_keys($_GET) as $key ){ 54 $return[$key] = $this->_fetch_from_array($_GET, $key); 55 } 47 56 return $return; 48 57 } -
z-inventory-manager/trunk/hc4/app/router.php
r2107074 r2149267 2 2 interface HC4_App_Router_ 3 3 { 4 public function add( $methodSlug, $handler ); 5 public function find( $method, $slug ); 4 public function add( $contextRoute, $handler ); 5 public function alias( $alias, $real ); 6 public function close( array $contexts = array() ); 7 public function find( $context, $slug, $limit = NULL ); 6 8 } 7 9 … … 9 11 { 10 12 protected $routes = array(); 13 protected $aliases = array(); 14 protected $closed = FALSE; 11 15 12 16 public function __construct( 17 HC4_App_Profiler $profiler 13 18 ) 14 19 {} 15 20 16 protected function _prepare( $methodSlug, $handler ) 17 { 18 $methodSlugArray = explode( '/', $methodSlug, 2 ); 19 $method = array_shift( $methodSlugArray ); 20 $slug = array_shift( $methodSlugArray ); 21 $method = strtolower( $method ); 22 $return = array( $method, $slug, $handler ); 23 return $return; 24 } 25 26 public function add( $methodSlug, $handler ) 27 { 28 $add = $this->_prepare( $methodSlug, $handler ); 29 $this->routes[] = $add; 30 return $this; 21 public function find( $context, $slug, $limit = NULL ) 22 { 23 if( ! $this->closed ){ 24 $this->close(); 25 } 26 27 // $this->profiler->markStart( __METHOD__ ); 28 29 $return = array(); 30 $context = strtoupper( $context ); 31 32 if( ! isset($this->routes[$context]) ){ 33 $this->profiler->markEnd( __METHOD__ ); 34 return $return; 35 } 36 37 // if( 'LAYOUT' === $context ){ 38 // echo "GOT RESULTS"; 39 // _print_r( $this->routes[$context] ); 40 // exit; 41 // } 42 43 reset( $this->routes[$context] ); 44 foreach( $this->routes[$context] as $r ){ 45 list( $thisRoute, $thisHandler ) = $r; 46 47 $ok = FALSE; 48 // re? 49 if( '%' == substr($thisRoute, 0, 1) ){ 50 if( preg_match($thisRoute, $slug, $params) ){ 51 $ok = TRUE; 52 array_shift( $params ); 53 } 54 } 55 else { 56 if( $thisRoute == $slug ){ 57 $ok = TRUE; 58 $params = array(); 59 } 60 } 61 62 if( ! $ok ){ 63 continue; 64 } 65 66 $return[] = array( $thisHandler, $params ); 67 68 if( (NULL !== $limit) && ($limit >= count($return)) ){ 69 break; 70 } 71 } 72 73 // $this->profiler->markEnd( __METHOD__ ); 74 return $return; 75 } 76 77 public function add( $contextRoute, $handler ) 78 { 79 if( $this->closed ){ 80 echo __CLASS__ . ': closed for new routes<br>'; 81 return; 82 } 83 84 list( $context, $route ) = $this->_prepareContextRoute( $contextRoute ); 85 86 if( ! isset($this->routes[$context]) ){ 87 $this->routes[$context] = array(); 88 } 89 $this->routes[$context][] = array( $route, $handler ); 90 91 return $this; 92 } 93 94 public function prepend( $contextRoute, $handler ) 95 { 96 if( $this->closed ){ 97 echo __CLASS__ . ': closed for new routes<br>'; 98 return; 99 } 100 101 list( $context, $route ) = $this->_prepareContextRoute( $contextRoute ); 102 103 if( ! isset($this->routes[$context]) ){ 104 $this->routes[$context] = array(); 105 } 106 array_unshift( $this->routes[$context], array( $route, $handler) ); 107 108 return $this; 109 } 110 111 protected function _prepareContextRoute( $contextRoute ) 112 { 113 $contextRouteArray = explode( '/', $contextRoute, 2 ); 114 $context = $contextRouteArray[0]; 115 $route = isset($contextRouteArray[1]) ? $contextRouteArray[1] : ''; 116 $return = array( $context, $route ); 117 return $return; 31 118 } 32 119 33 120 public function alias( $alias, $real ) 34 121 { 35 reset( $this->routes ); 36 foreach( $this->routes as $r ){ 37 list( $thisMethod, $thisRoute, $thisHandler ) = $r; 38 $first = strpos($thisRoute, '{'); 122 if( ! isset($this->aliases[$alias]) ){ 123 $this->aliases[$alias] = array(); 124 } 125 $this->aliases[$alias][] = $real; 126 return $this; 127 } 128 129 /* if we close then it 1) expands aliases; 2) gets unavailable for adding new routes */ 130 public function close( array $contexts = array() ) 131 { 132 $this->profiler->markStart( __METHOD__ ); 133 $this->closed = TRUE; 134 135 if( ! $contexts ){ 136 $contexts = array_keys( $this->routes ); 137 } 138 139 // expand aliases 140 foreach( $contexts as $context ){ 141 $count = count( $this->routes[$context] ); 142 for( $ii = ($count - 1); $ii >= 0; $ii-- ){ 143 list( $thisRoute, $thisHandler ) = $this->routes[$context][$ii]; 144 145 $first = strpos( $thisRoute, '{' ); 146 if( FALSE === $first ){ 147 // not aliased 148 continue; 149 } 150 151 $realRoutes = $this->expandAlias( $thisRoute ); 152 $expandedRoutes = array(); 153 foreach( $realRoutes as $realRoute ){ 154 $expandedRoutes[] = array( $realRoute, $thisHandler ); 155 } 156 157 array_splice( $this->routes[$context], $ii, 1, $expandedRoutes ); 158 } 159 } 160 161 // convert to re's where needed 162 foreach( $contexts as $context ){ 163 $count = count( $this->routes[$context] ); 164 for( $ii = ($count - 1); $ii >= 0; $ii-- ){ 165 list( $thisRoute, $thisHandler ) = $this->routes[$context][$ii]; 166 167 if( (FALSE !== strpos($thisRoute, ':')) OR (FALSE !== strpos($thisRoute, '*')) ){ 168 $re = $this->makeRe($thisRoute); 169 $this->routes[$context][$ii][0] = $re; 170 } 171 } 172 } 173 174 $this->profiler->markEnd( __METHOD__ ); 175 return $this; 176 } 177 178 public function makeRe( $route ) 179 { 180 static $cache = array(); 181 182 if( isset($cache[$route]) ){ 183 return $cache[$route]; 184 } 185 186 $return = $route; 187 188 if( '*' === $return ){ 189 $return = '.*'; 190 } 191 else { 192 $return = str_replace( '*', '.+', $return ); 193 $return = str_replace( '[', '(', $return ); 194 $return = str_replace( ']', ')', $return ); 195 196 // $re = str_replace( ':id', '[\w\-]+', $return ); 197 $return = str_replace( ':id', '[\d\_\-]+', $return ); 198 // find :param like things 199 $return = preg_replace( '/\:(\w+)/', '[^\/]+', $return ); 200 } 201 202 $return = '%^' . $return . '$%'; 203 204 $cache[$route] = $return; 205 return $return; 206 } 207 208 public function expandAlias( $route ) 209 { 210 static $cache = array(); 211 if( isset($cache[$route]) ){ 212 return $cache[$route]; 213 } 214 215 $return = array(); 216 217 $first = strpos( $route, '{' ); 218 $second = strpos( $route, '}', $first ); 219 $alias = substr( $route, $first, $second - $first + 1 ); 220 221 if( ! isset($this->aliases[$alias]) ){ 222 return $return; 223 } 224 225 reset( $this->aliases[$alias] ); 226 foreach( $this->aliases[$alias] as $aliasReplace ){ 227 $realRoute = substr_replace( $route, $aliasReplace, $first, $second - $first + 1 ); 228 229 // no more aliases 230 $first = strpos( $realRoute, '{' ); 39 231 if( FALSE === $first ){ 40 continue; 41 } 42 $second = strpos($thisRoute, '}', $first); 43 $thisAlias = substr( $thisRoute, $first, $second - $first + 1 ); 44 if( $thisAlias != $alias ){ 45 continue; 46 } 47 48 $realThisRoute = substr_replace( $thisRoute, $real, $first, $second - $first + 1 ); 49 50 $add = array( $thisMethod, $realThisRoute, $thisHandler ); 51 $this->routes[] = $add; 52 } 53 54 return $this; 55 } 56 57 public function prepend( $methodSlug, $handler ) 58 { 59 $add = $this->_prepare( $methodSlug, $handler ); 60 array_unshift( $this->routes, $add ); 61 return $this; 62 } 63 64 public function find( $method, $slug ) 65 { 66 $return = array(); 67 $method = strtolower( $method ); 68 69 reset( $this->routes ); 70 foreach( $this->routes as $r ){ 71 list( $thisMethod, $thisRoute, $thisHandler ) = $r; 72 73 if( $thisMethod != $method ){ 74 continue; 75 } 76 77 // convert to re 78 $re = $thisRoute; 79 80 // find #href like things 81 $hash = NULL; 82 $hashPos = strpos( $re, '#' ); 83 if( FALSE !== $hashPos ){ 84 $hash = substr( $re, $hashPos + 1 ); 85 $re = substr( $re, 0, $hashPos ); 86 } 87 88 $re = str_replace( '[', '(', $re ); 89 $re = str_replace( ']', ')', $re ); 90 $re = str_replace( '*', '.+', $re ); 91 92 // $re = str_replace( ':id', '[\w\-]+', $re ); 93 $re = str_replace( ':id', '[\d\_\-]+', $re ); 94 // find :param like things 95 $re = preg_replace( '/\:(\w+)/', '[^\/]+', $re ); 96 97 $re = '%^' . $re . '$%'; 98 99 if( ! preg_match($re, $slug, $matches) ){ 100 continue; 101 } 102 103 // echo "BINGO!<br>"; 104 // _print_r( $matches ); 105 106 array_shift( $matches ); 107 108 $i = $hash ? $hash : count($return); 109 $return[ $i ] = array( $thisHandler, $matches ); 110 } 111 232 $return[] = $realRoute; 233 } 234 else { 235 $realRoutes = $this->expandAlias( $realRoute ); 236 $return = array_merge( $return, $realRoutes ); 237 } 238 } 239 240 $cache[$route] = $return; 112 241 return $return; 113 242 } -
z-inventory-manager/trunk/hc4/app/uri.php
r2061857 r2149267 185 185 186 186 if( isset($_SERVER['HTTP_HOST']) && $_SERVER['SERVER_PORT'] != '80'){ 187 $return .= $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT']; 187 if( FALSE === strpos($_SERVER['HTTP_HOST'], ':') ){ 188 $return .= $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT']; 189 } 190 else { 191 $return .= $_SERVER['HTTP_HOST']; 192 } 188 193 } 189 194 else { -
z-inventory-manager/trunk/hc4/database/boot.php
r2107074 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class HC4_Database_Boot 3 implements HC4_App_Module_Interface4 3 { 5 public static function bind ( array $appConfig )4 public static function bind2( array $appConfig ) 6 5 { 7 6 $bind = array(); -
z-inventory-manager/trunk/hc4/database/prefixed.php
r2107074 r2149267 6 6 public $prefix = NULL; 7 7 8 public function __construct( HC4_Database_Interface $db, $prefix ) 8 public function __construct( 9 HC4_Database_Interface $db, 10 $prefix 11 ) 9 12 { 10 13 $this->db = $db; -
z-inventory-manager/trunk/hc4/database/profiled.php
r2107074 r2149267 6 6 protected $profiler = NULL; 7 7 8 public function __construct( HC4_Database_Interface $db, HC4_App_Profiler $profiler ) 8 public function __construct( 9 HC4_Database_Interface $db, 10 HC4_App_Profiler $profiler 11 ) 9 12 { 10 13 $this->db = $db; -
z-inventory-manager/trunk/hc4/html/href/boot.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class HC4_Html_Href_Boot 3 implements HC4_App_Module_Interface4 3 { 5 public static function bind( array $appConfig )6 {7 $bind = array();8 9 $myAppName = $appConfig['app-name'];10 $myAppShortName = $appConfig['app-short-name'];11 12 $uri = new HC4_App_Uri;13 $currentSlug = $uri->getSlug();14 15 switch( $appConfig['platform'] ){16 case 'standalone':17 $template = $uri->makeUrl( '{SLUG}' );18 19 $templateGet = $template;20 $templatePost = $template;21 $templateApi = $template;22 23 // ASSETS24 $assetsWebDir = $uri->baseUrl();25 if( substr($assetsWebDir, -1) != '/' ){26 $test = explode('/', $assetsWebDir);27 $lastPart = array_pop( $test );28 if( strpos($lastPart, '.') !== FALSE ){29 $assetsWebDir = dirname( $assetsWebDir );30 }31 }32 if( substr($assetsWebDir, -1) != '/' ){33 $assetsWebDir = $assetsWebDir . '/';34 }35 $templateAsset = $assetsWebDir . '{SLUG}';36 37 break;38 39 case 'joomla':40 $template = $uri->makeUrl( '{SLUG}' );41 42 $templateGet = $template;43 $templatePost = $template;44 $templateApi = $template;45 46 // ASSETS47 $templateAsset = JUri::base() . 'components/com_' . $myAppName . '/' . '{SLUG}';48 break;49 50 case 'wordpress':51 $templateGet = $uri->makeUrl( '{SLUG}' );52 53 // API54 $url = parse_url( site_url('/') );55 56 $baseUrl = $url['scheme'] . '://'. $url['host'];57 if( isset($url['port']) && (80 != $url['port']) ){58 $baseUrl .= ':' . $url['port'];59 }60 $baseUrl .= $url['path'];61 62 $templateApi = $baseUrl;63 $templateApi .= (isset($url['query']) && $url['query']) ? '?' . $url['query'] . '&' : '?';64 $templateApi .= 'hcs=' . $myAppShortName . '&hca={SLUG}';65 66 // POST67 // $templatePost = $templateApi;68 $templatePost = $templateGet;69 $templatePost .= ( FALSE === strpos($templatePost, '?') ) ? '?' : '&';70 $templatePost .= 'hcs=' . $myAppShortName;71 72 // ASSETS73 $pluginFile = $appConfig['app-dir'] . '/' . $appConfig['app-name'];74 // $templateAsset = plugins_url( '{SLUG}', $appConfig['app-dir'] );75 $templateAsset = plugins_url( '{SLUG}', $pluginFile );76 break;77 }78 79 // OVERRIDE BY CONFIG FILE80 $templateAsset = array( '_' => $templateAsset );81 if( isset($appConfig['app-href-asset']) ){82 $templateAsset = array_merge( $templateAsset, $appConfig['app-href-asset'] );83 }84 85 $href = new HC4_Html_Href_Implementation( $currentSlug, $templateGet, $templatePost, $templateApi, $templateAsset );86 $bind['HC4_Html_Href_Interface'] = $href;87 88 return $bind;89 }90 4 } -
z-inventory-manager/trunk/hc4/html/input/boot.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class HC4_Html_Input_Boot 3 implements HC4_App_Module_Interface4 3 { 5 public static function bind( array $appConfig)4 public static function bind() 6 5 { 7 6 $bind = array(); 8 9 switch( $appConfig['platform'] ){ 10 case 'standalone': 11 $bind['HC4_Html_Input_RichTextarea'] = 'HC4_Html_Input_Textarea'; 12 break; 13 14 case 'joomla': 15 $bind['HC4_Html_Input_RichTextarea'] = 'HC4_Html_Input_Textarea'; 16 break; 17 18 case 'wordpress': 19 $bind['HC4_Html_Input_RichTextarea'] = 'HC4_Html_Input_WordPress_RichTextarea'; 20 break; 21 } 22 7 $bind['HC4_Html_Input_RichTextarea'] = 'HC4_Html_Input_Textarea'; 23 8 return $bind; 24 9 } -
z-inventory-manager/trunk/hc4/html/input/checkbox.php
r2107074 r2149267 12 12 13 13 $out = array(); 14 15 $out[] = '<label class="hc-block hc-xs-py1">'; 14 if( NULL !== $label ){ 15 $out[] = '<label class="hc-block hc-xs-py1 hc-magictoggle-container">'; 16 } 16 17 17 18 if( NULL !== $label ){ … … 19 20 } 20 21 21 $out[] = '<input type="checkbox" class="hc4-input-checkbox " name="' . $name . '" value="' . $k . '"';22 $out[] = '<input type="checkbox" class="hc4-input-checkbox hc-magictoggle-toggler" name="' . $name . '" value="' . $k . '"'; 22 23 if( $checked ){ 23 24 $out[] = ' checked="checked"'; … … 26 27 27 28 if( NULL !== $label ){ 28 $out[] = $label; 29 if( ! is_array($label) ){ 30 $labelOn = '<span class="">' . $label . '</span>'; 31 $labelOff = '<span class="hc-muted2">' . $label . '</span>'; 32 $label = array( $labelOn, $labelOff ); 33 } 34 35 if( is_array($label) ){ 36 $labelView = '<span class="hc-magictoggle-on">' . $label[0] . '</span><span class="hc-magictoggle-off">' . $label[1] . '</span>'; 37 } 38 else { 39 $labelView = $label; 40 } 41 // $out[] = $label; 42 $out[] = $labelView; 29 43 $out[] = '</span>'; 30 44 } 31 45 32 $out[] = '</label>'; 46 if( NULL !== $label ){ 47 $out[] = '</label>'; 48 } 33 49 34 50 $out = join( '', $out ); -
z-inventory-manager/trunk/hc4/html/input/checkboxdetails.php
r2107074 r2149267 10 10 public function render( $name, $value, $checked, $label, $details = NULL, $inverse = FALSE ) 11 11 { 12 $myId = 'hc4-input-checkboxdetails-' . HC4_App_Functions::generateRand( 2);12 $myId = 'hc4-input-checkboxdetails-' . HC4_App_Functions::generateRand(4); 13 13 14 14 $value = $this->helper->getValue( $name, $value ); … … 19 19 20 20 $out = array(); 21 if( ! $inverse ){ 22 $out[] = $checkboxView; 23 $out[] = $detailsView; 24 } 25 else { 26 $out[] = $detailsView; 27 $out[] = $checkboxView; 28 } 21 $out[] = $checkboxView; 22 $out[] = $detailsView; 23 24 // if( ! $inverse ){ 25 // $out[] = $checkboxView; 26 // $out[] = $detailsView; 27 // } 28 // else { 29 // $out[] = $detailsView; 30 // $out[] = $checkboxView; 31 // } 29 32 30 33 $out = join( '', $out ); -
z-inventory-manager/trunk/hc4/html/input/checkboxset.php
r2107074 r2149267 21 21 foreach( $options as $k => $label ){ 22 22 if( $inline ){ 23 $out[] = '<div class="hc-nowrap hc- lg-inline-block hc-lg-mr1">';23 $out[] = '<div class="hc-nowrap hc-inline-block hc-mr1">'; 24 24 } 25 25 else { -
z-inventory-manager/trunk/hc4/html/input/multiset.php
r2061857 r2149267 4 4 public function __construct( 5 5 HC4_Html_Input_Helper $helper, 6 HC4_Html_Input_RadioSet $inputRadioSet 6 HC4_Html_Input_RadioSet $inputRadioSet, 7 HC4_Html_Input_Radio $inputRadio 7 8 ) 8 9 {} … … 11 12 { 12 13 $myId = 'hc4-input-multiset-' . HC4_App_Functions::generateRand(2); 13 14 14 $value = $this->helper->getValue( $name, $value ); 15 16 $out = array();17 $out[] = $this->inputRadioSet->renderInline( $name, $labels, $value );18 19 foreach( $options as $k => $v ){20 $out[] = '<div class="hc4-input-multiset-detail hc4-input-multiset-detail-' . $k . '">';21 $out[] = $v;22 $out[] = '</div>';23 }24 25 $out = join( '', $out );26 $out = $this->helper->afterRender( $name, $out );27 15 28 16 ob_start(); … … 30 18 31 19 <div id="<?php echo $myId; ?>"> 32 <?php echo $out; ?> 20 <?php echo $this->inputRadioSet->renderInline( $name, $labels, $value, 'hc4-input-multiset-toggler' ); ?> 21 22 <?php foreach( $options as $k => $v ): ?> 23 <div class="hc4-input-multiset-detail hc4-input-multiset-detail-<?php echo $k; ?>"> 24 <?php echo $v; ?> 25 </div> 26 <?php endforeach; ?> 27 33 28 </div> 29 <?php echo $this->renderJs( $myId ); ?> 30 31 <?php 32 $return = ob_get_clean(); 33 $return = $this->helper->afterRender( $name, $return ); 34 return $return; 35 } 36 37 public function renderList( $name, array $labels, array $options, $value = NULL ) 38 { 39 $myId = 'hc4-input-multiset-' . HC4_App_Functions::generateRand(2); 40 $value = $this->helper->getValue( $name, $value ); 41 42 ob_start(); 43 ?> 44 45 <div id="<?php echo $myId; ?>"> 46 47 <?php foreach( $labels as $k => $label ): ?> 48 <?php $checked = ($k == $value) ? TRUE : FALSE; ?> 49 <?php echo $this->inputRadio->render( $name, $k, $checked, $label, 'hc4-input-multiset-toggler' ); ?> 50 <div class="hc4-input-multiset-detail hc4-input-multiset-detail-<?php echo $k; ?>"> 51 <?php echo $options[$k]; ?> 52 </div> 53 <?php endforeach; ?> 54 55 </div> 56 <?php echo $this->renderJs( $myId ); ?> 57 58 <?php 59 $return = ob_get_clean(); 60 $return = $this->helper->afterRender( $name, $return ); 61 return $return; 62 } 63 64 public function renderJs( $myId ) 65 { 66 ob_start(); 67 ?> 34 68 35 69 <script> … … 38 72 function MultiSetInput( el ){ 39 73 var ii = 0, jj = 0; 40 var togglers = el.getElementsByClassName( 'hc4-input- radio' );74 var togglers = el.getElementsByClassName( 'hc4-input-multiset-toggler' ); 41 75 var details = el.getElementsByClassName( 'hc4-input-multiset-detail' ); 42 76 … … 69 103 </script> 70 104 71 72 105 <?php 73 106 return ob_get_clean(); -
z-inventory-manager/trunk/hc4/html/input/radio.php
r2107074 r2149267 7 7 {} 8 8 9 public function render( $name, $k, $checked = FALSE, $label = NULL )9 public function render( $name, $k, $checked = FALSE, $label = NULL, $moreClass = '' ) 10 10 { 11 11 // $checked = $this->helper->getValue( $name, $checked ); … … 19 19 } 20 20 21 $out[] = '<input type="radio" class="hc4-input-radio" name="' . $name . '" value="' . $k . '"'; 21 $class = 'hc4-input-radio'; 22 if( $moreClass ){ 23 $class .= ' ' . $moreClass; 24 } 25 26 $out[] = '<input type="radio" class="' . $class . '" name="' . $name . '" value="' . $k . '"'; 22 27 if( $checked ){ 23 28 $out[] = ' checked="checked"'; -
z-inventory-manager/trunk/hc4/html/input/radioset.php
r2107074 r2149267 8 8 {} 9 9 10 public function renderInline( $name, array $options = array(), $value = NULL )10 public function renderInline( $name, array $options = array(), $value = NULL, $moreClass = '' ) 11 11 { 12 return $this->render( $name, $options, $value, TRUE );12 return $this->render( $name, $options, $value, TRUE, $moreClass ); 13 13 } 14 14 15 public function render( $name, array $options = array(), $value = NULL, $inline = FALSE )15 public function render( $name, array $options = array(), $value = NULL, $inline = FALSE, $moreClass = '' ) 16 16 { 17 17 $value = $this->helper->getValue( $name, $value ); … … 21 21 foreach( $options as $k => $label ){ 22 22 if( $inline ){ 23 $out[] = '<div class="hc-nowrap hc- lg-inline-block hc-lg-mr1">';23 $out[] = '<div class="hc-nowrap hc-inline-block hc-mr1">'; 24 24 } 25 25 else { … … 28 28 29 29 $checked = ( ($value == $k) && (strlen($value) == strlen($k)) ) ? TRUE : FALSE; 30 $out[] = $this->inputRadio->render( $name, $k, $checked, $label );30 $out[] = $this->inputRadio->render( $name, $k, $checked, $label, $moreClass ); 31 31 32 32 $out[] = '</div>'; -
z-inventory-manager/trunk/hc4/html/input/text.php
r2061857 r2149267 7 7 {} 8 8 9 public function render( $name, $value = NULL )9 public function render( $name, $value = NULL, $size = NULL ) 10 10 { 11 11 $value = $this->helper->getValue( $name, $value ); 12 13 $out = '<input type="text" name="' . $name . '" value="' . $value . '" class="hc4-form-input">'; 14 12 $out = '<input type="text" name="' . $name . '" value="' . $value . '" class="hc4-form-input"'; 13 if( NULL !== $size ){ 14 $out .= ' size="' . $size . '" style="width: ' . ($size + 1) . 'em;"'; 15 } 16 $out .= '>'; 15 17 $out = $this->helper->afterRender( $name, $out ); 16 17 18 return $out; 18 19 } -
z-inventory-manager/trunk/hc4/html/input/wordpress/richtextarea.php
r2061857 r2149267 11 11 { 12 12 $value = $this->helper->getValue( $name, $value ); 13 14 // $out = '<input type="text" name="' . $name . '" value="' . $value . '" class="hc4-form-input">';15 13 16 14 $wpEditorSettings = array(); … … 31 29 ); 32 30 33 if( 0 ){ 34 $more_js = <<<EOT 35 <script type="text/javascript"> 36 var str = nts_tinyMCEPreInit.replace(/nts_wp_editor/gi, '$editor_id'); 37 var ajax_tinymce_init = JSON.parse(str); 38 39 tinymce.init( ajax_tinymce_init.mceInit['$editor_id'] ); 40 </script> 41 EOT; 42 43 // _WP_Editors::enqueue_scripts(); 44 // print_footer_scripts(); 45 // _WP_Editors::editor_js(); 46 echo $more_js; 47 } 31 // _WP_Editors::enqueue_scripts(); 32 // _WP_Editors::editor_js(); 48 33 49 34 $out = ob_get_clean(); … … 53 38 return $out; 54 39 } 55 56 public function render2()57 {58 $wpEditorSettings = array();59 $wpEditorSettings['textarea_name'] = $this->htmlName();60 61 $rows = $this->getAttr('rows');62 if( $rows ){63 $wpEditorSettings['textarea_rows'] = $rows;64 }65 66 // stupid wp, it outputs it right away67 ob_start();68 69 $editorId = $this->htmlId();70 wp_editor(71 $this->value,72 $editorId,73 $wpEditorSettings74 );75 76 if( 0 )77 {78 $more_js = <<<EOT79 <script type="text/javascript">80 var str = nts_tinyMCEPreInit.replace(/nts_wp_editor/gi, '$editor_id');81 var ajax_tinymce_init = JSON.parse(str);82 83 tinymce.init( ajax_tinymce_init.mceInit['$editor_id'] );84 </script>85 EOT;86 87 // _WP_Editors::enqueue_scripts();88 // print_footer_scripts();89 // _WP_Editors::editor_js();90 echo $more_js;91 }92 93 $out = ob_get_clean();94 return $out;95 96 97 98 99 $out = $this->htmlFactory->makeElement('input')100 ->addAttr('type', 'text' )101 ->addAttr('name', $this->htmlName() )102 ->addAttr('class', 'hc-field')103 // ->addAttr('class', 'hc-block')104 ->addAttr('class', 'hc-full-width')105 ;106 107 if( strlen($this->value) ){108 $out->addAttr('value', $this->value);109 }110 111 $attr = $this->getAttr();112 foreach( $attr as $k => $v ){113 $out->addAttr( $k, $v );114 }115 116 $out->addAttr('id', $this->htmlId());117 118 if( strlen($this->label) ){119 $out120 ->addAttr('placeholder', $this->label)121 ;122 }123 124 if( $this->bold ){125 $out126 ->addAttr('class', 'hc-fs5')127 ;128 }129 130 if( strlen($this->label) && (! $this->bold) ){131 $label = $this->htmlFactory->makeElement('label', $this->label)132 ->addAttr('for', $this->htmlId())133 ->addAttr('class', 'hc-fs2')134 ;135 $out = $this->htmlFactory->makeList( array($label, $out) );136 // $out = $this->htmlFactory->makeCollection( array($label, $out) );137 }138 139 return $out;140 }141 40 } -
z-inventory-manager/trunk/hc4/html/screen/abstract.php
r2107074 r2149267 2 2 abstract class HC4_Html_Screen_Abstract 3 3 { 4 protected $css = array(); 5 protected $js = array(); 6 protected $title = array(); 7 protected $subheader = array(); 8 protected $subfooter = array(); 9 protected $breadcrumbTitle = array(); 10 protected $breadcrumb = array(); 11 protected $layout = array(); 12 protected $menu = array(); 13 protected $partials = array(); 4 public function renderWidget( $slug, $return, $isAjax = FALSE ) 5 { 6 $this->profiler->markStart( __METHOD__ ); 14 7 15 public function alias( $alias, $real )16 {17 $this->css = $this->_alias( $alias, $real, $this->css );18 $this->js = $this->_alias( $alias, $real, $this->js );19 $this->title = $this->_alias( $alias, $real, $this->title );20 $this->subheader = $this->_alias( $alias, $real, $this->subheader );21 $this->subfooter = $this->_alias( $alias, $real, $this->subfooter );22 $this->breadcrumbTitle = $this->_alias( $alias, $real, $this->breadcrumbTitle );23 $this->breadcrumb = $this->_alias( $alias, $real, $this->breadcrumb );24 $this->layout = $this->_alias( $alias, $real, $this->layout );25 $this->menu = $this->_alias( $alias, $real, $this->menu );26 27 return $this;28 }29 30 public function _alias( $alias, $real, array $routes )31 {32 reset( $routes );33 foreach( $routes as $r ){34 list( $thisRoute, $thisHandler ) = $r;35 $first = strpos($thisRoute, '{');36 if( FALSE === $first ){37 continue;38 }39 $second = strpos($thisRoute, '}', $first);40 $thisAlias = substr( $thisRoute, $first, $second - $first + 1 );41 if( $thisAlias != $alias ){42 continue;43 }44 45 $realThisRoute = substr_replace( $thisRoute, $real, $first, $second - $first + 1 );46 47 $add = array( $realThisRoute, $thisHandler );48 $routes[] = $add;49 }50 51 return $routes;52 }53 54 public function css( $slugPreg, $path, $onlyFullScreen = FALSE )55 {56 $this->css[] = array( $slugPreg, $path, $onlyFullScreen );57 return $this;58 }59 60 public function js( $slugPreg, $path )61 {62 $this->js[] = array( $slugPreg, $path );63 return $this;64 }65 66 public function subheader( $slugPreg, $value )67 {68 $this->subheader[] = array( $slugPreg, $value );69 return $this;70 }71 72 public function subfooter( $slugPreg, $value )73 {74 $this->subfooter[] = array( $slugPreg, $value );75 return $this;76 }77 78 public function title( $slugPreg, $value )79 {80 $this->title[] = array( $slugPreg, $value );81 return $this;82 }83 84 public function breadcrumbTitle( $slugPreg, $value )85 {86 $this->breadcrumbTitle[] = array( $slugPreg, $value );87 return $this;88 }89 90 public function breadcrumb( $slugPreg, $value )91 {92 $this->breadcrumb[] = array( $slugPreg, $value );93 return $this;94 }95 96 public function layout( $slugPreg, $layout )97 {98 $this->layout[] = array( $slugPreg, $layout );99 return $this;100 }101 102 public function menu( $slugPreg, $menuLink )103 {104 $this->menu[] = array( $slugPreg, $menuLink );105 return $this;106 }107 108 public function partial( $slugPreg, $partialSlug )109 {110 $this->partials[] = array( $slugPreg, $partialSlug );111 return $this;112 }113 114 public function getCss( $slug, $noFullScreen = FALSE )115 {116 $return = array();117 118 $allReturn = $this->_find( $this->css, $slug, TRUE );119 foreach( $allReturn as $e ){120 list( $e, $thisFullScreen ) = $e;121 122 if( (! $noFullScreen) OR (! $thisFullScreen) ){123 $return[] = $e;124 }125 }126 127 return $return;128 }129 130 public function getJs( $slug )131 {132 return $this->_find( $this->js, $slug, TRUE );133 }134 135 public function getTitle( $slug )136 {137 return $this->_find( $this->title, $slug, FALSE );138 }139 140 public function getSubheader( $slug )141 {142 return $this->_find( $this->subheader, $slug, FALSE, 'passslug' );143 }144 145 public function getSubfooter( $slug )146 {147 return $this->_find( $this->subfooter, $slug, FALSE, 'passslug' );148 }149 150 public function getBreadcrumbTitle( $slug )151 {152 return $this->_find( $this->breadcrumbTitle, $slug, FALSE );153 }154 155 public function getLayout( $slug )156 {157 return $this->_find( $this->layout, $slug, FALSE );158 }159 160 public function getMenu( $slug )161 {162 $rawReturn = $this->_find( $this->menu, $slug, TRUE, 'passslug' );163 164 $return = array();165 // straight out166 foreach( $rawReturn as $rm ){167 if( isset($rm[0]) && is_array($rm[0]) ){168 foreach( $rm as $rm2 ){169 $return[] = $rm2;170 }171 }172 else {173 $return[] = $rm;174 }175 }176 177 // priority178 $order = 100;179 $count = count( $return );180 for( $ii = 0; $ii < $count; $ii++ ){181 if( ! isset($return[$ii][2]) ){182 $return[$ii][2] = $order++;183 }184 }185 186 usort( $return, function($a, $b){187 return ( $a[2] > $b[2] );188 });189 190 // _print_r( $return );191 return $return;192 }193 194 public function getPartials( $slug )195 {196 return $this->_find( $this->partials, $slug, TRUE );197 }198 199 public function getBreadcrumb( $slug )200 {201 $return = array();202 if( ! $slug ){203 return $return;204 }205 206 $explicitParent = $this->getBreadcrumbExplicit( $slug );207 if( $explicitParent ){208 $parentSlug = $explicitParent;209 }210 else {211 $fullSlug = $slug;212 // if( $slug ){213 // $fullSlug = '/' . $slug;214 // }215 $slugParts = explode( '/', $fullSlug );216 array_pop( $slugParts );217 $parentSlug = join( '/', $slugParts );218 }219 220 $thisTitle = $this->getBreadcrumbTitle( $parentSlug );221 if( NULL === $thisTitle ){222 $thisTitle = $this->getTitle( $parentSlug );223 }224 225 if( $thisTitle ){226 if( is_array($thisTitle) ){227 $thisTitle = $thisTitle[0];228 $thisTitle = strip_tags( $thisTitle );229 }230 $return[] = array( $parentSlug, $thisTitle );231 }232 233 $parentReturn = $this->getBreadcrumb( $parentSlug );234 $return = array_merge( $parentReturn, $return );235 return $return;236 }237 238 public function getBreadcrumbOld( $slug )239 {240 $return = array();241 242 $explicit = $this->getBreadcrumbExplicit( $slug );243 if( $explicit ){244 $return = $this->getBreadcrumb( $explicit );245 246 $thisTitle = $this->getBreadcrumbTitle( $explicit );247 if( NULL === $thisTitle ){248 $thisTitle = $this->getTitle( $explicit );249 }250 251 if( $thisTitle ){252 if( is_array($thisTitle) ){253 $thisTitle = $thisTitle[0];254 $thisTitle = strip_tags( $thisTitle );255 }256 $return[] = array( $explicit, $thisTitle );257 }258 return $return;259 }260 261 $fullSlug = $slug;262 if( $slug ){263 $fullSlug = '/' . $slug;264 }265 266 $slugParts = explode( '/', $fullSlug );267 array_pop( $slugParts );268 269 $thisSlug = '';270 while( $slugParts ){271 $addPart = array_shift( $slugParts );272 if( $thisSlug ){273 $thisSlug .= '/';274 }275 $thisSlug .= $addPart;276 277 $thisTitle = $this->getBreadcrumbTitle( $thisSlug );278 if( NULL === $thisTitle ){279 $thisTitle = $this->getTitle( $thisSlug );280 }281 282 // $explicit = $this->getBreadcrumbExplicit( $thisSlug );283 // if( $explicit ){284 // $return = array_merge( $return, $explicit );285 // }286 287 if( $thisTitle ){288 if( is_array($thisTitle) ){289 // $thisTitle = join( ' ', $thisTitle );290 $thisTitle = $thisTitle[0];291 $thisTitle = strip_tags( $thisTitle );292 }293 $return[] = array( $thisSlug, $thisTitle );294 }295 }296 297 return $return;298 }299 300 public function getBreadcrumbExplicit( $slug )301 {302 $return = $this->_find( $this->breadcrumb, $slug, FALSE, 'passslug' );303 return $return;304 }305 306 protected function _find( array $routes, $slug, $many = FALSE, $passSlug = FALSE )307 {308 $return = $many ? array() : NULL;309 310 reset( $routes );311 foreach( $routes as $r ){312 $thisRoute = $r[0];313 314 // convert to re315 $re = $thisRoute;316 317 $re = str_replace( '[', '(', $re );318 $re = str_replace( ']', ')', $re );319 $re = str_replace( '*', '.*', $re );320 321 // $re = str_replace( ':id', '[\w\-]+', $re );322 $re = str_replace( ':id', '[\d\_\-]+', $re );323 // find :param like things324 $re = preg_replace( '/\:(\w+)/', '[^\/]+', $re );325 $re = '%^' . $re . '$%';326 327 // $re = '#' . $thisRoute . '#';328 if( ! preg_match($re, $slug, $matches) ){329 continue;330 }331 332 if( count($r) > 2 ){333 $thisOne = array_slice( $r, 1 );334 }335 else {336 $thisOne = $r[1];337 }338 339 if( $passSlug ){340 array_unshift( $matches, $slug );341 }342 343 if( is_array($thisOne) ){344 $keys = array_keys( $thisOne );345 foreach( $keys as $k ){346 $thisOne[$k] = $this->_processOne( $thisOne[$k], $matches );347 }348 }349 else {350 $thisOne = $this->_processOne( $thisOne, $matches );351 }352 353 // array_shift( $matches );354 // $return[] = array( $thisHandler, $matches );355 356 if( $many ){357 if( $thisOne ){358 $return[] = $thisOne;359 }360 }361 else {362 $return = $thisOne;363 break;364 }365 }366 367 return $return;368 }369 370 protected function _processOne( $thisOne, array $matches )371 {372 if( strpos($thisOne, '@') !== FALSE ){373 list( $className, $method ) = explode( '@', $thisOne );374 $object = $this->factory->make( $className );375 376 $args = array_slice( $matches, 1 );377 $thisOne = call_user_func_array( array($object, $method), $args );378 }379 else {380 if( count($matches) > 1 ){381 for( $ii = 1; $ii < count($matches); $ii++ ){382 $search = '{$' . $ii . '}';383 $replace = $matches[$ii];384 $thisOne = str_replace( $search, $replace, $thisOne );385 }386 }387 }388 389 return $thisOne;390 }391 392 public function renderWidget( $slug, $return )393 {394 8 // ANNOUNCE IF ANY 395 9 $announceView = NULL; … … 406 20 407 21 // LAYOUT 408 $title = $this->getTitle( $slug ); 22 // $breadcrumbLimit = $isAjax ? 1 : NULL; 23 // $breadcrumb = $this->getBreadcrumb( $slug, $breadcrumbLimit ); 24 if( $isAjax ){ 25 $breadcrumb = array(); 26 } 27 else { 28 $breadcrumb = $this->config->getBreadcrumb( $slug ); 29 } 30 31 $title = $this->config->getTitle( $slug ); 409 32 if( is_array($title) ){ 410 33 $title = join( ' ', $title ); 411 34 } 412 35 413 $menu = $this-> getMenu( $slug );414 $ breadcrumb = $this->getBreadcrumb( $slug );415 $sub header = $this->getSubheader( $slug );416 $ subfooter = $this->getSubfooter( $slug );36 $menu = $this->config->getMenu( $slug ); 37 $subheader = $this->config->getSubheader( $slug ); 38 $subfooter = $this->config->getSubfooter( $slug ); 39 $layout = $this->config->getLayout( $slug ); 417 40 418 $layout = $this->getLayout( $slug ); 419 $layout = $this->factory->make( $layout ); 420 421 $return = $layout->render( $slug, $return, $title, $menu, $breadcrumb, $subheader, $subfooter ); 41 $return = $layout->render( 42 $slug, 43 $isAjax, 44 $return, 45 $title, 46 $menu, 47 $breadcrumb, 48 $subheader, 49 $subfooter 50 ); 422 51 $return = $this->csrf->render( $return ); 423 52 … … 426 55 427 56 // HREFS 57 $this->profiler->markStart( __METHOD__ . ':hrefProcessOutput' ); 428 58 $return = $this->href->processOutput( $return ); 59 $this->profiler->markEnd( __METHOD__ . ':hrefProcessOutput' ); 60 61 $this->profiler->markEnd( __METHOD__ ); 429 62 430 63 return $return; -
z-inventory-manager/trunk/hc4/html/screen/boot.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class HC4_Html_Screen_Boot 3 implements HC4_App_Module_Interface4 3 { 5 public static function bind( array $appConfig )6 {7 $bind = array();8 9 switch( $appConfig['platform'] ){10 case 'standalone':11 $bind['HC4_Html_Screen_Interface'] = 'HC4_Html_Screen_Standalone';12 break;13 14 case 'joomla':15 $bind['HC4_Html_Screen_Interface'] = 'HC4_Html_Screen_Joomla';16 break;17 18 case 'wordpress':19 $bind['HC4_Html_Screen_Interface'] = 'HC4_Html_Screen_WordPress';20 break;21 }22 23 return $bind;24 }25 4 } -
z-inventory-manager/trunk/hc4/html/screen/interface.php
r2107074 r2149267 3 3 { 4 4 public function render( $slug, $result ); 5 6 public function css( $slugPreg, $path );7 public function js( $slugPreg, $path );8 public function title( $slugPreg, $value );9 public function breadcrumbTitle( $slugPreg, $value );10 public function menu( $slugPreg, $menuLink );11 public function layout( $slugPreg, $layout );12 13 public function getCss( $slug );14 public function getJs( $slug );15 public function getTitle( $slug );16 public function getMenu( $slug );17 public function getBreadcrumb( $slug );18 5 } -
z-inventory-manager/trunk/hc4/html/screen/layout/interface.php
r2107074 r2149267 4 4 public function render( 5 5 $slug, 6 $isAjax, 6 7 $content, 7 8 $title = NULL, -
z-inventory-manager/trunk/hc4/migration/boot.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class HC4_Migration_Boot 3 implements HC4_App_Module_Interface4 3 { 5 public static function bind( array $appConfig)4 public static function bind() 6 5 { 7 6 $bind = array(); -
z-inventory-manager/trunk/hc4/migration/settings.php
r2061857 r2149267 13 13 public function register( $migrationName, $migrationVersion, $migrationHandler ) 14 14 { 15 $confName = 'migration_' . $migrationName; 16 $this->settings->init( $confName, 0 ); 17 15 18 $this->migrations[] = array( $migrationName, $migrationVersion, $migrationHandler ); 16 19 return $this; … … 33 36 34 37 if( ! is_object($handler[0]) ){ 35 $handler[0] = $this->factory->make( $handler[0] );38 $handler[0] = $this->factory->make( $handler[0], __CLASS__ ); 36 39 } 37 40 … … 50 53 $installedVersion = 0; 51 54 } 52 53 55 return $installedVersion; 54 56 } … … 58 60 $confName = 'migration_' . $migrationName; 59 61 $this->settings->set( $confName, $newVersion ); 62 return $this; 60 63 } 61 64 } -
z-inventory-manager/trunk/hc4/redirect/ajax.php
r2061857 r2149267 5 5 public function call( $to ) 6 6 { 7 $out = array( 'redirect' => $to ); 8 $out = json_encode( $out ); 7 $out = '<hc4redirect>' . $to . '</hc4redirect>'; 9 8 echo $out; 10 9 exit; -
z-inventory-manager/trunk/hc4/redirect/boot.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class HC4_Redirect_Boot 3 implements HC4_App_Module_Interface4 3 { 5 public static function bind( array $appConfig)4 public static function bind() 6 5 { 7 6 $bind = array(); 8 9 switch( $appConfig['platform'] ){ 10 case 'standalone': 11 case 'joomla': 12 $bind['HC4_Redirect_Interface'] = 'HC4_Redirect_Header'; 13 break; 14 15 case 'wordpress': 16 $bind['HC4_Redirect_Interface'] = 'HC4_Redirect_Wordpress'; 17 break; 18 } 19 7 $bind['HC4_Redirect_Interface'] = 'HC4_Redirect_Header'; 20 8 return $bind; 21 9 } -
z-inventory-manager/trunk/hc4/session/boot.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class HC4_Session_Boot 3 implements HC4_App_Module_Interface4 3 { 5 public static function bind( array $appConfig ) 4 /** 5 * $config 6 * ['prefix'] string Session name prefix 7 * 8 * @param array $config 9 * @return array 10 */ 11 12 public static function bind( array $config = array() ) 6 13 { 7 14 $bind = array(); 15 $bind['HC4_Session_Interface'] = 'HC4_Session_Implementation'; 8 16 9 $bind['HC4_Session_Interface'] = 'HC4_Session_Implementation'; 17 if( isset($config['prefix']) ){ 18 $bind['HC4_Session_Implementation->prefix'] = $config['prefix']; 19 } 10 20 11 21 return $bind; -
z-inventory-manager/trunk/hc4/settings/database/crud.php
r2061857 r2149267 8 8 HC4_Database_Interface $db, 9 9 HC4_Database_QueryBuilder $q, 10 HC4_Settings_Database_Crud_Table$table10 $table 11 11 ) 12 12 {} -
z-inventory-manager/trunk/hc4/time/boot.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class HC4_Time_Boot 3 implements HC4_App_Module_Interface4 3 { 5 public static function bind( array $appConfig)4 public static function bind() 6 5 { 7 6 $bind = array(); -
z-inventory-manager/trunk/hc4/time/format.php
r2107074 r2149267 12 12 public function formatDuration( $seconds ); 13 13 public function formatDurationVerbose( $seconds ); 14 public function formatDurationFromText( $text ); 14 15 } 15 16 … … 133 134 } 134 135 136 public function formatDurationFromText( $text ) 137 { 138 $ts1 = $this->t->setDateDb( '20190725' )->getTimestamp(); 139 $ts2 = $this->t->modify( '+' . $text )->getTimestamp(); 140 141 $seconds = $ts2 - $ts1; 142 return $this->formatDurationVerbose( $seconds ); 143 } 144 135 145 public function formatDurationVerbose( $seconds ) 136 146 { 137 147 $seconds = (string) $seconds; 138 148 139 $hours = floor( $seconds / (60 * 60) ); 140 $remain = $seconds - $hours * (60 * 60); 149 $days = floor( $seconds / (24 * 60 * 60) ); 150 $remain = $seconds - $days * (24 * 60 * 60); 151 $hours = floor( $remain / (60 * 60) ); 152 $remain = $remain - $hours * (60 * 60); 141 153 $minutes = floor( $remain / 60 ); 142 154 143 155 $return = array(); 156 157 if( $days ){ 158 $daysView = $days; 159 $daysView = $daysView . '' . '__d__'; 160 $return[] = $daysView; 161 } 144 162 145 163 if( $hours ){ -
z-inventory-manager/trunk/hc4/time/implementation.php
r2107074 r2149267 200 200 } 201 201 202 public function getDateDb() 203 { 204 $dateFormat = 'Ymd'; 205 $return = $this->format( $dateFormat ); 202 public function getDateDb( $dateTimeDb = NULL ) 203 { 204 if( NULL === $dateTimeDb ){ 205 $dateFormat = 'Ymd'; 206 $return = $this->format( $dateFormat ); 207 } 208 else { 209 $return = substr( $dateTimeDb, 0, 8 ); 210 } 206 211 return $return; 207 212 } … … 724 729 return $return; 725 730 } 731 732 public function getAllDates( $startDate, $endDate ) 733 { 734 $return = array(); 735 736 $rexDate = $startDate; 737 $this->setDateDb( $rexDate ); 738 while( $rexDate <= $endDate ){ 739 $return[] = $rexDate; 740 $rexDate = $this->modify('+1 day')->getDateDb(); 741 } 742 743 return $return; 744 } 726 745 } -
z-inventory-manager/trunk/hc4/time/interface.php
r2061857 r2149267 51 51 52 52 public function getDifferenceInDays( $date1, $date2 ); 53 public function getAllDates( $startDate, $endDate ); 53 54 } -
z-inventory-manager/trunk/readme.txt
r2112339 r2149267 69 69 == Changelog == 70 70 71 = 2.0.2 = 72 * Added delete actions for items, purchases and sales. 73 * Internal framework update. 74 71 75 = 2.0.1 = 72 76 * If WooCommerce is installed, our plugin can use its products as inventory source. -
z-inventory-manager/trunk/z-inventory-manager2.php
r2107074 r2149267 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. 16 * Version: 2.0.2 7 7 * Author: hitcode.com 8 8 * Author URI: https://www.hitcode.com/ … … 13 13 include_once( dirname(__FILE__) . '/zi2-base.php' ); 14 14 15 $configFile = __DIR__ . '/config.php'; 16 $appConfig = file_exists($configFile) ? include( $configFile ) : array(); 17 18 $dir = isset( $appConfig['code-dir'] ) ? $appConfig['code-dir'] : __DIR__; 19 if( ! class_exists('HC4_App') ){ 20 include_once( $dir . '/hc4/app.php' ); 21 } 22 23 $hczi2 = new ZInventoryManager2_Wordpress( __DIR__, $appConfig ); 15 $hczi2 = new ZInventoryManager2_Wordpress( __FILE__ ); -
z-inventory-manager/trunk/zi2-base.php
r2107074 r2149267 16 16 class ZInventoryManager2_Wordpress 17 17 { 18 public $dir; 19 public $adminMenuLabel = 'Z Inventory Manager'; 20 public $appConfig = array(); 21 22 public function __construct( $dir, array $appConfig = array() ) 23 { 24 $this->dir = $dir; 25 $this->appConfig = $appConfig; 18 protected $pluginFile; 19 20 protected $adminMenuLabel = 'Z Inventory Manager'; 21 protected $myPage = 'z-inventory-manager2'; 22 protected $myAdminPage = 'z-inventory-manager2'; 23 protected $myShortPage = 'zi2'; 24 25 public function __construct( $pluginFile ) 26 { 27 $pluginDir = dirname( $pluginFile ); 28 29 // supplied config 30 $configFile = $pluginDir . '/config.php'; 31 $config = file_exists($configFile) ? require($configFile) : array(); 32 33 // hc4 autoload 34 $src = isset( $config['autoloader'] ) ? $config['autoloader'] : array(); 35 $autoloader = require( $pluginDir . '/autoloader.php' ); 36 spl_autoload_register( $autoloader($src) ); 37 38 $this->pluginFile = $pluginFile; 39 $pluginDir = dirname( $pluginFile ); 26 40 27 41 add_action( 'init', array($this, '_init') ); … … 35 49 add_filter( 'parent_file', array($this, 'setCurrentAppMenu') ); 36 50 37 $this->hc4init();38 51 add_shortcode( 'zi2', array($this, 'shortcode') ); 39 } 40 41 public function hc4init() 42 { 43 $platform = 'wordpress'; 44 $moreConfig = include( $this->dir . '/zi2/config.php' ); 45 $appConfig = array_merge( $this->appConfig, $moreConfig ); 46 47 $this->myPage = $appConfig['app-name']; 48 $this->myAdminPage = $appConfig['app-name']; 49 $this->myShortPage = $appConfig['app-short-name']; 50 51 $appConfig['platform'] = $platform; 52 $this->app = new HC4_App( $this->dir, $appConfig ); 52 53 // hc4 init 54 $modulesConfig = $this->getModules(); 55 56 foreach( $config as $k => $v ){ 57 if( isset($modulesConfig[$k]) ){ 58 $modulesConfig[$k] = array_merge( $modulesConfig[$k], $v ); 59 } 60 } 61 62 $this->app = new HC4_App_Index( $modulesConfig ); 63 } 64 65 public function getModules() 66 { 67 $return = require( dirname($this->pluginFile) . '/modules-zim.php' ); 68 return $return; 53 69 } 54 70 … … 143 159 } 144 160 145 public function isIntercepted()146 {147 $return = FALSE;148 149 $k = 'hcs';150 if( array_key_exists($k, $_GET) ){151 $v = sanitize_text_field( $_GET[$k] );152 if( ($v == $this->myPage) OR ($v == $this->myShortPage) ){153 $return = TRUE;154 }155 }156 157 return $return;158 }159 160 public function isMeAdmin()161 {162 $return = FALSE;163 if( ! isset($_REQUEST['page']) ){164 return $return;165 }166 167 $page = sanitize_text_field( $_REQUEST['page'] );168 169 if( $page == $this->myAdminPage ){170 $return = TRUE;171 }172 173 return $return;174 }175 176 161 public function adminSubmenu() 177 162 { … … 179 164 $menuSlug = $this->myAdminPage; 180 165 181 $screen = $this->app->factory('HC4_Html_Screen_ Interface');166 $screen = $this->app->factory('HC4_Html_Screen_Config'); 182 167 $translate = $this->app->factory('HC4_Translate_Interface'); 183 168 184 169 $menuItems = $screen->getMenu( '' ); 185 186 170 $mySubmenuCount = 0; 187 171 … … 261 245 return $parentFile; 262 246 } 247 248 public function isIntercepted() 249 { 250 $return = FALSE; 251 252 $k = 'hcs'; 253 if( array_key_exists($k, $_GET) ){ 254 $v = sanitize_text_field( $_GET[$k] ); 255 if( ($v == $this->myPage) OR ($v == $this->myShortPage) ){ 256 $return = TRUE; 257 } 258 } 259 260 return $return; 261 } 262 263 public function isMeAdmin() 264 { 265 $return = FALSE; 266 if( ! isset($_REQUEST['page']) ){ 267 return $return; 268 } 269 270 $page = sanitize_text_field( $_REQUEST['page'] ); 271 272 if( $page == $this->myAdminPage ){ 273 $return = TRUE; 274 } 275 276 return $return; 277 } 263 278 } 264 279 -
z-inventory-manager/trunk/zi2/01users/boot.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_01Users_Boot 3 implements HC4_App_Module_Interface4 3 { 5 4 public function __construct( 6 5 HC4_App_Router $router, 7 HC4_Html_Screen_ Interface$screen6 HC4_Html_Screen_Config $screen 8 7 ) 9 8 { -
z-inventory-manager/trunk/zi2/02conf/boot.php
r2107074 r2149267 11 11 12 12 class ZI2_02Conf_Boot 13 implements HC4_App_Module_Interface14 13 { 15 public static function bind( array $appConfig)14 public static function bind() 16 15 { 17 16 $bind = array(); 18 17 $bind['HC4_Settings_Database_Crud_Table'] = 'ZI2_02Conf_Boot_CrudTable'; 19 $bind['HC4_Settings_Interface'] = 'HC4_Settings_Database';18 // $bind['HC4_Settings_Interface'] = 'HC4_Settings_Database_Implementation'; 20 19 return $bind; 21 20 } … … 25 24 HC4_Settings_Interface $settings, 26 25 HC4_App_Router $router, 27 HC4_Html_Screen_ Interface$screen26 HC4_Html_Screen_Config $screen 28 27 ) 29 28 { … … 53 52 $screen 54 53 ->menu( '', array( 'admin/conf', '__Settings__', 1000) ) 55 ->menu( 'admin/conf', array( ' {CURRENT}/datetime', '__Date and Time__') )56 ->menu( 'admin/conf', array( ' {CURRENT}/email', '__Email__') )54 ->menu( 'admin/conf', array( '../datetime', '__Date and Time__') ) 55 ->menu( 'admin/conf', array( '../email', '__Email__') ) 57 56 58 57 ->title( 'admin/conf', '__Settings__' ) -
z-inventory-manager/trunk/zi2/02conf/ui/admin/datetime.php
r2061857 r2149267 36 36 } 37 37 38 $return = $this->render( $ values );38 $return = $this->render( $slug, $values ); 39 39 $return = $this->screen->render( $slug, $return ); 40 40 return $return; 41 41 } 42 42 43 public function render( array $values )43 public function render( $slug, array $values ) 44 44 { 45 45 ob_start(); 46 46 ?> 47 47 48 <form method="post" action="HREFPOST: {CURRENT}">48 <form method="post" action="HREFPOST:<?php echo $slug; ?>"> 49 49 <div class="hc4-form-elements"> 50 50 -
z-inventory-manager/trunk/zi2/02conf/ui/admin/email.php
r2061857 r2149267 45 45 ?> 46 46 47 <form method="post" action="HREFPOST: {CURRENT}">47 <form method="post" action="HREFPOST:.."> 48 48 <div class="hc4-form-elements"> 49 49 -
z-inventory-manager/trunk/zi2/03acl/boot.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_03Acl_Boot 3 implements HC4_App_Module_Interface4 3 { 5 4 public function __construct( … … 9 8 HC4_Settings_Interface $settings, 10 9 HC4_App_Router $router, 11 HC4_Html_Screen_ Interface$screen10 HC4_Html_Screen_Config $screen 12 11 ) 13 12 { -
z-inventory-manager/trunk/zi2/03acl/ui/admin/settings.php
r2061857 r2149267 77 77 ?> 78 78 79 <form method="post" action="HREFPOST: {CURRENT}">79 <form method="post" action="HREFPOST:.."> 80 80 81 <div class="hc4-admin-list-primary ">81 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 82 82 <div class="hc-grid"> 83 83 <div class="hc-col hc-col-4">__WordPress Role__</div> -
z-inventory-manager/trunk/zi2/04finance/boot.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_04Finance_Boot 3 implements HC4_App_Module_Interface4 3 { 5 4 public function __construct( 6 5 HC4_Settings_Interface $settings, 7 6 HC4_App_Router $router, 8 HC4_Html_Screen_ Interface$screen7 HC4_Html_Screen_Config $screen 9 8 ) 10 9 { … … 23 22 24 23 $screen 25 ->menu( 'admin/conf', array( ' {CURRENT}/finance', '__Finance__') )24 ->menu( 'admin/conf', array( '../finance', '__Finance__') ) 26 25 ->title( 'admin/conf/finance', '__Finance__' ) 27 26 ; -
z-inventory-manager/trunk/zi2/04finance/ui/admin/conf/finance.php
r2061857 r2149267 47 47 ?> 48 48 49 <form method="post" action="HREFPOST: {CURRENT}">49 <form method="post" action="HREFPOST:.."> 50 50 <div class="hc4-form-elements"> 51 51 -
z-inventory-manager/trunk/zi2/11items/boot.php
r2107074 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_11Items_Boot 3 implements HC4_App_Module_Interface4 3 { 5 public static function bind( array $appConfig)4 public static function bind() 6 5 { 7 6 $return = array(); … … 13 12 HC4_Migration_Interface $migration, 14 13 HC4_App_Router $router, 15 HC4_Html_Screen_ Interface$screen14 HC4_Html_Screen_Config $screen 16 15 ) 17 16 { -
z-inventory-manager/trunk/zi2/11items/data/crud.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_11Items_Data_Crud 3 extends HC4_Crud_ AbstractSql3 extends HC4_Crud_Sql_Abstract 4 4 { 5 5 public function __construct( 6 HC4_Crud_Sql Table $sqlTable6 HC4_Crud_Sql_Table $sqlTable 7 7 ) 8 8 { -
z-inventory-manager/trunk/zi2/11items/data/repo.php
r2107074 r2149267 15 15 16 16 public function __construct( 17 ZI2_11Items_Data_Crud $crud 17 ZI2_11Items_Data_Crud $crud, 18 HC4_App_Events $events 18 19 ) 19 20 {} … … 158 159 $this->crud->delete( $model->id ); 159 160 161 /* EVENT */ 162 $this->events->publish( 'ZI2_11Items_Data_Repo@delete', $model, func_get_args() ); 163 160 164 return $model; 161 165 } -
z-inventory-manager/trunk/zi2/12wooitems/boot.php
r2107074 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_12WooItems_Boot 3 implements HC4_App_Module_Interface4 3 { 5 4 public function __construct( … … 8 7 HC4_Html_Href_Interface $href, 9 8 HC4_App_Router $router, 10 HC4_Html_Screen_ Interface$screen9 HC4_Html_Screen_Config $screen 11 10 ) 12 11 { … … 36 35 37 36 $screen 38 ->menu( 'admin/conf', array( ' {CURRENT}/inventory', '__Inventory__') )37 ->menu( 'admin/conf', array( '../inventory', '__Inventory__') ) 39 38 ->title( 'admin/conf/inventory', '__Inventory__' ) 40 39 ; -
z-inventory-manager/trunk/zi2/12wooitems/ui/admin/inventory.php
r2107074 r2149267 41 41 ?> 42 42 43 <form method="post" action="HREFPOST: {CURRENT}">43 <form method="post" action="HREFPOST:.."> 44 44 <div class="hc4-form-elements"> 45 45 -
z-inventory-manager/trunk/zi2/21purchases/boot.php
r2107074 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_21Purchases_Boot 3 implements HC4_App_Module_Interface4 3 { 5 4 public function __construct( … … 7 6 HC4_Migration_Interface $migration, 8 7 HC4_App_Router $router, 9 HC4_Html_Screen_Interface $screen 8 HC4_App_Events $events, 9 HC4_Html_Screen_Config $screen 10 10 ) 11 11 { 12 $ns = 'ZI2_21Purchases_'; 13 12 14 $migration 13 15 ->register( 'purchases', 1, 'ZI2_21Purchases_Data_Migration@version1' ) … … 22 24 23 25 $screen 24 ->menu( 'admin/conf', array( ' {CURRENT}/purchases', '__Purchases__') )26 ->menu( 'admin/conf', array( '../purchases', '__Purchases__') ) 25 27 ->title( 'admin/conf/purchases', '__Purchases__' ) 26 28 ; … … 28 30 ->add( 'GET/admin/conf/purchases', 'ZI2_21Purchases_Ui_Admin_Conf_Purchases@get' ) 29 31 ->add( 'POST/admin/conf/purchases', 'ZI2_21Purchases_Ui_Admin_Conf_Purchases@post' ) 32 ; 33 34 // DELETE 35 $router 36 ->add( 'GET/admin/purchases/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@get' ) 37 ->add( 'POST/admin/purchases/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@post' ) 38 ; 39 $screen 40 ->menu( 'admin/purchases/[:id]', array('../delete', '× ' . '__Delete__', 900) ) 41 ->title( 'admin/purchases/[:id]/delete', '__Delete__' ) 30 42 ; 31 43 … … 58 70 59 71 ->title( 'admin/purchases/[:pid]/receipts/[:id]', '__Purchase Receipt__' ) 60 ->menu( 'admin/purchases/:pid/receipts/:id', array( 'POST/ {CURRENT}/delete', '__Delete__') )72 ->menu( 'admin/purchases/:pid/receipts/:id', array( 'POST/../delete', '__Delete__') ) 61 73 ; 62 74 … … 66 78 ->add( 'POST/admin/purchases/new', 'ZI2_21Purchases_Ui_Admin_New@post' ) 67 79 ; 68 69 80 $screen 70 ->menu( 'admin/purchases', array(' {CURRENT}/new', '__New Purchase__') )81 ->menu( 'admin/purchases', array('../new', '__New Purchase__') ) 71 82 ->title( 'admin/purchases/new', '__New Purchase__' ) 72 83 ; … … 83 94 $screen 84 95 ->title( 'admin/purchases/[:id]/items', '__Edit Items__' ) 85 ->menu( 'admin/purchases/:id/items', array( ' {CURRENT}/new', '__Add Item__') )96 ->menu( 'admin/purchases/:id/items', array( '../new', '__Add Item__') ) 86 97 ->title( 'admin/purchases/:id/items/new', '__Add Item__' ) 87 98 ->title( 'admin/purchases/:id/items/new/[:iid]', 'ZI2_21Purchases_Ui_Admin_Id_Items_New@title' ) 88 99 ; 100 101 // LISTEN TO ITEM DELETE 102 $events 103 ->listen( 'ZI2_11Items_Data_Repo@delete', $ns . 'Data_Listen@itemDeleted' ) 104 ; 89 105 } 90 106 } -
z-inventory-manager/trunk/zi2/21purchases/data/crud.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_21Purchases_Data_Crud 3 extends HC4_Crud_ AbstractSql3 extends HC4_Crud_Sql_Abstract 4 4 { 5 5 public function __construct( 6 HC4_Crud_Sql Table $sqlTable6 HC4_Crud_Sql_Table $sqlTable 7 7 ) 8 8 { -
z-inventory-manager/trunk/zi2/21purchases/data/crud/lines.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_21Purchases_Data_Crud_Lines 3 extends HC4_Crud_ AbstractSql3 extends HC4_Crud_Sql_Abstract 4 4 { 5 5 public function __construct( 6 HC4_Crud_Sql Table $sqlTable6 HC4_Crud_Sql_Table $sqlTable 7 7 ) 8 8 { -
z-inventory-manager/trunk/zi2/21purchases/data/crud/receipts.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_21Purchases_Data_Crud_Receipts 3 extends HC4_Crud_ AbstractSql3 extends HC4_Crud_Sql_Abstract 4 4 { 5 5 public function __construct( 6 HC4_Crud_Sql Table $sqlTable6 HC4_Crud_Sql_Table $sqlTable 7 7 ) 8 8 { -
z-inventory-manager/trunk/zi2/21purchases/data/crud/receipts/lines.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_21Purchases_Data_Crud_Receipts_Lines 3 extends HC4_Crud_ AbstractSql3 extends HC4_Crud_Sql_Abstract 4 4 { 5 5 public function __construct( 6 HC4_Crud_Sql Table $sqlTable6 HC4_Crud_Sql_Table $sqlTable 7 7 ) 8 8 { -
z-inventory-manager/trunk/zi2/21purchases/data/repo.php
r2107074 r2149267 13 13 public function updateReceipt( ZI2_21Purchases_Data_Model $purchase, ZI2_21Purchases_Data_Model_Receipt $receipt ); 14 14 15 public function delete( ZI2_21Purchases_Data_Model $model ); 15 16 public function create( ZI2_21Purchases_Data_Model $model ); 16 17 public function update( ZI2_21Purchases_Data_Model $model ); … … 29 30 ZI2_21Purchases_Data_Repo_Receipts $repoReceipts, 30 31 32 HC4_App_Events $events, 31 33 HC4_Settings_Interface $settings 32 34 ) … … 247 249 } 248 250 251 public function delete( ZI2_21Purchases_Data_Model $model ) 252 { 253 $lines = $this->repoLines->findManyByPurchases( array($model->id => $model) ); 254 if( isset($lines[$model->id]) ){ 255 foreach( $lines[$model->id] as $line ){ 256 $this->repoLines->delete( $line ); 257 } 258 } 259 260 $receipts = $this->repoReceipts->findManyByPurchases( array($model->id => $model) ); 261 if( isset($receipts[$model->id]) ){ 262 foreach( $receipts[$model->id] as $receipt ){ 263 $this->repoReceipts->delete( $receipt ); 264 } 265 } 266 267 $this->crud->delete( $model->id ); 268 269 /* EVENT */ 270 $this->events->publish( __METHOD__, $model, func_get_args() ); 271 272 return $model; 273 } 274 249 275 public function update( ZI2_21Purchases_Data_Model $model ) 250 276 { -
z-inventory-manager/trunk/zi2/21purchases/data/repo/lines.php
r2107074 r2149267 3 3 { 4 4 public function findManyByPurchases( array $purchases ); 5 public function findManyByItem( ZI2_11Items_Data_Model $item ); 5 6 public function delete( ZI2_21Purchases_Data_Model_Line $model ); 6 7 public function create( ZI2_21Purchases_Data_Model $purchase, ZI2_21Purchases_Data_Model_Line $model ); … … 66 67 67 68 $return[ $e['purchase_id'] ][ $model->id ] = $model; 69 } 70 71 return $return; 72 } 73 74 public function findManyByItem( ZI2_11Items_Data_Model $item ) 75 { 76 $return = array(); 77 78 $q = new HC4_Crud_Q; 79 $q->where( 'item_id', '=', $item->id ); 80 $results = $this->crud->read( $q ); 81 82 foreach( $results as $e ){ 83 $model = $this->_fromTable( $e ); 84 if( ! $model ){ 85 continue; 86 } 87 88 $return[ $model->id ] = $model; 68 89 } 69 90 -
z-inventory-manager/trunk/zi2/21purchases/data/repo/receipts/lines.php
r2107074 r2149267 3 3 { 4 4 public function findManyByReceipts( array $receipts ); 5 public function findManyByItem( ZI2_11Items_Data_Model $item ); 5 6 public function create( ZI2_21Purchases_Data_Model_Receipt $receipt, ZI2_21Purchases_Data_Model_Receipt_Line $line ); 6 7 public function delete( ZI2_21Purchases_Data_Model_Receipt_Line $model ); … … 69 70 } 70 71 72 public function findManyByItem( ZI2_11Items_Data_Model $item ) 73 { 74 $return = array(); 75 76 $q = new HC4_Crud_Q; 77 $q->where( 'item_id', '=', $item->id ); 78 $results = $this->crud->read( $q ); 79 80 foreach( $results as $e ){ 81 $model = $this->_fromTable( $e ); 82 if( ! $model ){ 83 continue; 84 } 85 86 $return[ $model->id ] = $model; 87 } 88 89 return $return; 90 } 91 71 92 public function create( ZI2_21Purchases_Data_Model_Receipt $receipt, ZI2_21Purchases_Data_Model_Receipt_Line $model ) 72 93 { -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/conf/purchases.php
r2061857 r2149267 48 48 ?> 49 49 50 <form method="post" action="HREFPOST: {CURRENT}">50 <form method="post" action="HREFPOST:.."> 51 51 <div class="hc4-form-elements"> 52 52 -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id.php
r2107074 r2149267 76 76 } 77 77 78 public function title( $ id )78 public function title( $slug, $id ) 79 79 { 80 80 $model = $this->repo->findById( $id ); … … 90 90 if( $model->isDraft() ){ 91 91 if( $model->lines ){ 92 $return[] = array( ' {CURRENT}/items', '__Edit Items__' );92 $return[] = array( '../items', '__Edit Items__' ); 93 93 } 94 94 else { 95 $return[] = array( ' {CURRENT}/items/new', '+ ' . '__Add Item__' );95 $return[] = array( '../items/new', '+ ' . '__Add Item__' ); 96 96 } 97 97 } 98 98 else { 99 99 if( $model->receipts ){ 100 $return[] = array( ' {CURRENT}/receipts', '☰ ' . '__Received Items__' );100 $return[] = array( '../receipts', '☰ ' . '__Received Items__' ); 101 101 } 102 102 103 103 $toReceive = $model->getItemsToReceive(); 104 104 if( $toReceive ){ 105 $return[] = array( ' {CURRENT}/receipts/new', '→ ' . '__Receive Items__' );105 $return[] = array( '../receipts/new', '→ ' . '__Receive Items__' ); 106 106 } 107 107 } … … 193 193 ob_start(); 194 194 ?> 195 <form method="post" action="HREFPOST: {CURRENT}">195 <form method="post" action="HREFPOST:.."> 196 196 197 197 <div class="hc4-form-elements"> … … 236 236 237 237 <div class="hc4-form-buttons"> 238 <button class="hc4-admin-btn-primary">__Save__</button>238 <button type="submit" class="hc4-admin-btn-primary">__Save__</button> 239 239 </div> 240 240 … … 263 263 ob_start(); 264 264 ?> 265 <div class="hc4-admin-list-primary ">265 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 266 266 267 267 <?php if( $entries ) : ?> -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/items.php
r2061857 r2149267 31 31 <?php if( $model->lines ) : ?> 32 32 33 <form method="post" action="HREFPOST: {CURRENT}">33 <form method="post" action="HREFPOST:.."> 34 34 35 <div class="hc4-admin-list-primary ">35 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 36 36 37 37 <div> … … 68 68 69 69 <div class="hc4-form-buttons"> 70 <button class="hc4-admin-btn-primary">__Save__</button>70 <button type="submit" class="hc4-admin-btn-primary">__Save__</button> 71 71 </div> 72 72 -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/items/new.php
r2061857 r2149267 13 13 {} 14 14 15 public function title( $ itemId )15 public function title( $slug, $itemId ) 16 16 { 17 17 $item = $this->repoItems->findById( $itemId ); … … 32 32 ob_start(); 33 33 ?> 34 <form method="post" action="HREFPOST: {CURRENT}">34 <form method="post" action="HREFPOST:.."> 35 35 36 36 <div class="hc4-form-elements"> … … 66 66 67 67 <div class="hc4-form-buttons"> 68 <button class="hc4-admin-btn-primary">__Add Item__</button>68 <button type="submit" class="hc4-admin-btn-primary">__Add Item__</button> 69 69 </div> 70 70 -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts.php
r2061857 r2149267 52 52 <?php endif; ?> 53 53 54 <div class="hc4-admin-list-primary ">54 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 55 55 <?php foreach( $model->lines as $e ) : ?> 56 56 <div> … … 80 80 <div class="hc-mb3"> 81 81 <div class="hc-my1"> 82 <a class="hc4-admin-title-link" href="HREFGET: {CURRENT}/<?php echo $e->id; ?>"><?php echo $e->refno; ?></a>82 <a class="hc4-admin-title-link" href="HREFGET:../<?php echo $e->id; ?>"><?php echo $e->refno; ?></a> 83 83 <?php echo $this->tf->formatDateWithWeekDay( $e->createdDate ); ?> 84 84 </div> 85 85 86 <div class="hc4-admin-list-primary ">86 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 87 87 <?php foreach( $e->lines as $l ) : ?> 88 88 <div class="hc-flex-auto-grid"> -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts/id.php
r2061857 r2149267 92 92 ob_start(); 93 93 ?> 94 <form method="post" action="HREFPOST: {CURRENT}">94 <form method="post" action="HREFPOST:.."> 95 95 96 96 <div class="hc4-form-elements"> … … 135 135 136 136 <div class="hc4-form-buttons"> 137 <button class="hc4-admin-btn-primary">__Save__</button>137 <button type="submit" class="hc4-admin-btn-primary">__Save__</button> 138 138 </div> 139 139 -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts/new.php
r2061857 r2149267 68 68 ob_start(); 69 69 ?> 70 <form method="post" action="HREFPOST: {CURRENT}">70 <form method="post" action="HREFPOST:.."> 71 71 72 72 <div class="hc4-form-elements"> … … 111 111 112 112 <div class="hc4-form-buttons"> 113 <button class="hc4-admin-btn-primary">__Receive Items__</button>113 <button type="submit" class="hc4-admin-btn-primary">__Receive Items__</button> 114 114 </div> 115 115 -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/index.php
r2061857 r2149267 18 18 $entries = $this->repo->findAll(); 19 19 20 $return = $this->render( $ entries );20 $return = $this->render( $slug, $entries ); 21 21 $return = $this->screen->render( $slug, $return ); 22 22 return $return; 23 23 } 24 24 25 public function render( array $entries )25 public function render( $slug, array $entries ) 26 26 { 27 27 ob_start(); 28 28 ?> 29 29 30 <div class="hc4-admin-list-primary ">30 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 31 31 32 32 <?php if( $entries ) : ?> … … 45 45 <div class="hc-flex-auto-grid"> 46 46 <div> 47 <a class="hc4-admin-title-link hc-xs-block" href="HREFGET: {CURRENT}/<?php echo $e->id; ?>"><?php echo $e->refno; ?></a>47 <a class="hc4-admin-title-link hc-xs-block" href="HREFGET:<?php echo $slug; ?>/<?php echo $e->id; ?>"><?php echo $e->refno; ?></a> 48 48 </div> 49 49 <div> -
z-inventory-manager/trunk/zi2/21purchases/ui/admin/new.php
r2061857 r2149267 36 36 ob_start(); 37 37 ?> 38 <form method="post" action="HREFPOST: {CURRENT}">38 <form method="post" action="HREFPOST:.."> 39 39 40 40 <div class="hc4-form-elements"> … … 64 64 65 65 <div class="hc4-form-buttons"> 66 <button class="hc4-admin-btn-primary">__Continue__</button>66 <button type="submit" class="hc4-admin-btn-primary">__Continue__</button> 67 67 </div> 68 68 -
z-inventory-manager/trunk/zi2/22sales/boot.php
r2107074 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_22Sales_Boot 3 implements HC4_App_Module_Interface4 3 { 5 4 public function __construct( … … 7 6 HC4_Migration_Interface $migration, 8 7 HC4_App_Router $router, 9 HC4_Html_Screen_ Interface$screen8 HC4_Html_Screen_Config $screen 10 9 ) 11 10 { 11 $ns = 'ZI2_22Sales_'; 12 12 13 $migration 13 14 ->register( 'sales', 1, 'ZI2_22Sales_Data_Migration@version1' ) … … 22 23 23 24 $screen 24 ->menu( 'admin/conf', array( ' {CURRENT}/sales', '__Sales__') )25 ->menu( 'admin/conf', array( '../sales', '__Sales__') ) 25 26 ->title( 'admin/conf/sales', '__Sales__' ) 26 27 ; … … 28 29 ->add( 'GET/admin/conf/sales', 'ZI2_22Sales_Ui_Admin_Conf_Sales@get' ) 29 30 ->add( 'POST/admin/conf/sales', 'ZI2_22Sales_Ui_Admin_Conf_Sales@post' ) 31 ; 32 33 // DELETE 34 $router 35 ->add( 'GET/admin/sales/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@get' ) 36 ->add( 'POST/admin/sales/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@post' ) 37 ; 38 $screen 39 ->menu( 'admin/sales/[:id]', array('../delete', '× ' . '__Delete__', 900) ) 40 ->title( 'admin/sales/[:id]/delete', '__Delete__' ) 30 41 ; 31 42 … … 58 69 59 70 ->title( 'admin/sales/[:pid]/shipments/[:id]', '__Sale Shipment__' ) 60 ->menu( 'admin/sales/:pid/shipments/:id', array( 'POST/ {CURRENT}/delete', '__Delete__') )71 ->menu( 'admin/sales/:pid/shipments/:id', array( 'POST/../delete', '__Delete__') ) 61 72 ; 62 73 … … 68 79 69 80 $screen 70 ->menu( 'admin/sales', array(' {CURRENT}/new', '__New Sale__') )81 ->menu( 'admin/sales', array('../new', '__New Sale__') ) 71 82 ->title( 'admin/sales/new', '__New Sale__' ) 72 83 ; … … 83 94 $screen 84 95 ->title( 'admin/sales/[:id]/items', '__Edit Items__' ) 85 ->menu( 'admin/sales/:id/items', array( ' {CURRENT}/new', '__Add Item__') )96 ->menu( 'admin/sales/:id/items', array( '../new', '__Add Item__') ) 86 97 ->title( 'admin/sales/:id/items/new', '__Add Item__' ) 87 98 ->title( 'admin/sales/:id/items/new/[:iid]', 'ZI2_22Sales_Ui_Admin_Id_Items_New@title' ) -
z-inventory-manager/trunk/zi2/22sales/data/crud.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_22Sales_Data_Crud 3 extends HC4_Crud_ AbstractSql3 extends HC4_Crud_Sql_Abstract 4 4 { 5 5 public function __construct( 6 HC4_Crud_Sql Table $sqlTable6 HC4_Crud_Sql_Table $sqlTable 7 7 ) 8 8 { -
z-inventory-manager/trunk/zi2/22sales/data/crud/lines.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_22Sales_Data_Crud_Lines 3 extends HC4_Crud_ AbstractSql3 extends HC4_Crud_Sql_Abstract 4 4 { 5 5 public function __construct( 6 HC4_Crud_Sql Table $sqlTable6 HC4_Crud_Sql_Table $sqlTable 7 7 ) 8 8 { -
z-inventory-manager/trunk/zi2/22sales/data/crud/shipments.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_22Sales_Data_Crud_Shipments 3 extends HC4_Crud_ AbstractSql3 extends HC4_Crud_Sql_Abstract 4 4 { 5 5 public function __construct( 6 HC4_Crud_Sql Table $sqlTable6 HC4_Crud_Sql_Table $sqlTable 7 7 ) 8 8 { -
z-inventory-manager/trunk/zi2/22sales/data/crud/shipments/lines.php
r2061857 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_22Sales_Data_Crud_Shipments_Lines 3 extends HC4_Crud_ AbstractSql3 extends HC4_Crud_Sql_Abstract 4 4 { 5 5 public function __construct( 6 HC4_Crud_Sql Table $sqlTable6 HC4_Crud_Sql_Table $sqlTable 7 7 ) 8 8 { -
z-inventory-manager/trunk/zi2/22sales/data/repo.php
r2107074 r2149267 13 13 public function updateShipment( ZI2_22Sales_Data_Model $sale, ZI2_22Sales_Data_Model_Shipment $shipment ); 14 14 15 public function delete( ZI2_22Sales_Data_Model $model ); 15 16 public function create( ZI2_22Sales_Data_Model $model ); 16 17 public function update( ZI2_22Sales_Data_Model $model ); … … 29 30 ZI2_22Sales_Data_Repo_Shipments $repoShipments, 30 31 32 HC4_App_Events $events, 31 33 HC4_Settings_Interface $settings 32 34 ) … … 246 248 } 247 249 250 public function delete( ZI2_22Sales_Data_Model $model ) 251 { 252 $lines = $this->repoLines->findManyBySales( array($model->id => $model) ); 253 if( isset($lines[$model->id]) ){ 254 foreach( $lines[$model->id] as $line ){ 255 $this->repoLines->delete( $line ); 256 } 257 } 258 259 $shipments = $this->repoShipments->findManyBySales( array($model->id => $model) ); 260 if( isset($shipments[$model->id]) ){ 261 foreach( $shipments[$model->id] as $shipment ){ 262 $this->repoShipments->delete( $shipment ); 263 } 264 } 265 266 $this->crud->delete( $model->id ); 267 268 /* EVENT */ 269 $this->events->publish( __METHOD__, $model, func_get_args() ); 270 271 return $model; 272 } 273 248 274 public function update( ZI2_22Sales_Data_Model $model ) 249 275 { -
z-inventory-manager/trunk/zi2/22sales/data/repo/lines.php
r2107074 r2149267 3 3 { 4 4 public function findManyBySales( array $sales ); 5 public function findManyByItem( ZI2_11Items_Data_Model $item ); 5 6 public function delete( ZI2_22Sales_Data_Model_Line $model ); 6 7 public function create( ZI2_22Sales_Data_Model $sale, ZI2_22Sales_Data_Model_Line $model ); … … 66 67 } 67 68 $return[ $e['sale_id'] ][ $model->id ] = $model; 69 } 70 71 return $return; 72 } 73 74 public function findManyByItem( ZI2_11Items_Data_Model $item ) 75 { 76 $return = array(); 77 78 $q = new HC4_Crud_Q; 79 $q->where( 'item_id', '=', $item->id ); 80 $results = $this->crud->read( $q ); 81 82 foreach( $results as $e ){ 83 $model = $this->_fromTable( $e ); 84 if( ! $model ){ 85 continue; 86 } 87 88 $return[ $model->id ] = $model; 68 89 } 69 90 -
z-inventory-manager/trunk/zi2/22sales/data/repo/shipments/lines.php
r2107074 r2149267 3 3 { 4 4 public function findManyByShipments( array $shipments ); 5 public function findManyByItem( ZI2_11Items_Data_Model $item ); 5 6 public function create( ZI2_22Sales_Data_Model_Shipment $shipment, ZI2_22Sales_Data_Model_Shipment_Line $line ); 6 7 public function delete( ZI2_22Sales_Data_Model_Shipment_Line $model ); … … 68 69 } 69 70 71 public function findManyByItem( ZI2_11Items_Data_Model $item ) 72 { 73 $return = array(); 74 75 $q = new HC4_Crud_Q; 76 $q->where( 'item_id', '=', $item->id ); 77 $results = $this->crud->read( $q ); 78 79 foreach( $results as $e ){ 80 $model = $this->_fromTable( $e ); 81 if( ! $model ){ 82 continue; 83 } 84 85 $return[ $model->id ] = $model; 86 } 87 88 return $return; 89 } 90 70 91 public function create( ZI2_22Sales_Data_Model_Shipment $shipment, ZI2_22Sales_Data_Model_Shipment_Line $model ) 71 92 { -
z-inventory-manager/trunk/zi2/22sales/ui/admin/conf/sales.php
r2061857 r2149267 48 48 ?> 49 49 50 <form method="post" action="HREFPOST: {CURRENT}">50 <form method="post" action="HREFPOST:.."> 51 51 <div class="hc4-form-elements"> 52 52 -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id.php
r2107074 r2149267 76 76 } 77 77 78 public function title( $ id )78 public function title( $slug, $id ) 79 79 { 80 80 $model = $this->repo->findById( $id ); … … 90 90 if( $model->isDraft() ){ 91 91 if( $model->lines ){ 92 $return[] = array( ' {CURRENT}/items', '__Edit Items__' );92 $return[] = array( '../items', '__Edit Items__' ); 93 93 } 94 94 else { 95 $return[] = array( ' {CURRENT}/items/new', '+ ' . '__Add Item__' );95 $return[] = array( '../items/new', '+ ' . '__Add Item__' ); 96 96 } 97 97 } 98 98 else { 99 99 if( $model->shipments ){ 100 $return[] = array( ' {CURRENT}/shipments', '☰ ' . '__Shipped Items__' );100 $return[] = array( '../shipments', '☰ ' . '__Shipped Items__' ); 101 101 } 102 102 103 103 $toShip = $model->getItemsToShip(); 104 104 if( $toShip ){ 105 $return[] = array( ' {CURRENT}/shipments/new', '→ ' . '__Ship Items__' );105 $return[] = array( '../shipments/new', '→ ' . '__Ship Items__' ); 106 106 } 107 107 } … … 193 193 ob_start(); 194 194 ?> 195 <form method="post" action="HREFPOST: {CURRENT}">195 <form method="post" action="HREFPOST:.."> 196 196 197 197 <div class="hc4-form-elements"> … … 236 236 237 237 <div class="hc4-form-buttons"> 238 <button class="hc4-admin-btn-primary">__Save__</button>238 <button type="submit" class="hc4-admin-btn-primary">__Save__</button> 239 239 </div> 240 240 … … 263 263 ob_start(); 264 264 ?> 265 <div class="hc4-admin-list-primary ">265 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 266 266 267 267 <?php if( $entries ) : ?> -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/items.php
r2061857 r2149267 31 31 <?php if( $model->lines ) : ?> 32 32 33 <form method="post" action="HREFPOST: {CURRENT}">33 <form method="post" action="HREFPOST:.."> 34 34 35 <div class="hc4-admin-list-primary ">35 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 36 36 37 37 <div> … … 68 68 69 69 <div class="hc4-form-buttons"> 70 <button class="hc4-admin-btn-primary">__Save__</button>70 <button type="submit" class="hc4-admin-btn-primary">__Save__</button> 71 71 </div> 72 72 -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/items/new.php
r2061857 r2149267 13 13 {} 14 14 15 public function title( $ itemId )15 public function title( $slug, $itemId ) 16 16 { 17 17 $item = $this->repoItems->findById( $itemId ); … … 32 32 ob_start(); 33 33 ?> 34 <form method="post" action="HREFPOST: {CURRENT}">34 <form method="post" action="HREFPOST:.."> 35 35 36 36 <div class="hc4-form-elements"> … … 66 66 67 67 <div class="hc4-form-buttons"> 68 <button class="hc4-admin-btn-primary">__Add Item__</button>68 <button type="submit" class="hc4-admin-btn-primary">__Add Item__</button> 69 69 </div> 70 70 -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments.php
r2061857 r2149267 52 52 <?php endif; ?> 53 53 54 <div class="hc4-admin-list-primary ">54 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 55 55 <?php foreach( $model->lines as $e ) : ?> 56 56 <div> … … 80 80 <div class="hc-mb3"> 81 81 <div class="hc-my1"> 82 <a class="hc4-admin-title-link" href="HREFGET: {CURRENT}/<?php echo $e->id; ?>"><?php echo $e->refno; ?></a>82 <a class="hc4-admin-title-link" href="HREFGET:../<?php echo $e->id; ?>"><?php echo $e->refno; ?></a> 83 83 <?php echo $this->tf->formatDateWithWeekDay( $e->createdDate ); ?> 84 84 </div> 85 85 86 <div class="hc4-admin-list-primary ">86 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 87 87 <?php foreach( $e->lines as $l ) : ?> 88 88 <div class="hc-flex-auto-grid"> -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments/id.php
r2061857 r2149267 92 92 ob_start(); 93 93 ?> 94 <form method="post" action="HREFPOST: {CURRENT}">94 <form method="post" action="HREFPOST:.."> 95 95 96 96 <div class="hc4-form-elements"> … … 135 135 136 136 <div class="hc4-form-buttons"> 137 <button class="hc4-admin-btn-primary">__Save__</button>137 <button type="submit" class="hc4-admin-btn-primary">__Save__</button> 138 138 </div> 139 139 -
z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments/new.php
r2061857 r2149267 68 68 ob_start(); 69 69 ?> 70 <form method="post" action="HREFPOST: {CURRENT}">70 <form method="post" action="HREFPOST:.."> 71 71 72 72 <div class="hc4-form-elements"> … … 111 111 112 112 <div class="hc4-form-buttons"> 113 <button class="hc4-admin-btn-primary">__Ship Items__</button>113 <button type="submit" class="hc4-admin-btn-primary">__Ship Items__</button> 114 114 </div> 115 115 -
z-inventory-manager/trunk/zi2/22sales/ui/admin/index.php
r2061857 r2149267 28 28 ?> 29 29 30 <div class="hc4-admin-list-primary ">30 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 31 31 32 32 <?php if( $entries ) : ?> … … 45 45 <div class="hc-flex-auto-grid"> 46 46 <div> 47 <a class="hc4-admin-title-link hc-xs-block" href="HREFGET: {CURRENT}/<?php echo $e->id; ?>"><?php echo $e->refno; ?></a>47 <a class="hc4-admin-title-link hc-xs-block" href="HREFGET:../<?php echo $e->id; ?>"><?php echo $e->refno; ?></a> 48 48 </div> 49 49 <div> -
z-inventory-manager/trunk/zi2/22sales/ui/admin/new.php
r2061857 r2149267 36 36 ob_start(); 37 37 ?> 38 <form method="post" action="HREFPOST: {CURRENT}">38 <form method="post" action="HREFPOST:.."> 39 39 40 40 <div class="hc4-form-elements"> … … 64 64 65 65 <div class="hc4-form-buttons"> 66 <button class="hc4-admin-btn-primary">__Continue__</button>66 <button type="submit" class="hc4-admin-btn-primary">__Continue__</button> 67 67 </div> 68 68 -
z-inventory-manager/trunk/zi2/31inventory/boot.php
r2107074 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_31Inventory_Boot 3 implements HC4_App_Module_Interface4 3 { 5 4 public function __construct( 6 5 HC4_App_Router $router, 7 HC4_Html_Screen_ Interface$screen6 HC4_Html_Screen_Config $screen 8 7 ) 9 8 { 9 $ns = 'ZI2_31Inventory_'; 10 10 11 // UI 11 12 $router 12 ->add( 'GET/admin/inventory', 'ZI2_31Inventory_Ui_Admin_Index@get' )13 ->add( 'GET/admin/inventory/status/[:s]', 'ZI2_31Inventory_Ui_Admin_Index@get' )13 ->add( 'GET/admin/inventory', $ns . 'Ui_Admin_Index@get' ) 14 ->add( 'GET/admin/inventory/status/[:s]', $ns . 'Ui_Admin_Index@get' ) 14 15 15 ->add( 'GET/admin/inventory/new', 'ZI2_31Inventory_Ui_Admin_New@get' )16 ->add( 'POST/admin/inventory/new', 'ZI2_31Inventory_Ui_Admin_New@post' )16 ->add( 'GET/admin/inventory/new', $ns . 'Ui_Admin_New@get' ) 17 ->add( 'POST/admin/inventory/new', $ns . 'Ui_Admin_New@post' ) 17 18 18 ->add( 'GET/admin/inventory/[:id]', 'ZI2_31Inventory_Ui_Admin_Id@get' )19 ->add( 'POST/admin/inventory/[:id]', 'ZI2_31Inventory_Ui_Admin_Id@post' )19 ->add( 'GET/admin/inventory/[:id]', $ns . 'Ui_Admin_Id@get' ) 20 ->add( 'POST/admin/inventory/[:id]', $ns . 'Ui_Admin_Id@post' ) 20 21 ; 21 22 22 23 $screen 23 24 ->title( 'admin/inventory', '__Inventory__' ) 24 // ->title( 'admin/calendars/status/[:s]', 'SH5_11Calendars_View_Admin_Index@titleStatus' )25 25 26 26 ->title( 'admin/inventory/new', '__New Item__' ) 27 ->title( 'admin/inventory/[:id]', 'ZI2_31Inventory_Ui_Admin_Id@title' )27 ->title( 'admin/inventory/[:id]', $ns . 'Ui_Admin_Id@title' ) 28 28 29 29 ->menu( '', array('admin/inventory', '__Inventory__', 50) ) 30 ->menu( 'admin/inventory', array('{CURRENT}/new', '+ __New Item__') ) 30 ->menu( 'admin/inventory', array('../new', '+ __New Item__') ) 31 ; 32 33 // DELETE 34 $router 35 ->add( 'GET/admin/inventory/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@get' ) 36 ->add( 'POST/admin/inventory/[:id]/delete', $ns . 'Ui_Admin_Id_Delete@post' ) 37 ; 38 $screen 39 ->menu( 'admin/inventory/[:id]', array( '../delete', '× ' . '__Delete__', 900 ) ) 40 ->title( 'admin/inventory/[:id]/delete', '__Delete__' ) 31 41 ; 32 42 33 43 // PURCHASES ITEM SELECTOR 34 44 $router 35 ->add( 'GET/admin/purchases/[:id]/items/new', 'ZI2_31Inventory_Ui_Admin_Purchases_Selector@get' )45 ->add( 'GET/admin/purchases/[:id]/items/new', $ns . 'Ui_Admin_Purchases_Selector@get' ) 36 46 ; 37 47 38 48 // SALES ITEM SELECTOR 39 49 $router 40 ->add( 'GET/admin/sales/[:id]/items/new', 'ZI2_31Inventory_Ui_Admin_Sales_Selector@get' )50 ->add( 'GET/admin/sales/[:id]/items/new', $ns . 'Ui_Admin_Sales_Selector@get' ) 41 51 ; 42 52 } -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/id.php
r2061857 r2149267 12 12 {} 13 13 14 public function title( $ id )14 public function title( $slug, $id ) 15 15 { 16 16 $model = $this->repo->findById( $id ); … … 30 30 ob_start(); 31 31 ?> 32 <form method="post" action="HREFPOST: {CURRENT}">32 <form method="post" action="HREFPOST:.."> 33 33 34 34 <div class="hc4-form-elements"> … … 84 84 85 85 <div class="hc4-form-buttons"> 86 <button class="hc4-admin-btn-primary">__Save__</button>86 <button type="submit" class="hc4-admin-btn-primary">__Save__</button> 87 87 </div> 88 88 -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/index.php
r2107074 r2149267 50 50 $label[] = ' [' . $statusCount . ']'; 51 51 52 $return[] = array( ' {CURRENT}/status/' . $status, $label );52 $return[] = array( '../status/' . $status, $label ); 53 53 } 54 54 … … 74 74 ?> 75 75 76 <div class="hc4-admin-list-primary ">76 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 77 77 78 78 <?php if( $entries ) : ?> … … 94 94 <div class="hc-flex-auto-grid"> 95 95 <div> 96 <a class="hc4-admin-title-link hc-xs-block" href="HREFGET: {CURRENT}/<?php echo $e->id; ?>"><?php echo $e->title; ?></a>96 <a class="hc4-admin-title-link hc-xs-block" href="HREFGET:../<?php echo $e->id; ?>"><?php echo $e->title; ?></a> 97 97 </div> 98 98 -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/new.php
r2061857 r2149267 7 7 HC4_Html_Input_Text $inputText, 8 8 HC4_Html_Input_RichTextarea $inputTextarea, 9 // HC4_Html_Input_Textarea $inputTextarea, 9 10 10 11 HC4_Html_Screen_Interface $screen … … 24 25 ob_start(); 25 26 ?> 26 <form method="post" action="HREFPOST: {CURRENT}">27 <form method="post" action="HREFPOST:.."> 27 28 28 29 <div class="hc4-form-elements"> … … 78 79 79 80 <div class="hc4-form-buttons"> 80 <button class="hc4-admin-btn-primary">__Save__</button>81 <button type="submit" class="hc4-admin-btn-primary">__Save__</button> 81 82 </div> 82 83 -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/purchases/selector.php
r2107074 r2149267 43 43 ?> 44 44 45 <div class="hc4-admin-list-primary ">45 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 46 46 47 47 <?php if( $entries ) : ?> -
z-inventory-manager/trunk/zi2/31inventory/ui/admin/sales/selector.php
r2107074 r2149267 43 43 ?> 44 44 45 <div class="hc4-admin-list-primary ">45 <div class="hc4-admin-list-primary hc4-admin-list-striped"> 46 46 47 47 <?php if( $entries ) : ?> -
z-inventory-manager/trunk/zi2/99app/boot.php
r2107074 r2149267 1 1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly 2 2 class ZI2_99App_Boot 3 implements HC4_App_Module_Interface4 3 { 5 public static function bind( $appConfig)4 public static function bind() 6 5 { 7 6 $return = array(); … … 12 11 public function __construct( 13 12 HC4_Migration_Interface $migration, 14 HC4_App_Config $appConfig,15 13 16 14 HC4_Settings_Interface $settings, … … 19 17 20 18 HC4_App_Router $router, 21 HC4_Html_Screen_ Interface$screen19 HC4_Html_Screen_Config $screen 22 20 ) 23 21 { … … 31 29 32 30 $screen 33 ->css( '*', 'hc4/assets/ css/hc.css' )34 ->css( '*', 'hc4/assets/ css/hc4-theme.css' )35 ->layout( '*', 'ZI2_99App_Ui_Layout ' )31 ->css( '*', 'hc4/assets/hc.css' ) 32 ->css( '*', 'hc4/assets/hc4-theme.css' ) 33 ->layout( '*', 'ZI2_99App_Ui_Layout@' ) 36 34 ; 37 35 -
z-inventory-manager/trunk/zi2/99app/data/upgrade.php
r2061857 r2149267 16 16 17 17 HC4_Database_Interface $db, 18 HC4_Crud_Sql Table $sqlTable18 HC4_Crud_Sql_Table $sqlTable 19 19 ) 20 20 {} -
z-inventory-manager/trunk/zi2/99app/ui/index.php
r2061857 r2149267 16 16 } 17 17 18 public function title( )18 public function title( $slug ) 19 19 { 20 20 $return = NULL; -
z-inventory-manager/trunk/zi2/99app/ui/layout.php
r2107074 r2149267 4 4 { 5 5 public function __construct( 6 HC4_App $app,6 HC4_App_Index $app, 7 7 HC4_Redirect_Interface $redirect, 8 8 HC4_Html_Href_Interface $href, … … 13 13 public function render( 14 14 $slug, 15 $isAjax, 15 16 $content, 16 17 $title = NULL, … … 53 54 54 55 <?php 55 if( $this->promo ){ 56 echo $this->promo->render( $slug ); 56 if( ! $isAjax ){ 57 if( $this->promo ){ 58 echo $this->promo->render( $slug ); 59 } 60 61 // $currentUser = $this->auth->getCurrentUser(); 62 // $root = $this->renderRoot( $currentUser, $slug ); 63 // if( NULL !== $root ){ 64 // array_unshift( $breadcrumb, $root ); 65 // } 66 $breadcrumbView = $this->renderBreadcrumb( $breadcrumb ); 57 67 } 58 ?> 59 68 else { 69 $breadcrumbView = NULL; 70 } 71 ?> 72 73 <?php if( ! $isAjax ) : ?> 60 74 <div id="zi2-<?php echo $slug; ?>"> 61 75 <div class="hc4-admin-page"> 62 76 63 <?php if( $breadcrumb ) : ?> 64 <div class="hc4-breadcrumb-desktop hc-xs-hide hc-fs2"> 65 <div class="hc-inline-flex"> 66 67 <?php $ii = 0; ?> 68 <?php foreach( $breadcrumb as $menuItem ) : ?> 69 <?php list( $to, $label ) = $menuItem; ?> 70 71 <?php if( $ii ) : ?> 72 <div class="hc-px1"> 73 » 74 </div> 75 <?php endif; ?> 76 77 <div> 78 <?php if( strpos($label, '<') === FALSE ) : ?> 79 <?php echo $this->renderLink2( $to, $label, $label ); ?> 80 <?php else : ?> 81 <?php echo $label; ?> 82 <?php endif; ?> 83 </div> 84 85 <?php $ii++; ?> 86 87 <?php endforeach; ?> 88 89 <?php if( 0 && strlen($title) ) : ?> 90 <div class="hc-px1"> 91 » 92 </div> 93 <div> 94 <div class="hc4-admin-label"><?php echo $title; ?></div> 95 </div> 96 <?php endif; ?> 97 98 </div> 99 </div> 100 101 <div class="hc4-breadcrumb-mobile hc-lg-hide hc-fs2"> 102 <?php 103 $lastItem = $breadcrumb[ count($breadcrumb) - 1 ]; 104 list( $to, $label ) = $lastItem; 105 ?> 106 <div class="hc-inline-flex"> 107 <div class="hc-px1"> 108 « 109 </div> 110 111 <div> 112 <?php if( strpos($label, '<') === FALSE ) : ?> 113 <?php echo $this->renderLink( $to, $label, $label ); ?> 114 <?php else : ?> 115 <?php echo $label; ?> 116 <?php endif; ?> 117 </div> 118 </div> 77 <?php if( strlen($breadcrumbView) ) : ?> 78 <div class="hc4-page-breadcrumb"> 79 <?php echo $breadcrumbView; ?> 119 80 </div> 120 81 <?php endif; ?> 121 122 <?php if( $title OR $menuView ) : ?> 123 124 <!-- MOBILE --> 125 <div class="hc4-admin-page-header hc-lg-hide"> 126 <div class="hc4-submenu-mobile hc-nowrap"> 127 128 <?php if( $menuView && (count($menuView) > 2) ) : ?> 129 <div class="hc-collapse-container hc-nowrap"> 130 <input type="checkbox" id="hc4-submenu-mobile" class="hc-collapse-toggler hc-hide"> 131 <label for="hc4-submenu-mobile" class="hc-collapse-burger hc-block"> 132 <div class="hc-xs-flex-grid"> 133 <div class="hc-xs-col hc-xs-col-10"><h1><?php echo $title; ?></h1></div> 134 <div class="hc-xs-col hc-xs-col-2 hc-align-center"> 135 <h1 class="hc-inline-block hc-px2" title="__Menu__">⋮</h1> 136 </div> 137 </div> 138 </label> 139 140 <div class="hc-collapse-content"> 141 <div class="hc4-admin-list-primary"> 142 <?php foreach( $menuView as $menuItem ) : ?> 143 <div> 144 <?php echo $menuItem; ?> 145 </div> 146 <?php endforeach; ?> 147 </div> 148 </div> 149 </div> 150 151 <?php else : ?> 152 153 <?php if( strlen($title) ) : ?> 82 <div id="zi2-page-window"> 83 <?php endif; ?> 84 85 <div class="hc4-admin-page-header"> 86 <?php if( $title ) : ?> 87 <?php if( defined('WPINC') && is_admin() ) : ?> 88 <h1 class="wp-heading-inline hc-inline-block" style="margin: 0 0 0 0; padding: 0 0 0 0;"><?php echo $title; ?></h1> 89 <?php else : ?> 154 90 <h1><?php echo $title; ?></h1> 155 91 <?php endif; ?> 156 157 <?php foreach( $menuView as $menuItem ) : ?> 158 <div class="hc-my2"><?php echo $menuItem; ?></div> 92 <?php endif; ?> 93 94 <?php if( $menuView ) : ?> 95 <?php echo $this->renderMenu( $menuView ); ?> 96 <?php endif; ?> 97 </div> 98 99 <?php if( strlen($subheader) ) : ?> 100 <div class="hc4-admin-page-subheader"> 101 <?php echo $subheader; ?> 102 </div> 103 <?php endif; ?> 104 105 <div class="hc4-admin-page-main"> 106 <?php if( $contentAsMenu ) : ?> 107 <div class="hc4-admin-list-secondary"> 108 <?php foreach( $contentAsMenu as $menuItem ) : ?> 109 <div> 110 <?php echo $menuItem; ?> 111 </div> 159 112 <?php endforeach; ?> 160 161 <?php endif; ?> 162 </div> 163 </div> 164 <!-- END OF MOBILE --> 165 166 <!-- DESKTOP --> 167 <?php if( $menuView OR strlen($title) ) : ?> 168 <div class="hc4-admin-page-header hc-xs-hide"> 169 <?php if( (count($menuView) == 1) && strlen($title) && (strlen($title) < 30) ) : ?> 170 <?php if( defined('WPINC') && is_admin() ) : ?> 171 <h1 class="wp-heading-inline hc-inline-block" style="margin: 0 0 0 0; padding: 0 0 0 0;"><?php echo $title; ?></h1> 172 <div class="hc-inline-block"> 173 <?php foreach( $menuView as $menuItem ) : ?> 174 <?php echo $menuItem; ?> 175 <?php endforeach; ?> 176 </div> 177 <?php else : ?> 178 <div class="hc-inline-flex"> 179 <div> 180 <h1><?php echo $title; ?></h1> 181 </div> 182 <?php foreach( $menuView as $menuItem ) : ?> 183 <div class="hc-px1"><?php echo $menuItem; ?></div> 184 <?php endforeach; ?> 185 </div> 186 <?php endif; ?> 187 113 </div> 114 <?php else : ?> 115 <?php echo $content; ?> 116 <?php endif; ?> 117 </div> 118 119 <?php if( strlen($subfooter) ) : ?> 120 <div class="hc4-admin-page-subfooter"> 121 <?php echo $subfooter; ?> 122 </div> 123 <?php endif; ?> 124 125 <?php if( ! $isAjax ) : ?> 126 </div> 127 </div> 128 </div> 129 <?php endif; ?> 130 131 <?php 132 $return = ob_get_clean(); 133 return $return; 134 } 135 136 public function renderBreadcrumb( $breadcrumb ) 137 { 138 if( ! $breadcrumb ){ 139 return; 140 } 141 142 ob_start(); 143 ?> 144 145 <!-- DESKTOP --> 146 <div class="hc4-breadcrumb-desktop hc-xs-hide hc-fs2"> 147 <div class="hc-inline-flex"> 148 149 <?php $ii = 0; ?> 150 <?php foreach( $breadcrumb as $menuItem ) : ?> 151 <?php list( $to, $label ) = $menuItem; ?> 152 153 <?php if( $ii ) : ?> 154 <div class="hc-px1"> 155 » 156 </div> 157 <?php endif; ?> 158 159 <div> 160 <?php if( strpos($label, '<') === FALSE ) : ?> 161 <?php echo $this->renderLink2( $to, $label, $label ); ?> 188 162 <?php else : ?> 189 <?php if( strlen($title) ) : ?> 190 <h1 style="margin: 0 0 0 0; padding: 0 0 0 0;"><?php echo $title; ?></h1> 191 <?php endif; ?> 192 193 <?php if( $menuView ) : ?> 194 <div class="hc4-submenu-desktop"> 195 <div class="hc-inline-flex"> 196 <?php $ii = 0; ?> 197 <?php foreach( $menuView as $menuItem ) : ?> 198 <?php if( $ii ) : ?> 199 <div class="hc-px1"> </div> 200 <?php endif; ?> 201 <div> 202 <?php echo $menuItem; ?> 203 </div> 204 <?php $ii++; ?> 205 <?php endforeach; ?> 206 </div> 207 </div> 208 <?php endif; ?> 163 <?php echo $label; ?> 209 164 <?php endif; ?> 210 165 </div> 211 <?php endif; ?> 212 <!-- END OF DESKTOP --> 213 <?php endif; ?> 214 215 <?php if( strlen($subheader) ) : ?> 216 <div class="hc4-admin-page-subheader"> 217 <?php echo $subheader; ?> 218 </div> 219 <?php endif; ?> 220 221 <div class="hc4-admin-page-main"> 222 <?php if( $contentAsMenu ) : ?> 166 167 <?php $ii++; ?> 168 169 <?php endforeach; ?> 170 </div> 171 </div> 172 <!-- END OF DESKTOP --> 173 174 <!-- MOBILE --> 175 <div class="hc4-breadcrumb-mobile hc-lg-hide hc-fs2"> 176 <?php 177 $lastItem = $breadcrumb[ count($breadcrumb) - 1 ]; 178 list( $to, $label ) = $lastItem; 179 ?> 180 181 <div class="hc-grid"> 182 <div class="hc-xs-col hc-xs-col-1 hc-valign-middle hc-align-center hc-py1">«</div> 183 184 <div class="hc-xs-col hc-xs-col-11 hc-valign-middle"> 185 <?php if( strpos($label, '<') === FALSE ) : ?> 186 <?php echo $this->renderLink2( $to, $label, $label ); ?> 187 <?php else : ?> 188 <?php echo $label; ?> 189 <?php endif; ?> 190 </div> 191 </div> 192 </div> 193 <!-- END OF MOBILE --> 194 195 <?php 196 return ob_get_clean(); 197 } 198 199 public function renderMenu( array $menuView ) 200 { 201 $menuHtmlId = HC4_App_Functions::generateRand( 4 ); 202 203 ob_start(); 204 ?> 205 206 <!-- MOBILE --> 207 <div class="hc4-submenu"> 208 <div class="hc4-submenu-mobile hc-nowrap hc-lg-hide"> 209 <div class="hc-collapse-container hc-nowrap"> 210 <input type="checkbox" id="hc4-submenu-<?php echo $menuHtmlId; ?>" class="hc-collapse-toggler hc-hide"> 211 <label for="hc4-submenu-<?php echo $menuHtmlId; ?>" class="hc-collapse-burger hc-block hc-border hc-p1 hc-my1"> 212 <div class="hc-px2" title="__Menu__">⋮ __Menu__</div> 213 </label> 214 215 <div class="hc-collapse-content"> 223 216 <div class="hc4-admin-list-secondary"> 224 <?php foreach( $ contentAsMenuas $menuItem ) : ?>217 <?php foreach( $menuView as $menuItem ) : ?> 225 218 <div> 226 219 <?php echo $menuItem; ?> … … 228 221 <?php endforeach; ?> 229 222 </div> 230 <?php else : ?> 231 <?php echo $content; ?> 232 <?php endif; ?> 233 </div> 234 235 <?php if( strlen($subfooter) ) : ?> 236 <div class="hc4-admin-page-subfooter"> 237 <?php echo $subfooter; ?> 238 </div> 239 <?php endif; ?> 240 241 </div> 223 </div> 224 </div> 225 </div> 226 <!-- END OF MOBILE --> 227 228 <!-- DESKTOP --> 229 <div class="hc4-submenu-desktop hc-xs-hide"> 230 <div class="hc-inline-flex"> 231 <?php $ii = 0; ?> 232 <?php foreach( $menuView as $menuItem ) : ?> 233 <?php if( $ii ) : ?> 234 <div class="hc-px1"> </div> 235 <?php endif; ?> 236 <div> 237 <?php echo $menuItem; ?> 238 </div> 239 <?php $ii++; ?> 240 <?php endforeach; ?> 241 </div> 242 </div> 243 <!-- END OF DESKTOP --> 242 244 </div> 243 245 … … 301 303 302 304 if( $to ){ 303 $to = str_replace( ' {CURRENT}', $slug, $to );305 $to = str_replace( '..', $slug, $to ); 304 306 if( ! $this->app->check( $method, $to ) ){ 305 307 return; -
z-inventory-manager/trunk/zi2/99app/ui/promo/promo.php
r2061857 r2149267 5 5 public function __construct( 6 6 ) 7 {} 7 { 8 } 8 9 9 10 public function render( $slug ) … … 14 15 15 16 // show on homepage only 16 if( $slug ){ 17 // if( $slug ){ 18 // return; 19 // } 20 if( 'admin' !== substr($slug, 0, strlen('admin')) ){ 17 21 return; 18 22 } … … 26 30 27 31 <?php if( is_admin() ) : ?> 28 <div class="update-nag hc-block hc- fs4 hc-my3">32 <div class="update-nag hc-block hc-my3"> 29 33 <?php else : ?> 30 <div class="hc-border hc-border-olive hc-rounded hc-p3 hc-block hc-fs4">34 <div class="hc-border hc-border-olive hc-rounded hc-p3 hc-block"> 31 35 <?php endif; ?> 32 36 <span class="dashicons dashicons-star-filled hc-olive"></span> <a target="_blank" href="https://www.z-inventory-manager.com/order/"><strong>Z Inventory Manager Pro</strong></a> with nice features like item stats and history, copying sales and purchases, and more!
Note: See TracChangeset
for help on using the changeset viewer.