[BUGFIX] stdWrap numRows fails due to wrong SELECT clause
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_fullsearch.php
index df35070..5d54fa9 100644 (file)
  * Class used in module tools/dbint (advanced search) and which may hold code specific for that module
  * However the class has a general principle in it which may be used in the web/export module.
  *
- * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
- * @coauthor   Jo Hasenau <info@cybercraft.de>
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @coauthor Jo Hasenau <info@cybercraft.de>
  */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *
- *
- *   88: class t3lib_fullsearch
- *  103:        function form()
- *  117:        function makeStoreControl()
- *  156:        function initStoreArray()
- *  176:        function cleanStoreQueryConfigs($storeQueryConfigs,$storeArray)
- *  193:        function addToStoreQueryConfigs($storeQueryConfigs,$index)
- *  209:        function saveQueryInAction($uid)
- *  256:        function loadStoreQueryConfigs($storeQueryConfigs,$storeIndex,$writeArray)
- *  272:        function procesStoreControl()
- *  344:        function queryMaker()
- *  414:        function getQueryResultCode($mQ,$res,$table)
- *  534:        function csvValues($row, $delim=',', $quote='"', $conf=array(), $table='')
- *  550:        function tableWrap($str)
- *  559:        function search()
- *  614:        function resultRowDisplay($row,$conf,$table)
- *  662:        function getProcessedValueExtra($table, $fN, $fV, $conf, $splitString)
- *  781:        function getTreeList($id, $depth, $begin = 0, $perms_clause)
- *  818:        function makeValueList($fN, $fV, $conf, $table, $splitString)
- * 1028:        function resultRowTitles($row,$conf,$table)
- * 1058:        function csvRowTitles($row, $conf, $table)
- *
- * TOTAL FUNCTIONS: 19
- * (This index is automatically created/updated by the extension "extdeveval")
- *
- */
-
 
 /**
  * Class used in module tools/dbint (advanced search) and which may hold code specific for that module
  * However the class has a general principle in it which may be used in the web/export module.
  *
- * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
  */
@@ -86,11 +55,10 @@ class t3lib_fullsearch {
                $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_t3lib_fullsearch.xml');
        }
 
-
        /**
         * [Describe function...]
         *
-        * @return      [type]          ...
+        * @return string
         */
        function form() {
                $out = '
@@ -104,7 +72,7 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @return      [type]          ...
+        * @return string
         */
        function makeStoreControl() {
                        // Load/Save
@@ -142,7 +110,7 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @return      [type]          ...
+        * @return array
         */
        function initStoreArray() {
                $storeArray = array(
@@ -160,9 +128,9 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $storeQueryConfigs: ...
-        * @param       [type]          $storeArray: ...
-        * @return      [type]          ...
+        * @param array $storeQueryConfigs
+        * @param array $storeArray
+        * @return array
         */
        function cleanStoreQueryConfigs($storeQueryConfigs, $storeArray) {
                if (is_array($storeQueryConfigs)) {
@@ -178,9 +146,9 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $storeQueryConfigs: ...
-        * @param       [type]          $index: ...
-        * @return      [type]          ...
+        * @param array $storeQueryConfigs
+        * @param integer $index
+        * @return array
         */
        function addToStoreQueryConfigs($storeQueryConfigs, $index) {
                $keyArr = explode(',', $this->storeList);
@@ -194,8 +162,8 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $uid: ...
-        * @return      [type]          ...
+        * @param integer $uid
+        * @return integer
         */
        function saveQueryInAction($uid) {
                if (t3lib_extMgm::isLoaded('sys_action')) {
@@ -208,7 +176,7 @@ class t3lib_fullsearch {
                        $qOK = 0;
                                // Show query
                        if ($saveArr['queryTable']) {
-                               /* @var t3lib_queryGenerator */
+                               /** @var t3lib_queryGenerator */
                                $qGen = t3lib_div::makeInstance('t3lib_queryGenerator');
                                $qGen->init('queryConfig', $saveArr['queryTable']);
                                $qGen->makeSelectorTable($saveArr);
@@ -240,10 +208,10 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $storeQueryConfigs: ...
-        * @param       [type]          $storeIndex: ...
-        * @param       [type]          $writeArray: ...
-        * @return      [type]          ...
+        * @param array $storeQueryConfigs
+        * @param integer $storeIndex
+        * @param array $writeArray
+        * @return array
         */
        function loadStoreQueryConfigs($storeQueryConfigs, $storeIndex, $writeArray) {
                if ($storeQueryConfigs[$storeIndex]) {
@@ -258,7 +226,7 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @return      [type]          ...
+        * @return string
         */
        function procesStoreControl() {
                $storeArray = $this->initStoreArray();
@@ -334,7 +302,8 @@ class t3lib_fullsearch {
                                                't3lib_FlashMessage',
                                                sprintf($GLOBALS['LANG']->getLL('query_removed'), htmlspecialchars($storeArray[$storeControl['STORE']]))
                                        );
-                                       unset($storeArray[$storeControl['STORE']]); // Removing
+                                               // Removing
+                                       unset($storeArray[$storeControl['STORE']]);
                                        $saveStoreArray = 1;
                                }
                        }
@@ -343,7 +312,8 @@ class t3lib_fullsearch {
                        }
                }
                if ($saveStoreArray) {
-                       unset($storeArray[0]); // making sure, index 0 is not set!
+                               // Making sure, index 0 is not set!
+                       unset($storeArray[0]);
                        $writeArray['storeArray'] = serialize($storeArray);
                        $writeArray['storeQueryConfigs'] = serialize($this->cleanStoreQueryConfigs($storeQueryConfigs, $storeArray));
                        $GLOBALS['SOBE']->MOD_SETTINGS = t3lib_BEfunc::getModuleData($GLOBALS['SOBE']->MOD_MENU, $writeArray, $GLOBALS['SOBE']->MCONF['name'], 'ses');
@@ -354,7 +324,7 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @return      [type]          ...
+        * @return string
         */
        function queryMaker() {
                $output = '';
@@ -371,7 +341,6 @@ class t3lib_fullsearch {
                        $output .= $GLOBALS['SOBE']->doc->spacer(20);
                }
 
-
                        // Query Maker:
                $qGen = t3lib_div::makeInstance('t3lib_queryGenerator');
                $qGen->init('queryConfig', $GLOBALS['SOBE']->MOD_SETTINGS['queryTable']);
@@ -389,7 +358,6 @@ class t3lib_fullsearch {
                                        // Show query
                                $qGen->enablePrefix = 1;
                                $qString = $qGen->getQuery($qGen->queryConfig);
-                               //                              debug($qGen->queryConfig);
 
                                switch ($mQ) {
                                        case 'count':
@@ -424,10 +392,10 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $mQ: ...
-        * @param       [type]          $res: ...
-        * @param       [type]          $table: ...
-        * @return      [type]          ...
+        * @param string $mQ
+        * @param pointer $res
+        * @param string $table
+        * @return string
         */
        function getQueryResultCode($mQ, $res, $table) {
                $out = '';
@@ -546,12 +514,12 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $row: ...
-        * @param       [type]          $delim: ...
-        * @param       [type]          $quote: ...
-        * @param       [type]          $conf: ...
-        * @param       [type]          $table: ...
-        * @return      [type]          ...
+        * @param array $row
+        * @param string $delim
+        * @param string $quote
+        * @param array $conf
+        * @param string $table
+        * @return string A single line of CSV
         */
        function csvValues($row, $delim = ',', $quote = '"', $conf = array(), $table = '') {
                $valueArray = $row;
@@ -566,8 +534,8 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $str: ...
-        * @return      [type]          ...
+        * @param string $str
+        * @return string
         */
        function tableWrap($str) {
                return '<table border="0" cellpadding="10" cellspacing="0" class="bgColor4"><tr><td nowrap><pre>' . $str . '</pre></td></tr></table>';
@@ -576,7 +544,7 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @return      [type]          ...
+        * @return string
         */
        function search() {
                $SET = $GLOBALS['SOBE']->MOD_SETTINGS;
@@ -591,7 +559,7 @@ class t3lib_fullsearch {
                                t3lib_div::loadTCA($table);
                                $conf = $GLOBALS['TCA'][$table];
 
-                                       // avoid querying tables with no columns
+                                       // Avoid querying tables with no columns
                                if (empty($conf['columns'])) {
                                        continue;
                                }
@@ -628,10 +596,10 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $row: ...
-        * @param       [type]          $conf: ...
-        * @param       [type]          $table: ...
-        * @return      [type]          ...
+        * @param array $row
+        * @param array $conf
+        * @param string $table
+        * @return string
         */
        function resultRowDisplay($row, $conf, $table) {
                static $even = FALSE;
@@ -688,12 +656,12 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $table: ...
-        * @param       [type]          $fN: ...
-        * @param       [type]          $fV: ...
-        * @param       [type]          $conf: ...
-        * @param       [type]          $splitString: ...
-        * @return      [type]          ...
+        * @param string $table
+        * @param string $fN
+        * @param string $fV
+        * @param array $conf Not used
+        * @param string $splitString
+        * @return string
         */
        function getProcessedValueExtra($table, $fN, $fV, $conf, $splitString) {
                        // Analysing the fields in the table.
@@ -804,15 +772,15 @@ class t3lib_fullsearch {
                return $out;
        }
 
-       /*
-       * [Describe function...]
-       *
-       * @param        [type]          $qString: ...
-       * @param        [type]          $depth: ...
-       * @param        [type]          $begin: ...
-       * @param        [type]          $perms_clause: ...
-       * @return       [type]          ...
-       */
+       /**
+        * [Describe function...]
+        *
+        * @param integer $id
+        * @param integer $depth
+        * @param integer $begin
+        * @param string $perms_clause
+        * @return string
+        */
        function getTreeList($id, $depth, $begin = 0, $perms_clause) {
                $depth = intval($depth);
                $begin = intval($begin);
@@ -844,12 +812,12 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $fN: ...
-        * @param       [type]          $fV: ...
-        * @param       [type]          $conf: ...
-        * @param       [type]          $table: ...
-        * @param       [type]          $splitString: ...
-        * @return      [type]          ...
+        * @param string $fN
+        * @param string $fV
+        * @param array $conf
+        * @param string $table
+        * @param string $splitString
+        * @return string
         */
        function makeValueList($fN, $fV, $conf, $table, $splitString) {
                $fieldSetup = $conf;
@@ -965,8 +933,7 @@ class t3lib_fullsearch {
                                        $labelField = $GLOBALS['TCA'][$from_table]['ctrl']['label'];
                                        $altLabelField = $GLOBALS['TCA'][$from_table]['ctrl']['label_alt'];
                                        if ($GLOBALS['TCA'][$from_table]['columns'][$labelField]['config']['items']) {
-                                               reset($GLOBALS['TCA'][$from_table]['columns'][$labelField]['config']['items']);
-                                               while (list(, $labelArray) = each($GLOBALS['TCA'][$from_table]['columns'][$labelField]['config']['items'])) {
+                                               foreach ($GLOBALS['TCA'][$from_table]['columns'][$labelField]['config']['items'] as $labelArray) {
                                                        if (substr($labelArray[0], 0, 4) == 'LLL:') {
                                                                $labelFieldSelect[$labelArray[1]] = $GLOBALS['LANG']->sL($labelArray[0]);
                                                        } else {
@@ -976,7 +943,6 @@ class t3lib_fullsearch {
                                                $useSelectLabels = 1;
                                        }
                                        if ($GLOBALS['TCA'][$from_table]['columns'][$altLabelField]['config']['items']) {
-                                               reset($GLOBALS['TCA'][$from_table]['columns'][$altLabelField]['config']['items']);
                                                foreach ($GLOBALS['TCA'][$from_table]['columns'][$altLabelField]['config']['items'] as $altLabelArray) {
                                                        if (substr($altLabelArray[0], 0, 4) == 'LLL:') {
                                                                $altLabelFieldSelect[$altLabelArray[1]] = $GLOBALS['LANG']->sL($altLabelArray[0]);
@@ -1017,7 +983,6 @@ class t3lib_fullsearch {
                                                }
                                                $GLOBALS['TYPO3_DB']->sql_free_result($res);
                                        }
-                                       reset($this->tableArray[$from_table]);
                                        foreach ($this->tableArray[$from_table] as $key => $val) {
                                                $GLOBALS['SOBE']->MOD_SETTINGS['labels_noprefix'] = $GLOBALS['SOBE']->MOD_SETTINGS['labels_noprefix'] == 1 ? 'on' :
                                                                $GLOBALS['SOBE']->MOD_SETTINGS['labels_noprefix'];
@@ -1059,10 +1024,10 @@ class t3lib_fullsearch {
        /**
         * Render table header
         *
-        * @param       array           row: Table columns
-        * @param       array           conf: Table TCA
-        * @param       string          table: Table name
-        * @return      string          HTML of table header
+        * @param array $row Table columns
+        * @param array $conf Table TCA
+        * @param string $table Table name
+        * @return string HTML of table header
         */
        function resultRowTitles($row, $conf, $table) {
                $SET = $GLOBALS['SOBE']->MOD_SETTINGS;
@@ -1098,10 +1063,10 @@ class t3lib_fullsearch {
        /**
         * [Describe function...]
         *
-        * @param       [type]          $row: ...
-        * @param       [type]          $conf: ...
-        * @param       [type]          $table: ...
-        * @return      [type]          ...
+        * @param array $row
+        * @param array $conf
+        * @param mixed $table Not used
+        * @return string
         */
        function csvRowTitles($row, $conf, $table) {
                $out = '';
@@ -1129,15 +1094,12 @@ class t3lib_fullsearch {
        /**
         * Sets the current name of the input form.
         *
-        * @param       string          $formName: The name of the form.
-        * @return      void
+        * @param string $formName The name of the form.
+        * @return void
         */
        public function setFormName($formName) {
                $this->formName = trim($formName);
        }
 }
 
-if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_fullsearch.php'])) {
-       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_fullsearch.php']);
-}
 ?>
\ No newline at end of file