Plugin Directory

Changeset 2149267


Ignore:
Timestamp:
09/01/2019 10:31:43 PM (6 years ago)
Author:
hitcode
Message:

2.0.2

Location:
z-inventory-manager/trunk
Files:
53 added
25 deleted
95 edited

Legend:

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

    r2107074 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
     2interface 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
    215class HC4_App_Events
     16implements HC4_App_Events_
    317{
    418    protected $listeners = array();
    5     public $debug = FALSE;
    619
    720    public function __construct(
    821        HC4_App_Factory $factory,
    9         HC4_App_Profiler $profiler
     22        HC4_App_Profiler $profiler,
     23        $debug = FALSE
    1024    )
    1125    {}
    1226
     27    /* REGISTER TO LISTEN EVENT */
    1328    public function listen( $eventName, $handler )
    1429    {
    1530        if( $this->debug ){
     31            $checkEventName = $eventName;
     32            if( 'filter:' == substr($checkEventName, 0, strlen('filter:')) ){
     33                $checkEventName = substr($checkEventName, strlen('filter:'));
     34            }
     35
    1636            // check if event exists
    17             if( FALSE === strpos($eventName, '@') ){
    18                 if( ! class_exists($eventName) ){
     37            if( FALSE === strpos($checkEventName, '@') ){
     38                if( ! class_exists($checkEventName) ){
    1939                    echo __CLASS__ . ": event '$eventName' doesn't exist<br>";
    2040                    return $this;
     
    2242            }
    2343            else {
    24                 list( $className, $methodName ) = explode( '@', $eventName );
     44                list( $className, $methodName ) = explode( '@', $checkEventName );
    2545                if( ! method_exists($className, $methodName) ){
    2646                    echo __CLASS__ . ": event '$eventName' doesn't exist<br>";
     
    3151            // check handler
    3252            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 );
    3458
    35                 if( FALSE === strpos($eventName, '@') ){
    36                     $className = $eventName;
     59                if( FALSE === strpos($checkHandler, '@') ){
     60                    $className = $checkHandler;
    3761                    $methodName = '__invoke';
    3862                }
    3963                else {
    40                     list( $className, $methodName ) = explode( '@', $handler );
     64                    list( $className, $methodName ) = explode( '@', $checkHandler );
    4165                }
    4266
    4367                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>";
    4569                    return $this;
    4670                }
     
    5680    }
    5781
    58     public function publish( $eventName, array $args = array() )
     82    /* REGISTER TO MODIFY THE EVENT OUTPUT */
     83    public function registerFilter( $eventName, $handler )
    5984    {
     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 );
    6093        $listeners = $this->getListeners( $eventName );
    6194
     95        array_unshift( $args, $return );
    6296        reset( $listeners );
    6397        foreach( $listeners as $handler ){
     
    73107
    74108        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;
    75137    }
    76138
     
    95157            $handler = array( $handler, $method );
    96158            if( ! is_object($handler[0]) ){
    97                 $handler[0] = $this->factory->make( $handler[0] );
     159                $handler[0] = $this->factory->make( $handler[0], __CLASS__ );
    98160            }
    99161        }
  • z-inventory-manager/trunk/hc4/app/factory.php

    r2107074 r2149267  
    44    protected $bind = array();
    55    protected $appModules = array();
     6    protected $profiler = NULL;
    67
    78    public function __construct(
     
    1516        foreach( $bind as $k => $v ){
    1617            $k = strtolower( $k );
    17             if( ! is_object($v) ){
     18            if( is_array($v) ){
     19               
     20            }
     21            elseif( ! is_object($v) ){
    1822                $v = strtolower( $v );
    1923            }
     
    2125        }
    2226
    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     }
     27if( 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    // }
    3548
    3649/**
    3750* Makes a functor object of a class. All of them are singletons.
    3851*
    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.
    4054*
    4155* @return object
    4256*/
    43     public function make()
    44     {
     57    public function make( $className, $callingClassName )
     58    {
     59// if( $this->profiler ){
     60    // $this->profiler->markStart( __METHOD__ );
     61// }
    4562        static $_reflections = array();
    46 
    47         $args = $originalArgs = func_get_args();
    48         $className = array_shift( $args );
    4963
    5064        if( __CLASS__ == $className ){
     
    5367
    5468        $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        }
    5576
    5677        if( ! isset($this->bind[$className]) ){
    5778            $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            }
    5888        }
    5989
     
    6797        }
    6898
    69         $args = $this->makeArgs( $realClassName, '__construct', $args );
    70 
     99if( $this->profiler ){
     100    $this->profiler->markStart( __METHOD__ );
     101}
     102
     103if( $this->profiler ){
     104    $this->profiler->markFactory( $realClassName );
     105}
     106
     107    // __construct
     108        $args = $this->makeArgs( $realClassName, '__construct', $callingClassName );
    71109        if( $args ){
     110// echo "JO '$realClassName'<br>";
    72111            $class = new ReflectionClass( $realClassName );
    73 // echo "JO '$realClassName'<br>";
    74112            $return = $class->newInstanceArgs( $args );
    75113
     
    94132        }
    95133
     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
    96146        $this->bind[$className] = $return;
     147if( $this->profiler ){
     148    $this->profiler->markEnd( __METHOD__ );
     149}
    97150        return $return;
    98151    }
    99152
    100     public function makeArgs( $className, $methodName, array $args = array() )
     153    public function getArgs( $className, $methodName )
    101154    {
    102155        static $_reflections = array();
    103156
     157        $return = array();
     158
     159        if( is_object($className) ){
     160            $className = get_class( $className );
     161        }
    104162        $className = strtolower( $className );
     163
    105164        if( ! isset($_reflections[$className]) ){
    106165            $_reflections[$className] = new ReflectionClass( $className );
     
    108167        $classReflection = $_reflections[$className];
    109168
    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    {
    117181        $return = array();
    118182
    119         $needArgs = $methodReflection->getParameters();
     183        $className = strtolower( $className );
     184        $needArgs = $this->getArgs( $className, $methodName );
     185
    120186        $numberOfArgs = count( $needArgs );
    121         $suppliedNumberOfArgs = count( $args );
    122187
    123188        for( $ii = 0; $ii < $numberOfArgs; $ii++ ){
     
    125190            $needArgName = $needArg->getName();
    126191
    127             if( $ii < $suppliedNumberOfArgs ){
    128                 $return[ $needArgName ] = $args[ $ii ];
    129                 continue;
    130             }
    131 
    132192    // NEED TO INJECT MISSING ARGS
    133193            $isOptional = $needArg->isOptional();
    134 
    135194            $argCreated = FALSE;
    136195
     
    142201                    $needArgClassName = strtolower( $needArgClassName );
    143202
     203                // CHECK CIRCULAR REFERENCE
     204                    if( $needArgClassName === $callingClassName ){
     205                        echo __CLASS__ . ': circular reference<br>' . $callingClassName . ' -> ' . $className . ' -> ' . $needArgClassName . '<br>';
     206                        exit;
     207                    }
     208
    144209                /* NOW CHECK IF THE PARENT CLASS IS ALLOWED TO MAKE ITS ARGUMENT */
    145210                // 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;
    155231                        }
    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                    }
    179233                }
    180234            }
    181235            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();
    183238                exit;
    184239            }
     
    191246            $return[ $needArgName ] = $arg;
    192247        }
     248// if( $this->profiler ){
     249    // $this->profiler->markEnd( __METHOD__ );
     250// }
    193251
    194252        return $return;
    195253    }
    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  
    214214    }
    215215
     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
    216257    public static function makeCombos( $array )
    217258    {
     
    240281    }
    241282
    242     public static function getCombinations( array $options )
     283    public static function getCombinations( array $options, $withNull = FALSE, $withTotalNull = FALSE )
    243284    {
    244285        $combinations = array( array() );
     
    250291                    $tmp[] = array_merge( $v1, array($v2) );
    251292                }
     293                if( $withNull ){
     294                    $tmp[] = $v1;
     295                }
    252296            }
    253297            $combinations = $tmp;
    254298        }
     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        });
    255323
    256324        return $combinations;
  • z-inventory-manager/trunk/hc4/app/profiler.php

    r2107074 r2149267  
    44    private $benchmark = NULL;
    55    protected $_available_sections = array(
     6        'handlers',
    67        'benchmarks',
    78        'memory_usage',
    8         'uri_string',
    9         'controller_info',
    109        'queries',
    1110        'events',
     11        'factory',
    1212        'get',
    1313        'post',
     
    2222    protected $lastQuery = array();
    2323    protected $events = array();
     24    protected $factory = array();
     25    protected $handlers = array();
    2426
    2527    public function __construct()
     
    3941    {
    4042        $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;
    4155        return $this;
    4256    }
     
    103117        $output .= "\n\n<table style='width:100%;'>\n";
    104118
    105         $decimals = 4;
     119        $decimals = 6;
    106120        $total = $profile['total'][0];
    107121        reset( $profile );
     
    266280    }
    267281
    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;">&nbsp;&nbsp;'.'profiler_uri_string'.'&nbsp;&nbsp;</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;">&nbsp;&nbsp;'.'profiler_controller_info'.'&nbsp;&nbsp;</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 
    304282    protected function _compile_memory_usage()
    305283    {
     
    370348            $output .= "\n\n<table style='width:100%; border:none'>\n";
    371349
     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."&nbsp;&nbsp; </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();
    372358            foreach ( $this->events as $e ){
    373359                list( $eventName, $handlerName ) = $e;
    374                
    375                 $output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>".$eventName."&nbsp;&nbsp; </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."&nbsp;&nbsp; </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>";
    376374                $output .= $handlerName;
    377375                $output .= "</td></tr>\n";
     
    380378            $output .= "</table>\n";
    381379        }
     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;">&nbsp;&nbsp;'.'profiler_factory: ' . count($this->factory) .'&nbsp;&nbsp;</legend>';
     391        $output .= "\n";
     392
     393        $classNames = $this->factory;
     394        sort( $classNames );
     395
     396        $output .= "\n\n<table style='width:100%;'>\n";
     397        foreach( $classNames as $className ){
     398            $output .= "<tr><td style='padding:3px;border:#bbb 1px solid;'>";
     399            $output .= $className;
     400            $output .= "</td></tr>\n";
     401        }
     402        $output .= "</table>\n";
     403
     404        $output .= "</fieldset>";
     405
     406        return $output;
     407    }
     408
     409    protected function _compile_handlers()
     410    {
     411        $output  = "\n\n";
     412        $output .= '<fieldset id="ci_profiler_events" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
     413        $output .= "\n";
     414        $output .= '<legend style="color:#cd6e00;">&nbsp;&nbsp;'.'profiler_handlers: ' .'&nbsp;&nbsp;</legend>';
     415        $output .= "\n";
     416
     417        $output .= "\n\n<table style='width:100%;'>\n";
     418        foreach( $this->handlers as $handler ){
     419            $output .= "<tr><td style='padding:3px;border:#bbb 1px solid;'>";
     420            $output .= $handler;
     421            $output .= "</td></tr>\n";
     422        }
     423        $output .= "</table>\n";
     424
    382425        $output .= "</fieldset>";
    383426
     
    438481    public function markEnd( $name )
    439482    {
    440         $this->marker[$name] +=  microtime( TRUE );
     483        if( isset($this->marker[$name]) ){
     484            $this->marker[$name] += microtime( TRUE );
     485        }
    441486    }
    442487
  • z-inventory-manager/trunk/hc4/app/request.php

    r2061857 r2149267  
    4545        }
    4646
     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        }
    4756        return $return;
    4857    }
  • z-inventory-manager/trunk/hc4/app/router.php

    r2107074 r2149267  
    22interface HC4_App_Router_
    33{
    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 );
    68}
    79
     
    911{
    1012    protected $routes = array();
     13    protected $aliases = array();
     14    protected $closed = FALSE;
    1115
    1216    public function __construct(
     17        HC4_App_Profiler $profiler
    1318    )
    1419    {}
    1520
    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;
    31118    }
    32119
    33120    public function alias( $alias, $real )
    34121    {
    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, '{' );
    39231            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;
    112241        return $return;
    113242    }
  • z-inventory-manager/trunk/hc4/app/uri.php

    r2061857 r2149267  
    185185
    186186        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            }
    188193        }
    189194        else {
  • z-inventory-manager/trunk/hc4/database/boot.php

    r2107074 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class HC4_Database_Boot
    3     implements HC4_App_Module_Interface
    43{
    5     public static function bind( array $appConfig )
     4    public static function bind2( array $appConfig )
    65    {
    76        $bind = array();
  • z-inventory-manager/trunk/hc4/database/prefixed.php

    r2107074 r2149267  
    66    public $prefix = NULL;
    77
    8     public function __construct( HC4_Database_Interface $db, $prefix )
     8    public function __construct(
     9        HC4_Database_Interface $db,
     10        $prefix
     11    )
    912    {
    1013        $this->db = $db;
  • z-inventory-manager/trunk/hc4/database/profiled.php

    r2107074 r2149267  
    66    protected $profiler = NULL;
    77
    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    )
    912    {
    1013        $this->db = $db;
  • z-inventory-manager/trunk/hc4/html/href/boot.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class HC4_Html_Href_Boot
    3     implements HC4_App_Module_Interface
    43{
    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             // ASSETS
    24                 $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             // ASSETS
    47                 $templateAsset = JUri::base() . 'components/com_' . $myAppName . '/' . '{SLUG}';
    48                 break;
    49 
    50             case 'wordpress':
    51                 $templateGet = $uri->makeUrl( '{SLUG}' );
    52 
    53             // API
    54                 $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             // POST
    67                 // $templatePost = $templateApi;
    68                 $templatePost = $templateGet;
    69                 $templatePost .= ( FALSE === strpos($templatePost, '?') ) ? '?' : '&';
    70                 $templatePost .= 'hcs=' . $myAppShortName;
    71 
    72             // ASSETS
    73                 $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 FILE
    80         $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     }
    904}
  • z-inventory-manager/trunk/hc4/html/input/boot.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class HC4_Html_Input_Boot
    3     implements HC4_App_Module_Interface
    43{
    5     public static function bind( array $appConfig )
     4    public static function bind()
    65    {
    76        $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';
    238        return $bind;
    249    }
  • z-inventory-manager/trunk/hc4/html/input/checkbox.php

    r2107074 r2149267  
    1212
    1313        $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        }
    1617
    1718        if( NULL !== $label ){
     
    1920        }
    2021
    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 . '"';
    2223        if( $checked ){
    2324            $out[] = ' checked="checked"';
     
    2627
    2728        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;
    2943            $out[] = '</span>';
    3044        }
    3145
    32         $out[] = '</label>';
     46        if( NULL !== $label ){
     47            $out[] = '</label>';
     48        }
    3349
    3450        $out = join( '', $out );
  • z-inventory-manager/trunk/hc4/html/input/checkboxdetails.php

    r2107074 r2149267  
    1010    public function render( $name, $value, $checked, $label, $details = NULL, $inverse = FALSE )
    1111    {
    12         $myId = 'hc4-input-checkboxdetails-' . HC4_App_Functions::generateRand(2);
     12        $myId = 'hc4-input-checkboxdetails-' . HC4_App_Functions::generateRand(4);
    1313
    1414        $value = $this->helper->getValue( $name, $value );
     
    1919
    2020        $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        // }
    2932
    3033        $out = join( '', $out );
  • z-inventory-manager/trunk/hc4/html/input/checkboxset.php

    r2107074 r2149267  
    2121        foreach( $options as $k => $label ){
    2222            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">';
    2424            }
    2525            else {
  • z-inventory-manager/trunk/hc4/html/input/multiset.php

    r2061857 r2149267  
    44    public function __construct(
    55        HC4_Html_Input_Helper $helper,
    6         HC4_Html_Input_RadioSet $inputRadioSet
     6        HC4_Html_Input_RadioSet $inputRadioSet,
     7        HC4_Html_Input_Radio $inputRadio
    78    )
    89    {}
     
    1112    {
    1213        $myId = 'hc4-input-multiset-' . HC4_App_Functions::generateRand(2);
    13 
    1414        $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 );
    2715
    2816        ob_start();
     
    3018
    3119<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
    3328</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?>
    3468
    3569<script>
     
    3872function MultiSetInput( el ){
    3973    var ii = 0, jj = 0;
    40     var togglers = el.getElementsByClassName( 'hc4-input-radio' );
     74    var togglers = el.getElementsByClassName( 'hc4-input-multiset-toggler' );
    4175    var details = el.getElementsByClassName( 'hc4-input-multiset-detail' );
    4276
     
    69103</script>
    70104
    71 
    72105<?php
    73106        return ob_get_clean();
  • z-inventory-manager/trunk/hc4/html/input/radio.php

    r2107074 r2149267  
    77    {}
    88
    9     public function render( $name, $k, $checked = FALSE, $label = NULL )
     9    public function render( $name, $k, $checked = FALSE, $label = NULL, $moreClass = '' )
    1010    {
    1111        // $checked = $this->helper->getValue( $name, $checked );
     
    1919        }
    2020
    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 . '"';
    2227        if( $checked ){
    2328            $out[] = ' checked="checked"';
  • z-inventory-manager/trunk/hc4/html/input/radioset.php

    r2107074 r2149267  
    88    {}
    99
    10     public function renderInline( $name, array $options = array(), $value = NULL )
     10    public function renderInline( $name, array $options = array(), $value = NULL, $moreClass = '' )
    1111    {
    12         return $this->render( $name, $options, $value, TRUE );
     12        return $this->render( $name, $options, $value, TRUE, $moreClass );
    1313    }
    1414
    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 = '' )
    1616    {
    1717        $value = $this->helper->getValue( $name, $value );
     
    2121        foreach( $options as $k => $label ){
    2222            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">';
    2424            }
    2525            else {
     
    2828
    2929            $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 );
    3131
    3232            $out[] = '</div>';
  • z-inventory-manager/trunk/hc4/html/input/text.php

    r2061857 r2149267  
    77    {}
    88
    9     public function render( $name, $value = NULL )
     9    public function render( $name, $value = NULL, $size = NULL )
    1010    {
    1111        $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 .= '>';
    1517        $out = $this->helper->afterRender( $name, $out );
    16 
    1718        return $out;
    1819    }
  • z-inventory-manager/trunk/hc4/html/input/wordpress/richtextarea.php

    r2061857 r2149267  
    1111    {
    1212        $value = $this->helper->getValue( $name, $value );
    13 
    14         // $out = '<input type="text" name="' . $name . '" value="' . $value . '" class="hc4-form-input">';
    1513
    1614        $wpEditorSettings = array();
     
    3129            );
    3230
    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();
    4833
    4934        $out = ob_get_clean();
     
    5338        return $out;
    5439    }
    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 away
    67         ob_start();
    68 
    69         $editorId = $this->htmlId();
    70         wp_editor(
    71             $this->value,
    72             $editorId,
    73             $wpEditorSettings
    74             );
    75 
    76         if( 0 )
    77         {
    78             $more_js = <<<EOT
    79 <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             $out
    120                 ->addAttr('placeholder', $this->label)
    121                 ;
    122         }
    123 
    124         if( $this->bold ){
    125             $out
    126                 ->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     }
    14140}
  • z-inventory-manager/trunk/hc4/html/screen/abstract.php

    r2107074 r2149267  
    22abstract class HC4_Html_Screen_Abstract
    33{
    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__ );
    147
    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 out
    166         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     // priority
    178         $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 re
    315             $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 things
    324             $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     {
    3948    // ANNOUNCE IF ANY
    3959        $announceView = NULL;
     
    40620
    40721    // 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 );
    40932        if( is_array($title) ){
    41033            $title = join( ' ', $title );
    41134        }
    41235
    413         $menu = $this->getMenu( $slug );
    414         $breadcrumb = $this->getBreadcrumb( $slug );
    415         $subheader = $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 );
    41740
    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            );
    42251        $return = $this->csrf->render( $return );
    42352
     
    42655
    42756    // HREFS
     57$this->profiler->markStart( __METHOD__ . ':hrefProcessOutput' );
    42858        $return = $this->href->processOutput( $return );
     59$this->profiler->markEnd( __METHOD__ . ':hrefProcessOutput' );
     60
     61$this->profiler->markEnd( __METHOD__ );
    42962
    43063        return $return;
  • z-inventory-manager/trunk/hc4/html/screen/boot.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class HC4_Html_Screen_Boot
    3     implements HC4_App_Module_Interface
    43{
    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     }
    254}
  • z-inventory-manager/trunk/hc4/html/screen/interface.php

    r2107074 r2149267  
    33{
    44    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 );
    185}
  • z-inventory-manager/trunk/hc4/html/screen/layout/interface.php

    r2107074 r2149267  
    44    public function render(
    55        $slug,
     6        $isAjax,
    67        $content,
    78        $title = NULL,
  • z-inventory-manager/trunk/hc4/migration/boot.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class HC4_Migration_Boot
    3     implements HC4_App_Module_Interface
    43{
    5     public static function bind( array $appConfig )
     4    public static function bind()
    65    {
    76        $bind = array();
  • z-inventory-manager/trunk/hc4/migration/settings.php

    r2061857 r2149267  
    1313    public function register( $migrationName, $migrationVersion, $migrationHandler )
    1414    {
     15        $confName = 'migration_' . $migrationName;
     16        $this->settings->init( $confName, 0 );
     17
    1518        $this->migrations[] = array( $migrationName, $migrationVersion, $migrationHandler );
    1619        return $this;
     
    3336
    3437                if( ! is_object($handler[0]) ){
    35                     $handler[0] = $this->factory->make( $handler[0] );
     38                    $handler[0] = $this->factory->make( $handler[0], __CLASS__ );
    3639                }
    3740
     
    5053            $installedVersion = 0;
    5154        }
    52 
    5355        return $installedVersion;
    5456    }
     
    5860        $confName = 'migration_' . $migrationName;
    5961        $this->settings->set( $confName, $newVersion );
     62        return $this;
    6063    }
    6164}
  • z-inventory-manager/trunk/hc4/redirect/ajax.php

    r2061857 r2149267  
    55    public function call( $to )
    66    {
    7         $out = array( 'redirect' => $to );
    8         $out = json_encode( $out );
     7        $out = '<hc4redirect>' . $to . '</hc4redirect>';
    98        echo $out;
    109        exit;
  • z-inventory-manager/trunk/hc4/redirect/boot.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class HC4_Redirect_Boot
    3     implements HC4_App_Module_Interface
    43{
    5     public static function bind( array $appConfig )
     4    public static function bind()
    65    {
    76        $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';
    208        return $bind;
    219    }
  • z-inventory-manager/trunk/hc4/session/boot.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class HC4_Session_Boot
    3     implements HC4_App_Module_Interface
    43{
    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() )
    613    {
    714        $bind = array();
     15        $bind['HC4_Session_Interface'] = 'HC4_Session_Implementation';
    816
    9         $bind['HC4_Session_Interface'] = 'HC4_Session_Implementation';
     17        if( isset($config['prefix']) ){
     18            $bind['HC4_Session_Implementation->prefix'] = $config['prefix'];
     19        }
    1020
    1121        return $bind;
  • z-inventory-manager/trunk/hc4/settings/database/crud.php

    r2061857 r2149267  
    88        HC4_Database_Interface $db,
    99        HC4_Database_QueryBuilder $q,
    10         HC4_Settings_Database_Crud_Table $table
     10        $table
    1111    )
    1212    {}
  • z-inventory-manager/trunk/hc4/time/boot.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class HC4_Time_Boot
    3     implements HC4_App_Module_Interface
    43{
    5     public static function bind( array $appConfig )
     4    public static function bind()
    65    {
    76        $bind = array();
  • z-inventory-manager/trunk/hc4/time/format.php

    r2107074 r2149267  
    1212    public function formatDuration( $seconds );
    1313    public function formatDurationVerbose( $seconds );
     14    public function formatDurationFromText( $text );
    1415}
    1516
     
    133134    }
    134135
     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
    135145    public function formatDurationVerbose( $seconds )
    136146    {
    137147        $seconds = (string) $seconds;
    138148
    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);
    141153        $minutes = floor( $remain / 60 );
    142154
    143155        $return = array();
     156
     157        if( $days ){
     158            $daysView = $days;
     159            $daysView = $daysView . '' . '__d__';
     160            $return[] = $daysView;
     161        }
    144162
    145163        if( $hours ){
  • z-inventory-manager/trunk/hc4/time/implementation.php

    r2107074 r2149267  
    200200    }
    201201
    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        }
    206211        return $return;
    207212    }
     
    724729        return $return;
    725730    }
     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    }
    726745}
  • z-inventory-manager/trunk/hc4/time/interface.php

    r2061857 r2149267  
    5151
    5252    public function getDifferenceInDays( $date1, $date2 );
     53    public function getAllDates( $startDate, $endDate );
    5354}
  • z-inventory-manager/trunk/readme.txt

    r2112339 r2149267  
    6969== Changelog ==
    7070
     71= 2.0.2 =
     72* Added delete actions for items, purchases and sales.
     73* Internal framework update.
     74
    7175= 2.0.1 =
    7276* If WooCommerce is installed, our plugin can use its products as inventory source.
  • z-inventory-manager/trunk/z-inventory-manager2.php

    r2107074 r2149267  
    44* Plugin URI: https://www.z-inventory-manager.com/
    55* Description: Manage your inventory - keep track of purchases, sales, transfers.
    6 * Version: 2.0.1
     6* Version: 2.0.2
    77* Author: hitcode.com
    88* Author URI: https://www.hitcode.com/
     
    1313include_once( dirname(__FILE__) . '/zi2-base.php' );
    1414
    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  
    1616class ZInventoryManager2_Wordpress
    1717{
    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 );
    2640
    2741        add_action( 'init', array($this, '_init') );
     
    3549        add_filter( 'parent_file', array($this, 'setCurrentAppMenu') );
    3650
    37         $this->hc4init();
    3851        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;
    5369    }
    5470
     
    143159    }
    144160
    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 
    176161    public function adminSubmenu()
    177162    {
     
    179164        $menuSlug = $this->myAdminPage;
    180165
    181         $screen = $this->app->factory('HC4_Html_Screen_Interface');
     166        $screen = $this->app->factory('HC4_Html_Screen_Config');
    182167        $translate = $this->app->factory('HC4_Translate_Interface');
    183168
    184169        $menuItems = $screen->getMenu( '' );
    185 
    186170        $mySubmenuCount = 0;
    187171
     
    261245        return $parentFile;
    262246    }
     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    }
    263278}
    264279
  • z-inventory-manager/trunk/zi2/01users/boot.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_01Users_Boot
    3     implements HC4_App_Module_Interface
    43{
    54    public function __construct(
    65        HC4_App_Router $router,
    7         HC4_Html_Screen_Interface $screen
     6        HC4_Html_Screen_Config $screen
    87    )
    98    {
  • z-inventory-manager/trunk/zi2/02conf/boot.php

    r2107074 r2149267  
    1111
    1212class ZI2_02Conf_Boot
    13     implements HC4_App_Module_Interface
    1413{
    15     public static function bind( array $appConfig )
     14    public static function bind()
    1615    {
    1716        $bind = array();
    1817        $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';
    2019        return $bind;
    2120    }
     
    2524        HC4_Settings_Interface $settings,
    2625        HC4_App_Router $router,
    27         HC4_Html_Screen_Interface $screen
     26        HC4_Html_Screen_Config $screen
    2827    )
    2928    {
     
    5352        $screen
    5453            ->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__') )
    5756
    5857            ->title(    'admin/conf',               '__Settings__' )
  • z-inventory-manager/trunk/zi2/02conf/ui/admin/datetime.php

    r2061857 r2149267  
    3636        }
    3737
    38         $return = $this->render( $values );
     38        $return = $this->render( $slug, $values );
    3939        $return = $this->screen->render( $slug, $return );
    4040        return $return;
    4141    }
    4242
    43     public function render( array $values )
     43    public function render( $slug, array $values )
    4444    {
    4545        ob_start();
    4646?>
    4747
    48 <form method="post" action="HREFPOST:{CURRENT}">
     48<form method="post" action="HREFPOST:<?php echo $slug; ?>">
    4949    <div class="hc4-form-elements">
    5050
  • z-inventory-manager/trunk/zi2/02conf/ui/admin/email.php

    r2061857 r2149267  
    4545?>
    4646
    47 <form method="post" action="HREFPOST:{CURRENT}">
     47<form method="post" action="HREFPOST:..">
    4848    <div class="hc4-form-elements">
    4949
  • z-inventory-manager/trunk/zi2/03acl/boot.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_03Acl_Boot
    3     implements HC4_App_Module_Interface
    43{
    54    public function __construct(
     
    98        HC4_Settings_Interface $settings,
    109        HC4_App_Router $router,
    11         HC4_Html_Screen_Interface $screen
     10        HC4_Html_Screen_Config $screen
    1211    )
    1312    {
  • z-inventory-manager/trunk/zi2/03acl/ui/admin/settings.php

    r2061857 r2149267  
    7777?>
    7878
    79 <form method="post" action="HREFPOST:{CURRENT}">
     79<form method="post" action="HREFPOST:..">
    8080
    81     <div class="hc4-admin-list-primary">
     81    <div class="hc4-admin-list-primary hc4-admin-list-striped">
    8282        <div class="hc-grid">
    8383            <div class="hc-col hc-col-4">__WordPress Role__</div>
  • z-inventory-manager/trunk/zi2/04finance/boot.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_04Finance_Boot
    3     implements HC4_App_Module_Interface
    43{
    54    public function __construct(
    65        HC4_Settings_Interface $settings,
    76        HC4_App_Router $router,
    8         HC4_Html_Screen_Interface $screen
     7        HC4_Html_Screen_Config $screen
    98    )
    109    {
     
    2322
    2423        $screen
    25             ->menu( 'admin/conf',   array( '{CURRENT}/finance', '__Finance__') )
     24            ->menu( 'admin/conf',   array( '../finance', '__Finance__') )
    2625            ->title(    'admin/conf/finance',   '__Finance__' )
    2726            ;
  • z-inventory-manager/trunk/zi2/04finance/ui/admin/conf/finance.php

    r2061857 r2149267  
    4747?>
    4848
    49 <form method="post" action="HREFPOST:{CURRENT}">
     49<form method="post" action="HREFPOST:..">
    5050    <div class="hc4-form-elements">
    5151
  • z-inventory-manager/trunk/zi2/11items/boot.php

    r2107074 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_11Items_Boot
    3     implements HC4_App_Module_Interface
    43{
    5     public static function bind( array $appConfig )
     4    public static function bind()
    65    {
    76        $return = array();
     
    1312        HC4_Migration_Interface $migration,
    1413        HC4_App_Router $router,
    15         HC4_Html_Screen_Interface $screen
     14        HC4_Html_Screen_Config $screen
    1615    )
    1716    {
  • z-inventory-manager/trunk/zi2/11items/data/crud.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_11Items_Data_Crud
    3     extends HC4_Crud_AbstractSql
     3    extends HC4_Crud_Sql_Abstract
    44{
    55    public function __construct(
    6         HC4_Crud_SqlTable $sqlTable
     6        HC4_Crud_Sql_Table $sqlTable
    77        )
    88    {
  • z-inventory-manager/trunk/zi2/11items/data/repo.php

    r2107074 r2149267  
    1515
    1616    public function __construct(
    17         ZI2_11Items_Data_Crud $crud
     17        ZI2_11Items_Data_Crud $crud,
     18        HC4_App_Events $events
    1819    )
    1920    {}
     
    158159        $this->crud->delete( $model->id );
    159160
     161    /* EVENT */
     162        $this->events->publish( 'ZI2_11Items_Data_Repo@delete', $model, func_get_args() );
     163
    160164        return $model;
    161165    }
  • z-inventory-manager/trunk/zi2/12wooitems/boot.php

    r2107074 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_12WooItems_Boot
    3     implements HC4_App_Module_Interface
    43{
    54    public function __construct(
     
    87        HC4_Html_Href_Interface $href,
    98        HC4_App_Router $router,
    10         HC4_Html_Screen_Interface $screen
     9        HC4_Html_Screen_Config $screen
    1110    )
    1211    {
     
    3635
    3736        $screen
    38             ->menu( 'admin/conf',   array( '{CURRENT}/inventory', '__Inventory__') )
     37            ->menu( 'admin/conf',   array( '../inventory', '__Inventory__') )
    3938            ->title(    'admin/conf/inventory', '__Inventory__' )
    4039            ;
  • z-inventory-manager/trunk/zi2/12wooitems/ui/admin/inventory.php

    r2107074 r2149267  
    4141?>
    4242
    43 <form method="post" action="HREFPOST:{CURRENT}">
     43<form method="post" action="HREFPOST:..">
    4444    <div class="hc4-form-elements">
    4545
  • z-inventory-manager/trunk/zi2/21purchases/boot.php

    r2107074 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_21Purchases_Boot
    3     implements HC4_App_Module_Interface
    43{
    54    public function __construct(
     
    76        HC4_Migration_Interface $migration,
    87        HC4_App_Router $router,
    9         HC4_Html_Screen_Interface $screen
     8        HC4_App_Events $events,
     9        HC4_Html_Screen_Config $screen
    1010    )
    1111    {
     12        $ns = 'ZI2_21Purchases_';
     13
    1214        $migration
    1315            ->register( 'purchases', 1, 'ZI2_21Purchases_Data_Migration@version1' )
     
    2224
    2325        $screen
    24             ->menu( 'admin/conf',   array( '{CURRENT}/purchases', '__Purchases__') )
     26            ->menu( 'admin/conf',   array( '../purchases', '__Purchases__') )
    2527            ->title(    'admin/conf/purchases', '__Purchases__' )
    2628            ;
     
    2830            ->add( 'GET/admin/conf/purchases',  'ZI2_21Purchases_Ui_Admin_Conf_Purchases@get' )
    2931            ->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', '&times; ' . '__Delete__', 900) )
     41            ->title(    'admin/purchases/[:id]/delete', '__Delete__' )
    3042            ;
    3143
     
    5870
    5971            ->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__') )
    6173            ;
    6274
     
    6678            ->add( 'POST/admin/purchases/new',  'ZI2_21Purchases_Ui_Admin_New@post' )
    6779            ;
    68 
    6980        $screen
    70             ->menu( 'admin/purchases',      array('{CURRENT}/new', '__New Purchase__') )
     81            ->menu( 'admin/purchases',      array('../new', '__New Purchase__') )
    7182            ->title(    'admin/purchases/new',  '__New Purchase__' )
    7283            ;
     
    8394        $screen
    8495            ->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__') )
    8697            ->title( 'admin/purchases/:id/items/new',   '__Add Item__' )
    8798            ->title( 'admin/purchases/:id/items/new/[:iid]',    'ZI2_21Purchases_Ui_Admin_Id_Items_New@title' )
    8899            ;
     100
     101    // LISTEN TO ITEM DELETE
     102        $events
     103            ->listen( 'ZI2_11Items_Data_Repo@delete', $ns . 'Data_Listen@itemDeleted' )
     104            ;
    89105    }
    90106}
  • z-inventory-manager/trunk/zi2/21purchases/data/crud.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_21Purchases_Data_Crud
    3     extends HC4_Crud_AbstractSql
     3    extends HC4_Crud_Sql_Abstract
    44{
    55    public function __construct(
    6         HC4_Crud_SqlTable $sqlTable
     6        HC4_Crud_Sql_Table $sqlTable
    77        )
    88    {
  • z-inventory-manager/trunk/zi2/21purchases/data/crud/lines.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_21Purchases_Data_Crud_Lines
    3     extends HC4_Crud_AbstractSql
     3    extends HC4_Crud_Sql_Abstract
    44{
    55    public function __construct(
    6         HC4_Crud_SqlTable $sqlTable
     6        HC4_Crud_Sql_Table $sqlTable
    77        )
    88    {
  • z-inventory-manager/trunk/zi2/21purchases/data/crud/receipts.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_21Purchases_Data_Crud_Receipts
    3     extends HC4_Crud_AbstractSql
     3    extends HC4_Crud_Sql_Abstract
    44{
    55    public function __construct(
    6         HC4_Crud_SqlTable $sqlTable
     6        HC4_Crud_Sql_Table $sqlTable
    77        )
    88    {
  • z-inventory-manager/trunk/zi2/21purchases/data/crud/receipts/lines.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_21Purchases_Data_Crud_Receipts_Lines
    3     extends HC4_Crud_AbstractSql
     3    extends HC4_Crud_Sql_Abstract
    44{
    55    public function __construct(
    6         HC4_Crud_SqlTable $sqlTable
     6        HC4_Crud_Sql_Table $sqlTable
    77        )
    88    {
  • z-inventory-manager/trunk/zi2/21purchases/data/repo.php

    r2107074 r2149267  
    1313    public function updateReceipt( ZI2_21Purchases_Data_Model $purchase, ZI2_21Purchases_Data_Model_Receipt $receipt );
    1414
     15    public function delete( ZI2_21Purchases_Data_Model $model );
    1516    public function create( ZI2_21Purchases_Data_Model $model );
    1617    public function update( ZI2_21Purchases_Data_Model $model );
     
    2930        ZI2_21Purchases_Data_Repo_Receipts $repoReceipts,
    3031
     32        HC4_App_Events $events,
    3133        HC4_Settings_Interface $settings
    3234    )
     
    247249    }
    248250
     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
    249275    public function update( ZI2_21Purchases_Data_Model $model )
    250276    {
  • z-inventory-manager/trunk/zi2/21purchases/data/repo/lines.php

    r2107074 r2149267  
    33{
    44    public function findManyByPurchases( array $purchases );
     5    public function findManyByItem( ZI2_11Items_Data_Model $item );
    56    public function delete( ZI2_21Purchases_Data_Model_Line $model );
    67    public function create( ZI2_21Purchases_Data_Model $purchase, ZI2_21Purchases_Data_Model_Line $model );
     
    6667
    6768            $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;
    6889        }
    6990
  • z-inventory-manager/trunk/zi2/21purchases/data/repo/receipts/lines.php

    r2107074 r2149267  
    33{
    44    public function findManyByReceipts( array $receipts );
     5    public function findManyByItem( ZI2_11Items_Data_Model $item );
    56    public function create( ZI2_21Purchases_Data_Model_Receipt $receipt, ZI2_21Purchases_Data_Model_Receipt_Line $line );
    67    public function delete( ZI2_21Purchases_Data_Model_Receipt_Line $model );
     
    6970    }
    7071
     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
    7192    public function create( ZI2_21Purchases_Data_Model_Receipt $receipt, ZI2_21Purchases_Data_Model_Receipt_Line $model )
    7293    {
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/conf/purchases.php

    r2061857 r2149267  
    4848?>
    4949
    50 <form method="post" action="HREFPOST:{CURRENT}">
     50<form method="post" action="HREFPOST:..">
    5151    <div class="hc4-form-elements">
    5252
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id.php

    r2107074 r2149267  
    7676    }
    7777
    78     public function title( $id )
     78    public function title( $slug, $id )
    7979    {
    8080        $model = $this->repo->findById( $id );
     
    9090        if( $model->isDraft() ){
    9191            if( $model->lines ){
    92                 $return[] = array( '{CURRENT}/items', '__Edit Items__' );
     92                $return[] = array( '../items', '__Edit Items__' );
    9393            }
    9494            else {
    95                 $return[] = array( '{CURRENT}/items/new', '+ ' . '__Add Item__' );
     95                $return[] = array( '../items/new', '+ ' . '__Add Item__' );
    9696            }
    9797        }
    9898        else {
    9999            if( $model->receipts ){
    100                 $return[] = array( '{CURRENT}/receipts', '&#9776; ' . '__Received Items__' );
     100                $return[] = array( '../receipts', '&#9776; ' . '__Received Items__' );
    101101            }
    102102
    103103            $toReceive = $model->getItemsToReceive();
    104104            if( $toReceive ){
    105                 $return[] = array( '{CURRENT}/receipts/new', '&rarr; ' . '__Receive Items__' );
     105                $return[] = array( '../receipts/new', '&rarr; ' . '__Receive Items__' );
    106106            }
    107107        }
     
    193193        ob_start();
    194194?>
    195 <form method="post" action="HREFPOST:{CURRENT}">
     195<form method="post" action="HREFPOST:..">
    196196
    197197    <div class="hc4-form-elements">
     
    236236
    237237    <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>
    239239    </div>
    240240
     
    263263        ob_start();
    264264?>
    265 <div class="hc4-admin-list-primary">
     265<div class="hc4-admin-list-primary hc4-admin-list-striped">
    266266
    267267<?php if( $entries ) : ?>
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/items.php

    r2061857 r2149267  
    3131<?php if( $model->lines ) : ?>
    3232
    33 <form method="post" action="HREFPOST:{CURRENT}">
     33<form method="post" action="HREFPOST:..">
    3434
    35     <div class="hc4-admin-list-primary">
     35    <div class="hc4-admin-list-primary hc4-admin-list-striped">
    3636
    3737        <div>
     
    6868
    6969    <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>
    7171    </div>
    7272
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/items/new.php

    r2061857 r2149267  
    1313    {}
    1414
    15     public function title( $itemId )
     15    public function title( $slug, $itemId )
    1616    {
    1717        $item = $this->repoItems->findById( $itemId );
     
    3232        ob_start();
    3333?>
    34 <form method="post" action="HREFPOST:{CURRENT}">
     34<form method="post" action="HREFPOST:..">
    3535
    3636    <div class="hc4-form-elements">
     
    6666
    6767    <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>
    6969    </div>
    7070
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts.php

    r2061857 r2149267  
    5252    <?php endif; ?>
    5353
    54     <div class="hc4-admin-list-primary">
     54    <div class="hc4-admin-list-primary hc4-admin-list-striped">
    5555    <?php foreach( $model->lines as $e ) : ?>
    5656        <div>
     
    8080        <div class="hc-mb3">
    8181            <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>
    8383                <?php echo $this->tf->formatDateWithWeekDay( $e->createdDate ); ?>
    8484            </div>
    8585
    86             <div class="hc4-admin-list-primary">
     86            <div class="hc4-admin-list-primary hc4-admin-list-striped">
    8787                <?php foreach( $e->lines as $l ) : ?>
    8888                    <div class="hc-flex-auto-grid">
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts/id.php

    r2061857 r2149267  
    9292        ob_start();
    9393?>
    94 <form method="post" action="HREFPOST:{CURRENT}">
     94<form method="post" action="HREFPOST:..">
    9595
    9696    <div class="hc4-form-elements">
     
    135135
    136136    <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>
    138138    </div>
    139139
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/id/receipts/new.php

    r2061857 r2149267  
    6868        ob_start();
    6969?>
    70 <form method="post" action="HREFPOST:{CURRENT}">
     70<form method="post" action="HREFPOST:..">
    7171
    7272    <div class="hc4-form-elements">
     
    111111
    112112    <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>
    114114    </div>
    115115
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/index.php

    r2061857 r2149267  
    1818        $entries = $this->repo->findAll();
    1919
    20         $return = $this->render( $entries );
     20        $return = $this->render( $slug, $entries );
    2121        $return = $this->screen->render( $slug, $return );
    2222        return $return;
    2323    }
    2424
    25     public function render( array $entries )
     25    public function render( $slug, array $entries )
    2626    {
    2727        ob_start();
    2828?>
    2929
    30 <div class="hc4-admin-list-primary">
     30<div class="hc4-admin-list-primary hc4-admin-list-striped">
    3131
    3232<?php if( $entries ) : ?>
     
    4545        <div class="hc-flex-auto-grid">
    4646            <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>
    4848            </div>
    4949            <div>
  • z-inventory-manager/trunk/zi2/21purchases/ui/admin/new.php

    r2061857 r2149267  
    3636        ob_start();
    3737?>
    38 <form method="post" action="HREFPOST:{CURRENT}">
     38<form method="post" action="HREFPOST:..">
    3939
    4040    <div class="hc4-form-elements">
     
    6464
    6565    <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>
    6767    </div>
    6868
  • z-inventory-manager/trunk/zi2/22sales/boot.php

    r2107074 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_22Sales_Boot
    3     implements HC4_App_Module_Interface
    43{
    54    public function __construct(
     
    76        HC4_Migration_Interface $migration,
    87        HC4_App_Router $router,
    9         HC4_Html_Screen_Interface $screen
     8        HC4_Html_Screen_Config $screen
    109    )
    1110    {
     11        $ns = 'ZI2_22Sales_';
     12
    1213        $migration
    1314            ->register( 'sales', 1, 'ZI2_22Sales_Data_Migration@version1' )
     
    2223
    2324        $screen
    24             ->menu( 'admin/conf',   array( '{CURRENT}/sales', '__Sales__') )
     25            ->menu( 'admin/conf',   array( '../sales', '__Sales__') )
    2526            ->title(    'admin/conf/sales', '__Sales__' )
    2627            ;
     
    2829            ->add( 'GET/admin/conf/sales',  'ZI2_22Sales_Ui_Admin_Conf_Sales@get' )
    2930            ->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', '&times; ' . '__Delete__', 900) )
     40            ->title(    'admin/sales/[:id]/delete', '__Delete__' )
    3041            ;
    3142
     
    5869
    5970            ->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__') )
    6172            ;
    6273
     
    6879
    6980        $screen
    70             ->menu( 'admin/sales',      array('{CURRENT}/new', '__New Sale__') )
     81            ->menu( 'admin/sales',      array('../new', '__New Sale__') )
    7182            ->title(    'admin/sales/new',  '__New Sale__' )
    7283            ;
     
    8394        $screen
    8495            ->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__') )
    8697            ->title( 'admin/sales/:id/items/new',   '__Add Item__' )
    8798            ->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  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_22Sales_Data_Crud
    3     extends HC4_Crud_AbstractSql
     3    extends HC4_Crud_Sql_Abstract
    44{
    55    public function __construct(
    6         HC4_Crud_SqlTable $sqlTable
     6        HC4_Crud_Sql_Table $sqlTable
    77        )
    88    {
  • z-inventory-manager/trunk/zi2/22sales/data/crud/lines.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_22Sales_Data_Crud_Lines
    3     extends HC4_Crud_AbstractSql
     3    extends HC4_Crud_Sql_Abstract
    44{
    55    public function __construct(
    6         HC4_Crud_SqlTable $sqlTable
     6        HC4_Crud_Sql_Table $sqlTable
    77        )
    88    {
  • z-inventory-manager/trunk/zi2/22sales/data/crud/shipments.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_22Sales_Data_Crud_Shipments
    3     extends HC4_Crud_AbstractSql
     3    extends HC4_Crud_Sql_Abstract
    44{
    55    public function __construct(
    6         HC4_Crud_SqlTable $sqlTable
     6        HC4_Crud_Sql_Table $sqlTable
    77        )
    88    {
  • z-inventory-manager/trunk/zi2/22sales/data/crud/shipments/lines.php

    r2061857 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_22Sales_Data_Crud_Shipments_Lines
    3     extends HC4_Crud_AbstractSql
     3    extends HC4_Crud_Sql_Abstract
    44{
    55    public function __construct(
    6         HC4_Crud_SqlTable $sqlTable
     6        HC4_Crud_Sql_Table $sqlTable
    77        )
    88    {
  • z-inventory-manager/trunk/zi2/22sales/data/repo.php

    r2107074 r2149267  
    1313    public function updateShipment( ZI2_22Sales_Data_Model $sale, ZI2_22Sales_Data_Model_Shipment $shipment );
    1414
     15    public function delete( ZI2_22Sales_Data_Model $model );
    1516    public function create( ZI2_22Sales_Data_Model $model );
    1617    public function update( ZI2_22Sales_Data_Model $model );
     
    2930        ZI2_22Sales_Data_Repo_Shipments $repoShipments,
    3031
     32        HC4_App_Events $events,
    3133        HC4_Settings_Interface $settings
    3234    )
     
    246248    }
    247249
     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
    248274    public function update( ZI2_22Sales_Data_Model $model )
    249275    {
  • z-inventory-manager/trunk/zi2/22sales/data/repo/lines.php

    r2107074 r2149267  
    33{
    44    public function findManyBySales( array $sales );
     5    public function findManyByItem( ZI2_11Items_Data_Model $item );
    56    public function delete( ZI2_22Sales_Data_Model_Line $model );
    67    public function create( ZI2_22Sales_Data_Model $sale, ZI2_22Sales_Data_Model_Line $model );
     
    6667            }
    6768            $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;
    6889        }
    6990
  • z-inventory-manager/trunk/zi2/22sales/data/repo/shipments/lines.php

    r2107074 r2149267  
    33{
    44    public function findManyByShipments( array $shipments );
     5    public function findManyByItem( ZI2_11Items_Data_Model $item );
    56    public function create( ZI2_22Sales_Data_Model_Shipment $shipment, ZI2_22Sales_Data_Model_Shipment_Line $line );
    67    public function delete( ZI2_22Sales_Data_Model_Shipment_Line $model );
     
    6869    }
    6970
     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
    7091    public function create( ZI2_22Sales_Data_Model_Shipment $shipment, ZI2_22Sales_Data_Model_Shipment_Line $model )
    7192    {
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/conf/sales.php

    r2061857 r2149267  
    4848?>
    4949
    50 <form method="post" action="HREFPOST:{CURRENT}">
     50<form method="post" action="HREFPOST:..">
    5151    <div class="hc4-form-elements">
    5252
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id.php

    r2107074 r2149267  
    7676    }
    7777
    78     public function title( $id )
     78    public function title( $slug, $id )
    7979    {
    8080        $model = $this->repo->findById( $id );
     
    9090        if( $model->isDraft() ){
    9191            if( $model->lines ){
    92                 $return[] = array( '{CURRENT}/items', '__Edit Items__' );
     92                $return[] = array( '../items', '__Edit Items__' );
    9393            }
    9494            else {
    95                 $return[] = array( '{CURRENT}/items/new', '+ ' . '__Add Item__' );
     95                $return[] = array( '../items/new', '+ ' . '__Add Item__' );
    9696            }
    9797        }
    9898        else {
    9999            if( $model->shipments ){
    100                 $return[] = array( '{CURRENT}/shipments', '&#9776; ' . '__Shipped Items__' );
     100                $return[] = array( '../shipments', '&#9776; ' . '__Shipped Items__' );
    101101            }
    102102
    103103            $toShip = $model->getItemsToShip();
    104104            if( $toShip ){
    105                 $return[] = array( '{CURRENT}/shipments/new', '&rarr; ' . '__Ship Items__' );
     105                $return[] = array( '../shipments/new', '&rarr; ' . '__Ship Items__' );
    106106            }
    107107        }
     
    193193        ob_start();
    194194?>
    195 <form method="post" action="HREFPOST:{CURRENT}">
     195<form method="post" action="HREFPOST:..">
    196196
    197197    <div class="hc4-form-elements">
     
    236236
    237237    <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>
    239239    </div>
    240240
     
    263263        ob_start();
    264264?>
    265 <div class="hc4-admin-list-primary">
     265<div class="hc4-admin-list-primary hc4-admin-list-striped">
    266266
    267267<?php if( $entries ) : ?>
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/items.php

    r2061857 r2149267  
    3131<?php if( $model->lines ) : ?>
    3232
    33 <form method="post" action="HREFPOST:{CURRENT}">
     33<form method="post" action="HREFPOST:..">
    3434
    35     <div class="hc4-admin-list-primary">
     35    <div class="hc4-admin-list-primary hc4-admin-list-striped">
    3636
    3737        <div>
     
    6868
    6969    <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>
    7171    </div>
    7272
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/items/new.php

    r2061857 r2149267  
    1313    {}
    1414
    15     public function title( $itemId )
     15    public function title( $slug, $itemId )
    1616    {
    1717        $item = $this->repoItems->findById( $itemId );
     
    3232        ob_start();
    3333?>
    34 <form method="post" action="HREFPOST:{CURRENT}">
     34<form method="post" action="HREFPOST:..">
    3535
    3636    <div class="hc4-form-elements">
     
    6666
    6767    <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>
    6969    </div>
    7070
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments.php

    r2061857 r2149267  
    5252    <?php endif; ?>
    5353
    54     <div class="hc4-admin-list-primary">
     54    <div class="hc4-admin-list-primary hc4-admin-list-striped">
    5555    <?php foreach( $model->lines as $e ) : ?>
    5656        <div>
     
    8080        <div class="hc-mb3">
    8181            <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>
    8383                <?php echo $this->tf->formatDateWithWeekDay( $e->createdDate ); ?>
    8484            </div>
    8585
    86             <div class="hc4-admin-list-primary">
     86            <div class="hc4-admin-list-primary hc4-admin-list-striped">
    8787                <?php foreach( $e->lines as $l ) : ?>
    8888                    <div class="hc-flex-auto-grid">
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments/id.php

    r2061857 r2149267  
    9292        ob_start();
    9393?>
    94 <form method="post" action="HREFPOST:{CURRENT}">
     94<form method="post" action="HREFPOST:..">
    9595
    9696    <div class="hc4-form-elements">
     
    135135
    136136    <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>
    138138    </div>
    139139
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/id/shipments/new.php

    r2061857 r2149267  
    6868        ob_start();
    6969?>
    70 <form method="post" action="HREFPOST:{CURRENT}">
     70<form method="post" action="HREFPOST:..">
    7171
    7272    <div class="hc4-form-elements">
     
    111111
    112112    <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>
    114114    </div>
    115115
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/index.php

    r2061857 r2149267  
    2828?>
    2929
    30 <div class="hc4-admin-list-primary">
     30<div class="hc4-admin-list-primary hc4-admin-list-striped">
    3131
    3232<?php if( $entries ) : ?>
     
    4545        <div class="hc-flex-auto-grid">
    4646            <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>
    4848            </div>
    4949            <div>
  • z-inventory-manager/trunk/zi2/22sales/ui/admin/new.php

    r2061857 r2149267  
    3636        ob_start();
    3737?>
    38 <form method="post" action="HREFPOST:{CURRENT}">
     38<form method="post" action="HREFPOST:..">
    3939
    4040    <div class="hc4-form-elements">
     
    6464
    6565    <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>
    6767    </div>
    6868
  • z-inventory-manager/trunk/zi2/31inventory/boot.php

    r2107074 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_31Inventory_Boot
    3     implements HC4_App_Module_Interface
    43{
    54    public function __construct(
    65        HC4_App_Router $router,
    7         HC4_Html_Screen_Interface $screen
     6        HC4_Html_Screen_Config $screen
    87    )
    98    {
     9        $ns = 'ZI2_31Inventory_';
     10
    1011    // UI
    1112        $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' )
    1415
    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' )
    1718
    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' )
    2021            ;
    2122
    2223        $screen
    2324            ->title(    'admin/inventory',                  '__Inventory__' )
    24             // ->title( 'admin/calendars/status/[:s]',  'SH5_11Calendars_View_Admin_Index@titleStatus' )
    2525
    2626            ->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' )
    2828
    2929            ->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', '&times; ' . '__Delete__', 900 ) )
     40            ->title( 'admin/inventory/[:id]/delete',    '__Delete__' )
    3141            ;
    3242
    3343    // PURCHASES ITEM SELECTOR
    3444        $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' )
    3646            ;
    3747
    3848    // SALES ITEM SELECTOR
    3949        $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' )
    4151            ;
    4252    }
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/id.php

    r2061857 r2149267  
    1212    {}
    1313
    14     public function title( $id )
     14    public function title( $slug, $id )
    1515    {
    1616        $model = $this->repo->findById( $id );
     
    3030        ob_start();
    3131?>
    32 <form method="post" action="HREFPOST:{CURRENT}">
     32<form method="post" action="HREFPOST:..">
    3333
    3434    <div class="hc4-form-elements">
     
    8484
    8585    <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>
    8787    </div>
    8888
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/index.php

    r2107074 r2149267  
    5050            $label[] = ' [' . $statusCount . ']';
    5151
    52             $return[] = array( '{CURRENT}/status/' . $status, $label );
     52            $return[] = array( '../status/' . $status, $label );
    5353        }
    5454
     
    7474?>
    7575
    76 <div class="hc4-admin-list-primary">
     76<div class="hc4-admin-list-primary hc4-admin-list-striped">
    7777
    7878<?php if( $entries ) : ?>
     
    9494        <div class="hc-flex-auto-grid">
    9595            <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>
    9797            </div>
    9898
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/new.php

    r2061857 r2149267  
    77        HC4_Html_Input_Text $inputText,
    88        HC4_Html_Input_RichTextarea $inputTextarea,
     9        // HC4_Html_Input_Textarea $inputTextarea,
    910
    1011        HC4_Html_Screen_Interface $screen
     
    2425        ob_start();
    2526?>
    26 <form method="post" action="HREFPOST:{CURRENT}">
     27<form method="post" action="HREFPOST:..">
    2728
    2829    <div class="hc4-form-elements">
     
    7879
    7980    <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>
    8182    </div>
    8283
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/purchases/selector.php

    r2107074 r2149267  
    4343?>
    4444
    45 <div class="hc4-admin-list-primary">
     45<div class="hc4-admin-list-primary hc4-admin-list-striped">
    4646
    4747<?php if( $entries ) : ?>
  • z-inventory-manager/trunk/zi2/31inventory/ui/admin/sales/selector.php

    r2107074 r2149267  
    4343?>
    4444
    45 <div class="hc4-admin-list-primary">
     45<div class="hc4-admin-list-primary hc4-admin-list-striped">
    4646
    4747<?php if( $entries ) : ?>
  • z-inventory-manager/trunk/zi2/99app/boot.php

    r2107074 r2149267  
    11<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
    22class ZI2_99App_Boot
    3     implements HC4_App_Module_Interface
    43{
    5     public static function bind( $appConfig )
     4    public static function bind()
    65    {
    76        $return = array();
     
    1211    public function __construct(
    1312        HC4_Migration_Interface $migration,
    14         HC4_App_Config $appConfig,
    1513
    1614        HC4_Settings_Interface $settings,
     
    1917
    2018        HC4_App_Router $router,
    21         HC4_Html_Screen_Interface $screen
     19        HC4_Html_Screen_Config $screen
    2220    )
    2321    {
     
    3129
    3230        $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@' )
    3634            ;
    3735
  • z-inventory-manager/trunk/zi2/99app/data/upgrade.php

    r2061857 r2149267  
    1616
    1717        HC4_Database_Interface $db,
    18         HC4_Crud_SqlTable $sqlTable
     18        HC4_Crud_Sql_Table $sqlTable
    1919    )
    2020    {}
  • z-inventory-manager/trunk/zi2/99app/ui/index.php

    r2061857 r2149267  
    1616    }
    1717
    18     public function title()
     18    public function title( $slug )
    1919    {
    2020        $return = NULL;
  • z-inventory-manager/trunk/zi2/99app/ui/layout.php

    r2107074 r2149267  
    44{
    55    public function __construct(
    6         HC4_App $app,
     6        HC4_App_Index $app,
    77        HC4_Redirect_Interface $redirect,
    88        HC4_Html_Href_Interface $href,
     
    1313    public function render(
    1414        $slug,
     15        $isAjax,
    1516        $content,
    1617        $title = NULL,
     
    5354
    5455<?php
    55 if( $this->promo ){
    56     echo $this->promo->render( $slug );
     56if( ! $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 );
    5767}
    58 ?>
    59 
     68else {
     69    $breadcrumbView = NULL;
     70}
     71?>
     72
     73<?php if( ! $isAjax ) : ?>
    6074<div id="zi2-<?php echo $slug; ?>">
    6175<div class="hc4-admin-page">
    6276
    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                         &raquo;
    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                         &raquo;
    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                     &laquo;
    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; ?>
    11980        </div>
    12081    <?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__">&vellip;</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 : ?>
    15490                    <h1><?php echo $title; ?></h1>
    15591                <?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>
    159112                <?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                &raquo;
     156            </div>
     157            <?php endif; ?>
     158
     159            <div>
     160                <?php if( strpos($label, '<') === FALSE ) : ?>
     161                    <?php echo $this->renderLink2( $to, $label, $label ); ?>
    188162                <?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">&nbsp;</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; ?>
    209164                <?php endif; ?>
    210165            </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">&laquo;</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__">&vellip; __Menu__</div>
     213        </label>
     214
     215        <div class="hc-collapse-content">
    223216            <div class="hc4-admin-list-secondary">
    224             <?php foreach( $contentAsMenu as $menuItem ) : ?>
     217            <?php foreach( $menuView as $menuItem ) : ?>
    225218                <div>
    226219                    <?php echo $menuItem; ?>
     
    228221            <?php endforeach; ?>
    229222            </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">&nbsp;</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 -->
    242244</div>
    243245
     
    301303
    302304        if( $to ){
    303             $to = str_replace( '{CURRENT}', $slug, $to );
     305            $to = str_replace( '..', $slug, $to );
    304306            if( ! $this->app->check( $method, $to ) ){
    305307                return;
  • z-inventory-manager/trunk/zi2/99app/ui/promo/promo.php

    r2061857 r2149267  
    55    public function __construct(
    66    )
    7     {}
     7    {
     8    }
    89
    910    public function render( $slug )
     
    1415
    1516    // show on homepage only
    16         if( $slug ){
     17        // if( $slug ){
     18            // return;
     19        // }
     20        if( 'admin' !== substr($slug, 0, strlen('admin')) ){
    1721            return;
    1822        }
     
    2630
    2731<?php if( is_admin() ) : ?>
    28     <div class="update-nag hc-block hc-fs4 hc-my3">
     32    <div class="update-nag hc-block hc-my3">
    2933<?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">
    3135<?php endif; ?>
    3236<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.