Index: typo3/template.php =================================================================== --- typo3/template.php (revision 5117) +++ typo3/template.php (working copy) @@ -1143,53 +1143,55 @@ // These vars defines the layout for the table produced by the table() function. // You can override these values from outside if you like. - var $tableLayout = Array ( - 'defRow' => Array ( - 'defCol' => Array('','') + var $tableLayout = array( + 'defRow' => array( + 'defCol' => array('','') ) ); var $table_TR = ''; var $table_TABLE = ''; /** - * Returns a table based on the input $arr + * Returns a table based on the input $data * * @param array Multidim array with first levels = rows, second levels = cells * @param array If set, then this provides an alternative layout array instead of $this->tableLayout * @return string The HTML table. * @internal */ - function table($arr, $layout='') { - if (is_array($arr)) { - $tableLayout = (is_array($layout)) ? $layout : $this->tableLayout; + function table($data, $layout = '') { + $result = ''; + if (is_array($data)) { + $tableLayout = (is_array($layout) ? $layout : $this->tableLayout); - reset($arr); - $code=''; - $rc=0; - while(list(,$val)=each($arr)) { - if ($rc % 2) { + $rowCount = 0; + foreach ($data as $tableRow) { + if ($rowCount % 2) { $layout = is_array($tableLayout['defRowOdd']) ? $tableLayout['defRowOdd'] : $tableLayout['defRow']; } else { $layout = is_array($tableLayout['defRowEven']) ? $tableLayout['defRowEven'] : $tableLayout['defRow']; } - $layoutRow = is_array($tableLayout[$rc]) ? $tableLayout[$rc] : $layout; - $code_td=''; - if (is_array($val)) { - $cc=0; - while(list(,$content)=each($val)) { - $wrap= is_array($layoutRow[$cc]) ? $layoutRow[$cc] : (is_array($layoutRow['defCol']) ? $layoutRow['defCol'] : (is_array($layout[$cc]) ? $layout[$cc] : $layout['defCol'])); - $code_td.=$wrap[0].$content.$wrap[1]; - $cc++; + $rowLayout = is_array($tableLayout[$rowCount]) ? $tableLayout[$rowCount] : $layout; + $rowResult = ''; + if (is_array($tableRow)) { + $cellCount = 0; + foreach ($tableRow as $tableCell) { + $cellWrap = (is_array($layout[$cellCount]) ? $layout[$cellCount] : $layout['defCol']); + $cellWrap = (is_array($rowLayout['defCol']) ? $rowLayout['defCol'] : $cellWrap); + $cellWrap = (is_array($rowLayout[$cellCount]) ? $rowLayout[$cellCount] : $cellWrap); + $rowResult .= $cellWrap[0] . $tableCell . $cellWrap[1]; + $cellCount++; } } - $trWrap = is_array($layoutRow['tr']) ? $layoutRow['tr'] : (is_array($layout['tr']) ? $layout['tr'] : array($this->table_TR, '')); - $code.=$trWrap[0].$code_td.$trWrap[1]; - $rc++; + $rowWrap = (is_array($layout['tr']) ? $layout['tr'] : array($this->table_TR, '')); + $rowWrap = (is_array($rowLayout['tr']) ? $rowLayout['tr'] : $rowWrap); + $result .= $rowWrap[0] . $rowResult . $rowWrap[1]; + $rowCount++; } $tableWrap = is_array($tableLayout['table']) ? $tableLayout['table'] : array($this->table_TABLE, '
'); - $code=$tableWrap[0].$code.$tableWrap[1]; + $result = $tableWrap[0] . $result . $tableWrap[1]; } - return $code; + return $result; } /** Index: typo3/sysext/setup/mod/index.php =================================================================== --- typo3/sysext/setup/mod/index.php (revision 5117) +++ typo3/sysext/setup/mod/index.php (working copy) @@ -232,25 +232,24 @@ * @return void */ function init() { - global $BE_USER,$BACK_PATH; $this->MCONF = $GLOBALS['MCONF']; // Returns the script user - that is the REAL logged in user! ($GLOBALS[BE_USER] might be another user due to simulation!) $scriptUser = $this->getRealScriptUserObj(); - $scriptUser->modAccess($this->MCONF,1); // ... and checking module access for the logged in user. + // ... and checking module access for the logged in user. + $scriptUser->modAccess($this->MCONF, 1); // Getting the 'override' values as set might be set in User TSconfig - $this->overrideConf = $BE_USER->getTSConfigProp('setup.override'); + $this->overrideConf = $GLOBALS['BE_USER']->getTSConfigProp('setup.override'); // Create instance of object for output of data $this->doc = t3lib_div::makeInstance('template'); - $this->doc->backPath = $BACK_PATH; + $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->doc->setModuleTemplate('templates/setup.html'); $this->doc->JScodeLibArray['dyntabmenu'] = $this->doc->getDynTabMenuJScode(); - $this->doc->form = '
'; - $this->doc->tableLayout = array ( - 'defRow' => array ( + $this->doc->tableLayout = array( + 'defRow' => array( '0' => array('',''), '2' => array('',''), 'defCol' => array('','') @@ -269,17 +268,17 @@ global $BE_USER,$LANG,$BACK_PATH,$TBE_MODULES; if ($this->languageUpdate) { - $this->doc->JScode.= ''; + $this->doc->JScodeArray['languageUpdate'] .= ' + if (top.refreshMenu) { + top.refreshMenu(); + } else { + top.TYPO3ModuleMenu.refreshMenu(); + } + + if (top.shortcutFrame) { + top.shortcutFrame.refreshShortcuts(); + } + '; } // Start page: @@ -291,14 +290,14 @@ // Load available backend modules $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules'); - $this->loadModules->observeWorkspaces = TRUE; + $this->loadModules->observeWorkspaces = true; $this->loadModules->load($TBE_MODULES); $this->content .= $this->doc->header($LANG->getLL('UserSettings').' - '.$BE_USER->user['realName'].' ['.$BE_USER->user['username'].']'); // If password is updated, output whether it failed or was OK. - if ($this->PASSWORD_UPDATED) { - if ($this->PASSWORD_UPDATED>0) { + if ($this->PASSWORD_UPDATED) { + if ($this->PASSWORD_UPDATED > 0) { $this->content .= $this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_ok'),1,0,1); } else { $this->content .= $this->doc->section($LANG->getLL('newPassword').':',$LANG->getLL('newPassword_failed'),1,0,2); @@ -306,257 +305,200 @@ $this->content .= $this->doc->spacer(25); } - // display full help is active? - $displayFullText = ($BE_USER->uc['edit_showFieldHelp'] == 'text'); - if ($displayFullText) { - $this->doc->tableLayout['defRowEven'] = array ('defCol' => array ('','')); - } - // Personal data - $code = array(); - $i = 0; - - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('beUser_realName'); - - } - $code[$i][1] = $this->setLabel('beUser_realName'); - $code[$i][2] = 'formWidth(20).' />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('beUser_realName'); - - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('beUser_email'); - } - $code[$i][1] = $this->setLabel('beUser_email'); - $code[$i][2] = 'formWidth(20).' />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('beUser_email'); - - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('emailMeAtLogin'); - } - $code[$i][1] = $this->setLabel('emailMeAtLogin').($BE_USER->user['email'] ? ' ('.$BE_USER->user['email'].')' : ''); - $code[$i][2] = 'uc['emailMeAtLogin']?' checked="checked"':'').' />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('emailMeAtLogin'); - - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('newPassword'); - } - $code[$i][1] = $this->setLabel('newPassword'); - $code[$i][2] = 'formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\';" />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('newPassword'); - - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('newPasswordAgain'); - } - $code[$i][1] = $this->setLabel('newPasswordAgain'); - $code[$i][2] = 'formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\'" />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('newPasswordAgain'); - - // Languages: - $opt = array(); - $opt['000000000']=' - '; - $theLanguages = t3lib_div::trimExplode('|',TYPO3_languages); - - // Character set conversion object: - $csConvObj = t3lib_div::makeInstance('t3lib_cs'); - - // traverse the number of languages: - foreach($theLanguages as $val) { - if ($val!='default') { - $localLabel = ' - ['.htmlspecialchars($GLOBALS['LOCAL_LANG']['default']['lang_'.$val]).']'; - $unavailable = $val!='default' && !@is_dir(PATH_typo3conf.'l10n/'.$val) ? '1' : ''; - if (!$unavailable) $opt[$GLOBALS['LOCAL_LANG']['default']['lang_'.$val].'--'.$val]=' - '; + // + // Personal data + // + // compile the languages dropdown + $languageOptions = array( + '000000000' => chr(10) . '' + ); + // traverse the number of languages + $theLanguages = t3lib_div::trimExplode('|', TYPO3_languages); + foreach ($theLanguages as $language) { + if ($language != 'default') { + $languageValue = $GLOBALS['LOCAL_LANG']['default']['lang_' . $language]; + $localLabel = ' - ['.htmlspecialchars($languageValue) . ']'; + $unavailable = (!is_dir(PATH_typo3conf . 'l10n/' . $language) ? true : false); + if (!$unavailable) { + $languageOptions[$languageValue . '--' . $language] = ' + '; + } } } - ksort($opt); + ksort($languageOptions); $languageCode = ' - ' . + implode('', $languageOptions) . ' '; - if ($BE_USER->uc['lang'] && !@is_dir(PATH_typo3conf.'l10n/'.$BE_USER->uc['lang'])) { - $languageCode.= '
'. - $this->doc->icons(3). - 'The selected language is not available before the language pack is installed.
'. - ($BE_USER->isAdmin()? 'You can use the Extension Manager to easily download and install new language packs.':'Please ask your system administrator to do this.'). - '
'; - } - - - if ($displayFullText) { - $code[$i++][1] = t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $BACK_PATH); + if ($BE_USER->uc['lang'] && !@is_dir(PATH_typo3conf . 'l10n/' . $BE_USER->uc['lang'])) { + $languageCode .= '
'. + $this->doc->icons(3) . + 'The selected language is not available before the language pack is installed.
'. + ($BE_USER->isAdmin() ? 'You can use the Extension Manager to easily download and install new language packs.':'Please ask your system administrator to do this.') . + '
'; } - $code[$i][1] = $this->setLabel('language'); - $code[$i][2] = $languageCode; - $code[$i++][3] = $displayFullText ? ' ' : t3lib_BEfunc::cshItem('_MOD_user_setup', 'language', $BACK_PATH); - $menuItems[] = array( - 'label' => $LANG->getLL('language').' & '.$LANG->getLL('personal_data'), - 'content' => $this->doc->spacer(20).$this->doc->table($code) + + // the data for the user configuration (uc), + $data = array( + 'beUser_realName' => array( + 'type' => 'text', + 'form' => 'formWidth(20).' />', + ), + 'beUser_email' => array( + 'type' => 'text', + 'form' => 'formWidth(20).' />', + ), + 'emailMeAtLogin' => array( + 'type' => 'check', + 'form' => 'uc['emailMeAtLogin']?' checked="checked"':'').' />', + ), + 'newPassword' => array( + 'type' => 'password', + 'form' => 'formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\';" />', + ), + 'newPasswordAgain' => array( + 'type' => 'password', + 'form' => 'formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\'" />', + ), + 'language' => array( + 'type' => 'select', + 'form' => $languageCode, + ), ); + $menuItems[] = $this->renderUserSetupTab($data, ($LANG->getLL('language') . ' & ' . $LANG->getLL('personal_data'))); + // + // compiling the 'Startup' section + // - // compiling the 'Startup' section - $code = array(); - $i = 0; - - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('condensedMode'); - } - $code[$i][1] = $this->setLabel('condensedMode','condensedMode'); - $code[$i][2] = 'uc['condensedMode']?' checked="checked"':'').' />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('condensedMode'); - - if($GLOBALS['BE_USER']->uc['interfaceSetup'] == 'backend_old') { - $code[$i][1] = $this->setLabel('noMenuMode','noMenuMode'); - $code[$i][2] = ''; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('noMenuMode'); - } - - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('startModule'); - } - $code[$i][1] = $this->setLabel('startModule','startModule'); - $modSelect = ''; - $code[$i][2] = $modSelect; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('startModule'); + $startModuleSelect = ''; - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('showThumbs'); - } - $code[$i][1] = $this->setLabel('showThumbs','thumbnailsByDefault'); - $code[$i][2] = 'uc['thumbnailsByDefault']?' checked="checked"':'').' />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('showThumbs'); - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('helpText'); - } - $code[$i][1] = $this->setLabel('helpText'); - $code[$i][2] = 'uc['helpText']?' checked="checked"':'').' />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('helpText'); - - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('edit_showFieldHelp'); - } - $code[$i][1] = $this->setLabel('edit_showFieldHelp'); - $code[$i][2] = 'uc['condensedMode']?' checked="checked"':'').' />', + 'label' => 'condensedMode' + ), + 'noMenuMode' => array( + 'type' => 'select', + 'form' => '', + 'labelkey' => 'noMenuMode' + ), + 'startModule' => array( + 'type' => 'select', + 'form' => $startModuleSelect, + 'labelkey' => 'startModule' + ), + 'showThumbs' => array( + 'type' => 'check', + 'form' => 'uc['thumbnailsByDefault']?' checked="checked"':'').' />', + 'labelkey' => 'thumbnailsByDefault', + ), + 'helpText' => array( + 'type' => 'check', + 'form' => 'uc['helpText']?' checked="checked"':'').' />', + ), + 'edit_showFieldHelp' => array( + 'type' => 'select', + 'form' => ''; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('edit_showFieldHelp'); - - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('maxTitleLen'); - } - $code[$i][1] = $this->setLabel('maxTitleLen','titleLen'); - $code[$i][2] = 'formWidth(5).' maxlength="5" />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('maxTitleLen'); - - $menuItems[] = array( - 'label' => $LANG->getLL('opening'), - 'content' => $this->doc->spacer(20).$this->doc->table($code) + ', + ), + 'maxTitleLen' => array( + 'type' => 'text', + 'form' => 'formWidth(5).' maxlength="5" />', + 'labelkey' => 'titleLen', + ), + ); - - // Edit - $code = array(); - $i = 0; - - if ($GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled']) { - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('edit_RTE'); - } - $code[$i][1] = $this->setLabel('edit_RTE'); - $code[$i][2] = 'uc['edit_RTE']?' checked="checked"':'').' />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('edit_RTE'); + if ($GLOBALS['BE_USER']->uc['interfaceSetup'] != 'backend_old') { + unset($data['noMenuMode']); } + $menuItems[] = $this->renderUserSetupTab($data, ($LANG->getLL('opening'))); - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('edit_docModuleUpload'); - } - $code[$i][1] = $this->setLabel('edit_docModuleUpload'); - $code[$i][2] = 'uc['edit_docModuleUpload']?' checked="checked"':'').' />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('edit_docModuleUpload'); - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('disableCMlayers'); - } - $code[$i][1] = $this->setLabel('disableCMlayers'); - $code[$i][2] = 'uc['disableCMlayers']?' checked="checked"':'').' />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('disableCMlayers'); + // + // Edit section & advanced options + // + $data = array( + 'edit_RTE' => array( + 'type' => 'check', + 'form' => 'uc['edit_RTE']?' checked="checked"':'').' />', + ), + 'edit_docModuleUpload' => array( + 'type' => 'check', + 'form' => 'uc['edit_docModuleUpload']?' checked="checked"':'').' />' + ), + 'disableCMlayers' => array( + 'type' => 'check', + 'form' => 'uc['disableCMlayers']?' checked="checked"':'').' />' + ), + 'copyLevels' => array( + 'type' => 'text', + 'form' => 'formWidth(5).' maxlength="5" /> '.$LANG->getLL('levels') + ), + 'recursiveDelete' => array( + 'type' => 'check', + 'form' => 'uc['recursiveDelete']?' checked="checked"':'').' />', + ), + ); - // Advanced Operations: - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('copyLevels'); + if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled']) { + unset($data['edit_RTE']); } - $code[$i][1] = $this->setLabel('copyLevels'); - $code[$i][2] = 'formWidth(5).' maxlength="5" /> '.$LANG->getLL('levels'); - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('copyLevels'); + $menuItems[] = $this->renderUserSetupTab($data, ($LANG->getLL('edit_functions') . ' & ' . $LANG->getLL('functions'))); - if ($displayFullText) { - $code[$i++][1] = $this->getCSH('recursiveDelete'); - } - $code[$i][1] = $this->setLabel('recursiveDelete'); - $code[$i][2] = 'uc['recursiveDelete']?' checked="checked"':'').' />'; - $code[$i++][3] = $displayFullText ? ' ' : $this->getCSH('recursiveDelete'); - $menuItems[] = array( - 'label' => $LANG->getLL('edit_functions') . ' & ' . $LANG->getLL('functions'), - 'content' => $this->doc->spacer(20).$this->doc->table($code) - ); - - - $code = array(); - $i = 0; - - // Admin functions - if($BE_USER->isAdmin()) { + // + // Admin functions + // + $data = array(); + if ($BE_USER->isAdmin()) { // Simulate selector box: - if ($this->simulateSelector) { - if ($displayFullText) { - $code[$i++][1] = t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $BACK_PATH); - } - $code[$i][1] = $this->setLabel('simulate'); - $code[$i][2] = $this->simulateSelector; - $code[$i++][3] = $displayFullText ? ' ' : t3lib_BEfunc::cshItem('_MOD_user_setup', 'simuser', $BACK_PATH); + if ($this->simulateSelector) { + $data['simulate'] = array( + 'type' => 'select', + 'form' => $this->simulateSelector, + 'csh' => 'simuser' + ); } - - $menuItems[] = array( - 'label' => $LANG->getLL('adminFunctions'), - 'content' => $this->doc->spacer(20).$this->doc->table($code) - ); + $menuItems[] = $this->renderUserSetupTab($data, $LANG->getLL('adminFunctions')); } + + // render the menu items; + $this->content .= $this->doc->spacer(20) . $this->doc->getDynTabMenu($menuItems, 'user-setup', false, false, 100); - $this->content .= $this->doc->spacer(20); - $this->content .= $this->doc->getDynTabMenu($menuItems, 'user-setup', false, false, 100); - // Submit and reset buttons $this->content .= $this->doc->spacer(20); - $this->content .= $this->doc->section('',' + $this->content .= $this->doc->section('', ' '. @@ -597,19 +539,15 @@ * @return array all available buttons as an assoc. array */ protected function getButtons() { - global $LANG, $BACK_PATH, $BE_USER; - $buttons = array( 'csh' => '', 'save' => '', 'shortcut' => '', ); - //CSH - $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_user_setup', '', $BACK_PATH, '|', TRUE); + $buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_user_setup', '', $GLOBALS['BACK_PATH'], '|', true); - if ($BE_USER->mayMakeShortcut()) { - // Shortcut + if ($GLOBALS['BE_USER']->mayMakeShortcut()) { $buttons['shortcut'] = $this->doc->makeShortcutIcon('','',$this->MCONF['name']); } @@ -642,6 +580,40 @@ } /** + * renders the data for one tab in the user setup and returns + * everything that is needed to have a complete tab + * for the dyntab menu + * @param $data a multi-dimensional array that will be converted to table contents + * @param $tabLabel the label that is put on top of the tab array + * @return ready to use for the dyntabmenu itemarray + */ + function renderUserSetupTab($data, $tabLabel) { + $code = array(); + $i = 0; + + // display full help is active? + $displayFullText = ($GLOBALS['BE_USER']->uc['edit_showFieldHelp'] == 'text'); + if ($displayFullText) { + $this->doc->tableLayout['defRowEven'] = array('defCol' => array ('','')); + } + + foreach ($data as $fieldname => $data) { + // add another table row with the full text help if needed + if ($displayFullText) { + $code[$i++][1] = $this->getCSH($data['csh'] ? $data['csh'] : $fieldname); + } + $code[$i][1] = $this->setLabel($fieldname, ($data['labelkey'] ? $data['labelkey'] : '')); + $code[$i][2] = $data['form']; + $code[$i++][3] = !$displayFullText ? $this->getCSH($data['csh'] ? $data['csh'] : $fieldname) : ' '; + } + + return array( + 'label' => $tabLabel, + 'content' => $this->doc->spacer(20) . $this->doc->table($code) + ); + } + + /** * Will make the simulate-user selector if the logged in user is administrator. * It will also set the GLOBAL(!) BE_USER to the simulated user selected if any (and set $this->OLD_BE_USER to logged in user) * @@ -712,7 +684,10 @@ * @return string HTML output. */ function getCSH($str) { - return t3lib_BEfunc::cshItem('_MOD_user_setup', 'option_'.$str, $GLOBALS['BACK_PATH'],'|',FALSE,'margin-bottom:0px;'); + if (!t3lib_div::inList('language', $str)) { + $str = 'option_' . $str; + } + return t3lib_BEfunc::cshItem('_MOD_user_setup', $str, $GLOBALS['BACK_PATH'], '|', false, 'margin-bottom:0px;'); } }