Kaynağa Gözat

make a start with adding labels for html form elements. this aids disabled
users, but also e.g. allows one to click the text next to a checkbox to
select it.

Thijs Kinkhorst 19 yıl önce
ebeveyn
işleme
be88f14bc2

+ 1 - 0
ChangeLog

@@ -95,6 +95,7 @@ Version 1.5.2 - CVS
     in PHP configuration (#1518885).
   - Make the default attachment dir /var/local/squirrelmail/attach, not
     $data_dir.
+  - Add HTML labels for form elements.
 
 Version 1.5.1 (branched on 2006-02-12)
 --------------------------------------

+ 2 - 1
functions/addressbook.php

@@ -233,7 +233,8 @@ function addressbook_inp_field($label, $field, $name, $size, $values, $add='') {
     $td_str .= $add ;
 
     return html_tag( 'tr' ,
-            html_tag( 'td', $label . ':', 'right', $color[4]) .
+            html_tag( 'td', '<label for="'.$name.'_'.$field.'_'.'">' .
+                $label . '</label>:', 'right', $color[4]) .
             html_tag( 'td', $td_str, 'left', $color[4])
             )
         . "\n";

+ 2 - 2
functions/folder_manip.php

@@ -121,7 +121,7 @@ function folders_rename_getname ($imapConnection, $delimiter, $old) {
             html_tag( 'td', '', 'center', $color[4] ) .
             addForm('folders.php').
             addHidden('smaction', 'rename').
-             _("New name:").
+             '<label for="new_name">' . _("New name:") . '</label>' .
              '<br /><b>' . htmlspecialchars($old_parent) . '</b>' .
              addInput('new_name', $old_name, 25) . '<br /><br />' . "\n";
              if ( $isfolder ) {
@@ -342,4 +342,4 @@ function folders_unsubscribe($imapConnection, $folder_names)
 }
 
 
-?>
+?>

+ 5 - 3
src/addrbook_search.php

@@ -209,13 +209,15 @@ if ($show == 'form' && ! isset($listall)) {
             '" method="post">' . "\n" .
          html_tag( 'table', '', '', '', 'border="0" width="100%" height="100%"' ) .
          html_tag( 'tr' ) .
-         html_tag( 'td', '  <strong>' . _("Search for") . "</strong>\n", 'left', '', 'style="white-space: nowrap;" valign="middle" width="10%"' ) .
+         html_tag( 'td', '  <strong><label for="query">' . _("Search for") .
+             "</label></strong>\n", 'left', '',
+             'style="white-space: nowrap;" valign="middle" width="10%"' ) .
          html_tag( 'td', '', 'left', '', '' ) .
          addInput('query', $query, 28);
 
     /* List all backends to allow the user to choose where to search */
     if ($abook->numbackends > 1) {
-        echo '<strong>' . _("in") . '</strong>&nbsp;'."\n";
+        echo '<strong><label for="backend">' . _("in") . '</label></strong>&nbsp;'."\n";
         $selopts = array();
         $selopts['-1'] = _("All address books");
 
@@ -300,4 +302,4 @@ if ($show == 'form' && ! isset($listall)) {
     }
 }
 $oTemplate->display('footer.tpl');
-?>
+?>

+ 7 - 4
src/addressbook.php

@@ -311,22 +311,25 @@ if ($showaddrlist) {
             }
             echo html_tag( 'tr', '', '', $tr_bgcolor);
             if ($abook->backends[$row['backend']]->writeable) {
+                $id = $row['backend'].':'.$row['nickname'];
                 echo html_tag( 'td',
                                '<small>' .
-                               addCheckBox('sel[]', $selected, $row['backend'].':'.$row['nickname']).
+                               addCheckBox("sel[$id]", $selected, $id).
                                '</small>' ,
                                'center', '', 'valign="top" width="1%"' );
+                $label1 = '<label for="sel_'.$id.'_">'; $label2='</label>';
             } else {
                 echo html_tag( 'td',
                                '&nbsp;' ,
                                'center', '', 'valign="top" width="1%"' );
+                $label1 = $label2 = '';
             }
             echo html_tag( 'td',
-                           '&nbsp;' . htmlspecialchars($row['nickname']) . '&nbsp;',
+                           '&nbsp;' . $label1 . htmlspecialchars($row['nickname']) . $label2 . '&nbsp;',
                            'left', '', 'valign="top" width="1%" style="white-space: nowrap;"' );
 
             echo html_tag( 'td',
-                           '&nbsp;' . htmlspecialchars($row['name']) . '&nbsp;',
+                           '&nbsp;' . $label1 . htmlspecialchars($row['name']) . $label2 . '&nbsp;',
                            'left', '', 'valign="top" width="1%" style="white-space: nowrap;"' );
 
             // email address column
@@ -377,4 +380,4 @@ echo "<!-- start of addressbook_bottom hook-->\n";
 do_hook('addressbook_bottom');
 echo "\n<!-- end of addressbook_bottom hook-->\n";
 $oTemplate->display('footer.tpl');
-?>
+?>

+ 11 - 9
src/compose.php

@@ -1151,7 +1151,7 @@ function showInputForm ($session, $values=false) {
         }
         echo '   <tr>' . "\n" .
             html_tag( 'td', '', 'right', $color[4], 'width="10%"' ) .
-            _("From:") . '</td>' . "\n" .
+            '<label for="identity">' . _("From:") . '</label></td>' . "\n" .
             html_tag( 'td', '', 'left', $color[4], 'width="90%"' ) .
             '         '.
             addSelect('identity', $ident_list, $identity, TRUE);
@@ -1162,28 +1162,28 @@ function showInputForm ($session, $values=false) {
 
     echo '   <tr>' . "\n" .
         html_tag( 'td', '', 'right', $color[4], 'width="10%"' ) .
-        _("To") . ':</td>' . "\n" .
+        '<label for="send_to">' . _("To") . '</label>:</td>' . "\n" .
         html_tag( 'td', '', 'left', $color[4], 'width="90%"' ) .
         addInput('send_to', $send_to, 60, 0, $onfocus_array). '<br />' . "\n" .
         '      </td>' . "\n" .
         '   </tr>' . "\n" .
         '   <tr>' . "\n" .
         html_tag( 'td', '', 'right', $color[4] ) .
-        _("Cc") . ':</td>' . "\n" .
+        '<label for="send_to_cc">' . _("Cc") . '</label>:</td>' . "\n" .
         html_tag( 'td', '', 'left', $color[4] ) .
         addInput('send_to_cc', $send_to_cc, 60, 0, $onfocus_array). '<br />' . "\n" .
         '      </td>' . "\n" .
         '   </tr>' . "\n" .
         '   <tr>' . "\n" .
         html_tag( 'td', '', 'right', $color[4] ) .
-        _("Bcc") . ':</td>' . "\n" .
+        '<label for="send_to_bcc">' . _("Bcc") . '</label>:</td>' . "\n" .
         html_tag( 'td', '', 'left', $color[4] ) .
         addInput('send_to_bcc', $send_to_bcc, 60, 0, $onfocus_array).'<br />' . "\n" .
         '      </td>' . "\n" .
         '   </tr>' . "\n" .
         '   <tr>' . "\n" .
         html_tag( 'td', '', 'right', $color[4] ) .
-        _("Subject") . ':</td>' . "\n" .
+        '<label for="subject">' . _("Subject") . '</label>:</td>' . "\n" .
         html_tag( 'td', '', 'left', $color[4] ) . "\n";
     echo '         '.addInput('subject', $subject, 60, 0, $onfocus_array).
         '      </td>' . "\n" .
@@ -1370,7 +1370,7 @@ function showComposeButtonRow() {
         if(!isset($mailprio)) {
             $mailprio = '3';
         }
-        echo '          ' . _("Priority") .
+        echo '          <label for="mailprio">' . _("Priority") . '</label>: '.
             addSelect('mailprio', array(
                         '1' => _("High"),
                         '3' => _("Normal"),
@@ -1380,8 +1380,10 @@ function showComposeButtonRow() {
     if ($default_use_mdn) {
         if ($mdn_user_support) {
             echo '          ' . _("Receipt") .': '.
-                addCheckBox('request_mdn', $request_mdn == '1', '1'). _("On Read").
-                addCheckBox('request_dr',  $request_dr  == '1', '1'). _("On Delivery");
+                addCheckBox('request_mdn', $request_mdn == '1', '1') .
+                    '<label for="request_mdn">' . _("On Read") . '</label>' .
+                addCheckBox('request_dr',  $request_dr  == '1', '1') .
+                    '<label for="request_dr">' .  _("On Delivery") . '</label>';
         }
     }
 
@@ -1732,4 +1734,4 @@ function deliverMessage($composeMessage, $draft=false) {
     }
     return $success;
 }
-?>
+?>

+ 2 - 2
templates/default/message_list.tpl

@@ -140,7 +140,7 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
             case 'checkbox':
                 if ($key != 'bypass_trash') {
 ?>
-                  <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?>&nbsp;
+                  <input type="checkbox" name="<?php echo $key; ?>" id="<?php echo $key; ?>" /><label for="<?php echo $key; ?>"><?php echo $value[0]; ?></label>&nbsp;
 <?php
                 }
                 break;
@@ -162,7 +162,7 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
  <?php
             if (isset($aFormElements['bypass_trash'])) {
 ?>
-                  <input type="checkbox" name="bypass_trash" /><?php echo $aFormElements['bypass_trash'][0]; ?>&nbsp;
+                  <input type="checkbox" name="bypass_trash" id="bypass_trash" /><label for="bypass_trash"><?php echo $aFormElements['bypass_trash'][0]; ?></label>&nbsp;
 <?php
             }
             if (isset($aFormElements['undeleteButton'])) {