diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-03-28 03:42:39 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-03-28 03:42:40 +0400 |
commit | ae4b03163792f0b6e933933e5d37df87dc3fd566 (patch) | |
tree | d1d7510a9728f587d3d63ebd03e4ecf3d904838b /core/DataTable/Filter/Pattern.php | |
parent | 158c2150f5f2e13ece459b8d131244c11b763997 (diff) |
Mass conversion of all files to the newly agreed coding standard: PSR 1/2
Converting Piwik core source files, PHP, JS, TPL, CSS
More info: http://piwik.org/participate/coding-standards/
Diffstat (limited to 'core/DataTable/Filter/Pattern.php')
-rw-r--r-- | core/DataTable/Filter/Pattern.php | 127 |
1 files changed, 62 insertions, 65 deletions
diff --git a/core/DataTable/Filter/Pattern.php b/core/DataTable/Filter/Pattern.php index 92f8b2b3d5..4a1ef8fd99 100644 --- a/core/DataTable/Filter/Pattern.php +++ b/core/DataTable/Filter/Pattern.php @@ -1,89 +1,86 @@ <?php /** * Piwik - Open source web analytics - * + * * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - * + * * @category Piwik * @package Piwik */ /** * Delete all rows for which the given $columnToFilter do not contain the $patternToSearch - * This filter is to be used on columns containing strings. + * This filter is to be used on columns containing strings. * Example: from the keyword report, keep only the rows for which the label contains "piwik" - * + * * @package Piwik * @subpackage Piwik_DataTable */ class Piwik_DataTable_Filter_Pattern extends Piwik_DataTable_Filter { - private $columnToFilter; - private $patternToSearch; - private $patternToSearchQuoted; + private $columnToFilter; + private $patternToSearch; + private $patternToSearchQuoted; private $invertedMatch; - /** - * @param Piwik_DataTable $table - * @param string $columnToFilter - * @param string $patternToSearch - * @param bool $invertedMatch - */ - public function __construct( $table, $columnToFilter, $patternToSearch, $invertedMatch = false ) - { - parent::__construct($table); - $this->patternToSearch = $patternToSearch; - $this->patternToSearchQuoted = self::getPatternQuoted($patternToSearch); - $this->columnToFilter = $columnToFilter; + /** + * @param Piwik_DataTable $table + * @param string $columnToFilter + * @param string $patternToSearch + * @param bool $invertedMatch + */ + 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; - } + } - /** - * Helper method to return the given pattern quoted - * - * @param string $pattern - * @return string - */ - static public function getPatternQuoted( $pattern ) - { - return '/'. str_replace('/', '\/', $pattern) .'/'; - } + /** + * Helper method to return the given pattern quoted + * + * @param string $pattern + * @return string + */ + static public function getPatternQuoted($pattern) + { + return '/' . str_replace('/', '\/', $pattern) . '/'; + } - /** - * Performs case insensitive match - * - * @param string $pattern - * @param string $patternQuoted - * @param string $string - * @param bool $invertedMatch - * @return int - */ - static public function match($pattern, $patternQuoted, $string, $invertedMatch) - { - return @preg_match($patternQuoted . "i", $string) == 1 ^ $invertedMatch; - } + /** + * Performs case insensitive match + * + * @param string $pattern + * @param string $patternQuoted + * @param string $string + * @param bool $invertedMatch + * @return int + */ + static public function match($pattern, $patternQuoted, $string, $invertedMatch) + { + return @preg_match($patternQuoted . "i", $string) == 1 ^ $invertedMatch; + } - /** - * @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. - $value = $row->getColumn($this->columnToFilter); - if($value === false) - { - $value = $row->getMetadata($this->columnToFilter); - } - if( !self::match($this->patternToSearch, $this->patternToSearchQuoted, $value, $this->invertedMatch)) - { - $table->deleteRow($key); - } - } - } + /** + * @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. + $value = $row->getColumn($this->columnToFilter); + if ($value === false) { + $value = $row->getMetadata($this->columnToFilter); + } + if (!self::match($this->patternToSearch, $this->patternToSearchQuoted, $value, $this->invertedMatch)) { + $table->deleteRow($key); + } + } + } } |