You are here

function services_admin_browse_test in Services 7

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. 6.2 services_admin_browse.inc \services_admin_browse_test()
1 string reference to 'services_admin_browse_test'
services_admin_browse_method in ./services_admin_browse.inc

File

./services_admin_browse.inc, line 95
@author Services Dev Team

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' => $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;
}