diff -urpN /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service.inc services/services/views2_service/views2_service.inc --- /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service.inc 1969-12-31 19:00:00.000000000 -0500 +++ services/services/views2_service/views2_service.inc 2008-11-09 11:23:04.000000000 -0500 @@ -0,0 +1,57 @@ +set_arguments($args, FALSE); + $view->set_offset($offset); + $view->set_items_per_page($limit); + + if ($display_id == NULL) { + foreach ($view->display as $id => $display) { + if ($display->display_plugin == 'views2_service_feed') { + $display_id = $id; + break; + } + } + } + + return $view->execute_display($display_id, $args); +} + +/** + * Check the access permission to a given views. + * + * @param view_name + * String. The views name. + * @return + * Boolean. TRUE if the user is allowed to load the given view. + */ +function views2_service_get_access($view_name) { + $view = views_get_view($view_name); + if (empty($view)) { + return FALSE; + } + + global $user; + return views_access($view); +} diff -urpN /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service.info services/services/views2_service/views2_service.info --- /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service.info 1969-12-31 19:00:00.000000000 -0500 +++ services/services/views2_service/views2_service.info 2008-11-09 11:23:04.000000000 -0500 @@ -0,0 +1,7 @@ +; $Id$ +name = Views2 Service +description = Provides a robust interface with Views2 for Services. +package = Services - services +dependencies[] = services +dependencies[] = views +core = 6.x diff -urpN /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service.module services/services/views2_service/views2_service.module --- /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service.module 1969-12-31 19:00:00.000000000 -0500 +++ services/services/views2_service/views2_service.module 2008-11-09 11:23:04.000000000 -0500 @@ -0,0 +1,83 @@ +Provides view methods to services applications. Requires services.module.

'); + case 'admin/modules#description': + return t('Provides view methods to services applications. Requires services.module.'); + } +} + +/** + * Implementation of hook_views_api() + */ +function views2_service_views_api() { + return array( + 'api' => '2', + 'path' => drupal_get_path('module', 'views2_service'), + ); +} + +/** + * Implementation of hook_service(). + */ +function views2_service_service() { + return array( + // views.get + array( + '#method' => 'views2.get', + '#callback' => 'views2_service_get', + '#access callback' => 'views2_service_get_access', + '#file' => array('file' => 'inc', 'module' => 'views2_service'), + '#key' => FALSE, + '#args' => array( + array( + '#name' => 'view_name', + '#type' => 'string', + '#description' => t('View name.'), + ), + array( + '#name' => 'fields', + '#type' => 'array', + '#optional' => TRUE, + '#description' => t('A list of fields to return.'), + ), + array( + '#name' => 'args', + '#type' => 'array', + '#optional' => TRUE, + '#description' => t('An array of arguments to pass to the view.'), + ), + array( + '#name' => 'offset', + '#type' => 'int', + '#optional' => TRUE, + '#description' => t('An offset integer for paging.'), + ), + array( + '#name' => 'limit', + '#type' => 'int', + '#optional' => TRUE, + '#description' => t('A limit integer for paging.'), + ), + array( + '#name' => 'display_id', + '#type' => 'string', + '#optional' => TRUE, + '#description' => t('The Views2 display_id to use. If none is provided, the first Services Feed display for the given view will be used.'), + ), + ), + '#return' => 'array', + '#help' => t('Retrieves a view defined in views.module.')), + ); +} \ No newline at end of file diff -urpN /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service.views.inc services/services/views2_service/views2_service.views.inc --- /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service.views.inc 1969-12-31 19:00:00.000000000 -0500 +++ services/services/views2_service/views2_service.views.inc 2008-11-09 11:23:04.000000000 -0500 @@ -0,0 +1,139 @@ + array( + 'views2_service_service' => array( + 'title' => t('Service'), + 'help' => t('Displays the default summary as a list.'), + 'handler' => 'views2_service_plugin_style_service', + 'theme' => 'views_view', + 'type' => 'normal', // only shows up as a summary style + 'uses fields' => TRUE, + 'uses options' => FALSE, + 'help topic' => 'style-summary', + ), + ), + ); + */ + return array( + 'display' => array( + 'views2_service_feed' => array( + 'title' => t('Services Feed'), + 'help' => t('Send the results of this view to Services.'), + 'handler' => 'views2_service_plugin_display_services_feed', +// 'parent' => 'page', // so it knows to load the page plugin .inc file + 'uses hook menu' => FALSE, + 'use ajax' => FALSE, + 'use pager' => FALSE, + 'accept attachments' => FALSE, + 'admin' => t('Services Feed'), + 'help topic' => 'display-services-feed', + ), + ), + 'style' => array( + 'views2_service_style' => array( + 'title' => t('Service'), + 'help' => t('Sends the results to Services.'), + 'handler' => 'views2_service_plugin_style_service', +// 'theme' => 'views_view', + 'type' => 'views2_service_feed', // only shows up as a summary style + 'uses fields' => TRUE, + 'uses options' => FALSE, + 'uses row plugin' => TRUE, + 'help topic' => 'style-service', + ), + ), + 'row' => array( + 'views2_service_fields' => array( + 'title' => t('Services Fields'), + 'help' => t('Displays the fields for output to Services with an optional template.'), + 'handler' => 'views2_service_plugin_row_service_fields', + 'theme' => 'views_view_fields', + 'uses fields' => TRUE, + 'uses options' => FALSE, + 'type' => 'views2_service_feed', + 'help topic' => 'style-services-row-fields', + ), + 'views2_service_nodes' => array( + 'title' => t('Services Nodes'), + 'help' => t('Displays nodes for output to Services with an optional template.'), + 'handler' => 'views2_service_plugin_row_service_nodes', +// 'theme' => 'views_view_fields', + 'uses fields' => FALSE, + 'uses options' => FALSE, + 'type' => 'views2_service_feed', + 'help topic' => 'style-services-row-nodes', + ), + 'views2_service_raw' => array( + 'title' => t('Services Raw'), + 'help' => t('Sends raw DB data to Services.'), + 'handler' => 'views2_service_plugin_row_service_raw', +// 'theme' => 'views_view_fields', + 'uses fields' => TRUE, + 'uses options' => FALSE, + 'type' => 'views2_service_feed', + 'help topic' => 'style-services-row-nodes', + ), + ), + ); + /* + return array( + 'display' => array( + 'service' => array( + 'title' => t('Service'), + 'help' => t('Display the view in the Services module.'), + 'handler' => 'views_plugin_display_service', + 'parent' => 'default', + 'uses hook menu' => FALSE, + 'use ajax' => FALSE, + 'use pager' => FALSE, + 'accept attachments' => FALSE, + 'admin' => t('Service'), +// 'help topic' => 'display-service', + ), + ), + 'style' => array( + 'services' => array( + 'title' => t('Services'), + 'help' => t('Allows the view to be read by Services.'), + 'handler' => 'views_plugin_style_services', +// 'theme' => 'views_view_rss', + 'uses row plugin' => TRUE, + 'uses options' => TRUE, + 'type' => 'feed', +// 'help topic' => 'style-rss', + ), + ), + 'row' => array( + 'services_fields' => array( + 'title' => t('Services Fields'), + 'help' => t('Displays the fields for output to Services with an optional template.'), + 'handler' => 'views_plugin_row_services_fields', + 'theme' => 'views_view_fields', + 'uses fields' => TRUE, + 'uses options' => TRUE, + 'type' => 'normal', +// 'help topic' => 'style-services-row-fields', + ), + 'services_nodes' => array( + 'title' => t('Services Nodes'), + 'help' => t('Displays nodes for output to Services with an optional template.'), + 'handler' => 'views_plugin_row_services_node', + 'theme' => 'views_view_fields', + 'uses fields' => TRUE, + 'uses options' => TRUE, + 'type' => 'normal', +// 'help topic' => 'style-services-row-fields', + ), + ), + ); + */ +} + diff -urpN /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service_plugin_display_services_feed.inc services/services/views2_service/views2_service_plugin_display_services_feed.inc --- /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service_plugin_display_services_feed.inc 1969-12-31 19:00:00.000000000 -0500 +++ services/services/views2_service/views2_service_plugin_display_services_feed.inc 2008-11-09 11:23:04.000000000 -0500 @@ -0,0 +1,74 @@ +view->render($this->display->id); + } + + function preview() { + $result = $this->view->render($this->display->id); + + // HINT: This should always be true. + if(is_array($result)) { + $result = print_r($result, TRUE); + } + + return '
' . check_plain($result) . '
'; + } + + /** + * Instead of going through the standard views_view.tpl.php, delegate this + * to the style handler. + */ + function render() { + return $this->view->style_plugin->render($this->view->result); + } + + function defaultable_sections($section = NULL) { + if (in_array($section, array('style_options', 'style_plugin', 'row_options', 'row_plugin',))) { + return FALSE; + } + + $sections = parent::defaultable_sections($section); + + return $sections; + } + + function option_definition() { + $options = parent::option_definition(); + + $options['displays'] = array('default' => array()); + + // Overrides for standard stuff: + $options['style_plugin']['default'] = 'views2_service_style'; + $options['style_options']['default'] = array('raw_data' => FALSE); + $options['sitename_title']['default'] = FALSE; + $options['row_plugin']['default'] = 'views2_service_raw'; + $options['defaults']['default']['style_plugin'] = FALSE; + $options['defaults']['default']['style_options'] = FALSE; + $options['defaults']['default']['row_plugin'] = FALSE; + $options['defaults']['default']['row_options'] = FALSE; + + return $options; + } +} diff -urpN /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service_plugin_row_service_fields.inc services/services/views2_service/views2_service_plugin_row_service_fields.inc --- /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service_plugin_row_service_fields.inc 1969-12-31 19:00:00.000000000 -0500 +++ services/services/views2_service/views2_service_plugin_row_service_fields.inc 2008-11-09 11:23:04.000000000 -0500 @@ -0,0 +1,31 @@ +view->field as $id => $field) { + $output[$id] = $field->render($row); + } + + return $output; + } +} + + diff -urpN /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service_plugin_row_service_nodes.inc services/services/views2_service/views2_service_plugin_row_service_nodes.inc --- /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service_plugin_row_service_nodes.inc 1969-12-31 19:00:00.000000000 -0500 +++ services/services/views2_service/views2_service_plugin_row_service_nodes.inc 2008-11-09 11:23:04.000000000 -0500 @@ -0,0 +1,26 @@ +nid)) { + return services_node_load(node_load($row->nid), $fields); + } + } +} diff -urpN /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service_plugin_row_service_raw.inc services/services/views2_service/views2_service_plugin_row_service_raw.inc --- /Users/smerrill/Documents/Drupal/Contributions/contributions/modules/services/services/views2_service/views2_service_plugin_row_service_raw.inc 1969-12-31 19:00:00.000000000 -0500 +++ services/services/views2_service/views2_service_plugin_row_service_raw.inc 2008-11-09 11:23:04.000000000 -0500 @@ -0,0 +1,22 @@ +namespaces = array(); + */ + + /* + $rows['theme_functions'] = $this->theme_functions(); + $rows['display_options'] = $this->display->handler->get_option('row_options'); + $rows['options'] = $this->options; + */ + + foreach ($this->view->result as $row) { + $rows[] = $this->row_plugin->render($row); + } + + // Services requires an array. + return $rows; + } +}