Index: switchtheme.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/switchtheme/switchtheme.admin.inc,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 switchtheme.admin.inc
--- switchtheme.admin.inc	2 Nov 2008 12:44:36 -0000	1.1.2.3
+++ switchtheme.admin.inc	8 Jan 2011 00:18:33 -0000
@@ -3,38 +3,37 @@
 
 /**
  * @file
- * Switchtheme administration functions.
+ * Administrative functionality for Switchtheme.
  */
 
 /**
- * Form builder function for theme settings; menu callback.
+ * Form constructor for theme settings.
  */
 function switchtheme_admin_settings() {
   $options = switchtheme_options();
-  foreach ($options as $option) {
-    $form['switchtheme']['switchtheme_'. $option] = array(
+  foreach ($options as $name => $label) {
+    $form['switchtheme']['switchtheme_' . $name] = array(
       '#type' => 'textfield',
-      '#title' => $option,
-      '#default_value' => variable_get('switchtheme_'. $option, drupal_ucfirst($option)),
+      '#title' => $label,
+      '#default_value' => variable_get('switchtheme_' . $name, $label),
     );
   }
   return system_settings_form($form);
 }
 
 /**
- * Form builder function for browser settings; menu callback.
+ * Form constructor for browser settings.
  */
 function switchtheme_admin_browser_settings() {
-  $form = array();
   $form['switchtheme_browser_enabled'] = array(
     '#type' => 'checkbox',
     '#title' => t('Browser-based theme switching'),
     '#description' => t('If enabled, the theme will be switched based on the browser of a visitor.'),
     '#default_value' => variable_get('switchtheme_browser_enabled', FALSE),
   );
-  
-  $themes = switchtheme_select();
-  $themes['default'] = 'Default';
+
+  $themes = array('default' => t('Default'));
+  $themes += switchtheme_options();
   $useragents = array();
   $result = db_query('SELECT data FROM {browscap}');
   while ($row = db_fetch_object($result)) {
@@ -51,11 +50,11 @@ function switchtheme_admin_browser_setti
     '#collapsed' => FALSE,
   );
   foreach ($useragents as $parent => $platforms) {
-    $form['switchtheme_browser']['switchtheme_browser_'. md5($parent)] = array(
+    $form['switchtheme_browser']['switchtheme_browser_' . md5($parent)] = array(
       '#type' => 'select',
       '#title' => $parent,
       '#options' => $themes,
-      '#default_value' => variable_get('switchtheme_browser_'. md5($parent), 'default'),
+      '#default_value' => variable_get('switchtheme_browser_' . md5($parent), 'default'),
     );
   }
   return system_settings_form($form);
Index: switchtheme.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/switchtheme/switchtheme.module,v
retrieving revision 1.10.2.8
diff -u -p -r1.10.2.8 switchtheme.module
--- switchtheme.module	8 Jan 2011 00:08:05 -0000	1.10.2.8
+++ switchtheme.module	8 Jan 2011 00:17:21 -0000
@@ -7,7 +7,7 @@
  */
 
 /**
- * Implementation of hook_help().
+ * Implements hook_help().
  */
 function switchtheme_help($path, $arg) {
   switch ($path) {
@@ -24,23 +24,22 @@ function switchtheme_help($path, $arg) {
 }
 
 /**
- * Implementation of hook_perm().
+ * Implements hook_perm().
  */
 function switchtheme_perm() {
   return array('administer switch', 'switch theme');
 }
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function switchtheme_menu() {
-  $items = array();
   $items['admin/settings/switchtheme'] = array(
     'title' => 'Switchtheme',
     'description' => "Configure settings for the Switchtheme block, as well as change how a visitor's user agent affects which theme is used.",
-    'access arguments' => array('administer switch'),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('switchtheme_admin_settings'),
+    'access arguments' => array('administer switch'),
     'file' => 'switchtheme.admin.inc',
   );
   $items['admin/settings/switchtheme/themes'] = array(
@@ -53,8 +52,10 @@ function switchtheme_menu() {
     $items['admin/settings/switchtheme/browser'] = array(
       'title' => 'Browser',
       'description' => "Configuration of switching the theme based on the visitor's browser.",
+      'page callback' => 'drupal_get_form',
       'page arguments' => array('switchtheme_admin_browser_settings'),
       'access arguments' => array('administer switch'),
+      'file' => 'switchtheme.admin.inc',
       'type' => MENU_LOCAL_TASK,
       'weight' => 2,
     );
@@ -63,7 +64,7 @@ function switchtheme_menu() {
 }
 
 /**
- * Implementation of hook_init().
+ * Implements hook_init().
  */
 function switchtheme_init() {
   global $custom_theme, $user;
@@ -98,7 +99,7 @@ function switchtheme_init() {
 }
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_theme().
  */
 function switchtheme_theme() {
   return array(
@@ -107,7 +108,7 @@ function switchtheme_theme() {
 }
 
 /**
- * Implementation of hook_block().
+ * Implements hook_block().
  */
 function switchtheme_block($op = 'list', $delta = 0, $edit = array()) {
   if ($op == 'list') {
@@ -134,7 +135,7 @@ function switchtheme_block($op = 'list',
 }
 
 /**
- * Render a random theme with screenshot to switch to.
+ * Renders a random theme with screenshot to switch to.
  */
 function switchtheme_display_random_block() {
   $themes = list_themes();
@@ -149,6 +150,9 @@ function switchtheme_display_random_bloc
   }
 }
 
+/**
+ * Form constructor for theme switcher form.
+ */
 function switchtheme_switch_form() {
   global $user, $custom_theme;
 
@@ -171,7 +175,7 @@ function theme_switchtheme_block_form($f
 }
 
 /**
- * Process a block switchtheme form submission.
+ * Form submission handler for switchtheme_switch_form().
  *
  * We do not validate the input here, because that is done in init_theme()
  * already.
@@ -196,31 +200,28 @@ function switchtheme_switch_form_submit(
 }
 
 /**
- * Create an array of enabled themes to select from.
- *
- * @todo Probably should come back here and cache the theme list.
+ * Returns an #options list of enabled themes.
  */
 function switchtheme_options() {
+  $options = array();
   $themes = list_themes();
-  foreach ($themes as $name => $attr) {
-    if ($attr->status) {
-      $options[$attr->name] = $attr->name;
+  foreach ($themes as $name => $theme) {
+    if ($theme->status) {
+      $options[$name] = $theme->info['name'];
     }
   }
   return $options;
 }
 
 /**
- * Create a select list of themes and labels.
+ * Returns switchtheme_options() with customized theme labels.
  */
 function switchtheme_select() {
-  $select  = array();
-  $options = switchtheme_options();
-
-  foreach ($options as $option) {
-    $select[$option] = variable_get('switchtheme_'. $option, drupal_ucfirst($option));
+  $options = array();
+  foreach (switchtheme_options() as $name => $label) {
+    $options[$name] = variable_get('switchtheme_' . $name, $label);
   }
-  asort($select);
-  return $select;
+  asort($options);
+  return $options;
 }
 
