Changeset 91 in ExiteCMS8


Ignore:
Timestamp:
09/14/11 15:21:14 (8 months ago)
Author:
WanWizard
Message:

updated to the latest Fuel 1.1/develop branch

Location:
trunk/fuel
Files:
1 added
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/fuel/core/classes/agent.php

    r78 r91  
    451451 
    452452                // normalize keys 
    453                 $properties = \Arr::replace_keys($properties, array_flip(static::$keys)); 
     453                $properties = \Arr::replace_key($properties, array_flip(static::$keys)); 
    454454 
    455455                // merge it with the defaults to add missing values 
  • trunk/fuel/core/classes/arr.php

    r85 r91  
    100100 
    101101        $array[array_shift($keys)] = $value; 
     102    } 
     103     
     104    /** 
     105     * Array_key_exists with a dot-notated key from an array. 
     106     * 
     107     * @param   array   $array    The search array 
     108     * @param   mixed   $key      The dot-notated key or array of keys 
     109     * @return  mixed 
     110     */ 
     111    public static function key_exists($array, $key) 
     112    { 
     113        foreach (explode('.', $key) as $key_part) 
     114        { 
     115            if ( ! is_array($array) or ! array_key_exists($key_part, $array)) 
     116            { 
     117                return false; 
     118            } 
     119 
     120            $array = $array[$key_part]; 
     121        } 
     122 
     123        return true; 
    102124    } 
    103125 
  • trunk/fuel/core/classes/cache.php

    r78 r91  
    3434     * Creates a new cache instance. 
    3535     * 
    36      * @access  public 
    3736     * @param   mixed                 The identifier of the cache, can be anything but empty 
    3837     * @param   array|string          Either an array of settings or the storage driver to be used 
     
    4948     * Creates a new cache instance. 
    5049     * 
    51      * @access  public 
    5250     * @param   mixed                 The identifier of the cache, can be anything but empty 
    5351     * @param   array|string          Either an array of settings or the storage driver to be used 
     
    9593    { 
    9694        $contents = \Fuel::value($contents); 
    97          
     95 
    9896        $cache = static::forge($identifier); 
    9997        return $cache->set($contents, $expiration, $dependencies); 
  • trunk/fuel/core/classes/cache/handler/driver.php

    r64 r91  
    2020     * Should make the contents readable 
    2121     * 
    22      * @access  public 
    23      * @param   mixed 
    24      * @return  mixed 
     22     * @param   mixed 
     23     * @return  mixed 
    2524     */ 
    2625    public function readable($contents); 
     
    2928     * Should make the contents writable 
    3029     * 
    31      * @access  public 
    32      * @param   mixed 
    33      * @return  mixed 
     30     * @param   mixed 
     31     * @return  mixed 
    3432     */ 
    3533    public function writable($contents); 
  • trunk/fuel/core/classes/cache/storage/driver.php

    r87 r91  
    6666    protected $driver = null; 
    6767 
    68     // --------------------------------------------------------------------- 
    69  
    7068    /** 
    7169     * Abstract method that should take care of the storage engine specific reading. Needs to set the object properties: 
     
    8078    abstract protected function _get(); 
    8179 
    82     // --------------------------------------------------------------------- 
    83  
    8480    /** 
    8581     * Abstract method that should take care of the storage engine specific writing. Needs to write the object properties: 
     
    9288    abstract protected function _set(); 
    9389 
    94     // --------------------------------------------------------------------- 
    95  
    9690    /** 
    9791     * Should delete this cache instance, should also run reset() afterwards 
    9892     */ 
    9993    abstract public function delete(); 
    100  
    101     // --------------------------------------------------------------------- 
    10294 
    10395    /** 
     
    108100     */ 
    109101    abstract public function delete_all($section); 
    110  
    111     // --------------------------------------------------------------------- 
    112102 
    113103    /** 
     
    120110    abstract public function check_dependencies(array $dependencies); 
    121111 
    122     // --------------------------------------------------------------------- 
    123  
    124112    /** 
    125113     * Default constructor, any extension should either load this first or act similar 
     
    133121 
    134122        // fetch options from config and set them 
    135         $this->expiration       = array_key_exists('expiration', $config) ? $config['expiration'] : \Config::get('cache.expiration', null); 
    136         $this->dependencies     = array_key_exists('dependencies', $config) ? $config['dependencies'] : array(); 
    137         $this->content_handler  = array_key_exists('content_handler', $config) ? new $config['content_handler']() : null; 
    138         $this->driver           = array_key_exists('driver', $config) ? $config['driver'] : 'file'; 
    139     } 
    140  
    141     // --------------------------------------------------------------------- 
     123        $this->expiration       = array_key_exists('expiration', $config) ? $config['expiration'] : \Config::get('cache.expiration', null); 
     124        $this->dependencies     = array_key_exists('dependencies', $config) ? $config['dependencies'] : array(); 
     125        $this->content_handler  = array_key_exists('content_handler', $config) ? new $config['content_handler']() : null; 
     126        $this->driver           = array_key_exists('driver', $config) ? $config['driver'] : 'file'; 
     127    } 
    142128 
    143129    /** 
     
    183169    } 
    184170 
    185     // --------------------------------------------------------------------- 
    186  
    187171    /** 
    188172     * Converts the identifier to a string when necessary: 
     
    217201        } 
    218202    } 
    219  
    220     // --------------------------------------------------------------------- 
    221203 
    222204    /** 
     
    233215    } 
    234216 
    235     // --------------------------------------------------------------------- 
    236  
    237     /** 
    238      * Front for writing the cache, ensures interchangebility of storage engines. Actual writing 
     217    /** 
     218     * Front for writing the cache, ensures interchangeability of storage engines. Actual writing 
    239219     * is being done by the _set() method which needs to be extended. 
    240220     * 
     
    284264    } 
    285265 
    286     // --------------------------------------------------------------------- 
    287  
    288     /** 
    289      * Front for reading the cache, ensures interchangebility of storage engines. Actual reading 
     266    /** 
     267     * Front for reading the cache, ensures interchangeability of storage engines. Actual reading 
    290268     * is being done by the _get() method which needs to be extended. 
    291269     * 
     
    319297    } 
    320298 
    321     // --------------------------------------------------------------------- 
    322  
    323     /** 
    324      * Does get() & set() in one call that takes a callback and it's arguements to generate the contents 
     299    /** 
     300     * Does get() & set() in one call that takes a callback and it's arguments to generate the contents 
    325301     * 
    326302     * @param   string|array  Valid PHP callback 
    327      * @param   array         Arguements for the above function/method 
     303     * @param   array         Arguments for the above function/method 
    328304     * @param   int|null      Cache expiration in seconds 
    329305     * @param   array         Contains the identifiers of caches this one will depend on 
     
    346322        return $this->get_contents(); 
    347323    } 
    348  
    349     // --------------------------------------------------------------------- 
    350324 
    351325    /** 
     
    364338    } 
    365339 
    366     // --------------------------------------------------------------------- 
    367  
    368340    /** 
    369341     * Fetches contents 
     
    375347        return $this->handle_reading($this->contents); 
    376348    } 
    377  
    378     // --------------------------------------------------------------------- 
    379349 
    380350    /** 
     
    391361    } 
    392362 
    393     // --------------------------------------------------------------------- 
    394  
    395363    /** 
    396364     * Gets a specific content handler 
     
    406374        } 
    407375 
    408         // When not yet set, use $handler or detect the prefered handler (string = string, otherwise serialize) 
     376        // When not yet set, use $handler or detect the preferred handler (string = string, otherwise serialize) 
    409377        if (empty($this->content_handler) && empty($handler)) 
    410378        { 
     
    430398    } 
    431399 
    432     // --------------------------------------------------------------------- 
    433  
    434400    /** 
    435401     * Converts the contents the cachable format 
     
    442408    } 
    443409 
    444     // --------------------------------------------------------------------- 
    445  
    446410    /** 
    447411     * Converts the cachable format to the original value 
     
    454418    } 
    455419} 
    456  
  • trunk/fuel/core/classes/cache/storage/file.php

    r67 r91  
    1818 
    1919    /** 
    20      * @const   string  Tag used for opening & closing cache properties 
     20     * @const  string  Tag used for opening & closing cache properties 
    2121     */ 
    2222    const PROPS_TAG = 'Fuel_Cache_Properties'; 
    2323 
    2424    /** 
    25      * @var string  File caching basepath 
     25     * @var  string  File caching basepath 
    2626     */ 
    2727    protected static $path = ''; 
    2828 
    2929    /** 
    30      * @var driver specific configuration 
     30     * @var  array  driver specific configuration 
    3131     */ 
    3232    protected $config = array(); 
    3333 
    34     // --------------------------------------------------------------------- 
    35  
    3634    public function __construct($identifier, $config) 
    3735    { 
     
    4139 
    4240        // check for an expiration override 
    43         $this->expiration = $this->_validate_config('expiration', isset($this->config['expiration']) ? $this->config['expiration'] : $this->expiration); 
     41        $this->expiration = $this->_validate_config('expiration', isset($this->config['expiration']) 
     42            ? $this->config['expiration'] : $this->expiration); 
    4443 
    4544        // determine the file cache path 
    46         static::$path = !empty($this->config['path']) ? $this->config['path'] : \Config::get('cache_dir', APPPATH.'cache'.DS); 
     45        static::$path = !empty($this->config['path']) 
     46            ? $this->config['path'] : \Config::get('cache_dir', APPPATH.'cache'.DS); 
     47 
    4748        if ( ! is_dir(static::$path) || ! is_writable(static::$path)) 
    4849        { 
     
    5152    } 
    5253 
    53     // --------------------------------------------------------------------- 
    54  
    5554    /** 
    5655     * Translates a given identifier to a valid path 
    5756     * 
    58      * @param   string 
    59      * @return  string 
    60      */ 
    61     protected function identifier_to_path( $identifier ) 
     57     * @param   string 
     58     * @return  string 
     59     */ 
     60    protected function identifier_to_path($identifier) 
    6261    { 
    6362        // replace dots with dashes 
     
    6766    } 
    6867 
    69     // --------------------------------------------------------------------- 
    70  
    7168    /** 
    7269     * Prepend the cache properties 
    7370     * 
    74      * @return string 
     71     * @return  string 
    7572     */ 
    7673    protected function prep_contents() 
    7774    { 
    7875        $properties = array( 
    79             'created'           => $this->created, 
    80             'expiration'        => $this->expiration, 
    81             'dependencies'      => $this->dependencies, 
    82             'content_handler'   => $this->content_handler 
     76            'created'          => $this->created, 
     77            'expiration'       => $this->expiration, 
     78            'dependencies'     => $this->dependencies, 
     79            'content_handler'  => $this->content_handler 
    8380        ); 
    8481        $properties = '{{'.self::PROPS_TAG.'}}'.json_encode($properties).'{{/'.self::PROPS_TAG.'}}'; 
    8582 
    86         return $properties . $this->contents; 
    87     } 
    88  
    89     // --------------------------------------------------------------------- 
     83        return $properties.$this->contents; 
     84    } 
    9085 
    9186    /** 
     
    111106        } 
    112107 
    113         $this->created          = $props['created']; 
    114         $this->expiration       = is_null($props['expiration']) ? null : (int) ($props['expiration'] - time()); 
    115         $this->dependencies     = $props['dependencies']; 
    116         $this->content_handler  = $props['content_handler']; 
    117     } 
    118  
    119     // --------------------------------------------------------------------- 
     108        $this->created          = $props['created']; 
     109        $this->expiration       = is_null($props['expiration']) ? null : (int) ($props['expiration'] - time()); 
     110        $this->dependencies     = $props['dependencies']; 
     111        $this->content_handler  = $props['content_handler']; 
     112    } 
    120113 
    121114    /** 
    122115     * Check if other caches or files have been changed since cache creation 
    123116     * 
    124      * @param   array 
    125      * @return  bool 
     117     * @param   array 
     118     * @return  bool 
    126119     */ 
    127120    public function check_dependencies(array $dependencies) 
     
    133126                $filemtime = filemtime($file); 
    134127                if ($filemtime === false || $filemtime > $this->created) 
     128                { 
    135129                    return false; 
     130                } 
    136131            } 
    137132            elseif (file_exists($dep)) 
     
    139134                $filemtime = filemtime($file); 
    140135                if ($filemtime === false || $filemtime > $this->created) 
     136                { 
    141137                    return false; 
     138                } 
    142139            } 
    143140            else 
     
    148145        return true; 
    149146    } 
    150  
    151     // --------------------------------------------------------------------- 
    152147 
    153148    /** 
     
    166161     * Purge all caches 
    167162     * 
    168      * @param   limit purge to subsection 
    169      * @return  bool 
     163     * @param   limit purge to subsection 
     164     * @return  bool 
    170165     */ 
    171166    public function delete_all($section) 
     
    177172    } 
    178173 
    179     // --------------------------------------------------------------------- 
    180  
    181174    /** 
    182175     * Save a cache, this does the generic pre-processing 
    183176     * 
    184      * @return  bool 
     177     * @return  bool  success 
    185178     */ 
    186179    protected function _set() 
     
    200193            { 
    201194                // create non existing dir 
    202                 if ( ! @mkdir($test_path, 0755, true)) return false; 
     195                if ( ! @mkdir($test_path, 0755, true)) 
     196                { 
     197                    return false; 
     198                } 
    203199            } 
    204200        } 
     
    208204        $handle = fopen($file, 'c'); 
    209205 
    210         if ($handle) 
    211         { 
    212             // wait for a lock 
    213             while ( ! flock($handle, LOCK_EX)); 
    214  
    215             // write the session data 
    216             fwrite($handle, $payload); 
    217  
    218             //release the lock 
    219             flock($handle, LOCK_UN); 
    220  
    221             // close the file 
    222             fclose($handle); 
    223         } 
    224     } 
    225  
    226     // --------------------------------------------------------------------- 
     206        if ( ! $handle) 
     207        { 
     208            return false; 
     209        } 
     210 
     211        // wait for a lock 
     212        while ( ! flock($handle, LOCK_EX)); 
     213 
     214        // write the session data 
     215        fwrite($handle, $payload); 
     216 
     217        //release the lock 
     218        flock($handle, LOCK_UN); 
     219 
     220        // close the file 
     221        fclose($handle); 
     222 
     223        return true; 
     224    } 
    227225 
    228226    /** 
    229227     * Load a cache, this does the generic post-processing 
    230228     * 
    231      * @return bool 
     229     * @return  bool  success 
    232230     */ 
    233231    protected function _get() 
     
    236234        $file = static::$path.$id_path.'.cache'; 
    237235        if ( ! file_exists($file)) 
    238             return false; 
     236        { 
     237            return false; 
     238        } 
    239239 
    240240        $handle = fopen($file, 'r'); 
    241241        if ( ! $handle) 
    242             return false; 
     242        { 
     243            return false; 
     244        } 
    243245 
    244246        // wait for a lock 
     
    266268    } 
    267269 
    268     // --------------------------------------------------------------------- 
    269  
    270270    /** 
    271271     * validate a driver config value 
    272272     * 
    273      * @param   string  name of the config variable to validate 
    274      * @param   mixed   value 
    275      * @access  private 
     273     * @param   string  name of the config variable to validate 
     274     * @param   mixed   value 
    276275     * @return  mixed 
    277276     */ 
     
    297296        return $value; 
    298297    } 
    299  
    300298} 
    301  
    302  
  • trunk/fuel/core/classes/cache/storage/memcached.php

    r87 r91  
    1818 
    1919    /** 
    20      * @const   string  Tag used for opening & closing cache properties 
     20     * @const  string  Tag used for opening & closing cache properties 
    2121     */ 
    2222    const PROPS_TAG = 'Fuel_Cache_Properties'; 
    2323 
    2424    /** 
    25      * @var driver specific configuration 
     25     * @var  array  driver specific configuration 
    2626     */ 
    2727    protected $config = array(); 
    2828 
    2929    /* 
    30      * @var storage for the memcached object 
     30     * @var  Memcached  storage for the memcached object 
    3131     */ 
    3232    protected $memcached = false; 
    3333 
    34     // --------------------------------------------------------------------- 
    35  
    3634    public function __construct($identifier, $config) 
    3735    { 
     
    4139 
    4240        // make sure we have a memcache id 
    43         $this->config['cache_id'] = $this->_validate_config('cache_id', isset($this->config['cache_id']) ? $this->config['cache_id'] : 'fuel'); 
     41        $this->config['cache_id'] = $this->_validate_config('cache_id', isset($this->config['cache_id']) 
     42            ? $this->config['cache_id'] : 'fuel'); 
    4443 
    4544        // check for an expiration override 
    46         $this->expiration = $this->_validate_config('expiration', isset($this->config['expiration']) ? $this->config['expiration'] : $this->expiration); 
     45        $this->expiration = $this->_validate_config('expiration', isset($this->config['expiration']) 
     46            ? $this->config['expiration'] : $this->expiration); 
    4747 
    4848        if ($this->memcached === false) 
     
    7171    } 
    7272 
    73     // --------------------------------------------------------------------- 
    74  
    7573    /** 
    7674     * Prepend the cache properties 
    7775     * 
    78      * @return string 
     76     * @return  string 
    7977     */ 
    8078    protected function prep_contents() 
    8179    { 
    8280        $properties = array( 
    83             'created'           => $this->created, 
    84             'expiration'        => $this->expiration, 
    85             'dependencies'      => $this->dependencies, 
    86             'content_handler'   => $this->content_handler 
     81            'created'          => $this->created, 
     82            'expiration'       => $this->expiration, 
     83            'dependencies'     => $this->dependencies, 
     84            'content_handler'  => $this->content_handler 
    8785        ); 
    8886        $properties = '{{'.static::PROPS_TAG.'}}'.json_encode($properties).'{{/'.static::PROPS_TAG.'}}'; 
    8987 
    90         return $properties . $this->contents; 
    91     } 
    92  
    93     // --------------------------------------------------------------------- 
     88        return $properties.$this->contents; 
     89    } 
    9490 
    9591    /** 
     
    115111        } 
    116112 
    117         $this->created          = $props['created']; 
    118         $this->expiration       = is_null($props['expiration']) ? null : (int) ($props['expiration'] - time()); 
    119         $this->dependencies     = $props['dependencies']; 
    120         $this->content_handler  = $props['content_handler']; 
    121     } 
    122  
    123     // --------------------------------------------------------------------- 
     113        $this->created          = $props['created']; 
     114        $this->expiration       = is_null($props['expiration']) ? null : (int) ($props['expiration'] - time()); 
     115        $this->dependencies     = $props['dependencies']; 
     116        $this->content_handler  = $props['content_handler']; 
     117    } 
    124118 
    125119    /** 
    126120     * Check if other caches or files have been changed since cache creation 
    127121     * 
    128      * @param   array 
    129      * @return  bool 
     122     * @param   array 
     123     * @return  bool 
    130124     */ 
    131125    public function check_dependencies(array $dependencies) 
     
    162156    } 
    163157 
    164     // --------------------------------------------------------------------- 
    165  
    166158    /** 
    167159     * Delete Cache 
     
    184176    } 
    185177 
    186     // --------------------------------------------------------------------- 
    187  
    188178    /** 
    189179     * Purge all caches 
    190180     * 
    191      * @param   limit purge to subsection 
    192      * @return  bool 
     181     * @param   limit purge to subsection 
     182     * @return  bool 
    193183     */ 
    194184    public function delete_all($section) 
     
    229219    } 
    230220 
    231     // --------------------------------------------------------------------- 
    232  
    233221    /** 
    234222     * Save a cache, this does the generic pre-processing 
    235223     * 
    236      * @return  bool 
     224     * @return  bool  success 
    237225     */ 
    238226    protected function _set() 
     
    248236            throw new \Fuel_Exception('Memcached returned error code "'.$this->memcached->getResultCode().'" on write. Check your configuration.'); 
    249237        } 
    250     } 
    251  
    252     // --------------------------------------------------------------------- 
     238 
     239        return true; 
     240    } 
    253241 
    254242    /** 
    255243     * Load a cache, this does the generic post-processing 
    256244     * 
    257      * @return bool 
     245     * @return  bool  success 
    258246     */ 
    259247    protected function _get() 
     
    271259        catch (\UnexpectedValueException $e) 
    272260        { 
    273  
    274261            return false; 
    275262        } 
     
    278265    } 
    279266 
    280     // --------------------------------------------------------------------- 
    281  
    282267    /** 
    283268     * validate a driver config value 
    284269     * 
    285      * @param   string  name of the config variable to validate 
    286      * @param   mixed   value 
    287      * @access  private 
     270     * @param   string  name of the config variable to validate 
     271     * @param   mixed   value 
    288272     * @return  mixed 
    289273     */ 
     
    342326    } 
    343327 
    344     // --------------------------------------------------------------------- 
    345  
    346     /** 
    347      * get's the memcached key belonging to the cache identifier 
    348      * 
    349      * @access  private 
    350      * @param   bool        if true, remove the key retrieved from the index 
     328    /** 
     329     * Get's the memcached key belonging to the cache identifier 
     330     * 
     331     * @param   bool  if true, remove the key retrieved from the index 
    351332     * @return  string 
    352333     */ 
     
    414395    } 
    415396 
    416     // --------------------------------------------------------------------- 
    417  
    418     /** 
    419      * generate a new unique key for the current identifier 
    420      * 
    421      * @access  private 
     397    /** 
     398     * Generate a new unique key for the current identifier 
     399     * 
    422400     * @return  string 
    423401     */ 
     
    431409        return md5($this->config['cache_id'].'_'.uniqid($key, TRUE)); 
    432410    } 
    433  
    434411} 
    435  
    436  
  • trunk/fuel/core/classes/cache/storage/redis.php

    r87 r91  
    1818 
    1919    /** 
    20      * @const   string  Tag used for opening & closing cache properties 
     20     * @const  string  Tag used for opening & closing cache properties 
    2121     */ 
    2222    const PROPS_TAG = 'Fuel_Cache_Properties'; 
    2323 
    2424    /** 
    25      * @var driver specific configuration 
     25     * @var  array  driver specific configuration 
    2626     */ 
    2727    protected $config = array(); 
    2828 
    2929    /* 
    30      * @var storage for the redis object 
     30     * @var  Redis  storage for the redis object 
    3131     */ 
    3232    protected $redis = false; 
    3333 
    34     // --------------------------------------------------------------------- 
    35  
    3634    public function __construct($identifier, $config) 
    3735    { 
     
    4139 
    4240        // make sure we have a redis id 
    43         $this->config['cache_id'] = $this->_validate_config('cache_id', isset($this->config['cache_id']) ? $this->config['cache_id'] : 'fuel'); 
     41        $this->config['cache_id'] = $this->_validate_config('cache_id', isset($this->config['cache_id']) 
     42            ? $this->config['cache_id'] : 'fuel'); 
    4443 
    4544        // check for an expiration override 
    46         $this->expiration = $this->_validate_config('expiration', isset($this->config['expiration']) ? $this->config['expiration'] : $this->expiration); 
     45        $this->expiration = $this->_validate_config('expiration', isset($this->config['expiration']) 
     46            ? $this->config['expiration'] : $this->expiration); 
    4747 
    4848        // make sure we have a redis database configured 
    49         $this->config['database'] = $this->_validate_config('database', isset($this->config['database']) ? $this->config['database'] : 'default'); 
     49        $this->config['database'] = $this->_validate_config('database', isset($this->config['database']) 
     50            ? $this->config['database'] : 'default'); 
    5051 
    5152        if ($this->redis === false) 
     
    7071    } 
    7172 
    72     // --------------------------------------------------------------------- 
    73  
    7473    /** 
    7574     * Translates a given identifier to a valid redis key 
    7675     * 
    77      * @param   string 
    78      * @return  string 
     76     * @param   string 
     77     * @return  string 
    7978     */ 
    8079    protected function identifier_to_key( $identifier ) 
     
    8382    } 
    8483 
    85     // --------------------------------------------------------------------- 
    86  
    8784    /** 
    8885     * Prepend the cache properties 
     
    9390    { 
    9491        $properties = array( 
    95             'created'           => $this->created, 
    96             'expiration'        => $this->expiration, 
    97             'dependencies'      => $this->dependencies, 
    98             'content_handler'   => $this->content_handler 
     92            'created'          => $this->created, 
     93            'expiration'       => $this->expiration, 
     94            'dependencies'     => $this->dependencies, 
     95            'content_handler'  => $this->content_handler 
    9996        ); 
    10097        $properties = '{{'.static::PROPS_TAG.'}}'.json_encode($properties).'{{/'.static::PROPS_TAG.'}}'; 
    10198 
    102         return $properties . $this->contents; 
    103     } 
    104  
    105     // --------------------------------------------------------------------- 
     99        return $properties.$this->contents; 
     100    } 
    106101 
    107102    /** 
     
    127122        } 
    128123 
    129         $this->created          = $props['created']; 
    130         $this->expiration       = is_null($props['expiration']) ? null : (int) ($props['expiration'] - time()); 
    131         $this->dependencies     = $props['dependencies']; 
    132         $this->content_handler  = $props['content_handler']; 
    133     } 
    134  
    135     // --------------------------------------------------------------------- 
     124        $this->created          = $props['created']; 
     125        $this->expiration       = is_null($props['expiration']) ? null : (int) ($props['expiration'] - time()); 
     126        $this->dependencies     = $props['dependencies']; 
     127        $this->content_handler  = $props['content_handler']; 
     128    } 
    136129 
    137130    /** 
    138131     * Check if other caches or files have been changed since cache creation 
    139132     * 
    140      * @param   array 
    141      * @return  bool 
     133     * @param   array 
     134     * @return  bool 
    142135     */ 
    143136    public function check_dependencies(array $dependencies) 
     
    175168    } 
    176169 
    177     // --------------------------------------------------------------------- 
    178  
    179170    /** 
    180171     * Delete Cache 
     
    194185    } 
    195186 
    196     // --------------------------------------------------------------------- 
    197  
    198187    /** 
    199188     * Purge all caches 
    200189     * 
    201      * @param   limit purge to subsection 
    202      * @return  bool 
     190     * @param   limit purge to subsection 
     191     * @return  bool 
    203192     */ 
    204193    public function delete_all($section) 
     
    260249    } 
    261250 
    262     // --------------------------------------------------------------------- 
    263  
    264251    /** 
    265252     * Save a cache, this does the generic pre-processing 
    266253     * 
    267      * @return  bool 
     254     * @return  bool  success 
    268255     */ 
    269256    protected function _set() 
     
    278265            $this->redis->expireat($key, $this->expiration); 
    279266        } 
    280     } 
    281  
    282     // --------------------------------------------------------------------- 
     267 
     268        return true; 
     269    } 
    283270 
    284271    /** 
    285272     * Load a cache, this does the generic post-processing 
    286273     * 
    287      * @return bool 
     274     * @return  bool  success 
    288275     */ 
    289276    protected function _get() 
     
    300287        catch (\UnexpectedValueException $e) 
    301288        { 
    302  
    303289            return false; 
    304290        } 
     
    307293    } 
    308294 
    309     // --------------------------------------------------------------------- 
    310  
    311295    /** 
    312296     * get's the memcached key belonging to the cache identifier 
    313297     * 
    314      * @access  private 
    315      * @param   bool        if true, remove the key retrieved from the index 
     298     * @param   bool  if true, remove the key retrieved from the index 
    316299     * @return  string 
    317300     */ 
     
    389372    } 
    390373 
    391     // --------------------------------------------------------------------- 
    392  
    393374    /** 
    394375     * generate a new unique key for the current identifier 
    395376     * 
    396      * @access  private 
    397377     * @return  string 
    398378     */ 
     
    407387    } 
    408388 
    409     // --------------------------------------------------------------------- 
    410  
    411389    /** 
    412390     * validate a driver config value 
    413391     * 
    414      * @param   string  name of the config variable to validate 
    415      * @param   mixed   value 
    416      * @access  private 
     392     * @param   string  name of the config variable to validate 
     393     * @param   mixed   value 
    417394     * @return  mixed 
    418395     */ 
     
    450427    } 
    451428 
    452     // -------------------------------------------------------------------- 
    453  
    454429    /** 
    455430     * Serialize an array 
     
    458433     * marker, so when it gets unserialized the slashes will be preserved 
    459434     * 
    460      * @access  private 
    461      * @param   array 
    462      * @return  string 
     435     * @param   array 
     436     * @return  string 
    463437     */ 
    464438    protected function _serialize($data) 
     
    484458        return serialize($data); 
    485459    } 
    486  
    487     // -------------------------------------------------------------------- 
    488460 
    489461    /** 
     
    493465     * temporary slash markers back to actual slashes 
    494466     * 
    495      * @access  private 
    496      * @param   array 
    497      * @return  string 
     467     * @param   array 
     468     * @return  string 
    498469     */ 
    499470    protected function _unserialize($data) 
     
    516487        return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data; 
    517488    } 
    518  
    519489} 
    520  
    521  
  • trunk/fuel/core/classes/controller/template.php

    r78 r91  
    4646    } 
    4747 
    48     // After contorller method has run output the template 
     48    // After controller method has run output the template 
    4949    public function after($response) 
    5050    { 
  • trunk/fuel/core/classes/database/mysqli/connection.php

    r88 r91  
    8181            { 
    8282                // Create a persistent connection 
    83                 $this->_connection =  new \mysqli('p:'.$hostname, $username, $password, $database, $port, $socket); 
     83                $this->_connection =  new \MySQLi('p:'.$hostname, $username, $password, $database, $port, $socket); 
    8484            } 
    8585            else 
    8686            { 
    8787                // Create a connection and force it to be a new link 
    88                 $this->_connection = new \mysqli($hostname, $username, $password, $database, $port, $socket); 
     88                $this->_connection = new \MySQLi($hostname, $username, $password, $database, $port, $socket); 
    8989            } 
    9090            if ($this->_connection->error) 
  • trunk/fuel/core/classes/fieldset/field.php

    r86 r91  
    340340    public function error() 
    341341    { 
    342         return $this->fieldset()->validation()->errors($this->name); 
     342        return $this->fieldset()->validation()->error($this->name); 
    343343    } 
    344344} 
  • trunk/fuel/core/classes/format.php

    r78 r91  
    3333    /** 
    3434     * This method is deprecated...use forge() instead. 
    35      *  
     35     * 
    3636     * @deprecated until 1.2 
    3737     */ 
     
    9696 
    9797        $array = array(); 
     98 
     99        if (is_object($data) and ! $data instanceof \Iterator) 
     100        { 
     101            $data = get_object_vars($data); 
     102        } 
    98103 
    99104        foreach ($data as $key => $value) 
  • trunk/fuel/core/classes/fuel.php

    r88 r91  
    187187        { 
    188188            is_string($package) and $path = array($package => $path); 
    189             static::add_package($path); 
     189            \Package::load($path); 
    190190        } 
    191191 
  • trunk/fuel/core/classes/image.php

    r78 r91  
    4242    /** 
    4343     * This method is deprecated...use forge() instead. 
    44      *  
     44     * 
    4545     * @deprecated until 1.2 
    4646     */ 
     
    5454     * Creates a new instance of the image driver 
    5555     * 
    56      * @param  array   $config 
    57      * @return Image_Driver 
     56     * @param   array  $config 
     57     * @return  Image_Driver 
    5858     */ 
    5959    public static function forge($config = array(), $filename = null) 
     
    8686     * factory(). 
    8787     * 
    88      * @param  array   $config   An array of configuration settings. 
    89      * @return Image_Driver 
     88     * @param   array   $config   An array of configuration settings. 
     89     * @return  Image_Driver 
    9090     */ 
    9191    public static function config($index = array(), $value = null) 
     
    107107     * Loads the image and checks if its compatable. 
    108108     * 
    109      * @param  string  $filename  The file to load 
    110      * @return Image_Driver 
     109     * @param   string  $filename  The file to load 
     110     * @return  Image_Driver 
    111111     */ 
    112112    public static function load($filename) 
     
    120120     * Absolute integer or percentages accepted for all 4. 
    121121     * 
    122      * @param  integer  $x1  X-Coordinate based from the top-left corner. 
    123      * @param  integer  $y1  Y-Coordinate based from the top-left corner. 
    124      * @param  integer  $x2  X-Coordinate based from the bottom-right corner. 
    125      * @param  integer  $y2  Y-Coordinate based from the bottom-right corner. 
    126      * @return Image_Driver 
     122     * @param   integer  $x1  X-Coordinate based from the top-left corner. 
     123     * @param   integer  $y1  Y-Coordinate based from the top-left corner. 
     124     * @param   integer  $x2  X-Coordinate based from the bottom-right corner. 
     125     * @param   integer  $y2  Y-Coordinate based from the bottom-right corner. 
     126     * @return  Image_Driver 
    127127     */ 
    128128    public static function crop($x1, $y1, $x2, $y2) 
     
    134134     * Resizes the image. If the width or height is null, it will resize retaining the original aspect ratio. 
    135135     * 
    136      * @param  integer  $width   The new width of the image. 
    137      * @param  integer  $height  The new height of the image. 
    138      * @param  boolean  $keepar  Defaults to true. If false, allows resizing without keeping AR. 
    139      * @param  boolean  $pad     If set to true and $keepar is true, it will pad the image with the configured bgcolor 
    140      * @return Image_Driver 
     136     * @param   integer  $width   The new width of the image. 
     137     * @param   integer  $height  The new height of the image. 
     138     * @param   boolean  $keepar  Defaults to true. If false, allows resizing without keeping AR. 
     139     * @param   boolean  $pad     If set to true and $keepar is true, it will pad the image with the configured bgcolor 
     140     * @return  Image_Driver 
    141141     */ 
    142142    public static function resize($width, $height, $keepar = true, $pad = false) 
     
    148148     * Resizes the image. If the width or height is null, it will resize retaining the original aspect ratio. 
    149149     * 
    150      * @param  integer  $width   The new width of the image. 
    151      * @param  integer  $height  The new height of the image. 
    152      * @return Image_Driver 
     150     * @param   integer  $width   The new width of the image. 
     151     * @param   integer  $height  The new height of the image. 
     152     * @return  Image_Driver 
    153153     */ 
    154154    public static function crop_resize($width, $height) 
     
    160160     * Rotates the image 
    161161     * 
    162      * @param  integer  $degrees  The degrees to rotate, negatives integers allowed. 
    163      * @return Image_Driver 
     162     * @param   integer  $degrees  The degrees to rotate, negatives integers allowed. 
     163     * @return  Image_Driver 
    164164     */ 
    165165    public static function rotate($degrees) 
     
    171171     * Adds a watermark to the image. 
    172172     * 
    173      * @param  string   $filename  The filename of the watermark file to use. 
    174      * @param  string   $position  The position of the watermark, ex: "bottom right", "center center", "top left" 
    175      * @param  integer  $padding   The spacing between the edge of the image. 
    176      * @return Image_Driver 
     173     * @param   string   $filename  The filename of the watermark file to use. 
     174     * @param   string   $position  The position of the watermark, ex: "bottom right", "center center", "top left" 
     175     * @param   integer  $padding   The spacing between the edge of the image. 
     176     * @return  Image_Driver 
    177177     */ 
    178178    public static function watermark($filename, $position, $padding = 5) 
     
    184184     * Adds a border to the image. 
    185185     * 
    186      * @param  integer  $size   The side of the border, in pixels. 
    187      * @param  string   $color  A hexidecimal color. 
    188      * @param  Image_Driver 
     186     * @param   integer  $size   The side of the border, in pixels. 
     187     * @param   string   $color  A hexidecimal color. 
     188     * @return  Image_Driver 
    189189     */ 
    190190    public static function border($size, $color = null) 
     
    196196     * Masks the image using the alpha channel of the image input. 
    197197     * 
    198      * @param  string  $maskimage  The location of the image to use as the mask 
    199      * @return Image_Driver 
     198     * @param   string  $maskimage  The location of the image to use as the mask 
     199     * @return  Image_Driver 
    200200     */ 
    201201    public static function mask($maskimage) 
     
    207207     * Adds rounded corners to the image. 
    208208     * 
    209      * @param  integer  $radius 
    210      * @param  integer  $sides      Accepts any combination of "tl tr bl br" seperated by spaces, or null for all sides 
    211      * @param  integer  $antialias  Sets the antialias range. 
    212      * @return Image_Driver 
     209     * @param   integer  $radius 
     210     * @param   integer  $sides      Accepts any combination of "tl tr bl br" seperated by spaces, or null for all sides 
     211     * @param   integer  $antialias  Sets the antialias range. 
     212     * @return  Image_Driver 
    213213     */ 
    214214    public static function rounded($radius, $sides = null, $antialias = null) 
     
    216216        return static::instance()->rounded($radius, $sides, $antialias); 
    217217    } 
    218      
     218 
    219219    /** 
    220220     * Turns the image into a grayscale version 
    221      *  
    222      * @return  Image_Driver 
     221     * 
     222     * @return  Image_Driver 
    223223     */ 
    224224    public static function grayscale() 
     
    230230     * Saves the image, and optionally attempts to set permissions 
    231231     * 
    232      * @param  string  $filename     The location where to save the image. 
    233      * @param  string  $permissions  Allows unix style permissions 
    234      * @return Image_Driver 
     232     * @param   string  $filename     The location where to save the image. 
     233     * @param   string  $permissions  Allows unix style permissions 
     234     * @return  Image_Driver 
    235235     */ 
    236236    public static function save($filename, $permissions = null) 
     
    242242     * Saves the image, and optionally attempts to set permissions 
    243243     * 
    244      * @param  string  $prepend      The text to add to the beginning of the filename. 
    245      * @param  string  $append       The text to add to the end of the filename. 
    246      * @param  string  $permissions  Allows unix style permissions 
    247      * @return Image_Driver 
     244     * @param   string  $prepend      The text to add to the beginning of the filename. 
     245     * @param   string  $append       The text to add to the end of the filename. 
     246     * @param   string  $permissions  Allows unix style permissions 
     247     * @return  Image_Driver 
    248248     */ 
    249249    public static function save_pa($prepend, $append = null, $permissions = null) 
     
    255255     * Outputs the file directly to the user. 
    256256     * 
    257      * @param  string  $filetype  The extension type to use. Ex: png, jpg, bmp, gif 
    258      * @return Image_Driver 
     257     * @param   string  $filetype  The extension type to use. Ex: png, jpg, bmp, gif 
     258     * @return  Image_Driver 
    259259     */ 
    260260    public static function output($filetype = null) 
     
    264264 
    265265    /** 
    266      * Returns sizes for the currently loaded image, or the image given in the $filename. 
    267      * 
    268      * @param   string  $filename   The location of the file to get sizes for. 
    269      * @return  object  An object containing width and height variables. 
     266     * Returns  sizes for the currently loaded image, or the image given in the $filename. 
     267     * 
     268     * @param   string  The location of the file to get sizes for. 
     269     * @return  object  An object containing width and height variables. 
    270270     */ 
    271271    public static function sizes($filename = null) 
     
    278278        return static::instance()->reload(); 
    279279    } 
    280  
    281280} 
    282  
  • trunk/fuel/core/classes/image/driver.php

    r78 r91  
    3030        Config::load('image', 'image'); 
    3131        if (is_array($config)) 
     32        { 
    3233            $this->config = array_merge(Config::get('image'), $config); 
     34        } 
    3335        else 
     36        { 
    3437            $this->config = Config::get('image'); 
    35         $this->debug("Image Class was initalized using the " . $this->config['driver'] . " driver."); 
     38        } 
     39        $this->debug("Image Class was initialized using the " . $this->config['driver'] . " driver."); 
    3640    } 
    3741    /** 
    3842     * Accepts configuration in either an array (as $index) or a pairing using $index and $value 
    3943     * 
    40      * @param  string  $index  The index to be set, or an array of configuration options. 
    41      * @param  mixed   $value  The value to be set if $index is not an array. 
     44     * @param   string  $index  The index to be set, or an array of configuration options. 
     45     * @param   mixed   $value  The value to be set if $index is not an array. 
     46     * @return  Image_Driver 
    4247     */ 
    4348    public function config($index = null, $value = null) 
     
    4651        { 
    4752            if (isset($index['driver'])) 
    48                 throw new \Fuel_Exception("The driver cannot be changed after initalization!"); 
     53            { 
     54                throw new \RuntimeException("The driver cannot be changed after initialization!"); 
     55            } 
    4956            $this->config = array_merge($this->config, $index); 
    5057        } 
     
    5259        { 
    5360            if ($index == 'driver') 
    54                 throw new \Fuel_Exception("The driver cannot be changed after initalization!"); 
     61            { 
     62                throw new \RuntimeException("The driver cannot be changed after initialization!"); 
     63            } 
    5564            $this->config[$index] = $value; 
    5665        } 
     66 
    5767        return $this; 
    5868    } 
     
    6171     * Exectues the presets set in the config. Additional parameters replace the $1, $2, ect. 
    6272     * 
    63      * @param  string  $name  The name of the preset. 
     73     * @param   string  $name  The name of the preset. 
     74     * @return  Image_Driver 
    6475     */ 
    6576    public function preset($name) 
     
    8798        else 
    8899        { 
    89             throw new \Fuel_Exception("Could not load preset $name, you sure it exists?"); 
    90         } 
    91         return $this; 
    92     } 
    93  
    94     /** 
    95      * Loads the image and checks if its compatable. 
     100            throw new \InvalidArgumentException("Could not load preset $name, you sure it exists?"); 
     101        } 
     102        return $this; 
     103    } 
     104 
     105    /** 
     106     * Loads the image and checks if its compatible. 
    96107     * 
    97108     * @param   string  $filename     The file to load 
     
    129140            else 
    130141            { 
    131                 throw new \Fuel_Exception("The library does not support this filetype for <i>$filename</i>."); 
     142                throw new \RuntimeException("The library does not support this filetype for $filename."); 
    132143            } 
    133144        } 
    134145        else 
    135146        { 
    136             throw new \Fuel_Exception("Image file <i>$filename</i> does not exist."); 
     147            throw new \OutOfBoundsException("Image file $filename does not exist."); 
    137148        } 
    138149        return $return; 
     
    239250                else 
    240251                { 
    241                     throw new \Fuel_Exception("Width and height cannot be null."); 
    242                 } 
    243             } 
    244         } 
     252                    throw new \InvalidArgumentException("Width and height cannot be null."); 
     253                } 
     254            } 
     255        } 
     256 
    245257        $origwidth  = $this->convert_number($width, true); 
    246258        $origheight = $this->convert_number($height, false); 
     
    285297            } 
    286298        } 
     299 
    287300        if ($pad) 
    288301        { 
    289302            $x = floor(($origwidth - $width) / 2); 
    290303            $y = floor(($origheight - $height) / 2); 
    291         } else { 
     304        } 
     305        else 
     306        { 
    292307            $origwidth  = $width; 
    293308            $origheight = $height; 
    294309        } 
     310 
    295311        return array( 
    296312            'width'   => $width, 
     
    316332        $height  = $this->convert_number($height, false); 
    317333        $x = $y = 0; 
     334 
    318335        if (function_exists('bcdiv')) 
    319336        { 
     
    338355            } 
    339356        } 
     357 
    340358        $sizes = $this->sizes(); 
    341359        $y = floor(($sizes->height - $height) / 2); 
     
    347365     * Rotates the image 
    348366     * 
    349      * @param   integer $degrees    The degrees to rotate, negatives integers allowed. 
    350      * @param   Image_Driver 
     367     * @param   integer  $degrees  The degrees to rotate, negatives integers allowed. 
     368     * @return  Image_Driver 
    351369     */ 
    352370    public function rotate($degrees) 
     
    361379     * Formats the rotate method input for use with driver specific methods 
    362380     * 
    363      * @param   integer $degrees    The degrees to rotate, negatives integers allowed. 
    364      * @return  Array   An array of variables for the specific driver. 
     381     * @param   integer  $degrees  The degrees to rotate, negatives integers allowed. 
     382     * @return  array    An array of variables for the specific driver. 
    365383     */ 
    366384    protected function _rotate($degrees) 
     
    379397     * Adds a watermark to the image. 
    380398     * 
    381      * @param   string  $filename   The filename of the watermark file to use. 
    382      * @param   string  $position   The position of the watermark, ex: "bottom right", "center center", "top left" 
    383      * @param   integer $padding    The amount of padding (in pixels) from the position. 
    384      * @param   Image_Driver 
     399     * @param   string   $filename  The filename of the watermark file to use. 
     400     * @param   string   $position  The position of the watermark, ex: "bottom right", "center center", "top left" 
     401     * @param   integer  $padding   The amount of padding (in pixels) from the position. 
     402     * @return  Image_Driver 
    385403     */ 
    386404    public function watermark($filename, $position, $padding = 5) 
     
    395413     * Formats the watermark method input for use with driver specific methods 
    396414     * 
    397      * @param   string  $filename   The filename of the watermark file to use. 
    398      * @param   string  $position   The position of the watermark, ex: "bottom right", "center center", "top left" 
    399      * @param   integer $padding    The amount of padding (in pixels) from the position. 
    400      * @return  Array   An array of variables for the specific driver. 
     415     * @param   string   $filename  The filename of the watermark file to use. 
     416     * @param   string   $position  The position of the watermark, ex: "bottom right", "center center", "top left" 
     417     * @param   integer  $padding   The amount of padding (in pixels) from the position. 
     418     * @return  array    An array of variables for the specific driver. 
    401419     */ 
    402420    protected function _watermark($filename, $position, $padding = 5) 
     
    452470     * Adds a border to the image. 
    453471     * 
    454      * @param   integer $size   The side of the border, in pixels. 
    455      * @param   string  $color  A hexidecimal color. 
    456      * @param   Image_Driver 
     472     * @param   integer  $size   The side of the border, in pixels. 
     473     * @param   string   $color  A hexadecimal color. 
     474     * @return  Image_Driver 
    457475     */ 
    458476    public function border($size, $color = null) 
     
    467485     * Formats the border method input for use with driver specific methods 
    468486     * 
    469      * @param   integer $size   The side of the border, in pixels. 
    470      * @param   string  $color  A hexidecimal color. 
    471      * @return  Array   An array of variables for the specific driver. 
     487     * @param   integer  $size   The side of the border, in pixels. 
     488     * @param   string   $color  A hexadecimal color. 
     489     * @return  array    An array of variables for the specific driver. 
    472490     */ 
    473491    protected function _border($size, $color = null) 
     
    484502     * Masks the image using the alpha channel of the image input. 
    485503     * 
    486      * @param   string  $maskimage  The location of the image to use as the mask 
    487      * @return  Image_Driver 
     504     * @param   string  $maskimage  The location of the image to use as the mask 
     505     * @return  Image_Driver 
    488506     */ 
    489507    public function mask($maskimage) 
     
    498516     * Formats the mask method input for use with driver specific methods 
    499517     * 
    500      * @param   string  $maskimage  The location of the image to use as the mask 
    501      * @return  Array   An array of variables for the specific driver. 
     518     * @param   string  $maskimage  The location of the image to use as the mask 
     519     * @return  array   An array of variables for the specific driver. 
    502520     */ 
    503521    protected function _mask($maskimage) 
     
    511529     * Adds rounded corners to the image. 
    512530     * 
    513      * @param   integer $radius 
    514      * @param   integer $sides  Accepts any combination of "tl tr bl br" seperated by spaces, or null for all sides 
    515      * @param   integer $antialias  Sets the antialias range. 
    516      * @return  Image_Driver 
     531     * @param   integer  $radius 
     532     * @param   integer  $sides      Accepts any combination of "tl tr bl br" separated by spaces, or null for all sides 
     533     * @param   integer  $antialias  Sets the antialias range. 
     534     * @return  Image_Driver 
    517535     */ 
    518536    public function rounded($radius, $sides = null, $antialias = null) 
     
    527545     * Formats the rounded method input for use with driver specific methods 
    528546     * 
    529      * @param   integer $radius 
    530      * @param   integer $sides  Accepts any combination of "tl tr bl br" seperated by spaces, or null for all sides 
    531      * @param   integer $antialias  Sets the antialias range. 
    532      * @return  Array   An array of variables for the specific driver. 
     547     * @param   integer  $radius 
     548     * @param   integer  $sides      Accepts any combination of "tl tr bl br" separated by spaces, or null for all sides 
     549     * @param   integer  $antialias  Sets the antialias range. 
     550     * @return  array    An array of variables for the specific driver. 
    533551     */ 
    534552    protected function _rounded($radius, $sides, $antialias) 
     
    559577        ); 
    560578    } 
    561      
     579 
    562580    /** 
    563581     * Turns the image into a grayscale version 
    564      *  
    565      * @return  Image_Driver 
     582     * 
     583     * @return  Image_Driver 
    566584     */ 
    567585    public function grayscale() 
     
    570588        return $this; 
    571589    } 
    572      
     590 
    573591    /** 
    574592     * Executes the grayscale event when the queue is ran. 
    575593     */ 
    576     protected function _grayscale() 
    577     { 
    578          
    579     } 
     594    abstract protected function _grayscale(); 
    580595 
    581596    /** 
    582597     * Saves the image, and optionally attempts to set permissions 
    583598     * 
    584      * @param   string  $filename   The location where to save the image. 
    585      * @param   string  $permissions    Allows unix style permissions 
     599     * @param   string  $filename     The location where to save the image. 
     600     * @param   string  $permissions  Allows unix style permissions 
     601     * @return  array 
    586602     */ 
    587603    public function save($filename, $permissions = null) 
     
    590606        if ( ! is_dir($directory)) 
    591607        { 
    592             throw new \Fuel_Exception("Could not find directory \"$directory\""); 
     608            throw new \OutOfBoundsException("Could not find directory \"$directory\""); 
    593609        } 
    594610 
     
    600616        if ( ! touch($filename)) 
    601617        { 
    602             throw new \Fuel_Exception("Do not have permission to write to \"$filename\""); 
     618            throw new \RuntimeException("Do not have permission to write to \"$filename\""); 
    603619        } 
    604620 
     
    606622        if ($permissions != null and ! chmod($filename, $permissions)) 
    607623        { 
    608             throw new \Fuel_Exception("Could not set permissions on the file."); 
     624            throw new \RuntimeException("Could not set permissions on the file."); 
    609625        } 
    610626 
     
    618634     * Saves the file in the original location, adding the append and prepend to the filename. 
    619635     * 
    620      * @param  string   $append       The string to append to the filename 
    621      * @param  string   $prepend      The string to prepend to the filename 
    622      * @param  string   $extension    The extension to save the image as, null defaults to the loaded images extension. 
    623      * @param  integer  $permissions  The permissions to attempt to set on the file. 
     636     * @param   string   $append       The string to append to the filename 
     637     * @param   string   $prepend      The string to prepend to the filename 
     638     * @param   string   $extension    The extension to save the image as, null defaults to the loaded images extension. 
     639     * @param   integer  $permissions  The permissions to attempt to set on the file. 
     640     * @return  Image_Driver 
    624641     */ 
    625642    public function save_pa($append, $prepend = null, $extension = null, $permissions = null) 
    626643    { 
    627644        $filename = substr($this->image_filename, 0, -(strlen($this->image_extension) + 1)); 
    628         $fullpath = $this->image_directory.'/'.$append.$filename.$prepend.'.'.($extension !== null ? $extension : $this->image_extension); 
     645        $fullpath = $this->image_directory.'/'.$append.$filename.$prepend.'.'. 
     646            ($extension !== null ? $extension : $this->image_extension); 
    629647        $this->save($fullpath, $permissions); 
    630648        return $this; 
     
    634652     * Outputs the file directly to the user. 
    635653     * 
    636      * @param   string  $filetype   The extension type to use. Ex: png, jpg, gif 
     654     * @param   string  $filetype  The extension type to use. Ex: png, jpg, gif 
     655     * @return  array 
    637656     */ 
    638657    public function output($filetype = null) 
     
    665684     * Returns sizes for the currently loaded image, or the image given in the $filename. 
    666685     * 
    667      * @param   string  $filename   The location of the file to get sizes for. 
    668      * @return  object  An object containing width and height variables. 
     686     * @param   string  $filename  The location of the file to get sizes for. 
     687     * @return  object  An object containing width and height variables. 
    669688     */ 
    670689    abstract public function sizes($filename = null); 
     
    678697     * Checks if the extension is accepted by this library, and if its valid sets the $this->image_extension variable. 
    679698     * 
    680      * @param   string  $filename 
    681      * @param   boolean $writevar   Decides if the extension should be written to $this->image_extension 
    682      * @return  boolean 
     699     * @param   string   $filename 
     700     * @param   boolean  $writevar  Decides if the extension should be written to $this->image_extension 
     701     * @return  boolean 
    683702     */ 
    684703    protected function check_extension($filename, $writevar = true) 
     
    699718     * Converts percentages, negatives, and other values to absolute integers. 
    700719     * 
    701      * @param   string  $input 
    702      * @param   boolean $x  Determines if the number relates to the x-axis or y-axis. 
    703      * @return  integer The converted number, useable with the image being edited. 
     720     * @param   string   $input 
     721     * @param   boolean  $x  Determines if the number relates to the x-axis or y-axis. 
     722     * @return  integer  The converted number, usable with the image being edited. 
    704723     */ 
    705724    protected function convert_number($input, $x = null) 
    706725    { 
    707         // Sanatize double negatives 
     726        // Sanitize double negatives 
    708727        $input = str_replace('--', '', $input); 
    709728 
     
    727746     * Queues a function to run at a later time. 
    728747     * 
    729      * @param   string  $function   The name of the function to be ran, without the leading _ 
     748     * @param  string  $function  The name of the function to be ran, without the leading _ 
    730749     */ 
    731750    protected function queue($function) 
     
    745764     * Runs all queued actions on the loaded image. 
    746765     * 
    747      * @param   boolean $clear  Decides if the queue should be cleared once completed. 
     766     * @param  boolean  $clear  Decides if the queue should be cleared once completed. 
    748767     */ 
    749768    public function run_queue($clear = null) 
     
    767786    /** 
    768787     * Reloads the image. 
     788     * 
     789     * @return  Image_Driver 
    769790     */ 
    770791    public function reload() 
     
    778799     * Used for debugging image output. 
    779800     * 
    780      * @param   string  $message 
     801     * @param  string  $message 
    781802     */ 
    782803    protected function debug() 
  • trunk/fuel/core/classes/image/gd.php

    r64 r91  
    2727        $image_extension == 'jpg' and $image_extension = 'jpeg'; 
    2828 
    29         if ( ! $return_data) { 
     29        if ( ! $return_data) 
     30        { 
    3031            $this->image_data !== null and imagedestroy($this->image_data); 
    3132            $this->image_data = null; 
    3233        } 
    33          
     34 
    3435        // Check if the function exists 
    3536        if (function_exists('imagecreatefrom'.$image_extension)) 
     
    5253        else 
    5354        { 
    54             throw new \Fuel_Exception("Function imagecreatefrom".$image_extension."() does not exist (Missing GD?)"); 
     55            throw new \RuntimeException("Function imagecreatefrom".$image_extension."() does not exist (Missing GD?)"); 
    5556        } 
    5657        return $return_data ? $return : $this; 
     
    9697        if ($values == false) 
    9798        { 
    98             throw new \Fuel_Exception("Watermark image not found or invalid filetype."); 
     99            throw new \InvalidArgumentException("Watermark image not found or invalid filetype."); 
    99100        } 
    100101        else 
     
    224225        $br and $this->round_corner($this->image_data, $radius, $antialias, false, false); 
    225226    } 
    226      
     227 
    227228    protected function _grayscale() 
    228229    { 
    229230        $sizes = $this->sizes(); 
    230          
     231 
    231232        // Create the 256 color palette 
    232233        $bwpalette = array(); 
    233234        for ($i = 0; $i < 256; $i++) 
     235        { 
    234236            $bwpalette[$i] = imagecolorallocate($this->image_data, $i, $i, $i); 
    235          
     237        } 
     238 
    236239        for ($x = 0; $x < $sizes->width; $x++) 
    237240        { 
     
    242245                $green = ($color >> 8) & 0xFF; 
    243246                $blue  = $color & 0xFF; 
    244                  
     247 
    245248                // If its black or white, theres no use in setting the pixel 
    246249                if (($red == 0 && $green == 0 && $blue == 0) || ($red == 255 && $green == 255 && $blue == 255)) 
     250                { 
    247251                    continue; 
    248                  
     252                } 
     253 
    249254                // Now set the color 
    250255                $shade = (($red*0.299)+($green*0.587)+($blue*0.114)); 
     
    299304        call_user_func_array('image'.$filetype, $vars); 
    300305        if ($this->config['persistence'] === false) 
     306        { 
    301307            $this->reload(); 
     308        } 
     309 
    302310        return $this; 
    303311    } 
     
    324332 
    325333        call_user_func_array('image'.$filetype, $vars); 
    326          
     334 
    327335        if ($this->config['persistence'] === false) 
     336        { 
    328337            $this->reload(); 
     338        } 
    329339 
    330340        return $this; 
     
    334344     * Creates a new color usable by GD. 
    335345     * 
    336      * @param  resource  $image  The image to create the color from 
    337      * @param  string    $hex    The hex code of the color 
    338      * @param  integer   $alpha  The alpha of the color, 0 (trans) to 100 (opaque) 
    339      * @return integer   The color 
     346     * @param   resource  $image  The image to create the color from 
     347     * @param   string    $hex    The hex code of the color 
     348     * @param   integer   $alpha  The alpha of the color, 0 (trans) to 100 (opaque) 
     349     * @return  integer   The color 
    340350     */ 
    341351    protected function create_color(&$image, $hex, $alpha) 
     
    371381            $alpha = 127 - floor($alpha * 1.27); 
    372382        } 
     383 
    373384        // Check if the transparency is allowed 
    374385        return imagecolorallocatealpha($image, $red, $green, $blue, $alpha); 
     
    408419            $transcolor = imagecolortransparent($image); 
    409420            if ($transcolor > 0) 
     421            { 
    410422                $color = $transcolor; 
     423            } 
    411424            imagecolortransparent($image, $color); 
    412425        } 
     
    511524        imagealphablending($image, true); 
    512525    } 
    513  
    514526} 
    515  
  • trunk/fuel/core/classes/image/imagemagick.php

    r78 r91  
    3535            while (file_exists($this->image_temp)); 
    3636        } 
    37         else if (file_exists($this->image_temp)) 
     37        elseif (file_exists($this->image_temp)) 
    3838        { 
    3939            $this->debug('Removing previous temporary image.'); 
     
    4343        if (!file_exists($this->config['temp_dir']) || !is_dir($this->config['temp_dir'])) 
    4444        { 
    45             throw new \Fuel_Exception("The temp directory that was given does not exist."); 
    46         } 
    47         else if (!touch($this->config['temp_dir'] . $this->config['temp_append'] . '_touch')) 
    48         { 
    49             throw new \Fuel_Exception("Could not write in the temp directory."); 
     45            throw new \RuntimeException("The temp directory that was given does not exist."); 
     46        } 
     47        elseif (!touch($this->config['temp_dir'] . $this->config['temp_append'] . '_touch')) 
     48        { 
     49            throw new \RuntimeException("Could not write in the temp directory."); 
    5050        } 
    5151        $this->exec('convert', '"'.$image_fullpath.'"[0] "'.$this->image_temp.'"'); 
     
    6868        $image = '"'.$this->image_temp.'"'; 
    6969        $this->exec('convert', "-define png:size=".$cwidth."x".$cheight." ".$image." ". 
    70                 "-background none ". 
    71                 "-resize \"".($pad ? $width : $cwidth)."x".($pad ? $height : $cheight)."!\" ". 
    72                 "-gravity center ". 
    73                 "-extent ".$cwidth."x".$cheight." ".$image); 
     70            "-background none ". 
     71            "-resize \"".($pad ? $width : $cwidth)."x".($pad ? $height : $cheight)."!\" ". 
     72            "-gravity center ". 
     73            "-extent ".$cwidth."x".$cheight." ".$image); 
    7474        $this->clear_sizes(); 
    7575    } 
     
    145145        $this->exec('convert', $command); 
    146146    } 
    147      
     147 
    148148    protected function _grayscale() 
    149149    { 
     
    182182            $return = $this->sizes_cache; 
    183183        } 
     184 
    184185        return $return; 
    185186    } 
     
    191192        $this->run_queue(); 
    192193        $this->add_background(); 
    193          
     194 
    194195        $old = '"'.$this->image_temp.'"'; 
    195196        $new = '"'.$filename.'"'; 
     
    197198 
    198199        if ($this->config['persistence'] === false) 
     200        { 
    199201            $this->reload(); 
     202        } 
    200203 
    201204        return $this; 
     
    224227            } 
    225228        } 
     229 
    226230        if ($this->config['persistence'] === false) 
     231        { 
    227232            $this->reload(); 
     233        } 
     234 
    228235        return $this; 
    229236    } 
     
    254261     * Executes the specified imagemagick executable and returns the output. 
    255262     * 
    256      * @param  string   $program   The name of the executable. 
    257      * @param  string   $params    The parameters of the executable. 
    258      * @param  boolean  $passthru  Returns the output if false or pass it to browser. 
    259      * @return mixed    Either returns the output or returns nothing. 
     263     * @param   string   $program   The name of the executable. 
     264     * @param   string   $params    The parameters of the executable. 
     265     * @param   boolean  $passthru  Returns the output if false or pass it to browser. 
     266     * @return  mixed    Either returns the output or returns nothing. 
    260267     */ 
    261268    private function exec($program, $params, $passthru = false) 
     
    264271        $this->im_path = realpath($this->config['imagemagick_dir'].$program); 
    265272        if ( ! $this->im_path) 
     273        { 
    266274            $this->im_path = realpath($this->config['imagemagick_dir'].$program); 
     275        } 
    267276        if ( ! $this->im_path) 
     277        { 
    268278            $this->im_path = realpath($this->config['imagemagick_dir'].$program.'.exe'); 
     279        } 
    269280        if ( ! $this->im_path) 
    270             throw new \Fuel_Exception("imagemagick executables not found in ".$this->config['imagemagick_dir']); 
     281        { 
     282            throw new \RuntimeException("imagemagick executables not found in ".$this->config['imagemagick_dir']); 
     283        } 
     284 
    271285        $command = $this->im_path." ".$params; 
    272286        $this->debug("Running command: <code>$command</code>"); 
     
    281295            throw new \Fuel_Exception("imagemagick failed to edit the image. Returned with $code.<br /><br />Command:\n <code>$command</code>"); 
    282296        } 
     297 
    283298        return $output; 
    284299    } 
     
    287302     * Creates a new color usable by ImageMagick. 
    288303     * 
    289      * @param  string   $hex    The hex code of the color 
    290      * @param  integer  $alpha  The alpha of the color, 0 (trans) to 100 (opaque) 
    291      * @return string   rgba representation of the hex and alpha values. 
     304     * @param   string   $hex    The hex code of the color 
     305     * @param   integer  $alpha  The alpha of the color, 0 (trans) to 100 (opaque) 
     306     * @return  string   rgba representation of the hex and alpha values. 
    292307     */ 
    293308    protected function create_color($hex, $alpha) 
  • trunk/fuel/core/classes/image/imagick.php

    r78 r91  
    2323    { 
    2424        extract(parent::load($filename)); 
    25          
     25 
    2626        if ($this->imagick == null) 
     27        { 
    2728            $this->imagick = new \Imagick(); 
    28          
     29        } 
     30 
    2931        $this->imagick->readImage($filename); 
    30          
     32 
    3133        return $this; 
    3234    } 
     
    4850    { 
    4951        extract(parent::_resize($width, $height, $keepar, $pad)); 
    50          
     52 
    5153        $this->imagick->scaleImage($width, $height, $keepar); 
    52          
     54 
    5355        if ($pad) 
    5456        { 
     
    6365    { 
    6466        extract(parent::_rotate($degrees)); 
    65          
     67 
    6668        $this->imagick->rotateImage($this->create_color('#000', 0), $degrees); 
    6769    } 
     
    7981    { 
    8082        extract(parent::_border($size, $color)); 
    81          
     83 
    8284        $this->imagick->borderImage($this->create_color($color, 100), $size, $size); 
    8385    } 
     
    9193        $this->imagick->compositeImage($wmimage, \Imagick::COMPOSITE_COPYOPACITY, 0, 0); 
    9294    } 
    93      
     95 
    9496    protected function _rounded($radius, $sides, $antialias = 0) 
    9597    { 
    9698        extract(parent::_rounded($radius, $sides, null)); 
    97          
     99 
    98100        $sizes = $this->sizes(); 
    99101        $sizes->width_half = $sizes->width / 2; 
    100102        $sizes->height_half = $sizes->height / 2; 
    101          
     103 
    102104        if ( ! $tl) 
    103105        { 
     
    105107            $tlimage->cropImage($sizes->width_half, $sizes->height_half, 0, 0); 
    106108        } 
    107          
     109 
    108110        if ( ! $tr) 
    109111        { 
     
    111113            $trimage->cropImage($sizes->width_half, $sizes->height_half, $sizes->width_half, 0); 
    112114        } 
    113          
     115 
    114116        if ( ! $bl) 
    115117        { 
     
    117119            $blimage->cropImage($sizes->width_half, $sizes->height_half, 0, $sizes->height_half); 
    118120        } 
    119          
     121 
    120122        if ( ! $br) 
    121123        { 
     
    123125            $brimage->cropImage($sizes->width_half, $sizes->height_half, $sizes->width_half, $sizes->height_half); 
    124126        } 
    125          
     127 
    126128        $this->imagick->roundCorners($radius, $radius); 
    127          
     129 
    128130        if ( ! $tl) 
     131        { 
    129132            $this->imagick->compositeImage($tlimage, \Imagick::COMPOSITE_DEFAULT, 0, 0); 
    130          
     133        } 
     134 
    131135        if ( ! $tr) 
     136        { 
    132137            $this->imagick->compositeImage($trimage, \Imagick::COMPOSITE_DEFAULT, $sizes->width_half, 0); 
    133          
     138        } 
     139 
    134140        if ( ! $bl) 
     141        { 
    135142            $this->imagick->compositeImage($blimage, \Imagick::COMPOSITE_DEFAULT, 0, $sizes->height_half); 
    136          
     143        } 
     144 
    137145        if ( ! $br) 
     146        { 
    138147            $this->imagick->compositeImage($brimage, \Imagick::COMPOSITE_DEFAULT, $sizes->width_half, $sizes->height_half); 
    139     } 
    140      
     148        } 
     149    } 
     150 
    141151    protected function _grayscale() 
    142152    { 
     
    147157    { 
    148158        if ($filename === null) 
     159        { 
    149160            return (object) array( 
    150161                'width'  => $this->imagick->getImageWidth(), 
    151162                'height' => $this->imagick->getImageHeight() 
    152163            ); 
    153         else 
    154         { 
    155             $tmpimage = new \Imagick(); 
    156             $tmpimage->readImage($filename); 
    157             return (object) array( 
    158                 'width'  => $tmpimage->getImageWidth(), 
    159                 'height' => $tmpimage->getImageHeight() 
    160             ); 
    161         } 
     164        } 
     165 
     166        $tmpimage = new \Imagick(); 
     167        $tmpimage->readImage($filename); 
     168        return (object) array( 
     169            'width'  => $tmpimage->getImageWidth(), 
     170            'height' => $tmpimage->getImageHeight() 
     171        ); 
    162172    } 
    163173 
     
    165175    { 
    166176        extract(parent::save($filename, $permissions)); 
    167          
     177 
    168178        $this->run_queue(); 
    169179        $this->add_background(); 
    170          
     180 
    171181        $filetype = $this->image_extension; 
    172          
     182 
    173183        if ($this->imagick->getImageFormat() != $filetype) 
     184        { 
    174185            $this->imagick->setImageFormat($filetype); 
    175          
     186        } 
     187 
    176188        file_put_contents($filename, $this->imagick->getImageBlob()); 
    177189 
    178190        if ($this->config['persistence'] === false) 
     191        { 
    179192            $this->reload(); 
    180          
     193        } 
     194 
    181195        return $this; 
    182196    } 
     
    185199    { 
    186200        extract(parent::output($filetype)); 
    187          
     201 
    188202        $this->run_queue(); 
    189203        $this->add_background(); 
    190          
     204 
    191205        if ($this->imagick->getImageFormat() != $filetype) 
     206        { 
    192207            $this->imagick->setImageFormat($filetype); 
    193          
     208        } 
     209 
    194210        if ( ! $this->config['debug']) 
     211        { 
    195212            echo $this->imagick->getImageBlob(); 
    196          
     213        } 
     214 
    197215        return $this; 
    198216    } 
     
    247265    } 
    248266} 
    249  
  • trunk/fuel/core/classes/input.php

    r88 r91  
    130130 
    131131        // Do some final clean up of the uri 
    132         static::$detected_uri = \Security::clean_uri(str_replace(array('//', '../'), '/', $uri)); 
     132        static::$detected_uri = \Security::clean_uri($uri, true); 
    133133 
    134134        return static::$detected_uri; 
  • trunk/fuel/core/classes/request.php

    r88 r91  
    133133 
    134134    /** 
     135     * Returns the current request is an HMVC request 
     136     * 
     137     * Usage: 
     138     * 
     139     *     if (Request::is_hmvc()) 
     140     *     { 
     141     *         // Do something special... 
     142     *         return; 
     143     *     } 
     144     * 
     145     * @return  bool 
     146     */ 
     147    public static function is_hmvc() 
     148    { 
     149        return static::active() !== static::main(); 
     150    } 
     151 
     152    /** 
    135153     * Shows a 404.  Checks to see if a 404_override route is set, if not show 
    136154     * a default 404. 
  • trunk/fuel/core/classes/security.php

    r87 r91  
    5656    /** 
    5757     * Cleans the request URI 
    58      */ 
    59     public static function clean_uri($uri) 
     58     * 
     59     * @param  string  $uri     uri to clean 
     60     * @param  bool    $strict  whether to remove relative directories 
     61     */ 
     62    public static function clean_uri($uri, $strict = false) 
    6063    { 
    6164        $filters = \Config::get('security.uri_filter', array()); 
    6265        $filters = is_array($filters) ? $filters : array($filters); 
     66 
     67        $strict and $uri = preg_replace(array("/\.+\//", '/\/+/'), '/', $uri); 
    6368 
    6469        return static::clean($uri, $filters); 
     
    177182            $value = htmlentities($value, ENT_COMPAT, \Fuel::$encoding, false); 
    178183        } 
    179         elseif (is_array($value) || $value instanceof \Iterator || get_class($value) == 'stdClass') 
     184        elseif (is_array($value) or ($value instanceof \Iterator and $value instanceof \ArrayAccess)) 
    180185        { 
    181186            // Add to $already_cleaned variable when object 
     
    185190            { 
    186191                $value[$k] = static::htmlentities($v); 
     192            } 
     193        } 
     194        elseif ($value instanceof \Iterator or get_class($value) == 'stdClass') 
     195        { 
     196            // Add to $already_cleaned variable 
     197            $already_cleaned[] = $value; 
     198 
     199            foreach ($value as $k => $v) 
     200            { 
     201                $value->{$k} = static::htmlentities($v); 
    187202            } 
    188203        } 
  • trunk/fuel/core/classes/str.php

    r78 r91  
    157157            ? mb_strtolower(mb_substr($str, 0, 1, $encoding), $encoding). 
    158158                mb_substr($str, 1, mb_strlen($str, $encoding), $encoding) 
    159             : ucfirst($str); 
     159            : lcfirst($str); 
    160160    } 
    161161 
  • trunk/fuel/core/classes/upload.php

    r90 r91  
    365365 
    366366        // determine the validate status 
    367         $valid = true; 
     367        $valid = false; 
    368368        foreach(static::$files as $key => $value) 
    369369        { 
    370             if ($value['error'] !== 0) 
    371             { 
    372                 $valid = false; 
     370            if ($value['error'] == 0) 
     371            { 
     372                $valid = true; 
    373373                break; 
    374374            } 
  • trunk/fuel/core/classes/validation.php

    r87 r91  
    320320        { 
    321321            $value = $this->input($field->name); 
    322             if ($allow_partial && $value === null) 
     322            if (($allow_partial === true and $value === null) 
     323                or (is_array($allow_partial) and ! in_array($field->name, $allow_partial))) 
    323324            { 
    324325                continue; 
     
    393394                        ? get_class(@$callback[0]).'->'.@$callback[1] 
    394395                        : @$callback[0].'::'.@$callback[1]); 
    395             Error::notice('Invalid rule "'.$string.'" passed to Validation, not used.'); 
     396            \Error::notice('Invalid rule "'.$string.'" passed to Validation, not used.'); 
    396397            return false; 
    397398        } 
  • trunk/fuel/core/config/cache.php

    r64 r91  
    6262    ), 
    6363 
     64    // specific configuration settings for the apc driver 
     65    'apc'  => array( 
     66        'cache_id'  => 'fuel',  // unique id to distinquish fuel cache items from others stored on the same server(s) 
     67    ), 
     68 
    6469    // specific configuration settings for the redis driver 
    6570    'redis'  => array( 
  • trunk/fuel/core/tests/arr.php

    r64 r91  
    7272        $this->assertEquals($expected, $output); 
    7373    } 
     74     
     75    /** 
     76     * Tests Arr::key_exists() 
     77     * 
     78     * @test 
     79     * @dataProvider person_provider 
     80     */ 
     81    public function test_key_exists_with_key_found($person) 
     82    { 
     83        $expected = true; 
     84        $output = Arr::key_exists($person, "name"); 
     85        $this->assertEquals($expected, $output); 
     86    } 
     87     
     88    /** 
     89     * Tests Arr::key_exists() 
     90     * 
     91     * @test 
     92     * @dataProvider person_provider 
     93     */ 
     94    public function test_key_exists_with_key_not_found($person) 
     95    { 
     96        $expected = false; 
     97        $output = Arr::key_exists($person, "unknown"); 
     98        $this->assertEquals($expected, $output); 
     99    } 
     100     
     101    /** 
     102     * Tests Arr::key_exists() 
     103     * 
     104     * @test 
     105     * @dataProvider person_provider 
     106     */ 
     107    public function test_key_exists_with_dot_separated_key($person) 
     108    { 
     109        $expected = true; 
     110        $output = Arr::key_exists($person, "location.city"); 
     111        $this->assertEquals($expected, $output); 
     112    } 
    74113 
    75114    /** 
  • trunk/fuel/packages/auth/classes/auth/login/simpleauth.php

    r88 r91  
    6767        if (is_null($this->user) or ($this->user['username'] != $username and $this->user != static::$guest_login)) 
    6868        { 
    69             $this->user = \DB::select() 
     69            $this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*'))) 
    7070                ->where('username', '=', $username) 
    7171                ->from(\Config::get('simpleauth.table_name')) 
    72                 ->execute()->current(); 
     72                ->execute(\Config::get('simpleauth.db_connection'))->current(); 
    7373        } 
    7474 
     
    103103 
    104104        $password = $this->hash_password($password); 
    105         $this->user = \DB::select() 
     105        $this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*'))) 
    106106            ->where_open() 
    107107            ->where('username', '=', $username_or_email) 
     
    110110            ->where('password', '=', $password) 
    111111            ->from(\Config::get('simpleauth.table_name')) 
    112             ->execute()->current(); 
     112            ->execute(\Config::get('simpleauth.db_connection'))->current(); 
    113113 
    114114        if ($this->user == false) 
     
    141141        } 
    142142 
    143         $this->user = \DB::select() 
     143        $this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*'))) 
    144144            ->where_open() 
    145145            ->where('username', '=', $username_or_email) 
     
    147147            ->where_close() 
    148148            ->from(\Config::get('simpleauth.table_name')) 
    149             ->execute() 
     149            ->execute(\Config::get('simpleauth.db_connection')) 
    150150            ->current(); 
    151151 
     
    195195        } 
    196196 
    197         $same_users = \DB::select() 
     197        $same_users = \DB::select_array(\Config::get('simpleauth.table_columns', array('*'))) 
    198198            ->where('username', '=', $username) 
    199199            ->or_where('email', '=', $email) 
    200200            ->from(\Config::get('simpleauth.table_name')) 
    201             ->execute(); 
     201            ->execute(\Config::get('simpleauth.db_connection')); 
    202202 
    203203        if ($same_users->count() > 0) 
     
    222222        $result = \DB::insert(\Config::get('simpleauth.table_name')) 
    223223            ->set($user) 
    224             ->execute(); 
     224            ->execute(\Config::get('simpleauth.db_connection')); 
    225225 
    226226        return ($result[1] > 0) ? $result[0] : false; 
     
    238238    { 
    239239        $username = $username ?: $this->user['username']; 
    240         $current_values = \DB::select() 
     240        $current_values = \DB::select_array(\Config::get('simpleauth.table_columns', array('*'))) 
    241241            ->where('username', '=', $username) 
    242             ->from(\Config::get('simpleauth.table_name'))->execute(); 
     242            ->from(\Config::get('simpleauth.table_name')) 
     243            ->execute(\Config::get('simpleauth.db_connection')); 
    243244 
    244245        if (empty($current_values)) 
     
    307308            ->set($update) 
    308309            ->where('username', '=', $username) 
    309             ->execute(); 
     310            ->execute(\Config::get('simpleauth.db_connection')); 
    310311 
    311312        // Refresh user 
    312313        if ($this->user['username'] == $username) 
    313314        { 
    314             $this->user = \DB::select() 
     315            $this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*'))) 
    315316                ->where('username', '=', $username) 
    316317                ->from(\Config::get('simpleauth.table_name')) 
    317                 ->execute()->current(); 
     318                ->execute(\Config::get('simpleauth.db_connection'))->current(); 
    318319        } 
    319320 
     
    357358        $affected_rows = \DB::delete(\Config::get('simpleauth.table_name')) 
    358359            ->where('username', '=', $username) 
    359             ->execute(); 
     360            ->execute(\Config::get('simpleauth.db_connection')); 
    360361 
    361362        return $affected_rows > 0; 
     
    379380        \DB::update(\Config::get('simpleauth.table_name')) 
    380381            ->set(array('last_login' => $last_login, 'login_hash' => $login_hash)) 
    381             ->where('username', '=', $this->user['username'])->execute(); 
     382            ->where('username', '=', $this->user['username']) 
     383            ->execute(\Config::get('simpleauth.db_connection')); 
    382384 
    383385        $this->user['login_hash'] = $login_hash; 
  • trunk/fuel/packages/auth/config/simpleauth.php

    r88 r91  
    2323 
    2424    /** 
     25     * DB connection, leave null to use default 
     26     */ 
     27    'db_connection' => null, 
     28 
     29    /** 
    2530     * DB table name for the user table 
    2631     */ 
    2732    'table_name' => 'users', 
     33 
     34    /** 
     35     * Choose which columns are selected, must include: username, password, email, last_login, 
     36     * login_hash, group & profile_fields 
     37     */ 
     38    'table_columns' => array('*'), 
    2839 
    2940    /** 
     
    6273     */ 
    6374    'login_hash_salt' => 'put_some_salt_in_here', 
    64      
     75 
    6576    /** 
    6677     * $_POST key for login username 
    6778     */ 
    6879    'username_post_key' => 'username', 
    69      
     80 
    7081    /** 
    7182     * $_POST key for login password 
  • trunk/fuel/packages/oil/classes/command.php

    r51 r91  
    140140                    \Cli::option('coverage-html') and $command .= ' --coverage-html '.\Cli::option('coverage-html'); 
    141141 
    142                     passthru($command); 
     142                    foreach(explode(';', $command) as $c) 
     143                    { 
     144                        passthru($c); 
     145                    } 
    143146 
    144147                break; 
  • trunk/fuel/packages/oil/views/default/scaffold/ar_model.php

    r51 r91  
    1313 
    1414} 
    15  
    16 /* End of file <?php echo Str::lower($name); ?>.php */ 
  • trunk/fuel/packages/oil/views/default/scaffold/controller.php

    r59 r91  
    1212     
    1313} 
    14  
    15 /* End of file <?php echo $controller_uri; ?>.php */ 
  • trunk/fuel/packages/orm/classes/observer/validation.php

    r87 r91  
    103103        $val = static::set_fields($obj)->validation(); 
    104104 
     105        // only allow partial validation on updates, specify the fields for updates to allow null 
     106        $allow_partial = $obj->is_new() ? false : array(); 
     107 
    105108        $input = array(); 
    106109        foreach (array_keys($obj->properties()) as $p) 
    107110        { 
    108             ! in_array($p, $obj->primary_key()) and $obj->is_changed($p) and $input[$p] = $obj->{$p}; 
     111            if ( ! in_array($p, $obj->primary_key()) and $obj->is_changed($p)) 
     112            { 
     113                $input[$p] = $obj->{$p}; 
     114                is_array($allow_partial) and $allow_partial[] = $p; 
     115            } 
    109116        } 
    110117 
    111         if ( ! empty($input) and $val->run($input, true, array($obj)) === false) 
     118        if ( ! empty($input) and $val->run($input, $allow_partial, array($obj)) === false) 
    112119        { 
    113120            throw new ValidationFailed($val->show_errors()); 
  • trunk/fuel/packages/orm/classes/query.php

    r88 r91  
    6262 
    6363    /** 
    64      * @var  int  max number of returned rows 
     64     * @var  int  max number of returned base model instances 
    6565     */ 
    6666    protected $limit; 
    6767 
    6868    /** 
    69      * @var  int  offset 
     69     * @var  int  offset of base model table 
    7070     */ 
    7171    protected $offset; 
     72 
     73    /** 
     74     * @var  int  max number of requested rows 
     75     */ 
     76    protected $rows_limit; 
     77 
     78    /** 
     79     * @var  int  offset of requested rows 
     80     */ 
     81    protected $rows_offset; 
    7282 
    7383    /** 
     
    146156                    $this->offset($val); 
    147157                    break; 
     158                case 'rows_limit': 
     159                    $this->rows_limit($val); 
     160                    break; 
     161                case 'rows_offset': 
     162                    $this->rows_offset($val); 
     163                    break; 
    148164            } 
    149165        } 
     
    225241    { 
    226242        $this->offset = intval($offset); 
     243 
     244        return $this; 
     245    } 
     246 
     247    /** 
     248     * Set the limit of rows requested 
     249     * 
     250     * @param  int 
     251     */ 
     252    public function rows_limit($limit) 
     253    { 
     254        $this->rows_limit = intval($limit); 
     255 
     256        return $this; 
     257    } 
     258 
     259    /** 
     260     * Set the offset of rows requested 
     261     * 
     262     * @param  int 
     263     */ 
     264    public function rows_offset($offset) 
     265    { 
     266        $this->rows_offset = intval($offset); 
    227267 
    228268        return $this; 
     
    701741        } 
    702742 
     743        // Set the row limit and offset, these are applied to the outer query when a subquery 
     744        // is used or overwrite limit/offset when it's a normal query 
     745        ! is_null($this->rows_limit) and $query->limit($this->rows_limit); 
     746        ! is_null($this->rows_offset) and $query->offset($this->rows_offset); 
     747 
    703748        return array('query' => $query, 'models' => $models); 
    704749    } 
Note: See TracChangeset for help on using the changeset viewer.