Index: plugins/services_views.info
===================================================================
RCS file: plugins/services_views.info
diff -N plugins/services_views.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/services_views.info	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,8 @@
+; $Id: $
+name = Services views
+description = Provide a views based service creation.
+package = Services
+dependencies[] = services 
+dependencies[] = views
+core = 6.x
+php = 5.x 
Index: plugins/includes/views/services_plugin_style_service.inc
===================================================================
RCS file: plugins/includes/views/services_plugin_style_service.inc
diff -N plugins/includes/views/services_plugin_style_service.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/includes/views/services_plugin_style_service.inc	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,43 @@
+<?php
+// $Id: $
+class services_plugin_style_service extends views_plugin_style_default {
+  function init(&$view, &$display) {
+    parent::init($view, $display);
+    $fields = $display->handler->default_display->options['fields'];
+    $this->options['fields'] = $fields;
+  }
+
+  /**
+   * Set default options
+   */
+  function options(&$options) {
+    parent::options($options);
+  }
+  
+  function option_definition() {
+    $options = parent::option_definition();    
+    return $options;
+  }
+
+  function options_form(&$form, &$form_state) {
+    $options = array('' => '');
+    foreach ($this->options['fields'] as $field) {
+      $handler = views_get_handler($field['table'], $field['field'], 'field');
+      $options[$field['field']] = $handler->ui_name();
+    }      
+  }
+
+   /**
+   * Style validation.
+   */
+  function validate() {
+    $errors = parent::validate();
+    
+    $style = $this->display->display_options['style_plugin'];
+    return $errors;
+  }
+ 
+  function render() {
+    // Need to build this
+  }
+}
Index: plugins/services_views.module
===================================================================
RCS file: plugins/services_views.module
diff -N plugins/services_views.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/services_views.module	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,51 @@
+<?php
+// $Id: $
+/**
+ * @author Services Dev Team
+ * @file
+ *  Provides a views based builder for services.
+ */
+
+/**
+ * Implementation of hook_views_api().
+ */
+function services_views_views_api() {
+  return array(
+    'api' => 2,
+    'path' => drupal_get_path('module', 'services_views') . '/includes/views',
+  );
+}
+
+/**
+ * Implementation of hook_service().
+ */
+function services_views_service() {
+  // This will be build the array structure that services
+  // Callback will be via a generic views wrapper
+  // Views args will become parameters 
+  // The service needs to define an additional parameter for the view
+  // We need to execute
+  $services = array();
+  $query = db_query("SELECT display_title, display_options FROM {views_display} where display_plugin = 'services_views'");
+  while ($result = db_fetch_object($query)) {
+    $options = unserialize($result->display_options);
+    $args = array();
+    foreach($options['arguments'] as $argument => $values) {
+      $args[] = array(
+        '#name'           => $argument,
+        '#type'           => 'int', // how will we handle types?
+        '#description'    => $values['table'] .' '. $values['field'],
+      );
+    }
+    $services[] = array(
+      '#method'           => $result->display_title,
+      '#callback'         => 'services_views_handler',
+      '#access callback'  => 'services_views_access', // can actually check permissions on the view 
+      //'#file'             => array('file' => 'inc', 'module' => 'user_service'),
+      '#args'             => $args,
+      '#return'           => 'struct', // We need a way to define this in the view
+      '#help'             => t($result->display_title) //We need a way to define this as option in the view
+    );
+  }
+  return $services;
+}
Index: plugins/includes/views/services_views.views.inc
===================================================================
RCS file: plugins/includes/views/services_views.views.inc
diff -N plugins/includes/views/services_views.views.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/includes/views/services_views.views.inc	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,63 @@
+<?php
+//$Id: $
+//views_include_handlers();
+/**
+ * Implementation of hook_views_plugins
+ */
+function services_views_views_plugins() {
+  $path = drupal_get_path('module', 'services_views') . '/includes/views';
+  $views_path = drupal_get_path('module', 'views');
+
+  $data = array(
+    //'module' => 'services_views', // This just tells our themes are elsewhere.
+    'display' => array(
+      // Parents are not really displays, just needed so the files can
+      // be included.
+      'parent' => array(
+        'no ui' => TRUE,
+        'handler' => 'views_plugin_display',
+        'path' => "$views_path/plugins",
+        'parent' => '',
+      ),
+      'services_views' => array(
+        'title' => t('Services'),
+        'help' => t('Display the view as an service.'),
+        'handler' => 'services_plugin_display_service',
+        'path' => "$path",
+        'parent' => 'parent',
+        'uses hook menu' => FALSE,
+        'theme' => 'views_view',
+        'no ui' => FALSE,
+        'no remove' => TRUE,
+        'use ajax' => FALSE,
+        'use pager' => FALSE,
+        'accept attachments' => FALSE,
+        'admin' => t('Service'),
+        'help topic' => 'display-service',
+      ),
+    ),
+    'style' => array(
+      'parent' => array(
+        // this isn't really a display but is necessary so the file can
+        // be included.
+        'no ui' => TRUE,
+        'handler' => 'views_plugin_style',
+        'path' => "$views_path/plugins",
+        'parent' => '',
+      ),
+      'services' => array(
+        'title' => t('Service'),
+        'help' => t('Generates an service from a view.'),
+        'handler' => 'services_plugin_style_service',
+        'path' => "$path",
+        'parent' => 'parent',
+        'uses row plugin' => TRUE,
+        'uses fields' => TRUE,
+        'uses options' => FALSE,
+        'type' => 'services',
+        'even empty' => TRUE,
+      ),
+    ),
+  );
+  return $data;
+}
Index: plugins/includes/views/services_plugin_display_service.inc
===================================================================
RCS file: plugins/includes/views/services_plugin_display_service.inc
diff -N plugins/includes/views/services_plugin_display_service.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/includes/views/services_plugin_display_service.inc	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,66 @@
+<?php
+// $Id:$
+class services_plugin_display_service extends views_plugin_display_default {
+  
+  function get_style_type() { return 'service'; }
+
+  function uses_breadcrumb() { return FALSE; }
+  
+  /**
+   * Feeds do not go through the normal page theming mechanism. Instead, they
+   * go through their own little theme function and then return NULL so that
+   * Drupal believes that the page has already rendered itself...which it has.
+   */
+  function execute() {
+    $output = $this->view->render();
+    if (empty($output)) {
+      return drupal_not_found();
+    }
+    print $output;
+  }
+
+  function preview() {
+    return '<pre>' . check_plain($this->view->render()) . '</pre>';
+  }
+
+  /**
+   * 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 option_definition() {
+    $options = parent::option_definition();
+
+    $options['displays'] = array('default' => array());
+
+    // Overrides for standard stuff:
+    $options['style_plugin']['default'] = 'default';
+    $options['row_plugin']['default'] = 'fields';
+    $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;
+  }
+
+  /**
+   * Provide the default form for setting options.
+   */
+  function options_form(&$form, &$form_state) {
+    // It is very important to call the parent function here.
+    parent::options_form($form, $form_state);
+
+    switch ($form_state['section']) {
+      case 'title':
+        $form['title']['#title'] = 'Method name';
+        $form['title']['#process'] = array('views_process_dependency');
+        $form['title']['#dependency'] = array('edit-sitename-title' => array(FALSE));
+        break;
+    }
+  }  
+}
+
