/[drupal]/contributions/docs/developer/examples/xmlrpc_example.module
ViewVC logotype

Contents of /contributions/docs/developer/examples/xmlrpc_example.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Sun Feb 19 23:04:56 2006 UTC (3 years, 9 months ago) by JonBob
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5, DRUPAL-6--1, DRUPAL-4-7
Changes since 1.2: +3 -3 lines
File MIME type: text/x-php
Remove trailing whitespace
1 <?php
2 // $Id: xmlrpc_example.module,v 1.2 2005/11/16 08:31:38 drewish Exp $
3
4 /**
5 * @file
6 * This is an example of how to implement XML-RPC callbacks by implementing a
7 * validation suite.
8 *
9 * Information on the test in this suite can be found at:
10 * http://www.xmlrpc.com/validator1Docs
11 */
12
13 /**
14 * Implementation of hook_xmlrpc().
15 *
16 * This function provides Drupal with an array to map XML-RPC callbacks to the
17 * functions implemented by this module.
18 */
19 function xmlrpc_example_xmlrpc() {
20 return (array(
21 'validator1.arrayOfStructsTest' => 'xmlrpc_example_arrayOfStructsTest',
22 'validator1.countTheEntities' => 'xmlrpc_example_countTheEntities',
23 'validator1.easyStructTest' => 'xmlrpc_example_easyStructTest',
24 'validator1.echoStructTest' => 'xmlrpc_example_echoStructTest',
25 'validator1.manyTypesTest' => 'xmlrpc_example_manyTypesTest',
26 'validator1.moderateSizeArrayCheck' => 'xmlrpc_example_moderateSizeArrayCheck',
27 'validator1.nestedStructTest' => 'xmlrpc_example_nestedStructTest',
28 'validator1.simpleStructReturnTest' => 'xmlrpc_example_simpleStructReturnTest'
29 ));
30 }
31
32 function xmlrpc_example_arrayOfStructsTest($array) {
33 $sum = 0;
34 foreach ($array as $struct) {
35 $sum += $struct['curly'];
36 }
37 return $sum;
38 }
39
40 function xmlrpc_example_countTheEntities($string) {
41 return array(
42 'ctLeftAngleBrackets' => substr_count($string, '<'),
43 'ctRightAngleBrackets' => substr_count($string, '>'),
44 'ctAmpersands' => substr_count($string, '&'),
45 'ctApostrophes' => substr_count($string, "'"),
46 'ctQuotes' => substr_count($string, '"'),
47 );
48 }
49
50 function xmlrpc_example_easyStructTest($array) {
51 return $array["curly"] + $array["moe"] + $array["larry"];
52 }
53
54 function xmlrpc_example_echoStructTest($array) {
55 return $array;
56 }
57
58 function xmlrpc_example_manyTypesTest($args) {
59 $timestamp = mktime($args[4]->hour, $args[4]->minute, $args[4]->second, $args[4]->month, $args[4]->day, $args[4]->year);
60 return array($args[0], $args[1], $args[2], $args[3], xmlrpc_date($timestamp), xmlrpc_base64($args[5]));
61 }
62
63 function xmlrpc_example_moderateSizeArrayCheck($array) {
64 return array_shift($array) . array_pop($array);
65 }
66
67 function xmlrpc_example_nestedStructTest($array) {
68 return $array["2000"]["04"]["01"]["larry"] + $array["2000"]["04"]["01"]["moe"] + $array["2000"]["04"]["01"]["curly"];
69 }
70
71 function xmlrpc_example_simpleStructReturnTest($number) {
72 return array("times10" => ($number*10), "times100" => ($number*100), "times1000" => ($number*1000));
73 }
74

  ViewVC Help
Powered by ViewVC 1.1.2