? test.patch
? archive/Thumbs.db
? archive/scripts/1193091785.mp3
? catalog/The Database.mdb
? catalog/fixit.php
? catalog/import.php
? schedule/images/Thumbs.db
Index: schedule/station_schedule.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/schedule/station_schedule.install,v
retrieving revision 1.14
diff -u -p -u -p -r1.14 station_schedule.install
--- schedule/station_schedule.install	10 Aug 2007 17:13:22 -0000	1.14
+++ schedule/station_schedule.install	26 Oct 2007 20:54:23 -0000
@@ -13,6 +13,7 @@ function station_schedule_install() {
         CREATE TABLE {station_schedule} (
           `nid` int unsigned NOT NULL default '0',
           `increment` int unsigned NOT NULL default '0',
+          `streams` longtext,
           PRIMARY KEY(`nid`)
         ) /*!40100 DEFAULT CHARACTER SET utf8 */;
       ");
@@ -318,4 +319,36 @@ function station_schedule_update_5200() 
 function station_schedule_update_5201() {
   variable_set('station_schedule_redirect_old_urls', 1);
   return array();
+}
+
+/**
+ * Move the streams from variables into the schedule table.
+ */
+function station_schedule_update_5202() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("ALTER TABLE {station_schedule} ADD COLUMN `streams` longtext AFTER `increment`");
+
+      $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', ''),
+        ),
+      );
+
+      db_query("UPDATE {station_schedule} SET streams = '%s'", serialize($streams));
+
+      variable_del('station_stream_high_url');
+      variable_del('station_stream_low_url');
+      break;
+  }
+  return $ret;
 }
\ No newline at end of file
Index: schedule/station_schedule.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/schedule/station_schedule.module,v
retrieving revision 1.54
diff -u -p -u -p -r1.54 station_schedule.module
--- schedule/station_schedule.module	26 Oct 2007 19:00:14 -0000	1.54
+++ schedule/station_schedule.module	26 Oct 2007 20:57:54 -0000
@@ -86,6 +86,14 @@ function station_schedule_menu($may_cach
             'weight' => $weight++,
           );
         }
+        $items[] = array(
+          'path' => "node/$nid/view/streams",
+          'title' => t('Streams'),
+          'type' => MENU_LOCAL_TASK,
+          'callback' => 'station_schedule_listen_page',
+          'callback arguments' => array($node),
+          'weight' => -10,
+        );
 
         $items[] = array(
           'path' => "node/$nid/schedule",
@@ -202,16 +210,105 @@ function station_schedule_form($node) {
       '#type' => 'textarea',
       '#title' => check_plain($type->body_label),
       '#default_value' => $node->body,
-      '#rows' => 10,
+      '#rows' => 6,
       '#required' => ($type->min_word_count > 0),
       '#description' => t("Description of the schedule."),
     );
     $form['body_filter']['format'] = filter_form($node->format);
   }
+  $form['settings']['streams'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Web streams'),
+    '#theme' => 'station_schedule_form_streams',
+    '#collapsible' => TRUE,
+  );
+
+  if (!isset($node->settings['streams']['new'])) {
+    $node->settings['streams']['new'] = array(
+      'name' => '',
+      'description' => '',
+      'urls' => array(),
+    );
+  }
+  foreach ($node->settings['streams'] as $key => $stream) {
+    $form['settings']['streams'][$key]['name'] = array(
+      '#type' => 'textfield',
+      '#size' => 10,
+      '#default_value' => $stream['name'],
+    );
+    $form['settings']['streams'][$key]['description'] = array(
+      '#type' => 'textfield',
+      '#size' => 20,
+      '#default_value' => $stream['description'],
+    );
+    $form['settings']['streams'][$key]['urls'] = array(
+      '#type' => 'textarea',
+      '#rows' => 2,
+      '#cols' => 20,
+      '#default_value' => implode("\n", $stream['urls']),
+    );
+  }
 
   return $form;
 }
 
+
+function theme_station_schedule_form_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;
+}
+
+/**
+ * Implementation of hook_validate().
+ */
+function station_schedule_validate(&$node) {
+  foreach ($node->settings['streams'] as $key => $stream) {
+    // Must have both a name and URL.
+    if (empty($stream['name']) xor empty($stream['urls'])) {
+      if (empty($stream['name'])) {
+        form_set_error("settings][streams][$key][name", t('You must provide a name for the webstream.'));
+      }
+      else {
+        form_set_error("settings][streams][$key][urls", t('You must provide a URL for the webstream.'));
+      }
+    }
+
+    foreach (explode("\n", $stream['urls']) as $url) {
+      $url = trim($url);
+      if (!empty($url) && !valid_url($url, TRUE)) {
+        form_set_error("settings][streams][$key][urls", t('An invalid webstream URL was provided: %url', array('%url' => $url)));
+      }
+    }
+  }
+}
+
+/**
+ * Implementation of hook_submit().
+ */
+function station_schedule_submit(&$node) {
+  $streams = array();
+  foreach ($node->settings['streams'] as $key => $stream) {
+    // Skip empty rows.
+    if (!empty($stream['name'])) {
+      // Convert URLs into an array.
+      $stream['urls'] = array_map('trim', explode("\n", $stream['urls']));
+      $streams[$stream['name']] = $stream;
+    }
+  }
+  $node->settings['streams'] = $streams;
+}
+
+
 /**
  * Implementation of hook_load().
  */
@@ -238,8 +335,17 @@ function station_schedule_load($node) {
     }
   }
 
+  // Load the settings.
+  $settings = db_fetch_array(db_query('SELECT increment, streams FROM {station_schedule} WHERE nid = %d', $node->nid));
+  if (isset($settings['streams']) && $streams = unserialize($settings['streams'])) {
+    $settings['streams'] = $streams;
+  }
+  else {
+    $settings['streams'] = array();
+  }
+
   return array(
-    'settings' => db_fetch_array(db_query('SELECT increment FROM {station_schedule} WHERE nid = %d', $node->nid)),
+    'settings' => $settings,
     'schedule' => $schedule,
   );
 }
@@ -248,7 +354,7 @@ function station_schedule_load($node) {
  * Implementation of hook_insert().
  */
 function station_schedule_insert($node) {
-  db_query("INSERT INTO {station_schedule} (nid, increment) VALUES (%d, %d)", $node->nid, $node->settings['increment']);
+  db_query("INSERT INTO {station_schedule} (nid, increment, streams) VALUES (%d, %d, '%s')", $node->nid, $node->settings['increment'], serialize($node->settings['streams']));
 }
 
 /**
@@ -264,7 +370,7 @@ function station_schedule_delete($node) 
  */
 function station_schedule_update($node) {
   db_query("DELETE FROM {station_schedule} WHERE nid = %d", $node->nid);
-  db_query("INSERT INTO {station_schedule} (nid, increment) VALUES (%d, %d)", $node->nid, $node->settings['increment']);
+  db_query("INSERT INTO {station_schedule} (nid, increment, streams) VALUES (%d, %d, '%s')", $node->nid, $node->settings['increment'], serialize($node->settings['streams']));
 }
 
 function station_schedule_admin_settings() {
@@ -1170,15 +1276,6 @@ function theme_station_schedule_item($st
   return $output;
 }
 
-
-/**
- * Today's schedule. This is just a short cut for the menu system.
- */
-function station_schedule_today_page($schedule_nid) {
-  $node = node_load($schedule_nid);
-  return station_schedule_day_page($node, station_today());
-}
-
 /**
  * Print a day's schedule page.
  */
@@ -1223,3 +1320,26 @@ function station_schedule_day_page($node
 
   return $output;
 }
+
+/**
+ * Display the listen links for a station_schedule node.
+ */
+function station_schedule_listen_page($node, $stream = NULL) {
+  if (isset($node->settings['streams'][$stream])) {
+    // TODO return an m3u file...
+  }
+
+  $content = array();
+  foreach ($node->settings['streams'] as $key => $stream) {
+    $content[$key]['title'] = array(
+      '#type' => 'item',
+      '#title' => check_plain($stream['name']),
+      '#value' => l(t('Listen'), "node/{$node->nid}/listen/{$stream['name']}", $url),
+      '#description' => check_plain($stream['description']),
+      '#weight' => 0,
+    );
+  }
+
+  return drupal_render($content);
+
+}
\ No newline at end of file
