Changeset 1842

Show
Ignore:
Timestamp:
01/28/2008 10:02:04 AM (12 months ago)
Author:
Shadowhand
Message:

Quick changes:

  • Updated Kohana::auto_load() to handle the new driver structure
  • Switched driver loading format to handle new driver structure
  • Fixed some formatting issues with Payment drivers (bad JB!)
Location:
trunk/system
Files:
12 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/core/Kohana.php

    r1810 r1842  
    558558         * @throws  Kohana_Exception 
    559559         * @param   string  name of class 
    560          * @return  void 
     560         * @return  bool 
    561561         */ 
    562562        public static function auto_load($class) 
     
    594594                        case 'Driver': 
    595595                                $type = 'libraries/drivers'; 
    596                                 $file = substr($class, 0, -7); 
     596                                $file = str_replace('_', '/', substr($class, 0, -7)); 
    597597                        break; 
    598598                        default: 
     
    607607                // If the file doesn't exist, just return 
    608608                if (($filepath = self::find_file($type, $file)) === FALSE) 
    609                         return; 
     609                        return FALSE; 
    610610 
    611611                // Load the requested file 
     
    626626                        } 
    627627                } 
     628 
     629                return TRUE; 
    628630        } 
    629631 
  • trunk/system/libraries/Archive.php

    r1814 r1842  
    2929                $type = empty($type) ? 'zip' : $type; 
    3030 
    31                 try 
    32                 { 
    33                         // Set driver name 
    34                         $driver = 'Archive_'.ucfirst($type).'_Driver'; 
     31                // Set driver name 
     32                $driver = 'Archive_'.ucfirst($type).'_Driver'; 
    3533 
    36                         // Manually load so that exceptions can be caught 
    37                         require_once Kohana::find_file('libraries/drivers', substr($driver, 0, -7), TRUE); 
    38                 } 
    39                 catch (Kohana_Exception $exception) 
    40                 { 
     34                // Load the driver 
     35                if ( ! Kohana::auto_load($driver)) 
    4136                        throw new Kohana_Exception('archive.driver_not_supported', $type); 
    42                 } 
    4337 
    4438                // Initialize the driver 
  • trunk/system/libraries/Cache.php

    r1814 r1842  
    3434                $this->config = (array) $config + Config::item('cache'); 
    3535 
    36                 try 
    37                 { 
    38                         // Set driver name 
    39                         $driver = 'Cache_'.ucfirst($this->config['driver']).'_Driver'; 
    40  
    41                         // Manually load so that exceptions can be caught 
    42                         require_once Kohana::find_file('libraries/drivers', substr($driver, 0, -7), TRUE); 
    43                 } 
    44                 catch (Kohana_Exception $e) 
    45                 { 
     36                // Set driver name 
     37                $driver = 'Cache_'.ucfirst($this->config['driver']).'_Driver'; 
     38 
     39                // Load the driver 
     40                if ( ! Kohana::auto_load($driver)) 
    4641                        throw new Kohana_Exception('cache.driver_not_supported', $this->config['driver']); 
    47                 } 
    4842 
    4943                // Initialize the driver 
  • trunk/system/libraries/Database.php

    r1836 r1842  
    151151                $this->config['connection'] = $db; 
    152152 
    153                 try 
    154                 { 
    155                         // Set driver name 
    156                         $driver = 'Database_'.ucfirst($this->config['connection']['type']).'_Driver'; 
    157  
    158                         // Manually load so that exceptions can be caught 
    159                         require_once Kohana::find_file('libraries/drivers', substr($driver, 0, -7), TRUE); 
    160                 } 
    161                 catch (Kohana_Exception $e) 
    162                 { 
     153                // Set driver name 
     154                $driver = 'Database_'.ucfirst($this->config['connection']['type']).'_Driver'; 
     155 
     156                // Load the driver 
     157                if ( ! Kohana::auto_load($driver)) 
    163158                        throw new Kohana_Database_Exception('database.driver_not_supported', $this->config['connection']['type']); 
    164                 } 
    165159 
    166160                // Initialize the driver 
  • trunk/system/libraries/Image.php

    r1827 r1842  
    9494                $this->config = (array) $config + Config::item('image'); 
    9595 
    96                 try 
    97                 { 
    98                         // Set driver name 
    99                         $driver = 'Image_'.ucfirst($this->config['driver']).'_Driver'; 
    100  
    101                         // Manually load so that exceptions can be caught 
    102                         require_once Kohana::find_file('libraries/drivers', substr($driver, 0, -7), TRUE); 
    103                 } 
    104                 catch (Kohana_Exception $e) 
    105                 { 
     96                // Set driver class name 
     97                $driver = 'Image_'.ucfirst($this->config['driver']).'_Driver'; 
     98 
     99                // Load the driver 
     100                if ( ! Kohana::auto_load($driver)) 
    106101                        throw new Kohana_Exception('image.driver_not_supported', $this->config['driver']); 
    107                 } 
    108102 
    109103                // Initialize the driver 
  • trunk/system/libraries/Payment.php

    r1814 r1842  
    7878                $this->config = array_merge($this->config, Config::item('payment.'.$this->config['driver'])); 
    7979 
    80                 try 
    81                 { 
    82                         // Set driver name 
    83                         $driver = 'Payment_'.ucfirst($this->config['driver']).'_Driver'; 
     80                // Set driver name 
     81                $driver = 'Payment_'.ucfirst($this->config['driver']).'_Driver'; 
    8482 
    85                         // Manually load so that exceptions can be caught 
    86                         require_once Kohana::find_file('libraries/drivers', substr($driver, 0, -7), TRUE); 
    87                 } 
    88                 catch (Kohana_Exception $e) 
    89                 { 
     83                // Load the driver 
     84                if ( ! Kohana::auto_load($driver)) 
    9085                        throw new Kohana_Exception('payment.driver_not_supported', $this->config['driver']); 
    91                 } 
    9286 
    9387                // Initialize the driver 
  • trunk/system/libraries/Session.php

    r1814 r1842  
    5656                        if (self::$config['driver'] != 'native') 
    5757                        { 
    58                                 try 
    59                                 { 
    60                                         // Set driver name 
    61                                         $driver = 'Session_'.ucfirst(self::$config['driver']).'_Driver'; 
    62  
    63                                         // Manually load so that exceptions can be caught 
    64                                         require_once Kohana::find_file('libraries/drivers', substr($driver, 0, -7), TRUE); 
    65                                 } 
    66                                 catch (Kohana_Exception $e) 
    67                                 { 
     58                                // Set driver name 
     59                                $driver = 'Session_'.ucfirst(self::$config['driver']).'_Driver'; 
     60 
     61                                // Load the driver 
     62                                if ( ! Kohana::auto_load($driver)) 
    6863                                        throw new Kohana_Exception('session.driver_not_supported', self::$config['driver']); 
    69                                 } 
    7064 
    7165                                // Initialize the driver 
  • trunk/system/libraries/drivers/Payment/Authorize.php

    r1841 r1842  
    1212{ 
    1313        // Fields required to do a transaction 
    14         private $required_fields = array('x_login' => FALSE, 
    15                                          'x_version' => TRUE, 
    16                                          'x_delim_char' => TRUE, 
    17                                          'x_url' => TRUE, 
    18                                          'x_type' => TRUE, 
    19                                          'x_method' => TRUE, 
    20                                          'x_tran_key' => FALSE, 
    21                                          'x_relay_response' => TRUE, 
    22                                          'x_card_num' => FALSE, 
    23                                          'x_expiration_date' => FALSE, 
    24                                          'x_amount' => FALSE, 
    25                                          ); 
     14        private $required_fields = array 
     15        ( 
     16                'x_login' => FALSE, 
     17                'x_version' => TRUE, 
     18                'x_delim_char' => TRUE, 
     19                'x_url' => TRUE, 
     20                'x_type' => TRUE, 
     21                'x_method' => TRUE, 
     22                'x_tran_key' => FALSE, 
     23                'x_relay_response' => TRUE, 
     24                'x_card_num' => FALSE, 
     25                'x_expiration_date' => FALSE, 
     26                'x_amount' => FALSE, 
     27        ); 
     28 
    2629        // Default required values 
    2730        private $authnet_values = array 
  • trunk/system/libraries/drivers/Payment/Paypal.php

    r1841 r1842  
    1616class Payment_Paypal_Driver { 
    1717 
    18         private $required_fields = array('API_UserName'  => FALSE, 
    19                                          'API_Password'  => FALSE, 
    20                                          'API_Signature' => FALSE, 
    21                                          'API_Endpoint'  => TRUE, 
    22                                          'version'       => TRUE, 
    23                                          'Amt'           => FALSE, 
    24                                          'PAYMENTACTION' => TRUE, 
    25                                          'ReturnUrl'     => FALSE, 
    26                                          'CANCELURL'     => FALSE, 
    27                                          'CURRENCYCODE'  => TRUE); 
    28  
    29         private $paypal_values = array('API_UserName'  => '', 
    30                                        'API_Password'  => '', 
    31                                        'API_Signature' => '', 
    32                                        'API_Endpoint'  => 'https://api-3t.paypal.com/nvp', 
    33                                        'version'       => '3.0', 
    34                                        'Amt'           => 0, 
    35                                        'PAYMENTACTION' => 'Sale', 
    36                                        'ReturnUrl'     => '', 
    37                                        'CANCELURL'     => '', 
    38                                        'error_url'     => '', 
    39                                        'CURRENCYCODE'  => 'USD', 
    40                                        'payerid'       => ''); 
     18        private $required_fields = array 
     19        ( 
     20                'API_UserName'  => FALSE, 
     21                'API_Password'  => FALSE, 
     22                'API_Signature' => FALSE, 
     23                'API_Endpoint'  => TRUE, 
     24                'version'       => TRUE, 
     25                'Amt'           => FALSE, 
     26                'PAYMENTACTION' => TRUE, 
     27                'ReturnUrl'     => FALSE, 
     28                'CANCELURL'     => FALSE, 
     29                'CURRENCYCODE'  => TRUE 
     30        ); 
     31 
     32        private $paypal_values = array 
     33        ( 
     34                'API_UserName'  => '', 
     35                'API_Password'  => '', 
     36                'API_Signature' => '', 
     37                'API_Endpoint'  => 'https://api-3t.paypal.com/nvp', 
     38                'version'       => '3.0', 
     39                'Amt'           => 0, 
     40                'PAYMENTACTION' => 'Sale', 
     41                'ReturnUrl'     => '', 
     42                'CANCELURL'     => '', 
     43                'error_url'     => '', 
     44                'CURRENCYCODE'  => 'USD', 
     45                'payerid'       => '' 
     46        ); 
    4147 
    4248        private $paypal_url = ''; 
  • trunk/system/libraries/drivers/Payment/Trident.php

    r1841 r1842  
    1212{ 
    1313        // Fields required to do a transaction 
    14         private $required_fields = array('profile_id'         => FALSE, 
    15                                          'profile_key'        => FALSE, 
    16                                          'card_number'        => FALSE, 
    17                                          'card_exp_date'      => FALSE, 
    18                                          'transaction_amount' => FALSE, 
    19                                          'transaction_type'   => FALSE); 
     14        private $required_fields = array 
     15        ( 
     16                'profile_id'         => FALSE, 
     17                'profile_key'        => FALSE, 
     18                'card_number'        => FALSE, 
     19                'card_exp_date'      => FALSE, 
     20                'transaction_amount' => FALSE, 
     21                'transaction_type'   => FALSE 
     22        ); 
    2023 
    21         private $fields = array('profile_id'         => '', 
    22                                 'profile_key'        => '', 
    23                                 'card_number'        => '', 
    24                                 'card_exp_date'      => '', 
    25                                 'transaction_amount' => '', 
    26                                 'transaction_type'   => ''); 
     24        private $fields = array 
     25        ( 
     26                'profile_id'         => '', 
     27                'profile_key'        => '', 
     28                'card_number'        => '', 
     29                'card_exp_date'      => '', 
     30                'transaction_amount' => '', 
     31                'transaction_type'   => '' 
     32        ); 
    2733 
    2834        private $test_mode = TRUE; 
  • trunk/system/libraries/drivers/Payment/Trustcommerce.php

    r1841 r1842  
    1212{ 
    1313        // Fields required to do a transaction 
    14         private $required_fields = array('custid' => TRUE, 
    15                                          'password' => TRUE, 
    16                                          'action' => TRUE, 
    17                                          'media' => TRUE, 
    18                                          'cc' => FALSE, 
    19                                          'exp' => FALSE, 
    20                                          'amount' => FALSE 
    21                                          ); 
     14        private $required_fields = array 
     15        ( 
     16                'custid' => TRUE, 
     17                'password' => TRUE, 
     18                'action' => TRUE, 
     19                'media' => TRUE, 
     20                'cc' => FALSE, 
     21                'exp' => FALSE, 
     22                'amount' => FALSE 
     23        ); 
    2224 
    2325        private $tclink_library = './path/to/library'; 
  • trunk/system/libraries/drivers/Payment/Yourpay.php

    r1841 r1842  
    1212{ 
    1313        // Fields required to do a transaction 
    14         private $required_fields = array('card_num' => FALSE, 
    15                                          'expiration_date' => FALSE, 
    16                                          'amount' => FALSE, 
    17                                          'tax' => FALSE, 
    18                                          'shipping' => FALSE, 
    19                                          'cvm_value' => FALSE 
    20                                          ); 
     14        private $required_fields = array 
     15        ( 
     16                'card_num' => FALSE, 
     17                'expiration_date' => FALSE, 
     18                'amount' => FALSE, 
     19                'tax' => FALSE, 
     20                'shipping' => FALSE, 
     21                'cvm_value' => FALSE 
     22        ); 
     23 
    2124        // Default required values 
    2225        private $fields = array