? .git ? station_views.patch ? schedule/views/station_schedule_plugin_argument_validate_day.inc Index: schedule/views/station_schedule.views.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/station/schedule/views/station_schedule.views.inc,v retrieving revision 1.9 diff -u -p -r1.9 station_schedule.views.inc --- schedule/views/station_schedule.views.inc 21 Sep 2009 21:36:20 -0000 1.9 +++ schedule/views/station_schedule.views.inc 22 Sep 2009 21:50:19 -0000 @@ -44,6 +44,9 @@ function station_schedule_views_handlers 'station_schedule_handler_filter_time' => array( 'parent' => 'views_handler_filter_numeric', ), + 'station_schedule_handler_filter_schedule_item' => array( + 'parent' => 'views_handler_filter_boolean_operator', + ), ), ); } @@ -141,14 +144,6 @@ function station_schedule_views_data() { 'help' => t("Items on the station's schedules."), ); - // For other base tables, explain how we join - $data['station_schedule_item']['table']['join'] = array( - 'node' => array( - 'left_field' => 'nid', - 'field' => 'program_nid', - ), - ); - // ---------------------------------------------------------------- // Fields $data['station_schedule_item']['iid'] = array( @@ -266,3 +261,61 @@ function station_schedule_views_data() { return $data; } + +/** + * Use views_data_alter to add relations from {node} to {schedule_items}. + */ +function station_schedule_views_data_alter(&$data) { + $data['node']['station_schedule_iid'] = array( + 'group' => t('Station Schedule'), + 'title' => t('Scheduled Programs'), + 'help' => t('All programs on this schedule.'), + 'real field' => 'nid', +// 'field' => array( +// 'handler' => 'views_handler_field_upload_fid', +// ), + 'filter' => array( + 'handler' => 'station_schedule_handler_filter_schedule_item', + 'title' => t('Has scheduled programs'), + 'type' => 'yes-no', + 'label' => t('Has scheduled programs'), + 'help' => t('Only display schedules with programs. This can cause duplicates if there are multiple programs scheduled.'), + ), + 'relationship' => array( + 'title' => t('Scheduled Programs'), + 'help' => t('Add a relationship to gain access to data about the programs on a schedule. Note that this relationship will cause duplicate schedule nodes if there are multiple programs on the schedule.'), + 'relationship table' => 'node', + 'relationship field' => 'nid', + 'base' => 'station_schedule_item', + 'base field' => 'schedule_nid', + 'handler' => 'views_handler_relationship', + 'label' => t('Scheduled Programs'), + ), + ); + $data['node']['station_program_iid'] = array( + 'group' => t('Station Program'), + 'title' => t('Program Schedule Times'), + 'help' => t('All the times this program is scheduled.'), + 'real field' => 'nid', +// 'field' => array( +// 'handler' => 'views_handler_field_upload_fid', +// ), + 'filter' => array( + 'handler' => 'station_schedule_handler_filter_schedule_item', + 'title' => t('Is scheduled'), + 'type' => 'yes-no', + 'label' => t('Program is scheduled'), + 'help' => t('Only display programs that are on a schedule. This can cause duplicates if the schedule is on multiple schedules.'), + ), + 'relationship' => array( + 'title' => t('Program Scheduling'), + 'help' => t('Add a relationship to gain access to data about the times a program is scheduled. Note that this relationship will cause duplicate schedule nodes if the program is multiple slots or on multiple schedules.'), + 'relationship table' => 'node', + 'relationship field' => 'nid', + 'base' => 'station_schedule_item', + 'base field' => 'program_nid', + 'handler' => 'views_handler_relationship', + 'label' => t("Program's scheduling"), + ), + ); +} \ No newline at end of file Index: schedule/views/station_schedule.views_default.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/station/schedule/views/station_schedule.views_default.inc,v retrieving revision 1.9 diff -u -p -r1.9 station_schedule.views_default.inc --- schedule/views/station_schedule.views_default.inc 21 Sep 2009 21:36:20 -0000 1.9 +++ schedule/views/station_schedule.views_default.inc 22 Sep 2009 21:50:21 -0000 @@ -21,7 +21,7 @@ function station_schedule_views_default_ $handler->override_option('relationships', array( 'program_nid' => array( 'label' => 'Program', - 'required' => 0, + 'required' => 1, 'id' => 'program_nid', 'table' => 'station_schedule_item', 'field' => 'program_nid', @@ -29,7 +29,7 @@ function station_schedule_views_default_ ), 'schedule_nid' => array( 'label' => 'Schedule', - 'required' => 0, + 'required' => 1, 'id' => 'schedule_nid', 'table' => 'station_schedule_item', 'field' => 'schedule_nid', @@ -109,6 +109,7 @@ function station_schedule_views_default_ $handler->override_option('sorts', array( 'start' => array( 'order' => 'ASC', + 'start_from' => 'begin_week', 'id' => 'start', 'table' => 'station_schedule_item', 'field' => 'start', @@ -239,6 +240,9 @@ function station_schedule_views_default_ 'type' => 'perm', 'perm' => 'view station schedule content', )); + $handler->override_option('cache', array( + 'type' => 'none', + )); $handler->override_option('empty', 'There are no programs scheduled for this day.'); $handler->override_option('empty_format', '1'); $handler->override_option('items_per_page', 0); @@ -420,6 +424,9 @@ function station_schedule_views_default_ $handler->override_option('access', array( 'type' => 'none', )); + $handler->override_option('cache', array( + 'type' => 'none', + )); $handler->override_option('style_plugin', 'table'); $handler->override_option('style_options', array( 'grouping' => '', @@ -444,10 +451,10 @@ function station_schedule_views_default_ $views[$view->name] = $view; /* - * View 'station_scheduled_programs' + * View 'station_schedule_programs' */ $view = new view; - $view->name = 'station_scheduled_programs'; + $view->name = 'station_schedule_programs'; $view->description = 'Scheduled programs'; $view->tag = 'station_schedule'; $view->view_php = ''; @@ -456,6 +463,16 @@ function station_schedule_views_default_ $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( + 'station_program_iid' => array( + 'label' => 'Program\'s scheduling', + 'required' => 0, + 'id' => 'station_program_iid', + 'table' => 'node', + 'field' => 'station_program_iid', + 'relationship' => 'none', + ), + )); $handler->override_option('fields', array( 'title' => array( 'label' => 'Title', @@ -538,6 +555,32 @@ function station_schedule_views_default_ 'button' => 'Override', ), ), + 'time' => array( + 'label' => 'Time range', + 'alter' => array( + 'alter_text' => 0, + 'text' => '', + 'make_link' => 0, + 'path' => '', + 'link_class' => '', + 'alt' => '', + 'prefix' => '', + 'suffix' => '', + 'help' => '', + 'trim' => 0, + 'max_length' => '', + 'word_boundary' => 1, + 'ellipsis' => 1, + 'strip_tags' => 0, + 'html' => 0, + ), + 'style' => 'station_dayhour_range', + 'exclude' => 0, + 'id' => 'time', + 'table' => 'station_schedule_item', + 'field' => 'time', + 'relationship' => 'station_program_iid', + ), )); $handler->override_option('sorts', array( 'title' => array( @@ -570,12 +613,33 @@ function station_schedule_views_default_ 'table' => 'node', 'field' => 'status_extra', ), + 'station_program_iid' => array( + 'operator' => '=', + 'value' => '1', + 'group' => '0', + 'exposed' => FALSE, + 'expose' => array( + 'operator' => FALSE, + 'label' => '', + ), + 'id' => 'station_program_iid', + 'table' => 'node', + 'field' => 'station_program_iid', + 'override' => array( + 'button' => 'Override', + ), + 'relationship' => 'none', + ), )); $handler->override_option('access', array( 'type' => 'perm', 'perm' => 'view station program content', )); + $handler->override_option('cache', array( + 'type' => 'none', + )); $handler->override_option('title', 'Programs'); + $handler->override_option('items_per_page', 30); $handler->override_option('use_pager', '1'); $handler->override_option('style_plugin', 'table'); $handler->override_option('style_options', array( @@ -603,11 +667,11 @@ function station_schedule_views_default_ ), 'default' => '-1', )); - $handler = $view->new_display('page', 'Page', 'page_1'); - $handler->override_option('path', 'station/programs/schedule'); + $handler = $view->new_display('page', 'Scheduled Page', 'page_1'); + $handler->override_option('path', 'station/programs/scheduled'); $handler->override_option('menu', array( - 'type' => 'normal', - 'title' => 'Programs', + 'type' => 'default tab', + 'title' => 'Scheduled', 'description' => '', 'weight' => '0', 'name' => 'navigation', @@ -618,6 +682,144 @@ function station_schedule_views_default_ 'description' => '', 'weight' => '0', )); + $handler = $view->new_display('page', 'Unscheduled Page', 'page_2'); + $handler->override_option('fields', array( + 'title' => array( + 'label' => 'Title', + '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' => 'none', + 'override' => array( + 'button' => 'Override', + ), + ), + 'field_station_program_genre_value' => array( + 'label' => '', + 'link_to_node' => 0, + 'label_type' => 'widget', + 'format' => 'default', + 'multiple' => array( + 'group' => TRUE, + 'multiple_number' => '', + 'multiple_from' => '', + 'multiple_reversed' => FALSE, + ), + 'exclude' => 0, + 'id' => 'field_station_program_genre_value', + 'table' => 'node_data_field_station_program_genre', + 'field' => 'field_station_program_genre_value', + 'relationship' => 'none', + ), + 'field_station_program_dj_uid' => array( + 'label' => 'DJs', + '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' => 0, + 'label_type' => 'widget', + 'format' => 'default', + 'multiple' => array( + 'group' => 1, + 'multiple_number' => '', + 'multiple_from' => '', + 'multiple_reversed' => 0, + ), + 'exclude' => 0, + 'id' => 'field_station_program_dj_uid', + 'table' => 'node_data_field_station_program_dj', + 'field' => 'field_station_program_dj_uid', + 'relationship' => 'none', + 'override' => array( + 'button' => 'Override', + ), + ), + )); + $handler->override_option('filters', array( + 'type' => array( + 'operator' => 'in', + 'value' => array( + 'station_program' => 'station_program', + ), + 'group' => '0', + 'exposed' => FALSE, + 'expose' => array( + 'operator' => FALSE, + 'label' => '', + ), + 'id' => 'type', + 'table' => 'node', + 'field' => 'type', + 'relationship' => 'none', + ), + 'status_extra' => array( + 'id' => 'status_extra', + 'table' => 'node', + 'field' => 'status_extra', + ), + 'station_program_iid' => array( + 'operator' => '=', + 'value' => '0', + 'group' => '0', + 'exposed' => FALSE, + 'expose' => array( + 'operator' => FALSE, + 'label' => '', + ), + 'id' => 'station_program_iid', + 'table' => 'node', + 'field' => 'station_program_iid', + 'override' => array( + 'button' => 'Use default', + ), + 'relationship' => 'none', + ), + )); + $handler->override_option('path', 'station/programs/unscheduled'); + $handler->override_option('menu', array( + 'type' => 'tab', + 'title' => 'Unscheduled', + 'description' => '', + 'weight' => '0', + 'name' => 'navigation', + )); + $handler->override_option('tab_options', array( + 'type' => 'none', + 'title' => '', + 'description' => '', + 'weight' => 0, + )); $views[$view->name] = $view; /* @@ -692,6 +894,9 @@ function station_schedule_views_default_ 'type' => 'perm', 'perm' => 'view station schedule content', )); + $handler->override_option('cache', array( + 'type' => 'none', + )); $handler->override_option('title', 'Schedule listing'); $handler->override_option('style_plugin', 'list'); $handler->override_option('style_options', array( Index: schedule/views/station_schedule_handler_field_time_range.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/station/schedule/views/station_schedule_handler_field_time_range.inc,v retrieving revision 1.2 diff -u -p -r1.2 station_schedule_handler_field_time_range.inc --- schedule/views/station_schedule_handler_field_time_range.inc 22 Sep 2009 20:45:37 -0000 1.2 +++ schedule/views/station_schedule_handler_field_time_range.inc 22 Sep 2009 21:50:21 -0000 @@ -18,7 +18,6 @@ class station_schedule_handler_field_tim 'station_hour_duration' => t('Duration'), 'station_hour_range' => t('Hour range'), 'station_dayhour_range' => t('Day/hour range'), - ), '#default_value' => $this->options['style'], '#description' => t('Which time style should be used.'), Index: schedule/views/station_schedule_handler_filter_schedule_item.inc =================================================================== RCS file: schedule/views/station_schedule_handler_filter_schedule_item.inc diff -N schedule/views/station_schedule_handler_filter_schedule_item.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ schedule/views/station_schedule_handler_filter_schedule_item.inc 22 Sep 2009 21:50:21 -0000 @@ -0,0 +1,9 @@ +ensure_my_table(); + $this->query->add_where($this->options['group'], "(SELECT COUNT(*) FROM {station_schedule_item} ssi WHERE ssi.program_nid = $this->table_alias.$this->real_field) " . (empty($this->value) ? '=' : '<>') . " 0"); + } +} \ No newline at end of file