本文整理匯總了PHP中CurrencyDisplay::_instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP CurrencyDisplay::_instance方法的具體用法?PHP CurrencyDisplay::_instance怎麽用?PHP CurrencyDisplay::_instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CurrencyDisplay
的用法示例。
在下文中一共展示了CurrencyDisplay::_instance方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getInstance
/**
*
* Gives back the format of the currency, gets $style if none is set, with the currency Id, when nothing is found it tries the vendorId.
* When no param is set, you get the format of the mainvendor
*
* @author Max Milbers
* @param int $currencyId Id of the currency
* @param int $vendorId Id of the vendor
* @param string $style The vendor_currency_display_code
* FORMAT:
1: id,
2: CurrencySymbol,
3: NumberOfDecimalsAfterDecimalSymbol,
4: DecimalSymbol,
5: Thousands separator
6: Currency symbol position with Positive values :
7: Currency symbol position with Negative values :
EXAMPLE: ||€|2|,||1|8
* @return string
*/
public static function getInstance($currencyId = 0, $vendorId = 0)
{
// vmdebug('hmmmmm getInstance given $currencyId '.$currencyId,self::$_instance->_currency_id);
// if(empty(self::$_instance) || empty(self::$_instance->_currency_id) || ($currencyId!=self::$_instance->_currency_id && !empty($currencyId)) ){
if (empty(self::$_instance) || (!empty($currencyId) and $currencyId != self::$_instance->_currency_id)) {
self::$_instance = new CurrencyDisplay($vendorId);
if (empty($currencyId)) {
if (self::$_instance->_app->isSite()) {
self::$_instance->_currency_id = self::$_instance->_app->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id', 0));
}
if (empty(self::$_instance->_currency_id)) {
self::$_instance->_currency_id = self::$_instance->_vendorCurrency;
}
} else {
self::$_instance->_currency_id = $currencyId;
}
$q = 'SELECT * FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . (int) self::$_instance->_currency_id . '"';
self::$_instance->_db->setQuery($q);
$style = self::$_instance->_db->loadObject();
if (!empty($style)) {
self::$_instance->setCurrencyDisplayToStyleStr($style);
} else {
$uri = JFactory::getURI();
if (empty(self::$_instance->_currency_id)) {
$link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=user&task=editshop';
JError::raiseWarning('1', JText::sprintf('COM_VIRTUEMART_CONF_WARN_NO_CURRENCY_DEFINED', '<a href="' . $link . '">' . $link . '</a>'));
} else {
if (JRequest::getWord('view') != 'currency') {
$link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=currency&task=edit&cid[]=' . self::$_instance->_currency_id;
JError::raiseWarning('1', JText::sprintf('COM_VIRTUEMART_CONF_WARN_NO_FORMAT_DEFINED', '<a href="' . $link . '">' . $link . '</a>'));
}
}
// self::$_instance->setCurrencyDisplayToStyleStr($currencyId);
//would be nice to automatically unpublish the product/currency or so
}
}
self::$_instance->setPriceArray();
return self::$_instance;
}
示例2: getInstance
/**
*
* Gives back the format of the currency, gets $style if none is set, with the currency Id, when nothing is found it tries the vendorId.
* When no param is set, you get the format of the mainvendor
*
* @author Max Milbers
* @param int $currencyId Id of the currency
* @param int $vendorId Id of the vendor
* @param string $style The vendor_currency_display_code
* FORMAT:
1: id,
2: CurrencySymbol,
3: NumberOfDecimalsAfterDecimalSymbol,
4: DecimalSymbol,
5: Thousands separator
6: Currency symbol position with Positive values :
7: Currency symbol position with Negative values :
EXAMPLE: ||€|2|,||1|8
* @return string
*/
public static function getInstance($currencyId = 0, $vendorId = 0)
{
// if(empty(self::$_instance) || empty(self::$_instance->_currency_id) || ($currencyId!=self::$_instance->_currency_id && !empty($currencyId)) ){
if (empty(self::$_instance) || (!empty($currencyId) and $currencyId != self::$_instance->_currency_id)) {
self::$_instance = new CurrencyDisplay($vendorId);
if (empty($currencyId)) {
if (self::$_instance->_app->isSite()) {
self::$_instance->_currency_id = self::$_instance->_app->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', vRequest::getInt('virtuemart_currency_id', 0));
}
if (empty(self::$_instance->_currency_id)) {
self::$_instance->_currency_id = self::$_instance->_vendorCurrency;
}
} else {
self::$_instance->_currency_id = $currencyId;
}
$vendorM = VmModel::getModel('currency');
$style = $vendorM->getData((int) self::$_instance->_currency_id);
if (!empty($style)) {
self::$_instance->setCurrencyDisplayToStyleStr($style);
} else {
$uri = JFactory::getURI();
VmConfig::loadJLang('com_virtuemart');
if (empty(self::$_instance->_currency_id)) {
$link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=user&task=editshop';
vmWarn(vmText::sprintf('COM_VIRTUEMART_CONF_WARN_NO_CURRENCY_DEFINED', '<a href="' . $link . '">' . $link . '</a>'));
} else {
if (vRequest::getCmd('view') != 'currency') {
$link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=currency&task=edit&cid[]=' . self::$_instance->_currency_id;
vmWarn(vmText::sprintf('COM_VIRTUEMART_CONF_WARN_NO_FORMAT_DEFINED', '<a href="' . $link . '">' . $link . '</a>'));
}
}
// self::$_instance->setCurrencyDisplayToStyleStr($currencyId);
//would be nice to automatically unpublish the product/currency or so
}
}
self::$_instance->setPriceArray();
return self::$_instance;
}