本文整理汇总了PHP中eZCurrencyData::fetchList方法的典型用法代码示例。如果您正苦于以下问题:PHP eZCurrencyData::fetchList方法的具体用法?PHP eZCurrencyData::fetchList怎么用?PHP eZCurrencyData::fetchList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZCurrencyData
的用法示例。
在下文中一共展示了eZCurrencyData::fetchList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
static function fetch($currencyCode, $asObject = true)
{
if ($currencyCode) {
$currency = eZCurrencyData::fetchList(array('code' => $currencyCode), $asObject);
if (is_array($currency) && count($currency) > 0) {
return $currency[$currencyCode];
}
}
return null;
}
示例2: updateAutoRates
static function updateAutoRates()
{
$error = array('code' => eZExchangeRatesUpdateHandler::OK, 'description' => '');
$handler = eZExchangeRatesUpdateHandler::create();
if ($handler) {
$error = $handler->requestRates();
if ($error['code'] === eZExchangeRatesUpdateHandler::OK) {
$rateList = $handler->rateList();
if (is_array($rateList) && count($rateList) > 0) {
$handlerBaseCurrency = $handler->baseCurrency();
if ($handlerBaseCurrency) {
$shopBaseCurrency = false;
$shopINI = eZINI::instance('shop.ini');
if ($shopINI->hasVariable('ExchangeRatesSettings', 'BaseCurrency')) {
$shopBaseCurrency = $shopINI->variable('ExchangeRatesSettings', 'BaseCurrency');
}
if (!$shopBaseCurrency) {
$shopBaseCurrency = $handlerBaseCurrency;
}
// update rates for existing currencies
//$baseCurrencyCode = $handler->baseCurrency();
if (isset($rateList[$shopBaseCurrency]) || $shopBaseCurrency === $handlerBaseCurrency) {
// to avoid unnecessary multiplication set $crossBaseRate to 'false';
$crossBaseRate = false;
if ($shopBaseCurrency !== $handlerBaseCurrency) {
$crossBaseRate = 1.0 / (double) $rateList[$shopBaseCurrency];
$rateList[$handlerBaseCurrency] = '1.0000';
}
$currencyList = eZCurrencyData::fetchList();
if (is_array($currencyList) && count($currencyList) > 0) {
foreach ($currencyList as $currency) {
$rateValue = false;
$currencyCode = $currency->attribute('code');
if (isset($rateList[$currencyCode])) {
$rateValue = $rateList[$currencyCode];
if ($crossBaseRate !== false) {
$rateValue *= $crossBaseRate;
}
} else {
if ($currencyCode === $shopBaseCurrency) {
$rateValue = '1.0000';
}
}
$currency->setAttribute('auto_rate_value', $rateValue);
$currency->sync();
}
}
$error['code'] = eZExchangeRatesUpdateHandler::OK;
$error['description'] = ezpI18n::tr('kernel/shop', "'Auto' rates were updated successfully.");
} else {
$error['code'] = eZExchangeRatesUpdateHandler::INVALID_BASE_CROSS_RATE;
$error['description'] = ezpI18n::tr('kernel/shop', "Unable to calculate cross-rate for currency-pair '%1'/'%2'", null, array($handlerBaseCurrency, $shopBaseCurrency));
}
} else {
$error['code'] = eZExchangeRatesUpdateHandler::UNKNOWN_BASE_CURRENCY;
$error['description'] = ezpI18n::tr('kernel/shop', 'Unable to determine currency for retrieved rates.');
}
} else {
$error['code'] = eZExchangeRatesUpdateHandler::EMPTY_RATE_LIST;
$error['description'] = ezpI18n::tr('kernel/shop', 'Retrieved empty list of rates.');
}
}
} else {
$error['code'] = eZExchangeRatesUpdateHandler::CANT_CREATE_HANDLER;
$error['description'] = ezpI18n::tr('kernel/shop', 'Unable to create handler to update auto rates.');
}
if ($error['code'] !== eZExchangeRatesUpdateHandler::OK) {
eZDebug::writeError($error['description'], __METHOD__);
}
return $error;
}
示例3: currencyList
function currencyList()
{
if ( !isset( $this->CurrencyList ) )
{
$this->CurrencyList = eZCurrencyData::fetchList();
}
return $this->CurrencyList;
}
示例4: fetchCurrencyList
function fetchCurrencyList( $status = false )
{
$conditions = null;
$status = eZCurrencyData::statusStringToNumeric( $status );
if ( $status !== false )
{
$conditions = array( 'status' => $status );
}
$currencyList = eZCurrencyData::fetchList( $conditions );
$result = array( 'result' => $currencyList );
return $result;
}
示例5: switch
if ($error['code'] != 0) {
$error['style'] = 'message-error';
} else {
$error['style'] = 'message-feedback';
}
}
switch (eZPreferences::value('currencies_list_limit')) {
case '2':
$limit = 25;
break;
case '3':
$limit = 50;
break;
default:
$limit = 10;
break;
}
// fetch currencies
$currencyList = eZCurrencyData::fetchList(null, true, $offset, $limit);
$currencyCount = eZCurrencyData::fetchListCount();
$viewParameters = array('offset' => $offset);
$tpl = eZTemplate::factory();
$tpl->setVariable('currency_list', $currencyList);
$tpl->setVariable('currency_list_count', $currencyCount);
$tpl->setVariable('limit', $limit);
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('show_error_message', $error !== false);
$tpl->setVariable('error', $error);
$Result = array();
$Result['path'] = array(array('text' => ezpI18n::tr('kernel/shop', 'Available currency list'), 'url' => false));
$Result['content'] = $tpl->fetch("design:shop/currencylist.tpl");
示例6: currencyForLocale
function currencyForLocale($localeString = false)
{
global $cli;
global $currencyList;
$currency = false;
if ($currencyList === false) {
$currencyList = eZCurrencyData::fetchList();
}
$locale = eZLocale::instance($localeString);
if (is_object($locale)) {
// get currency
if ($currencyCode = $locale->currencyShortName()) {
if (!isset($currencyList[$currencyCode])) {
$cli->warning("Currency '{$currencyCode}' doesn't exist");
$cli->notice("Creating currency '{$currencyCode}'... ", false);
$currencySymbol = $locale->currencySymbol();
$localeCode = $locale->localeFullCode();
if ($currency = eZCurrencyData::create($currencyCode, $currencySymbol, $localeCode, '0.00000', '1.00000', '0.00000')) {
$cli->output('Ok');
$currency->store();
$currencyList[$currencyCode] = $currency;
} else {
$cli->error('Failed');
}
} else {
$currency = $currencyList[$currencyCode];
}
} else {
$cli->error("Unable to find currency code for the '{$localeString}' locale");
}
} else {
$cli->error("Unable to find '{$localeString}' locale");
}
return $currency;
}