You are here

views_service.module in Services 6.2

Link general views functionalities to services module.

File

services/views_service/views_service.module
View source
<?php

/**
 * @file
 *  Link general views functionalities to services module.
 */

/**
 * Implementation of hook_service().
 */
function views_service_service() {
  return array(
    // views.get
    array(
      '#method' => 'views.get',
      '#callback' => 'views_service_get',
      '#access callback' => 'views_service_get_access',
      '#file' => array(
        'file' => 'inc',
        'module' => 'views_service',
      ),
      '#args' => array(
        array(
          '#name' => 'view_name',
          '#type' => 'string',
          '#description' => t('View name.'),
        ),
        array(
          '#name' => 'display_id',
          '#type' => 'string',
          '#optional' => TRUE,
          '#description' => t('A display provided by the selected view.'),
        ),
        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. For example to get item from 6 to 15, pass offset=5 and limit=10.'),
        ),
        array(
          '#name' => 'limit',
          '#type' => 'int',
          '#optional' => TRUE,
          '#description' => t('A limit integer for paging. For example to get item from 6 to 15, pass offset=5 and limit=10.'),
        ),
        array(
          '#name' => 'format_output',
          '#type' => 'boolean',
          '#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.'),
    ),
    // views.export
    array(
      '#method' => 'views.export',
      '#callback' => 'views_service_export',
      '#access arguments' => array(
        'administer views',
      ),
      '#file' => array(
        'file' => 'inc',
        'module' => 'views_service',
      ),
      '#args' => array(
        'string',
      ),
      '#args' => array(
        array(
          '#name' => 'view_name',
          '#type' => 'string',
          '#description' => t('View name.'),
        ),
      ),
      '#return' => 'string',
      '#help' => t('Exports the code of a view, same as the output you would get from the Export tab.'),
    ),
    // views.import
    array(
      '#method' => 'views.import',
      '#callback' => 'views_service_import',
      '#access arguments' => array(
        'administer views',
      ),
      '#file' => array(
        'file' => 'inc',
        'module' => 'views_service',
      ),
      '#args' => array(
        array(
          '#name' => 'view_import',
          '#type' => 'string',
          '#size' => 'big',
          '#description' => t('Code from a Views->Export.'),
        ),
        array(
          '#name' => 'view_name',
          '#type' => 'string',
          '#optional' => TRUE,
          '#description' => t('The new Views name.'),
        ),
      ),
      '#return' => 'int',
      '#help' => t('Imports a view through code, equivalent to using the Import tab in the views admin.'),
    ),
  );
}

Functions

Namesort descending Description
views_service_service Implementation of hook_service().