function clients_drupal_clients_service_options in Web Service Clients 7
Same name and namespace in other branches
- 6 backends/clients_drupal/clients_drupal.module \clients_drupal_clients_service_options()
Implementation of hook_clients_service_options
File
- backends/
clients_drupal/ clients_drupal.module, line 82 - Drupal Services plugin for Clients module
Code
function clients_drupal_clients_service_options($connection, $wrapper, $wrapper_values, $resource) {
// TODO: kill this -- see TODO on clients_service_options().
if ($connection->type != 'drupal_services') {
return;
}
$form = array();
$connection = clients_connection_load((int) $connection->cid);
$methods = array_map('trim', explode("\n", trim($connection->configuration['methods_enabled'])));
$methods = array_combine($methods, $methods);
$options_selected = isset($wrapper_values['options']) ? $wrapper_values['options'] : (isset($resource->rid) ? $resource->configuration['options'] : array());
// if we change connection and method doesn't exist, reset
if (!in_array($options_selected['method'], $methods)) {
$options_selected['method'] = key($methods);
}
$form['method'] = array(
'#type' => 'select',
'#title' => t('Method'),
'#default_value' => $options_selected['method'],
'#options' => $methods,
'#description' => t('Choose method'),
'#required' => TRUE,
'#ahah' => array(
'path' => ahah_helper_path(array(
$wrapper,
)),
'wrapper' => $wrapper,
'method' => 'replace',
'effect' => 'fade',
),
);
if ($options_selected['method'] == 'views.get') {
$views = array_map('trim', explode("\n", trim($connection->configuration['views_enabled'])));
$views = array_combine($views, $views);
$form['view'] = array(
'#type' => 'select',
'#title' => t('View'),
'#default_value' => $options_selected['view'],
'#options' => $views,
'#description' => t('Choose view'),
);
$form['arguments']['first'] = array(
'#type' => 'textfield',
'#title' => t('Argument'),
'#default_value' => $options_selected['arguments']['first'],
'#size' => 10,
'#maxlength' => 30,
);
$form['offset'] = array(
'#type' => 'textfield',
'#title' => t('Offset'),
'#default_value' => $options_selected['offset'],
'#size' => 3,
'#maxlength' => 4,
);
$form['limit'] = array(
'#type' => 'textfield',
'#title' => t('Limit'),
'#default_value' => $options_selected['limit'],
'#size' => 3,
'#maxlength' => 4,
);
}
else {
/**
* @todo some 'method not supported' handling
*/
}
return $form;
}