? test.patch
? archive/_________station_archive.install
? archive/____station_archive.module
? catalog/The Database.mdb
? catalog/fixit.php
? catalog/import.php
Index: schedule/views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/schedule/views.inc,v
retrieving revision 1.14
diff -u -p -u -p -r1.14 views.inc
--- schedule/views.inc	1 Nov 2007 17:52:11 -0000	1.14
+++ schedule/views.inc	26 Nov 2007 16:49:16 -0000
@@ -84,9 +84,24 @@ function station_schedule_views_tables()
       )
     ),
     'fields' => array(
+      'start' => array(
+        'name' => t('Station Schedule: Single scheduled time'),
+        'help' => t("Single instance of the program on the schedule. Use this when you want a program displayed for each time it's scheduled."),
+        'sortable' => TRUE,
+        'sort_handler' => 'station_handler_field_sort_schedule_item_start',
+        'handler' => 'station_handler_field_schedule_time',
+        'option' => array(
+          '#type' => 'select',
+          '#options' => array(
+            'hour' => t('Show only hours'),
+            'dayhour' => t('Show days and hours'),
+          ),
+        ),
+        'addlfields' => array('finish', 'schedule_nid'),
+      ),
       'times' => array(
-        'name' => t('Station Schedule: Scheduled times'),
-        'help' => t("The time a program begins."),
+        'name' => t('Station Schedule: All scheduled times'),
+        'help' => t("Summary of all the times the program is scheduled."),
         'sortable' => FALSE,
         'notafield' => TRUE,
         'handler' => 'station_handler_field_schedule_times',
@@ -150,11 +165,27 @@ function station_schedule_views_tables()
         'help' => t("Filter down to the program that is currently being broadcast."),
       ),
     ),
+    'sorts' => array(
+      'start' => array(
+        'name' => t('Station Schedule: Start time'),
+        'help' => t('Sort the nodes based on their scheduled starting time.'),
+        'handler' => 'station_handler_sort_schedule_item_start',
+      ),
+    ),
   );
 
   return $tables;
 }
 
+/**
+ * Substitute current time; this works with cached queries.
+ */
+function station_schedule_views_query_substitutions($view) {
+  $timestamp = station_local_ts(time());
+  $minute = station_minute_from_day_hour(date('w', $timestamp), date('G', $timestamp));
+  return array('***CURRENT_STATION_MINUTE***' => $minute);
+}
+
 function station_handler_field_schedule_current_program($fieldinfo, $fielddata, $value, $data) {
   if (isset($data->station_schedule_item_current_program_nid)) {
     if ($program = node_load($data->station_schedule_item_current_program_nid)) {
@@ -172,6 +203,15 @@ function station_handler_field_schedule_
   }
 }
 
+function station_handler_field_schedule_time($fieldinfo, $fielddata, $value, $data) {
+  if (isset($data->station_schedule_item_start) && isset($data->station_schedule_item_finish)) {
+    if ($fielddata['options'] == 'dayhour') {
+      return theme('station_hour_range', $data->station_schedule_item_start, $data->station_schedule_item_finish);
+    }
+    return theme('station_dayhour_range', $data->station_schedule_item_start, $data->station_schedule_item_finish);
+  }
+}
+
 function station_handler_field_schedule_times($fieldinfo, $fielddata, $value, $data) {
   if ($program = node_load($data->nid)) {
     $scheduled = array();
@@ -218,6 +258,20 @@ function station_handler_field_listen_li
   return l($links['station_archive_rss']['title'], $links['station_archive_rss']['href'], NULL, NULL, NULL, TRUE, TRUE);
 }
 
+function station_handler_field_sort_schedule_item_start($fielddata, $fieldinfo) {
+  $start_offset = (int) MINUTES_IN_DAY * (7 - variable_get('date_first_day', 0));
+  $divisor = (int) MINUTES_IN_WEEK;
+  return "(({$fielddata['fullname']} + {$start_offset}) %% {$divisor})"; 
+}
+
+function station_handler_sort_schedule_item_start($op, &$query, $sortinfo, $sortdata) {
+  $start_offset = (int) MINUTES_IN_DAY * (7 - variable_get('date_first_day', 0));
+  $divisor = (int) MINUTES_IN_WEEK;
+  $formula = "(({$sortdata['field']} + {$start_offset}) %% {$divisor})";
+
+  $query->add_orderby(NULL, $formula, $sortdata['sortorder'], $sortinfo['table'] . '.start_sort');
+}
+
 
 function station_handler_filter_is_scheduled($op, $filterdata, $filterinfo, &$query) {
   switch ($op) {
@@ -233,15 +287,6 @@ function station_handler_filter_is_sched
   }
 }
 
-/**
- * Substitute current time; this works with cached queries.
- */
-function station_schedule_views_query_substitutions($view) {
-  $timestamp = station_local_ts(time());
-  $minute = station_minute_from_day_hour(date('w', $timestamp), date('G', $timestamp));
-  return array('***CURRENT_STATION_MINUTE***' => $minute);
-}
-
 function station_handler_filter_now_playing($op, $filterdata, $filterinfo, &$query) {
   switch ($op) {
   case 'handler':
