You are here

function services_admin_browse_method in Services 5

Same name and namespace in other branches
  1. 6 services_admin_browse.inc \services_admin_browse_method()
  2. 6.2 services_admin_browse.inc \services_admin_browse_method()
  3. 7 services_admin_browse.inc \services_admin_browse_method()
1 string reference to 'services_admin_browse_method'
services_menu in ./services.module
Implementation of hook_menu.

File

./services_admin_browse.inc, line 57
The file contains code which is used to create the services testing interface

Code

function services_admin_browse_method() {
  global $_services_admin_browse_test_submit_result;
  if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && user_access('administer services')) {
    drupal_get_form('services_admin_browse_test');
    $output .= '<h3>' . t('Result') . '</h3>';
    $output .= '<code>' . $_services_admin_browse_test_submit_result . '</code>';
    print $output;
    exit;
  }
  $method = services_method_get(arg(4));
  if (!$method) {
    return $output;
  }

  //die(print_r($method, true));

  //drupal_set_title($method['#method']);
  $output .= '<h3>' . $method['#method'] . '</h3>';
  $output .= '<p>' . $method['#help'] . '</p>';

  // List arguments.
  $output .= '<h3>' . t('Arguments') . ' (' . count($method['#args']) . ')</h3>';
  $output .= '<dl id="service-browser-arguments">';
  $count = 0;
  foreach ($method['#args'] as $arg) {
    $count++;
    $output .= '<dt><em class="type">' . $arg['#type'] . '</em> <strong class="name">' . $arg['#name'] . '</strong>  (' . ($arg['#optional'] ? t('optional') : t('required')) . ')</dt>';
    $output .= '<dd>' . $arg['#description'] . '</dd>';
  }
  $output .= '</dl>';

  // Allow testing of methods.
  $output .= '<h3>' . t('Call method') . '</h3>';
  $output .= drupal_get_form('services_admin_browse_test');

  // Display results.
  if (user_access('administer services')) {
    $output .= '<div id="output">';
    if ($_services_admin_browse_test_submit_result) {
      $output .= '<h3>' . t('Result') . '</h3>';
      $output .= '<code>' . $_services_admin_browse_test_submit_result . '</code>';
    }
    $output .= '</div>';
  }
  return $output;
}