Followup to #7361: Using label tags in setup module
authorIngmar Schlecht <ingmar.schlecht@typo3.org>
Sun, 3 Feb 2008 18:40:55 +0000 (18:40 +0000)
committerIngmar Schlecht <ingmar.schlecht@typo3.org>
Sun, 3 Feb 2008 18:40:55 +0000 (18:40 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3041 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/setup/mod/index.php

index 068b9b2..ced2041 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2008-02-03  Ingmar Schlecht  <ingmar@typo3.org>
 
-       * Followup to #7282: Username is now only linked to user setup if the module is accessible
+       * Followup to #7282: Username is now only linked to user setup if the module is accessible, thanks to Steffen Kamper
+       * Followup to #7361: Using label tags in setup module
 
 2008-02-03  Benjamin Mack  <mack@xnos.org>
 
index 46bb41e..273cd5d 100755 (executable)
@@ -309,23 +309,23 @@ class SC_mod_user_setup_index {
                        // Personal data
                $code = array();
                $code[1][1] = $this->setLabel('beUser_realName');
-               $code[1][2] = '<input type="text" name="ext_beuser[realName]" value="'.htmlspecialchars($BE_USER->user['realName']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
+               $code[1][2] = '<input id="field_beUser_realName" type="text" name="ext_beuser[realName]" value="'.htmlspecialchars($BE_USER->user['realName']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
                $code[1][3] = $this->getCSH('beUser_realName');
                
                $code[2][1] = $this->setLabel('beUser_email');
-               $code[2][2] = '<input type="text" name="ext_beuser[email]" value="'.htmlspecialchars($BE_USER->user['email']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
+               $code[2][2] = '<input id="field_beUser_email" type="text" name="ext_beuser[email]" value="'.htmlspecialchars($BE_USER->user['email']).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />';
                $code[2][3] = $this->getCSH('beUser_email');
                
                $code[3][1] = $this->setLabel('emailMeAtLogin').($BE_USER->user['email'] ? ' ('.$BE_USER->user['email'].')' : '');
-               $code[3][2] = '<input type="checkbox" name="data[emailMeAtLogin]"'.($BE_USER->uc['emailMeAtLogin']?' checked="checked"':'').' />';
+               $code[3][2] = '<input id="field_emailMeAtLogin" type="checkbox" name="data[emailMeAtLogin]"'.($BE_USER->uc['emailMeAtLogin']?' checked="checked"':'').' />';
                $code[3][3] = $this->getCSH('emailMeAtLogin');
                
                $code[4][1] = $this->setLabel('newPassword');
-               $code[4][2] = '<input type="password" name="ext_beuser[password1]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\';" />';
+               $code[4][2] = '<input id="field_newPassword" type="password" name="ext_beuser[password1]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\';" />';
                $code[4][3] = $this->getCSH('newPassword');
                
                $code[5][1] = $this->setLabel('newPasswordAgain');
-               $code[5][2] = '<input type="password" name="ext_beuser[password2]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\'" />';
+               $code[5][2] = '<input id="field_newPasswordAgain" type="password" name="ext_beuser[password2]" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' onchange="this.value=this.value?MD5(this.value):\'\'" />';
                $code[5][3] = $this->getCSH('newPasswordAgain');
                
                        // Languages:
@@ -348,7 +348,7 @@ class SC_mod_user_setup_index {
                }
                ksort($opt);
                $languageCode = '
-                               <select name="data[lang]">'.
+                               <select id="field_language" name="data[lang]">'.
                                        implode('',$opt).'
                                </select>';
                        if ($BE_USER->uc['lang'] && !@is_dir(PATH_typo3conf.'l10n/'.$BE_USER->uc['lang']))      {
@@ -375,11 +375,11 @@ class SC_mod_user_setup_index {
                $code = array();
 
                $code[2][1] = $this->setLabel('condensedMode','condensedMode');
-               $code[2][2] = '<input type="checkbox" name="data[condensedMode]"'.($BE_USER->uc['condensedMode']?' checked="checked"':'').' />';
+               $code[2][2] = '<input id="field_condensedMode" type="checkbox" name="data[condensedMode]"'.($BE_USER->uc['condensedMode']?' checked="checked"':'').' />';
                $code[2][3] = $this->getCSH('condensedMode');
                
                $code[3][1] = $this->setLabel('noMenuMode','noMenuMode');
-               $code[3][2] = '<select name="data[noMenuMode]">
+               $code[3][2] = '<select id="field_noMenuMode" name="data[noMenuMode]">
                        <option value=""'.(!$BE_USER->uc['noMenuMode']?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_def').'</option>
                        <option value="1"'.($BE_USER->uc['noMenuMode'] && (string)$BE_USER->uc['noMenuMode']!="icons"?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_sel').'</option>
                        <option value="icons"'.((string)$BE_USER->uc['noMenuMode']=='icons'?' selected="selected"':'').'>'.$LANG->getLL('noMenuMode_icons').'</option>
@@ -387,7 +387,7 @@ class SC_mod_user_setup_index {
                $code[3][3] = $this->getCSH('noMenuMode');
                
                $code[4][1] = $this->setLabel('startModule','startModule');
-               $modSelect = '<select name="data[startModule]">';
+               $modSelect = '<select id="field_startModule" name="data[startModule]">';
                $modSelect .= '<option value=""></option>';
                if (empty($BE_USER->uc['startModule'])) {
                        $BE_USER->uc['startModule'] = $BE_USER->uc_default['startModule'];
@@ -407,15 +407,15 @@ class SC_mod_user_setup_index {
                $code[4][3] = $this->getCSH('startModule');
                
                $code[5][1] = $this->setLabel('showThumbs','thumbnailsByDefault');
-               $code[5][2] = '<input type="checkbox" name="data[thumbnailsByDefault]"'.($BE_USER->uc['thumbnailsByDefault']?' checked="checked"':'').' />';
+               $code[5][2] = '<input id="field_showThumbs" type="checkbox" name="data[thumbnailsByDefault]"'.($BE_USER->uc['thumbnailsByDefault']?' checked="checked"':'').' />';
                $code[5][3] = $this->getCSH('showThumbs');
                
                $code[6][1] = $this->setLabel('helpText');
-               $code[6][2] = '<input type="checkbox" name="data[helpText]"'.($BE_USER->uc['helpText']?' checked="checked"':'').' />';
+               $code[6][2] = '<input id="field_helpText" type="checkbox" name="data[helpText]"'.($BE_USER->uc['helpText']?' checked="checked"':'').' />';
                $code[6][3] = $this->getCSH('helpText');
                
                $code[7][1] = $this->setLabel('edit_showFieldHelp');
-               $code[7][2] = '<select name="data[edit_showFieldHelp]">
+               $code[7][2] = '<select id="field_edit_showFieldHelp" name="data[edit_showFieldHelp]">
                        <option value="">'.$LANG->getLL('edit_showFieldHelp_none').'</option>
                        <option value="icon"'.($BE_USER->uc['edit_showFieldHelp']=='icon'?' selected="selected"':'').'>'.$LANG->getLL('edit_showFieldHelp_icon').'</option>
                        <option value="text"'.($BE_USER->uc['edit_showFieldHelp']=='text'?' selected="selected"':'').'>'.$LANG->getLL('edit_showFieldHelp_message').'</option>
@@ -423,7 +423,7 @@ class SC_mod_user_setup_index {
                $code[7][3] = $this->getCSH('edit_showFieldHelp');
                
                $code[8][1] = $this->setLabel('maxTitleLen','titleLen');
-               $code[8][2] = '<input type="text" name="data[titleLen]" value="'.$BE_USER->uc['titleLen'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />';
+               $code[8][2] = '<input id="field_maxTitleLen" type="text" name="data[titleLen]" value="'.$BE_USER->uc['titleLen'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />';
                $code[8][3] = $this->getCSH('maxTitleLen');
                
                $menuItems[] = array(
@@ -436,25 +436,25 @@ class SC_mod_user_setup_index {
                $code = array();
                if ($GLOBALS['TYPO3_CONF_VARS']['BE']['RTEenabled'])    {
                        $code[2][1] = $this->setLabel('edit_RTE');
-                       $code[2][2] = '<input type="checkbox" name="data[edit_RTE]"'.($BE_USER->uc['edit_RTE']?' checked="checked"':'').' />';
+                       $code[2][2] = '<input id="field_edit_RTE" type="checkbox" name="data[edit_RTE]"'.($BE_USER->uc['edit_RTE']?' checked="checked"':'').' />';
                        $code[2][3] = $this->getCSH('edit_RTE');
                }
                $code[4][1] = $this->setLabel('edit_docModuleUpload');
-               $code[4][2] = '<input type="checkbox" name="data[edit_docModuleUpload]"'.($BE_USER->uc['edit_docModuleUpload']?' checked="checked"':'').' />';
+               $code[4][2] = '<input id="field_edit_docModuleUpload" type="checkbox" name="data[edit_docModuleUpload]"'.($BE_USER->uc['edit_docModuleUpload']?' checked="checked"':'').' />';
                $code[4][3] = $this->getCSH('edit_docModuleUpload');
                
                $code[6][1] = $this->setLabel('disableCMlayers');
-               $code[6][2] = '<input type="checkbox" name="data[disableCMlayers]"'.($BE_USER->uc['disableCMlayers']?' checked="checked"':'').' />';
+               $code[6][2] = '<input id="field_disableCMlayers" type="checkbox" name="data[disableCMlayers]"'.($BE_USER->uc['disableCMlayers']?' checked="checked"':'').' />';
                $code[6][3] = $this->getCSH('disableCMlayers');
 
 
                        // Advanced Operations:
                $code[8][1] = $this->setLabel('copyLevels');
-               $code[8][2] = '<input type="text" name="data[copyLevels]" value="'.$BE_USER->uc['copyLevels'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />&nbsp;'.$LANG->getLL('levels');
+               $code[8][2] = '<input id="field_copyLevels" type="text" name="data[copyLevels]" value="'.$BE_USER->uc['copyLevels'].'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).' maxlength="5" />&nbsp;'.$LANG->getLL('levels');
                $code[8][3] = $this->getCSH('copyLevels');
                
                $code[10][1] = $this->setLabel('recursiveDelete');
-               $code[10][2] = '<input type="checkbox" name="data[recursiveDelete]"'.($BE_USER->uc['recursiveDelete']?' checked="checked"':'').' />';
+               $code[10][2] = '<input id="field_recursiveDelete" type="checkbox" name="data[recursiveDelete]"'.($BE_USER->uc['recursiveDelete']?' checked="checked"':'').' />';
                $code[10][3] = $this->getCSH('recursiveDelete');
                
                $menuItems[] = array(
@@ -567,7 +567,7 @@ class SC_mod_user_setup_index {
                                        $opt[] = '<option value="'.$rr['uid'].'"'.($this->simUser==$rr['uid']?' selected="selected"':'').'>'.htmlspecialchars($rr['username'].' ('.$rr['realName'].')').'</option>';
                                }
                        }
-                       $this->simulateSelector = '<select name="simulateUser" onchange="window.location.href=\'index.php?simUser=\'+this.options[this.selectedIndex].value;">'.implode('',$opt).'</select>';
+                       $this->simulateSelector = '<select id="field_simulate" name="simulateUser" onchange="window.location.href=\'index.php?simUser=\'+this.options[this.selectedIndex].value;">'.implode('',$opt).'</select>';
                }
 
                if ($this->simUser>0)   {       // This can only be set if the previous code was executed.
@@ -588,13 +588,18 @@ class SC_mod_user_setup_index {
         *
         * @param       string          Locallang key
         * @param       string          Alternative override-config key
+        * @param       boolean         Defines whether the string should be wrapped in a <label> tag.
+        * @param       string          Alternative id for use in "for" attribute of <label> tag. By default the $str key is used prepended with "field_".
         * @return      string          HTML output.
         */
-       function setLabel($str,$key='') {
+       function setLabel($str, $key='', $addLabelTag=true, $altLabelTagId='')  {
                $out = $GLOBALS['LANG']->getLL($str) . ': ';
                if (isset($this->overrideConf[($key?$key:$str)]))       {
                        $out = '<span style="color:#999999">'.$out.'</span>';
                }
+               if($addLabelTag) {
+                       $out = '<label for="'.($altLabelTagId?$altLabelTagId:'field_'.$str).'">'.$out.'</label>';
+               }
                return $out;
        }