Commit 59e55d34 authored by Peter Niederlag's avatar Peter Niederlag
Browse files

backported some bugfixes from HEAD
see Changelog for details


git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_3-7@731 709f56b5-9817-0410-a4d7-c38de5d9e867
parent b062c221
2005-05-19 Peter Niederlag <pn@kreativwert.de>
* backported fix for Bug #849: TSConfig forceDisplayFieldIcons will
work regardless of settings for adminPanel
* backported fix for db_new_content_el.php: Consider allow/deny
for CE's
* backported fix from HEAD for Bug #416 in class.t3lib_install.php: Problems with
auto_increment and default values
* backported fix from HEAD for Bug #422 in class.t3lib_stdgraphic.php:
potential problems with Charset Conversion
* backported fix for Bug #958: require_once() instead of require()
2005-02-24 Michael Stucki <michael@typo3.org>
* Mailer problem: Postfix < 2.0 is now automatically detected (see below)
......
......@@ -2,7 +2,7 @@
/***************************************************************
* Copyright notice
*
* (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
* (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
......@@ -82,11 +82,11 @@ require_once(PATH_t3lib.'class.t3lib_sqlparser.php');
*/
class t3lib_install {
// External, Static
var $updateIdentity = ''; // Set to string which identifies the script using this class.
var $deletedPrefixKey = 'zzz_deleted_'; // Prefix used for tables/fields when deleted/renamed.
var $dbUpdateCheckboxPrefix = 'TYPO3_INSTALL[database_update]'; // Prefix for checkbox fields when updating database.
var $mysqlVersion = '3.22'; // 3.22 or 3.23. If set to 3.23, then the expected format of the incoming sql-dump files are changed. 'DEFAULT' and 'NOT NULL' are reversed in order and 'DEFAULT' is lowercase. Also auto_incremented fields are without default definitions.
var $localconf_addLinesOnly = 0; // If this is set, modifications to localconf.php is done by adding new lines to the array only. If unset, existing values are recognized and changed.
var $localconf_editPointToken = 'INSTALL SCRIPT EDIT POINT TOKEN - all lines after this points may be changed by the install script!'; // If set and addLinesOnly is disabled, lines will be change only if they are after this token (on a single line!) in the file
var $allowUpdateLocalConf = 0; // If true, this class will allow the user to update the localconf.php file. Is set true in the init.php file.
......@@ -291,6 +291,19 @@ class t3lib_install {
} else {
$lineV = ereg_replace(',$','',$value);
$parts = explode(' ',$lineV,2);
// Make sure there is no default value when auto_increment is set
if(stristr($parts[1],'auto_increment')) {
$parts[1] = eregi_replace(' default \'0\'','',$parts[1]);
}
// "default" is always lower-case
if(strstr($parts[1], ' DEFAULT ')) {
$parts[1] = str_replace(' DEFAULT ', ' default ', $parts[1]);
}
// Change order of "default" and "null" statements
$parts[1] = preg_replace('/(.*) (default .*) (NOT NULL)/', '$1 $3 $2', $parts[1]);
$parts[1] = preg_replace('/(.*) (default .*) (NULL)/', '$1 $3 $2', $parts[1]);
if ($parts[0]!='PRIMARY' && $parts[0]!='KEY' && $parts[0]!='UNIQUE') {
$total[$isTable]['fields'][$parts[0]] = $parts[1];
} else {
......@@ -423,7 +436,7 @@ class t3lib_install {
foreach($info[$theKey] as $fieldN => $fieldC) {
if (!isset($FDcomp[$table][$theKey][$fieldN])) {
$extraArr[$table][$theKey][$fieldN] = $fieldC;
} elseif (strcmp($FDcomp[$table][$theKey][$fieldN], $fieldC)){
} elseif (strcmp($FDcomp[$table][$theKey][$fieldN], $fieldC)) {
$diffArr[$table][$theKey][$fieldN] = $fieldC;
$diffArr_cur[$table][$theKey][$fieldN] = $FDcomp[$table][$theKey][$fieldN];
}
......@@ -549,22 +562,15 @@ class t3lib_install {
*/
function assembleFieldDefinition($row) {
$field[] = $row['Type'];
if ($this->mysqlVersion=='3.23' && !$row['Null']) {
$field[] = 'NOT NULL';
}
if (!$row['Null']) { $field[] = 'NOT NULL'; }
if (!strstr($row['Type'],'blob') && !strstr($row['Type'],'text')) {
// This code will return a default value if the sql-file version is not 3.23 and the field is not auto-incremented. In 3.23 files, the auto-incremented fields do not have a default definition.
// Furthermore if the file is 3.22 the default value of auto-incremented fields are expected to always be zero which is why the default value is passed through intval(). Thus it should work on 3.23 MySQL servers.
if ($this->mysqlVersion!='3.23' || !stristr($row['Extra'],'auto_increment')) {
$field[] = ($this->mysqlVersion=='3.23'?'default':'DEFAULT')." '".(stristr($row['Extra'],'auto_increment')?intval($row['Default']):addslashes($row['Default']))."'";
// Add a default value if the field is not auto-incremented (these fields never have a default definition).
if (!stristr($row['Extra'],'auto_increment')) {
$field[] = 'default '."'".(addslashes($row['Default']))."'";
}
}
if ($this->mysqlVersion!='3.23' && !$row['Null']) {
$field[] = 'NOT NULL';
}
if ($row['Extra']) {
$field[] = $row['Extra'];
}
if ($row['Extra']) { $field[] = $row['Extra']; }
return implode(' ',$field);
}
......@@ -584,12 +590,10 @@ class t3lib_install {
$statementArrayPointer = 0;
foreach($sqlcodeArr as $line => $linecontent) {
// Setting MySQL Version if necessary.
if (substr(trim($linecontent),0,16)=='# Server version') {
$this->mysqlVersion = doubleval(substr(trim($linecontent),16));
}
$is_set = 0;
if(stristr($linecontent,'auto_increment')) {
$linecontent = eregi_replace(' default \'0\'','',$linecontent);
}
if (!$removeNonSQL || (strcmp(trim($linecontent),'') && substr(trim($linecontent),0,1)!='#' && substr(trim($linecontent),0,2)!='--')) { // '--' is seen as mysqldump comments from server version 3.23.49
$statementArray[$statementArrayPointer].= $linecontent;
......@@ -622,7 +626,14 @@ class t3lib_install {
if (eregi('^create[[:space:]]*table[[:space:]]*([[:alnum:]_]*)',substr($linecontent,0,100),$reg)) {
$table = trim($reg[1]);
if ($table) {
if (TYPO3_OS=='WIN') {$table=strtolower($table);} // tablenames are always lowercase on windows!
if (TYPO3_OS=='WIN') { $table=strtolower($table); } // table names are always lowercase on Windows!
$sqlLines = explode(chr(10), $linecontent);
foreach($sqlLines as $k=>$v) {
if(stristr($v,'auto_increment')) {
$sqlLines[$k] = eregi_replace(' default \'0\'','',$v);
}
}
$linecontent = implode(chr(10), $sqlLines);
$crTables[$table] = $linecontent;
}
} elseif ($insertCountFlag && eregi('^insert[[:space:]]*into[[:space:]]*([[:alnum:]_]*)',substr($linecontent,0,100),$reg)) {
......
......@@ -284,8 +284,10 @@ class t3lib_stdGraphic {
if (TYPO3_MODE=='FE') {
$this->csConvObj = &$GLOBALS['TSFE']->csConvObj;
} else { // BE assumed:
} elseif(is_object($GLOBALS['LANG'])) { // BE assumed:
$this->csConvObj = &$GLOBALS['LANG']->csConvObj;
} else { // The object may not exist yet, so we need to create it now. Happens in the Install Tool for example.
$this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
}
$this->nativeCharset = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'];
}
......
......@@ -74,14 +74,14 @@ define('TYPO3_mainDir', 'typo3/'); // This is the directory of the backend admi
// ******************
// Including config
// ******************
require(PATH_t3lib.'class.t3lib_div.php');
require(PATH_t3lib.'class.t3lib_extmgm.php');
require_once(PATH_t3lib.'class.t3lib_div.php');
require_once(PATH_t3lib.'class.t3lib_extmgm.php');
require(PATH_t3lib.'config_default.php');
if (!defined ('TYPO3_db')) die ('The configuration file was not included.');
if (!$TYPO3_CONF_VARS['GFX']['image_processing']) die ('ImageProcessing was disabled!');
require(PATH_t3lib.'class.t3lib_db.php'); // The database library
require_once(PATH_t3lib.'class.t3lib_db.php'); // The database library
$TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
......
......@@ -2,7 +2,7 @@
/***************************************************************
* Copyright notice
*
* (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
* (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
......@@ -39,21 +39,22 @@
*
*
*
* 100: class ext_posMap extends t3lib_positionMap
* 110: function wrapRecordTitle($str,$row)
* 124: function onClickInsertRecord($row,$vv,$moveUid,$pid,$sys_lang=0)
* 101: class ext_posMap extends t3lib_positionMap
* 111: function wrapRecordTitle($str,$row)
* 125: function onClickInsertRecord($row,$vv,$moveUid,$pid,$sys_lang=0)
*
*
* 152: class SC_db_new_content_el
* 175: function init()
* 211: function main()
* 358: function printContent()
* 153: class SC_db_new_content_el
* 176: function init()
* 212: function main()
* 359: function printContent()
*
* SECTION: OTHER FUNCTIONS:
* 387: function getWizardItems()
* 397: function wizardArray()
* 388: function getWizardItems()
* 398: function wizardArray()
* 559: function removeInvalidElements(&$wizardItems)
*
* TOTAL FUNCTIONS: 7
* TOTAL FUNCTIONS: 8
* (This index is automatically created/updated by the extension "extdeveval")
*
*/
......@@ -403,71 +404,95 @@ class SC_db_new_content_el {
'icon'=>'gfx/c_wiz/regular_text.gif',
'title'=>$LANG->getLL('common_1_title'),
'description'=>$LANG->getLL('common_1_description'),
'params'=>'&defVals[tt_content][CType]=text'
'tt_content_defValues' => array(
'CType' => 'text'
)
),
'common_2' => array(
'icon'=>'gfx/c_wiz/text_image_below.gif',
'title'=>$LANG->getLL('common_2_title'),
'description'=>$LANG->getLL('common_2_description'),
'params'=>'&defVals[tt_content][CType]=textpic&defVals[tt_content][imageorient]=8'
'tt_content_defValues' => array(
'CType' => 'textpic',
'imageorient' => 8
)
),
'common_3' => array(
'icon'=>'gfx/c_wiz/text_image_right.gif',
'title'=>$LANG->getLL('common_3_title'),
'description'=>$LANG->getLL('common_3_description'),
'params'=>'&defVals[tt_content][CType]=textpic&defVals[tt_content][imageorient]=17'
'tt_content_defValues' => array(
'CType' => 'textpic',
'imageorient' => 17
)
),
'common_4' => array(
'icon'=>'gfx/c_wiz/images_only.gif',
'title'=>$LANG->getLL('common_4_title'),
'description'=>$LANG->getLL('common_4_description'),
'params'=>'&defVals[tt_content][CType]=image&defVals[tt_content][imagecols]=2'
'tt_content_defValues' => array(
'CType' => 'image',
'imagecols' => 2
)
),
'common_5' => array(
'icon'=>'gfx/c_wiz/bullet_list.gif',
'title'=>$LANG->getLL('common_5_title'),
'description'=>$LANG->getLL('common_5_description'),
'params'=>'&defVals[tt_content][CType]=bullets'
'tt_content_defValues' => array(
'CType' => 'bullets',
)
),
'common_6' => array(
'icon'=>'gfx/c_wiz/table.gif',
'title'=>$LANG->getLL('common_6_title'),
'description'=>$LANG->getLL('common_6_description'),
'params'=>'&defVals[tt_content][CType]=table'
'tt_content_defValues' => array(
'CType' => 'table',
)
),
'special' => array('header'=>$LANG->getLL('special')),
'special_1' => array(
'icon'=>'gfx/c_wiz/filelinks.gif',
'title'=>$LANG->getLL('special_1_title'),
'description'=>$LANG->getLL('special_1_description'),
'params'=>'&defVals[tt_content][CType]=uploads'
'tt_content_defValues' => array(
'CType' => 'uploads',
)
),
'special_2' => array(
'icon'=>'gfx/c_wiz/multimedia.gif',
'title'=>$LANG->getLL('special_2_title'),
'description'=>$LANG->getLL('special_2_description'),
'params'=>'&defVals[tt_content][CType]=multimedia'
'tt_content_defValues' => array(
'CType' => 'multimedia',
)
),
'special_3' => array(
'icon'=>'gfx/c_wiz/sitemap2.gif',
'title'=>$LANG->getLL('special_3_title'),
'description'=>$LANG->getLL('special_3_description'),
'params'=>'&defVals[tt_content][CType]=menu&defVals[tt_content][menu_type]=2'
'tt_content_defValues' => array(
'CType' => 'menu',
'menu_type' => 2
)
),
'special_4' => array(
'icon'=>'gfx/c_wiz/html.gif',
'title'=>$LANG->getLL('special_4_title'),
'description'=>$LANG->getLL('special_4_description'),
'params'=>'&defVals[tt_content][CType]=html'
'tt_content_defValues' => array(
'CType' => 'html',
)
),
'forms' => array('header'=>$LANG->getLL('forms')),
'forms_1' => array(
'icon'=>'gfx/c_wiz/mailform.gif',
'title'=>$LANG->getLL('forms_1_title'),
'description'=>$LANG->getLL('forms_1_description'),
'params'=>'&defVals[tt_content][CType]=mailform&defVals[tt_content][bodytext]='.rawurlencode(trim('
'tt_content_defValues' => array(
'CType' => 'mailform',
'bodytext' => trim('
# Example content:
Name: | *name = input,40 | Enter your name here
Email: | *email=input,40 |
......@@ -477,26 +502,33 @@ Contact me: | tv=check | 1
|formtype_mail = submit | Send form!
|html_enabled=hidden | 1
|subject=hidden| This is the subject
'))
')
)
),
'forms_2' => array(
'icon'=>'gfx/c_wiz/searchform.gif',
'title'=>$LANG->getLL('forms_2_title'),
'description'=>$LANG->getLL('forms_2_description'),
'params'=>'&defVals[tt_content][CType]=search'
'tt_content_defValues' => array(
'CType' => 'search',
)
),
'forms_3' => array(
'icon'=>'gfx/c_wiz/login_form.gif',
'title'=>$LANG->getLL('forms_3_title'),
'description'=>$LANG->getLL('forms_3_description'),
'params'=>'&defVals[tt_content][CType]=login'
'tt_content_defValues' => array(
'CType' => 'login',
)
),
'plugins' => array('header'=>$LANG->getLL('plugins')),
'plugins_1' => array(
'icon'=>'gfx/c_wiz/user_defined.gif',
'title'=>$LANG->getLL('plugins_1_title'),
'description'=>$LANG->getLL('plugins_1_description'),
'params'=>'&defVals[tt_content][CType]=list'
'tt_content_defValues' => array(
'CType' => 'list',
)
),
);
......@@ -510,8 +542,63 @@ Contact me: | tv=check | 1
}
}
// Remove elements where preset values are not allowed:
$this->removeInvalidElements($wizardItems);
return $wizardItems;
}
/**
* Checks the array for elements which might contain unallowed default values and will unset them!
* Looks for the "tt_content_defValues" key in each element and if found it will traverse that array as fieldname / value pairs and check. The values will be added to the "params" key of the array (which should probably be unset or empty by default).
*
* @param array Wizard items, passed by reference
* @return void
*/
function removeInvalidElements(&$wizardItems) {
global $TCA;
// Load full table definition:
t3lib_div::loadTCA('tt_content');
// Traverse wizard items:
foreach($wizardItems as $key => $cfg) {
// Exploding parameter string, if any (old style)
if ($wizardItems[$key]['params']) {
// Explode GET vars recursively
$tempGetVars = t3lib_div::explodeUrl2Array($wizardItems[$key]['params'],TRUE);
// If tt_content values are set, merge them into the tt_content_defValues array, unset them from $tempGetVars and re-implode $tempGetVars into the param string (in case remaining parameters are around).
if (is_array($tempGetVars['defVals']['tt_content'])) {
$wizardItems[$key]['tt_content_defValues'] = array_merge(is_array($wizardItems[$key]['tt_content_defValues']) ? $wizardItems[$key]['tt_content_defValues'] : array(), $tempGetVars['defVals']['tt_content']);
unset($tempGetVars['defVals']['tt_content']);
$wizardItems[$key]['params'] = t3lib_div::implodeArrayForUrl('',$tempGetVars);
}
}
// If tt_content_defValues are defined...:
if (is_array($wizardItems[$key]['tt_content_defValues'])) {
// Traverse field values:
foreach($wizardItems[$key]['tt_content_defValues'] as $fN => $fV) {
if (is_array($TCA['tt_content']['columns'][$fN])) {
// Get information about if the field value is OK:
$config = &$TCA['tt_content']['columns'][$fN]['config'];
$authModeDeny = $config['type']=='select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode('tt_content',$fN,$fV,$config['authMode']);
if ($authModeDeny) {
// Remove element all together:
unset($wizardItems[$key]);
break;
} else {
// Add the parameter:
$wizardItems[$key]['params'].= '&defVals[tt_content]['.$fN.']='.rawurlencode($fV);
}
}
}
}
}
}
}
// Include extension?
......
......@@ -2,7 +2,7 @@
/***************************************************************
* Copyright notice
*
* (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
* (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
......@@ -75,11 +75,11 @@ $TT->push('','Script start');
// *********************
// DIV Library included
// Mandatory libraries included
// *********************
$TT->push('Include class t3lib_db, t3lib_div, t3lib_extmgm','');
require(PATH_t3lib.'class.t3lib_div.php');
require(PATH_t3lib.'class.t3lib_extmgm.php');
require_once(PATH_t3lib.'class.t3lib_div.php');
require_once(PATH_t3lib.'class.t3lib_extmgm.php');
$TT->pull();
......@@ -92,10 +92,10 @@ require(PATH_t3lib.'config_default.php');
if (!defined ('TYPO3_db')) die ('The configuration file was not included.'); // the name of the TYPO3 database is stored in this constant. Here the inclusion of the config-file is verified by checking if this var is set.
if (!t3lib_extMgm::isLoaded('cms')) die('<strong>Error:</strong> The main frontend extension "cms" was not loaded. Enable it in the extension manager in the backend.');
require(PATH_t3lib.'class.t3lib_db.php');
require_once(PATH_t3lib.'class.t3lib_db.php');
$TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
$CLIENT=t3lib_div::clientInfo(); // Set to the browser: net / msie if 4+ browsers
$CLIENT = t3lib_div::clientInfo(); // Set to the browser: net / msie if 4+ browsers
$TT->pull();
......@@ -131,7 +131,7 @@ if (!get_magic_quotes_gpc()) {
// Create $TSFE object (TSFE = TypoScript Front End)
// Connecting to database
// ***********************************
$temp_TSFEclassName=t3lib_div::makeInstanceClassName('tslib_fe');
$temp_TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
$TSFE = new $temp_TSFEclassName(
$TYPO3_CONF_VARS,
t3lib_div::_GP('id'),
......@@ -208,8 +208,8 @@ if ($_COOKIE['be_typo_user']) { // If the backend cookie is set, we proceed and
$BE_USER->ext_forcePreview=1;
}
// Include classes for editing IF editing module in Admin Panel is open (it is assumed that $TSFE->displayEditIcons is set only if the Edit module is open in the Admin Panel)
if ($BE_USER->extAdmModuleEnabled('edit') && $BE_USER->extIsAdmMenuOpen('edit')) {
// Include classes for editing IF editing module in Admin Panel is open
if (($BE_USER->extAdmModuleEnabled('edit') && $BE_USER->extIsAdmMenuOpen('edit')) || $TSFE->displayEditIcons == 1) {
$TSFE->includeTCA();
if ($BE_USER->extIsEditAction()) {
require_once (PATH_t3lib.'class.t3lib_tcemain.php');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment