Project

General

Profile

Bug #22410 » 14050_cleaning_t3lib_search_directory.patch

Administrator Admin, 2010-11-25 00:27

View differences:

t3lib/search/class.t3lib_search_livesearch_queryParser.php (revision )
/**
* @var string
*/
protected $tableName = '';
protected $tableName = '';
/**
* @var string
......
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;
}
......
* @return boolean
*/
public function isValidPageJump($query) {
$isValid = false;
$isValid = FALSE;
if (preg_match('~^#(\d)+$~', $query)) {
$isValid = true;
$isValid = TRUE;
}
return $isValid;
......
* @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)) {
strpos($query, self::COMMAND_SPLIT_INDICATOR) > 1 &&
$this->getTableNameFromCommand($query)) {
$isValid = true;
$isValid = TRUE;
}
return $isValid;
......
return $resultQuery;
}
}
?>
t3lib/search/class.t3lib_search_livesearch.php (revision )
/**
* @var t3lib_search_livesearch_queryParser
*/
protected $queryParser = null;
protected $queryParser = NULL;
/**
* Initialize access settings.
......
*/
public function find($searchQuery) {
$recordArray = array();
$pageIdList = $this->getAvailablePageIds (
$pageIdList = $this->getAvailablePageIds(
implode(',', $GLOBALS['BE_USER']->returnWebmounts()),
self::RECURSIVE_PAGE_LEVEL
);
......
$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;
......
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(
......
*/
protected function getRecordArray($tableName, $where, $orderBy, $limit) {
$collect = array();
$isFirst = true;
$isFirst = TRUE;
$queryParts = array(
'SELECT' => '*',
'SELECT' => '*',
'FROM' => $tableName,
'FROM' => $tableName,
'WHERE' => $where,
'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)) {
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
$collect[] = array (
$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;
......
$editLink = '';
if ($tableName == 'pages') {
$localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
$localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages', $row['uid']));
$permsEdit = $localCalcPerms&2;
$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;
......
$titleLength = $GLOBALS['BE_USER']->uc['titleLen'];
}
return htmlspecialchars(t3lib_div::fixed_lgd_cs($title, $titleLength));;
return htmlspecialchars(t3lib_div::fixed_lgd_cs($title, $titleLength));
;
}
/**
......
protected function makeQuerySearchByTable($tableName, $fieldsToSearchWithin) {
// free text search
$queryLikeStatement = ' LIKE \'%' . $this->getQueryString($tableName) . '%\'';
$queryPart = ' AND (' . implode($queryLikeStatement . ' OR ', $fieldsToSearchWithin) . $queryLikeStatement . ')';
$queryPart = ' AND (' . implode($queryLikeStatement . ' OR ', $fieldsToSearchWithin) . $queryLikeStatement . ')';
$queryPart .= t3lib_BEfunc::deleteClause($tableName);
$queryPart .= t3lib_BEfunc::deleteClause($tableName);
$queryPart .= t3lib_BEfunc::versioningPlaceholderClause($tableName);
$queryPart .= t3lib_BEfunc::versioningPlaceholderClause($tableName);
return $queryPart;
}
......
$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'];
}
......
$fieldListArray = array();
// Traverse configured columns and add them to field array, if available for user.
foreach((array) $GLOBALS['TCA'][$tableName]['columns'] as $fieldName => $fieldValue) {
foreach ((array) $GLOBALS['TCA'][$tableName]['columns'] as $fieldName => $fieldValue) {
// @todo Reformat
// @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';
}
......
$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, '');
}
(88-88/93)