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


PHP Piwik\DataTable类代码示例

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


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

示例1: filter

 /**
  * See {@link PatternRecursive}.
  * 
  * @param DataTable $table
  * @return int The number of deleted rows.
  */
 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 = 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 && !Pattern::match($this->patternToSearchQuoted, $row->getColumn($this->columnToFilter), $invertedMatch = false)) {
             $table->deleteRow($key);
         }
     }
     return $table->getRowsCount();
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:32,代码来源:PatternRecursive.php

示例2: filter

 /**
  * @param DataTable $table
  */
 public function filter($table)
 {
     $row = $table->getRowFromLabel(Archiver::EVENT_NAME_NOT_SET);
     if ($row) {
         $row->setColumn('label', Piwik::translate('General_NotDefined', Piwik::translate('Events_EventName')));
     }
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:10,代码来源:ReplaceEventNameNotSet.php

示例3: mergeDataTables

 /**
  * Merge the columns of two data tables.
  * Manipulates the first table.
  *
  * @param DataTable|DataTable\Map $table1 The table to eventually filter.
  * @param DataTable|DataTable\Map $table2 Whether to delete rows with no visits or not.
  */
 public function mergeDataTables($table1, $table2)
 {
     // handle table arrays
     if ($table1 instanceof DataTable\Map && $table2 instanceof DataTable\Map) {
         $subTables2 = $table2->getDataTables();
         foreach ($table1->getDataTables() as $index => $subTable1) {
             if (!array_key_exists($index, $subTables2)) {
                 // occurs when archiving starts on dayN and continues into dayN+1, see https://github.com/piwik/piwik/issues/5168#issuecomment-50959925
                 continue;
             }
             $subTable2 = $subTables2[$index];
             $this->mergeDataTables($subTable1, $subTable2);
         }
         return;
     }
     $firstRow2 = $table2->getFirstRow();
     if (!$firstRow2 instanceof Row) {
         return;
     }
     $firstRow1 = $table1->getFirstRow();
     if (empty($firstRow1)) {
         $firstRow1 = $table1->addRow(new Row());
     }
     foreach ($firstRow2->getColumns() as $metric => $value) {
         $firstRow1->setColumn($metric, $value);
     }
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:34,代码来源:MergeDataTables.php

示例4: filter

 /**
  * @param DataTable $table
  */
 public function filter($table)
 {
     $notDefinedLabel = Piwik::translate('General_NotDefined', Piwik::translate('CustomVariables_ColumnCustomVariableValue'));
     $table->queueFilter('ColumnCallbackReplace', array('label', function ($label) use($notDefinedLabel) {
         return $label == \Piwik\Plugins\CustomVariables\Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED ? $notDefinedLabel : $label;
     }));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:10,代码来源:CustomVariablesValuesFromNameId.php

示例5: addSummaryRow

 /**
  * @param DataTable $table
  */
 private function addSummaryRow($table)
 {
     if ($table->getRowsCount() <= $this->truncateAfter + 1) {
         return;
     }
     $table->filter('Sort', array($this->columnToSortByBeforeTruncating, 'desc', $naturalSort = true, $recursiveSort = false));
     $rows = array_values($table->getRows());
     $count = $table->getRowsCount();
     $newRow = new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW)));
     $aggregationOps = $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
     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, $aggregationOps);
             }
         } else {
             $newRow->sumRow($rows[$i], $enableCopyMetadata = false, $aggregationOps);
         }
     }
     $table->filter('Limit', array(0, $this->truncateAfter));
     $table->addSummaryRow($newRow);
     unset($rows);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:29,代码来源:Truncate.php

示例6: filter

 /**
  * See {@link GroupBy}.
  *
  * @param DataTable $table
  */
 public function filter($table)
 {
     $groupByRows = array();
     $nonGroupByRowIds = array();
     foreach ($table->getRows() as $rowId => $row) {
         // skip the summary row
         if ($rowId == 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, $copyMeta = true, $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME));
             $nonGroupByRowIds[] = $rowId;
         }
     }
     // delete the unneeded rows.
     $table->deleteRows($nonGroupByRowIds);
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:33,代码来源:GroupBy.php

示例7: test_renderDataTable_shouldReturnResult

 public function test_renderDataTable_shouldReturnResult()
 {
     $dataTable = new DataTable();
     $dataTable->addRowFromSimpleArray(array('nb_visits' => 5, 'nb_random' => 10));
     $response = $this->builder->renderDataTable($dataTable);
     $this->assertSame("- 1 ['nb_visits' => 5, 'nb_random' => 10] [] [idsubtable = ]<br />\n", $response);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:7,代码来源:ConsoleRendererTest.php

示例8: filter

 /**
  * See {@link Sort}.
  *
  * @param DataTable $table
  * @return mixed
  */
 public function filter($table)
 {
     if ($table instanceof Simple) {
         return;
     }
     if (empty($this->columnToSort)) {
         return;
     }
     if (!$table->getRowsCountWithoutSummaryRow()) {
         return;
     }
     $row = $table->getFirstRow();
     if ($row === false) {
         return;
     }
     $config = new Sorter\Config();
     $sorter = new Sorter($config);
     $config->naturalSort = $this->naturalSort;
     $config->primaryColumnToSort = $sorter->getPrimaryColumnToSort($table, $this->columnToSort);
     $config->primarySortOrder = $sorter->getPrimarySortOrder($this->order);
     $config->primarySortFlags = $sorter->getBestSortFlags($table, $config->primaryColumnToSort);
     $config->secondaryColumnToSort = $sorter->getSecondaryColumnToSort($row, $config->primaryColumnToSort);
     $config->secondarySortOrder = $sorter->getSecondarySortOrder($this->order, $config->secondaryColumnToSort);
     $config->secondarySortFlags = $sorter->getBestSortFlags($table, $config->secondaryColumnToSort);
     // secondary sort should not be needed for all other sort flags (eg string/natural sort) as label is unique and would make it slower
     $isSecondaryColumnSortNeeded = $config->primarySortFlags === SORT_NUMERIC;
     $config->isSecondaryColumnSortEnabled = $this->isSecondaryColumnSortEnabled && $isSecondaryColumnSortNeeded;
     $this->sort($sorter, $table);
 }
开发者ID:piwik,项目名称:piwik,代码行数:35,代码来源:Sort.php

示例9: filter

 /**
  * @param DataTable $table
  */
 public function filter($table)
 {
     $numRows = 0;
     $lastGroupFromPreviousPage = null;
     foreach ($table->getRows() as $row) {
         $this->addRowIfNeeded($row, $numRows);
         $numRows++;
         $subtable = $row->getSubtable();
         if ($subtable) {
             if (!$this->hasRows()) {
                 $lastGroupFromPreviousPage = $row;
             }
             foreach ($subtable->getRows() as $subRow) {
                 $this->addRowIfNeeded($subRow, $numRows);
                 $numRows++;
             }
             $row->removeSubtable();
         }
         if ($this->hasNumberOfRequestedRowsFound()) {
             break;
         }
     }
     $this->prependGroupIfFirstSiteBelongsToAGroupButGroupIsMissingInRows($lastGroupFromPreviousPage);
     $table->setRows($this->rows);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:28,代码来源:NestedSitesLimiter.php

示例10: filter

 /**
  * See {@link ColumnCallbackAddMetadata}.
  *
  * @param DataTable $table
  */
 public function filter($table)
 {
     if ($this->applyToSummaryRow) {
         $rows = $table->getRows();
     } else {
         $rows = $table->getRowsWithoutSummaryRow();
     }
     foreach ($rows as $key => $row) {
         $parameters = array();
         foreach ($this->columnsToRead as $columnsToRead) {
             $parameters[] = $row->getColumn($columnsToRead);
         }
         if (!is_null($this->functionParameters)) {
             $parameters = array_merge($parameters, $this->functionParameters);
         }
         if (!is_null($this->functionToApply)) {
             $newValue = call_user_func_array($this->functionToApply, $parameters);
         } else {
             $newValue = $parameters[0];
         }
         if ($newValue !== false) {
             $row->addMetadata($this->metadataToAdd, $newValue);
         }
     }
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:30,代码来源:ColumnCallbackAddMetadata.php

示例11: filter

 /**
  * See {@link ColumnCallbackReplace}.
  *
  * @param DataTable $table
  */
 public function filter($table)
 {
     foreach ($table->getRows() as $row) {
         $extraColumnParameters = array();
         foreach ($this->extraColumnParameters as $columnName) {
             $extraColumnParameters[] = $row->getColumn($columnName);
         }
         foreach ($this->columnsToFilter as $column) {
             // when a value is not defined, we set it to zero by default (rather than displaying '-')
             $value = $this->getElementToReplace($row, $column);
             if ($value === false) {
                 $value = 0;
             }
             $parameters = array_merge(array($value), $extraColumnParameters);
             if (!is_null($this->functionParameters)) {
                 $parameters = array_merge($parameters, $this->functionParameters);
             }
             $newValue = call_user_func_array($this->functionToApply, $parameters);
             $this->setElementToReplace($row, $column, $newValue);
             $this->filterSubTable($row);
         }
     }
     if (in_array('label', $this->columnsToFilter)) {
         // we need to force rebuilding the index
         $table->setLabelsHaveChanged();
     }
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:32,代码来源:ColumnCallbackReplace.php

示例12: doFilterRecursiveDescend

 /**
  * Method for the recursive descend
  *
  * @param array $labelParts
  * @param DataTable $dataTable
  * @return Row|bool
  */
 private function doFilterRecursiveDescend($labelParts, $dataTable)
 {
     // we need to make sure to rebuild the index as some filters change the label column directly via
     // $row->setColumn('label', '') which would not be noticed in the label index otherwise.
     $dataTable->rebuildIndex();
     // search for the first part of the tree search
     $labelPart = array_shift($labelParts);
     $row = false;
     foreach ($this->getLabelVariations($labelPart) as $labelPart) {
         $row = $dataTable->getRowFromLabel($labelPart);
         if ($row !== false) {
             break;
         }
     }
     if ($row === false) {
         // not found
         return false;
     }
     // end of tree search reached
     if (count($labelParts) == 0) {
         return $row;
     }
     $subTable = $this->loadSubtable($dataTable, $row);
     if ($subTable === null) {
         // no more subtables but label parts left => no match found
         return false;
     }
     return $this->doFilterRecursiveDescend($labelParts, $subTable);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:36,代码来源:LabelFilter.php

示例13: doFilterRecursiveDescend

 /**
  * Method for the recursive descend
  *
  * @param array $labelParts
  * @param DataTable $dataTable
  * @return Row|bool
  */
 private function doFilterRecursiveDescend($labelParts, $dataTable)
 {
     // search for the first part of the tree search
     $labelPart = array_shift($labelParts);
     $row = false;
     foreach ($this->getLabelVariations($labelPart) as $labelPart) {
         $row = $dataTable->getRowFromLabel($labelPart);
         if ($row !== false) {
             break;
         }
     }
     if ($row === false) {
         // not found
         return false;
     }
     // end of tree search reached
     if (count($labelParts) == 0) {
         return $row;
     }
     $subTable = $this->loadSubtable($dataTable, $row);
     if ($subTable === null) {
         // no more subtables but label parts left => no match found
         return false;
     }
     return $this->doFilterRecursiveDescend($labelParts, $subTable);
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:33,代码来源:LabelFilter.php

示例14: filterTable

 private function filterTable($withUser = 5)
 {
     $dataTable = new DataTable();
     $dataTable->addRowsFromArray(array(array(Row::COLUMNS => array('label' => 'val1', Metrics::INDEX_NB_USERS => 0)), array(Row::COLUMNS => array('label' => 'val2')), array(Row::COLUMNS => array('label' => 'val2 5w ö?', Metrics::INDEX_NB_USERS => $withUser))));
     $dataTable->filter($this->filter, array($idSite = 1, $period = 'day', $date = 'today'));
     return $dataTable->getColumn(Metrics::INDEX_NB_USERS);
 }
开发者ID:ep123,项目名称:plugin-CustomDimensions,代码行数:7,代码来源:RemoveUserIfNeededTest.php

示例15: filterTable

 /**
  * @param DataTable $table
  */
 protected function filterTable($table)
 {
     foreach ($table->getRows() as $row) {
         $newColumns = $this->getRenamedColumns($row->getColumns());
         $row->setColumns($newColumns);
         $this->filterSubTable($row);
     }
 }
开发者ID:piwik,项目名称:piwik,代码行数:11,代码来源:ReplaceColumnNames.php


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