/** * Creates an instance of a filter for a given configuration * * @param Tx_PtExtlist_Domain_Configuration_Filters_FilterConfig $filterConfig * @return Tx_PtExtlist_Domain_Model_Filter_FilterInterface */ public function createInstance(Tx_PtExtlist_Domain_Configuration_Filters_FilterConfig $filterConfig) { $filter = $this->createFilterObject($filterConfig->getFilterClassName()); /* @var $filter Tx_PtExtlist_Domain_Model_Filter_FilterInterface */ $filter->_injectFilterConfig($filterConfig); $sessionPersistenceManager = $this->sessionPersistenceManagerBuilder->getInstance(); // TODO check whether filter interface should extend session persistable interface $sessionPersistenceManager->registerObjectAndLoadFromSession($filter); $filter->_injectDataBackend($this->dataBackendFactory->getDataBackendInstanceByListIdentifier($filterConfig->getListIdentifier())); $filter->init(); return $filter; }
/** * Determine the dataProvider to use for filter options * * TODO: Test me! * @param Tx_PtExtlist_Domain_Configuration_Filters_FilterConfig $filterConfig * @return string dataProviderClass */ protected function determineDataProviderClass(Tx_PtExtlist_Domain_Configuration_Filters_FilterConfig $filterConfig) { if ($filterConfig->getSettings('dataProviderClassName')) { $dataProviderClassName = $filterConfig->getSettings('dataProviderClassName'); } else { if ($filterConfig->getSettings('options')) { $dataProviderClassName = 'Tx_PtExtlist_Domain_Model_Filter_DataProvider_ExplicitData'; } else { $dataProviderClassName = 'Tx_PtExtlist_Domain_Model_Filter_DataProvider_GroupData'; } } Tx_PtExtbase_Assertions_Assert::isTrue(class_exists($dataProviderClassName), array('message' => 'The defined DataProviderClass "' . $dataProviderClassName . '" does not exist! 1283535558')); return $dataProviderClassName; }
/** * @param Tx_PtExtlist_Domain_QueryObject_Query $groupDataQuery * @param array $excludeFilters * @param Tx_PtExtlist_Domain_Configuration_Filters_FilterConfig $filterConfig * @return string */ protected function buildGroupDataQuery(Tx_PtExtlist_Domain_QueryObject_Query $groupDataQuery, $excludeFilters = array(), Tx_PtExtlist_Domain_Configuration_Filters_FilterConfig $filterConfig = null) { $this->buildQuery(); $selectPart = 'SELECT ' . $this->queryInterpreter->getSelectPart($groupDataQuery); $fromPart = $this->listQueryParts['FROM']; $groupPart = count($groupDataQuery->getGroupBy()) > 0 ? ' GROUP BY ' . $this->queryInterpreter->getGroupBy($groupDataQuery) : ''; $sortingPart = count($groupDataQuery->getSortings()) > 0 ? ' ORDER BY ' . $this->queryInterpreter->getSorting($groupDataQuery) : ''; /** * If this list is grouped. There are two cases * 1. We want to show the rowCount. In this case we have to build the list first and then use this list as * source to calculate the selectable rows and the count. This has the drawback, that options are not displayed, if grouped within the list. * 2. We do not need the rowCount. In this case, we exchange the original grouping fields with the fields needed by the filter. */ if ($this->listQueryParts['GROUPBY'] && $filterConfig->getShowRowCount()) { $selectPart = $this->convertTableFieldToAlias($selectPart); $groupPart = $this->convertTableFieldToAlias($groupPart); $sortingPart = $this->convertTableFieldToAlias($sortingPart); $filterWherePart = $this->buildWherePart($excludeFilters); $filterWherePart = $filterWherePart ? ' WHERE ' . $filterWherePart . " \n" : ''; // if the list has a group by clause itself, we have to use the listQuery as subQuery $fromPart = ' FROM (' . $this->listQueryParts['SELECT'] . $this->listQueryParts['FROM'] . $filterWherePart . $this->listQueryParts['GROUPBY'] . ') AS SUBQUERY '; unset($filterWherePart); // we confined the subquery, so we dont need this in the group query } else { $filterWherePart = $this->buildWherePart($excludeFilters); if ($filterWherePart != '') { $filterWherePart = ' WHERE ' . $filterWherePart . " \n"; } } $query = implode(" \n", array($selectPart, $fromPart, $filterWherePart, $groupPart, $sortingPart)); $query = $this->processQueryWithFluid($query); return $query; }
public function testGetLabel() { $filterConfig = new Tx_PtExtlist_Domain_Configuration_Filters_FilterConfig($this->configurationBuilderMock, $this->filterSettings, 'test'); $this->assertEquals($filterConfig->getLabel(), $this->filterSettings['label']); }
protected function checkFilter(Tx_PtExtlist_Domain_Configuration_Filters_FilterConfig $filter) { $groups = $filter->getAccessGroups(); if (!is_array($groups)) { return true; } // for testing purposes if (empty($groups)) { return true; } return $this->compareAccess($groups); }
/** * Returns an array of fields to be used for rendering breadcrumb message. * * Per default, this is the label of the filter and its value. Feel free to add * further values in your own filter classes * * @return array */ protected function getFieldsForBreadcrumb() { return array('label' => $this->filterConfig->getLabel(), 'value' => $this->getDisplayValue()); }