本文整理汇总了PHP中Piwik\DataTable::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP DataTable::filter方法的具体用法?PHP DataTable::filter怎么用?PHP DataTable::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\DataTable
的用法示例。
在下文中一共展示了DataTable::filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_filter_shouldIgnoreSummaryRow
public function test_filter_shouldIgnoreSummaryRow()
{
$row = $this->buildRow(array('label' => 'other'));
$this->table->addSummaryRow($row);
$this->table->filter($this->filter, array('UTC', 'day', 'today'));
$this->assertFalse($row->getMetadata('segmentValue'));
}
示例2: filter
/**
* @param DataTable $table
*/
public function filter($table)
{
// make url labels clickable
$table->filter('ColumnCallbackAddMetadata', array('label', 'url'));
// prettify the DataTable
$table->filter('ColumnCallbackReplace', array('label', 'Piwik\\Plugins\\Referrers\\removeUrlProtocol'));
$table->queueFilter('ReplaceColumnNames');
}
示例3: test_filter_shouldUrlEncodeValues
public function test_filter_shouldUrlEncodeValues()
{
$mapping = array(1 => 'Core tests', 3 => 'plugins tästs');
$this->table->filter($this->filter, array('segmentName', $mapping));
$metadata = $this->table->getRowsMetadata('segment');
$expected = array('segmentName==Core+tests', false, 'segmentName==plugins+t%C3%A4sts', false, false, false);
$this->assertSame($expected, $metadata);
}
示例4: test_filter_shouldOnlyPrependIfAMetadataNameIsSet
public function test_filter_shouldOnlyPrependIfAMetadataNameIsSet()
{
$this->table->filter($this->filter, array('other', 'prependme'));
$metadata = $this->table->getRowsMetadata('other');
$this->assertSame(array(false, 'prependmevalue', false, 'prependmevalue', 'prependme'), $metadata);
// should still be the same
$metadata = $this->table->getRowsMetadata('test');
$this->assertSame(array('1', '2', '3', '1', '4'), $metadata);
}
示例5: test_filter_shouldRemoveAllMetadataEntriesHavingTheGivenName
public function test_filter_shouldRemoveAllMetadataEntriesHavingTheGivenName()
{
$prepend = 'city=test;';
$this->table->filter($this->filter, array($prepend));
$metadata = $this->table->getRowsMetadata('segment');
$this->assertSame(array(false, $prepend . 'country=NZ', false, $prepend . 'country=AU', $prepend), $metadata);
// should be still the same
$metadata = $this->table->getRowsMetadata('test');
$this->assertSame(array('1', '2', '3', '1', '4'), $metadata);
}
示例6: test_filter_shoulAppendGivenStringToAllColumnsOfAllRows_EvenIfTheyHaveDifferentColumns
public function test_filter_shoulAppendGivenStringToAllColumnsOfAllRows_EvenIfTheyHaveDifferentColumns()
{
$this->addRow(array('nb_visits' => 49));
$nameToAppend = '_new_visit';
$this->table->filter($this->filter, array($nameToAppend));
$expectedRow1 = array('nb_visits' . $nameToAppend => 1, 'nb_conversions' . $nameToAppend => 5, 'revenue' . $nameToAppend => 10, 'conversion_rate' . $nameToAppend => 20);
$expectedRow2 = array('nb_visits' . $nameToAppend => 49);
$this->assertColumnsOfRowIdEquals($expectedRow1, $rowId = 0);
$this->assertColumnsOfRowIdEquals($expectedRow2, $rowId = 1);
}
示例7: test_filter_shouldNotGenerateASegmentValueIfReturnValueIsFalse
public function test_filter_shouldNotGenerateASegmentValueIfReturnValueIsFalse()
{
$this->table->filter($this->filter, array(function ($label) {
if ($label === false) {
return 'was false';
}
return false;
}));
$segmentValues = $this->table->getRowsMetadata('segmentValue');
$expected = array(false, false, false, false, 'was false', false, 'was false', false);
$this->assertSame($expected, $segmentValues);
}
示例8: test_filter_shouldRemoveTheMetadataFromSubtables_IfOneIsSet
public function test_filter_shouldRemoveTheMetadataFromSubtables_IfOneIsSet()
{
$row = $this->addRowWithMetadata(array('test' => '5', 'other' => 'value2'));
$table = new DataTable();
$table->addRow($this->buildRowWithMetadata(array('other' => 'value3')));
$table->addRow($this->buildRowWithMetadata(array('test' => '6')));
$table->addRow($this->buildRowWithMetadata(array('test' => '7', 'other' => 'value4')));
$row->setSubtable($table);
$this->table->filter($this->filter, array('other'));
$this->assertFalse($row->getMetadata('other'));
$metadata = $table->getRowsMetadata('other');
$this->assertSame(array(false, false, false), $metadata);
}
示例9: 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);
}
示例10: test_filter_IfMultipleSegmentsAreGiven_ShouldIgnoreASummaryRow
public function test_filter_IfMultipleSegmentsAreGiven_ShouldIgnoreASummaryRow()
{
$summaryRow = $this->buildRow(array('label' => 'part1 part2'));
$this->table->addSummaryRow($summaryRow);
$this->table->filter($this->filter, array(array('seg1', 'seg2'), $delimiter = ' '));
$this->assertFalse($summaryRow->getMetadata('segment'));
}
示例11: manipulateDataTable
/**
* Template method called from self::manipulate.
* Flatten each data table.
*
* @param DataTable $dataTable
* @return DataTable
*/
protected function manipulateDataTable($dataTable)
{
$newDataTable = $dataTable->getEmptyClone($keepFilters = true);
// this recursive filter will be applied to subtables
$dataTable->filter('ReplaceSummaryRowLabel');
$this->flattenDataTableInto($dataTable, $newDataTable);
return $newDataTable;
}
示例12: filter
/**
* See {@link ExcludeLowPopulation}.
*
* @param DataTable $table
*/
public function filter($table)
{
$minimumValue = $this->minimumValue;
$isValueLowPopulation = function ($value) use($minimumValue) {
return $value < $minimumValue;
};
$table->filter('ColumnCallbackDeleteRow', array($this->columnToFilter, $isValueLowPopulation));
}
示例13: test_filter
public function test_filter()
{
$dataTable = new DataTable();
$dataTable->addRowsFromArray(array(array(Row::COLUMNS => array('label' => 'val1', 'nb_visits' => 120)), array(Row::COLUMNS => array('nb_visits' => 90)), array(Row::COLUMNS => array('label' => 'val2 5w ö?', 'nb_visits' => 99)), array(Row::COLUMNS => array('label' => Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED, 'nb_visits' => 99))));
$dataTable->filter($this->filter, array($idDimension = 5));
$metadata = $dataTable->getRowsMetadata('segment');
$expected = array('dimension5==val1', false, 'dimension5==val2+5w+%C3%B6%3F', 'dimension5==');
$this->assertSame($expected, $metadata);
}
示例14: filterDataTable
/**
* @param DataTable $dataTable
*/
private function filterDataTable($dataTable)
{
$dataTable->filter('Sort', array(Metrics::INDEX_NB_VISITS));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
$dataTable->filter(function (DataTable $table) {
$row = $table->getRowFromLabel(Archiver::CONTENT_PIECE_NOT_SET);
if ($row) {
$row->setColumn('label', Piwik::translate('General_NotDefined', Piwik::translate('Contents_ContentPiece')));
}
foreach ($table->getRows() as $row) {
if ($row->getMetadata('contentTarget') === Archiver::CONTENT_TARGET_NOT_SET) {
$row->setMetadata('contentTarget', '');
}
}
});
// Content interaction rate = interactions / impressions
$dataTable->queueFilter('ColumnCallbackAddColumnPercentage', array('interaction_rate', 'nb_interactions', 'nb_impressions', $precision = 2));
}
示例15: filter
/**
* See {@link PrependValueToMetadata}.
*
* @param DataTable $table
*/
public function filter($table)
{
if (empty($this->metadataColumn) || empty($this->valueToPrepend)) {
return;
}
$metadataColumn = $this->metadataColumn;
$valueToPrepend = $this->valueToPrepend;
$table->filter(function (DataTable $dataTable) use($metadataColumn, $valueToPrepend) {
foreach ($dataTable->getRows() as $row) {
$filter = $row->getMetadata($metadataColumn);
if ($filter !== false) {
$row->setMetadata($metadataColumn, $valueToPrepend . $filter);
}
}
});
}