├── docs ├── media │ ├── images │ │ ├── Constant.png │ │ └── Variable.png │ ├── banner.css │ └── stylesheet.css ├── blank.html ├── errors.html ├── packages.html ├── index.html ├── Ripcord │ ├── Ripcord_Exception.html │ ├── _ripcord_server.php.html │ ├── _ripcord_documentor.php.html │ ├── Ripcord_Documentor_Parser.html │ ├── Ripcord_Transport.html │ ├── Ripcord_Documentor_Parser_phpdoc.html │ ├── Ripcord_TransportException.html │ ├── Ripcord_BadMethodCallException.html │ ├── Ripcord_RemoteException.html │ ├── Ripcord_ConfigurationException.html │ ├── _ripcord.php.html │ ├── Ripcord_InvalidArgumentException.html │ ├── _ripcord_client.php.html │ ├── Ripcord_Documentor_Interface.html │ ├── Ripcord_Transport_CURL.html │ ├── Ripcord_Transport_Stream.html │ ├── Ripcord_Client_MultiCall.html │ ├── Ripcord_Client_Call.html │ └── Ripcord_Server.html ├── classtrees_Ripcord.html └── li_Ripcord.html ├── readme.txt ├── ripcord.php ├── ripcord_server.php ├── ripcord_client.php └── ripcord_documentor.php /docs/media/images/Constant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poef/ripcord/HEAD/docs/media/images/Constant.png -------------------------------------------------------------------------------- /docs/media/images/Variable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/poef/ripcord/HEAD/docs/media/images/Variable.png -------------------------------------------------------------------------------- /docs/blank.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Ripcord v0.9: Easy XML-RPC for PHP 4 | 5 | 6 | 7 | 8 |

Ripcord v0.9: Easy XML-RPC for PHP

9 | Welcome to Ripcord!
10 |
11 | This documentation was generated by phpDocumentor v1.4.3
12 | 13 | -------------------------------------------------------------------------------- /docs/media/banner.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | background-color: #CCCCFF; 4 | margin: 0px; 5 | padding: 0px; 6 | } 7 | 8 | /* Banner (top bar) classes */ 9 | 10 | .banner { } 11 | 12 | .banner-menu 13 | { 14 | clear: both; 15 | padding: .5em; 16 | border-top: 2px solid #6666AA; 17 | } 18 | 19 | .banner-title 20 | { 21 | text-align: right; 22 | font-size: 20pt; 23 | font-weight: bold; 24 | margin: .2em; 25 | } 26 | 27 | .package-selector 28 | { 29 | background-color: #AAAADD; 30 | border: 1px solid black; 31 | color: yellow; 32 | } 33 | -------------------------------------------------------------------------------- /docs/errors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | phpDocumentor Parser Errors and Warnings 7 | 8 | 9 | 10 | 11 | Post-parsing
12 | 13 |

ripcord_client.php

14 |

Warnings:


15 | Warning on line 313 - no @package tag was used in a DocBlock for class Ripcord_Client_MultiCall
16 |

17 | Documentation generated on Tue, 16 Nov 2010 16:20:19 +0100 by phpDocumentor 1.4.3 18 |

19 | 20 | -------------------------------------------------------------------------------- /docs/packages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 26 | 27 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | Ripcord v0.9: Easy XML-RPC for PHP 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | <H2>Frame Alert</H2> 20 | <P>This document is designed to be viewed using the frames feature. 21 | If you see this message, you are using a non-frame-capable web client.</P> 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_Exception.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_Exception 7 | 8 | 9 | 10 | 11 |
12 |

Interface Ripcord_Exception

13 | 14 | 15 |
16 |
Description
17 | 19 |
20 | 21 |

This interface is implemented by all exceptions thrown by Ripcord.

22 |

23 | Located in /ripcord.php (line 312) 24 |

25 | 26 | 27 |

28 | 	
29 | 			
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |

40 | Documentation generated on Tue, 16 Nov 2010 16:20:17 +0100 by phpDocumentor 1.4.3 41 |

42 |
43 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | Readme Ripcord: Easy XML-RPC Client and Server for PHP 5 2 | ============================================================================= 3 | 4 | Ripcord is a very easy to use XML-RPC library for PHP. It provides client, 5 | server and auto documentation features for XML-RPC but also SimpleRPC and 6 | simplified SOAP (1.1). It uses PHP's xmlrpc library and it needs at least PHP 5. 7 | 8 | To create a simple xmlrpc client do something like this: 9 | 10 | film->getScore( 'e3dee9d19a8c3af7c92f9067d2945b59', 500 ); 14 | ?> 15 | 16 | See the RipcordClientManual 17 | for more information. 18 | 19 | To create a simple xmlrpc server do something like this: 20 | 21 | run(); 31 | ?> 32 | 33 | See the RipcordServerManual 34 | for more information. 35 | 36 | 37 | Extending Ripcord 38 | ================= 39 | 40 | Ripcord is also very simple to extend. All functionality can be changed 41 | through dependency injection. The client by default uses the PHP Streams API 42 | to connect to a server, but can simply be reconfigured to use CURL. You 43 | can provide your own configuration or even a completely new transport method 44 | by simply injecting a new transport object into the client. 45 | 46 | Any server created with Ripcord is auto documenting by default. Simply browse 47 | to the URL of your RPC server and you will see a list of all methods including 48 | any inline documentation for that method, if you use docblock style comments, e.g.: 49 | 50 | /** 51 | * This will show up with your method description. 52 | */ 53 | function yourMethod() { 54 | } 55 | 56 | The auto documentor is again easily extended to use your own styles or extensions 57 | and you can simply inject a completely different documentor object into the server 58 | if you want. Or skip it altogether. 59 | 60 | 61 | Documentation 62 | ============= 63 | 64 | The full API documentation is included in the docs/ directory. 65 | 66 | -------------------------------------------------------------------------------- /docs/classtrees_Ripcord.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 |

16 |

Root interface Ripcord_Documentor_Interface

17 | 19 | 20 |

Root interface Ripcord_Documentor_Parser

21 | 23 | 24 |

Root interface Ripcord_Exception

25 | 27 | 28 |

Root interface Ripcord_Transport

29 | 31 | 32 |

Root class ripcord

33 | 35 | 36 |

Root class Ripcord_Client

37 | 41 | 42 |

Root class Ripcord_Client_Call

43 | 45 | 46 |

Root class Ripcord_Documentor

47 | 49 | 50 |

Root class Ripcord_Documentor_Parser_phpdoc

51 | 53 | 54 |

Root class Ripcord_Server

55 | 57 | 58 |

Root class Ripcord_Transport_CURL

59 | 61 | 62 |

Root class Ripcord_Transport_Stream

63 | 65 | 66 |

Root class BadMethodCallException

67 | 69 | 70 |

Root class Exception

71 | 73 | 74 |

Root class InvalidArgumentException

75 | 77 | 78 |

Root class RuntimeException

79 | 81 | 82 |

83 | Documentation generated on Tue, 16 Nov 2010 16:20:15 +0100 by phpDocumentor 1.4.3 84 |

85 | 86 | -------------------------------------------------------------------------------- /docs/Ripcord/_ripcord_server.php.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs for page ripcord_server.php 7 | 8 | 9 | 10 | 11 |
12 |

/ripcord_server.php

13 | 14 | 15 |
16 |
Description
17 | 22 |
23 | 24 |

Ripcord is an easy to use XML-RPC library for PHP.

25 |
    26 |
  • author: Auke van Slooten <auke@muze.nl>
  • 27 |
  • version: Ripcord 0.9 - PHP 5
  • 28 |
  • copyright: Copyright (C) 2010, Muze <www.muze.nl>
  • 29 |
  • license: GNU Public License
  • 30 |
31 | 32 |
33 |
34 | 35 | 36 |
37 |
Classes
38 | 43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 56 | 57 |
ClassDescription
51 | Ripcord_Server 52 | 54 | This class implements the Ripcord server. It is an OO wrapper around PHP's XML-RPC methods, with some added features. 55 |
58 |
59 |
60 | 61 | 62 |
63 |
Includes
64 | 69 |
70 | 71 |
72 | 73 |
74 | 75 | require_once 76 | (dirname(__FILE__).'/ripcord.php') 77 | (line 14) 78 | 79 |
80 | 81 | 82 |

Includes the static ripcord factory class and exceptions

83 | 84 |
85 |
86 |
87 | 88 | 89 | 90 | 91 |

92 | Documentation generated on Tue, 16 Nov 2010 16:20:19 +0100 by phpDocumentor 1.4.3 93 |

94 |
95 | -------------------------------------------------------------------------------- /docs/Ripcord/_ripcord_documentor.php.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs for page ripcord_documentor.php 7 | 8 | 9 | 10 | 11 |
12 |

/ripcord_documentor.php

13 | 14 | 15 |
16 |
Description
17 | 21 |
22 | 23 |

Ripcord is an easy to use XML-RPC library for PHP.

24 |
    25 |
  • author: Auke van Slooten <auke@muze.nl>
  • 26 |
  • version: Ripcord 0.9 - PHP 5
  • 27 |
  • copyright: Copyright (C) 2010, Muze <www.muze.nl>
  • 28 |
  • license: GNU Public License
  • 29 |
30 | 31 |
32 |
33 | 34 | 35 |
36 |
Classes
37 | 41 |
42 | 43 | 44 | 45 | 46 | 47 | 48 | 51 | 54 | 55 | 56 | 59 | 62 | 63 | 64 | 67 | 70 | 71 | 72 | 75 | 78 | 79 |
ClassDescription
49 | Ripcord_Documentor_Interface 50 | 52 | This interface defines the minimum methods any documentor needs to implement. 53 |
57 | Ripcord_Documentor 58 | 60 | This class implements the default documentor for the ripcord server. Any request to the server without a request_xml is handled by the documentor. 61 |
65 | Ripcord_Documentor_Parser 66 | 68 | This interface describes the minimum interface needed for a comment parser object used by the 69 |
73 | Ripcord_Documentor_Parser_phpdoc 74 | 76 | This class implements the Ripcord_Documentor_Parser interface, parsing the docComment as a phpdoc style docComment. 77 |
80 |
81 |
82 | 83 | 84 | 85 | 86 | 87 |

88 | Documentation generated on Tue, 16 Nov 2010 16:20:18 +0100 by phpDocumentor 1.4.3 89 |

90 |
91 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_Documentor_Parser.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_Documentor_Parser 7 | 8 | 9 | 10 | 11 |
12 |

Interface Ripcord_Documentor_Parser

13 | 14 | 15 |
16 |
Description
17 | 22 |
23 | 24 |

This interface describes the minimum interface needed for a comment parser object used by the

25 |

Ripcord_Documentor

26 |

27 | Located in /ripcord_documentor.php (line 489) 28 |

29 | 30 | 31 |

 32 | 	
 33 | 			
34 |
35 | 36 | 37 | 38 | 39 | 40 |
41 |
Method Summary
42 | 46 |
47 |
48 | 49 |
50 | array 51 | parse 52 | (string $commentBlock) 53 |
54 |
55 |
56 |
57 | 58 | 59 | 60 |
61 |
Methods
62 | 67 |
68 | 69 | 70 | 71 |
72 | 73 |
74 | parse (line 496) 75 |
76 | 77 | 78 |

This method parses a given docComment block and returns an array with information.

79 |
    80 |
  • return: The parsed information.
  • 81 |
  • access: public
  • 82 |
83 | 84 |
85 | array 86 | 87 | parse 88 | 89 | (string $commentBlock) 90 |
91 | 92 |
    93 |
  • 94 | string 95 | $commentBlock: The docComment block.
  • 96 |
97 | 98 | 99 |
100 | 101 |
102 |
103 | 104 | 105 |

106 | Documentation generated on Tue, 16 Nov 2010 16:20:19 +0100 by phpDocumentor 1.4.3 107 |

108 |
109 | -------------------------------------------------------------------------------- /docs/li_Ripcord.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
Ripcord
12 | 53 |

phpDocumentor v 1.4.3

54 | 55 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_Transport.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_Transport 7 | 8 | 9 | 10 | 11 |
12 |

Interface Ripcord_Transport

13 | 14 | 15 |
16 |
Description
17 | 22 |
23 | 24 |

This interface describes the minimum interface needed for the transport object used by the

25 |

Ripcord_Client

26 |

27 | Located in /ripcord_client.php (line 425) 28 |

29 | 30 | 31 |

 32 | 	
 33 | 			
34 |
35 | 36 | 37 | 38 | 39 | 40 |
41 |
Method Summary
42 | 46 |
47 |
48 | 49 |
50 | string 51 | post 52 | (string $url, string $request) 53 |
54 |
55 |
56 |
57 | 58 | 59 | 60 |
61 |
Methods
62 | 67 |
68 | 69 | 70 | 71 |
72 | 73 |
74 | post (line 433) 75 |
76 | 77 | 78 |

This method must post the request to the given url and return the results.

79 |
    80 |
  • return: The server response
  • 81 |
  • access: public
  • 82 |
83 | 84 |
85 | string 86 | 87 | post 88 | 89 | (string $url, string $request) 90 |
91 | 92 |
    93 |
  • 94 | string 95 | $url: The url to post to.
  • 96 |
  • 97 | string 98 | $request: The request to post.
  • 99 |
100 | 101 | 102 |
103 | 104 |
105 |
106 | 107 | 108 |

109 | Documentation generated on Tue, 16 Nov 2010 16:20:18 +0100 by phpDocumentor 1.4.3 110 |

111 |
112 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_Documentor_Parser_phpdoc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_Documentor_Parser_phpdoc 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_Documentor_Parser_phpdoc

13 | 14 | 15 |
16 |
Description
17 | 22 |
23 |

24 | Implements interfaces: 25 |

27 |

28 | 29 |

This class implements the Ripcord_Documentor_Parser interface, parsing the docComment as a phpdoc style docComment.

30 |

31 | Located in /ripcord_documentor.php (line 504) 32 |

33 | 34 | 35 |

 36 | 	
 37 | 			
38 |
39 | 40 | 41 | 42 | 43 | 44 |
45 |
Method Summary
46 | 50 |
51 |
52 | 53 |
54 | array 55 | parse 56 | (string $commentBlock) 57 |
58 |
59 |
60 |
61 | 62 | 63 | 64 |
65 |
Methods
66 | 71 |
72 | 73 | 74 | 75 |
76 | 77 |
78 | parse (line 512) 79 |
80 | 81 | 82 |

This method parses a given docComment block and returns an array with information.

83 |
    84 |
  • return: The parsed information.
  • 85 |
  • access: public
  • 86 |
87 | 88 |
89 | array 90 | 91 | parse 92 | 93 | (string $commentBlock) 94 |
95 | 96 |
    97 |
  • 98 | string 99 | $commentBlock: The docComment block.
  • 100 |
101 | 102 |
103 |
Implementation of:
104 |
105 |
Ripcord_Documentor_Parser::parse()
106 |
This method parses a given docComment block and returns an array with information.
107 |
108 | 109 |
110 | 111 |
112 |
113 | 114 | 115 |

116 | Documentation generated on Tue, 16 Nov 2010 16:20:19 +0100 by phpDocumentor 1.4.3 117 |

118 |
119 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_TransportException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_TransportException 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_TransportException

13 | 14 | 15 |
16 |
Description
17 | 23 |
24 |

25 | Implements interfaces: 26 |

28 |

29 | 30 |

This class is used whenever something goes wrong in sending / receiving data. Possible exceptions thrown are:

  • ripcord::cannotAccessURL (-4) Could not access {url} - Thrown by the transport object when unable to access the given url.

31 |

32 | Located in /ripcord.php (line 344) 33 |

34 | 35 | 36 |
RuntimeException
 37 |    |
 38 |    --Ripcord_TransportException
39 | 40 |
41 |
42 | 43 | 44 | 45 | 46 | 47 | 48 |
49 |
Variables
50 | 59 |
60 |

Inherited Variables

61 | 62 |

Inherited from RuntimeException (Internal Class)

63 |
64 | 65 | $code
66 |
67 | 68 | $file
69 |
70 | 71 | $line
72 |
73 | 74 | $message
75 |
76 |
77 | 78 |
79 |
80 | 81 | 82 |
83 |
Methods
84 | 90 |
91 | 92 | 93 |

Inherited Methods

94 | 95 | 96 |

Inherited From RuntimeException (Internal Class)

97 |
98 | constructor __construct ( [$message = ], [$code = ] )
99 | getCode ( )
100 | getFile ( )
101 | getLine ( )
102 | getMessage ( )
103 | getTrace ( )
104 | getTraceAsString ( )
105 | __clone ( )
106 | __toString ( )
107 |
108 | 109 |
110 |
111 | 112 | 113 |

114 | Documentation generated on Tue, 16 Nov 2010 16:20:17 +0100 by phpDocumentor 1.4.3 115 |

116 |
117 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_BadMethodCallException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_BadMethodCallException 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_BadMethodCallException

13 | 14 | 15 |
16 |
Description
17 | 23 |
24 |

25 | Implements interfaces: 26 |

28 |

29 | 30 |

This class is used whenever an when a method passed to the server is invalid.

31 |

  • ripcord::methodNotFound (-1) Method {method} not found. - Thrown by the ripcord server when a requested method isn't found.

32 |

33 | Located in /ripcord.php (line 319) 34 |

35 | 36 | 37 |
BadMethodCallException
 38 |    |
 39 |    --Ripcord_BadMethodCallException
40 | 41 |
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 |
Variables
51 | 60 |
61 |

Inherited Variables

62 | 63 |

Inherited from BadMethodCallException (Internal Class)

64 |
65 | 66 | $code
67 |
68 | 69 | $file
70 |
71 | 72 | $line
73 |
74 | 75 | $message
76 |
77 |
78 | 79 |
80 |
81 | 82 | 83 |
84 |
Methods
85 | 91 |
92 | 93 | 94 |

Inherited Methods

95 | 96 | 97 |

Inherited From BadMethodCallException (Internal Class)

98 |
99 | constructor __construct ( [$message = ], [$code = ] )
100 | getCode ( )
101 | getFile ( )
102 | getLine ( )
103 | getMessage ( )
104 | getTrace ( )
105 | getTraceAsString ( )
106 | __clone ( )
107 | __toString ( )
108 |
109 | 110 |
111 |
112 | 113 | 114 |

115 | Documentation generated on Tue, 16 Nov 2010 16:20:16 +0100 by phpDocumentor 1.4.3 116 |

117 |
118 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_RemoteException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_RemoteException 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_RemoteException

13 | 14 | 15 |
16 |
Description
17 | 23 |
24 |

25 | Implements interfaces: 26 |

28 |

29 | 30 |

This class is used for exceptions generated from xmlrpc faults returned by the server. The code and message correspond to the code and message from the xmlrpc fault.

31 |

32 | Located in /ripcord.php (line 351) 33 |

34 | 35 | 36 |
Exception
 37 |    |
 38 |    --Ripcord_RemoteException
39 | 40 |
41 |
42 | 43 | 44 | 45 | 46 | 47 | 48 |
49 |
Variables
50 | 59 |
60 |

Inherited Variables

61 | 62 |

Inherited from Exception (Internal Class)

63 |
64 | 65 | $code
66 |
67 | 68 | $file
69 |
70 | 71 | $line
72 |
73 | 74 | $message
75 |
76 | 77 | $string
78 |
79 | 80 | $trace
81 |
82 |
83 | 84 |
85 |
86 | 87 | 88 |
89 |
Methods
90 | 96 |
97 | 98 | 99 |

Inherited Methods

100 | 101 | 102 |

Inherited From Exception (Internal Class)

103 |
104 | constructor __construct ( [$message = ], [$code = ] )
105 | getCode ( )
106 | getFile ( )
107 | getLine ( )
108 | getMessage ( )
109 | getTrace ( )
110 | getTraceAsString ( )
111 | __clone ( )
112 | __toString ( )
113 |
114 | 115 |
116 |
117 | 118 | 119 |

120 | Documentation generated on Tue, 16 Nov 2010 16:20:17 +0100 by phpDocumentor 1.4.3 121 |

122 |
123 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_ConfigurationException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_ConfigurationException 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_ConfigurationException

13 | 14 | 15 |
16 |
Description
17 | 23 |
24 |

25 | Implements interfaces: 26 |

28 |

29 | 30 |

This class is used whenever prerequisite requirements are not met.

31 |

  • ripcord::xmlrpcNotInstalled (-5) PHP XMLRPC library is not installed - Thrown by the ripcord server and client when the xmlrpc library is not installed.

32 |

33 | Located in /ripcord.php (line 326) 34 |

35 | 36 | 37 |
Exception
 38 |    |
 39 |    --Ripcord_ConfigurationException
40 | 41 |
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 |
Variables
51 | 60 |
61 |

Inherited Variables

62 | 63 |

Inherited from Exception (Internal Class)

64 |
65 | 66 | $code
67 |
68 | 69 | $file
70 |
71 | 72 | $line
73 |
74 | 75 | $message
76 |
77 | 78 | $string
79 |
80 | 81 | $trace
82 |
83 |
84 | 85 |
86 |
87 | 88 | 89 |
90 |
Methods
91 | 97 |
98 | 99 | 100 |

Inherited Methods

101 | 102 | 103 |

Inherited From Exception (Internal Class)

104 |
105 | constructor __construct ( [$message = ], [$code = ] )
106 | getCode ( )
107 | getFile ( )
108 | getLine ( )
109 | getMessage ( )
110 | getTrace ( )
111 | getTraceAsString ( )
112 | __clone ( )
113 | __toString ( )
114 |
115 | 116 |
117 |
118 | 119 | 120 |

121 | Documentation generated on Tue, 16 Nov 2010 16:20:17 +0100 by phpDocumentor 1.4.3 122 |

123 |
124 | -------------------------------------------------------------------------------- /docs/Ripcord/_ripcord.php.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs for page ripcord.php 7 | 8 | 9 | 10 | 11 |
12 |

/ripcord.php

13 | 14 | 15 |
16 |
Description
17 | 21 |
22 | 23 |

Ripcord is an easy to use XML-RPC library for PHP.

24 |
    25 |
  • author: Auke van Slooten <auke@muze.nl>
  • 26 |
  • version: Ripcord 0.9 - PHP 5
  • 27 |
  • copyright: Copyright (C) 2010, Muze <www.muze.nl>
  • 28 |
  • license: GNU Public License
  • 29 |
30 | 31 |
32 |
33 | 34 | 35 |
36 |
Classes
37 | 41 |
42 | 43 | 44 | 45 | 46 | 47 | 48 | 51 | 54 | 55 | 56 | 59 | 62 | 63 | 64 | 67 | 70 | 71 | 72 | 75 | 78 | 79 | 80 | 83 | 86 | 87 | 88 | 91 | 94 | 95 | 96 | 99 | 102 | 103 |
ClassDescription
49 | ripcord 50 | 52 | The ripcord class contains a number of useful static methods. This makes it a bit easier to create a server or client, convert types and check for errors. 53 |
57 | Ripcord_Exception 58 | 60 | This interface is implemented by all exceptions thrown by Ripcord. 61 |
65 | Ripcord_BadMethodCallException 66 | 68 | This class is used whenever an when a method passed to the server is invalid. 69 |
73 | Ripcord_ConfigurationException 74 | 76 | This class is used whenever prerequisite requirements are not met. 77 |
81 | Ripcord_InvalidArgumentException 82 | 84 | This class is used whenever an argument passed to a Ripcord method is invalid for any reason. Possible exceptions thrown are:
  • ripcord::notRipcordCall (-2) Argument {index} is not a valid Ripcord call - Thrown by the client when passing incorrect arguments to system.multiCall.
85 |
89 | Ripcord_TransportException 90 | 92 | This class is used whenever something goes wrong in sending / receiving data. Possible exceptions thrown are:
  • ripcord::cannotAccessURL (-4) Could not access {url} - Thrown by the transport object when unable to access the given url.
93 |
97 | Ripcord_RemoteException 98 | 100 | This class is used for exceptions generated from xmlrpc faults returned by the server. The code and message correspond to the code and message from the xmlrpc fault. 101 |
104 |
105 |
106 | 107 | 108 | 109 | 110 | 111 |

112 | Documentation generated on Tue, 16 Nov 2010 16:20:15 +0100 by phpDocumentor 1.4.3 113 |

114 |
115 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_InvalidArgumentException.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_InvalidArgumentException 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_InvalidArgumentException

13 | 14 | 15 |
16 |
Description
17 | 23 |
24 |

25 | Implements interfaces: 26 |

28 |

29 | 30 |

This class is used whenever an argument passed to a Ripcord method is invalid for any reason. Possible exceptions thrown are:

  • ripcord::notRipcordCall (-2) Argument {index} is not a valid Ripcord call - Thrown by the client when passing incorrect arguments to system.multiCall.

31 |

  • ripcord::cannotRecurse (-3) Cannot recurse system.multiCall - Thrown by the ripcord server when system.multicall is called within itself.
  • ripcord::notDateTime (-6) Variable is not of type datetime - Thrown by the ripcord timestamp method.
  • ripcord::notBase64 (-7) Variable is not of type base64 - Thrown by the ripcord binary method.
  • ripcord::unknownServiceType (-8) Variable is not a classname or an object - Thrown by the ripcord server.

32 |

33 | Located in /ripcord.php (line 337) 34 |

35 | 36 | 37 |
InvalidArgumentException
 38 |    |
 39 |    --Ripcord_InvalidArgumentException
40 | 41 |
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 |
Variables
51 | 60 |
61 |

Inherited Variables

62 | 63 |

Inherited from InvalidArgumentException (Internal Class)

64 |
65 | 66 | $code
67 |
68 | 69 | $file
70 |
71 | 72 | $line
73 |
74 | 75 | $message
76 |
77 |
78 | 79 |
80 |
81 | 82 | 83 |
84 |
Methods
85 | 91 |
92 | 93 | 94 |

Inherited Methods

95 | 96 | 97 |

Inherited From InvalidArgumentException (Internal Class)

98 |
99 | constructor __construct ( [$message = ], [$code = ] )
100 | getCode ( )
101 | getFile ( )
102 | getLine ( )
103 | getMessage ( )
104 | getTrace ( )
105 | getTraceAsString ( )
106 | __clone ( )
107 | __toString ( )
108 |
109 | 110 |
111 |
112 | 113 | 114 |

115 | Documentation generated on Tue, 16 Nov 2010 16:20:17 +0100 by phpDocumentor 1.4.3 116 |

117 |
118 | -------------------------------------------------------------------------------- /docs/Ripcord/_ripcord_client.php.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs for page ripcord_client.php 7 | 8 | 9 | 10 | 11 |
12 |

/ripcord_client.php

13 | 14 | 15 |
16 |
Description
17 | 22 |
23 | 24 |

Ripcord is an easy to use XML-RPC library for PHP.

25 |
    26 |
  • author: Auke van Slooten <auke@muze.nl>
  • 27 |
  • version: Ripcord 0.9 - PHP 5
  • 28 |
  • copyright: Copyright (C) 2010, Muze <www.muze.nl>
  • 29 |
  • license: GNU Public License
  • 30 |
31 | 32 |
33 |
34 | 35 | 36 |
37 |
Classes
38 | 43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 56 | 57 | 58 | 61 | 64 | 65 | 66 | 69 | 72 | 73 | 74 | 77 | 80 | 81 | 82 | 85 | 88 | 89 | 90 | 93 | 96 | 97 |
ClassDescription
51 | Ripcord_Client 52 | 54 | This class implements a simple RPC client, for XML-RPC, (simplified) SOAP 1.1 or Simple RPC. The client abstracts the entire RPC process behind native PHP methods. Any method defined by the rpc server can be called as if it was a native method of the rpc client. 55 |
59 | Ripcord_Client_MultiCall 60 | 62 | This class provides the fetch interface for system.multiCall. It is returned 63 |
67 | Ripcord_Client_Call 68 | 70 | This class is used with the Ripcord_Client when calling system.multiCall. Instead of immediately calling the method on the rpc server, a Ripcord_Client_Call object is created with all the information needed to call the method using the multicall parameters. The call object is returned immediately and is used as input parameter for the multiCall call. The result of the call can be bound to a php variable. This variable will be filled with the result of the call when it is available. 71 |
75 | Ripcord_Transport 76 | 78 | This interface describes the minimum interface needed for the transport object used by the 79 |
83 | Ripcord_Transport_Stream 84 | 86 | This class implements the Ripcord_Transport interface using PHP streams. 87 |
91 | Ripcord_Transport_CURL 92 | 94 | This class implements the Ripcord_Transport interface using CURL. 95 |
98 |
99 |
100 | 101 | 102 |
103 |
Includes
104 | 109 |
110 | 111 |
112 | 113 |
114 | 115 | require_once 116 | (dirname(__FILE__).'/ripcord.php') 117 | (line 14) 118 | 119 |
120 | 121 | 122 |

Includes the static ripcord factory class and exceptions

123 | 124 |
125 |
126 |
127 | 128 | 129 | 130 | 131 |

132 | Documentation generated on Tue, 16 Nov 2010 16:20:17 +0100 by phpDocumentor 1.4.3 133 |

134 |
135 | -------------------------------------------------------------------------------- /docs/media/stylesheet.css: -------------------------------------------------------------------------------- 1 | a { color: #336699; text-decoration: none; } 2 | a:hover { color: #6699CC; text-decoration: underline; } 3 | a:active { color: #6699CC; text-decoration: underline; } 4 | 5 | body { background : #FFFFFF; } 6 | body, table { font-family: Georgia, Times New Roman, Times, serif; font-size: 10pt } 7 | p, li { line-height: 140% } 8 | a img { border: 0px; } 9 | dd { margin-left: 0px; padding-left: 1em; } 10 | 11 | /* Page layout/boxes */ 12 | 13 | .info-box {} 14 | .info-box-title { margin: 1em 0em 0em 0em; padding: .25em; font-weight: normal; font-size: 14pt; border: 2px solid #999999; background-color: #CCCCFF } 15 | .info-box-body { border: 1px solid #999999; padding: .5em; } 16 | .nav-bar { font-size: 8pt; white-space: nowrap; text-align: right; padding: .2em; margin: 0em 0em 1em 0em; } 17 | 18 | .oddrow { background-color: #F8F8F8; border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em} 19 | .evenrow { border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em} 20 | 21 | .page-body { max-width: 800px; margin: auto; } 22 | .tree dl { margin: 0px } 23 | 24 | /* Index formatting classes */ 25 | 26 | .index-item-body { margin-top: .5em; margin-bottom: .5em} 27 | .index-item-description { margin-top: .25em } 28 | .index-item-details { font-weight: normal; font-style: italic; font-size: 8pt } 29 | .index-letter-section { background-color: #EEEEEE; border: 1px dotted #999999; padding: .5em; margin-bottom: 1em} 30 | .index-letter-title { font-size: 12pt; font-weight: bold } 31 | .index-letter-menu { text-align: center; margin: 1em } 32 | .index-letter { font-size: 12pt } 33 | 34 | /* Docbook classes */ 35 | 36 | .description {} 37 | .short-description { font-weight: bold; color: #666666; } 38 | .tags { padding-left: 0em; margin-left: 3em; color: #666666; list-style-type: square; } 39 | .parameters { padding-left: 0em; margin-left: 3em; font-style: italic; list-style-type: square; } 40 | .redefinitions { font-size: 8pt; padding-left: 0em; margin-left: 2em; } 41 | .package { } 42 | .package-title { font-weight: bold; font-size: 14pt; border-bottom: 1px solid black } 43 | .package-details { font-size: 85%; } 44 | .sub-package { font-weight: bold; font-size: 120% } 45 | .tutorial { border-width: thin; border-color: #0066ff } 46 | .tutorial-nav-box { width: 100%; border: 1px solid #999999; background-color: #F8F8F8; } 47 | .nav-button-disabled { color: #999999; } 48 | .nav-button:active, 49 | .nav-button:focus, 50 | .nav-button:hover { background-color: #DDDDDD; outline: 1px solid #999999; text-decoration: none } 51 | .folder-title { font-style: italic } 52 | 53 | /* Generic formatting */ 54 | 55 | .field { font-weight: bold; } 56 | .detail { font-size: 8pt; } 57 | .notes { font-style: italic; font-size: 8pt; } 58 | .separator { background-color: #999999; height: 2px; } 59 | .warning { color: #FF6600; } 60 | .disabled { font-style: italic; color: #999999; } 61 | 62 | /* Code elements */ 63 | 64 | .line-number { } 65 | 66 | .class-table { width: 100%; } 67 | .class-table-header { border-bottom: 1px dotted #666666; text-align: left} 68 | .class-name { color: #000000; font-weight: bold; } 69 | 70 | .method-summary { padding-left: 1em; font-size: 8pt } 71 | .method-header { } 72 | .method-definition { margin-bottom: .3em } 73 | .method-title { font-weight: bold; } 74 | .method-name { font-weight: bold; } 75 | .method-signature { font-size: 85%; color: #666666; margin: .5em 0em } 76 | .method-result { font-style: italic; } 77 | 78 | .var-summary { padding-left: 1em; font-size: 8pt; } 79 | .var-header { } 80 | .var-title { margin-bottom: .3em } 81 | .var-type { font-style: italic; } 82 | .var-name { font-weight: bold; } 83 | .var-default {} 84 | .var-description { font-weight: normal; color: #000000; } 85 | 86 | .include-title { } 87 | .include-type { font-style: italic; } 88 | .include-name { font-weight: bold; } 89 | 90 | .const-title { } 91 | .const-name { font-weight: bold; } 92 | 93 | /* Syntax highlighting */ 94 | 95 | .src-code { border: 1px solid #336699; padding: 1em; background-color: #EEEEEE; } 96 | .src-line { font-family: 'Courier New', Courier, monospace; font-weight: normal; } 97 | 98 | .src-comm { color: green; } 99 | .src-id { } 100 | .src-inc { color: #0000FF; } 101 | .src-key { color: #0000FF; } 102 | .src-num { color: #CC0000; } 103 | .src-str { color: #66cccc; } 104 | .src-sym { font-weight: bold; } 105 | .src-var { } 106 | 107 | .src-php { font-weight: bold; } 108 | 109 | .src-doc { color: #009999 } 110 | .src-doc-close-template { color: #0000FF } 111 | .src-doc-coretag { color: #0099FF; font-weight: bold } 112 | .src-doc-inlinetag { color: #0099FF } 113 | .src-doc-internal { color: #6699cc } 114 | .src-doc-tag { color: #0080CC } 115 | .src-doc-template { color: #0000FF } 116 | .src-doc-type { font-style: italic } 117 | .src-doc-var { font-style: italic } 118 | 119 | .tute-tag { color: #009999 } 120 | .tute-attribute-name { color: #0000FF } 121 | .tute-attribute-value { color: #0099FF } 122 | .tute-entity { font-weight: bold; } 123 | .tute-comment { font-style: italic } 124 | .tute-inline-tag { color: #636311; font-weight: bold } 125 | 126 | /* tutorial */ 127 | 128 | .authors { } 129 | .author { font-style: italic; font-weight: bold } 130 | .author-blurb { margin: .5em 0em .5em 2em; font-size: 85%; font-weight: normal; font-style: normal } 131 | .example { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; } 132 | *[class="example"] { line-height : 0.5em } 133 | .listing { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; white-space: nowrap; } 134 | *[class="listing"] { line-height : 0.5em } 135 | .release-info { font-size: 85%; font-style: italic; margin: 1em 0em } 136 | .ref-title-box { } 137 | .ref-title { } 138 | .ref-purpose { font-style: italic; color: #666666 } 139 | .ref-synopsis { } 140 | .title { font-weight: bold; margin: 1em 0em 0em 0em; padding: .25em; border: 2px solid #999999; background-color: #CCCCFF } 141 | .cmd-synopsis { margin: 1em 0em } 142 | .cmd-title { font-weight: bold } 143 | .toc { margin-left: 2em; padding-left: 0em } 144 | 145 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_Documentor_Interface.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_Documentor_Interface 7 | 8 | 9 | 10 | 11 |
12 |

Interface Ripcord_Documentor_Interface

13 | 14 | 15 |
16 |
Description
17 | 22 |
23 | 24 |

This interface defines the minimum methods any documentor needs to implement.

25 |

26 | Located in /ripcord_documentor.php (line 15) 27 |

28 | 29 | 30 |

 31 | 	
 32 | 			
33 |
34 | 35 | 36 | 37 | 38 | 39 |
40 |
Method Summary
41 | 45 |
46 |
47 | 48 |
49 | Ripcord_Documentor_Interface 50 | __construct 51 | ([ $options = null]) 52 |
53 |
54 | void 55 | getIntrospectionXML 56 | () 57 |
58 |
59 | void 60 | handle 61 | ( $rpcServer) 62 |
63 |
64 | void 65 | setMethodData 66 | ( $methods) 67 |
68 |
69 |
70 |
71 | 72 | 73 | 74 |
75 |
Methods
76 | 81 |
82 | 83 | 84 | 85 |
86 | 87 |
88 | Constructor __construct (line 17) 89 |
90 | 91 | 92 |
    93 |
  • access: public
  • 94 |
95 | 96 |
97 | Ripcord_Documentor_Interface 98 | 99 | __construct 100 | 101 | ([ $options = null]) 102 |
103 | 104 |
    105 |
  • 106 | 107 | $options
  • 108 |
109 | 110 | 111 |
112 | 113 |
114 | 115 |
116 | getIntrospectionXML (line 20) 117 |
118 | 119 | 120 |
    121 |
  • access: public
  • 122 |
123 | 124 |
125 | void 126 | 127 | getIntrospectionXML 128 | 129 | () 130 |
131 | 132 | 133 | 134 |
135 | 136 |
137 | 138 |
139 | handle (line 19) 140 |
141 | 142 | 143 |
    144 |
  • access: public
  • 145 |
146 | 147 |
148 | void 149 | 150 | handle 151 | 152 | ( $rpcServer) 153 |
154 | 155 |
    156 |
  • 157 | 158 | $rpcServer
  • 159 |
160 | 161 | 162 |
163 | 164 |
165 | 166 |
167 | setMethodData (line 18) 168 |
169 | 170 | 171 |
    172 |
  • access: public
  • 173 |
174 | 175 |
176 | void 177 | 178 | setMethodData 179 | 180 | ( $methods) 181 |
182 | 183 |
    184 |
  • 185 | 186 | $methods
  • 187 |
188 | 189 | 190 |
191 | 192 |
193 |
194 | 195 | 196 |

197 | Documentation generated on Tue, 16 Nov 2010 16:20:18 +0100 by phpDocumentor 1.4.3 198 |

199 |
200 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_Transport_CURL.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_Transport_CURL 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_Transport_CURL

13 | 14 | 15 |
16 |
Description
17 | 23 |
24 |

25 | Implements interfaces: 26 |

28 |

29 | 30 |

This class implements the Ripcord_Transport interface using CURL.

31 |

32 | Located in /ripcord_client.php (line 499) 33 |

34 | 35 | 36 |

 37 | 	
 38 | 			
39 |
40 | 41 | 42 | 43 | 44 |
45 |
Variable Summary
46 | 53 |
54 |
55 |
56 | mixed 57 | $responseHeaders 58 |
59 |
60 |
61 |
62 | 63 | 64 |
65 |
Method Summary
66 | 73 |
74 |
75 | 76 |
77 | Ripcord_Transport_CURL 78 | __construct 79 | ([array $curlOptions = null]) 80 |
81 |
82 | string 83 | post 84 | (string $url, string $request) 85 |
86 |
87 |
88 |
89 | 90 | 91 |
92 |
Variables
93 | 102 |
103 | 104 |
105 | 106 |
107 | 108 | mixed 109 | $responseHeaders 110 | = null (line 514) 111 | 112 |
113 | 114 | 115 |

Contains the headers sent by the server.

116 |
    117 |
  • access: public
  • 118 |
119 | 120 | 121 | 122 | 123 | 124 |
125 | 126 |
127 |
128 | 129 | 130 |
131 |
Methods
132 | 138 |
139 | 140 | 141 | 142 |
143 | 144 |
145 | Constructor __construct (line 520) 146 |
147 | 148 | 149 |

This is the constructor for the Ripcord_Transport_CURL class.

150 |
    151 |
  • access: public
  • 152 |
153 | 154 |
155 | Ripcord_Transport_CURL 156 | 157 | __construct 158 | 159 | ([array $curlOptions = null]) 160 |
161 | 162 |
    163 |
  • 164 | array 165 | $curlOptions: A list of CURL options.
  • 166 |
167 | 168 | 169 |
170 | 171 |
172 | 173 |
174 | post (line 539) 175 |
176 | 177 | 178 |

This method posts the request to the given url

179 |
    180 |
  • return: The server response
  • 181 |
  • throws: Ripcord_TransportException (ripcord::cannotAccessURL) when the given URL cannot be accessed for any reason.
  • 182 |
  • access: public
  • 183 |
184 | 185 |
186 | string 187 | 188 | post 189 | 190 | (string $url, string $request) 191 |
192 | 193 |
    194 |
  • 195 | string 196 | $url: The url to post to.
  • 197 |
  • 198 | string 199 | $request: The request to post.
  • 200 |
201 | 202 |
203 |
Implementation of:
204 |
205 |
Ripcord_Transport::post()
206 |
This method must post the request to the given url and return the results.
207 |
208 | 209 |
210 | 211 |
212 |
213 | 214 | 215 |

216 | Documentation generated on Tue, 16 Nov 2010 16:20:18 +0100 by phpDocumentor 1.4.3 217 |

218 |
219 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_Transport_Stream.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_Transport_Stream 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_Transport_Stream

13 | 14 | 15 |
16 |
Description
17 | 23 |
24 |

25 | Implements interfaces: 26 |

28 |

29 | 30 |

This class implements the Ripcord_Transport interface using PHP streams.

31 |

32 | Located in /ripcord_client.php (line 440) 33 |

34 | 35 | 36 |

 37 | 	
 38 | 			
39 |
40 | 41 | 42 | 43 | 44 |
45 |
Variable Summary
46 | 53 |
54 |
55 |
56 | mixed 57 | $responseHeaders 58 |
59 |
60 |
61 |
62 | 63 | 64 |
65 |
Method Summary
66 | 73 |
74 |
75 | 76 |
77 | Ripcord_Transport_Stream 78 | __construct 79 | ([array $contextOptions = null]) 80 |
81 |
82 | string 83 | post 84 | (string $url, string $request) 85 |
86 |
87 |
88 |
89 | 90 | 91 |
92 |
Variables
93 | 102 |
103 | 104 |
105 | 106 |
107 | 108 | mixed 109 | $responseHeaders 110 | = null (line 450) 111 | 112 |
113 | 114 | 115 |

Contains the headers sent by the server.

116 |
    117 |
  • access: public
  • 118 |
119 | 120 | 121 | 122 | 123 | 124 |
125 | 126 |
127 |
128 | 129 | 130 |
131 |
Methods
132 | 138 |
139 | 140 | 141 | 142 |
143 | 144 |
145 | Constructor __construct (line 456) 146 |
147 | 148 | 149 |

This is the constructor for the Ripcord_Transport_Stream class.

150 |
    151 |
  • access: public
  • 152 |
153 | 154 |
155 | Ripcord_Transport_Stream 156 | 157 | __construct 158 | 159 | ([array $contextOptions = null]) 160 |
161 | 162 |
    163 |
  • 164 | array 165 | $contextOptions: Optional. An array with stream context options.
  • 166 |
167 | 168 | 169 |
170 | 171 |
172 | 173 |
174 | post (line 471) 175 |
176 | 177 | 178 |

This method posts the request to the given url.

179 |
    180 |
  • return: The server response
  • 181 |
  • throws: Ripcord_TransportException (ripcord::cannotAccessURL) when the given URL cannot be accessed for any reason.
  • 182 |
  • access: public
  • 183 |
184 | 185 |
186 | string 187 | 188 | post 189 | 190 | (string $url, string $request) 191 |
192 | 193 |
    194 |
  • 195 | string 196 | $url: The url to post to.
  • 197 |
  • 198 | string 199 | $request: The request to post.
  • 200 |
201 | 202 |
203 |
Implementation of:
204 |
205 |
Ripcord_Transport::post()
206 |
This method must post the request to the given url and return the results.
207 |
208 | 209 |
210 | 211 |
212 |
213 | 214 | 215 |

216 | Documentation generated on Tue, 16 Nov 2010 16:20:18 +0100 by phpDocumentor 1.4.3 217 |

218 |
219 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_Client_MultiCall.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_Client_MultiCall 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_Client_MultiCall

13 | 14 | 15 |
16 |
Description
17 | 23 |
24 | 25 |

This class provides the fetch interface for system.multiCall. It is returned

26 |

when calling $client->system->multiCall() with no arguments. Upon construction it puts the originating client into multiCall deferred mode. The client will gather the requested method calls instead of executing them immediately. It will them execute all of them, in order, when calling $client->system->multiCall()->fetch(). This class extends Ripcord_Client only so it has access to its protected _multiCall property.

27 |

28 | Located in /ripcord_client.php (line 313) 29 |

30 | 31 | 32 |
Ripcord_Client
 33 |    |
 34 |    --Ripcord_Client_MultiCall
35 | 36 |
37 |
38 | 39 | 40 | 41 | 42 | 43 |
44 |
Method Summary
45 | 52 |
53 |
54 | 55 |
56 | Ripcord_Client_MultiCall 57 | __construct 58 | ( $client, [ $methodName = 'system.multiCall']) 59 |
60 |
61 | void 62 | execute 63 | () 64 |
65 |
66 | void 67 | start 68 | () 69 |
70 |
71 |
72 |
73 | 74 | 75 |
76 |
Variables
77 | 86 |
87 |

Inherited Variables

88 | 89 |

Inherited from Ripcord_Client

90 |
91 | 92 | Ripcord_Client::$_autoDecode
93 |
94 | 95 | Ripcord_Client::$_multiCall
96 |
97 | 98 | Ripcord_Client::$_multiCallArgs
99 |
100 | 101 | Ripcord_Client::$_request
102 |
103 | 104 | Ripcord_Client::$_response
105 |
106 | 107 | Ripcord_Client::$_throwExceptions
108 |
109 |
110 | 111 |
112 |
113 | 114 | 115 |
116 |
Methods
117 | 123 |
124 | 125 | 126 | 127 |
128 | 129 |
130 | Constructor __construct (line 324) 131 |
132 | 133 | 134 |
    135 |
  • access: public
  • 136 |
137 | 138 |
139 | Ripcord_Client_MultiCall 140 | 141 | __construct 142 | 143 | ( $client, [ $methodName = 'system.multiCall']) 144 |
145 | 146 |
    147 |
  • 148 | 149 | $client
  • 150 |
  • 151 | 152 | $methodName
  • 153 |
154 | 155 |
156 |
Redefinition of:
157 |
158 |
Ripcord_Client::__construct()
159 |
The constructor for the RPC client.
160 |
161 | 162 |
163 | 164 |
165 | 166 |
167 | execute (line 343) 168 |
169 | 170 | 171 |
    172 |
  • access: public
  • 173 |
174 | 175 |
176 | void 177 | 178 | execute 179 | 180 | () 181 |
182 | 183 | 184 | 185 |
186 | 187 |
188 | 189 |
190 | start (line 334) 191 |
192 | 193 | 194 |
    195 |
  • access: public
  • 196 |
197 | 198 |
199 | void 200 | 201 | start 202 | 203 | () 204 |
205 | 206 | 207 | 208 |
209 |

Inherited Methods

210 | 211 | 212 |

Inherited From Ripcord_Client

213 |
214 | Ripcord_Client::__construct()
215 | Ripcord_Client::__call()
216 | Ripcord_Client::__get()
217 |
218 | 219 |
220 |
221 | 222 | 223 |

224 | Documentation generated on Tue, 16 Nov 2010 16:20:18 +0100 by phpDocumentor 1.4.3 225 |

226 |
227 | -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_Client_Call.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_Client_Call 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_Client_Call

13 | 14 | 15 |
16 |
Description
17 | 23 |
24 | 25 |

This class is used with the Ripcord_Client when calling system.multiCall. Instead of immediately calling the method on the rpc server, a Ripcord_Client_Call object is created with all the information needed to call the method using the multicall parameters. The call object is returned immediately and is used as input parameter for the multiCall call. The result of the call can be bound to a php variable. This variable will be filled with the result of the call when it is available.

26 |

27 | Located in /ripcord_client.php (line 361) 28 |

29 | 30 | 31 |

 32 | 	
 33 | 			
34 |
35 | 36 | 37 | 38 | 39 |
40 |
Variable Summary
41 | 48 |
49 |
50 |
51 | mixed 52 | $bound 53 |
54 |
55 | mixed 56 | $index 57 |
58 |
59 | mixed 60 | $method 61 |
62 |
63 | mixed 64 | $params 65 |
66 |
67 |
68 |
69 | 70 | 71 |
72 |
Method Summary
73 | 80 |
81 |
82 | 83 |
84 | Ripcord_Client_Call 85 | __construct 86 | (string $method, array $params) 87 |
88 |
89 | object Returns 90 | bind 91 | ( &$bound, mixed $bound) 92 |
93 |
94 | array 95 | encode 96 | () 97 |
98 |
99 |
100 |
101 | 102 | 103 |
104 |
Variables
105 | 114 |
115 | 116 |
117 | 118 |
119 | 120 | mixed 121 | $bound 122 | = null (line 381) 123 | 124 |
125 | 126 | 127 |

A reference to the php variable to fill with the result of the call, if any.

128 |
    129 |
  • access: public
  • 130 |
131 | 132 | 133 | 134 | 135 | 136 |
137 | 138 |
139 | 140 |
141 | 142 | mixed 143 | $index 144 | = null (line 376) 145 | 146 |
147 | 148 | 149 |

The index in the multicall request array, if any.

150 |
    151 |
  • access: public
  • 152 |
153 | 154 | 155 | 156 | 157 | 158 |
159 | 160 |
161 | 162 |
163 | 164 | mixed 165 | $method 166 | = null (line 366) 167 | 168 |
169 | 170 | 171 |

The method to call on the rpc server

172 |
    173 |
  • access: public
  • 174 |
175 | 176 | 177 | 178 | 179 | 180 |
181 | 182 |
183 | 184 |
185 | 186 | mixed 187 | $params 188 | = array() (line 371) 189 | 190 |
191 | 192 | 193 |

The arguments to pass on to the method.

194 |
    195 |
  • access: public
  • 196 |
197 | 198 | 199 | 200 | 201 | 202 |
203 | 204 |
205 |
206 | 207 | 208 |
209 |
Methods
210 | 216 |
217 | 218 | 219 | 220 |
221 | 222 |
223 | Constructor __construct (line 388) 224 |
225 | 226 | 227 |

The constructor for the Ripcord_Client_Call class.

228 |
    229 |
  • access: public
  • 230 |
231 | 232 |
233 | Ripcord_Client_Call 234 | 235 | __construct 236 | 237 | (string $method, array $params) 238 |
239 | 240 |
    241 |
  • 242 | string 243 | $method: The name of the rpc method to call
  • 244 |
  • 245 | array 246 | $params: The parameters for the rpc method.
  • 247 |
248 | 249 | 250 |
251 | 252 |
253 | 254 |
255 | bind (line 401) 256 |
257 | 258 | 259 |

This method allows you to bind a php variable to the result of this method call.

260 |

When the method call's result is available, the php variable will be filled with this result.

261 |
    262 |
  • return: this object for chaining.
  • 263 |
  • access: public
  • 264 |
265 | 266 |
267 | object Returns 268 | 269 | bind 270 | 271 | ( &$bound, mixed $bound) 272 |
273 | 274 |
    275 |
  • 276 | mixed 277 | $bound: The variable to bind the result from this call to.
  • 278 |
  • 279 | 280 | &$bound
  • 281 |
282 | 283 | 284 |
285 | 286 |
287 | 288 |
289 | encode (line 411) 290 |
291 | 292 | 293 |

This method returns the correct format for a multiCall argument.

294 |
    295 |
  • return: An array with the methodName and params
  • 296 |
  • access: public
  • 297 |
298 | 299 |
300 | array 301 | 302 | encode 303 | 304 | () 305 |
306 | 307 | 308 | 309 |
310 | 311 |
312 |
313 | 314 | 315 |

316 | Documentation generated on Tue, 16 Nov 2010 16:20:18 +0100 by phpDocumentor 1.4.3 317 |

318 |
319 | -------------------------------------------------------------------------------- /ripcord.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright Copyright (C) 2010, Muze 7 | * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License 8 | * @version Ripcord 0.9 - PHP 5 9 | */ 10 | 11 | /** 12 | * The ripcord class contains a number of useful static methods. This makes it a bit easier to create a server or client, convert types 13 | * and check for errors. 14 | * @package Ripcord 15 | */ 16 | class ripcord 17 | { 18 | /** 19 | * This method checks whether the given argument is an XML-RPC fault. 20 | * @param mixed $fault 21 | * @return bool 22 | */ 23 | public static function isFault($fault) 24 | { 25 | if ( isset($fault) && is_array($fault) ) { 26 | return xmlrpc_is_fault($fault); 27 | } else { 28 | return false; 29 | } 30 | } 31 | 32 | /** 33 | * This method generates an XML-RPC fault with the given code and message. 34 | * @param int $code 35 | * @param string $message 36 | * @return array 37 | */ 38 | public static function fault($code, $message) 39 | { 40 | return array('faultCode' => $code, 'faultString' => $message); 41 | } 42 | 43 | /** 44 | * This method returns a new Ripcord server, which by default implements XML-RPC, Simple RPC and SOAP 1.1. 45 | * The server will publish any methods passed through the $services argument. It can be configured through 46 | * the $options argument. 47 | * @param mixed $services Optional. Either an object or an array of objects. If the array has non-numeric keys, the key will be used as a namespace for the methods in the object. 48 | * @param array $options Optional. An array of options to set for the Ripcord server. 49 | * @see Ripcord_Server 50 | */ 51 | public static function server($services = null, $options = null, $documentor = null) 52 | { 53 | self::load('Ripcord_Server'); 54 | if ( !isset($documentor) ) 55 | { 56 | $doc = array('name', 'css', 'wsdl', 'wsdl2'); 57 | $docOptions = array(); 58 | foreach ( $doc as $key ) 59 | { 60 | if ( isset($options[$key]) ) 61 | { 62 | $docOptions[$key] = $options[$key]; 63 | unset( $options[$key] ); 64 | } 65 | } 66 | $docOptions['version'] = $options['version']; 67 | $documentor = self::documentor( $docOptions ); 68 | } 69 | return new Ripcord_Server($services, $options, $documentor); 70 | } 71 | 72 | /** 73 | * This method returns a new Ripcord client. By default this will be an XML-RPC client, but you can change this 74 | * through the $options argument. 75 | * @param string $url The url of the RPC server to connect with 76 | * @param array $options Optional. An array of options to set for the Ripcord client. 77 | * @see Ripcord_Client 78 | */ 79 | public static function client($url, $options = null, $transport = null ) 80 | { 81 | self::load('Ripcord_Client'); 82 | if ( !isset($transport) ) 83 | { 84 | $transport = new Ripcord_Transport_Stream(); 85 | } 86 | return new Ripcord_Client($url, $options, $transport); 87 | } 88 | 89 | /** 90 | * This method returns a new Ripcord documentor object. 91 | * @param array $options Optional. An array of options to set for the Ripcord documentor. 92 | * @param object docCommentParser Optional. An object that parses a docComment block. Must 93 | * implement the Ripcord_Documentor_CommentParser interface. 94 | * @see Ripcord_Client 95 | */ 96 | public static function documentor( $options = null, $docCommentParser = null ) 97 | { 98 | self::load('Ripcord_Documentor'); 99 | if (!$docCommentParser) { 100 | $docCommentParser = new Ripcord_Documentor_Parser_phpdoc(); 101 | } 102 | return new Ripcord_Documentor( $options, $docCommentParser ); 103 | } 104 | 105 | /** 106 | * This method returns an XML-RPC datetime object from a given unix timestamp. 107 | * @param int $timestamp 108 | * @return object 109 | */ 110 | public static function datetime($timestamp) 111 | { 112 | $datetime = date("Ymd\TH:i:s", $timestamp); 113 | xmlrpc_set_type($datetime, 'datetime'); 114 | return $datetime; 115 | } 116 | 117 | /** 118 | * This method returns a unix timestamp from a given XML-RPC datetime object. 119 | * It will throw a 'Variable is not of type datetime' Ripcord_Exception (code -6) 120 | * if the given argument is not of the correct type. 121 | * @param object $datetime 122 | * @return int 123 | */ 124 | public static function timestamp($datetime) 125 | { 126 | if (xmlrpc_get_type($datetime)=='datetime') 127 | { 128 | return $datetime->timestamp; 129 | } else { 130 | throw Ripcord_Exception('Variable is not of type datetime', -6); 131 | } 132 | } 133 | 134 | /** 135 | * This method returns an XML-RPC base64 object from a given binary string. 136 | * @param string $binary 137 | * @return object 138 | */ 139 | public static function base64($binary) 140 | { 141 | xmlrpc_set_type($binary, 'base64'); 142 | return $binary; 143 | } 144 | 145 | /** 146 | * This method returns a (binary) string from a given XML-RPC base64 object. 147 | * It will throw a 'Variable is not of type base64' Ripcord_Exception (code -7) 148 | * if the given argument is not of the correct type. 149 | * @param object $base64 150 | * @return string 151 | */ 152 | public static function binary($base64) 153 | { 154 | if (xmlrpc_get_type($base64)=='base64') 155 | { 156 | return $base64->scalar; 157 | } else { 158 | throw Ripcord_Exception('Variable is not of type base64', -7); 159 | } 160 | } 161 | 162 | /** 163 | * This method returns the type of the given parameter. This can be any of the XML-RPC data types, e.g. 164 | * 'struct', 'int', 'string', 'base64', 'boolean', 'double', 'array' or 'datetime'. 165 | * @param mixed $param 166 | * @return string 167 | */ 168 | public static function getType($param) 169 | { 170 | return xmlrpc_get_type($param); 171 | } 172 | 173 | /** 174 | * This method returns a new Ripcord client, configured to access a SOAP 1.1 server. 175 | * @param string $url 176 | * @param array $options Optional. 177 | * @see Ripcord_Client 178 | */ 179 | public static function soapClient($url, $options = null, $transport = null) 180 | { 181 | $options['version'] = 'soap 1.1'; 182 | return self::client($url, $options, $transport); 183 | } 184 | 185 | /** 186 | * This method returns a new Ripcord client, configured to access an XML-RPC server. 187 | * @param string $url 188 | * @param array $options Optional. 189 | * @return object 190 | * @see Ripcord_Client 191 | */ 192 | public static function xmlrpcClient($url, $options = null, $transport = null) 193 | { 194 | $options['version'] = 'xmlrpc'; 195 | return self::client($url, $options, $transport); 196 | } 197 | 198 | /** 199 | * This method returns a new Ripcord client, configured to access a Simple RPC server. 200 | * @param string $url 201 | * @param array $options Optional. 202 | * @return object 203 | * @see Ripcord_Client 204 | */ 205 | public static function simpleClient($url, $options = null, $transport = null) 206 | { 207 | $options['version'] = 'simple'; 208 | return self::client($url, $options, $transport); 209 | } 210 | 211 | /** 212 | * This method includes a ripcord class, using require_once. Used for autoloading ripcord classes. 213 | * @param string $class The name of the class to load. 214 | * @return boolean 215 | */ 216 | public static function load($class) 217 | { 218 | if (substr($class, 0, 8)=='Ripcord_') 219 | { 220 | $root = dirname(__FILE__).'/ripcord_'; 221 | $class = substr($class, 8); 222 | $file = str_replace('.', '', $class); 223 | $file = str_replace('_', '/', $file); 224 | $file = strtolower($file); 225 | while ($file && $file!='.') 226 | { 227 | if ( file_exists($root.$file.'.php') ) 228 | { 229 | require_once($root.$file.'.php'); 230 | return true; 231 | } else { 232 | $file = dirname($file); 233 | } 234 | } 235 | } 236 | return false; 237 | } 238 | 239 | /** 240 | * This method creates a new Ripcord_Client_Call object, which encodes the information needed for 241 | * a method call to an rpc server. This is mostly used for the system.multiCall method. 242 | * @param string $method The name of the method call to encode 243 | * @param mixed $args,... The remainder of the arguments are encoded as parameters to the call 244 | * @return object 245 | */ 246 | public static function encodeCall() 247 | { 248 | self::load('Ripcord_Client'); 249 | $params = func_get_args(); 250 | $method = array_shift($params); 251 | return new Ripcord_Client_Call( $method, $params ); 252 | } 253 | 254 | /* 255 | * This method binds the first parameter to the output of a Ripcord client call. If 256 | * the second argument is a Ripcord_Client_Call object, it binds the parameter to it, 257 | * if not it simply assigns the second parameter to the first parameter. 258 | * This means that doing: 259 | * > ripcord::bind( $result, $client->someMethod() ) 260 | * will always result in $result eventually containing the return value of $client->someMethod(). 261 | * Whether multiCall mode has been enabled or not. 262 | */ 263 | public function bind(&$bound, $call) 264 | { 265 | if ( is_a( $call, 'Ripcord_Client_Call' ) ) 266 | { 267 | $call->bound =& $bound; 268 | } else { 269 | $bound = $call; 270 | } 271 | return null; 272 | } 273 | 274 | /** 275 | * Method {method} not found. - Thrown by the ripcord server when a requested method isn't found. 276 | */ 277 | const methodNotFound = -1; 278 | /** 279 | * Argument {index} is not a valid Ripcord call - Thrown by the client when passing incorrect arguments to system.multiCall. 280 | */ 281 | const notRipcordCall = -2; 282 | /** 283 | * Cannot recurse system.multiCall - Thrown by the ripcord server when system.multicall is called within itself. 284 | */ 285 | const cannotRecurse = -3; 286 | /** 287 | * Could not access {url} - Thrown by the transport object when unable to access the given url. 288 | */ 289 | const cannotAccessURL = -4; 290 | /** 291 | * PHP XMLRPC library is not installed - Thrown by the ripcord server and client when the xmlrpc library is not installed. 292 | */ 293 | const xmlrpcNotInstalled = -5; 294 | /** 295 | * Variable is not of type datetime - Thrown by the ripcord timestamp method. 296 | */ 297 | const notDatetime = -6; 298 | /** 299 | * Variable is not of type base64 - Thrown by the ripcord binary method. 300 | */ 301 | const notBase64 = -7; 302 | /** 303 | * Variable is not a classname or an object - Thrown by the ripcord server. 304 | */ 305 | const unknownServiceType = -8; 306 | } 307 | 308 | /** 309 | * This interface is implemented by all exceptions thrown by Ripcord. 310 | * @package Ripcord 311 | */ 312 | interface Ripcord_Exception {} 313 | 314 | /** 315 | * This class is used whenever an when a method passed to the server is invalid. 316 | * - ripcord::methodNotFound (-1) Method {method} not found. - Thrown by the ripcord server when a requested method isn't found. 317 | * @package Ripcord 318 | */ 319 | class Ripcord_BadMethodCallException extends BadMethodCallException implements Ripcord_Exception { } 320 | 321 | /** 322 | * This class is used whenever prerequisite requirements are not met. 323 | * - ripcord::xmlrpcNotInstalled (-5) PHP XMLRPC library is not installed - Thrown by the ripcord server and client when the xmlrpc library is not installed. 324 | * @package Ripcord 325 | */ 326 | class Ripcord_ConfigurationException extends Exception implements Ripcord_Exception { } 327 | 328 | /** 329 | * This class is used whenever an argument passed to a Ripcord method is invalid for any reason. Possible exceptions thrown are: 330 | * - ripcord::notRipcordCall (-2) Argument {index} is not a valid Ripcord call - Thrown by the client when passing incorrect arguments to system.multiCall. 331 | * - ripcord::cannotRecurse (-3) Cannot recurse system.multiCall - Thrown by the ripcord server when system.multicall is called within itself. 332 | * - ripcord::notDateTime (-6) Variable is not of type datetime - Thrown by the ripcord timestamp method. 333 | * - ripcord::notBase64 (-7) Variable is not of type base64 - Thrown by the ripcord binary method. 334 | * - ripcord::unknownServiceType (-8) Variable is not a classname or an object - Thrown by the ripcord server. 335 | * @package Ripcord 336 | */ 337 | class Ripcord_InvalidArgumentException extends InvalidArgumentException implements Ripcord_Exception { } 338 | 339 | /** 340 | * This class is used whenever something goes wrong in sending / receiving data. Possible exceptions thrown are: 341 | * - ripcord::cannotAccessURL (-4) Could not access {url} - Thrown by the transport object when unable to access the given url. 342 | * @package Ripcord 343 | */ 344 | class Ripcord_TransportException extends RuntimeException implements Ripcord_Exception { } 345 | 346 | /** 347 | * This class is used for exceptions generated from xmlrpc faults returned by the server. The code and message correspond 348 | * to the code and message from the xmlrpc fault. 349 | * @package Ripcord 350 | */ 351 | class Ripcord_RemoteException extends Exception implements Ripcord_Exception { } 352 | 353 | if (function_exists('spl_autoload_register')) { 354 | spl_autoload_register('ripcord::load'); 355 | } 356 | ?> -------------------------------------------------------------------------------- /ripcord_server.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright Copyright (C) 2010, Muze 7 | * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License 8 | * @version Ripcord 0.9 - PHP 5 9 | */ 10 | 11 | /** 12 | * Includes the static ripcord factory class and exceptions 13 | */ 14 | require_once(dirname(__FILE__).'/ripcord.php'); 15 | 16 | /** 17 | * This class implements the Ripcord server. It is an OO wrapper around PHP's XML-RPC methods, with some added features. 18 | * You can create an XML-RPC (or Simple RPC or a simple SOAP 1.1) server by defining a class with public methods and passing 19 | * an object (or array of objects) of this class to the constructor of Ripcord_Server. Then simply call the run() method. 20 | * 21 | * A basic example: 22 | * 23 | * run(); 27 | * ?> 28 | * 29 | * 30 | * An example with namespaces in the method names and a static class as rpc service. 31 | * 32 | * $myObject, 37 | * 'namespace2' => 'myOtherClass' 38 | * ) 39 | * ); 40 | * $server->run(); 41 | * ?> 42 | * 43 | * 44 | * You don't need to instantiate a class to use it with Ripcord, in the above example 'myOtherClass' is the 45 | * name of a PHP class to use. In addition you may also specify functions or methods directly, in any format 46 | * that matches PHP's is_callable() criteria. 47 | * @package Ripcord 48 | */ 49 | 50 | /* 51 | TODO: 52 | - create seperate interface for encoding / decoding requests 53 | - create xmlrpc-epi class using xmlrpc_encode/decode for xml-rpc, simple-rpc and for now soap 54 | - add json-rpc class (http://json-rpc.org/wiki/specification) 55 | - pass list of protocol parsers/generators in the constructor of the server 56 | - protocol must know how to handle the system.* methods 57 | */ 58 | class Ripcord_Server 59 | { 60 | /** 61 | * Contains a reference to the Ripcord documentor object. 62 | * @see Ripcord_Documentor 63 | */ 64 | private $documentor = null; 65 | 66 | /** 67 | * Contains a reference to the XML-RPC server created with xmlrpc_server_create. 68 | */ 69 | private $xmlrpc = null; 70 | 71 | /** 72 | * Contains a list of methods set for this server. Excludes the system.* methods automatically 73 | * created by PHP's xmlrpc_server_create. 74 | */ 75 | private $methods = array(); 76 | 77 | /** 78 | * Contains an array with outputOptions, used when calling methods on the xmlrpc server created with 79 | * xmlrpc_server_create. These options can be overridden through the $options parameter of the 80 | * Ripcord_Server constructor. 81 | * @see Ripcord_Server::setOutputOption() 82 | */ 83 | private $outputOptions = array( 84 | "output_type" => "xml", 85 | "verbosity" => "pretty", 86 | "escaping" => array("markup"), 87 | "version" => "auto", 88 | "encoding" => "utf-8" 89 | ); 90 | 91 | /** 92 | * Creates a new instance of the Ripcord server. 93 | * @param mixed $services. Optional. An object or array of objects. The public methods in these objects will be exposed 94 | * through the RPC server. If the services array has non-numeric keys, the key for each object will define its namespace. 95 | * @param array $options. Optional. Allows you to override the default server settings. Accepted key names are: 96 | * - 'documentor': allows you to specify an alternative HTML documentor class, or if set to false, no HTML documentor. 97 | * - 'name' : The name of the server, used by the default HTML documentor. 98 | * - 'css' : An url of a css file to link to in the HTML documentation. 99 | * - 'wsdl' : The wsdl 1.0 description of this service (only usefull if you run the 'soap 1.1' version, or the 'auto' version 100 | * - 'wsdl2' : The wsdl 2.0 description of this service 101 | * In addition you can set any of the outputOptions for the xmlrpc server. 102 | * @see Ripcord_Server::setOutputOption() 103 | * @throws Ripcord_InvalidArgumentException (ripcord::unknownServiceType) when passed an incorrect service 104 | * @throws Ripcord_ConfigurationException (ripcord::xmlrpcNotInstalled) when the xmlrpc extension in not available. 105 | */ 106 | function __construct($services = null, $options = null, $documentor = null) 107 | { 108 | if ( !function_exists( 'xmlrpc_server_create' ) ) 109 | { 110 | throw new Ripcord_ConfigurationException('PHP XMLRPC library is not installed', 111 | ripcord::xmlrpcNotInstalled ); 112 | } 113 | libxml_disable_entity_loader(); // prevents XXE attacks 114 | $this->xmlrpc = xmlrpc_server_create(); 115 | if (isset($services)) 116 | { 117 | if (is_array($services)) 118 | { 119 | foreach ($services as $serviceName => $service) 120 | { 121 | $this->addService($service, $serviceName); 122 | } 123 | } else { 124 | $this->addService($services); 125 | } 126 | } 127 | if ( isset($documentor) && is_object($documentor) ) { 128 | $this->documentor = $documentor; 129 | xmlrpc_server_register_introspection_callback( $this->xmlrpc, 130 | array( $this->documentor, 'getIntrospectionXML') ); 131 | } 132 | if ( isset($options) ) 133 | { 134 | $this->outputOptions = array_merge($this->outputOptions, $options); 135 | } 136 | } 137 | 138 | /** 139 | * Allows you to add a service to the server after construction. 140 | * @param object $service The object or class whose public methods must be added to the rpc server. May also be a function or method. 141 | * @param string $serviceName Optional. The namespace for the methods. 142 | * @throws Ripcord_InvalidArgumentException (ripcord::unknownServiceType) when passed an incorrect service 143 | */ 144 | public function addService($service, $serviceName = 0) 145 | { 146 | if ( is_object( $service ) ) 147 | { 148 | $reflection = new ReflectionObject( $service ); 149 | } 150 | else if ( is_string( $service ) && class_exists( $service ) ) 151 | { 152 | $reflection = new ReflectionClass( $service ); 153 | } 154 | else if ( is_callable( $service ) ) // method passed directly 155 | { 156 | $this->addMethod( $serviceName, $service ); 157 | return; 158 | } 159 | else 160 | { 161 | throw new Ripcord_InvalidArgumentException( 'Unknown service type ' . $serviceName, 162 | ripcord::unknownServiceType ); 163 | } 164 | if ( $serviceName && !is_numeric( $serviceName ) ) 165 | { 166 | $serviceName .= '.'; 167 | } 168 | else 169 | { 170 | $serviceName = ''; 171 | } 172 | $methods = $reflection->getMethods(); 173 | if ( is_array( $methods ) ) 174 | { 175 | foreach( $methods as $method ) 176 | { 177 | if ( substr( $method->name, 0, 1 ) != '_' 178 | && !$method->isPrivate() && !$method->isProtected()) 179 | { 180 | $rpcMethodName = $serviceName . $method->name; 181 | $this->addMethod( 182 | $rpcMethodName, 183 | array( $service, $method->name ) 184 | ); 185 | } 186 | } 187 | } 188 | } 189 | 190 | /** 191 | * Allows you to add a single method to the server after construction. 192 | * @param string $name The name of the method as exposed through the rpc server 193 | * @param callback $method The name of the method to call, or an array with classname or object and method name. 194 | */ 195 | public function addMethod($name, $method) 196 | { 197 | $this->methods[$name] = array( 198 | 'name' => $name, 199 | 'call' => $method 200 | ); 201 | xmlrpc_server_register_method( $this->xmlrpc, $name, array( $this, 'call' ) ); 202 | } 203 | 204 | /** 205 | * Runs the rpc server. Automatically handles an incoming request. 206 | */ 207 | public function run() 208 | { 209 | if ($this->documentor) { 210 | $this->documentor->setMethodData( $this->methods ); 211 | } 212 | $request_xml = file_get_contents( 'php://input' ); 213 | if ( !$request_xml ) 214 | { 215 | if ( ( $query = $_SERVER['QUERY_STRING'] ) 216 | && isset($this->wsdl[$query]) && $this->wsdl[$query] ) 217 | { 218 | header('Content-type: text/xml'); 219 | header('Access-Control-Allow-Origin: *'); 220 | $wsdl = $this->wsdl[$query]; 221 | header('Content-Length: '.strlen($wsdl) ); 222 | echo $wsdl; 223 | } 224 | else if ( $this->documentor ) 225 | { 226 | header('Content-type: text/html; charset=' . $this->outputOptions['encoding']); 227 | $this->documentor->handle( $this, $this->methods ); 228 | } 229 | else 230 | { 231 | // FIXME: add check for json-rpc protocol, if set and none of the xml protocols are set, use that 232 | header('Content-type: text/xml'); 233 | header('Access-Control-Allow-Origin: *'); 234 | $result = xmlrpc_encode_request( 235 | null, 236 | ripcord::fault( -1, 'No request xml found.' ), 237 | $this->outputOptions 238 | ); 239 | header('Content-Length: '.strlen( $result ) ); 240 | echo $result; 241 | } 242 | } 243 | else 244 | { 245 | // FIXME: add check for the protocol of the request, could be json-rpc, then check if it is supported. 246 | header('Content-type: text/xml'); 247 | header('Access-Control-Allow-Origin: *'); 248 | $result = $this->handle( $request_xml ); 249 | header('Content-Length: '.strlen($result) ); 250 | echo $result; 251 | } 252 | } 253 | 254 | /** 255 | * This method wraps around xmlrpc_decode_request, since it is borken in many ways. This wraps 256 | * around all the ugliness needed to make it not dump core and not print expat warnings. 257 | */ 258 | private function parseRequest( $request_xml ) { 259 | $xml = @simplexml_load_string($request_xml); 260 | if (!$xml && !$xml->getNamespaces()) { 261 | // FIXME: check for protocol json-rpc 262 | //simplexml in combination with namespaces (soap) lets $xml evaluate to false 263 | return xmlrpc_encode_request( 264 | null, 265 | ripcord::fault( -3, 'Invalid Method Call - Ripcord Server accepts only XML-RPC, SimpleRPC or SOAP 1.1 calls'), 266 | $this->outputOptions 267 | ); 268 | } else { 269 | // prevent segmentation fault on incorrect xmlrpc request (without methodName) 270 | $methodCall = $xml->xpath('//methodCall'); 271 | if ($methodCall) { //xml-rpc 272 | $methodName = $xml->xpath('//methodName'); 273 | if (!$methodName) { 274 | return xmlrpc_encode_request( 275 | null, 276 | ripcord::fault( -3, 'Invalid Method Call - No methodName given'), 277 | $this->outputOptions 278 | ); 279 | } 280 | } 281 | } 282 | $method = null; 283 | ob_start(); // xmlrpc_decode echo expat errors if the xml is not valid, can't stop it. 284 | $params = xmlrpc_decode_request($request_xml, $method); 285 | ob_end_clean(); // clean up any xml errors 286 | return array( 'methodName' => $method, 'params' => $params ); 287 | } 288 | 289 | /** 290 | * This method implements the system.multiCall method without dumping core. The built-in method from the 291 | * xmlrpc library dumps core when you have registered any php methods, fixed in php 5.3.2 292 | */ 293 | private function multiCall( $params = null ) { 294 | if ( $params && is_array( $params ) ) 295 | { 296 | $result = array(); 297 | $params = $params[0]; 298 | foreach ( $params as $param ) { 299 | $method = $param['methodName']; 300 | $args = $param['params']; 301 | try { 302 | // XML-RPC specification says that non-fault results must be in a single item array 303 | $result[] = array( $this->call($method, $args) ); 304 | } catch( Exception $e) { 305 | $result[] = ripcord::fault( $e->getCode(), $e->getMessage() ); 306 | } 307 | } 308 | $result = xmlrpc_encode_request( null, $result, $this->outputOptions ); 309 | } else { 310 | $result = xmlrpc_encode_request( 311 | null, 312 | ripcord::fault( -2, 'Illegal or no params set for system.multiCall'), 313 | $this->outputOptions 314 | ); 315 | } 316 | return $result; 317 | } 318 | 319 | /** 320 | * Handles the given request xml 321 | * @param string $request_xml The incoming request. 322 | * @return string 323 | */ 324 | public function handle($request_xml) 325 | { 326 | $result = $this->parseRequest( $request_xml ); 327 | if (!$result || ripcord::isFault( $result ) ) 328 | { 329 | return $result; 330 | } 331 | else 332 | { 333 | $method = $result['methodName']; 334 | $params = $result['params']; 335 | } 336 | if ( $method == 'system.multiCall' || $method == 'system.multicall' ) { 337 | // php's xml-rpc server (xmlrpc-epi) crashes on multicall, so handle it ourselves... fixed in php 5.3.2 338 | $result = $this->multiCall( $params ); 339 | } else { 340 | try { 341 | $result = xmlrpc_server_call_method( 342 | $this->xmlrpc, $request_xml, null, $this->outputOptions 343 | ); 344 | } catch( Exception $e) { 345 | $result = xmlrpc_encode_request( 346 | null, 347 | ripcord::fault( $e->getCode(), $e->getMessage() ), 348 | $this->outputOptions 349 | ); 350 | } 351 | } 352 | return $result; 353 | } 354 | 355 | /** 356 | * Calls a method by its rpc name. 357 | * @param string $method The rpc name of the method 358 | * @param array $args The arguments to this method 359 | * @return mixed 360 | * @throws Ripcord_InvalidArgumentException (ripcord::cannotRecurse) when passed a recursive multiCall 361 | * @throws Ripcord_BadMethodCallException (ripcord::methodNotFound) when the requested method isn't available. 362 | */ 363 | public function call( $method, $args = null ) 364 | { 365 | if ( isset( $this->methods[$method] ) ) 366 | { 367 | $call = $this->methods[$method]['call']; 368 | return call_user_func_array( $call, $args); 369 | } else { 370 | if ( substr( $method, 0, 7 ) == 'system.' ) 371 | { 372 | if ( $method == 'system.multiCall' ) { 373 | throw new Ripcord_InvalidArgumentException( 374 | 'Cannot recurse system.multiCall', ripcord::cannotRecurse ); 375 | } 376 | // system methods are handled internally by the xmlrpc server, so we've got to create a makebelieve request, 377 | // there is no other way because of a badly designed API 378 | $req = xmlrpc_encode_request( $method, $args, $this->outputOptions ); 379 | $result = xmlrpc_server_call_method( $this->xmlrpc, $req, null, 380 | $this->outputOptions); 381 | return xmlrpc_decode( $result ); 382 | } else { 383 | throw new Ripcord_BadMethodCallException( 'Method '.$method.' not found.', 384 | ripcord::methodNotFound ); 385 | } 386 | } 387 | } 388 | 389 | /** 390 | * Allows you to set specific output options of the server after construction. 391 | * @param string $option The name of the option 392 | * @param mixed $value The value of the option 393 | * The options are: 394 | * - output_type: Return data as either php native data or xml encoded. Can be either 'php' or 'xml'. 'xml' is the default. 395 | * - verbosity: Determines the compactness of generated xml. Can be either 'no_white_space', 'newlines_only' or 'pretty'. 396 | * 'pretty' is the default. 397 | * - escaping: Determines how/whether to escape certain characters. 1 or more values are allowed. If multiple, they need 398 | * to be specified as a sub-array. Options are: 'cdata', 'non-ascii', 'non-print' and 'markup'. Default is 'non-ascii', 399 | * 'non-print' and 'markup'. 400 | * - version: Version of the xml vocabulary to use. Currently, three are supported: 'xmlrpc', 'soap 1.1' and 'simple'. The 401 | * keyword 'auto' is also recognized and tells the server to respond in whichever version the request cam in. 'auto' is 402 | * the default. 403 | * - encoding: The character encoding that the data is in. Can be any supported character encoding. Default is 'utf-8'. 404 | */ 405 | public function setOutputOption($option, $value) 406 | { 407 | if ( isset($this->outputOptions[$option]) ) 408 | { 409 | $this->outputOptions[$option] = $value; 410 | return true; 411 | } else { 412 | return false; 413 | } 414 | } 415 | } 416 | 417 | ?> -------------------------------------------------------------------------------- /ripcord_client.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright Copyright (C) 2010, Muze 7 | * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License 8 | * @version Ripcord 0.9 - PHP 5 9 | */ 10 | 11 | /** 12 | * Includes the static ripcord factory class and exceptions 13 | */ 14 | require_once(dirname(__FILE__).'/ripcord.php'); 15 | 16 | /** 17 | * This class implements a simple RPC client, for XML-RPC, (simplified) SOAP 1.1 or Simple RPC. The client abstracts 18 | * the entire RPC process behind native PHP methods. Any method defined by the rpc server can be called as if it was 19 | * a native method of the rpc client. 20 | * 21 | * E.g. 22 | * 23 | * film->getScore( 'e3dee9d19a8c3af7c92f9067d2945b59', 500 ); 26 | * ?> 27 | * 28 | * 29 | * The client has a simple interface for the system.multiCall method: 30 | * 31 | * system->multiCall()->start(); 34 | * ripcord::bind( $methods, $client->system->listMethods() ); 35 | * ripcord::bind( $foo, $client->getFoo() ); 36 | * $client->system->multiCall()->execute(); 37 | * ?> 38 | * 39 | * 40 | * The soap client can only handle the basic php types and doesn't understand xml namespaces. Use PHP's SoapClient 41 | * for complex soap calls. This client cannot parse wsdl. 42 | * If you want to skip the ripcord::client factory method, you _must_ provide a transport object explicitly. 43 | * 44 | * @link http://wiki.moviemeter.nl/index.php/API Moviemeter API documentation 45 | * @package Ripcord 46 | */ 47 | class Ripcord_Client 48 | { 49 | /** 50 | * The url of the rpc server 51 | */ 52 | private $_url = ''; 53 | 54 | /** 55 | * The transport object, used to post requests. 56 | */ 57 | private $_transport = null; 58 | 59 | /** 60 | * A list of output options, used with the xmlrpc_encode_request method. 61 | * @see Ripcord_Server::setOutputOption() 62 | */ 63 | private $_outputOptions = array( 64 | "output_type" => "xml", 65 | "verbosity" => "pretty", 66 | "escaping" => array("markup"), 67 | "version" => "xmlrpc", 68 | "encoding" => "utf-8" 69 | ); 70 | 71 | /** 72 | * The namespace to use when calling a method. 73 | */ 74 | private $_namespace = null; 75 | 76 | /** 77 | * A reference to the root client object. This is so when you use namespaced sub clients, you can always 78 | * find the _response and _request data in the root client. 79 | */ 80 | private $_rootClient = null; 81 | 82 | /** 83 | * A flag to indicate whether or not to preemptively clone objects passed as arguments to methods, see 84 | * php bug #50282. Only correctly set in the rootClient. 85 | */ 86 | private $_cloneObjects = false; 87 | 88 | /** 89 | * A flag to indicate if we are in a multiCall block. Start this with $client->system->multiCall()->start() 90 | */ 91 | protected $_multiCall = false; 92 | 93 | /** 94 | * A list of deferred encoded calls. 95 | */ 96 | protected $_multiCallArgs = array(); 97 | 98 | /** 99 | * The exact response from the rpc server. For debugging purposes. 100 | */ 101 | public $_response = ''; 102 | 103 | /** 104 | * The exact request from the client. For debugging purposes. 105 | */ 106 | public $_request = ''; 107 | 108 | /** 109 | * Whether or not to throw exceptions when an xml-rpc fault is returned by the server. Default is false. 110 | */ 111 | public $_throwExceptions = false; 112 | 113 | /** 114 | * Whether or not to decode the XML-RPC datetime and base64 types to unix timestamp and binary string 115 | * respectively. 116 | */ 117 | public $_autoDecode = true; 118 | 119 | /** 120 | * The constructor for the RPC client. 121 | * @param string $url The url of the rpc server 122 | * @param array $options Optional. A list of outputOptions. See {@link Ripcord_Server::setOutputOption()} 123 | * @param object $rootClient Optional. Used internally when using namespaces. 124 | * @throws Ripcord_ConfigurationException (ripcord::xmlrpcNotInstalled) when the xmlrpc extension is not available. 125 | */ 126 | public function __construct( $url, array $options = null, $transport = null, $rootClient = null ) 127 | { 128 | if ( !isset($rootClient) ) { 129 | $rootClient = $this; 130 | if ( !function_exists( 'xmlrpc_encode_request' ) ) 131 | { 132 | throw new Ripcord_ConfigurationException('PHP XMLRPC library is not installed', 133 | ripcord::xmlrpcNotInstalled); 134 | } 135 | $version = explode('.', phpversion() ); 136 | if ( (0 + $version[0]) == 5) { 137 | if ( ( 0 + $version[1]) < 2 ) { 138 | $this->_cloneObjects = true; // workaround for bug #50282 139 | } 140 | } 141 | } 142 | $this->_rootClient = $rootClient; 143 | $this->_url = $url; 144 | if ( isset($options) ) 145 | { 146 | if ( isset($options['namespace']) ) 147 | { 148 | $this->_namespace = $options['namespace']; 149 | unset( $options['namespace'] ); 150 | } 151 | $this->_outputOptions = $options; 152 | } 153 | if ( isset($transport) ) { 154 | $this->_transport = $transport; 155 | } 156 | } 157 | 158 | /** 159 | * This method catches any native method called on the client and calls it on the rpc server instead. It automatically 160 | * parses the resulting xml and returns native php type results. 161 | * @throws Ripcord_InvalidArgumentException (ripcord::notRipcordCall) when handling a multiCall and the 162 | * arguments passed do not have the correct method call information 163 | * @throws Ripcord_RemoteException when _throwExceptions is true and the server returns an XML-RPC Fault. 164 | */ 165 | public function __call($name, $args) 166 | { 167 | if ( isset($this->_namespace) ) 168 | { 169 | $name = $this->_namespace . '.' . $name; 170 | } 171 | 172 | if ( $name === 'system.multiCall' || $name == 'system.multicall' ) 173 | { 174 | if ( !$args || ( is_array($args) && count($args)==0 ) ) 175 | { 176 | // multiCall is called without arguments, so return the fetch interface object 177 | return new Ripcord_Client_MultiCall( $this->_rootClient, $name ); 178 | } else if ( is_array( $args ) && (count( $args ) == 1) && 179 | is_array( $args[0] ) && !isset( $args[0]['methodName'] ) ) 180 | { 181 | // multicall is called with a simple array of calls. 182 | $args = $args[0]; 183 | } 184 | $this->_rootClient->_multiCall = false; 185 | $params = array(); 186 | $bound = array(); 187 | foreach ( $args as $key => $arg ) 188 | { 189 | if ( !is_a( $arg, 'Ripcord_Client_Call' ) && 190 | (!is_array($arg) || !isset($arg['methodName']) ) ) 191 | { 192 | throw new Ripcord_InvalidArgumentException( 193 | 'Argument '.$key.' is not a valid Ripcord call', 194 | ripcord::notRipcordCall); 195 | } 196 | if ( is_a( $arg, 'Ripcord_Client_Call' ) ) 197 | { 198 | $arg->index = count( $params ); 199 | $params[] = $arg->encode(); 200 | } 201 | else 202 | { 203 | $arg['index'] = count( $params ); 204 | $params[] = array( 205 | 'methodName' => $arg['methodName'], 206 | 'params' => isset($arg['params']) ? 207 | (array) $arg['params'] : array() 208 | ); 209 | } 210 | $bound[$key] = $arg; 211 | } 212 | $args = array( $params ); 213 | $this->_rootClient->_multiCallArgs = array(); 214 | } 215 | if ( $this->_rootClient->_multiCall ) { 216 | $call = new Ripcord_Client_Call( $name, $args ); 217 | $this->_rootClient->_multiCallArgs[] = $call; 218 | return $call; 219 | } 220 | if ($this->_rootClient->_cloneObjects) { //workaround for php bug 50282 221 | foreach( $args as $key => $arg) { 222 | if (is_object($arg)) { 223 | $args[$key] = clone $arg; 224 | } 225 | } 226 | } 227 | $request = xmlrpc_encode_request( $name, $args, $this->_outputOptions ); 228 | $response = $this->_transport->post( $this->_url, $request ); 229 | $result = xmlrpc_decode( $response, $this->_outputOptions['encoding'] ); 230 | $this->_rootClient->_request = $request; 231 | $this->_rootClient->_response = $response; 232 | if ( ripcord::isFault( $result ) && $this->_throwExceptions ) 233 | { 234 | throw new Ripcord_RemoteException($result['faultString'], $result['faultCode']); 235 | } 236 | if ( isset($bound) && is_array( $bound ) ) 237 | { 238 | foreach ( $bound as $key => $callObject ) 239 | { 240 | if ( is_a( $callObject, 'Ripcord_Client_Call' ) ) 241 | { 242 | $returnValue = $result[$callObject->index]; 243 | } 244 | else 245 | { 246 | $returnValue = $result[$callObject['index']]; 247 | } 248 | if ( is_array( $returnValue ) && count( $returnValue ) == 1 ) 249 | { 250 | // XML-RPC specification says that non-fault results must be in a single item array 251 | $returnValue = current($returnValue); 252 | } 253 | if ($this->_autoDecode) 254 | { 255 | $type = xmlrpc_get_type($returnValue); 256 | switch ($type) 257 | { 258 | case 'base64' : 259 | $returnValue = ripcord::binary($returnValue); 260 | break; 261 | case 'datetime' : 262 | $returnValue = ripcord::timestamp($returnValue); 263 | break; 264 | } 265 | } 266 | if ( is_a( $callObject, 'Ripcord_Client_Call' ) ) { 267 | $callObject->bound = $returnValue; 268 | } 269 | $bound[$key] = $returnValue; 270 | } 271 | $result = $bound; 272 | } 273 | return $result; 274 | } 275 | 276 | /** 277 | * This method catches any reference to properties of the client and uses them as a namespace. The 278 | * property is automatically created as a new instance of the rpc client, with the name of the property 279 | * as a namespace. 280 | * @param string $name The name of the namespace 281 | * @return object A Ripcord Client with the given namespace set. 282 | */ 283 | public function __get($name) 284 | { 285 | $result = null; 286 | if ( !isset($this->{$name}) ) 287 | { 288 | $result = new Ripcord_Client( 289 | $this->_url, 290 | array_merge($this->_outputOptions, array( 291 | 'namespace' => $this->_namespace ? 292 | $this->_namespace . '.' . $name : $name 293 | ) ), 294 | $this->_transport, 295 | $this->_rootClient 296 | ); 297 | $this->{$name} = $result; 298 | } 299 | return $result; 300 | } 301 | } 302 | 303 | /** 304 | * This class provides the fetch interface for system.multiCall. It is returned 305 | * when calling $client->system->multiCall() with no arguments. Upon construction 306 | * it puts the originating client into multiCall deferred mode. The client will 307 | * gather the requested method calls instead of executing them immediately. It 308 | * will them execute all of them, in order, when calling 309 | * $client->system->multiCall()->fetch(). 310 | * This class extends Ripcord_Client only so it has access to its protected _multiCall 311 | * property. 312 | */ 313 | class Ripcord_Client_MultiCall extends Ripcord_Client 314 | { 315 | 316 | /* 317 | * The reference to the originating client to put into multiCall mode. 318 | */ 319 | private $client = null; 320 | 321 | /* 322 | * This method creates a new multiCall fetch api object. 323 | */ 324 | public function __construct( $client, $methodName = 'system.multiCall' ) 325 | { 326 | $this->client = $client; 327 | $this->methodName = $methodName; 328 | } 329 | 330 | /* 331 | * This method puts the client into multiCall mode. While in this mode all 332 | * method calls are collected as deferred calls (Ripcord_Client_Call). 333 | */ 334 | public function start() 335 | { 336 | $this->client->_multiCall = true; 337 | } 338 | 339 | /* 340 | * This method finally calls the clients multiCall method with all deferred 341 | * method calls since multiCall mode was enabled. 342 | */ 343 | public function execute() 344 | { 345 | if ($this->methodName=='system.multiCall') { 346 | return $this->client->system->multiCall( $this->client->_multiCallArgs ); 347 | } else { // system.multicall 348 | return $this->client->system->multicall( $this->client->_multiCallArgs ); 349 | } 350 | } 351 | 352 | } 353 | 354 | /** 355 | * This class is used with the Ripcord_Client when calling system.multiCall. Instead of immediately calling the method on the rpc server, 356 | * a Ripcord_Client_Call object is created with all the information needed to call the method using the multicall parameters. The call object is 357 | * returned immediately and is used as input parameter for the multiCall call. The result of the call can be bound to a php variable. This 358 | * variable will be filled with the result of the call when it is available. 359 | * @package Ripcord 360 | */ 361 | class Ripcord_Client_Call 362 | { 363 | /** 364 | * The method to call on the rpc server 365 | */ 366 | public $method = null; 367 | 368 | /** 369 | * The arguments to pass on to the method. 370 | */ 371 | public $params = array(); 372 | 373 | /** 374 | * The index in the multicall request array, if any. 375 | */ 376 | public $index = null; 377 | 378 | /** 379 | * A reference to the php variable to fill with the result of the call, if any. 380 | */ 381 | public $bound = null; 382 | 383 | /** 384 | * The constructor for the Ripcord_Client_Call class. 385 | * @param string $method The name of the rpc method to call 386 | * @param array $params The parameters for the rpc method. 387 | */ 388 | public function __construct($method, $params) 389 | { 390 | $this->method = $method; 391 | $this->params = $params; 392 | } 393 | 394 | /** 395 | * This method allows you to bind a php variable to the result of this method call. 396 | * When the method call's result is available, the php variable will be filled with 397 | * this result. 398 | * @param mixed $bound The variable to bind the result from this call to. 399 | * @return object Returns this object for chaining. 400 | */ 401 | public function bind(&$bound) 402 | { 403 | $this->bound =& $bound; 404 | return $this; 405 | } 406 | 407 | /** 408 | * This method returns the correct format for a multiCall argument. 409 | * @return array An array with the methodName and params 410 | */ 411 | public function encode() { 412 | return array( 413 | 'methodName' => $this->method, 414 | 'params' => (array) $this->params 415 | ); 416 | } 417 | 418 | } 419 | 420 | /** 421 | * This interface describes the minimum interface needed for the transport object used by the 422 | * Ripcord_Client 423 | * @package Ripcord 424 | */ 425 | interface Ripcord_Transport 426 | { 427 | /** 428 | * This method must post the request to the given url and return the results. 429 | * @param string $url The url to post to. 430 | * @param string $request The request to post. 431 | * @return string The server response 432 | */ 433 | public function post( $url, $request ); 434 | } 435 | 436 | /** 437 | * This class implements the Ripcord_Transport interface using PHP streams. 438 | * @package Ripcord 439 | */ 440 | class Ripcord_Transport_Stream implements Ripcord_Transport 441 | { 442 | /** 443 | * A list of stream context options. 444 | */ 445 | private $options = array(); 446 | 447 | /** 448 | * Contains the headers sent by the server. 449 | */ 450 | public $responseHeaders = null; 451 | 452 | /** 453 | * This is the constructor for the Ripcord_Transport_Stream class. 454 | * @param array $contextOptions Optional. An array with stream context options. 455 | */ 456 | public function __construct( $contextOptions = null ) 457 | { 458 | if ( isset($contextOptions) ) 459 | { 460 | $this->options = $contextOptions; 461 | } 462 | } 463 | 464 | /** 465 | * This method posts the request to the given url. 466 | * @param string $url The url to post to. 467 | * @param string $request The request to post. 468 | * @return string The server response 469 | * @throws Ripcord_TransportException (ripcord::cannotAccessURL) when the given URL cannot be accessed for any reason. 470 | */ 471 | public function post( $url, $request ) 472 | { 473 | $options = array_merge( 474 | $this->options, 475 | array( 476 | 'http' => array( 477 | 'method' => "POST", 478 | 'header' => "Content-Type: text/xml", 479 | 'content' => $request 480 | ) 481 | ) 482 | ); 483 | $context = stream_context_create( $options ); 484 | $result = @file_get_contents( $url, false, $context ); 485 | $this->responseHeaders = $http_response_header; 486 | if ( !$result ) 487 | { 488 | throw new Ripcord_TransportException( 'Could not access ' . $url, 489 | ripcord::cannotAccessURL ); 490 | } 491 | return $result; 492 | } 493 | } 494 | 495 | /** 496 | * This class implements the Ripcord_Transport interface using CURL. 497 | * @package Ripcord 498 | */ 499 | class Ripcord_Transport_CURL implements Ripcord_Transport 500 | { 501 | /** 502 | * A list of CURL options. 503 | */ 504 | private $options = array(); 505 | 506 | /** 507 | * A flag that indicates whether or not we can safely pass the previous exception to a new exception. 508 | */ 509 | private $skipPreviousException = false; 510 | 511 | /** 512 | * Contains the headers sent by the server. 513 | */ 514 | public $responseHeaders = null; 515 | 516 | /** 517 | * This is the constructor for the Ripcord_Transport_CURL class. 518 | * @param array $curlOptions A list of CURL options. 519 | */ 520 | public function __construct( $curlOptions = null ) 521 | { 522 | if ( isset($curlOptions) ) 523 | { 524 | $this->options = $curlOptions; 525 | } 526 | $version = explode('.', phpversion() ); 527 | if ( ( (0 + $version[0]) == 5) && ( 0 + $version[1]) < 3 ) { // previousException supported in php >= 5.3 528 | $this->_skipPreviousException = true; 529 | } 530 | } 531 | 532 | /** 533 | * This method posts the request to the given url 534 | * @param string $url The url to post to. 535 | * @param string $request The request to post. 536 | * @throws Ripcord_TransportException (ripcord::cannotAccessURL) when the given URL cannot be accessed for any reason. 537 | * @return string The server response 538 | */ 539 | public function post( $url, $request) 540 | { 541 | $curl = curl_init(); 542 | $options = (array) $this->options + array( 543 | CURLOPT_RETURNTRANSFER => 1, 544 | CURLOPT_URL => $url, 545 | CURLOPT_POST => true, 546 | CURLOPT_POSTFIELDS => $request, 547 | CURLOPT_HEADER => true 548 | ); 549 | curl_setopt_array( $curl, $options ); 550 | $contents = curl_exec( $curl ); 551 | $headerSize = curl_getinfo( $curl, CURLINFO_HEADER_SIZE ); 552 | $this->responseHeaders = substr( $contents, 0, $headerSize ); 553 | $contents = substr( $contents, $headerSize ); 554 | 555 | if ( curl_errno( $curl ) ) 556 | { 557 | $errorNumber = curl_errno( $curl ); 558 | $errorMessage = curl_error( $curl ); 559 | curl_close( $curl ); 560 | $version = explode('.', phpversion() ); 561 | if (!$this->_skipPreviousException) { // previousException supported in php >= 5.3 562 | $exception = new Ripcord_TransportException( 'Could not access ' . $url 563 | , ripcord::cannotAccessURL 564 | , new Exception( $errorMessage, $errorNumber ) 565 | ); 566 | } else { 567 | $exception = new Ripcord_TransportException( 'Could not access ' . $url 568 | . ' ( original CURL error: ' . $errorMessage . ' ) ', 569 | ripcord::cannotAccessURL 570 | ); 571 | } 572 | throw $exception; 573 | } 574 | curl_close($curl); 575 | return $contents; 576 | } 577 | } 578 | 579 | ?> -------------------------------------------------------------------------------- /ripcord_documentor.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright Copyright (C) 2010, Muze 7 | * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License 8 | * @version Ripcord 0.9 - PHP 5 9 | */ 10 | 11 | /** 12 | * This interface defines the minimum methods any documentor needs to implement. 13 | * @package Ripcord 14 | */ 15 | interface Ripcord_Documentor_Interface 16 | { 17 | public function setMethodData( $methods ); 18 | public function handle( $rpcServer ); 19 | public function getIntrospectionXML(); 20 | } 21 | 22 | /** 23 | * This class implements the default documentor for the ripcord server. Any request to the server 24 | * without a request_xml is handled by the documentor. 25 | * @package Ripcord 26 | */ 27 | class Ripcord_Documentor implements Ripcord_Documentor_Interface 28 | { 29 | /** 30 | * The object to parse the docComments. 31 | */ 32 | private $docCommentParser = null; 33 | 34 | /** 35 | * The name of the rpc server, used as the title and heading of the default HTML page. 36 | */ 37 | public $name = 'Ripcord: Simple RPC Server'; 38 | 39 | /** 40 | * A url to an optional css file or a css string for an inline stylesheet. 41 | */ 42 | public $css = " 43 | html { 44 | font-family: georgia, times, serif; 45 | font-size: 79%; 46 | background-color: #EEEEEE; 47 | } 48 | h1 { 49 | font-family: 'arial black', helvetica, sans-serif; 50 | font-size: 2em; 51 | font-weight: normal; 52 | margin: -20px -21px 0.4em -20px; 53 | padding: 40px 20px 20px; 54 | background: #01648E; /* for non-css3 browsers */ 55 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00486E', endColorstr='#09799E'); /* for IE */ 56 | background: -webkit-gradient(linear, left top, left bottom, from(#00486E), to(#09799E)); /* for webkit browsers */ 57 | background: -moz-linear-gradient(top, #00486E, #09799E); /* for firefox 3.6+ */ 58 | color: white; 59 | border-bottom: 4px solid black; 60 | text-shadow: black 0.1em 0.1em 0.2em; 61 | } 62 | h2 { 63 | font-family: arial, helvetica, sans-serif; 64 | font-weight: bold; 65 | font-size: 1.4em; 66 | color: #444444; 67 | text-shadow: #AAAAAA 0.1em 0.1em 0.2em; 68 | margin-top: 2.5em; 69 | border-bottom: 1px solid #09799E; 70 | } 71 | h3 { 72 | font-family: arial, helvetica, sans-serif; 73 | font-weight: normal; 74 | font-size: 1.4em; 75 | color: #555555; 76 | text-shadow: #AAAAAA 0.1em 0.1em 0.2em; 77 | margin-bottom: 0px; 78 | } 79 | div.signature { 80 | font-family: courier, monospace; 81 | margin-bottom: 1.4em; 82 | } 83 | ul, ol, li { 84 | margin: 0px; 85 | padding: 0px; 86 | } 87 | ul, ol { 88 | color: #09799E; 89 | margin-bottom: 1.4em; 90 | } 91 | ul li { 92 | list-style: square; 93 | } 94 | ul li, ol li { 95 | margin-left: 20px; 96 | } 97 | li span, li label { 98 | color: black; 99 | } 100 | li.param label { 101 | font-family: courier, monospace; 102 | padding-right: 1.4em; 103 | } 104 | a { 105 | text-decoration: none; 106 | } 107 | a:hover { 108 | text-decoration: underline; 109 | } 110 | body { 111 | background-color: white; 112 | width: 830px; 113 | margin: 10px auto; 114 | padding: 20px; 115 | -moz-box-shadow: 5px 5px 5px #ccc; 116 | -webkit-box-shadow: 5px 5px 5px #ccc; 117 | box-shadow: 5px 5px 5px #ccc; 118 | } 119 | code { 120 | display: block; 121 | background-color: #999999; 122 | padding: 10px; 123 | margin: 0.4em 0px 1.4em 0px; 124 | color: white; 125 | white-space: pre; 126 | font-family: courier, monospace; 127 | font-size: 1.2em; 128 | } 129 | .tag, .argName, .argType { 130 | margin-right: 10px; 131 | } 132 | .argument { 133 | margin-left: 20px; 134 | } 135 | .footer { 136 | font-family: helvetica, sans-serif; 137 | font-size: 0.9em; 138 | font-weight: normal; 139 | margin: 0px -21px -20px -20px; 140 | padding: 20px; 141 | background: #01648E; /* for non-css3 browsers */ 142 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00486E', endColorstr='#09799E'); /* for IE */ 143 | background: -webkit-gradient(linear, left top, left bottom, from(#00486E), to(#09799E)); /* for webkit browsers */ 144 | background: -moz-linear-gradient(top, #00486E, #09799E); /* for firefox 3.6+ */ 145 | color: white; 146 | } 147 | .footer a { 148 | color: white; 149 | text-decoration: none; 150 | } 151 | "; 152 | 153 | /** 154 | * The wsdl 1.0 description. 155 | */ 156 | public $wsdl = false; 157 | 158 | /** 159 | * The wsdl 2.0 description 160 | */ 161 | public $wsdl2 = false; 162 | 163 | /** 164 | * Which version of the XML vocabulary the server implements. Either 'xmlrpc', 'soap 1.1', 'simple' or 'auto'. 165 | */ 166 | public $version = 'auto'; 167 | 168 | /** 169 | * The root URL of the rpc server. 170 | */ 171 | public $root = ''; 172 | 173 | /** 174 | * Optional header text for the online documentation. 175 | */ 176 | public $header = ''; 177 | 178 | /** 179 | * Optional footer text for the online documentation. 180 | */ 181 | public $footer = ''; 182 | 183 | /** 184 | * A list of method data, containing all the user supplied methods the rpc server implements. 185 | */ 186 | private $methods = null; 187 | 188 | /** 189 | * The constructor for the Ripcord_Documentor class. 190 | * @param array $options. Optional. Allows you to set the public properties of this class upon construction. 191 | */ 192 | public function __construct( $options = null, $docCommentParser = null ) 193 | { 194 | $check = array( 'name', 'css', 'wsdl', 'wsdl2', 'root', 'version', 'header', 'footer' ); 195 | foreach ( $check as $name ) 196 | { 197 | if ( isset($options[$name]) ) 198 | { 199 | $this->{$name} = $options[$name]; 200 | } 201 | } 202 | $this->docCommentParser = $docCommentParser; 203 | } 204 | 205 | /** 206 | * This method fills the list of method data with all the user supplied methods of the rpc server. 207 | * @param array $methodData A list of methods with name and callback information. 208 | */ 209 | public function setMethodData( $methodData ) 210 | { 211 | $this->methods = $methodData; 212 | } 213 | 214 | /** 215 | * This method handles any request which isn't a valid rpc request. 216 | * @param object $rpcServer A reference to the active rpc server. 217 | */ 218 | public function handle( $rpcServer ) 219 | { 220 | $methods = $rpcServer->call('system.listMethods'); 221 | echo ''; 222 | echo '' . $this->name . ''; 223 | if ( isset($this->css) ) 224 | { 225 | if (strpos($this->css, "\n")!==false) { 226 | echo ''; 227 | } else { 228 | echo ''; 229 | } 230 | } 231 | echo ''; 232 | echo '
'; 233 | echo '

' . $this->name . '

'; 234 | echo $this->header; 235 | echo '

'; 236 | $showWSDL = false; 237 | switch ( $this->version ) 238 | { 239 | case 'xmlrpc': 240 | echo 'This server implements the XML-RPC specification'; 241 | break; 242 | case 'simple': 243 | echo 'This server implements the SimpleRPC 1.0 specification'; 244 | break; 245 | case 'auto'; 246 | echo 'This server implements the SOAP 1.1, XML-RPC and SimpleRPC 1.0 specification.'; 247 | $showWSDL = true; 248 | break; 249 | case 'soap 1.1': 250 | echo 'This server implements the SOAP 1.1 specification.'; 251 | $showWSDL = true; 252 | break; 253 | } 254 | echo '

'; 255 | if ( $showWSDL && ( $this->wsdl || $this->wsdl2 ) ) 256 | { 257 | echo ''; 267 | } 268 | 269 | $methods = $rpcServer->call( 'system.describeMethods' ); 270 | $allMethods = array(); 271 | $allFunctions = array(); 272 | foreach( $methods['methodList'] as $index => $method ) 273 | { 274 | if ( strpos( $method['name'], '.' ) !== false ) 275 | { 276 | $allMethods[ $method['name'] ] = $index; 277 | } else { 278 | $allFunctions[ $method['name'] ] = $index; 279 | } 280 | } 281 | ksort( $allMethods ); 282 | ksort( $allFunctions ); 283 | $allMethods = $allFunctions + $allMethods; 284 | 285 | echo '

Methods

    '; 286 | foreach ( $allMethods as $methodName => $methodIndex ) 287 | { 288 | echo '
  • ' . $methodName . '
  • '; 289 | } 290 | echo '
'; 291 | 292 | $currentClass = ''; 293 | $class = ''; 294 | echo '
'; 295 | foreach ( $allMethods as $methodName => $methodIndex ) 296 | { 297 | $method = $methods['methodList'][$methodIndex]; 298 | $pos = strpos( $methodName, '.'); 299 | if ( $pos !== false ) 300 | { 301 | $class = substr( $methodName, 0, $pos ); 302 | } 303 | if ( $currentClass != $class ) 304 | { 305 | echo '
'; 306 | echo '
'; 307 | $currentClass = $class; 308 | } 309 | echo '

' . $method['name'] . '

'; 310 | if ( isset( $method['signatures'] ) ) 311 | { 312 | 313 | foreach ( $method['signatures'] as $signature ) 314 | { 315 | echo '
'; 316 | if ( is_array( $signature['returns'] ) ) { 317 | $return = $signature['returns'][0]; 318 | echo '(' . $return['type'] . ') '; 319 | } 320 | echo $method['name'] . '('; 321 | $paramInfo = false; 322 | if ( is_array( $signature['params'] ) ) 323 | { 324 | $paramInfo = $signature['params']; 325 | $params = ''; 326 | foreach ( $signature['params'] as $param ) 327 | { 328 | $params .= ', (' . $param['type'] . ') ' . $param['name'] . ' '; 329 | } 330 | echo substr($params, 1); 331 | } 332 | echo ')
'; 333 | if ( is_array( $paramInfo ) ) 334 | { 335 | echo '

Parameters

    '; 336 | foreach ( $paramInfo as $param ) 337 | { 338 | echo '
  • '; 339 | echo ' '; 340 | echo '' . $param['description'] . ''; 341 | echo '
  • '; 342 | } 343 | echo '
'; 344 | } 345 | } 346 | 347 | } 348 | 349 | if ( $method['purpose'] ) 350 | { 351 | echo '
' . $method['purpose'] . '
'; 352 | } 353 | 354 | if ( isset( $method['notes'] ) && is_array( $method['notes'] ) ) 355 | { 356 | echo '

Notes

    '; 357 | foreach ( $method['notes'] as $note ) 358 | { 359 | echo '
  1. ' . $note. '
  2. '; 360 | } 361 | echo '
'; 362 | } 363 | 364 | if ( isset( $method['see'] ) && is_array( $method['see'] ) ) 365 | { 366 | echo '
'; 367 | echo '

See

'; 368 | echo '
    '; 369 | foreach ( $method['see'] as $link => $description) 370 | { 371 | echo '
  • '; 372 | if ( isset( $allMethods[$link] ) ) 373 | { 374 | echo '' . $link . ' ' . $description . ''; 375 | } else { 376 | echo '' . $link . ' ' . $description . ''; 377 | } 378 | echo '
  • '; 379 | } 380 | echo '
'; 381 | } 382 | 383 | } 384 | echo '
'; 385 | echo $this->footer; 386 | echo ''; 389 | echo '
'; 390 | } 391 | 392 | /** 393 | * This method returns an XML document in the introspection format expected by 394 | * xmlrpc_server_register_introspection_callback. It uses the php Reflection 395 | * classes to gather information from the registered methods. 396 | * Descriptions are added from phpdoc docblocks if found. 397 | * @return string XML string with the introspection data. 398 | */ 399 | function getIntrospectionXML() 400 | { 401 | $xml = ""; 402 | if ( isset($this->methods) && is_array( $this->methods ) ) 403 | { 404 | foreach ($this->methods as $method => $methodData ) 405 | { 406 | if ( is_array( $methodData['call'] ) ) 407 | { 408 | $reflection = new ReflectionMethod( 409 | $methodData['call'][0], 410 | $methodData['call'][1] 411 | ); 412 | } 413 | else 414 | { 415 | $reflection = new ReflectionFunction( $methodData['call'] ); 416 | } 417 | $description = $reflection->getDocComment(); 418 | if ( $description && $this->docCommentParser ) 419 | { 420 | $data = $this->docCommentParser->parse( $description ); 421 | if ($data['description']) 422 | { 423 | $description = $data['description']; 424 | } 425 | } 426 | if ($description) 427 | { 428 | $description = '

' . str_replace( array( "\r\n\r\n", "\n\n") , '

', $description) 429 | . '

'; 430 | } 431 | if ( is_array( $data ) ) 432 | { 433 | foreach( $data as $key => $value ) 434 | { 435 | switch( $key ) 436 | { 437 | case 'category' : 438 | case 'deprecated' : 439 | case 'package' : 440 | $description .= '
' 441 | . $key . '' . $value .'
'; 442 | break; 443 | 444 | default : 445 | break; 446 | } 447 | } 448 | } 449 | $xml .= ''; 451 | if ( is_array( $data ) && ( isset( $data['arguments'] ) || isset( $data['return'] ) ) ) 452 | { 453 | $xml .= ''; 454 | if ( isset( $data['arguments'] ) && is_array($data['arguments']) ) 455 | { 456 | $xml .= ''; 457 | foreach ( $data['arguments'] as $name => $argument ) 458 | { 459 | if ( $name[0] == '$' ) 460 | { 461 | $name = substr( $name, 1 ); 462 | } 463 | $xml .= ''; 466 | } 467 | $xml .= ''; 468 | } 469 | if ( isset( $data['return'] ) && is_array( $data['return'] ) ) 470 | { 471 | $xml .= ''; 473 | } 474 | $xml .= ''; 475 | } 476 | $xml .= ''; 477 | } 478 | } 479 | $xml .= "
"; 480 | return $xml; 481 | } 482 | } 483 | 484 | /** 485 | * This interface describes the minimum interface needed for a comment parser object used by the 486 | * Ripcord_Documentor 487 | * @package Ripcord 488 | */ 489 | interface Ripcord_Documentor_Parser 490 | { 491 | /** 492 | * This method parses a given docComment block and returns an array with information. 493 | * @param string $commentBlock The docComment block. 494 | * @return array The parsed information. 495 | */ 496 | public function parse( $commentBlock ); 497 | } 498 | 499 | /** 500 | * This class implements the Ripcord_Documentor_Parser interface, parsing the docComment 501 | * as a phpdoc style docComment. 502 | * @package Ripcord 503 | */ 504 | class Ripcord_Documentor_Parser_phpdoc implements Ripcord_Documentor_Parser 505 | { 506 | 507 | /** 508 | * This method parses a given docComment block and returns an array with information. 509 | * @param string $commentBlock The docComment block. 510 | * @return array The parsed information. 511 | */ 512 | public function parse( $commentBlock) 513 | { 514 | $this->currentTag = 'description'; 515 | $description = preg_replace('/^(\s*(\/\*\*|\*\/|\*))/m', '', $commentBlock); 516 | $info = array(); 517 | $lines = explode( "\n", $description ); 518 | foreach ( $lines as $line ) { 519 | $info = $this->parseLine( $line, $info ); 520 | } 521 | return $info; //array( 'description' => $description ); 522 | } 523 | 524 | /** 525 | * This method parses a single line from the comment block. 526 | */ 527 | private function parseLine( $line, $info ) 528 | { 529 | $handled = false; 530 | if (preg_match('/^\s*(@[a-z]+)\s(.*)$/i', $line, $matches)) 531 | { 532 | $this->currentTag = substr($matches[1], 1); 533 | $line = trim( substr($line, strlen($this->currentTag)+2 ) ); 534 | switch( $this->currentTag ) 535 | { 536 | case 'param' : 537 | if ( preg_match('/^\s*([[:alpha:]|]+)\s([[:alnum:]$_]+)(.*)$/i', $line, $matches) ) 538 | { 539 | if ( !isset($info['arguments']) ) { 540 | $info['arguments'] = array(); 541 | } 542 | if ( !isset($info['arguments'][$matches[2]]) ) { 543 | $info['arguments'][$matches[2]] = array('description' => ''); 544 | } 545 | $info['arguments'][$matches[2]]['type'] = $matches[1]; 546 | $info['arguments'][$matches[2]]['description'] .= $this->parseDescription($matches[3]); 547 | } 548 | $handled = true; 549 | break; 550 | case 'return' : 551 | if ( preg_match('/^\s*([[:alpha:]|]+)\s(.*)$/i', $line, $matches) ) 552 | { 553 | if ( !isset($info['return']) ) { 554 | $info['return'] = array( 'description' => '' ); 555 | } 556 | $info['return']['type'] = $matches[1]; 557 | $info['return']['description'] .= $this->parseDescription($matches[2]); 558 | } 559 | $handled = true; 560 | break; 561 | } 562 | } 563 | if (!$handled) { 564 | switch( $this->currentTag) { 565 | case 'param' : 566 | case 'return' : 567 | if ( !isset( $info[$this->currentTag] ) ) { 568 | $info[$this->currentTag] = array(); 569 | } 570 | $info[$this->currentTag]['description'] .= $this->parseDescription($line); 571 | break; 572 | default: 573 | if ( !isset( $info[$this->currentTag] ) ) { 574 | $info[$this->currentTag] = ''; 575 | } 576 | $info[$this->currentTag] .= $this->parseDescription($line); 577 | break; 578 | } 579 | } 580 | return $info; 581 | } 582 | 583 | /** 584 | * This method parses only the text description part of a line of the comment block. 585 | */ 586 | private function parseDescription( $line ) { 587 | while ( preg_match('/{@([^}]*)}/', $line, $matches) ) { 588 | switch( $matches[1] ) { 589 | case 'internal' : 590 | $line = str_replace( $matches[0], '', $line ); 591 | break; 592 | default : 593 | $line = str_replace( $matches[0], $matches[1], $line ); 594 | break; 595 | } 596 | } 597 | $line = str_replace( array( '\@', '{@*}' ), array( '@', '*/' ), $line ); 598 | return $line; 599 | } 600 | } 601 | 602 | ?> -------------------------------------------------------------------------------- /docs/Ripcord/Ripcord_Server.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Docs For Class Ripcord_Server 7 | 8 | 9 | 10 | 11 |
12 |

Class Ripcord_Server

13 | 14 | 15 |
16 |
Description
17 | 22 |
23 | 24 |

This class implements the Ripcord server. It is an OO wrapper around PHP's XML-RPC methods, with some added features.

25 |

You can create an XML-RPC (or Simple RPC or a simple SOAP 1.1) server by defining a class with public methods and passing an object (or array of objects) of this class to the constructor of Ripcord_Server. Then simply call the run() method.

A basic example:

  1.  <?php
  2. 26 |
  3.    $myObject new MyClass();
  4. 27 |
  5.    $server ripcord::server$myObject );
  6. 28 |
  7.    $server->run();
  8. 29 |
  9.  ?>
  10. 30 |

An example with namespaces in the method names and a static class as rpc service.

  1.  <?php
  2. 31 |
  3.    $myObject new MyClass();
  4. 32 |
  5.    $server ripcord::server(
  6. 33 |
  7.      array(
  8. 34 |
  9.        'namespace1' => $myObject,
  10. 35 |
  11.        'namespace2' => 'myOtherClass'
  12. 36 |
  13.      )
  14. 37 |
  15.    );
  16. 38 |
  17.    $server->run();
  18. 39 |
  19.  ?>
  20. 40 |

You don't need to instantiate a class to use it with Ripcord, in the above example 'myOtherClass' is the name of a PHP class to use. In addition you may also specify functions or methods directly, in any format that matches PHP's is_callable() criteria.

41 |

42 | Located in /ripcord_server.php (line 49) 43 |

44 | 45 | 46 |

 47 | 	
 48 | 			
49 |
50 | 51 | 52 | 53 | 54 | 55 |
56 |
Method Summary
57 | 61 |
62 |
63 | 64 |
65 | Ripcord_Server 66 | __construct 67 | ([ $services = null], [ $options = null], [ $documentor = null], mixed $services., array $options.) 68 |
69 |
70 | void 71 | addMethod 72 | (string $name, callback $method) 73 |
74 |
75 | void 76 | addService 77 | (object $service, [string $serviceName = 0]) 78 |
79 |
80 | mixed 81 | call 82 | (string $method, [array $args = null]) 83 |
84 |
85 | string 86 | handle 87 | (string $request_xml) 88 |
89 |
90 | void 91 | run 92 | () 93 |
94 |
95 | void 96 | setOutputOption 97 | (string $option, mixed $value) 98 |
99 |
100 |
101 |
102 | 103 | 104 | 105 |
106 |
Methods
107 | 112 |
113 | 114 | 115 | 116 |
117 | 118 |
119 | Constructor __construct (line 97) 120 |
121 | 122 | 123 |

Creates a new instance of the Ripcord server.

124 |
    125 |
  • see: Ripcord_Server::setOutputOption()
  • 126 |
  • throws: Ripcord_InvalidArgumentException (ripcord::unknownServiceType) when passed an incorrect service
  • 127 |
  • throws: Ripcord_ConfigurationException (ripcord::xmlrpcNotInstalled) when the xmlrpc extension in not available.
  • 128 |
129 | 130 |
131 | Ripcord_Server 132 | 133 | __construct 134 | 135 | ([ $services = null], [ $options = null], [ $documentor = null], mixed $services., array $options.) 136 |
137 | 138 |
    139 |
  • 140 | mixed 141 | $services.: Optional. An object or array of objects. The public methods in these objects will be exposed through the RPC server. If the services array has non-numeric keys, the key for each object will define its namespace.
  • 142 |
  • 143 | array 144 | $options.: Optional. Allows you to override the default server settings. Accepted key names are:
    • 'documentor': allows you to specify an alternative HTML documentor class, or if set to false, no HTML documentor.
    • 'name' : The name of the server, used by the default HTML documentor.
    • 'css' : An url of a css file to link to in the HTML documentation.
    • 'wsdl' : The wsdl 1.0 description of this service (only usefull if you run the 'soap 1.1' version, or the 'auto' version
    • 'wsdl2' : The wsdl 2.0 description of this service
    In addition you can set any of the outputOptions for the xmlrpc server.
  • 145 |
  • 146 | 147 | $services
  • 148 |
  • 149 | 150 | $options
  • 151 |
  • 152 | 153 | $documentor
  • 154 |
155 | 156 | 157 |
158 | 159 |
160 | 161 |
162 | addMethod (line 185) 163 |
164 | 165 | 166 |

Allows you to add a single method to the server after construction.

167 |
    168 |
  • access: public
  • 169 |
170 | 171 |
172 | void 173 | 174 | addMethod 175 | 176 | (string $name, callback $method) 177 |
178 | 179 |
    180 |
  • 181 | string 182 | $name: The name of the method as exposed through the rpc server
  • 183 |
  • 184 | callback 185 | $method: The name of the method to call, or an array with classname or object and method name.
  • 186 |
187 | 188 | 189 |
190 | 191 |
192 | 193 |
194 | addService (line 134) 195 |
196 | 197 | 198 |

Allows you to add a service to the server after construction.

199 |
    200 |
  • throws: Ripcord_InvalidArgumentException (ripcord::unknownServiceType) when passed an incorrect service
  • 201 |
  • access: public
  • 202 |
203 | 204 |
205 | void 206 | 207 | addService 208 | 209 | (object $service, [string $serviceName = 0]) 210 |
211 | 212 |
    213 |
  • 214 | object 215 | $service: The object or class whose public methods must be added to the rpc server. May also be a function or method.
  • 216 |
  • 217 | string 218 | $serviceName: Optional. The namespace for the methods.
  • 219 |
220 | 221 | 222 |
223 | 224 |
225 | 226 |
227 | call (line 340) 228 |
229 | 230 | 231 |

Calls a method by its rpc name.

232 |
    233 |
  • throws: Ripcord_BadMethodCallException (ripcord::methodNotFound) when the requested method isn't available.
  • 234 |
  • throws: Ripcord_InvalidArgumentException (ripcord::cannotRecurse) when passed a recursive multiCall
  • 235 |
  • access: public
  • 236 |
237 | 238 |
239 | mixed 240 | 241 | call 242 | 243 | (string $method, [array $args = null]) 244 |
245 | 246 |
    247 |
  • 248 | string 249 | $method: The rpc name of the method
  • 250 |
  • 251 | array 252 | $args: The arguments to this method
  • 253 |
254 | 255 | 256 |
257 | 258 |
259 | 260 |
261 | handle (line 301) 262 |
263 | 264 | 265 |

Handles the given request xml

266 |
    267 |
  • access: public
  • 268 |
269 | 270 |
271 | string 272 | 273 | handle 274 | 275 | (string $request_xml) 276 |
277 | 278 |
    279 |
  • 280 | string 281 | $request_xml: The incoming request.
  • 282 |
283 | 284 | 285 |
286 | 287 |
288 | 289 |
290 | run (line 197) 291 |
292 | 293 | 294 |

Runs the rpc server. Automatically handles an incoming request.

295 |
    296 |
  • access: public
  • 297 |
298 | 299 |
300 | void 301 | 302 | run 303 | 304 | () 305 |
306 | 307 | 308 | 309 |
310 | 311 |
312 | 313 |
314 | setOutputOption (line 382) 315 |
316 | 317 | 318 |

Allows you to set specific output options of the server after construction.

319 |
    320 |
  • access: public
  • 321 |
322 | 323 |
324 | void 325 | 326 | setOutputOption 327 | 328 | (string $option, mixed $value) 329 |
330 | 331 |
    332 |
  • 333 | string 334 | $option: The name of the option
  • 335 |
  • 336 | mixed 337 | $value: The value of the option The options are:
    • output_type: Return data as either php native data or xml encoded. Can be either 'php' or 'xml'. 'xml' is the default.
    • verbosity: Determines the compactness of generated xml. Can be either 'no_white_space', 'newlines_only' or 'pretty'. 338 | 'pretty' is the default.
    • escaping: Determines how/whether to escape certain characters. 1 or more values are allowed. If multiple, they need 339 | to be specified as a sub-array. Options are: 'cdata', 'non-ascii', 'non-print' and 'markup'. Default is 'non-ascii', 340 | 'non-print' and 'markup'.
    • version: Version of the xml vocabulary to use. Currently, three are supported: 'xmlrpc', 'soap 1.1' and 'simple'. The 341 | keyword 'auto' is also recognized and tells the server to respond in whichever version the request cam in. 'auto' is 342 | the default.
    • encoding: The character encoding that the data is in. Can be any supported character encoding. Default is 'utf-8'.
  • 343 |
344 | 345 | 346 |
347 | 348 |
349 |
350 | 351 | 352 |

353 | Documentation generated on Tue, 16 Nov 2010 16:20:19 +0100 by phpDocumentor 1.4.3 354 |

355 |
356 | --------------------------------------------------------------------------------