You are here

function services_admin_browse_test in Services 6.2

Same name and namespace in other branches
  1. 5 services_admin_browse.inc \services_admin_browse_test()
  2. 6 services_admin_browse.inc \services_admin_browse_test()
  3. 7 services_admin_browse.inc \services_admin_browse_test()

Build the form used for testing a service in the browser

Return value

FAPI array

See also

services_admin_browse_test_submit()

1 string reference to 'services_admin_browse_test'
services_admin_browse_method in ./services_admin_browse.inc
Display a form for the testing of a single service method in the browser.

File

./services_admin_browse.inc, line 115
Browser thru all services and servers.

Code

function services_admin_browse_test() {
  $form = array();
  $method = services_method_get(arg(4));
  $form['arg'] = array(
    '#tree' => TRUE,
  );
  $form['format'] = array(
    '#tree' => TRUE,
  );
  foreach ($method['args'] as $key => $arg) {
    $form['name'][$key] = array(
      '#value' => $arg['name'],
    );
    $form['optional'][$key] = array(
      '#value' => isset($arg['optional']) && $arg['optional'] ? t('optional') : t('required'),
    );
    if (isset($arg['size']) && $arg['size'] == 'big') {
      $form['arg'][$key] = array(
        '#type' => 'textarea',
      );
    }
    else {
      $form['arg'][$key] = array(
        '#type' => 'textfield',
      );
    }
    $format_opt = array();
    switch ($arg['type']) {
      case 'array':
        $format_opt['cdel'] = t('Comma delimited');
      case 'struct':
        $format_opt['json'] = t('JSON');
        $format_opt['sphp'] = t('Serialized PHP');
        break;
    }
    if (!empty($format_opt)) {
      $form['format'][$key] = array(
        '#type' => 'select',
        '#options' => $format_opt,
      );
    }
    else {
      $form['format'][$key] = array(
        '#type' => 'value',
        '#value' => '',
      );
    }
  }
  services_auth_invoke('alter_browse_form', $form, $method);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Call method'),
  );
  $form['#redirect'] = FALSE;
  return $form;
}