Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorsgiehl <stefan@piwik.org>2015-10-15 22:06:48 +0300
committersgiehl <stefan@piwik.org>2015-10-15 23:26:38 +0300
commitccefdb1d5451133709edcc468577de39a343c00a (patch)
tree49053827ef60f141f5dd262d76d4180425ed22e4 /core
parent5b64e37e82cab28cac0998910dccefd73668400e (diff)
use number format for currency in all websites dashboard
Diffstat (limited to 'core')
-rw-r--r--core/Metrics.php2
-rw-r--r--core/Metrics/Formatter.php38
-rw-r--r--core/MetricsFormatter.php4
-rw-r--r--core/NumberFormatter.php2
-rw-r--r--core/Singleton.php2
-rw-r--r--core/Site.php38
-rwxr-xr-xcore/Twig.php2
7 files changed, 46 insertions, 42 deletions
diff --git a/core/Metrics.php b/core/Metrics.php
index ffaa26a4a3..50cd33c032 100644
--- a/core/Metrics.php
+++ b/core/Metrics.php
@@ -238,7 +238,7 @@ class Metrics
{
$nameToUnit = array(
'_rate' => '%',
- 'revenue' => Formatter::getCurrencySymbol($idSite),
+ 'revenue' => Site::getCurrencySymbolFor($idSite),
'_time_' => 's'
);
diff --git a/core/Metrics/Formatter.php b/core/Metrics/Formatter.php
index 8fbe5cbb89..077646ba00 100644
--- a/core/Metrics/Formatter.php
+++ b/core/Metrics/Formatter.php
@@ -150,7 +150,7 @@ class Formatter
public function getPrettyMoney($value, $idSite)
{
$space = ' ';
- $currencySymbol = self::getCurrencySymbol($idSite);
+ $currencySymbol = Site::getCurrencySymbolFor($idSite);
$currencyBefore = $currencySymbol . $space;
$currencyAfter = '';
// (maybe more currencies prefer this notation?)
@@ -190,42 +190,6 @@ class Formatter
}
/**
- * Returns the currency symbol for a site.
- *
- * @param int $idSite The ID of the site to return the currency symbol for.
- * @return string eg, `'$'`.
- * @api
- */
- public static function getCurrencySymbol($idSite)
- {
- $symbols = self::getCurrencyList();
- $currency = Site::getCurrencyFor($idSite);
-
- if (isset($symbols[$currency])) {
- return $symbols[$currency][0];
- }
-
- return '';
- }
-
- /**
- * Returns the list of all known currency symbols.
- *
- * @return array An array mapping currency codes to their respective currency symbols
- * and a description, eg, `array('USD' => array('$', 'US dollar'))`.
- *
- * @deprecated Use Piwik\Intl\Data\Provider\CurrencyDataProvider instead.
- * @see \Piwik\Intl\Data\Provider\CurrencyDataProvider::getCurrencyList()
- * @api
- */
- public static function getCurrencyList()
- {
- /** @var CurrencyDataProvider $dataProvider */
- $dataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\CurrencyDataProvider');
- return $dataProvider->getCurrencyList();
- }
-
- /**
* Formats all metrics, including processed metrics, for a DataTable. Metrics to format
* are found through report metadata and DataTable metadata.
*
diff --git a/core/MetricsFormatter.php b/core/MetricsFormatter.php
index daa8710fc6..0bf5a1a735 100644
--- a/core/MetricsFormatter.php
+++ b/core/MetricsFormatter.php
@@ -62,11 +62,11 @@ class MetricsFormatter
public static function getCurrencySymbol($idSite)
{
- return Formatter::getCurrencySymbol($idSite);
+ return Site::getCurrencySymbolFor($idSite);
}
public static function getCurrencyList()
{
- return Formatter::getCurrencyList();
+ return Site::getCurrencyList();
}
}
diff --git a/core/NumberFormatter.php b/core/NumberFormatter.php
index ad030400f4..de2f5157ce 100644
--- a/core/NumberFormatter.php
+++ b/core/NumberFormatter.php
@@ -50,6 +50,8 @@ class NumberFormatter extends Singleton
/**
* Loads all required data from Intl plugin
+ *
+ * @return NumberFormatter
*/
public function __construct()
{
diff --git a/core/Singleton.php b/core/Singleton.php
index cde63cb744..46e3c531d7 100644
--- a/core/Singleton.php
+++ b/core/Singleton.php
@@ -32,7 +32,7 @@ class Singleton
* Returns the singleton instance for the derived class. If the singleton instance
* has not been created, this method will create it.
*
- * @return Singleton
+ * @return static
*/
public static function getInstance()
{
diff --git a/core/Site.php b/core/Site.php
index a975268ad1..3bc535fc2d 100644
--- a/core/Site.php
+++ b/core/Site.php
@@ -10,7 +10,9 @@
namespace Piwik;
use Exception;
+use Piwik\Container\StaticContainer;
use Piwik\Exception\UnexpectedWebsiteFoundException;
+use Piwik\Intl\Data\Provider\CurrencyDataProvider;
use Piwik\Plugins\SitesManager\API;
/**
@@ -559,6 +561,42 @@ class Site
}
/**
+ * Returns the currency of the site with the specified ID.
+ *
+ * @param int $idsite The site ID.
+ * @return string
+ */
+ public static function getCurrencySymbolFor($idsite)
+ {
+ $currency = self::getCurrencyFor($idsite);
+ $symbols = self::getCurrencyList();
+
+ if (isset($symbols[$currency])) {
+ return $symbols[$currency][0];
+ }
+
+ return '';
+ }
+
+
+ /**
+ * Returns the list of all known currency symbols.
+ *
+ * @return array An array mapping currency codes to their respective currency symbols
+ * and a description, eg, `array('USD' => array('$', 'US dollar'))`.
+ *
+ * @deprecated Use Piwik\Intl\Data\Provider\CurrencyDataProvider instead.
+ * @see \Piwik\Intl\Data\Provider\CurrencyDataProvider::getCurrencyList()
+ * @api
+ */
+ public static function getCurrencyList()
+ {
+ /** @var CurrencyDataProvider $dataProvider */
+ $dataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\CurrencyDataProvider');
+ return $dataProvider->getCurrencyList();
+ }
+
+ /**
* Returns the excluded IP addresses of the site with the specified ID.
*
* @param int $idsite The site ID.
diff --git a/core/Twig.php b/core/Twig.php
index c806dcf9bb..63733a852a 100755
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -331,7 +331,7 @@ class Twig
}
$idSite = func_get_args();
$idSite = $idSite[1];
- $currencySymbol = Formatter::getCurrencySymbol($idSite);
+ $currencySymbol = Site::getCurrencySymbolFor($idSite);
return NumberFormatter::getInstance()->formatCurrency($amount, $currencySymbol, GoalManager::REVENUE_PRECISION);
});
$this->twig->addFilter($moneyFilter);