/**
  * Constructor.
  *
  * @param DataTable $table The table to eventually filter.
  */
 public function __construct($table, $idSite, $period, $date)
 {
     parent::__construct($table);
     $this->idSite = $idSite;
     $this->period = $period;
     $this->date = $date;
 }
Ejemplo n.º 2
0
 /**
  * Constructor.
  *
  * @param DataTable $table The DataTable that will be filtered eventually.
  * @param int $offset The starting row index to keep.
  * @param int $limit Number of rows to keep (specify -1 to keep all rows).
  * @param bool $keepSummaryRow Whether to keep the summary row or not.
  */
 public function __construct($table, $offset, $limit = -1, $keepSummaryRow = false)
 {
     parent::__construct($table);
     $this->offset = $offset;
     $this->limit = $limit;
     $this->keepSummaryRow = $keepSummaryRow;
 }
Ejemplo n.º 3
0
 /**
  * Constructor.
  *
  * @param DataTable $table The DataTable to filter.
  * @param string $groupByColumn The column name to reduce.
  * @param callable $reduceFunction The reduce function. This must alter the `$groupByColumn`
  *                                 columng in some way.
  * @param array $parameters deprecated - use an [anonymous function](http://php.net/manual/en/functions.anonymous.php)
  *                          instead.
  */
 public function __construct($table, $groupByColumn, $reduceFunction, $parameters = array())
 {
     parent::__construct($table);
     $this->groupByColumn = $groupByColumn;
     $this->reduceFunction = $reduceFunction;
     $this->parameters = $parameters;
 }
Ejemplo n.º 4
0
 /**
  * Constructor.
  *
  * @param DataTable $table The table to eventually filter.
  * @param string $columnToFilter The column to match with the `$patternToSearch` pattern.
  * @param string $patternToSearch The regex pattern to use.
  * @param bool $invertedMatch Whether to invert the pattern or not. If true, will remove
  *                            rows if they match the pattern.
  */
 public function __construct($table, $columnToFilter, $patternToSearch, $invertedMatch = false)
 {
     parent::__construct($table);
     $this->patternToSearch = $patternToSearch;
     $this->patternToSearchQuoted = self::getPatternQuoted($patternToSearch);
     $this->columnToFilter = $columnToFilter;
     $this->invertedMatch = $invertedMatch;
 }
Ejemplo n.º 5
0
 /**
  * Constructor.
  * 
  * @param DataTable $table The table that will eventually be filtered.
  * @param string|null $newLabel The new label for summary row. If null, defaults to
  *                              `Piwik::translate('General_Others')`.
  */
 public function __construct($table, $newLabel = null)
 {
     parent::__construct($table);
     if (is_null($newLabel)) {
         $newLabel = Piwik::translate('General_Others');
     }
     $this->newLabel = $newLabel;
 }
Ejemplo n.º 6
0
 /**
  * Constructor.
  *
  * @param DataTable $table The table that will be eventually filtered.
  * @param array|null $mappingToApply The name mapping to apply. Must map old column names
  *                                   with new ones, eg,
  *
  *                                       array('OLD_COLUMN_NAME' => 'NEW_COLUMN NAME',
  *                                             'OLD_COLUMN_NAME2' => 'NEW_COLUMN NAME2')
  *
  *                                   If null, {@link Piwik\Metrics::$mappingFromIdToName} is used.
  */
 public function __construct($table, $mappingToApply = null)
 {
     parent::__construct($table);
     $this->mappingToApply = Metrics::$mappingFromIdToName;
     if (!is_null($mappingToApply)) {
         $this->mappingToApply = $mappingToApply;
     }
 }
 /**
  * Constructor.
  *
  * @param DataTable $table The table to eventually filter.
  * @param int $idSite
  * @param string $period
  * @param string $date
  * @param string $segment
  * @param bool $expanded
  */
 public function __construct($table, $idSite, $period, $date, $segment, $expanded)
 {
     parent::__construct($table);
     $this->idSite = $idSite;
     $this->period = $period;
     $this->date = $date;
     $this->segment = $segment;
     $this->expanded = $expanded;
 }
Ejemplo n.º 8
0
 /**
  * @param DataTable $table
  * @param string $columnToFilter name of the column to filter
  * @param float $minimumValue minimum value for range
  * @param float $maximumValue maximum value for range
  */
 public function __construct($table, $columnToFilter, $minimumValue = 0.0, $maximumValue = 100.0)
 {
     parent::__construct($table);
     $this->columnToFilter = $columnToFilter;
     if ($minimumValue < $maximumValue) {
         self::$minimumValue = $minimumValue;
         self::$maximumValue = $maximumValue;
     }
 }
Ejemplo n.º 9
0
 /**
  * Generates a segment filter based on the label column and the given segment names
  *
  * @param DataTable $table
  * @param string|array $segmentOrSegments Either one segment or an array of segments.
  *                                        If more than one segment is given a delimter has to be defined.
  * @param string $delimiter               The delimiter by which the label should be splitted.
  */
 public function __construct($table, $segmentOrSegments, $delimiter = '')
 {
     parent::__construct($table);
     if (!is_array($segmentOrSegments)) {
         $segmentOrSegments = array($segmentOrSegments);
     }
     $this->segments = $segmentOrSegments;
     $this->delimiter = $delimiter;
 }
Ejemplo n.º 10
0
 /**
  * Constructor.
  * 
  * @param DataTable $table The table to eventually filter.
  * @param string $columnToFilter The column to match with the `$patternToSearch` pattern.
  * @param string $patternToSearch The regex pattern to use.
  */
 public function __construct($table, $columnToFilter, $patternToSearch)
 {
     parent::__construct($table);
     $this->patternToSearch = $patternToSearch;
     $this->patternToSearchQuoted = Pattern::getPatternQuoted($patternToSearch);
     $this->patternToSearch = $patternToSearch;
     //preg_quote($patternToSearch);
     $this->columnToFilter = $columnToFilter;
 }
Ejemplo n.º 11
0
 /**
  * Constructor.
  *
  * @param DataTable $table The table to eventually filter.
  * @param string $columnToSort The name of the column to sort by.
  * @param string $order order `'asc'` or `'desc'`.
  * @param bool $naturalSort Whether to use a natural sort or not (see {@link http://php.net/natsort}).
  * @param bool $recursiveSort Whether to sort all subtables or not.
  */
 public function __construct($table, $columnToSort, $order = 'desc', $naturalSort = true, $recursiveSort = false)
 {
     parent::__construct($table);
     if ($recursiveSort) {
         $table->enableRecursiveSort();
     }
     $this->columnToSort = $columnToSort;
     $this->naturalSort = $naturalSort;
     $this->setOrder($order);
 }
Ejemplo n.º 12
0
 /**
  * Constructor.
  *
  * @param DataTable $table The DataTable that will be filtered.
  * @param array|string $columns The names of the columns to pass to the callback.
  * @param string $columnToAdd The name of the column to add.
  * @param callable $functionToApply The callback to apply to each row of a DataTable. The columns
  *                                  specified in `$columns` are passed to this callback.
  * @param array $functionParameters deprecated - use an [anonymous function](http://php.net/manual/en/functions.anonymous.php)
  *                                  instead.
  */
 public function __construct($table, $columns, $columnToAdd, $functionToApply, $functionParameters = array())
 {
     parent::__construct($table);
     if (!is_array($columns)) {
         $columns = array($columns);
     }
     $this->columns = $columns;
     $this->columnToAdd = $columnToAdd;
     $this->functionToApply = $functionToApply;
     $this->functionParameters = $functionParameters;
 }
Ejemplo n.º 13
0
Archivo: Sort.php Proyecto: piwik/piwik
 /**
  * Constructor.
  *
  * @param DataTable $table The table to eventually filter.
  * @param string $columnToSort The name of the column to sort by.
  * @param string $order order `'asc'` or `'desc'`.
  * @param bool $naturalSort Whether to use a natural sort or not (see {@link http://php.net/natsort}).
  * @param bool $recursiveSort Whether to sort all subtables or not.
  * @param bool $doSortBySecondaryColumn If true will sort by a secondary column. The column is automatically
  *                                    detected and will be either nb_visits or label, if possible.
  */
 public function __construct($table, $columnToSort, $order = 'desc', $naturalSort = true, $recursiveSort = true, $doSortBySecondaryColumn = false)
 {
     parent::__construct($table);
     if ($recursiveSort) {
         $table->enableRecursiveSort();
     }
     $this->columnToSort = $columnToSort;
     $this->naturalSort = $naturalSort;
     $this->order = strtolower($order);
     $this->isSecondaryColumnSortEnabled = $doSortBySecondaryColumn;
 }
Ejemplo n.º 14
0
 /**
  * Constructor.
  * 
  * @param DataTable $table The DataTable to filter.
  * @param array|string $columnsToFilter The columns whose values should be passed to the callback
  *                                      and then replaced with the callback's result.
  * @param callable $functionToApply The function to execute. Must take the column value as a parameter
  *                                  and return a value that will be used to replace the original.
  * @param array|null $functionParameters deprecated - use an [anonymous function](http://php.net/manual/en/functions.anonymous.php)
  *                                       instead.
  * @param array $extraColumnParameters Extra column values that should be passed to the callback, but
  *                                     shouldn't be replaced.
  */
 public function __construct($table, $columnsToFilter, $functionToApply, $functionParameters = null, $extraColumnParameters = array())
 {
     parent::__construct($table);
     $this->functionToApply = $functionToApply;
     $this->functionParameters = $functionParameters;
     if (!is_array($columnsToFilter)) {
         $columnsToFilter = array($columnsToFilter);
     }
     $this->columnsToFilter = $columnsToFilter;
     $this->extraColumnParameters = $extraColumnParameters;
 }
Ejemplo n.º 15
0
 /**
  * Constructor.
  * 
  * @param DataTable $table The table that will be filtered eventually.
  * @param int $truncateAfter The row index to truncate at. All rows passed this index will
  *                           be removed.
  * @param string $labelSummaryRow The label to use for the summary row. Defaults to
  *                                `Piwik::translate('General_Others')`.
  * @param string $columnToSortByBeforeTruncating The column to sort by before truncation, eg,
  *                                               `'nb_visits'`.
  * @param bool $filterRecursive If true executes this filter on all subtables descending from
  *                              `$table`.
  */
 public function __construct($table, $truncateAfter, $labelSummaryRow = null, $columnToSortByBeforeTruncating = null, $filterRecursive = true)
 {
     parent::__construct($table);
     $this->truncateAfter = $truncateAfter;
     if ($labelSummaryRow === null) {
         $labelSummaryRow = Piwik::translate('General_Others');
     }
     $this->labelSummaryRow = $labelSummaryRow;
     $this->columnToSortByBeforeTruncating = $columnToSortByBeforeTruncating;
     $this->filterRecursive = $filterRecursive;
 }
 /**
  * Constructor.
  * 
  * @param DataTable $table The DataTable that will eventually be filtered.
  * @param string|array $metadataToRead The metadata to read from each row and pass to the callback.
  * @param string $metadataToAdd The name of the metadata to add.
  * @param callable $functionToApply The callback to execute for each row. The result will be
  *                                  added as metadata with the name `$metadataToAdd`.
  * @param bool $applyToSummaryRow True if the callback should be applied to the summary row, false
  *                                if otherwise.
  */
 public function __construct($table, $metadataToRead, $metadataToAdd, $functionToApply, $applyToSummaryRow = true)
 {
     parent::__construct($table);
     $this->functionToApply = $functionToApply;
     if (!is_array($metadataToRead)) {
         $metadataToRead = array($metadataToRead);
     }
     $this->metadataToRead = $metadataToRead;
     $this->metadataToAdd = $metadataToAdd;
     $this->applyToSummaryRow = $applyToSummaryRow;
 }
 /**
  * Constructor.
  *
  * @param DataTable $table The DataTable instance that will be filtered.
  * @param string|array $columnsToRead The columns to read from each row and pass on to the callback.
  * @param string $metadataToAdd The name of the metadata field that will be added to each row.
  * @param callable $functionToApply The callback to apply for each row.
  * @param array $functionParameters deprecated - use an [anonymous function](http://php.net/manual/en/functions.anonymous.php)
  *                                  instead.
  * @param bool $applyToSummaryRow Whether the callback should be applied to the summary row or not.
  */
 public function __construct($table, $columnsToRead, $metadataToAdd, $functionToApply = null, $functionParameters = null, $applyToSummaryRow = true)
 {
     parent::__construct($table);
     if (!is_array($columnsToRead)) {
         $columnsToRead = array($columnsToRead);
     }
     $this->columnsToRead = $columnsToRead;
     $this->functionToApply = $functionToApply;
     $this->functionParameters = $functionParameters;
     $this->metadataToAdd = $metadataToAdd;
     $this->applyToSummaryRow = $applyToSummaryRow;
 }
Ejemplo n.º 18
0
 /**
  * Constructor.
  * 
  * @param DataTable $table The DataTable that will be filtered eventually.
  * @param array|string $columnsToFilter The column or array of columns that should be
  *                                      passed to the callback.
  * @param callback $function The callback that determines whether a row should be deleted
  *                           or not. Should return `true` if the row should be deleted.
  * @param array $functionParams deprecated - use an [anonymous function](http://php.net/manual/en/functions.anonymous.php)
  *                              instead.
  */
 public function __construct($table, $columnsToFilter, $function, $functionParams = array())
 {
     parent::__construct($table);
     if (!is_array($functionParams)) {
         $functionParams = array($functionParams);
     }
     if (!is_array($columnsToFilter)) {
         $columnsToFilter = array($columnsToFilter);
     }
     $this->function = $function;
     $this->columnsToFilter = $columnsToFilter;
     $this->functionParams = $functionParams;
 }
Ejemplo n.º 19
0
 /**
  * Constructor.
  *
  * @param DataTable $table The DataTable instance that will eventually be filtered.
  * @param array|string $columnsToRemove An array of column names or a comma-separated list of
  *                                      column names. These columns will be removed.
  * @param array|string $columnsToKeep An array of column names that should be kept or a
  *                                    comma-separated list of column names. Columns not in
  *                                    this list will be removed.
  * @param bool $deleteIfZeroOnly If true, columns will be removed only if their value is 0.
  */
 public function __construct($table, $columnsToRemove, $columnsToKeep = array(), $deleteIfZeroOnly = false)
 {
     parent::__construct($table);
     if (is_string($columnsToRemove)) {
         $columnsToRemove = $columnsToRemove == '' ? array() : explode(',', $columnsToRemove);
     }
     if (is_string($columnsToKeep)) {
         $columnsToKeep = $columnsToKeep == '' ? array() : explode(',', $columnsToKeep);
     }
     $this->columnsToRemove = $columnsToRemove;
     $this->columnsToKeep = array_flip($columnsToKeep);
     // flip so we can use isset instead of in_array
     $this->deleteIfZeroOnly = $deleteIfZeroOnly;
 }
Ejemplo n.º 20
0
 /**
  * Constructor.
  *
  * @param DataTable $table The DataTable that will be filtered eventually.
  * @param string $columnToFilter The name of the column whose value will determine whether
  *                               a row is deleted or not.
  * @param number|false $minimumValue The minimum column value. Rows with column values <
  *                                   this number will be deleted. If false,
  *                                   `$minimumPercentageThreshold` is used.
  * @param bool|float $minimumPercentageThreshold If supplied, column values must be a greater
  *                                               percentage of the sum of all column values than
  *                                               this precentage.
  */
 public function __construct($table, $columnToFilter, $minimumValue, $minimumPercentageThreshold = false)
 {
     parent::__construct($table);
     $this->columnToFilter = $columnToFilter;
     if ($minimumValue == 0) {
         if ($minimumPercentageThreshold === false) {
             $minimumPercentageThreshold = self::MINIMUM_SIGNIFICANT_PERCENTAGE_THRESHOLD;
         }
         $allValues = $table->getColumn($this->columnToFilter);
         $sumValues = array_sum($allValues);
         $minimumValue = $sumValues * $minimumPercentageThreshold;
     }
     $this->minimumValue = $minimumValue;
 }
 /**
  * Constructor.
  *
  * @param DataTable $table The DataTable that will eventually be filtered.
  * @param string $columnNameToAdd The name of the column to add the quotient value to.
  * @param string $columnValueToRead The name of the column that holds the dividend.
  * @param number|string $divisorValueOrDivisorColumnName
  *                           Either numeric value to use as the divisor for every row,
  *                           or the name of the column whose value should be used as the
  *                           divisor.
  * @param int $quotientPrecision The precision to use when rounding the quotient.
  * @param bool|number $shouldSkipRows Whether rows w/o the column to read should be skipped or not.
  * @param bool $getDivisorFromSummaryRow Whether to get the divisor from the summary row or the current
  *                                       row iteration.
  */
 public function __construct($table, $columnNameToAdd, $columnValueToRead, $divisorValueOrDivisorColumnName, $quotientPrecision = 0, $shouldSkipRows = false, $getDivisorFromSummaryRow = false)
 {
     parent::__construct($table);
     $this->table = $table;
     $this->columnValueToRead = $columnValueToRead;
     $this->columnNameToAdd = $columnNameToAdd;
     if (is_numeric($divisorValueOrDivisorColumnName)) {
         $this->totalValueUsedAsDivisor = $divisorValueOrDivisorColumnName;
     } else {
         $this->columnNameUsedAsDivisor = $divisorValueOrDivisorColumnName;
     }
     $this->quotientPrecision = $quotientPrecision;
     $this->shouldSkipRows = $shouldSkipRows;
     $this->getDivisorFromSummaryRow = $getDivisorFromSummaryRow;
 }
Ejemplo n.º 22
0
 /**
  * Constructor.
  *
  * @param DataTable $table The table that will be filtered.
  * @param int $labelSummaryRow The value of the label column for the new row.
  */
 public function __construct($table, $labelSummaryRow = DataTable::LABEL_SUMMARY_ROW)
 {
     parent::__construct($table);
     $this->labelSummaryRow = $labelSummaryRow;
 }
 /**
  * @param DataTable $table
  * @param $report
  */
 public function __construct($table, $report)
 {
     parent::__construct($table);
     $this->report = $report;
 }
Ejemplo n.º 24
0
 /**
  * Constructor.
  *
  * @param DataTable $table The table to pivot.
  * @param string $report The ID of the report being pivoted, eg, `'Referrers.getKeywords'`.
  * @param string $pivotByDimension The ID of the dimension to pivot by, eg, `'Referrers.Keyword'`.
  * @param string|false $pivotColumn The metric that should be displayed in the pivot table, eg, `'nb_visits'`.
  *                                  If `false`, the first non-label column is used.
  * @param false|int $pivotByColumnLimit The number of columns to limit the pivot table to.
  * @param bool $isFetchingBySegmentEnabled Whether to allow fetching by segment.
  * @throws Exception if pivoting the report by a dimension is unsupported.
  */
 public function __construct($table, $report, $pivotByDimension, $pivotColumn, $pivotByColumnLimit = false, $isFetchingBySegmentEnabled = true)
 {
     parent::__construct($table);
     Log::debug("PivotByDimension::%s: creating with [report = %s, pivotByDimension = %s, pivotColumn = %s, " . "pivotByColumnLimit = %s, isFetchingBySegmentEnabled = %s]", __FUNCTION__, $report, $pivotByDimension, $pivotColumn, $pivotByColumnLimit, $isFetchingBySegmentEnabled);
     $this->pivotColumn = $pivotColumn;
     $this->pivotByColumnLimit = $pivotByColumnLimit ?: self::getDefaultColumnLimit();
     $this->isFetchingBySegmentEnabled = $isFetchingBySegmentEnabled;
     $namesToId = Metrics::getMappingFromNameToId();
     $this->metricIndexValue = isset($namesToId[$this->pivotColumn]) ? $namesToId[$this->pivotColumn] : null;
     $this->setPivotByDimension($pivotByDimension);
     $this->setThisReportMetadata($report);
     $this->checkSupportedPivot();
 }
 /**
  * Constructor.
  *
  * @param DataTable $table The table to eventually filter.
  */
 public function __construct($table, $firstLevelSearchEnginesTable, $idSubtable = null)
 {
     parent::__construct($table);
     $this->firstLevelSearchEnginesTable = $firstLevelSearchEnginesTable;
     $this->idSubtable = $idSubtable;
 }
Ejemplo n.º 26
0
 /**
  * @param DataTable $table
  */
 public function __construct($table)
 {
     parent::__construct($table);
     $this->columnToDecode = 'label';
 }
 /**
  * Constructor.
  *
  * @param DataTable $table The DataTable instance that will be filtered.
  * @param string $metadataToRemove The name of the metadata field that will be removed from each row.
  */
 public function __construct($table, $metadataToRemove)
 {
     parent::__construct($table);
     $this->metadataToRemove = $metadataToRemove;
 }
 /**
  * Constructor.
  * 
  * @param DataTable $table The table to eventually filter.
  * @param bool $deleteRowsWithNoVisit Whether to delete rows with no visits or not.
  */
 public function __construct($table, $deleteRowsWithNoVisit = true)
 {
     $this->deleteRowsWithNoVisit = $deleteRowsWithNoVisit;
     parent::__construct($table);
 }
 /**
  * @param DataTable $table
  * @param string $segment
  * @param array $mapping
  */
 public function __construct($table, $segment, $mapping)
 {
     parent::__construct($table);
     $this->segment = $segment;
     $this->mapping = $mapping;
 }
 /**
  * Constructor.
  *
  * @param DataTable $table The table to eventually filter.
  */
 public function __construct($table, $idDimension)
 {
     parent::__construct($table);
     $this->idDimension = $idDimension;
 }