[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZExchangeRatesUpdateHandler class 4 // 5 // Created on: <12-Mar-2006 13:06:15 dl> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezexchangeratesupdatehandler.php 30 */ 31 32 define( 'EZ_EXCHANGE_RATES_HANDLER_OK', 0 ); 33 define( 'EZ_EXCHANGE_RATES_HANDLER_CANT_CREATE_HANDLER', 1 ); 34 define( 'EZ_EXCHANGE_RATES_HANDLER_REQUEST_RATES_FAILED', 2 ); 35 define( 'EZ_EXCHANGE_RATES_HANDLER_EMPTY_RATE_LIST', 3 ); 36 define( 'EZ_EXCHANGE_RATES_HANDLER_UNKNOWN_BASE_CURRENCY', 4 ); 37 define( 'EZ_EXCHANGE_RATES_HANDLER_INVALID_BASE_CROSS_RATE', 5 ); 38 39 class eZExchangeRatesUpdateHandler 40 { 41 function eZExchangeRatesUpdateHandler() 42 { 43 $this->RateList = false; 44 $this->BaseCurrency = false; 45 46 $this->initialize(); 47 } 48 49 function initialize( $params = array() ) 50 { 51 if ( !isset( $params['BaseCurrency'] ) ) 52 $params['BaseCurrency'] = ''; 53 54 $this->setBaseCurrency( $params['BaseCurrency'] ); 55 } 56 57 /*! 58 \static 59 */ 60 function create( $handlerName = false ) 61 { 62 include_once ( 'lib/ezutils/classes/ezini.php' ); 63 64 $shopINI =& eZINI::instance( 'shop.ini' ); 65 if ( $handlerName === false) 66 { 67 if ( $shopINI->hasVariable( 'ExchangeRatesSettings', 'ExchangeRatesUpdateHandler' ) ) 68 $handlerName = $shopINI->variable( 'ExchangeRatesSettings', 'ExchangeRatesUpdateHandler' ); 69 } 70 71 $handlerName = strtolower( $handlerName ); 72 73 $dirList = array(); 74 $repositoryDirectories = $shopINI->variable( 'ExchangeRatesSettings', 'RepositoryDirectories' ); 75 $extensionDirectories = $shopINI->variable( 'ExchangeRatesSettings', 'ExtensionDirectories' ); 76 77 $baseDirectory = eZExtension::baseDirectory(); 78 foreach ( $extensionDirectories as $extensionDirectory ) 79 { 80 if ( !empty( $extensionDirectory ) ) 81 $dirList[] = $baseDirectory . '/' . $extensionDirectory . '/exchangeratehandlers'; 82 } 83 84 foreach ( $repositoryDirectories as $repositoryDirectory ) 85 { 86 if ( !empty( $repositoryDirectory ) ) 87 $dirList[] = $repositoryDirectory; 88 } 89 90 $foundHandler = false; 91 foreach ( $dirList as $dir ) 92 { 93 $includeFile = "$dir/$handlerName/{$handlerName}handler.php"; 94 95 if ( file_exists( $includeFile ) ) 96 { 97 $foundHandler = true; 98 break; 99 } 100 } 101 102 if ( !$foundHandler ) 103 { 104 eZDebug::writeError( "Exchange rates update handler '$handlerName' not found, " . 105 "searched in these directories: " . 106 implode( ', ', $dirList ), 107 'eZExchangeRatesUpdateHandler::create' ); 108 return false; 109 } 110 111 require_once( $includeFile ); 112 $className = $handlerName . 'handler'; 113 return new $className; 114 } 115 116 function rateList() 117 { 118 return $this->RateList; 119 } 120 121 function setRateList( &$rateList ) 122 { 123 $this->RateList = $rateList; 124 } 125 126 function baseCurrency() 127 { 128 return $this->BaseCurrency; 129 } 130 131 function setBaseCurrency( $baseCurrency ) 132 { 133 $this->BaseCurrency = $baseCurrency; 134 } 135 136 function requestRates() 137 { 138 $error = array( 'code' => EZ_EXCHANGE_RATES_HANDLER_REQUEST_RATES_FAILED, 139 'description' => ezi18n( 'kernel/shop', "eZExchangeRatesUpdateHandler: you should reimplement 'requestRates' method" ) ); 140 141 return $error; 142 } 143 144 var $RateList; 145 var $BaseCurrency; 146 } 147 148 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |