Index: dayhour.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/Attic/dayhour.inc,v
retrieving revision 1.11.2.1
diff -u -p -r1.11.2.1 dayhour.inc
--- dayhour.inc	26 Mar 2007 16:30:59 -0000	1.11.2.1
+++ dayhour.inc	16 Jul 2007 19:20:44 -0000
@@ -73,7 +73,7 @@ function station_valid_day($day) {
  * @param integer optional day of the week. Sunday = 0
  * @return array|string array if $index isn't specified
  */
-function station_day_name($day = null) {
+function station_day_name($day = NULL) {
   static $days;
   if (!isset($days)) {
     $days = array(
@@ -87,7 +87,7 @@ function station_day_name($day = null) {
     );
   }
 
-  if ($day === null) {
+  if ($day === NULL) {
     return $days;
   }
   else {
Index: station.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/Attic/station.install,v
retrieving revision 1.7
diff -u -p -r1.7 station.install
--- station.install	16 Jan 2007 20:39:06 -0000	1.7
+++ station.install	16 Jul 2007 19:20:44 -0000
@@ -40,3 +40,26 @@ function _station_var_rename($from, $to)
 function station_update_100() {
   return array();
 }
+
+/**
+ * Migrate to the new stream variable format.
+ */
+function station_update_101() {
+  $streams = array(
+    'high' => array(
+      'name' => t('High'),
+      'description' => t('High bandwidth stream'),
+      'urls' => variable_get('station_stream_high_url', ''),
+    ),
+    'low' => array(
+      'name' => t('Low'),
+      'description' => t('Low bandwidth stream'),
+      'urls' => variable_get('station_stream_low_url', ''),
+    ),
+  );
+  variable_set('station_streams', $streams);
+  variable_del('station_stream_high_url');
+  variable_del('station_stream_low_url');
+
+  return array();
+}
\ No newline at end of file
Index: station.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/Attic/station.module,v
retrieving revision 1.27.2.2
diff -u -p -r1.27.2.2 station.module
--- station.module	25 Apr 2007 15:14:37 -0000	1.27.2.2
+++ station.module	16 Jul 2007 19:20:45 -0000
@@ -9,7 +9,7 @@ function station_help($section='') {
     case 'admin/settings/station':
       return t('Configure the core station settings. These settings are used by all of the station modules.');
   }
-  return null;
+  return NULL;
 }
 
 function station_menu($may_cache) {
@@ -22,22 +22,29 @@ function station_menu($may_cache) {
       'callback arguments' => array('station_admin_settings'),
       'description' => t('Change settings for the Station module.'),
       'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM);
-
+      'type' => MENU_NORMAL_ITEM,
+    );
     $items[] = array(
       'path' => 'admin/settings/station/main',
       'title' => t('Core'),
       'callback' => 'drupal_get_form',
       'callback arguments' => array('station_admin_settings'),
       'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => '-10');
+      'weight' => '-10',
+    );
 
     $items[] = array(
       'path' => 'station',
       'title' => t('Station'),
       'callback' => 'station_page',
       'access' => user_access('access content'),
-      'type' => MENU_NORMAL_ITEM);
+    );
+    $items[] = array(
+      'path' => 'station/listen',
+      'title' => t('Listen'),
+      'callback' => 'station_listen_page',
+      'access' => user_access('access content'),
+    );
   }
   return $items;
 }
@@ -47,23 +54,38 @@ function station_menu($may_cache) {
  * the modules settings form
  */
 function station_admin_settings() {
-  $form['station_stream'] = array(
+  $form['station_streams'] = array(
     '#type' => 'fieldset',
     '#title' => t('Webstream settings'),
-    '#description' => t('The station module expects that your station has a high and low bandwidth webstreams.'),
-  );
-  $form['station_stream']['station_stream_high_url'] = array(
-    '#type' => 'textfield',
-    '#title' => t('High-bandwith URL'),
-    '#default_value' => variable_get('station_stream_high_url', ''),
-    '#description' => t('The URL of the station\'s high-bandwith webstream.'),
+    '#tree' => TRUE,
+    '#theme' => 'station_admin_settings_streams',
+    '#description' => t('Add a stream for each format and bit-rate you provide. If you have mupltiple streams put one on each line in the URLs field. To remove a stream, simply clear all its fields.'),
   );
-  $form['station_stream']['station_stream_low_url'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Low-bandwith URL'),
-    '#default_value' => variable_get('station_stream_low_url', ''),
-    '#description' => t('The URL of the station\'s low-bandwith webstream.'),
+
+  $streams = variable_get('station_streams', array());
+  $streams['new'] = array(
+    'name' => '',
+    'description' => '',
+    'urls' => array(),
   );
+  foreach ($streams as $key => $stream) {
+    $form['station_streams'][$key]['name'] = array(
+      '#type' => 'textfield',
+      '#size' => 10,
+      '#default_value' => $stream['name'],
+    );
+    $form['station_streams'][$key]['description'] = array(
+      '#type' => 'textfield',
+      '#size' => 20,
+      '#default_value' => $stream['description'],
+    );
+    $form['station_streams'][$key]['urls'] = array(
+      '#type' => 'textarea',
+      '#rows' => 2,
+      '#cols' => 20,
+      '#default_value' => implode("\n", $stream['urls']),
+    );
+  }
 
   $form['station_remote'] = array(
     '#type' => 'fieldset',
@@ -120,10 +142,29 @@ function station_admin_settings() {
 /**
  * Checks that the RPC endpoint is valid.
  */
-function station_admin_settings_validate($form_id, $edit) {
+function station_admin_settings_validate($form_id, $form) {
+  foreach (element_children($form['station_streams']) as $key) {
+    // Must have both a name and URL.
+    if (empty($form['station_streams'][$key]['name']) xor empty($form['station_streams'][$key]['urls'])) {
+      if (empty($form['station_streams'][$key]['name'])) {
+        form_set_error('station_streams][name', t('You must provide a name.'));
+      }
+      else {
+        form_set_error("station_streams][$key][urls", t('You must provide a webstream URL.'));
+      }
+    }
+
+    foreach (explode("\n", $form['station_streams'][$key]['urls']) as $url) {
+      $url = trim($url);
+      if (!empty($url) && !valid_url($url, TRUE)) {
+        form_set_error("station_streams][$key][urls", t('An invalid webstream URL was provided: %url', array('%url' => $url)));
+      }
+    }
+  }
+
   if (!module_exists('station_schedule')) {
     // check station url
-    if ($url = $edit['station_remote_schedule_url']) {
+    if ($url = $form['station_remote_schedule_url']) {
       $url = check_url($url .'/xmlrpc.php');
       $ret = xmlrpc($url, 'station.program.get.at', time());
       if (xmlrpc_error_msg()) {
@@ -134,13 +175,59 @@ function station_admin_settings_validate
     }
 
     // check that the offset is an integer
-    $offset = $edit['station_remote_schedule_offset'];
+    $offset = $form['station_remote_schedule_offset'];
     if (!(is_numeric($offset) && intval($offset) == $offset)) {
       form_set_error('station_remote_schedule_offset', t('The offset must be an integer.'));
     }
   }
 }
 
+/**
+ * Make changes to the settings before passing them off to
+ * system_settings_form_submit().
+ */
+function station_admin_settings_submit($form_id, &$form_values) {
+  foreach ($form_values['station_streams'] as $key => $stream) {
+    // Remove blank rows.
+    if (empty($stream['name'])) {
+      unset($form_values['station_streams'][$key]);
+    }
+    else {
+      // Convert URLs into an array.
+      $urls = array();
+      foreach (explode("\n", $stream['urls']) as $url) {
+        if ($url = trim($url)) {
+          $urls[] = $url;
+        }
+      }
+      $stream['urls'] = $urls;
+
+      // Use the name as the key.
+      unset($form_values['station_streams'][$key]);
+      $key = drupal_strtolower($key);
+      $form_values['station_streams'][$key] = $stream;
+    }
+  }
+  return system_settings_form_submit($form_id, $form_values);
+}
+
+function theme_station_admin_settings_streams(&$form) {
+  $header = array(t('Name'), t('Description'), t('URLs'));
+  foreach (element_children($form) as $key) {
+    $row = array();
+    $row[] = drupal_render($form[$key]['name']);
+    $row[] = drupal_render($form[$key]['description']);
+    $row[] = drupal_render($form[$key]['urls']);
+    $rows[] = $row;
+  }
+  $output .= theme('table', $header, $rows);
+  $output .= drupal_render($form);
+
+  return $output;
+}
+
+
+
 
 function station_block($op = 'list', $delta = 0, $edit = array()) {
   switch ($op) {
@@ -167,8 +254,7 @@ function station_block($op = 'list', $de
         '#title' => t('No scheduled programming message'),
         '#size' => 60,
         '#description' => t('This string will appear when no program is currently scheduled.'),
-        '#default_value' =>
-          variable_get('station_block_unschedule',  t("We're on autopilot.")),
+        '#default_value' => variable_get('station_block_unschedule',  t("We're on autopilot.")),
       );
     }
     return $form;
@@ -184,6 +270,34 @@ function station_page() {
   return theme('menu_tree', menu_get_active_item());
 }
 
+function station_listen_page($stream = NULL) {
+  $streams = variable_get('station_streams', array();
+
+  if (isset($streams[$stream])) {
+    // TODO return an m3u file...
+  }
+
+  $content = array();
+  foreach ($streams) as $key => $stream) {
+    $content[$key] = array(
+      '#type' => 'fieldset',
+      '#title' => check_plain($stream['name']),
+      '#description' => check_plain($stream['description']),
+      '#weight' => -1,
+    );
+    $items = array();
+    foreach ($stream['urls'] as $url) {
+      $items[] = l($url, $url);
+    }
+    $content[$key]['links'] = array(
+      '#type' => 'item',
+      '#value' => theme('item_list', $items),
+      '#weight' => 1,
+    );
+  }
+
+  return drupal_render($content);
+}
 
 /**
  * Determine if we have a station archive module running locally or access to a
@@ -299,27 +413,24 @@ function station_get_program_at($timesta
 function station_block_current_program() {
   // current program
   $program = station_get_program_at(time());
-  $unschedule_message = check_plain(variable_get('station_block_unschedule',  t("We're on autopilot.")));
-  $high = check_url(variable_get('station_stream_high_url', ''));
-  $low = check_url(variable_get('station_stream_low_url', ''));
+  $unscheduled_message = check_plain(variable_get('station_block_unschedule',  t("We're on autopilot.")));
+  $streams = variable_get('station_streams', array());
 
-  return theme('station_block_current_program', $program, $unschedule_message, $high, $low);
+  return theme('station_block_current_program', $program, $unscheduled_message, $streams);
 }
 
 /**
  * Theme the current program block.
  *
  * @param $program
- *   program node object
+ *   Program node object.
  * @param $unscheduled_message
- *   message to display if no program is scheduled, i.e. when $program is null
- * @param $high_url
- *   optional, high-bandwidth webstream URL
- * @param $low_url
- *   optional, low-bandwith webstream URL
+ *   Message to display if no program is scheduled, i.e. when $program is NULL.
+ * @param $streams
+ *   Array with webstream URLs.
  * @return string
  */
-function theme_station_block_current_program($program = NULL, $unscheduled_message ='', $high_url = NULL, $low_url = NULL) {
+function theme_station_block_current_program($program = NULL, $unscheduled_message ='', $streams) {
   // program or unscheduled...
   if ($program) {
     $output = l($program->title, $program->node_url) .'<br />';
@@ -328,14 +439,11 @@ function theme_station_block_current_pro
     $output = $unscheduled_message .'<br />';
   }
 
-  // webstream links
-  if ($high_url || $low_url) {
+  // Webstream links
+  if (count($streams)) {
     $output .= t('Tune in: ');
-    if ($high_url) {
-      $output .= ' '. l(t('High'), $high_url);
-    }
-    if ($low_url) {
-      $output .= ' '. l(t('Low'), $low_url);
+    foreach ($streams as $stream) {
+      $output .= ' '. l($stream['name'], $stream['url']);
     }
   }
 
Index: archive/station_archive.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/archive/Attic/station_archive.module,v
retrieving revision 1.20.2.1
diff -u -p -r1.20.2.1 station_archive.module
--- archive/station_archive.module	26 Mar 2007 16:30:56 -0000	1.20.2.1
+++ archive/station_archive.module	16 Jul 2007 19:20:45 -0000
@@ -12,7 +12,7 @@ function station_archive_help($section =
     case 'admin/settings/station/archive':
       return t("These settings let you configure the way the station's webstream is archived into audio nodes. Audio is imported into the archive as part of Drupal's cron task. You'll need to ensure that that is properly configured. ");
     default:
-      return null;
+      return NULL;
   }
 }
 
@@ -615,8 +615,8 @@ function _station_archive_get_vid() {
 }
 
 /**
- * Implementation of hook_taxonomy(). Delete our vocabulary variable if the 
- * vocabulary is deleted. 
+ * Implementation of hook_taxonomy(). Delete our vocabulary variable if the
+ * vocabulary is deleted.
  */
 function station_archive($op, $type, $object = NULL) {
   if ($op == 'delete' && $type == 'vocabulary' && $object->vid == _station_archive_get_vid())  {
Index: playlist/station_playlist.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/playlist/Attic/station_playlist.module,v
retrieving revision 1.9.2.2
diff -u -p -r1.9.2.2 station_playlist.module
--- playlist/station_playlist.module	6 Jun 2007 05:59:38 -0000	1.9.2.2
+++ playlist/station_playlist.module	16 Jul 2007 19:20:45 -0000
@@ -18,7 +18,7 @@ function station_playlist_help($section=
     case 'admin/settings/station/playlist':
       return t("These settings allow you to configure the playlist node.");
     default:
-      return null;
+      return NULL;
   }
 }
 
