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


PHP Piwik_DataTable::setMetadata方法代码示例

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


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

示例1: makeDataTable

 /**
  * Creates a new DataTable with some metadata set. Sets the following metadata:
  * - 'site' => Piwik_Site instance for this archive
  * - 'period' => Piwik_Period instance for this archive
  * - 'timestamp' => the timestamp of the first date in this archive
  *
  * @param bool $isSimple Whether the DataTable should be a DataTable_Simple
  *                       instance or not.
  * @return Piwik_DataTable
  */
 public function makeDataTable($isSimple = false)
 {
     if ($isSimple) {
         $result = new Piwik_DataTable_Simple();
     } else {
         $result = new Piwik_DataTable();
     }
     $result->setMetadata('site', $this->getSite());
     $result->setMetadata('period', $this->getPeriod());
     $result->setMetadata('timestamp', $this->getTimestampStartDate());
     return $result;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:22,代码来源:Single.php

示例2: getDataTable

 /**
  * Returns a DataTable that has the name '$name' from the current Archive.
  * If $idSubTable is specified, returns the subDataTable called '$name_$idSubTable'
  *
  * @param string  $name
  * @param int     $idSubTable  optional id SubDataTable
  * @return Piwik_DataTable
  */
 public function getDataTable($name, $idSubTable = null)
 {
     if (!is_null($idSubTable)) {
         $name .= "_{$idSubTable}";
     }
     $this->setRequestedReport($name);
     $data = $this->get($name, 'blob', $tsArchived);
     $table = new Piwik_DataTable();
     if ($data !== false) {
         $table->addRowsFromSerializedArray($data);
         $table->setMetadata(Piwik_DataTable::ARCHIVED_DATE_METADATA_NAME, $tsArchived);
     }
     if ($data === false && $idSubTable !== null) {
         // This is not expected, but somehow happens in some unknown cases and very rarely.
         // Do not throw error in this case
         //throw new Exception("not expected");
         return new Piwik_DataTable();
     }
     return $table;
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:28,代码来源:Single.php

示例3: getByDayOfWeek

 /**
  * Returns datatable describing the number of visits for each day of the week.
  * 
  * @param string $idSite The site ID. Cannot refer to multiple sites.
  * @param string $period The period type: day, week, year, range...
  * @param string $date The start date of the period. Cannot refer to multiple dates.
  * @param string $segment The segment.
  * @return Piwik_DataTable
  */
 public function getByDayOfWeek($idSite, $period, $date, $segment = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     // disabled for multiple sites/dates
     if (Piwik_Archive::isMultipleSites($idSite)) {
         throw new Exception("VisitTime.getByDayOfWeek does not support multiple sites.");
     }
     if (Piwik_Archive::isMultiplePeriod($date, $period)) {
         throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates.");
     }
     // metrics to query
     $metrics = Piwik_ArchiveProcessing::getCoreMetrics();
     // get metric data for every day within the supplied period
     $oSite = new Piwik_Site($idSite);
     $oPeriod = Piwik_Archive::makePeriodFromQueryParams($oSite, $period, $date);
     $dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString();
     $archive = Piwik_Archive::build($idSite, 'day', $dateRange, $segment);
     $dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren();
     // if there's no data for this report, don't bother w/ anything else
     if ($dataTable->getRowsCount() == 0) {
         return $dataTable;
     }
     // group by the day of the week (see below for dayOfWeekFromDate function)
     $dataTable->filter('GroupBy', array('label', 'Piwik_VisitTime_dayOfWeekFromDate'));
     // create new datatable w/ empty rows, then add calculated datatable
     $rows = array();
     foreach (array(1, 2, 3, 4, 5, 6, 7) as $day) {
         $rows[] = array('label' => $day, 'nb_visits' => 0);
     }
     $result = new Piwik_DataTable();
     $result->addRowsFromSimpleArray($rows);
     $result->addDataTable($dataTable);
     // set day of week integer as metadata
     $result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week'));
     // translate labels
     $result->filter('ColumnCallbackReplace', array('label', 'Piwik_VisitTime_translateDayOfWeek'));
     // set datatable metadata for period start & finish
     $result->setMetadata('date_start', $oPeriod->getDateStart());
     $result->setMetadata('date_end', $oPeriod->getDateEnd());
     return $result;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:50,代码来源:API.php

示例4: setPastDataMetadata

 /**
  * Sets the total evolution metadata for a datatable returned by $this->buildDataTable
  * given data for the last period.
  * 
  * @param Piwik_DataTable $dataTable
  * @param Piwik_DataTable $pastData
  * @param array $apiMetrics Metrics info.
  */
 private function setPastDataMetadata($dataTable, $pastData, $apiMetrics)
 {
     if ($dataTable instanceof Piwik_DataTable_Array) {
         $pastArray = $pastData->getArray();
         foreach ($dataTable->getArray() as $subTable) {
             $this->setPastDataMetadata($subTable, current($pastArray), $apiMetrics);
             next($pastArray);
         }
     } else {
         // calculate total visits/actions/revenue for past data
         $this->setMetricsTotalsMetadata($pastData, $apiMetrics);
         foreach ($apiMetrics as $label => $metricInfo) {
             // get the names of metadata to set
             $totalMetadataName = self::getTotalMetadataName($label);
             $lastPeriodTotalMetadataName = self::getLastPeriodMetadataName($totalMetadataName);
             $totalEvolutionMetadataName = self::getTotalMetadataName($metricInfo[self::METRIC_EVOLUTION_COL_NAME_KEY]);
             // set last period total
             $pastTotal = $pastData->getMetadata($totalMetadataName);
             $dataTable->setMetadata($lastPeriodTotalMetadataName, $pastTotal);
             // calculate & set evolution
             $currentTotal = $dataTable->getMetadata($totalMetadataName);
             $evolution = Piwik_MultiSites_CalculateEvolutionFilter::calculate($currentTotal, $pastTotal);
             $dataTable->setMetadata($totalEvolutionMetadataName, $evolution);
         }
     }
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:34,代码来源:API.php


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