? station_archive_186770.patch
? test.patch
? archive/Thumbs.db
? archive/scripts/1193091785.mp3
? catalog/The Database.mdb
? catalog/fixit.php
? catalog/import.php
? schedule/Copy of station_schedule.module
? schedule/Copy of views.inc
? schedule/Copy of views_defaults.inc
? schedule/images/Thumbs.db
Index: station.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/station.install,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 station.install
--- station.install	10 Aug 2007 17:13:15 -0000	1.9
+++ station.install	31 Oct 2007 17:54:39 -0000
@@ -10,8 +10,6 @@ function station_uninstall() {
   variable_del('station_block_unschedule');
   variable_del('station_remote_archive_url');
   variable_del('station_remote_schedule_url');
-  variable_del('station_stream_high_url');
-  variable_del('station_stream_low_url');
 }
 
 
Index: station.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/station.module,v
retrieving revision 1.32
diff -u -p -u -p -r1.32 station.module
--- station.module	27 Aug 2007 22:53:05 -0000	1.32
+++ station.module	31 Oct 2007 17:54:08 -0000
@@ -331,56 +331,6 @@ function station_get_program_at($timesta
   return NULL;
 }
 
-/**
- * Return HTML body of the block listing the current program.
- *
- * @return string
- */
-function station_block_current_program() {
-  // current program
-  $program = station_get_program_at(time(), 0);
-  $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', ''));
-
-  return theme('station_block_current_program', $program, $unschedule_message, $high, $low);
-}
-
-/**
- * Theme the current program block.
- *
- * @param $program
- *   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
- * @return string
- */
-function theme_station_block_current_program($program = NULL, $unscheduled_message ='', $high_url = NULL, $low_url = NULL) {
-  // program or unscheduled...
-  if ($program) {
-    $output = l($program->title, $program->node_url) .'<br />';
-  }
-  else {
-    $output = $unscheduled_message .'<br />';
-  }
-
-  // webstream links
-  if ($high_url || $low_url) {
-    $output .= t('Tune in: ');
-    if ($high_url) {
-      $output .= ' '. l(t('High'), $high_url);
-    }
-    if ($low_url) {
-      $output .= ' '. l(t('Low'), $low_url);
-    }
-  }
-
-  return $output;
-}
 
 /**
  * Convert an array to a comma separates list with an add between the last terms.
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	31 Oct 2007 17:55:59 -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,40 @@ function station_schedule_update_5200() 
 function station_schedule_update_5201() {
   variable_set('station_schedule_redirect_old_urls', 1);
   return array();
-}
\ No newline at end of file
+}
+
+/**
+ * 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();
+      if ($high = variable_get('station_stream_high_url', '')) {
+        $streams['high'] = array(
+           'name' => t('High'),
+           'description' => t('High bandwidth stream'),
+           'urls' => $high,
+        );
+      }
+      if ($low = variable_get('station_stream_low_url', '')) {
+        $streams['low'] = array(
+          'name' => t('Low'),
+          'description' => t('Low bandwidth stream'),
+          'urls' => $low,
+        );
+      }
+      if (count($streams)) {
+        db_query("UPDATE {station_schedule} SET streams = '%s', unscheduled_message = '%s", serialize($streams), $unscheduled_message);
+      }
+      variable_del('station_stream_high_url');
+      variable_del('station_stream_low_url');
+
+      break;
+  }
+  return $ret;
+}
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	31 Oct 2007 18:01:54 -0000
@@ -67,6 +67,16 @@ function station_schedule_menu($may_cach
       $nid = (int) arg(1);
       $node = node_load($nid);
       if ($node->type == 'station_schedule') {
+        // Stream M3U links
+        foreach ($node->settings['streams'] as $key => $stream) {
+          $items[] = array(
+            'path' => "node/$nid/$key.m3u",
+            'type' => MENU_CALLBACK,
+            'callback' => 'station_schedule_stream_m3u',
+            'callback arguments' => array($stream),
+          );
+        }
+
         $items[] = array(
           'path' => "node/$nid/view/week",
           'title' => t('Week'),
@@ -196,6 +206,38 @@ function station_schedule_form($node) {
     '#options' => array(15 => t('15 Minutes'), 30 => t('30 Minutes'), 60 => t('1 Hour')),
     '#description' => t("This is the minimum increment that programs can be scheduled in. <strong>Caution:</strong> Increasing this value on an existing schedule will probably cause wierdness."),
   );
+  $form['settings']['streams'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Web streams'),
+    '#theme' => 'station_schedule_form_streams',
+    '#collapsible' => TRUE,
+    '#description' => t("If your station has webstreams enter them below."),
+  );
+  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']),
+    );
+  }
 
   if ($type->has_body) {
     $form['body_filter']['body'] = array(
@@ -212,6 +254,63 @@ function station_schedule_form($node) {
   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 +337,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 +356,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 +372,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() {
@@ -1223,3 +1331,34 @@ function station_schedule_day_page($node
 
   return $output;
 }
+
+/**
+ * Send the client an M3U file of the streams.
+ *
+ * @param $stream An array with a 'urls' item containing an array of webstream
+ *   URLs.
+ */
+function station_schedule_stream_m3u($stream) {
+  drupal_set_header('Content-Type: audio/mpegurl');
+  $output = '';
+  foreach ($stream['urls'] as $url) {
+    $output .= $url ."\n";
+  }
+  print $output;
+  exit();
+}
+
+/**
+ * Theme a station node's web streams.
+ *
+ * @param $node A station schedule node.
+ */
+function theme_station_schedule_streams($node) {
+  if (count($node->settings['streams'])) {
+    $output = t('Tune in: ');
+    foreach ($node->settings['streams'] as $key => $stream) {
+      $output .= l($stream['name'], "node/{$node->nid}/$key.m3u");
+    }
+    return $output;
+  }
+}
Index: schedule/views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/schedule/views.inc,v
retrieving revision 1.12
diff -u -p -u -p -r1.12 views.inc
--- schedule/views.inc	14 Sep 2007 18:15:26 -0000	1.12
+++ schedule/views.inc	31 Oct 2007 17:59:59 -0000
@@ -27,7 +27,26 @@ function station_schedule_views_tables()
       ),
     ),
   );
-
+  $tables['station_schedule'] = array(
+    'name' => 'station_schedule',
+    'join' => array(
+      'left' => array(
+        'table' => 'node',
+        'field' => 'nid'
+      ),
+      'right' => array(
+        'field' => 'nid'
+      )
+    ),
+    'fields' => array(
+      'streams' => array(
+        'name' => t('Station Schedule: Web streams'),
+        'help' => t("Web stream links"),
+        'sortable' => FALSE,
+        'handler' => 'station_handler_field_schedule_streams',
+      ),
+    ),
+  );
   $tables['station_schedule_item'] = array(
     'name' => 'station_schedule_item',
     'join' => array(
@@ -111,6 +130,13 @@ function station_schedule_views_tables()
   return $tables;
 }
 
+function station_handler_field_schedule_streams($fieldinfo, $fielddata, $value, $data) {
+  if ($streams = unserialize($data->station_schedule_streams)) {
+    $data->settings['streams'] = $streams;
+    return theme('station_schedule_streams', $data);
+  }
+}
+
 function station_handler_field_schedule_times($fieldinfo, $fielddata, $value, $data) {
   if ($program = node_load($data->nid)) {
     $scheduled = array();
