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


PHP DataTable\Row类代码示例

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


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

示例1: flattenRow

 /**
  * @param Row $row
  * @param DataTable $dataTable
  * @param string $labelPrefix
  * @param bool $parentLogo
  */
 private function flattenRow(Row $row, DataTable $dataTable, $labelPrefix = '', $parentLogo = false)
 {
     $label = $row->getColumn('label');
     if ($label !== false) {
         $label = trim($label);
         if (substr($label, 0, 1) == '/' && $this->recursiveLabelSeparator == '/') {
             $label = substr($label, 1);
         }
         $label = $labelPrefix . $label;
         $row->setColumn('label', $label);
     }
     $logo = $row->getMetadata('logo');
     if ($logo === false && $parentLogo !== false) {
         $logo = $parentLogo;
         $row->setMetadata('logo', $logo);
     }
     $subTable = $this->loadSubtable($dataTable, $row);
     $row->removeSubtable();
     if ($subTable === null) {
         if ($this->includeAggregateRows) {
             $row->setMetadata('is_aggregate', 0);
         }
         $dataTable->addRow($row);
     } else {
         if ($this->includeAggregateRows) {
             $row->setMetadata('is_aggregate', 1);
             $dataTable->addRow($row);
         }
         $prefix = $label . $this->recursiveLabelSeparator;
         foreach ($subTable->getRows() as $row) {
             $this->flattenRow($row, $dataTable, $prefix, $logo);
         }
     }
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:40,代码来源:Flattener.php

示例2: tryToAddColumn

 private function tryToAddColumn(Row $row, $column, $callable)
 {
     try {
         $row->addColumn($column, $callable);
     } catch (\Exception $e) {
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:7,代码来源:AddColumnsProcessedMetrics.php

示例3: addRowWithMetadata

 private function addRowWithMetadata($metadata)
 {
     $row = new Row(array(Row::COLUMNS => array('label' => 'val1')));
     foreach ($metadata as $name => $value) {
         $row->setMetadata($name, $value);
     }
     $this->table->addRow($row);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:8,代码来源:PrependSegmentFilterTest.php

示例4: buildRowWithMetadata

 private function buildRowWithMetadata($metadata)
 {
     $row = new Row(array(Row::COLUMNS => array('label' => 'val1')));
     foreach ($metadata as $name => $value) {
         $row->setMetadata($name, $value);
     }
     return $row;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:8,代码来源:ColumnCallbackDeleteMetadataTest.php

示例5: filterSubTable

 /**
  * Filters a row's subtable, if one exists and is loaded in memory.
  *
  * @param Row $row The row whose subtable should be filter.
  */
 public function filterSubTable(Row $row)
 {
     if (!$this->enableRecursive) {
         return;
     }
     $subTable = $row->getSubtable();
     if ($subTable) {
         $this->filter($subTable);
     }
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:15,代码来源:BaseFilter.php

示例6: filterSubTable

 /**
  * Filters a row's subtable, if one exists and is loaded in memory.
  *
  * @param Row $row The row whose subtable should be filter.
  */
 public function filterSubTable(Row $row)
 {
     if (!$this->enableRecursive) {
         return;
     }
     if ($row->isSubtableLoaded()) {
         $subTable = Manager::getInstance()->getTable($row->getIdSubDataTable());
         $this->filter($subTable);
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:15,代码来源:BaseFilter.php

示例7: sort

 public function sort(Row $a, Row $b)
 {
     foreach ($this->columnsToCheck as $column) {
         if ($column) {
             $valA = $a->getColumn($column);
             $valB = $b->getColumn($column);
             $sort = $this->sortVal($valA, $valB);
             if (isset($sort)) {
                 return $sort;
             }
         }
     }
     return 0;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:14,代码来源:OrderBy.php

示例8: addRow

 private function addRow(DataTable $table, DataTable\Row $row, $growthPercentage, $newValue, $oldValue, $difference, $disappeared = false, $isNew = false, $isMover = false)
 {
     $columns = $row->getColumns();
     $columns['growth_percent'] = $growthPercentage;
     $columns['growth_percent_numeric'] = str_replace('%', '', $growthPercentage);
     $columns['grown'] = '-' != substr($growthPercentage, 0, 1);
     $columns['value_old'] = $oldValue;
     $columns['value_new'] = $newValue;
     $columns['difference'] = $difference;
     $columns['importance'] = abs($difference);
     $columns['isDisappeared'] = $disappeared;
     $columns['isNew'] = $isNew;
     $columns['isMover'] = $isMover;
     $table->addRowFromArray(array(DataTable\Row::COLUMNS => $columns));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:15,代码来源:Insight.php

示例9: addSummaryRow

 private function addSummaryRow($table)
 {
     $table->filter('Sort', array($this->columnToSortByBeforeTruncating, 'desc'));
     if ($table->getRowsCount() <= $this->truncateAfter + 1) {
         return;
     }
     $rows = $table->getRows();
     $count = $table->getRowsCount();
     $newRow = new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW)));
     for ($i = $this->truncateAfter; $i < $count; $i++) {
         if (!isset($rows[$i])) {
             // case when the last row is a summary row, it is not indexed by $cout but by DataTable::ID_SUMMARY_ROW
             $summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
             //FIXME: I'm not sure why it could return false, but it was reported in: http://forum.piwik.org/read.php?2,89324,page=1#msg-89442
             if ($summaryRow) {
                 $newRow->sumRow($summaryRow, $enableCopyMetadata = false, $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME));
             }
         } else {
             $newRow->sumRow($rows[$i], $enableCopyMetadata = false, $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME));
         }
     }
     $table->filter('Limit', array(0, $this->truncateAfter));
     $table->addSummaryRow($newRow);
     unset($rows);
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:25,代码来源:Truncate.php

示例10: flattenRow

 /**
  * @param Row $row
  * @param DataTable $dataTable
  * @param string $labelPrefix
  * @param bool $parentLogo
  */
 private function flattenRow(Row $row, $rowId, DataTable $dataTable, $labelPrefix = '', $parentLogo = false)
 {
     $label = $row->getColumn('label');
     if ($label !== false) {
         $label = trim($label);
         if ($this->recursiveLabelSeparator == '/') {
             if (substr($label, 0, 1) == '/') {
                 $label = substr($label, 1);
             } elseif ($rowId === DataTable::ID_SUMMARY_ROW && $labelPrefix && $label != DataTable::LABEL_SUMMARY_ROW) {
                 $label = ' - ' . $label;
             }
         }
         $label = $labelPrefix . $label;
         $row->setColumn('label', $label);
     }
     $logo = $row->getMetadata('logo');
     if ($logo === false && $parentLogo !== false) {
         $logo = $parentLogo;
         $row->setMetadata('logo', $logo);
     }
     /** @var DataTable $subTable */
     $subTable = $row->getSubtable();
     if ($subTable) {
         $subTable->applyQueuedFilters();
         $row->deleteMetadata('idsubdatatable_in_db');
     } else {
         $subTable = $this->loadSubtable($dataTable, $row);
     }
     $row->removeSubtable();
     if ($subTable === null) {
         if ($this->includeAggregateRows) {
             $row->setMetadata('is_aggregate', 0);
         }
         $dataTable->addRow($row);
     } else {
         if ($this->includeAggregateRows) {
             $row->setMetadata('is_aggregate', 1);
             $dataTable->addRow($row);
         }
         $prefix = $label . $this->recursiveLabelSeparator;
         foreach ($subTable->getRows() as $rowId => $row) {
             $this->flattenRow($row, $rowId, $dataTable, $prefix, $logo);
         }
     }
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:51,代码来源:Flattener.php

示例11: getColumn

 /**
  * Returns column from a given row.
  * Will work with 2 types of datatable
  * - raw datatables coming from the archive DB, which columns are int indexed
  * - datatables processed resulting of API calls, which columns have human readable english names
  *
  * @param Row|array $row
  * @param int $columnIdRaw see consts in Archive::
  * @param bool|array $mappingIdToName
  * @return mixed  Value of column, false if not found
  */
 public function getColumn($row, $columnIdRaw, $mappingIdToName = false)
 {
     if (empty($mappingIdToName)) {
         $mappingIdToName = Metrics::$mappingFromIdToName;
     }
     $columnIdReadable = $mappingIdToName[$columnIdRaw];
     if ($row instanceof Row) {
         $raw = $row->getColumn($columnIdRaw);
         if ($raw !== false) {
             return $raw;
         }
         return $row->getColumn($columnIdReadable);
     }
     if (isset($row[$columnIdRaw])) {
         return $row[$columnIdRaw];
     }
     if (isset($row[$columnIdReadable])) {
         return $row[$columnIdReadable];
     }
     return false;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:32,代码来源:Base.php

示例12: aggregateRowWithLabel

 /**
  * Aggregates the $row columns to this table.
  *
  * $row must have a column "label". The $row will be summed to this table's row with the same label.
  *
  * @param $row
  * @params null|array $columnAggregationOps
  * @throws \Exception
  */
 protected function aggregateRowWithLabel(Row $row, $columnAggregationOps)
 {
     $labelToLookFor = $row->getColumn('label');
     if ($labelToLookFor === false) {
         throw new Exception("Label column not found in the table to add in addDataTable()");
     }
     $rowFound = $this->getRowFromLabel($labelToLookFor);
     if ($rowFound === false) {
         if ($labelToLookFor === self::LABEL_SUMMARY_ROW) {
             $this->addSummaryRow($row);
         } else {
             $this->addRow($row);
         }
     } else {
         $rowFound->sumRow($row, $copyMeta = true, $columnAggregationOps);
         // if the row to add has a subtable whereas the current row doesn't
         // we simply add it (cloning the subtable)
         // if the row has the subtable already
         // then we have to recursively sum the subtables
         $subTable = $row->getSubtable();
         if ($subTable) {
             $subTable->metadata[self::COLUMN_AGGREGATION_OPS_METADATA_NAME] = $columnAggregationOps;
             $rowFound->sumSubtable($subTable);
         }
     }
 }
开发者ID:piwik,项目名称:piwik,代码行数:35,代码来源:DataTable.php

示例13: getPastRowFromCurrent

 /**
  * Utility function. Returns the current row in the past DataTable.
  *
  * @param Row $row The row in the 'current' DataTable.
  * @return bool|Row
  */
 protected function getPastRowFromCurrent($row)
 {
     return $this->pastDataTable->getRowFromLabel($row->getColumn('label'));
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:10,代码来源:CalculateEvolutionFilter.php

示例14: testWhenRowsInRandomOrderButSortSpecifiedShouldComputeSummaryRowAfterSort

 public function testWhenRowsInRandomOrderButSortSpecifiedShouldComputeSummaryRowAfterSort()
 {
     $table = new DataTable();
     $table->addRow($this->getRow3());
     $table->addRow($this->getRow2());
     $table->addRow($this->getRow4());
     $table->addRow($this->getRow1());
     $table->addRow($this->getRow0());
     $filter = new Truncate($table, 2, DataTable::LABEL_SUMMARY_ROW, $columnToSortBy = 'nb');
     $filter->filter($table);
     $this->assertEquals(3, $table->getRowsCount());
     $expectedRow = new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW, 'nb' => 111)));
     $this->assertTrue(Row::isEqual($table->getLastRow(), $expectedRow));
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:14,代码来源:TruncateTest.php

示例15: enrichWithUniqueVisitorsMetric

 protected function enrichWithUniqueVisitorsMetric(Row $row)
 {
     if (!$this->getParams()->isSingleSite()) {
         // we only compute unique visitors for a single site
         return;
     }
     if ($row->getColumn('nb_uniq_visitors') !== false) {
         if (SettingsPiwik::isUniqueVisitorsEnabled($this->getParams()->getPeriod()->getLabel())) {
             $uniqueVisitors = (double) $this->computeNbUniqVisitors();
             $row->setColumn('nb_uniq_visitors', $uniqueVisitors);
         } else {
             $row->deleteColumn('nb_uniq_visitors');
         }
     }
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:15,代码来源:ArchiveProcessor.php


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