View source
<?php
$plugin = array(
'schema' => 'services_client_connection',
'access' => 'administer services client connection',
'menu' => array(
'menu prefix' => 'admin/structure/services_client',
'menu item' => 'connection',
'menu title' => 'Connection',
'menu description' => 'Administer services client connections.',
'items' => array(
'auth' => array(
'path' => 'list/%ctools_export_ui/auth',
'title' => 'Auth',
'page callback' => 'ctools_export_ui_switcher_page',
'page arguments' => array(
'services_client_connection',
'auth',
5,
),
'load arguments' => array(
'services_client_connection',
),
'access arguments' => array(
'administer services client connection',
),
'type' => MENU_LOCAL_TASK,
),
'server' => array(
'path' => 'list/%ctools_export_ui/server',
'title' => 'Server',
'page callback' => 'ctools_export_ui_switcher_page',
'page arguments' => array(
'services_client_connection',
'server',
5,
),
'load arguments' => array(
'services_client_connection',
),
'access arguments' => array(
'administer services client connection',
),
'type' => MENU_LOCAL_TASK,
'weight' => -1,
),
'request' => array(
'path' => 'list/%ctools_export_ui/request',
'title' => 'Request',
'page callback' => 'ctools_export_ui_switcher_page',
'page arguments' => array(
'services_client_connection',
'request',
5,
),
'load arguments' => array(
'services_client_connection',
),
'access arguments' => array(
'administer services client connection',
),
'type' => MENU_LOCAL_TASK,
'weight' => -1,
),
),
),
'title singular' => t('services client connection'),
'title singular proper' => t('Services client connection'),
'title plural' => t('services client connection'),
'title plural proper' => t('Services client connections'),
'allowed operations' => array(
'auth' => array(
'title' => t('Edit Authentication'),
),
'server' => array(
'title' => t('Edit Server'),
),
'request' => array(
'title' => t('Edit Request'),
),
),
'form' => array(
'settings' => 'services_client_connection_export_ui_form',
'validate' => 'services_client_connection_export_ui_form_validate',
'submit' => 'services_client_connection_export_ui_form_submit',
),
'handler' => array(
'class' => 'services_client_connection_ui',
'parent' => 'ctools_export_ui',
),
);
function services_client_connection_export_ui_form(&$form, &$form_state) {
$item =& $form_state['item'];
$breadcrumb = array();
$breadcrumb[] = l(t('Home'), '');
$breadcrumb[] = l(t('Administration'), 'admin');
$breadcrumb[] = l(t('Structure'), 'admin/structure');
$breadcrumb[] = l(t('Services Client'), 'admin/structure/services_client');
$breadcrumb[] = l(t('Connection'), 'admin/structure/services_client/connection');
drupal_set_breadcrumb($breadcrumb);
$version = isset($form_state['values']['version']) ? $form_state['values']['version'] : $item->version;
$version = $version ? $version : 3;
$form['version'] = array(
'#type' => 'select',
'#title' => t('Services version'),
'#options' => drupal_map_assoc(range(1, 3)),
'#default_value' => $version,
'#ajax' => array(
'callback' => 'services_client_connection_export_ui_ajax',
'wrapper' => 'scc-plugins',
),
);
$form['endpoint'] = array(
'#type' => 'textfield',
'#title' => t('Endpoint'),
'#default_value' => $item->endpoint,
'#description' => t('Remote endpoint URL'),
);
$form['debug'] = array(
'#type' => 'checkbox',
'#title' => t('Debug'),
'#default_value' => $item->debug,
);
$form['plugins'] = array(
'#tree' => FALSE,
'#prefix' => '<div id="scc-plugins">',
'#suffix' => '</div>',
'#type' => 'item',
);
$auth_plugins = services_client_connection_get_plugins('auth', $version, TRUE);
$none = array(
'' => '- ' . t('None') . ' -',
);
$form['plugins']['auth'] = array(
'#type' => 'select',
'#title' => t('Authentication'),
'#options' => $none + $auth_plugins,
'#description' => t('Select authentication plugin. If none is selected all requests will be unauthenticated'),
'#default_value' => $item->config['auth']['plugin'],
);
$server_plugins = services_client_connection_get_plugins('server', $version, TRUE);
$form['plugins']['server'] = array(
'#type' => 'select',
'#title' => t('Server'),
'#options' => $server_plugins,
'#default_value' => $item->config['server']['plugin'],
);
$request_plugin = services_client_connection_get_plugins('request', $version, TRUE);
$form['plugins']['request'] = array(
'#type' => 'select',
'#title' => t('Request'),
'#options' => $request_plugin,
'#default_value' => $item->config['request']['plugin'],
);
}
function services_client_connection_export_ui_ajax($form, $form_state) {
return $form['plugins'];
}
function services_client_connection_export_ui_form_validate($form, &$form_state) {
}
function services_client_connection_export_ui_form_submit($form, &$form_state) {
$item =& $form_state['item'];
$item->config['auth']['plugin'] = $form_state['values']['auth'];
$item->config['server']['plugin'] = $form_state['values']['server'];
$item->config['request']['plugin'] = $form_state['values']['request'];
}