/** * @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(); }
/** * 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); } }
/** * 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); } }
/** * 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); } } }
/** * @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); } } }
/** * Will search in the DataTable for a Label matching the searched string * and return only the matching row, or an empty datatable */ protected function getFilterPageDatatableSearch( $callBackParameters, $search, $actionType, $table = false, $searchTree = false, $searchCurrentLevel = 0 ) { if($table === false) { $table = call_user_func_array(array('Piwik_Archive', 'getDataTableFromArchive'), $callBackParameters); } if($searchTree === false) { if($actionType == Piwik_Tracker_Action::TYPE_ACTION_NAME) { $searchedString = Piwik_Common::unsanitizeInputValue($search); } else { $searchedString = Piwik_Tracker_Action::excludeQueryParametersFromUrl($search, $idSite = $callBackParameters[1]); } $searchTree = Piwik_Actions::getActionExplodedNames($searchedString, $actionType); } if(!($table instanceof Piwik_DataTable)) { throw new Exception("For this API function, date=lastN or date=previousM is not supported"); } $rows = $table->getRows(); $labelSearch = $searchTree[$searchCurrentLevel]; $isEndSearch = ((count($searchTree)-1) == $searchCurrentLevel); foreach($rows as $key => $row) { $found = false; // Found a match at this level $label = $row->getColumn('label'); if($label === $labelSearch) { // Is this the end of the search tree? then we found the requested row if($isEndSearch) { // var_dump($label); var_dump($labelSearch); exit; $table = new Piwik_DataTable(); $table->addRow($row); return $table; } // If we still need to search deeper, call search $idSubTable = $row->getIdSubDataTable(); // Update the idSubtable in the callback parameter list, to fetch this subtable from the archive $callBackParameters[6] = $idSubTable; $subTable = call_user_func_array(array('Piwik_Archive', 'getDataTableFromArchive'), $callBackParameters); $found = $this->getFilterPageDatatableSearch($callBackParameters, $search, $actionType, $subTable, $searchTree, $searchCurrentLevel+1); if($found) { return $found; } } if(!$found) { $table->deleteRow($key); } } // Case the DataTable was searched but nothing was found, @see getFilterPageDatatableSearch() if($searchCurrentLevel == 0) { return new Piwik_DataTable; } return false; }