[TASK] Remember search filter in PageModule
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / PageLayoutController.php
index 8b0d468..1ba40b2 100644 (file)
@@ -258,6 +258,9 @@ class PageLayoutController {
                $this->MCONF = $GLOBALS['MCONF'];
                $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
                $this->backPath = $GLOBALS['BACK_PATH'];
+               // Get session data
+               $sessionData = $GLOBALS['BE_USER']->getSessionData(\TYPO3\CMS\Recordlist\RecordList::class);
+               $this->search_field = !empty($sessionData['search_field']) ? $sessionData['search_field'] : '';
                // GPvars:
                $this->id = (int)GeneralUtility::_GP('id');
                $this->pointer = GeneralUtility::_GP('pointer');
@@ -266,11 +269,20 @@ class PageLayoutController {
                $this->popView = GeneralUtility::_GP('popView');
                $this->edit_record = GeneralUtility::_GP('edit_record');
                $this->new_unique_uid = GeneralUtility::_GP('new_unique_uid');
-               $this->search_field = GeneralUtility::_GP('search_field');
+               if (!empty(GeneralUtility::_GP('search_field'))) {
+                       $this->search_field = GeneralUtility::_GP('search_field');
+                       $sessionData['search_field'] = $this->search_field;
+               }
                $this->search_levels = GeneralUtility::_GP('search_levels');
                $this->showLimit = GeneralUtility::_GP('showLimit');
                $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
                $this->externalTables = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables'];
+               if (!empty(GeneralUtility::_GP('search')) && empty(GeneralUtility::_GP('search_field'))) {
+                       $this->search_field = '';
+                       $sessionData['search_field'] = $this->search_field;
+               }
+               // Store session data
+               $GLOBALS['BE_USER']->setAndSaveSessionData(\TYPO3\CMS\Recordlist\RecordList::class, $sessionData);
                // Load page info array:
                $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
                // Initialize menu