Next Scheduled Program Block
tim.plunkett - September 17, 2009 - 22:26
| Project: | Station |
| Version: | 6.x-2.x-dev |
| Component: | Schedule |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Always wanted one of these.
90% of it was copy/paste, but I had to mess around with some of the logic in station_schedule_program_get_next.
Also, didn't write a station_program_get_next, since I didn't understand the XMLRPC/caching stuff.
Works for me, even on the wrap-around between Sunday and Monday.
Cheers!
| Attachment | Size |
|---|---|
| station_next.patch | 6.46 KB |

#1
I think I'd rather focus on the views half of it... it doesn't really seem to be used by the rest of the patch though...
#2
You mean the changes made to station/schedule/views.inc?
Yeah, I just copied everything related to "current_program" and made a "next_program" version, then made appropriate changes.
I ended up not changing anything there, I guess.
I was uncertain pretty much the entire time, so if something seems arbitrary or unnecessary, it probably is.
#3
I think you can actually do this all with the current views code. Try importing this view and playing with it:
<?php$view = new view;
$view->name = 'station_schedule_upcoming';
$view->description = 'Upcoming programming.';
$view->tag = 'station_schedule';
$view->view_php = '';
$view->base_table = 'station_schedule_item';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'program_nid' => array(
'label' => 'Program',
'required' => 0,
'id' => 'program_nid',
'table' => 'station_schedule_item',
'field' => 'program_nid',
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'title' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'program_nid',
),
'start' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'style' => 'station_hour_range',
'exclude' => 0,
'id' => 'start',
'table' => 'station_schedule_item',
'field' => 'start',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'finish' => array(
'order' => 'ASC',
'start_from' => 'now',
'id' => 'finish',
'table' => 'station_schedule_item',
'field' => 'finish',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('title', 'Upcoming Programs');
$handler->override_option('items_per_page', 2);
$handler->override_option('use_more', 0);
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
?>
#4
I'm still baffled by Views sometimes.
For example, why is it that I can use "Station schedule item: Finish" to sort by, but I can't seem to filter by "Station schedule item: Start"?
Otherwise, this code works great, except it includes the show currently on-air. Not sure how to get around that.
#5
Because I never finished the filter handler for that field ;) I got sort of stalled out trying to decide how the option should work. It seemed like it should have options, perhaps:
Though the first two seems like the most important options. I'll spend some time on it today and see what I can whip up. I'd really like to get a "stable" 2.x release out the door and I feel like the schedule views support is one of the last big things to do.
#6
i've committed some other views fixes but here's a patch i'm working on to rework the start and finish handling.
#7
This is getting pretty close. I've broken the schedule item times up into start, finish and time range. This might break some existing views but it should be easy enough to correct.
Updated export of the demo view:
<?php$view = new view;
$view->name = 'station_schedule_upcoming';
$view->description = 'Upcoming programs';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'station_schedule_item';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'program_nid' => array(
'label' => 'Program',
'required' => 0,
'id' => 'program_nid',
'table' => 'station_schedule_item',
'field' => 'program_nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'schedule_nid' => array(
'label' => 'Schedule',
'required' => 0,
'id' => 'schedule_nid',
'table' => 'station_schedule_item',
'field' => 'schedule_nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'title' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'program_nid',
'override' => array(
'button' => 'Override',
),
),
'start' => array(
'label' => 'Start',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'style' => 'station_dayhour',
'exclude' => 0,
'id' => 'start',
'table' => 'station_schedule_item',
'field' => 'start',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'finish' => array(
'label' => 'Finish',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'style' => 'station_hour',
'exclude' => 0,
'id' => 'finish',
'table' => 'station_schedule_item',
'field' => 'finish',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'time' => array(
'label' => 'Duration',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'style' => 'station_hour_duration',
'exclude' => 0,
'id' => 'time',
'table' => 'station_schedule_item',
'field' => 'time',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'start' => array(
'operator' => '<=',
'value' => array(
'mode' => 'now',
'offset' => '',
'value' => 0,
'min' => '',
'max' => '',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => 'start_op',
'label' => 'Station schedule item: Start',
'use_operator' => FALSE,
'identifier' => 'start',
'remember' => FALSE,
'single' => TRUE,
'optional' => TRUE,
),
'id' => 'start',
'table' => 'station_schedule_item',
'field' => 'start',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
'finish' => array(
'operator' => '>',
'value' => array(
'mode' => 'now',
'offset' => '0',
'value' => 1800,
'min' => '',
'max' => '',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'finish',
'table' => 'station_schedule_item',
'field' => 'finish',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
'status_extra' => array(
'operator' => '=',
'value' => '',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status_extra',
'table' => 'node',
'field' => 'status_extra',
'relationship' => 'program_nid',
),
));
$handler->override_option('access', array(
'type' => 'perm',
'perm' => 'view station schedule content',
));
$handler->override_option('title', 'Upcomming programs');
$handler->override_option('empty', 'Nothing is scheduled.');
$handler->override_option('empty_format', '1');
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', 'Station Schedule Upcoming Programs');
$handler->override_option('block_caching', -1);
?>
#8
I committed the patch for the views code since I'm pretty happy with it. I do want to work on a default "now playing" block view to ship with the module (probably disabled).
#9
double post
#10
Just a heads up to anyone applying these patches:
I updated to HEAD, and it broke the views code from comment #3 pretty horribly.
Make sure to delete that view!
So, "Upcoming" is spelled wrong.
Also, before I go crazy trying to get it in there: what's an easy way to get the "Tune In" with links to the streams into this block?
On second review: this displays the current program. Purposeful?
#11
The views code in comment #7 is perfect for current programs, this is what I came up with for next program.
<?php$view = new view;
$view->name = 'station_schedule_upcoming';
$view->description = 'Upcoming programs';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'station_schedule_item';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'program_nid' => array(
'label' => 'Program',
'required' => 0,
'id' => 'program_nid',
'table' => 'station_schedule_item',
'field' => 'program_nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'schedule_nid' => array(
'label' => 'Schedule',
'required' => 0,
'id' => 'schedule_nid',
'table' => 'station_schedule_item',
'field' => 'schedule_nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'title' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'program_nid',
'override' => array(
'button' => 'Override',
),
),
'start' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'style' => 'station_dayhour',
'exclude' => 0,
'id' => 'start',
'table' => 'station_schedule_item',
'field' => 'start',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
'finish' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'style' => 'station_hour',
'exclude' => 0,
'id' => 'finish',
'table' => 'station_schedule_item',
'field' => 'finish',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'start' => array(
'order' => 'ASC',
'start_from' => 'begin_week',
'id' => 'start',
'table' => 'station_schedule_item',
'field' => 'start',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'start' => array(
'operator' => '>',
'value' => array(
'mode' => 'now',
'value' => 0,
'min' => '',
'max' => '',
'offset' => '',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => 'start_op',
'label' => 'Station schedule item: Start',
'use_operator' => FALSE,
'identifier' => 'start',
'remember' => FALSE,
'single' => TRUE,
'optional' => TRUE,
),
'id' => 'start',
'table' => 'station_schedule_item',
'field' => 'start',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
'status_extra' => array(
'operator' => '=',
'value' => '',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status_extra',
'table' => 'node',
'field' => 'status_extra',
'relationship' => 'program_nid',
),
));
$handler->override_option('access', array(
'type' => 'perm',
'perm' => 'view station schedule content',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('title', 'Upcoming programs');
$handler->override_option('empty', 'Nothing is scheduled.');
$handler->override_option('empty_format', '1');
$handler->override_option('items_per_page', 1);
$handler->override_option('row_options', array(
'inline' => array(
'start' => 'start',
'finish' => 'finish',
),
'separator' => ' - ',
'hide_empty' => 0,
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', 'Station Schedule Upcoming Programs');
$handler->override_option('block_caching', -1);
?>
#12
If there's only one program in the block you can just add a relation to the schedule and add its tune in link. If there's more than one it'll appear in each item (which might be what you want if you've got multiple schedules).
#13
i think this has been addressed. if not feel free to re-open the issue.
#14
Automatically closed -- issue fixed for 2 weeks with no activity.
#15
I'm using the view from Comment #11, but it doesn't seem to be wrapping back around to Sunday. Just getting Thursday -> Saturday programs.
Anyone else have the same result ?