/** * Hook called after the dataTable has been loaded from the API * Can be used to add, delete or modify the data freshly loaded */ protected function postDataTableLoadedFromAPI() { if (empty($this->dataTable)) { return false; } // First, filters that delete rows foreach ($this->queuedFiltersPriority as $filter) { $filterName = $filter[0]; $filterParameters = $filter[1]; $this->dataTable->filter($filterName, $filterParameters); } if (0 == Piwik_Common::getRequestVar('disable_generic_filters', '0', 'string')) { // Second, generic filters (Sort, Limit, Replace Column Names, etc.) $requestString = $this->getRequestString(); $request = Piwik_API_Request::getRequestArrayFromString($requestString); if (!empty($this->variablesDefault['enable_sort']) && $this->variablesDefault['enable_sort'] === 'false') { $request['filter_sort_column'] = $request['filter_sort_order'] = ''; } $genericFilter = new Piwik_API_DataTableGenericFilter($request); $genericFilter->filter($this->dataTable); } // Finally, apply datatable filters that were queued (should be 'presentation' filters that do not affect the number of rows) foreach ($this->queuedFilters as $filter) { $filterName = $filter[0]; $filterParameters = $filter[1]; $this->dataTable->filter($filterName, $filterParameters); } }
protected function handleDataTable($datatable) { // if the flag disable_generic_filters is defined we skip the generic filters if('false' == Piwik_Common::getRequestVar('disable_generic_filters', 'false', 'string', $this->request)) { $genericFilter = new Piwik_API_DataTableGenericFilter($this->request); $genericFilter->filter($datatable); } // we automatically safe decode all datatable labels (against xss) $datatable->queueFilter('SafeDecodeLabel'); // if the flag disable_queued_filters is defined we skip the filters that were queued if(Piwik_Common::getRequestVar('disable_queued_filters', 'false', 'string', $this->request) == 'false') { $datatable->applyQueuedFilters(); } return $this->getRenderedDataTable($datatable); }
/** * Handles the given data table * * @param Piwik_DataTable $datatable * @return string */ protected function handleDataTable($datatable) { // if requested, flatten nested tables if (Piwik_Common::getRequestVar('flat', '0', 'string', $this->request) == '1') { $flattener = new Piwik_API_DataTableManipulator_Flattener($this->apiModule, $this->apiMethod, $this->request); if (Piwik_Common::getRequestVar('include_aggregate_rows', '0', 'string', $this->request) == '1') { $flattener->includeAggregateRows(); } $datatable = $flattener->flatten($datatable); } // if the flag disable_generic_filters is defined we skip the generic filters if (0 == Piwik_Common::getRequestVar('disable_generic_filters', '0', 'string', $this->request)) { $genericFilter = new Piwik_API_DataTableGenericFilter($this->request); $genericFilter->filter($datatable); } // we automatically safe decode all datatable labels (against xss) $datatable->queueFilter('SafeDecodeLabel'); // if the flag disable_queued_filters is defined we skip the filters that were queued if (Piwik_Common::getRequestVar('disable_queued_filters', 'false', 'string', $this->request) == 'false') { $datatable->applyQueuedFilters(); } // use the ColumnDelete filter if hideColumns/showColumns is provided (must be done // after queued filters are run so processed metrics can be removed, too) $hideColumns = Piwik_Common::getRequestVar('hideColumns', '', 'string', $this->request); $showColumns = Piwik_Common::getRequestVar('showColumns', '', 'string', $this->request); if ($hideColumns !== '' || $showColumns !== '') { $datatable->filter('ColumnDelete', array($hideColumns, $showColumns)); } // apply label filter: only return a single row matching the label parameter $label = Piwik_Common::getRequestVar('label', '', 'string', $this->request); if ($label !== '') { $label = Piwik_Common::unsanitizeInputValue($label); $filter = new Piwik_API_DataTableManipulator_LabelFilter($this->apiModule, $this->apiMethod, $this->request); $datatable = $filter->filter($label, $datatable); } return $this->getRenderedDataTable($datatable); }
/** * Hook called after the dataTable has been loaded from the API * Can be used to add, delete or modify the data freshly loaded * * @return bool */ protected function postDataTableLoadedFromAPI() { if (empty($this->dataTable)) { return false; } // deal w/ table metadata if ($this->dataTable instanceof Piwik_DataTable) { $this->viewProperties['metadata'] = $this->dataTable->getAllTableMetadata(); if (isset($this->viewProperties['metadata'][Piwik_DataTable::ARCHIVED_DATE_METADATA_NAME])) { $this->viewProperties['metadata'][Piwik_DataTable::ARCHIVED_DATE_METADATA_NAME] = $this->makePrettyArchivedOnText(); } } // First, filters that delete rows foreach ($this->queuedFiltersPriority as $filter) { $filterName = $filter[0]; $filterParameters = $filter[1]; $this->dataTable->filter($filterName, $filterParameters); } if (!$this->areGenericFiltersDisabled()) { // Second, generic filters (Sort, Limit, Replace Column Names, etc.) $requestString = $this->getRequestString(); $request = Piwik_API_Request::getRequestArrayFromString($requestString); if (!empty($this->variablesDefault['enable_sort']) && $this->variablesDefault['enable_sort'] === 'false') { $request['filter_sort_column'] = $request['filter_sort_order'] = ''; } $genericFilter = new Piwik_API_DataTableGenericFilter($request); $genericFilter->filter($this->dataTable); } if (!$this->areQueuedFiltersDisabled()) { // Finally, apply datatable filters that were queued (should be 'presentation' filters that // do not affect the number of rows) foreach ($this->queuedFilters as $filter) { $filterName = $filter[0]; $filterParameters = $filter[1]; $this->dataTable->filter($filterName, $filterParameters); } } return true; }
protected function handleDataTable($datatable) { // if the flag disable_generic_filters is defined we skip the generic filters if (0 == Piwik_Common::getRequestVar('disable_generic_filters', '0', 'string', $this->request)) { $genericFilter = new Piwik_API_DataTableGenericFilter($this->request); $genericFilter->filter($datatable); } // we automatically safe decode all datatable labels (against xss) $datatable->queueFilter('SafeDecodeLabel'); // if the flag disable_queued_filters is defined we skip the filters that were queued if (Piwik_Common::getRequestVar('disable_queued_filters', 'false', 'string', $this->request) == 'false') { $datatable->applyQueuedFilters(); } // apply label filter: only return a single row matching the label parameter $label = Piwik_Common::getRequestVar('label', '', 'string', $this->request); if ($label !== '') { // the label can be passed with html entities. // we remove them here and try with and without them in the label filter. $label = html_entity_decode($label); $filter = new Piwik_API_DataTableLabelFilter(); $datatable = $filter->filter($label, $datatable, $this->apiModule, $this->apiMethod, $this->request); } return $this->getRenderedDataTable($datatable); }