| 1 |
<?php |
<?php |
| 2 |
// $Id: services_admin_browse.inc,v 1.5.2.45.2.1 2009/06/13 20:00:14 marcingy Exp $ |
// $Id: services_admin_browse.inc,v 1.5.2.45.2.2 2009/09/05 13:57:58 marcingy Exp $ |
| 3 |
/** |
/** |
| 4 |
* @author Services Dev Team |
* @author Services Dev Team |
| 5 |
* @file |
* @file |
| 20 |
$output .= '<ul>'; |
$output .= '<ul>'; |
| 21 |
foreach ($servers as $module) { |
foreach ($servers as $module) { |
| 22 |
$info = module_invoke($module, 'server_info'); |
$info = module_invoke($module, 'server_info'); |
| 23 |
$name = $info['#name']; |
services_strip_hashes($info); |
| 24 |
$path = 'services/'. $info['#path']; |
|
| 25 |
|
$name = $info['name']; |
| 26 |
|
$path = 'services/'. $info['path']; |
| 27 |
$output .= '<li class="leaf">'. l($name .' - /'. $path, $path) .'</li>'; |
$output .= '<li class="leaf">'. l($name .' - /'. $path, $path) .'</li>'; |
| 28 |
} |
} |
| 29 |
$output .= '</ul>'; |
$output .= '</ul>'; |
| 38 |
// group namespaces |
// group namespaces |
| 39 |
$services = array(); |
$services = array(); |
| 40 |
foreach ($methods as $method) { |
foreach ($methods as $method) { |
| 41 |
$namespace = drupal_substr($method['#method'], 0, strrpos($method['#method'], '.')); |
$namespace = drupal_substr($method['method'], 0, strrpos($method['method'], '.')); |
| 42 |
$services[$namespace][] = $method; |
$services[$namespace][] = $method; |
| 43 |
} |
} |
| 44 |
|
|
| 47 |
$output .= '<h3>'. $namespace .'</h3>'; |
$output .= '<h3>'. $namespace .'</h3>'; |
| 48 |
$output .= '<ul>'; |
$output .= '<ul>'; |
| 49 |
foreach ($methods as $method) { |
foreach ($methods as $method) { |
| 50 |
$output .= '<li class="leaf">'. l($method['#method'], 'admin/build/services/browse/'. $method['#method']) .'</li>'; |
$output .= '<li class="leaf">'. l($method['method'], 'admin/build/services/browse/'. $method['method']) .'</li>'; |
| 51 |
} |
} |
| 52 |
$output .= '</ul>'; |
$output .= '</ul>'; |
| 53 |
} |
} |
| 64 |
|
|
| 65 |
$output = ''; |
$output = ''; |
| 66 |
|
|
| 67 |
$output .= '<h3>'. $method['#method'] .'</h3>'; |
$output .= '<h3>'. $method['method'] .'</h3>'; |
| 68 |
$output .= '<p>'. $method['#help'] .'</p>'; |
$output .= '<p>'. $method['help'] .'</p>'; |
| 69 |
|
|
| 70 |
// List arguments. |
// List arguments. |
| 71 |
$output .= '<h3>'. t('Arguments') .' ('. count($method['#args']) .')</h3>'; |
$output .= '<h3>'. t('Arguments') .' ('. count($method['args']) .')</h3>'; |
| 72 |
$output .= '<dl id="service-browser-arguments">'; |
$output .= '<dl id="service-browser-arguments">'; |
| 73 |
$count = 0; |
$count = 0; |
| 74 |
foreach ($method['#args'] as $arg) { |
foreach ($method['args'] as $arg) { |
| 75 |
$count++; |
$count++; |
| 76 |
$output .= '<dt><em class="type">'. $arg['#type'] .'</em><strong class="name">'. |
$output .= '<dt><em class="type">'. $arg['type'] .'</em><strong class="name">'. |
| 77 |
$arg['#name'] .'</strong> ('. (($arg['#optional']) ? t('optional') : t('required')) .')</dt>'; |
$arg['name'] .'</strong> ('. (($arg['optional']) ? t('optional') : t('required')) .')</dt>'; |
| 78 |
$output .= '<dd>'. $arg['#description'] .'</dd>'; |
$output .= '<dd>'. $arg['description'] .'</dd>'; |
| 79 |
} |
} |
| 80 |
|
|
| 81 |
$output .= '</dl>'; |
$output .= '</dl>'; |
| 102 |
$form['arg'] = array('#tree' => TRUE); |
$form['arg'] = array('#tree' => TRUE); |
| 103 |
$form['format'] = array('#tree' => TRUE); |
$form['format'] = array('#tree' => TRUE); |
| 104 |
|
|
| 105 |
foreach ($method['#args'] as $key => $arg) { |
foreach ($method['args'] as $key => $arg) { |
| 106 |
$form['name'][$key] = array( |
$form['name'][$key] = array( |
| 107 |
'#value' => $arg['#name'] |
'#value' => $arg['name'] |
| 108 |
); |
); |
| 109 |
$form['optional'][$key] = array( |
$form['optional'][$key] = array( |
| 110 |
'#value' => ($arg['#optional']) ? t('optional') : t('required') |
'#value' => ($arg['optional']) ? t('optional') : t('required') |
| 111 |
); |
); |
| 112 |
|
|
| 113 |
if (isset($arg['#size']) && $arg['#size'] == 'big') { |
if (isset($arg['size']) && $arg['size'] == 'big') { |
| 114 |
$form['arg'][$key] = array( |
$form['arg'][$key] = array( |
| 115 |
'#type' => 'textarea' |
'#type' => 'textarea' |
| 116 |
); |
); |
| 122 |
} |
} |
| 123 |
|
|
| 124 |
$format_opt = array(); |
$format_opt = array(); |
| 125 |
switch ($arg['#type']) { |
switch ($arg['type']) { |
| 126 |
case 'array': |
case 'array': |
| 127 |
$format_opt['cdel'] = t('Comma delimited'); |
$format_opt['cdel'] = t('Comma delimited'); |
| 128 |
case 'struct': |
case 'struct': |
| 161 |
$args = services_admin_browse_test_unserialize_args($form_state['values']['arg'], $form_state['values']['format']); |
$args = services_admin_browse_test_unserialize_args($form_state['values']['arg'], $form_state['values']['format']); |
| 162 |
// Allow the authorization module to handle submitted values. |
// Allow the authorization module to handle submitted values. |
| 163 |
services_auth_invoke('alter_browse_form_submit', $method, $args); |
services_auth_invoke('alter_browse_form_submit', $method, $args); |
| 164 |
$result = services_method_call($method['#method'], $args, TRUE); |
$result = services_method_call($method['method'], $args, TRUE); |
| 165 |
$_services_admin_browse_test_submit_result = '<pre>'. htmlspecialchars(print_r($result, TRUE)) .'</pre>'; |
$_services_admin_browse_test_submit_result = '<pre>'. htmlspecialchars(print_r($result, TRUE)) .'</pre>'; |
| 166 |
} |
} |
| 167 |
|
|
| 169 |
$method = services_method_get(arg(4)); |
$method = services_method_get(arg(4)); |
| 170 |
$noskip = FALSE; |
$noskip = FALSE; |
| 171 |
// Convert args |
// Convert args |
| 172 |
for ($c = count($method['#args']) - 1; $c >= 0; $c--) { |
for ($c = count($method['args']) - 1; $c >= 0; $c--) { |
| 173 |
$arg = $method['#args'][$c]; |
$arg = $method['args'][$c]; |
| 174 |
$value = $values[$c]; |
$value = $values[$c]; |
| 175 |
|
|
| 176 |
// Remove empty values from end of array |
// Remove empty values from end of array |
| 194 |
$return[$c] = NULL; |
$return[$c] = NULL; |
| 195 |
} |
} |
| 196 |
else { |
else { |
| 197 |
$return[$c] = json_decode($value, $arg['#type'] === 'array'); |
$return[$c] = json_decode($value, $arg['type'] === 'array'); |
| 198 |
} |
} |
| 199 |
break; |
break; |
| 200 |
case 'sphp': |
case 'sphp': |
| 256 |
$auth_options = array('' => t('-- Select a authorization module')); |
$auth_options = array('' => t('-- Select a authorization module')); |
| 257 |
foreach ($auth_modules as $module) { |
foreach ($auth_modules as $module) { |
| 258 |
$info = services_auth_info(NULL, $module); |
$info = services_auth_info(NULL, $module); |
| 259 |
$auth_options[$info['#description']][$module] = $info['#title']; |
services_strip_hashes($info); |
| 260 |
|
|
| 261 |
|
$auth_options[$info['description']][$module] = $info['title']; |
| 262 |
} |
} |
| 263 |
|
|
| 264 |
$form['security'] = array( |
$form['security'] = array( |