当前位置: 首页>>代码示例>>PHP>>正文


PHP Site::getCurrencySymbolFor方法代码示例

本文整理汇总了PHP中Piwik\Site::getCurrencySymbolFor方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::getCurrencySymbolFor方法的具体用法?PHP Site::getCurrencySymbolFor怎么用?PHP Site::getCurrencySymbolFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\Site的用法示例。


在下文中一共展示了Site::getCurrencySymbolFor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPrettyMoney

 /**
  * Returns a pretty formated monetary value using the currency associated with a site.
  *
  * @param int|string $value The monetary value to format.
  * @param int $idSite The ID of the site whose currency will be used.
  * @return string
  * @api
  */
 public function getPrettyMoney($value, $idSite)
 {
     $space = ' ';
     $currencySymbol = Site::getCurrencySymbolFor($idSite);
     $currencyBefore = $currencySymbol . $space;
     $currencyAfter = '';
     // (maybe more currencies prefer this notation?)
     $currencySymbolToAppend = array('€', 'kr', 'zł');
     // manually put the currency symbol after the amount
     if (in_array($currencySymbol, $currencySymbolToAppend)) {
         $currencyAfter = $space . $currencySymbol;
         $currencyBefore = '';
     }
     // if the input is a number (it could be a string or INPUT form),
     // and if this number is not an int, we round to precision 2
     if (is_numeric($value)) {
         if ($value == round($value)) {
             // 0.0 => 0
             $value = round($value);
         } else {
             $precision = GoalManager::REVENUE_PRECISION;
             $value = sprintf("%01." . $precision . "f", $value);
         }
     }
     $prettyMoney = $currencyBefore . $value . $currencyAfter;
     return $prettyMoney;
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:35,代码来源:Formatter.php

示例2: getCurrencySymbol

 public static function getCurrencySymbol($idSite)
 {
     return Site::getCurrencySymbolFor($idSite);
 }
开发者ID:cemo,项目名称:piwik,代码行数:4,代码来源:MetricsFormatter.php

示例3: formatMetrics

 private function formatMetrics(&$metrics)
 {
     $formatter = NumberFormatter::getInstance();
     foreach ($metrics as $metricName => &$value) {
         if (in_array($metricName, $this->displayedMetricColumns)) {
             if (strpos($metricName, 'revenue') !== false) {
                 $currency = isset($metrics['idsite']) ? Site::getCurrencySymbolFor($metrics['idsite']) : '';
                 $value = $formatter->formatCurrency($value, $currency);
                 continue;
             }
             $value = $formatter->format($value);
         }
     }
 }
开发者ID:piwik,项目名称:piwik,代码行数:14,代码来源:Dashboard.php

示例4: getUnit

 /**
  * Derive the unit name from a column name
  * @param $column
  * @param $idSite
  * @return string
  * @ignore
  */
 public static function getUnit($column, $idSite)
 {
     $nameToUnit = array('_rate' => '%', 'revenue' => Site::getCurrencySymbolFor($idSite), '_time_' => 's');
     foreach ($nameToUnit as $pattern => $type) {
         if (strpos($column, $pattern) !== false) {
             return $type;
         }
     }
     return '';
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:17,代码来源:Metrics.php

示例5: piwik_format_money

function piwik_format_money($amount, $idSite)
{
    $currencySymbol = Site::getCurrencySymbolFor($idSite);
    $numberFormatter = NumberFormatter::getInstance();
    return $numberFormatter->formatCurrency($amount, $currencySymbol, GoalManager::REVENUE_PRECISION);
}
开发者ID:diosmosis,项目名称:piwik,代码行数:6,代码来源:Twig.php

示例6: addFilter_money

 protected function addFilter_money()
 {
     $formatter = $this->formatter;
     $moneyFilter = new Twig_SimpleFilter('money', function ($amount) use($formatter) {
         if (func_num_args() != 2) {
             throw new Exception('the money modifier expects one parameter: the idSite.');
         }
         $idSite = func_get_args();
         $idSite = $idSite[1];
         $currencySymbol = Site::getCurrencySymbolFor($idSite);
         return NumberFormatter::getInstance()->formatCurrency($amount, $currencySymbol, GoalManager::REVENUE_PRECISION);
     });
     $this->twig->addFilter($moneyFilter);
 }
开发者ID:nagyadam2092,项目名称:piwik,代码行数:14,代码来源:Twig.php

示例7: configureView

 public function configureView(ViewDataTable $view)
 {
     $idGoal = Common::getRequestVar('idGoal', 0, 'string');
     $idSite = $this->getIdSite();
     if ($view->isViewDataTableId(Sparklines::ID)) {
         /** @var Sparklines $view */
         $isEcommerceEnabled = $this->isEcommerceEnabled($idSite);
         $onlySummary = Common::getRequestVar('only_summary', 0, 'int');
         if ($onlySummary && !empty($idGoal)) {
             if (is_numeric($idGoal)) {
                 $view->config->title_attributes = array('piwik-goal-page-link' => $idGoal);
             }
             // in Goals overview summary we show proper title for a goal
             $goal = $this->getGoal($idGoal);
             if (!empty($goal['name'])) {
                 $view->config->title = Piwik::translate('Goals_GoalX', "'" . $goal['name'] . "'");
             }
         } else {
             $view->config->title = '';
         }
         $numberFormatter = NumberFormatter::getInstance();
         $view->config->filters[] = function (DataTable $table) use($numberFormatter, $idSite) {
             $firstRow = $table->getFirstRow();
             if ($firstRow) {
                 $revenue = $firstRow->getColumn('revenue');
                 $currencySymbol = Site::getCurrencySymbolFor($idSite);
                 $revenue = $numberFormatter->formatCurrency($revenue, $currencySymbol, GoalManager::REVENUE_PRECISION);
                 $firstRow->setColumn('revenue', $revenue);
                 $conversionRate = $firstRow->getColumn('conversion_rate');
                 if (false !== $conversionRate) {
                     $firstRow->setColumn('conversion_rate', $numberFormatter->formatPercent($conversionRate, $precision = 1));
                 }
                 $conversions = $firstRow->getColumn('nb_conversions');
                 if (false !== $conversions) {
                     $firstRow->setColumn('nb_conversions', $numberFormatter->formatNumber($conversions));
                 }
                 $visitsConverted = $firstRow->getColumn('nb_visits_converted');
                 if (false !== $visitsConverted) {
                     $firstRow->setColumn('nb_visits_converted', $numberFormatter->formatNumber($visitsConverted));
                 }
             }
         };
         $view->config->addTranslations(array('nb_visits' => Piwik::translate('VisitsSummary_NbVisitsDescription'), 'nb_conversions' => Piwik::translate('Goals_ConversionsDescription'), 'nb_visits_converted' => Piwik::translate('General_NVisits'), 'conversion_rate' => Piwik::translate('Goals_OverallConversionRate'), 'revenue' => Piwik::translate('Goals_OverallRevenue')));
         $allowMultiple = Common::getRequestVar('allow_multiple', 0, 'int');
         if ($allowMultiple) {
             $view->config->addSparklineMetric(array('nb_conversions', 'nb_visits_converted'), $order = 10);
         } else {
             $view->config->addSparklineMetric(array('nb_conversions'), $order = 10);
         }
         $view->config->addSparklineMetric(array('conversion_rate'), $order = 20);
         if (empty($idGoal)) {
             // goals overview sparklines below evolution graph
             if ($isEcommerceEnabled) {
                 // this would be ideally done in Ecommerce plugin but then it is hard to keep same order
                 $view->config->addSparklineMetric(array('revenue'), $order = 30);
             }
         } else {
             if ($onlySummary) {
                 // in Goals Overview we list an overview for each goal....
                 $view->config->addTranslation('conversion_rate', Piwik::translate('Goals_ConversionRate'));
             } elseif ($isEcommerceEnabled) {
                 // in Goals detail page...
                 $view->config->addSparklineMetric(array('revenue'), $order = 30);
             }
         }
     } else {
         if ($view->isViewDataTableId(Evolution::ID)) {
             if (!empty($idSite) && Piwik::isUserHasAdminAccess($idSite)) {
                 $view->config->title_edit_entity_url = 'index.php' . Url::getCurrentQueryStringWithParametersModified(array('module' => 'Goals', 'action' => 'manage', 'forceView' => null, 'viewDataTable' => null, 'showtitle' => null, 'random' => null));
             }
             $goal = $this->getGoal($idGoal);
             if (!empty($goal['name'])) {
                 $view->config->title = Piwik::translate('Goals_GoalX', "'" . $goal['name'] . "'");
                 if (!empty($goal['description'])) {
                     $view->config->description = $goal['description'];
                 }
             } else {
                 $view->config->title = Piwik::translate('General_EvolutionOverPeriod');
             }
             if (empty($view->config->columns_to_display)) {
                 $view->config->columns_to_display = array('nb_conversions');
             }
         }
     }
 }
开发者ID:piwik,项目名称:piwik,代码行数:85,代码来源:Get.php

示例8: trackingCodeGenerator

 /**
  * Renders and echo's an admin page that lets users generate custom JavaScript
  * tracking code and custom image tracker links.
  */
 public function trackingCodeGenerator()
 {
     Piwik::checkUserHasSomeViewAccess();
     $view = new View('@CoreAdminHome/trackingCodeGenerator');
     $this->setBasicVariablesView($view);
     $view->topMenu = MenuTop::getInstance()->getMenu();
     $view->userMenu = MenuUser::getInstance()->getMenu();
     $viewableIdSites = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
     $defaultIdSite = reset($viewableIdSites);
     $view->idSite = Common::getRequestVar('idSite', $defaultIdSite, 'int');
     $view->defaultReportSiteName = Site::getNameFor($view->idSite);
     $view->defaultSiteRevenue = Site::getCurrencySymbolFor($view->idSite);
     $view->maxCustomVariables = CustomVariables::getNumUsableCustomVariables();
     $allUrls = APISitesManager::getInstance()->getSiteUrlsFromId($view->idSite);
     if (isset($allUrls[1])) {
         $aliasUrl = $allUrls[1];
     } else {
         $aliasUrl = 'x.domain.com';
     }
     $view->defaultReportSiteAlias = $aliasUrl;
     $mainUrl = Site::getMainUrlFor($view->idSite);
     $view->defaultReportSiteDomain = @parse_url($mainUrl, PHP_URL_HOST);
     // get currencies for each viewable site
     $view->currencySymbols = APISitesManager::getInstance()->getCurrencySymbols();
     $dntChecker = new DoNotTrackHeaderChecker();
     $view->serverSideDoNotTrackEnabled = $dntChecker->isActive();
     return $view->render();
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:32,代码来源:Controller.php


注:本文中的Piwik\Site::getCurrencySymbolFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。