• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Piwik_DataTable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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_array($this->function, array_merge(array($columnValue), $this->functionParams))) {
             $table->deleteRow($key);
         }
         $this->filterSubTable($row);
     }
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:15,代码来源:ColumnCallbackDeleteRow.php


示例17: getTable

 protected function getTable()
 {
     $subtableAskPath1 = new Piwik_DataTable();
     $subtableAskPath1->addRowsFromArray(array(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'path1-index-page.html')), array(Piwik_DataTable_Row::COLUMNS => array('label' => 'another-page'))));
     $subtableAsk = new Piwik_DataTable();
     $subtableAsk->addRowsFromArray(array(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'path1'), Piwik_DataTable_Row::DATATABLE_ASSOCIATED => $subtableAskPath1), array(Piwik_DataTable_Row::COLUMNS => array('label' => 'index.html'))));
     $table = new Piwik_DataTable();
     $rows = array(array(Piwik_DataTable_Row::COLUMNS => array('label' => 'http://www.ask.com'), Piwik_DataTable_Row::DATATABLE_ASSOCIATED => $subtableAsk), array(Piwik_DataTable_Row::COLUMNS => array('label' => 'yahoo')));
     $table->addRowsFromArray($rows);
     return $table;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:11,代码来源:PatternRecursive.test.php


示例18: filterCollectionTableContent

 /**
  * Filtert Kollektionsdaten nach Strings. -> z.B. Unterscheidung Standard <-> Projekt
  * @param Piwik_DataTable $dataTable
  * @param String $filter
  * @param boolean $bool
  */
 private static function filterCollectionTableContent($dataTable, $filter, $bool)
 {
     $rows = $dataTable->getRows();
     Piwik_cdebug::clog('filterCollectionTableContent: rows: ' . count($rows));
     foreach ($rows as $i => $row) {
         $label = $row->getColumn('label');
         if (strpos($label, $filter) !== false xor $bool) {
             $dataTable->deleteRow($i);
         }
     }
 }
开发者ID:arminiusdc,项目名称:goobi-contrib,代码行数:17,代码来源:API.php


示例19: filter

 /**
  * Decodes all columns of the given data table
  *
  * @param Piwik_DataTable  $table
  */
 public function filter($table)
 {
     foreach ($table->getRows() as $row) {
         $value = $row->getColumn($this->columnToDecode);
         if ($value !== false) {
             $value = self::filterValue($value);
             $row->setColumn($this->columnToDecode, $value);
             $this->filterSubTable($row);
         }
     }
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:16,代码来源:SafeDecodeLabel.php


示例20: test_filter_Lowpop1

 /**
  * Test to exclude low population filter
  */
 function test_filter_Lowpop1()
 {
     $idcol = Piwik_DataTable_Row::COLUMNS;
     $table = new Piwik_DataTable();
     $rows = array(array($idcol => array('label' => 'google', 'nb_visits' => 897)), array($idcol => array('label' => 'ask', 'nb_visits' => -152)), array($idcol => array('label' => 'piwik', 'nb_visits' => 1.5)), array($idcol => array('label' => 'piwik2', 'nb_visits' => 1.4)), array($idcol => array('label' => 'yahoo', 'nb_visits' => 154)), array($idcol => array('label' => 'amazon', 'nb_visits' => 30)), array($idcol => array('label' => '238949', 'nb_visits' => 0)), array($idcol => array('label' => 'Q*(%&*', 'nb_visits' => 1)), array($idcol => array('label' => 'Q*(%&*2', 'nb_visits' => -1.5)));
     $table->addRowsFromArray($rows);
     $expectedtable = new Piwik_DataTable();
     $rows = array(array($idcol => array('label' => 'google', 'nb_visits' => 897)), array($idcol => array('label' => 'piwik', 'nb_visits' => 1.5)), array($idcol => array('label' => 'piwik2', 'nb_visits' => 1.4)), array($idcol => array('label' => 'yahoo', 'nb_visits' => 154)), array($idcol => array('label' => 'amazon', 'nb_visits' => 30)));
     $expectedtable->addRowsFromArray($rows);
     $filter = new Piwik_DataTable_Filter_ExcludeLowPopulation($table, 'nb_visits', 1.4);
     $this->assertTrue(Piwik_DataTable::isEqual($table, $expectedtable));
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:15,代码来源:ExcludeLowPopulation.test.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Piwik_DataTable_Filter类代码示例发布时间:2022-05-23
下一篇:
PHP Piwik_Config类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap