Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_search_directory
authorSteffen Kamper <info@sk-typo3.de>
Wed, 24 Nov 2010 23:18:58 +0000 (23:18 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Wed, 24 Nov 2010 23:18:58 +0000 (23:18 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9609 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/search/class.t3lib_search_livesearch.php
t3lib/search/class.t3lib_search_livesearch_queryParser.php

index 9246efd..f4f60ca 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
 
 2010-11-24  Steffen Kamper  <steffen@typo3.org>
 
+       * Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_search_directory
        * Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_message_directory
        * Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_matchcondition_directory
        * Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_mail_directory
index 9ee3325..78be481 100644 (file)
@@ -79,7 +79,7 @@ class t3lib_search_livesearch {
        /**
         * @var t3lib_search_livesearch_queryParser
         */
-       protected $queryParser = null;
+       protected $queryParser = NULL;
 
        /**
         * Initialize access settings.
@@ -117,7 +117,7 @@ class t3lib_search_livesearch {
         */
        public function find($searchQuery) {
                $recordArray = array();
-               $pageIdList = $this->getAvailablePageIds (
+               $pageIdList = $this->getAvailablePageIds(
                        implode(',', $GLOBALS['BE_USER']->returnWebmounts()),
                        self::RECURSIVE_PAGE_LEVEL
                );
@@ -134,7 +134,7 @@ class t3lib_search_livesearch {
                        $recordArray = $this->findByGlobalTableList($pageIdList, $limit);
                }
 
-               // @todo Need to make sure we don't return too many records. How do we handle this when querying across multiple tables?
+                       // @todo Need to make sure we don't return too many records. How do we handle this when querying across multiple tables?
                $recordArray = array_slice($recordArray, 0, $this->limitCount);
 
                return $recordArray;
@@ -189,7 +189,7 @@ class t3lib_search_livesearch {
        protected function findByTable($tableName, $pageIdList, $limit) {
                $getRecordArray = array();
                $fieldsToSearchWithin = $this->extractSearchableFieldsFromTable($tableName);
-               $pageBasedPermission = ($tableName == 'pages' && $this->userPermissions) ? $this->userPermissions : '1=1 ' ;
+               $pageBasedPermission = ($tableName == 'pages' && $this->userPermissions) ? $this->userPermissions : '1=1 ';
                $where = 'pid IN(' . $pageIdList . ')' . $pageBasedPermission . $this->makeQuerySearchByTable($tableName, $fieldsToSearchWithin);
                $orderBy = $this->makeOrderByTable($tableName);
                $getRecordArray = $this->getRecordArray(
@@ -220,26 +220,26 @@ class t3lib_search_livesearch {
         */
        protected function getRecordArray($tableName, $where, $orderBy, $limit) {
                $collect = array();
-               $isFirst = true;
+               $isFirst = TRUE;
                $queryParts = array(
-                       'SELECT'  => '*',
-                       'FROM'    => $tableName,
-                       'WHERE'   => $where,
+                       'SELECT' => '*',
+                       'FROM' => $tableName,
+                       'WHERE' => $where,
                        'ORDERBY' => $orderBy,
-                       'LIMIT'   => $limit
+                       'LIMIT' => $limit
                );
-               $result  = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
+               $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
                $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
 
-               while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
-                       $collect[] = array (
+               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
+                       $collect[] = array(
                                'id' => $tableName . ':' . $row['uid'],
                                'recordTitle' => ($isFirst) ? $this->getRecordTitlePrep($this->getTitleOfCurrentRecordType($tableName), self::GROUP_TITLE_MAX_LENGTH) : '',
                                'iconHTML' => t3lib_iconWorks::getSpriteIconForRecord($tableName, $row),
                                'title' => $this->getRecordTitlePrep($this->getTitleFromCurrentRow($tableName, $row), self::RECORD_TITLE_MAX_LENGTH),
                                'editLink' => $this->getEditLink($tableName, $row),
                        );
-                       $isFirst = false;
+                       $isFirst = FALSE;
                }
 
                return $collect;
@@ -260,16 +260,16 @@ class t3lib_search_livesearch {
                $editLink = '';
 
                if ($tableName == 'pages') {
-                       $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
-                       $permsEdit = $localCalcPerms&2;
+                       $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages', $row['uid']));
+                       $permsEdit = $localCalcPerms & 2;
                } else {
-                       $permsEdit = $calcPerms&16;
+                       $permsEdit = $calcPerms & 16;
                }
 
                        // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
                        // @todo Is there an existing function to generate this link?
                if ($permsEdit) {
-                       $editLink = 'alt_doc.php?' . '&edit['.$tableName.']['.$row['uid'].']=edit';
+                       $editLink = 'alt_doc.php?' . '&edit[' . $tableName . '][' . $row['uid'] . ']=edit';
                }
 
                return $editLink;
@@ -299,7 +299,8 @@ class t3lib_search_livesearch {
                        $titleLength = $GLOBALS['BE_USER']->uc['titleLen'];
                }
 
-               return htmlspecialchars(t3lib_div::fixed_lgd_cs($title, $titleLength));;
+               return htmlspecialchars(t3lib_div::fixed_lgd_cs($title, $titleLength));
+               ;
        }
 
        /**
@@ -326,9 +327,9 @@ class t3lib_search_livesearch {
        protected function makeQuerySearchByTable($tableName, $fieldsToSearchWithin) {
                        // free text search
                $queryLikeStatement = ' LIKE \'%' . $this->getQueryString($tableName) . '%\'';
-               $queryPart                      = ' AND (' . implode($queryLikeStatement . ' OR ', $fieldsToSearchWithin) . $queryLikeStatement . ')';
-               $queryPart                 .= t3lib_BEfunc::deleteClause($tableName);
-               $queryPart                 .= t3lib_BEfunc::versioningPlaceholderClause($tableName);
+               $queryPart = ' AND (' . implode($queryLikeStatement . ' OR ', $fieldsToSearchWithin) . $queryLikeStatement . ')';
+               $queryPart .= t3lib_BEfunc::deleteClause($tableName);
+               $queryPart .= t3lib_BEfunc::versioningPlaceholderClause($tableName);
 
                return $queryPart;
        }
@@ -345,7 +346,7 @@ class t3lib_search_livesearch {
                $orderBy = '';
 
                if (is_array($GLOBALS['TCA'][$tableName]['ctrl']) && array_key_exists('sortby', $GLOBALS['TCA'][$tableName]['ctrl'])) {
-                       $orderBy = 'ORDER BY '.$GLOBALS['TCA'][$tableName]['ctrl']['sortby'];
+                       $orderBy = 'ORDER BY ' . $GLOBALS['TCA'][$tableName]['ctrl']['sortby'];
                } else {
                        $orderBy = $GLOBALS['TCA'][$tableName]['ctrl']['default_sortby'];
                }
@@ -363,27 +364,27 @@ class t3lib_search_livesearch {
                $fieldListArray = array();
 
                        // Traverse configured columns and add them to field array, if available for user.
-               foreach((array) $GLOBALS['TCA'][$tableName]['columns'] as $fieldName => $fieldValue) {
-                       // @todo Reformat
+               foreach ((array) $GLOBALS['TCA'][$tableName]['columns'] as $fieldName => $fieldValue) {
+                               // @todo Reformat
                        if (
-                                       (!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $tableName . ':' . $fieldName)) // does current user have access to the field
+                               (!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $tableName . ':' . $fieldName)) // does current user have access to the field
                                &&
-                                       ($fieldValue['config']['type'] != 'passthrough') // field type is not searchable
+                               ($fieldValue['config']['type'] != 'passthrough') // field type is not searchable
                                &&
-                                       (!preg_match('/date|time|int/', $fieldValue['config']['eval'])) // field can't be of type date, time, int
+                               (!preg_match('/date|time|int/', $fieldValue['config']['eval'])) // field can't be of type date, time, int
                                &&
-                                       (
-                                                       ($fieldValue['config']['type'] == 'text')
+                               (
+                                               ($fieldValue['config']['type'] == 'text')
                                                ||
-                                                       ($fieldValue['config']['type'] == 'input')
-                                       )
-                               ) {
+                                               ($fieldValue['config']['type'] == 'input')
+                               )
+                       ) {
                                $fieldListArray[] = $fieldName;
                        }
                }
 
                        // Add special fields:
-               if ($GLOBALS['BE_USER']->isAdmin())     {
+               if ($GLOBALS['BE_USER']->isAdmin()) {
                        $fieldListArray[] = 'uid';
                        $fieldListArray[] = 'pid';
                }
@@ -450,7 +451,7 @@ class t3lib_search_livesearch {
                $tree = t3lib_div::makeInstance('t3lib_pageTree');
                $tree->init('AND ' . $this->userPermissions);
                $tree->makeHTML = 0;
-               $tree->fieldArray = Array('uid','php_tree_stop');
+               $tree->fieldArray = array('uid', 'php_tree_stop');
                if ($depth) {
                        $tree->getTree($id, $depth, '');
                }
index 8a77cdc..b7d0ba0 100644 (file)
@@ -44,7 +44,7 @@ class t3lib_search_livesearch_queryParser {
        /**
         * @var string
         */
-       protected $tableName  = '';
+       protected $tableName = '';
 
        /**
         * @var string
@@ -90,6 +90,7 @@ class t3lib_search_livesearch_queryParser {
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch']) && array_key_exists($this->commandKey, $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch'])) {
                        $tableName = $GLOBALS['TYPO3_CONF_VARS']['SYS']['livesearch'][$this->commandKey];
                }
+
                return $tableName;
        }
 
@@ -110,10 +111,10 @@ class t3lib_search_livesearch_queryParser {
         * @return boolean
         */
        public function isValidPageJump($query) {
-               $isValid = false;
+               $isValid = FALSE;
 
                if (preg_match('~^#(\d)+$~', $query)) {
-                       $isValid = true;
+                       $isValid = TRUE;
                }
 
                return $isValid;
@@ -126,11 +127,11 @@ class t3lib_search_livesearch_queryParser {
         * @return boolean
         */
        public function isValidCommand($query) {
-               $isValid = false;
+               $isValid = FALSE;
                if (strpos($query, self::COMMAND_KEY_INDICATOR) === 0 &&
-                   strpos($query, self::COMMAND_SPLIT_INDICATOR) > 1 &&
-                   $this->getTableNameFromCommand($query)) {
-                       $isValid = true;
+                       strpos($query, self::COMMAND_SPLIT_INDICATOR) > 1 &&
+                       $this->getTableNameFromCommand($query)) {
+                       $isValid = TRUE;
                }
 
                return $isValid;
@@ -172,4 +173,5 @@ class t3lib_search_livesearch_queryParser {
                return $resultQuery;
        }
 }
+
 ?>
\ No newline at end of file