Issue Bug Closed

#20529stdWrap for TypoSrcrip-select parameters

David Bruchmann 05/29/09, 15:51 updated 03/29/11, 14:22

Description

The select function doesn’t allow stdWrap for several parameters. So the have to be hardcoded in TS.

I changed function getQuery in class.tslib_content.php so that all parameters in the defined array $stdWrapAllowedValues are parsed through stdWrap.

Now im’m not quite sure, which parameters kann be added there, adding the sql-statements (where, andwhere, join) brakes down the function but what’s about begin, languageField, orderBy, groupBy?

function getQuery($table, $conf, $returnQueryArray=FALSE) {

$stdWrapAllowedValues = Array(‘pidInList.’,‘uidInList.’,‘recursive.’,‘min.’,‘max.’);
foreach ($conf as $k => $v) {
if (in_array($k,$stdWrapAllowedValues) || in_array($k.’.’,$stdWrapAllowedValues)) {
preg_match(‘/(.*?)\./’,$k,$r);
$conf[$r1] = trim($this->stdWrap($conf[$r1],$conf[$k]));
}
}
// Handle recursive function for the pidInList
if (isset($conf[‘recursive’])) {
$conf[‘recursive’] = intval($conf[‘recursive’]);
if ($conf[‘recursive’] > 0) {
foreach (explode(‘,’, $conf[‘pidInList’]) as $value) {
$pidList .= $value . ‘,’ . $this->getTreeList($value, $conf[‘recursive’]);
}
$conf[‘pidInList’] = trim($pidList, ‘,’);
}
}
if (!strcmp($conf[‘pidInList’],’‘))    {
$conf[‘pidInList’] = ‘this’;
}
$queryParts = $this->getWhere($table,$conf,TRUE);
    // Fields:
$queryParts[‘SELECT’] = $conf[‘selectFields’] ? $conf[‘selectFields’] : ‘*’;
    // Setting LIMIT:
if ($conf[‘max’] || $conf[‘begin’]) {
$error=0;
    // Finding the total number of records, if used:
if (strstr(strtolower($conf[‘begin’].$conf[‘max’]),‘total’)) {
$res = $GLOBALS[‘TYPO3_DB’]->exec_SELECTquery(‘count(*)’, $table, $queryParts[‘WHERE’], $queryParts[‘GROUPBY’]);
if ($error = $GLOBALS[‘TYPO3_DB’]->sql_error()) {
$GLOBALS[‘TT’]->setTSlogMessage($error);
} else {
$row = $GLOBALS[‘TYPO3_DB’]->sql_fetch_row($res);
$conf[‘max’] = str_ireplace(‘total’, $row0, $conf[‘max’]);
$conf[‘begin’] = str_ireplace(‘total’, $row0, $conf[‘begin’]);
}
$GLOBALS[‘TYPO3_DB’]->sql_free_result($res);
}
if (!$error) {
$conf[‘begin’] = t3lib_div::intInRange(ceil($this->calc($conf[‘begin’])),0);
$conf[‘max’] = t3lib_div::intInRange(ceil($this->calc($conf[‘max’])),0);
if ($conf[‘begin’] && !$conf[‘max’]) {
$conf[‘max’] = 100000;
}
    if ($conf[‘begin’] && $conf[‘max’])    {
$queryParts[‘LIMIT’] = $conf[‘begin’].’,’.$conf[‘max’];
} elseif (!$conf[‘begin’] && $conf[‘max’]) {
$queryParts[‘LIMIT’] = $conf[‘max’];
}
}
}
(issue imported from #M11220)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.