Project

General

Profile

Bug #22410 » 14050_cleaning_t3lib_tceforms_directory.patch

Administrator Admin, 2010-11-25 00:42

View differences:

t3lib/tceforms/class.t3lib_tceforms_suggest_defaultreceiver.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 2007-2010 Andreas Wolf <andreas.wolf@ikt-werk.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 2007-2010 Andreas Wolf <andreas.wolf@ikt-werk.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Default implementation of a handler class for an ajax record selector.
......
// if table is versionized, only get the records from the Live Workspace
// the overlay itself of WS-records is done below
if ($GLOBALS['TCA'][$this->table]['ctrl']['versioningWS'] == true) {
if ($GLOBALS['TCA'][$this->table]['ctrl']['versioningWS'] == TRUE) {
$this->addWhere .= ' AND t3ver_wsid = 0';
}
......
$rows = array();
$this->params = &$params;
$start = $recursionCounter * 50;
$start = $recursionCounter * 50;
$this->prepareSelectStatement();
$this->prepareOrderByStatement();
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*',
$this->table,
$this->selectClause,
'',
$this->orderByStatement,
$start . ', 50');
'*',
$this->table,
$this->selectClause,
'',
$this->orderByStatement,
$start . ', 50');
$allRowsCount = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
......
while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
// check if we already have collected the maximum number of records
if (count($rows) > $this->maxItems) break;
if (count($rows) > $this->maxItems) {
break;
}
$this->manipulateRecord($row);
$this->makeWorkspaceOverlay($row);
......
$path = $this->getRecordPath($row, $uid);
if (strlen($path) > 30) {
$croppedPath = '<abbr title="' . htmlspecialchars($path) . '">' .
htmlspecialchars($GLOBALS['LANG']->csConvObj->crop($GLOBALS['LANG']->charSet, $path, 10) .
'...' . $GLOBALS['LANG']->csConvObj->crop($GLOBALS['LANG']->charSet, $path, -20)
) . '</abbr>';
htmlspecialchars($GLOBALS['LANG']->csConvObj->crop($GLOBALS['LANG']->charSet, $path, 10) .
'...' . $GLOBALS['LANG']->csConvObj->crop($GLOBALS['LANG']->charSet, $path, -20)
) . '</abbr>';
} else {
$croppedPath = htmlspecialchars($path);
}
$label = $this->getLabel($row);
$entry = array(
'text' => '<span class="suggest-label">' . $label . '</span><span class="suggest-uid">[' . $uid . ']</span><br />
'text' => '<span class="suggest-label">' . $label . '</span><span class="suggest-uid">[' . $uid . ']</span><br />
<span class="suggest-path">' . $croppedPath . '</span>',
'table' => ($this->mmForeignTable ? $this->mmForeignTable : $this->table),
'label' => $label,
'path' => $path,
'path' => $path,
'uid' => $uid,
'uid' => $uid,
'icon' => $iconPath,
'icon' => $iconPath,
'style' => 'background-image:url(' . $iconPath . ');',
'class' => (isset($this->config['cssClass']) ? $this->config['cssClass'] : ''),
);
......
// if there are less records than we need, call this function again to get more records
if (count($rows) < $this->maxItems &&
$allRowsCount >= 50 && $recursionCounter < $this->maxItems) {
$allRowsCount >= 50 && $recursionCounter < $this->maxItems) {
$tmp = self::queryTable($params, ++$recursionCounter);
$rows = array_merge($tmp, $rows);
}
......
if (strlen($searchString)) {
$searchString = $GLOBALS['TYPO3_DB']->quoteStr($searchString, $this->table);
$likeCondition = ' LIKE \'' . ($searchWholePhrase ? '%' : '') .
$GLOBALS['TYPO3_DB']->escapeStrForLike($searchString, $this->table) . '%\'';
$GLOBALS['TYPO3_DB']->escapeStrForLike($searchString, $this->table) . '%\'';
// Search in all fields given by label or label_alt
$selectFieldsList = $GLOBALS['TCA'][$this->table]['ctrl']['label'] . ',' . $GLOBALS['TCA'][$this->table]['ctrl']['label_alt'];
......
* Selects whether the logged in Backend User is allowed to read a specific record
*/
protected function checkRecordAccess($row, $uid) {
$retValue = true;
$retValue = TRUE;
$table = ($this->mmForeignTable ? $this->mmForeignTable : $this->table);
if ($table == 'pages') {
if (!t3lib_BEfunc::readPageAccess($uid, $GLOBALS['BE_USER']->getPagePermsClause(1))) {
$retValue = false;
$retValue = FALSE;
}
} else {
if (!is_array(t3lib_BEfunc::readPageAccess($row['pid'], $GLOBALS['BE_USER']->getPagePermsClause(1)))) {
$retValue = false;
$retValue = FALSE;
}
}
return $retValue;
......
*/
protected function makeWorkspaceOverlay(&$row) {
// check for workspace-versions
if ($GLOBALS['BE_USER']->workspace != 0 && $GLOBALS['TCA'][$this->table]['ctrl']['versioningWS'] == true) {
if ($GLOBALS['BE_USER']->workspace != 0 && $GLOBALS['TCA'][$this->table]['ctrl']['versioningWS'] == TRUE) {
t3lib_BEfunc::workspaceOL(($this->mmForeignTable ? $this->mmForeignTable : $this->table), $row);
}
}
......
* @return string The label
*/
protected function getLabel($row) {
return t3lib_BEfunc::getRecordTitle(($this->mmForeignTable ? $this->mmForeignTable : $this->table), $row, true);
return t3lib_BEfunc::getRecordTitle(($this->mmForeignTable ? $this->mmForeignTable : $this->table), $row, TRUE);
}
/**
......
if ($this->config['renderFunc'] != '') {
$params = array(
'table' => $this->table,
'uid' => $row['uid'],
'uid' => $row['uid'],
'row' => $row,
'row' => $row,
'entry' => &$entry
);
t3lib_div::callUserFunction($this->config['renderFunc'], $params, $this, '');
t3lib/tceforms/class.t3lib_tceforms_flexforms.php (revision )
$TSconfig = $this->setTSconfig($table, $tableRow);
if (!empty($TSconfig[$tableField][$flexformIdentifier . '.'])) {
$sheetConf = t3lib_div::removeDotsFromTS($TSconfig[$tableField][$flexformIdentifier . '.']);
};
}
;
// Get non-exclude-fields from group access lists
$nonExcludeFields = $this->getFlexFormNonExcludeFields($table, $tableField, $flexformIdentifier);
......
continue;
}
$fieldConf = $sheetConf[$fieldName];
$fieldConf = $sheetConf[$fieldName];
$removeItems = (!empty($fieldConf['removeItems']) ? t3lib_div::trimExplode(',', $fieldConf['removeItems'], TRUE) : array());
$keepItems = (!empty($fieldConf['keepItems']) ? t3lib_div::trimExplode(',', $fieldConf['keepItems'], TRUE) : array());
$keepItems = (!empty($fieldConf['keepItems']) ? t3lib_div::trimExplode(',', $fieldConf['keepItems'], TRUE) : array());
$renameItems = (!empty($fieldConf['altLabels']) && is_array($fieldConf['altLabels']) ? $fieldConf['altLabels'] : array());
$renameItems = (!empty($fieldConf['altLabels']) && is_array($fieldConf['altLabels']) ? $fieldConf['altLabels'] : array());
$addItems = (!empty($fieldConf['addItems']) && is_array($fieldConf['addItems']) ? $fieldConf['addItems'] : array());
$addItems = (!empty($fieldConf['addItems']) && is_array($fieldConf['addItems']) ? $fieldConf['addItems'] : array());
unset($fieldConf['removeItems']);
unset($fieldConf['keepItems']);
......
// Collect only FlexForm fields
foreach ($accessListFields as $field) {
if (strpos($field, $identPrefix) !== FALSE) {
list(,, $sheetName, $fieldName) = explode(';', $field);
list(, , $sheetName, $fieldName) = explode(';', $field);
$nonExcludeFields[$sheetName][$fieldName] = TRUE;
}
}
t3lib/tceforms/class.t3lib_tceforms_tree.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Steffen Ritter <info@steffen-ritter.net>
* (c) 2010 Steffen Kamper <steffen@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 2010 Steffen Ritter <info@steffen-ritter.net>
* (c) 2010 Steffen Kamper <steffen@typo3.org>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* TCEforms wizard for rendering an AJAX selector for records
*
......
$item = new stdClass();
$item->uid = $additionalItem[1];
$item->text = $GLOBALS['LANG']->sL($additionalItem[0]);
$item->selectable = true;
$item->leaf = true;
$item->selectable = TRUE;
$item->leaf = TRUE;
$item->checked = in_array($additionalItem[1], $selectedNodes);
if (file_exists(PATH_typo3 . $additionalItem[3])) {
$item->icon = $additionalItem[3];
} elseif (strlen(trim($additionalItem[3]))) {
$item->iconCls= t3lib_iconWorks::getSpriteIconClasses($additionalItem[3]);
$item->iconCls = t3lib_iconWorks::getSpriteIconClasses($additionalItem[3]);
}
$itemArray[] = $item;
......
$id = md5($PA['itemFormElName']);
if (isset($PA['fieldConf']['config']['size']) && intval($PA['fieldConf']['config']['size']) > 0 ) {
if (isset($PA['fieldConf']['config']['size']) && intval($PA['fieldConf']['config']['size']) > 0) {
$height = intval($PA['fieldConf']['config']['size']) * 20;
} else {
$height = 280;
}
if (isset($PA['fieldConf']['config']['autoSizeMax']) && intval($PA['fieldConf']['config']['autoSizeMax']) > 0 ) {
if (isset($PA['fieldConf']['config']['autoSizeMax']) && intval($PA['fieldConf']['config']['autoSizeMax']) > 0) {
$autoSizeMax = intval($PA['fieldConf']['config']['autoSizeMax']) * 20;
}
......
onChange: "' . $onChange . '",
tcaMaxItems: ' . ($PA['fieldConf']['config']['maxitems'] ? intval($PA['fieldConf']['config']['maxitems']) : 99999) . ',
tcaExclusiveKeys: "' . (
$PA['fieldConf']['config']['exclusiveKeys']
? $PA['fieldConf']['config']['exclusiveKeys'] : '') . '",
$PA['fieldConf']['config']['exclusiveKeys']
? $PA['fieldConf']['config']['exclusiveKeys'] : '') . '",
ucId: "' . md5($table . '|' . $field ) . '",
ucId: "' . md5($table . '|' . $field) . '",
selModel: TYPO3.Components.Tree.EmptySelectionModel
});
tree' . $id . '.' . ($autoSizeMax
? 'bodyStyle = "max-height: ' . $autoSizeMax . 'px;"'
: 'height = ' . $height
) . ';
? 'bodyStyle = "max-height: ' . $autoSizeMax . 'px;"'
: 'height = ' . $height
) . ';
tree' . $id . '.render("tree_' . $id . '");' .
($expanded ? 'tree' . $id . '.expandAll();' : '') . '
($expanded ? 'tree' . $id . '.expandAll();' : '') . '
');
$formField = '
t3lib/tceforms/class.t3lib_tceforms_suggest.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 2007-2010 Andreas Wolf <andreas.wolf@ikt-werk.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 2007-2010 Andreas Wolf <andreas.wolf@ikt-werk.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* TCEforms wizard for rendering an AJAX selector for records
*
......
// count the number of ajax selectors used
public $suggestCount = 0;
public $cssClass = 'typo3-TCEforms-suggest';
public $TCEformsObj; // reference to t3lib_tceforms
public $TCEformsObj; // reference to t3lib_tceforms
/**
......
$selector = '
<div class="' . $containerCssClass . '" id="' . $suggestId . '">
<input type="text" id="' . $fieldname . 'Suggest" value="' .
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.findRecord') . '" class="' . $this->cssClass . '-search" />
$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.findRecord') . '" class="' . $this->cssClass . '-search" />
<div class="' . $this->cssClass . '-indicator" style="display: none;" id="' . $fieldname . 'SuggestIndicator">
<img src="' . $GLOBALS['BACK_PATH'] . 'gfx/spinner.gif" alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:alttext.suggestSearching') . '" />
</div>
......
$jsObj = str_replace(' ', '', ucwords(str_replace('-', ' ', t3lib_div::strtolower($suggestId))));
$this->TCEformsObj->additionalJS_post[] = '
var ' . $jsObj . ' = new TCEForms.Suggest("' . $fieldname . '", "' . $table . '", "' . $field .
'", "' . $row['uid'] . '", ' . $row['pid'] . ', ' . $minChars . ');
'", "' . $row['uid'] . '", ' . $row['pid'] . ', ' . $minChars . ');
' . $jsObj . '.defaultValue = "' . t3lib_div::slashJS($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.findRecord')) . '";
';
......
$foreign_table_where = '';
$wizardConfig = $GLOBALS['TCA'][$table]['columns'][$field]['config']['wizards']['suggest'];
if (isset($GLOBALS['TCA'][$table]['columns'][$field]['config']['allowed'])) {
$queryTables = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['allowed']);
$queryTables = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['allowed']);
} elseif (isset($GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table'])) {
$queryTables = array($GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table']);
$foreign_table_where = $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table_where'];
......
if (!is_array($GLOBALS['TCA'][$queryTable]) || !count($GLOBALS['TCA'][$queryTable])) {
continue;
}
$config = (array)$wizardConfig['default'];
$config = (array) $wizardConfig['default'];
if (is_array($wizardConfig[$queryTable])) {
$config = t3lib_div::array_merge_recursive_overrule($config, $wizardConfig[$queryTable]);
......
$config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.']['suggest.']['default.']);
}
if (is_array($TSconfig['TCEFORM.']['suggest.'][$queryTable.'.'])) {
if (is_array($TSconfig['TCEFORM.']['suggest.'][$queryTable . '.'])) {
$config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.']['suggest.'][$queryTable.'.']);
$config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.']['suggest.'][$queryTable . '.']);
}
// use $table instead of $queryTable here because we overlay a config
// for the input-field here, not for the queried table
if (is_array($TSconfig['TCEFORM.'][$table.'.'][$field.'.']['suggest.']['default.'])) {
if (is_array($TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.']['default.'])) {
$config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.'][$table.'.'][$field.'.']['suggest.']['default.']);
$config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.']['default.']);
}
if (is_array($TSconfig['TCEFORM.'][$table.'.'][$field.'.']['suggest.'][$queryTable.'.'])) {
if (is_array($TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.'][$queryTable . '.'])) {
$config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.'][$table.'.'][$field.'.']['suggest.'][$queryTable.'.']);
$config = t3lib_div::array_merge_recursive_overrule($config, $TSconfig['TCEFORM.'][$table . '.'][$field . '.']['suggest.'][$queryTable . '.']);
}
//process addWhere
......
}
if (isset($config['addWhere'])) {
$config['addWhere'] = strtr(' ' . $config['addWhere'], array(
'###THIS_UID###' => intval($uid),
'###CURRENT_PID###' => intval($pageId),
));
'###THIS_UID###' => intval($uid),
'###CURRENT_PID###' => intval($pageId),
));
}
// instantiate the class that should fetch the records for this $queryTable
$receiverClassName = $config['receiverClass'];
......
$row = $resultRows[$rowsSort[$i]];
$rowId = $row['table'] . '-' . $row['uid'] . '-' . $table . '-' . $uid . '-' . $field;
$listItems[] = '<li' . ($row['class'] != '' ? ' class="' . $row['class'] . '"' : '') .
' id="' . $rowId . '" style="' . $row['style'] . '">' . $row['text'] . '</li>';
' id="' . $rowId . '" style="' . $row['style'] . '">' . $row['text'] . '</li>';
}
}
(91-91/93)