本文整理汇总了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;
}