本文整理汇总了PHP中Piwik_DataTable::getRows方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_DataTable::getRows方法的具体用法?PHP Piwik_DataTable::getRows怎么用?PHP Piwik_DataTable::getRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_DataTable
的用法示例。
在下文中一共展示了Piwik_DataTable::getRows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
示例2: 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();
}
示例3: 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);
}
示例4: filter
/**
* Adds a summary row to the given data table
*
* @param Piwik_DataTable $table
*/
public function filter($table)
{
if ($table->getRowsCount() <= $this->startRowToSummarize + 1) {
return;
}
$table->filter('Sort', array($this->columnToSortByBeforeTruncating, 'desc'));
$rows = $table->getRows();
$count = $table->getRowsCount();
$newRow = new Piwik_DataTable_Row();
for ($i = $this->startRowToSummarize; $i < $count; $i++) {
if (!isset($rows[$i])) {
// case when the last row is a summary row, it is not indexed by $cout but by Piwik_DataTable::ID_SUMMARY_ROW
$summaryRow = $table->getRowFromId(Piwik_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);
}
} else {
$newRow->sumRow($rows[$i], $enableCopyMetadata = false);
}
}
$newRow->setColumns(array('label' => $this->labelSummaryRow) + $newRow->getColumns());
if ($this->deleteRows) {
$table->filter('Limit', array(0, $this->startRowToSummarize));
}
$table->addSummaryRow($newRow);
unset($rows);
}
示例5: foreach
/**
* @param Piwik_DataTable $subTable
*/
function __construct($subTable)
{
parent::__construct();
foreach ($subTable->getRows() as $row) {
$this->sumRow($row);
}
}
示例6: doManipulate
/**
* Template method called from self::manipulate.
* Flatten each data table.
*
* @param Piwik_DataTable $dataTable
* @param bool $date
* @return Piwik_DataTable
*/
protected function doManipulate(Piwik_DataTable $dataTable, $date = false)
{
$newDataTable = $dataTable->getEmptyClone();
foreach ($dataTable->getRows() as $row) {
$this->flattenRow($row, $newDataTable, $date);
}
return $newDataTable;
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: 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);
}
}
示例11: 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);
}
}
}
示例12: 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);
}
}
}
示例13: filter
/**
* Truncates the table after X rows and adds a summary row
*
* @param Piwik_DataTable $table
*/
public function filter($table)
{
$table->filter('AddSummaryRow', array($this->truncateAfter));
$table->filter('ReplaceSummaryRowLabel');
foreach ($table->getRows() as $row) {
if ($row->isSubtableLoaded()) {
$idSubTable = $row->getIdSubDataTable();
$subTable = Piwik_DataTable_Manager::getInstance()->getTable($idSubTable);
$subTable->filter('Truncate', array($this->truncateAfter));
}
}
}
示例14: filter
/**
* @param Piwik_DataTable $table
*/
public function filter($table)
{
foreach ($table->getRows() as $key => $row) {
//instead search must handle
// - negative search with -piwik
// - exact match with ""
// see (?!pattern) A subexpression that performs a negative lookahead search, which matches the search string at any point where a string not matching pattern begins.
if (!self::match($this->patternToSearch, $this->patternToSearchQuoted, $row->getColumn($this->columnToFilter), $this->invertedMatch)) {
$table->deleteRow($key);
}
}
}
示例15: filter
/**
* Executes the filter an adjusts all columns to fit the defined range
*
* @param Piwik_DataTable $table
*/
public function filter($table)
{
foreach ($table->getRows() as $row) {
$value = $row->getColumn($this->columnToFilter);
if ($value !== false) {
if ($value < self::$minimumValue) {
$row->setColumn($this->columnToFilter, self::$minimumValue);
} elseif ($value > self::$maximumValue) {
$row->setColumn($this->columnToFilter, self::$maximumValue);
}
}
}
}