Index: worldclock.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/worldclock/worldclock.module,v
retrieving revision 1.1.4.3
diff -u -p -r1.1.4.3 worldclock.module
--- worldclock.module	9 May 2008 13:37:57 -0000	1.1.4.3
+++ worldclock.module	11 May 2008 10:02:31 -0000
@@ -189,31 +189,31 @@ function get_location_info($loc) {
   $mon_array = array('', t('January'), t('February'), t('March'), t('April'),
                      t('May'), t('June'), t('July'), t('August'),
                      t('September'), t('October'), t('November'), t('December'));
-  $out = '';
+  $output = '';
   if ($loc[INDEX_GMT] >= 0) {
-    $out .= t('GMT +') . $loc[INDEX_GMT] .', ';
+    $output .= t('GMT +') . $loc[INDEX_GMT] .', ';
   }
   else {
-    $out .= t('GMT ') . $loc[INDEX_GMT] .', ';
+    $output .= t('GMT ') . $loc[INDEX_GMT] .', ';
   }
   if ($loc[INDEX_DST] == 0) {
-    $out .= t('No DST ');
+    $output .= t('No DST ');
   }
   else {
-    $out .= t('DST ');
+    $output .= t('DST ');
     // now add DST start and end information
   $out .= t(' from !stime:00AM on !snth !sdow in !smonth',
             array('!stime'  => $loc[INDEX_STIME],
                   '!snth'   => $nth_array[$loc[INDEX_SNTH]],
                   '!sdow'   => $dow_array[$loc[INDEX_SDOW]],
                   '!smonth' => $mon_array[$loc[INDEX_SMON]]));
-  $out .= t(' to !etime:00AM on !enth !edow in !emonth',
+  $output .= t(' to !etime:00AM on !enth !edow in !emonth',
             array('!etime'  => $loc[INDEX_ETIME],
                   '!enth'   => $nth_array[$loc[INDEX_ENTH]],
                   '!edow'   => $dow_array[$loc[INDEX_EDOW]],
                   '!emonth' => $mon_array[$loc[INDEX_EMON]]));
   }
-  return $out;
+  return $output;
 }
 
 /**
@@ -267,82 +267,38 @@ function worldclock_block($op='list', $d
     $maxnum    = variable_get('worldclock_maxnum', 4);
     $footnote  = variable_get('worldclock_footnote', '');
     $showzebra = variable_get('worldclock_showzebra', 0);
-    $format    = variable_get('worldclock_format', 'm/d h:i A');
-    $timestr   = variable_get('worldclock_timestr', 'm/d h:i A');
     $showdst   = variable_get('worldclock_showdst', 0);
     $dststr    = variable_get('worldclock_dststr', '*');
+    $timestr   = variable_get('worldclock_format', 'm/d h:i A');
+    if ($timestr == 'custom') {
+      $timestr = variable_get('worldclock_timestr', 'm/d h:i A');
+    }
     
     // output block content
-    $output = theme('clocks_list', $wc_location, $maxnum, $showzebra, $footnote);
+    $output = theme('clocks_list', $wc_location, $maxnum, $showzebra, $timestr, $footnote);
     
     // output javascript
     $output .= '<script language="javascript">';
     $output .= 'var locations = new Array();';
-    $output .= 'var sdow;';
-    $output .= 'var smon;';
-    $output .= 'var maxnum;';
-    $output .= 'var time_str;';
-    $output .= 'var show_dst;';
-    $output .= 'var dst_str;';
-    $output .= 'maxnum  = '. $maxnum .';';
-    if ($format == 'custom') {
-      $output .= 'time_str = "'. $timestr .'";';
-    }
-    else {
-      $output .= 'time_str = "'. $format .'";';
-    }
-    $output .= 'show_dst = '. $showdst .';';
-    $output .= 'dst_str  = "'. $dststr .'";';
-    $output .= "sdow = new Array('" .
-      t('Sun') ."', '" .
-      t('Mon') ."', '" .
-      t('Tue') ."', '" .
-      t('Wed') ."', '" .
-      t('Thu') ."', '" .
-      t('Fri') ."', '" .
-      t('Sat') ."');";
-    $output .= "smon = new Array('" .
-      t('Jan') ."', '" .
-      t('Feb') ."', '" .
-      t('Mar') ."', '" .
-      t('Apr') ."', '" .
-      t('May') ."', '" .
-      t('Jun') ."', '" .
-      t('Jul') ."', '" .
-      t('Aug') ."', '" .
-      t('Sep') ."', '" .
-      t('Oct') ."', '" .
-      t('Nov') ."', '" .
-      t('Dec') ."');";
+    $output .= 'var maxnum  = '. $maxnum .';';
+    $output .= 'var time_str = "'. $timestr .'";';
+    $output .= 'var show_dst = '. $showdst .';';
+    $output .= 'var dst_str  = "'. $dststr .'";';
+    
+    $days_short = array(t('Sun'), t('Mon'), t('Tue'), t('Wed'), t('Thu'), t('Fri'), t('Sat'));
+    $days_long  = array(t('Sunday'), t('Monday'), t('Tueday'), t('Wedday'), t('Thuday'), t('Friday'), t('Satday'));
+    $months_short = array(t('Jan'), t('Feb'), t('Mar'), t('Apr'), t('May'), t('Jun'), t('Jul'), t('Aug'), t('Sep'), t('Oct'), t('Nov'), t('Dec'));
+    $months_long  = array(t('January'), t('February'), t('March'), t('April'), t('May'), t('June'), t('July'), t('August'), t('September'), t('October'), t('November'), t('December'));
+    
+    $output .= 'var sdow = '. drupal_to_js($days_short) .';';
+    $output .= 'var ldow = '. drupal_to_js($days_long) .';';
+    $output .= 'var smon = '. drupal_to_js($months_short) .';';
+    $output .= 'var lmon = '. drupal_to_js($months_long) .';';
 
     for ($j = 1 ; $j <= $maxnum ; $j++) {
       $loc_no = variable_get('worldclock_location_'. $j, 0);
       // get the location record
-      $loc = $wc_location[$loc_no];
-      $loc_name  = $loc[INDEX_NAME];
-      $loc_diff  = $loc[INDEX_GMT];
-      $loc_dst   = $loc[INDEX_DST];
-      $loc_smon  = $loc[INDEX_SMON];
-      $loc_snth  = $loc[INDEX_SNTH];
-      $loc_sdow  = $loc[INDEX_SDOW];
-      $loc_stime = $loc[INDEX_STIME];
-      $loc_emon  = $loc[INDEX_EMON];
-      $loc_enth  = $loc[INDEX_ENTH];
-      $loc_edow  = $loc[INDEX_EDOW];
-      $loc_etime = $loc[INDEX_ETIME];
-      $output .= "locations[" . $j ."] = new Array('" .
-        $loc_no    ."', '" .
-        $loc_name  ."', '" .
-        $loc_diff  ."', '" .
-        $loc_dst   ."', '" .
-        $loc_smon  ."', '" .
-        $loc_snth  ."', '" .
-        $loc_sdow  ."', '" .
-        $loc_stime ."', '" .
-        $loc_emon  ."', '" .
-        $loc_enth  ."', '" .
-        $loc_edow  ."', '" .
-        $loc_etime ."');";
+      $output .= "locations[$j] = ". drupal_to_js(array_merge(array($loc_no), $wc_location[$loc_no])) .';';
     }
     $output .= 'setTimeout("DisplayClock(maxnum, time_str, show_dst, dst_str, locations)", 100);';
     $output .= '</script>';
@@ -353,13 +309,13 @@ function worldclock_block($op='list', $d
 }
 
 /**
- * Theme hook
+ * Theme hook for Drupal 6.x 
  */
 
 function worldclock_theme() {
   return array(
     'clocks_list' => array(
-      'arguments' => array('wc_location' => NULL, 'maxnum' => NULL, 'showzebra' => NULL, 'footnote' => NULL),
+      'arguments' => array('wc_location' => NULL, 'maxnum' => NULL, 'showzebra' => NULL, 'timestr' => NULL, 'footnote' => NULL),
     ),
   );
 }
@@ -368,7 +324,7 @@ function worldclock_theme() {
  * Theming function for block
  */
 
-function theme_clocks_list($wc_location, $maxnum, $showzebra, $footnote) {
+function theme_clocks_list($wc_location, $maxnum, $showzebra, $timestr, $footnote) {
   $output = '';
   // output table HTML
   $tr_class = '';
@@ -384,9 +340,9 @@ function theme_clocks_list($wc_location,
       $loc = $wc_location[$loc_no];
       $loc_name  = $loc[INDEX_NAME];
       $output .= '<tr class="'. $tr_class .'">';
-      $output .= '<td id="worldclock_location">'. $loc_name  .'</td>';
-      $output .= '<td id="worldclock_time">';
-      $output .= '<span id="worldclock'. $j .'"></span></td>';
+      $output .= '<td class="worldclock_location">'. $loc_name  .'</td>';
+      $output .= '<td class="worldclock_time">';
+      $output .= '<span id="worldclock'. $j .'">'. date($timestr) .'</span></td>';
       $output .= '</tr>';
     }
   }
@@ -433,7 +389,7 @@ function worldclock_admin() {
     if ($loc_no) {
       $loc = $wc_location[$loc_no];
       $loc_info = get_location_info($loc);
-  }
+    }
     // create a pull-down menu
     $form['location']['worldclock_location_'. $j] = array(
       '#type' => 'select',
@@ -471,63 +427,63 @@ function worldclock_admin() {
   );
 
   $form['display']['worldclock_format'] = array(
-  '#type' => 'select',
-  '#title' => t('Display format'),
-  '#options' => array(
-    'm/d h:i A'   => t('04/07 01:23 PM'),
-    'm/d h:i a'   => t('04/07 01:23 pm'),
-    'm/d h:i:s A' => t('04/07 01:23:45 PM'),
-    'm/d h:i:s a' => t('04/07 01:23:45 pm'),
-    'm/d H:i'     => t('04/07 13:23'),
-    'm/d H:i:s'   => t('04/07 13:23:45'),
-
-    'M d h:i A'   => t('Apr 07 01:23 PM'),
-    'M d h:i a'   => t('Apr 07 01:23 pm'),
-    'M d h:i:s A' => t('Apr 07 01:23:45 PM'),
-    'M d h:i:s a' => t('Apr 07 01:23:45 pm'),
-    'M d H:i'     => t('Apr 07 13:23'),
-    'M d H:i:s'   => t('Apr 07 13:23:45'),
-
-    'd/m h:i A'   => t('07/04 01:23 PM'),
-    'd/m h:i a'   => t('07/04 01:23 pm'),
-    'd/m h:i:s A' => t('07/04 01:23:45 PM'),
-    'd/m h:i:s a' => t('07/04 01:23:45 pm'),
-    'd/m H:i'     => t('07/04 13:23'),
-    'd/m H:i:s'   => t('07/04 13:23:45'),
-
-    'd M h:i A'   => t('07 Apr 01:23 PM'),
-    'd M h:i a'   => t('07 Apr 01:23 pm'),
-    'd M h:i:s A' => t('07 Apr 01:23:45 PM'),
-    'd M h:i:s a' => t('07 Apr 01:23:45 pm'),
-    'd M H:i'     => t('07 Apr 13:23'),
-    'd M H:i:s'   => t('07 Apr 13:23:45'),
+    '#type' => 'select',
+    '#title' => t('Display format'),
+    '#options' => array(
+      'm/d h:i A'   => t('04/07 01:23 PM'),
+      'm/d h:i a'   => t('04/07 01:23 pm'),
+      'm/d h:i:s A' => t('04/07 01:23:45 PM'),
+      'm/d h:i:s a' => t('04/07 01:23:45 pm'),
+      'm/d H:i'     => t('04/07 13:23'),
+      'm/d H:i:s'   => t('04/07 13:23:45'),
+
+      'M d h:i A'   => t('Apr 07 01:23 PM'),
+      'M d h:i a'   => t('Apr 07 01:23 pm'),
+      'M d h:i:s A' => t('Apr 07 01:23:45 PM'),
+      'M d h:i:s a' => t('Apr 07 01:23:45 pm'),
+      'M d H:i'     => t('Apr 07 13:23'),
+      'M d H:i:s'   => t('Apr 07 13:23:45'),
+
+      'd/m h:i A'   => t('07/04 01:23 PM'),
+      'd/m h:i a'   => t('07/04 01:23 pm'),
+      'd/m h:i:s A' => t('07/04 01:23:45 PM'),
+      'd/m h:i:s a' => t('07/04 01:23:45 pm'),
+      'd/m H:i'     => t('07/04 13:23'),
+      'd/m H:i:s'   => t('07/04 13:23:45'),
+
+      'd M h:i A'   => t('07 Apr 01:23 PM'),
+      'd M h:i a'   => t('07 Apr 01:23 pm'),
+      'd M h:i:s A' => t('07 Apr 01:23:45 PM'),
+      'd M h:i:s a' => t('07 Apr 01:23:45 pm'),
+      'd M H:i'     => t('07 Apr 13:23'),
+      'd M H:i:s'   => t('07 Apr 13:23:45'),
 
-    'custom'      => t('Custom format'),
+      'custom'      => t('Custom format'),
     ),
-  '#description' => t('Date/time used for the menu item is not a current time, but an example..'),
-  '#default_value' => $format,
-  '#attributes' => array('onchange' => 'ChangeFormat(this)'),
+    '#description' => t('Date/time used for the menu item is not a current time, but an example..'),
+    '#default_value' => $format,
+    '#attributes' => array('onchange' => 'ChangeFormat(this)'),
   );
 
   if ($format == 'custom') {
-  $timestr_style = 'visibility: visible; overflow: hidden;';
+    $timestr_style = 'visibility: visible; overflow: hidden;';
   }
   else {
-  $timestr_style = 'visibility: hidden; height: 0px; overflow: hidden;';
+    $timestr_style = 'visibility: hidden; height: 0px; overflow: hidden;';
   }
 
   $timestr_example = date($timestr);
 
   $form['display']['worldclock_timestr'] = array(
     '#type' => 'textfield',
-  '#title' => t('Custom format string'),
-  '#size' => 20,
-  '#maxlength' => 20,
-  '#field_suffix' => t(' Example: <b>!str1</b>', array('!str1' => date($timestr))),
-  '#default_value' => $timestr,
-  '#description' => $format_desc,
-  '#prefix' => '<div id="worldclock_timestr_div" style="'. $timestr_style .'">',
-  '#suffix' => '</div>',
+    '#title' => t('Custom format string'),
+    '#size' => 20,
+    '#maxlength' => 20,
+    '#field_suffix' => t(' Example: <b>!str1</b>', array('!str1' => date($timestr))),
+    '#default_value' => $timestr,
+    '#description' => $format_desc,
+    '#prefix' => '<div id="worldclock_timestr_div" style="'. $timestr_style .'">',
+    '#suffix' => '</div>',
   );
 
   $form['display']['worldclock_showdst'] = array(
@@ -539,20 +495,20 @@ function worldclock_admin() {
 
   $form['display']['worldclock_dststr'] = array(
     '#type' => 'textfield',
-  '#title' => t('DST marker'),
-  '#size' => 10,
-  '#maxlength' => 10,
-  '#default_value' => variable_get('worldclock_dststr', '*'),
-  '#description' => t('Specify the DST marker (Symbol, character or a short text). HTML tags are allowed.'),
+    '#title' => t('DST marker'),
+    '#size' => 10,
+    '#maxlength' => 10,
+    '#default_value' => variable_get('worldclock_dststr', '*'),
+    '#description' => t('Specify the DST marker (Symbol, character or a short text). HTML tags are allowed.'),
   );
 
   $form['display']['worldclock_footnote'] = array(
     '#type' => 'textfield',
-  '#title' => t('Footnote'),
-  '#size' => 60,
-  '#maxlength' => 60,
-  '#default_value' => variable_get('worldclock_footnote', ''),
-  '#description' => t('Footnote, if any (for example, an explanation about DST marker). HTML tags are allowed.'),
+    '#title' => t('Footnote'),
+    '#size' => 60,
+    '#maxlength' => 60,
+    '#default_value' => variable_get('worldclock_footnote', ''),
+    '#description' => t('Footnote, if any (for example, an explanation about DST marker). HTML tags are allowed.'),
   );
 
   $form['advanced'] = array(
