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


PHP Piwik_DataTable类代码示例

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


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

示例1: manipulate

 /**
  * This method can be used by subclasses to iterate over data tables that might be
  * data table arrays. It calls back the template method self::doManipulate for each table.
  * This way, data table arrays can be handled in a transparent fashion.
  *
  * @param Piwik_DataTable_Array|Piwik_DataTable  $dataTable
  * @throws Exception
  * @return Piwik_DataTable_Array|Piwik_DataTable
  */
 protected function manipulate($dataTable)
 {
     if ($dataTable instanceof Piwik_DataTable_Array) {
         $newTableArray = new Piwik_DataTable_Array();
         $newTableArray->metadata = $dataTable->metadata;
         $newTableArray->setKeyName($dataTable->getKeyName());
         foreach ($dataTable->getArray() as $date => $subTable) {
             // for period=week, the label is "2011-08-15 to 2011-08-21", which is
             // an invalid date parameter => only use the first date
             // in other languages the whole string does not start with the date so
             // we need to preg match it.
             if (!preg_match('/[0-9]{4}(-[0-9]{2})?(-[0-9]{2})?/', $date, $match)) {
                 throw new Exception("Could not recognize date: {$date}");
             }
             $dateForApiRequest = $match[0];
             $subTable = $this->doManipulate($subTable, $dateForApiRequest);
             $newTableArray->addTable($subTable, $date);
         }
         return $newTableArray;
     }
     if ($dataTable instanceof Piwik_DataTable) {
         return $this->doManipulate($dataTable);
     }
     return $dataTable;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:34,代码来源:DataTableManipulator.php

示例2: renderTable

 /**
  * Computes the output for the given data table
  *
  * @param Piwik_DataTable  $table
  * @return string
  * @throws Exception
  */
 protected function renderTable($table)
 {
     if (!$table instanceof Piwik_DataTable_Array || $table->getKeyName() != 'date') {
         throw new Exception("RSS feeds can be generated for one specific website &idSite=X." . "\nPlease specify only one idSite or consider using &format=XML instead.");
     }
     $idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
     $period = Piwik_Common::getRequestVar('period');
     $piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName() . "?module=CoreHome&action=index&idSite=" . $idSite . "&period=" . $period;
     $out = "";
     $moreRecentFirst = array_reverse($table->getArray(), true);
     foreach ($moreRecentFirst as $date => $subtable) {
         $timestamp = $table->metadata[$date]['timestamp'];
         $site = $table->metadata[$date]['site'];
         $pudDate = date('r', $timestamp);
         $dateInSiteTimezone = Piwik_Date::factory($timestamp)->setTimezone($site->getTimezone())->toString('Y-m-d');
         $thisPiwikUrl = Piwik_Common::sanitizeInputValue($piwikUrl . "&date={$dateInSiteTimezone}");
         $siteName = $site->getName();
         $title = $siteName . " on " . $date;
         $out .= "\t<item>\n\t\t<pubDate>{$pudDate}</pubDate>\n\t\t<guid>{$thisPiwikUrl}</guid>\n\t\t<link>{$thisPiwikUrl}</link>\n\t\t<title>{$title}</title>\n\t\t<author>http://piwik.org</author>\n\t\t<description>";
         $out .= Piwik_Common::sanitizeInputValue($this->renderDataTable($subtable));
         $out .= "</description>\n\t</item>\n";
     }
     $header = $this->getRssHeader();
     $footer = $this->getRssFooter();
     return $header . $out . $footer;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:33,代码来源:Rss.php

示例3: foreach

 /**
  * @param Piwik_DataTable  $subTable
  */
 function __construct($subTable)
 {
     parent::__construct();
     foreach ($subTable->getRows() as $row) {
         $this->sumRow($row);
     }
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:10,代码来源:DataTableSummary.php

示例4: filter

 /**
  * Filters the given DataTable. Removes columns that are not desired from
  * each DataTable row.
  * 
  * @param Piwik_DataTable $table
  */
 public function filter($table)
 {
     $recurse = false;
     // only recurse if there are columns to remove/keep
     // remove columns specified in $this->columnsToRemove
     if (!empty($this->columnsToRemove)) {
         foreach ($table->getRows() as $row) {
             foreach ($this->columnsToRemove as $column) {
                 $row->deleteColumn($column);
             }
         }
         $recurse = true;
     }
     // remove columns not specified in $columnsToKeep
     if (!empty($this->columnsToKeep)) {
         foreach ($table->getRows() as $row) {
             foreach ($row->getColumns() as $name => $value) {
                 // label cannot be removed via whitelisting
                 if ($name != 'label' && !isset($this->columnsToKeep[$name])) {
                     $row->deleteColumn($name);
                 }
             }
         }
         $recurse = true;
     }
     // recurse
     if ($recurse) {
         foreach ($table->getRows() as $row) {
             $this->filterSubTable($row);
         }
     }
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:38,代码来源:ColumnDelete.php

示例5: filter

 /**
  * @param Piwik_DataTable $table
  * @return int
  */
 public function filter($table)
 {
     $rows = $table->getRows();
     foreach ($rows as $key => $row) {
         // A row is deleted if
         // 1 - its label doesnt contain the pattern
         // AND 2 - the label is not found in the children
         $patternNotFoundInChildren = false;
         try {
             $idSubTable = $row->getIdSubDataTable();
             $subTable = Piwik_DataTable_Manager::getInstance()->getTable($idSubTable);
             // we delete the row if we couldn't find the pattern in any row in the
             // children hierarchy
             if ($this->filter($subTable) == 0) {
                 $patternNotFoundInChildren = true;
             }
         } catch (Exception $e) {
             // there is no subtable loaded for example
             $patternNotFoundInChildren = true;
         }
         if ($patternNotFoundInChildren && !Piwik_DataTable_Filter_Pattern::match($this->patternToSearch, $this->patternToSearchQuoted, $row->getColumn($this->columnToFilter), $invertedMatch = false)) {
             $table->deleteRow($key);
         }
     }
     return $table->getRowsCount();
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:30,代码来源:PatternRecursive.php

示例6: filter

 /**
  * Applies the reduce function to each row and merges rows w/ the same reduce result.
  *
  * @param Piwik_DataTable  $table
  */
 public function filter($table)
 {
     $groupByRows = array();
     $nonGroupByRowIds = array();
     foreach ($table->getRows() as $rowId => $row) {
         // skip the summary row
         if ($rowId == Piwik_DataTable::ID_SUMMARY_ROW) {
             continue;
         }
         // reduce the group by column of this row
         $groupByColumnValue = $row->getColumn($this->groupByColumn);
         $parameters = array_merge(array($groupByColumnValue), $this->parameters);
         $groupByValue = call_user_func_array($this->reduceFunction, $parameters);
         if (!isset($groupByRows[$groupByValue])) {
             // if we haven't encountered this group by value before, we mark this row as a
             // row to keep, and change the group by column to the reduced value.
             $groupByRows[$groupByValue] = $row;
             $row->setColumn($this->groupByColumn, $groupByValue);
         } else {
             // if we have already encountered this group by value, we add this row to the
             // row that will be kept, and mark this one for deletion
             $groupByRows[$groupByValue]->sumRow($row);
             $nonGroupByRowIds[] = $rowId;
         }
     }
     // delete the unneeded rows.
     $table->deleteRows($nonGroupByRowIds);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:33,代码来源:GroupBy.php

示例7: getPlanetRatios

 public function getPlanetRatios()
 {
     $planetRatios = array('Mercury' => 0.382, 'Venus' => 0.949, 'Earth' => 1.0, 'Mars' => 0.532, 'Jupiter' => 11.209, 'Saturn' => 9.449, 'Uranus' => 4.007, 'Neptune' => 3.883);
     // convert this array to a DataTable object
     $dataTable = new Piwik_DataTable();
     $dataTable->addRowsFromArrayWithIndexLabel($planetRatios);
     return $dataTable;
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:8,代码来源:API.php

示例8: filter

 /**
  * @param Piwik_DataTable  $table
  */
 public function filter($table)
 {
     foreach ($table->getRows() as $key => $row) {
         $oldValue = $row->getMetadata($this->metadataToRead);
         $newValue = call_user_func($this->functionToApply, $oldValue);
         $row->addMetadata($this->metadataToAdd, $newValue);
     }
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:11,代码来源:MetadataCallbackAddMetadata.php

示例9: filter

 /**
  * Executes the filter and renames the defined columns
  *
  * @param Piwik_DataTable  $table
  */
 public function filter($table)
 {
     foreach ($table->getRows() as $key => $row) {
         $oldColumns = $row->getColumns();
         $newColumns = $this->getRenamedColumns($oldColumns);
         $row->setColumns($newColumns);
         $this->filterSubTable($row);
     }
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:14,代码来源:ReplaceColumnNames.php

示例10: getCompetitionDatatable

 public function getCompetitionDatatable()
 {
     $dataTable = new Piwik_DataTable();
     $row1 = new Piwik_DataTable_Row();
     $row1->setColumns(array('name' => 'piwik', 'license' => 'GPL'));
     $dataTable->addRow($row1);
     $dataTable->addRowFromSimpleArray(array('name' => 'google analytics', 'license' => 'commercial'));
     return $dataTable;
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:9,代码来源:API.php

示例11: testRangeCheckNormalDataTableNonIntegerValues

 /**
  *
  * @group Core
  * @group DataTable
  * @group DataTable_Filter
  * @group DataTable_Filter_RangeCheck
  */
 public function testRangeCheckNormalDataTableNonIntegerValues()
 {
     $table = new Piwik_DataTable();
     $table->addRowsFromArray(array(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'ask', 'count' => '3')), array(Piwik_DataTable_Row::COLUMNS => array('label' => 'nintendo', 'count' => 'test')), array(Piwik_DataTable_Row::COLUMNS => array('label' => 'test', 'count' => 0x1232)), array(Piwik_DataTable_Row::COLUMNS => array('label' => 'piwik', 'count' => 0x5)), array(Piwik_DataTable_Row::COLUMNS => array('label' => 'google', 'count' => '9test')), array(Piwik_DataTable_Row::COLUMNS => array('label' => 'yahoo', 'count' => 'test4'))));
     $filter = new Piwik_DataTable_Filter_RangeCheck($table, 'count', 3.97, 10);
     $filter->filter($table);
     $expectedOrder = array(3.97, 3.97, 10, 5, '9test', 3.97);
     $this->assertEquals($expectedOrder, $table->getColumn('count'));
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:16,代码来源:RangeCheckTest.php

示例12: getRank

 /**
  * Get rank
  *
  * @param string $url URL to request Ranks for
  * @return Piwik_DataTable
  */
 public function getRank($url)
 {
     Piwik::checkUserHasSomeViewAccess();
     $rank = new Piwik_SEO_RankChecker($url);
     $data = array('Google PageRank' => array('rank' => $rank->getPageRank(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'pagerank'), Piwik_Translate('SEO_AlexaRank') => array('rank' => $rank->getAlexaRank(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://alexa.com'), 'id' => 'alexa'), Piwik_Translate('SEO_DomainAge') => array('rank' => $rank->getAge(), 'logo' => 'plugins/SEO/images/whois.png', 'id' => 'domain-age'));
     $dataTable = new Piwik_DataTable();
     $dataTable->addRowsFromArrayWithIndexLabel($data);
     return $dataTable;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:15,代码来源:API.php

示例13: testConsoleSimple

 /**
  *  test with a row without child
  *
  * @group Core
  * @group DataTable
  * @group DataTable_Renderer
  * @group DataTable_Renderer_Console
  */
 public function testConsoleSimple()
 {
     $table = new Piwik_DataTable();
     $table->addRowFromArray(array(Piwik_DataTable_Row::COLUMNS => array('visits' => 245, 'visitors' => 245), Piwik_DataTable_Row::METADATA => array('logo' => 'test.png')));
     $expected = "- 1 ['visits' => 245, 'visitors' => 245] ['logo' => 'test.png'] [idsubtable = ]<br />\n";
     $render = new Piwik_DataTable_Renderer_Console();
     $render->setTable($table);
     $rendered = $render->render();
     $this->assertEquals($expected, $rendered);
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:18,代码来源:ConsoleTest.php

示例14: archiveDataArray

 /** Build DataTable from array and archive it */
 private function archiveDataArray($keyword, &$data)
 {
     $dataTable = new Piwik_DataTable();
     foreach ($data as &$row) {
         $dataTable->addRow(new Piwik_SiteUsers_ExtendedDataTableRow(array(Piwik_DataTable_Row::COLUMNS => $row)));
     }
     $name = 'SiteUsers_' . $keyword;
     $this->archiveProcessing->insertBlobRecord($name, $dataTable->getSerialized());
     destroy($dataTable);
 }
开发者ID:BeezyT,项目名称:piwik-siteusers,代码行数:11,代码来源:Archive.php

示例15: filter

 /**
  * Filters the given data table
  *
  * @param Piwik_DataTable  $table
  */
 public function filter($table)
 {
     foreach ($table->getRows() as $key => $row) {
         $columnValue = $row->getColumn($this->columnToFilter);
         if (!call_user_func($this->function, $columnValue)) {
             $table->deleteRow($key);
         }
         $this->filterSubTable($row);
     }
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:15,代码来源:ColumnCallbackDeleteRow.php


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