Beispiel #1
0
 /**
 *
 * 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;
 }
Beispiel #2
0
 /**
 *
 * 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: ||&euro;|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;
 }