Fixed bug #7896: Hide the page browser if not enough entries are available (Thanks...
[Packages/TYPO3.CMS.git] / typo3 / class.db_list.inc
index c7dcce7..ba4d577 100644 (file)
@@ -178,7 +178,7 @@ class recordList extends t3lib_recordList {
                $this->counter=0;
                $this->JScode='';
                $this->HTMLcode='';
-        
+
                        // limits
                if(isset($this->modTSconfig['properties']['itemsLimitPerTable'])) {
                        $this->itemsLimitPerTable = t3lib_div::intInRange(intval($this->modTSconfig['properties']['itemsLimitPerTable']), 1, 10000);
@@ -186,7 +186,7 @@ class recordList extends t3lib_recordList {
                if(isset($this->modTSconfig['properties']['itemsLimitSingleTable'])) {
                        $this->itemsLimitSingleTable = t3lib_div::intInRange(intval($this->modTSconfig['properties']['itemsLimitSingleTable']), 1, 10000);
                }
-               
+
                        // Set select levels:
                $sL=intval($this->searchLevels);
                $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
@@ -210,6 +210,10 @@ class recordList extends t3lib_recordList {
                        // Save modified user uc
                        $GLOBALS['BE_USER']->uc['moduleData']['db_list.php'] = $this->tablesCollapsed;
                        $GLOBALS['BE_USER']->writeUC($GLOBALS['BE_USER']->uc);
+                       if (t3lib_div::_GP('returnUrl')) {
+                               $location = t3lib_div::_GP('returnUrl');
+                               t3lib_utility_Http::redirect($location);
+                       }
                }
 
                if ($sL>0)      {
@@ -458,8 +462,15 @@ class recordList extends t3lib_recordList {
         * @param       string          Field list to select, * for all (for "SELECT [fieldlist] FROM ...")
         * @return      array           Returns query array
         */
-       function makeQueryArray($table, $id, $addWhere="",$fieldList='*')       {
-               global $TCA;
+       function makeQueryArray($table, $id, $addWhere='', $fieldList='*')      {
+               global $TCA, $TYPO3_CONF_VARS;
+
+               $hookObjectsArr = array();
+               if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'])) {
+                       foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'] as $classRef) {
+                               $hookObjectsArr[] = t3lib_div::getUserObj($classRef);
+                       }
+               }
 
                        // Set ORDER BY:
                $orderBy = ($TCA[$table]['ctrl']['sortby']) ? 'ORDER BY '.$TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby'];
@@ -494,6 +505,19 @@ class recordList extends t3lib_recordList {
                        'LIMIT' => $limit
                );
 
+                       // Apply hook as requested in http://bugs.typo3.org/view.php?id=4361
+               foreach ($hookObjectsArr as $hookObj) {
+                       if (method_exists($hookObj, 'makeQueryArray_post')) {
+                               $_params = array(
+                                       'orderBy' => $orderBy,
+                                       'limit' => $limit,
+                                       'pC' => $pC,
+                                       'search' => $search,
+                               );
+                               $hookObj->makeQueryArray_post($queryParts, $this, $table, $id, $addWhere, $fieldList, $_params);
+                       }
+               }
+
                        // Return query:
                return $queryParts;
        }
@@ -795,8 +819,7 @@ class recordList extends t3lib_recordList {
                                $returnUrl = '&returnUrl='.rawurlencode($this->listURL());
                                $location = $GLOBALS['BACK_PATH'].'alt_doc.php?'.$params.$returnUrl;
 
-                               header('Location: '.t3lib_div::locationHeaderUrl($location));
-                               exit;
+                               t3lib_utility_Http::redirect($location);
                        }
                }
        }