? 329048-17-views-2.patch
Index: services/views_service/views_service.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/services/services/views_service/Attic/views_service.inc,v
retrieving revision 1.1.2.11
diff -u -p -r1.1.2.11 views_service.inc
--- services/views_service/views_service.inc	15 Feb 2009 08:50:42 -0000	1.1.2.11
+++ services/views_service/views_service.inc	24 May 2009 09:20:30 -0000
@@ -11,44 +11,40 @@
  *
  * @param $view_name
  *   String. The views name.
+ * @param $display_id
+ *   String (optional). The display name.
  * @param $fields
- *   Array (optional). Array of fields to return.
- * @param $args
- *   Array (optional). Array of args to pass to the view.
+ *   Array (optional). A list of fields in the view.
  * @param $offset
- *   Array (optional). Offset record to start from.
+ *   Integer (optional). An offset integer for paging.
  * @param $limit
- *   Array (optional). Max number of records to return.
+ *   Integer (optional). A limit integer for paging.
+ * @param $args
+ *   Array (optional). A list of arguments.
+ * @param format_ouput
+ *   Integer (optional). TRUE if view should be formatted using the defined 
+ *   style plugin.
  * @return
  *   Array. The views return.
  */
-function views_service_get($view_name, $fields = array(), $args = array(), $offset = 0, $limit = 0) {
+function views_service_get($view_name, $fields = array(), $args = array(), $offset = 0, $limit = 0, $format_ouput = FALSE) {
+  $result = array();
   $view = views_get_view($view_name);
 
-  // Put all arguments and then execute
+  // Put all arguments and then execute.
   $view->set_arguments($args, FALSE);
   $view->set_offset($offset);
   $view->set_items_per_page($limit);
-  $view->execute();
-  
-  // Get row plugin setting
-  $row_plugin = $view->display[$view->current_display]->display_options['row_plugin'];
-  
-  $nodes = array();
-  // If row plugin is node, then we must do a node_load
-  if ($row_plugin == 'node') {
-    foreach ($view->result as $node) {
-      $nodes[] = services_node_load(node_load($node->nid), $fields);
-    }
+  if (!$format_ouput) {
+    $view->set_display($display_id);
+    $view->execute();
+    $return = $view->result;
   }
-  // Otherwise, pass through the fields filter, just in case
   else {
-    foreach ($view->result as $node) {
-      $nodes[] = services_node_load($node, $fields);
-    }
+    // We want to keep the result an array.
+    $result[] = $view->preview($display_id);
   }
-
-  return $nodes;
+  return $result;
 }
 
 /**
Index: services/views_service/views_service.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/services/services/views_service/Attic/views_service.module,v
retrieving revision 1.4.2.20
diff -u -p -r1.4.2.20 views_service.module
--- services/views_service/views_service.module	18 May 2009 20:55:22 -0000	1.4.2.20
+++ services/views_service/views_service.module	24 May 2009 09:20:30 -0000
@@ -36,6 +36,12 @@ function views_service_service() {
           '#description'    => t('View name.')
         ),
         array(
+          '#name'           => 'display_id',
+          '#type'           => 'string',
+          '#optional'       => TRUE,
+          '#description'    => t('A display provided by the selected view.')
+        ),
+        array(
           '#name'           => 'fields',
           '#type'           => 'array',
           '#optional'       => TRUE,
@@ -59,6 +65,12 @@ function views_service_service() {
           '#optional'       => TRUE,
           '#description'    => t('A limit integer for paging.')
         ),
+        array(
+          '#name'           => 'format_ouput',
+          '#type'           => 'int',
+          '#optional'       => TRUE,
+          '#description'    => t('TRUE if view should be formatted, or only the view result returned (FALSE by default).')
+        ),        
       ),
       '#return'           => 'array',
       '#help'             => t('Retrieves a view defined in views.module.')),
