Ejemplo n.º 1
0
 /** @test */
 public function resetResetsFiltersOfThisBoxAndSetsIsSubmittedFilterboxToFalse()
 {
     $filterbox = new Tx_PtExtlist_Domain_Model_Filter_Filterbox();
     $filterbox->_injectFilterboxConfiguration($this->filterBoxConfigurationMock);
     $filterbox->isSubmittedFilterbox();
     $filter = $this->getMock('Tx_PtExtlist_Tests_Domain_Model_Filter_Stubs_FilterStub', array('reset'), array(), '', false);
     $filter->expects($this->once())->method('reset');
     $filterbox->addItem($filter, 'testfilter');
     $filterbox->reset();
     $this->assertEquals($filterbox->isSubmittedFilterbox(), false);
 }
 /**
  * Renders submit action
  *
  * @return String
  */
 public function submitAction()
 {
     /**
      * Some explanation on what happens here:
      *
      * 1. We check whether filter validates. If not, we set error in template and forward to 'show'
      * 2. Whenever a filter is submitted, this action is called. Previously active state of filter is stored in session, so
      *	 we have to reset this. Active state for filterbox is set in init() of filterbox again, if GP vars are available.
      * 3. We have to reset the pagers, as changed filter state normally means changed pager state
      * 4. We check, whether we have a redirect on submit configured for this filter and do the redirect if we have done so
      */
     if (!$this->filterbox->validate()) {
         $this->view->assign('filtersDontValidate', true);
         $this->forward('show');
     }
     $this->filterboxCollection->resetIsSubmittedFilterbox();
     $this->resetPagers();
     if ($this->filterbox->getFilterboxConfiguration()->getResetToDefaultSortingOnSubmit()) {
         $this->resetSorter();
     }
     // check whether we have a redirect on submit configured for this filter
     if ($this->filterbox->isSubmittedFilterbox() && $this->filterbox->getFilterboxConfiguration()->doRedirectOnSubmit()) {
         $this->redirect($this->filterbox->getFilterboxConfiguration()->getRedirectOnSubmitActionName(), $this->filterbox->getFilterboxConfiguration()->getRedirectOnSubmitControllerName(), null, null, $this->filterbox->getFilterboxConfiguration()->getRedirectOnSubmitPageId());
     }
     if ($this->configurationBuilder->getSettings('redirectOnSubmitFilter') == 1) {
         /**
          * Whenever a filter is not first widget on page, we have to do a redirect
          * for reset pager and all other components whenever a filter values changed
          */
         $this->redirect('show');
     } else {
         $this->forward('show');
     }
 }