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


PHP Piwik_Site::isEcommerceEnabledFor方法代码示例

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


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

示例1: getDividend

 /**
  * Returns the difference between the column in the specific row and its
  * sister column in the past DataTable.
  * 
  * @param Piwik_DataTable_Row $row
  * @return int|float
  */
 protected function getDividend($row)
 {
     $currentValue = $row->getColumn($this->columnValueToRead);
     // if the site this is for doesn't support ecommerce & this is for the revenue_evolution column,
     // we don't add the new column
     if ($currentValue === false && $this->isRevenueEvolution && !Piwik_Site::isEcommerceEnabledFor($row->getColumn('label'))) {
         return false;
     }
     $pastRow = $this->getPastRowFromCurrent($row);
     if ($pastRow) {
         $pastValue = $pastRow->getColumn($this->columnValueToRead);
     } else {
         $pastValue = 0;
     }
     return $currentValue - $pastValue;
 }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:23,代码来源:CalculateEvolutionFilter.php

示例2: renderReport

    public function renderReport($processedReport)
    {
        $isGoalPluginEnabled = Piwik_Common::isGoalPluginEnabled();
        $prettyDate = $processedReport['prettyDate'];
        $reportData = $processedReport['reportData'];
        $evolutionMetrics = array();
        $multiSitesAPIMetrics = Piwik_MultiSites_API::getApiMetrics($enhanced = true);
        foreach ($multiSitesAPIMetrics as $metricSettings) {
            $evolutionMetrics[] = $metricSettings[Piwik_MultiSites_API::METRIC_EVOLUTION_COL_NAME_KEY];
        }
        // no decimal for all metrics to shorten SMS content (keeps the monetary sign for revenue metrics)
        $reportData->filter('ColumnCallbackReplace', array(array_merge(array_keys($multiSitesAPIMetrics), $evolutionMetrics), create_function('$value', '
					return preg_replace_callback (
						FLOAT_REGEXP,
						create_function (
							\'$matches\',
							\'return round($matches[0]);\'
						),
						$value
					);
					')));
        // evolution metrics formatting :
        //  - remove monetary, percentage and white spaces to shorten SMS content
        //    (this is also needed to be able to test $value != 0 and see if there is an evolution at all in SMSReport.tpl)
        //  - adds a plus sign
        $reportData->filter('ColumnCallbackReplace', array($evolutionMetrics, create_function('$value', '
					$matched = preg_match(FLOAT_REGEXP, $value, $matches);
					return $matched ? sprintf("%+d",$matches[0]) : $value;
					')));
        $dataRows = $reportData->getRows();
        $reportMetadata = $processedReport['reportMetadata'];
        $reportRowsMetadata = $reportMetadata->getRows();
        $siteHasECommerce = array();
        foreach ($reportRowsMetadata as $rowMetadata) {
            $idSite = $rowMetadata->getColumn('idsite');
            $siteHasECommerce[$idSite] = Piwik_Site::isEcommerceEnabledFor($idSite);
        }
        $smarty = new Piwik_Smarty();
        $smarty->assign("isGoalPluginEnabled", $isGoalPluginEnabled);
        $smarty->assign("reportRows", $dataRows);
        $smarty->assign("reportRowsMetadata", $reportRowsMetadata);
        $smarty->assign("prettyDate", $prettyDate);
        $smarty->assign("siteHasECommerce", $siteHasECommerce);
        $smarty->assign("displaySiteName", $processedReport['metadata']['action'] == 'getAll');
        $this->rendering .= $smarty->fetch(PIWIK_USER_PATH . '/plugins/MobileMessaging/templates/SMSReport.tpl');
    }
开发者ID:nnnnathann,项目名称:piwik,代码行数:46,代码来源:Sms.php

示例3: getSitesInfo

 public function getSitesInfo($view)
 {
     Piwik::checkUserHasSomeViewAccess();
     $displayRevenueColumn = Piwik_Common::isGoalPluginEnabled();
     // overwrites the default Date set in the parent controller
     // Instead of the default current website's local date,
     // we set "today" or "yesterday" based on the default Piwik timezone
     $piwikDefaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
     $dateRequest = Piwik_Common::getRequestVar('date', 'today');
     $period = Piwik_Common::getRequestVar('period', 'day');
     $date = $dateRequest;
     if ($period != 'range') {
         $date = $this->getDateParameterInTimezone($dateRequest, $piwikDefaultTimezone);
         $date = $date->toString();
     }
     $siteIds = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
     $dataTable = Piwik_MultiSites_API::getInstance()->getAll($period, $date, $segment = false);
     list($minDate, $maxDate) = $this->getMinMaxDateAcrossWebsites($siteIds);
     $totalVisits = $totalActions = $totalRevenue = 0;
     // put data into a form the template will understand better
     $digestableData = array();
     foreach ($siteIds as $idSite) {
         $isEcommerceEnabled = Piwik_Site::isEcommerceEnabledFor($idSite);
         $digestableData[$idSite] = array('idsite' => $idSite, 'main_url' => Piwik_Site::getMainUrlFor($idSite), 'name' => Piwik_Site::getNameFor($idSite), 'visits' => 0, 'actions' => 0);
         if ($period != 'range') {
             $digestableData[$idSite]['visits_evolution'] = 0;
             $digestableData[$idSite]['actions_evolution'] = 0;
         }
         if ($displayRevenueColumn) {
             $revenueDefault = $isEcommerceEnabled ? 0 : "'-'";
             if ($period != 'range') {
                 $digestableData[$idSite]['revenue_evolution'] = $revenueDefault;
             }
         }
     }
     foreach ($dataTable->getRows() as $row) {
         $idsite = (int) $row->getMetadata('idsite');
         $site =& $digestableData[$idsite];
         $site['visits'] = (int) $row->getColumn('nb_visits');
         $totalVisits += $site['visits'];
         $site['actions'] = (int) $row->getColumn('nb_actions');
         $totalActions += $site['actions'];
         if ($displayRevenueColumn) {
             if ($row->getColumn('revenue') !== false) {
                 $site['revenue'] = $row->getColumn('revenue');
                 $totalRevenue += $site['revenue'];
             }
         }
         if ($period != 'range') {
             $site['visits_evolution'] = $row->getColumn('visits_evolution');
             $site['actions_evolution'] = $row->getColumn('actions_evolution');
             if ($displayRevenueColumn) {
                 $site['revenue_evolution'] = $row->getColumn('revenue_evolution');
             }
         }
     }
     $this->applyPrettyMoney($digestableData);
     $view->sitesData = array_values($digestableData);
     $view->evolutionBy = $this->evolutionBy;
     $view->period = $period;
     $view->dateRequest = $dateRequest;
     $view->page = $this->page;
     $view->limit = $this->limit;
     $view->orderBy = $this->orderBy;
     $view->order = $this->order;
     $view->totalVisits = $totalVisits;
     $view->totalRevenue = $totalRevenue;
     $view->displayRevenueColumn = $displayRevenueColumn;
     $view->totalActions = $totalActions;
     $params = $this->getGraphParamsModified();
     $view->dateSparkline = $period == 'range' ? $dateRequest : $params['date'];
     $view->autoRefreshTodayReport = false;
     // if the current date is today, or yesterday,
     // in case the website is set to UTC-12), or today in UTC+14, we refresh the page every 5min
     if (in_array($date, array('today', date('Y-m-d'), 'yesterday', Piwik_Date::factory('yesterday')->toString('Y-m-d'), Piwik_Date::factory('now', 'UTC+14')->toString('Y-m-d')))) {
         $view->autoRefreshTodayReport = Piwik_Config::getInstance()->General['multisites_refresh_after_seconds'];
     }
     $this->setGeneralVariablesView($view);
     $this->setMinDateView($minDate, $view);
     $this->setMaxDateView($maxDate, $view);
     $view->show_sparklines = Piwik_Config::getInstance()->General['show_multisites_sparklines'];
     echo $view->render();
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:83,代码来源:Controller.php

示例4: buildDataTable

 private function buildDataTable($sites, $period, $date, $segment, $_restrictSitesToLogin, $enhanced)
 {
     $allWebsitesRequested = $sites == 'all';
     if ($allWebsitesRequested) {
         if (Piwik::isUserIsSuperUser() && !Piwik_TaskScheduler::isTaskBeingExecuted()) {
             Piwik_Site::setSites(Piwik_SitesManager_API::getInstance()->getAllSites());
         } else {
             Piwik_Site::setSitesFromArray(Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin));
         }
     }
     // build the archive type used to query archive data
     $archive = Piwik_Archive::build($sites, $period, $date, $segment, $_restrictSitesToLogin);
     // determine what data will be displayed
     $fieldsToGet = array();
     $columnNameRewrites = array();
     $apiECommerceMetrics = array();
     $apiMetrics = Piwik_MultiSites_API::getApiMetrics($enhanced);
     foreach ($apiMetrics as $metricName => $metricSettings) {
         $fieldsToGet[] = $metricSettings[self::METRIC_RECORD_NAME_KEY];
         $columnNameRewrites[$metricSettings[self::METRIC_RECORD_NAME_KEY]] = $metricName;
         if ($metricSettings[self::METRIC_IS_ECOMMERCE_KEY]) {
             $apiECommerceMetrics[$metricName] = $metricSettings;
         }
     }
     // get the data
     // $dataTable instanceOf Piwik_DataTable_Array
     $dataTable = $archive->getDataTableFromNumeric($fieldsToGet);
     // get rid of the DataTable_Array that is created by the IndexedBySite archive type
     if ($dataTable instanceof Piwik_DataTable_Array && $allWebsitesRequested) {
         $dataTable = $dataTable->mergeChildren();
     } else {
         if (!$dataTable instanceof Piwik_DataTable_Array) {
             $firstDataTableRow = $dataTable->getFirstRow();
             $firstDataTableRow->setColumn('label', $sites);
         }
     }
     // if the period isn't a range & a lastN/previousN date isn't used, we get the same
     // data for the last period to show the evolution of visits/actions/revenue
     if ($period != 'range' && !preg_match('/(last|previous)([0-9]*)/', $date, $regs)) {
         if (strpos($date, ',')) {
             $rangePeriod = new Piwik_Period_Range($period, $date);
             $lastStartDate = Piwik_Period_Range::removePeriod($period, $rangePeriod->getDateStart(), $n = 1);
             $lastEndDate = Piwik_Period_Range::removePeriod($period, $rangePeriod->getDateEnd(), $n = 1);
             $strLastDate = "{$lastStartDate},{$lastEndDate}";
         } else {
             $strLastDate = Piwik_Period_Range::removePeriod($period, Piwik_Date::factory($date), $n = 1)->toString();
         }
         $pastArchive = Piwik_Archive::build('all', $period, $strLastDate, $segment, $_restrictSitesToLogin);
         $pastData = $pastArchive->getDataTableFromNumeric($fieldsToGet);
         $pastData = $pastData->mergeChildren();
         // use past data to calculate evolution percentages
         $this->calculateEvolutionPercentages($dataTable, $pastData, $apiMetrics);
     }
     // remove eCommerce related metrics on non eCommerce Piwik sites
     // note: this is not optimal in terms of performance: those metrics should not be retrieved in the first place
     if ($enhanced) {
         // $dataTableRows instanceOf Piwik_DataTable_Row[]
         $dataTableRows = $dataTable->getRows();
         foreach ($dataTableRows as $dataTableRow) {
             $siteId = $dataTableRow->getColumn('label');
             if (!Piwik_Site::isEcommerceEnabledFor($siteId)) {
                 foreach ($apiECommerceMetrics as $metricSettings) {
                     $dataTableRow->deleteColumn($metricSettings[self::METRIC_RECORD_NAME_KEY]);
                     $dataTableRow->deleteColumn($metricSettings[self::METRIC_EVOLUTION_COL_NAME_KEY]);
                 }
             }
         }
     }
     // move the site id to a metadata column
     $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'idsite'));
     // set the label of each row to the site name
     if ($allWebsitesRequested) {
         $getNameFor = array('Piwik_Site', 'getNameFor');
         $dataTable->filter('ColumnCallbackReplace', array('label', $getNameFor));
     } else {
         $dataTable->filter('ColumnDelete', array('label'));
     }
     // replace record names with user friendly metric names
     $dataTable->filter('ReplaceColumnNames', array($columnNameRewrites));
     // Ensures data set sorted, for Metadata output
     $dataTable->filter('Sort', array(self::NB_VISITS_METRIC, 'desc', $naturalSort = false));
     // filter rows without visits
     // note: if only one website is queried and there are no visits, we can not remove the row otherwise Piwik_API_ResponseBuilder throws 'Call to a member function getColumns() on a non-object'
     if ($allWebsitesRequested) {
         $dataTable->filter('ColumnCallbackDeleteRow', array(self::NB_VISITS_METRIC, create_function('$value', 'return $value != 0;')));
     }
     return $dataTable;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:88,代码来源:API.php

示例5: testSetDefaultTimezoneAndCurrencyAndExcludedQueryParametersAndExcludedIps

 /**
  * 
  * @group Plugins
  * @group SitesManager
  */
 public function testSetDefaultTimezoneAndCurrencyAndExcludedQueryParametersAndExcludedIps()
 {
     // test that they return default values
     $defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
     $this->assertEquals('UTC', $defaultTimezone);
     $defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
     $this->assertEquals('USD', $defaultCurrency);
     $excludedIps = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
     $this->assertEquals('', $excludedIps);
     $excludedQueryParameters = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
     $this->assertEquals('', $excludedQueryParameters);
     // test that when not specified, defaults are set as expected
     $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'));
     $site = new Piwik_Site($idsite);
     $this->assertEquals('UTC', $site->getTimezone());
     $this->assertEquals('USD', $site->getCurrency());
     $this->assertEquals('', $site->getExcludedQueryParameters());
     $this->assertEquals('', $site->getExcludedIps());
     $this->assertEquals(false, $site->isEcommerceEnabled());
     // set the global timezone and get it
     $newDefaultTimezone = 'UTC+5.5';
     Piwik_SitesManager_API::getInstance()->setDefaultTimezone($newDefaultTimezone);
     $defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
     $this->assertEquals($newDefaultTimezone, $defaultTimezone);
     // set the default currency and get it
     $newDefaultCurrency = 'EUR';
     Piwik_SitesManager_API::getInstance()->setDefaultCurrency($newDefaultCurrency);
     $defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
     $this->assertEquals($newDefaultCurrency, $defaultCurrency);
     // set the global IPs to exclude and get it
     $newGlobalExcludedIps = '1.1.1.*,1.1.*.*,150.1.1.1';
     Piwik_SitesManager_API::getInstance()->setGlobalExcludedIps($newGlobalExcludedIps);
     $globalExcludedIps = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
     $this->assertEquals($newGlobalExcludedIps, $globalExcludedIps);
     // set the global URL query params to exclude and get it
     $newGlobalExcludedQueryParameters = 'PHPSESSID,blabla, TesT';
     // removed the space
     $expectedGlobalExcludedQueryParameters = 'PHPSESSID,blabla,TesT';
     Piwik_SitesManager_API::getInstance()->setGlobalExcludedQueryParameters($newGlobalExcludedQueryParameters);
     $globalExcludedQueryParameters = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
     $this->assertEquals($expectedGlobalExcludedQueryParameters, $globalExcludedQueryParameters);
     // create a website and check that default currency and default timezone are set
     // however, excluded IPs and excluded query Params are not returned
     $idsite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, $siteSearch = 0, $searchKeywordParameters = 'test1,test2', $searchCategoryParameters = 'test2,test1', '', '', $newDefaultTimezone);
     $site = new Piwik_Site($idsite);
     $this->assertEquals($newDefaultTimezone, $site->getTimezone());
     $this->assertEquals(date('Y-m-d'), $site->getCreationDate()->toString());
     $this->assertEquals($newDefaultCurrency, $site->getCurrency());
     $this->assertEquals('', $site->getExcludedIps());
     $this->assertEquals('', $site->getExcludedQueryParameters());
     $this->assertEquals('test1,test2', $site->getSearchKeywordParameters());
     $this->assertEquals('test2,test1', $site->getSearchCategoryParameters());
     $this->assertFalse($site->isSiteSearchEnabled());
     $this->assertFalse(Piwik_Site::isSiteSearchEnabledFor($idsite));
     $this->assertFalse($site->isEcommerceEnabled());
     $this->assertFalse(Piwik_Site::isEcommerceEnabledFor($idsite));
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:62,代码来源:SitesManagerTest.php


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