From dcbaefafdfb955f61c9b83eb8d2e15eea2880694 Mon Sep 17 00:00:00 2001 From: rvelices Date: Tue, 19 Aug 2008 23:58:35 +0000 Subject: - ws can include php file before invoking web call method - remove "Pierrick ..." from some languages - tags - small change to avoid increasing number of urls - added a missing closedir - remove some unnecessary class names and inexisting rel attributes git-svn-id: http://piwigo.org/svn/trunk@2478 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/ws_core.inc.php | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'include/ws_core.inc.php') diff --git a/include/ws_core.inc.php b/include/ws_core.inc.php index c78d4f402..71a10b06d 100644 --- a/include/ws_core.inc.php +++ b/include/ws_core.inc.php @@ -344,12 +344,10 @@ class PwgServer var $_responseEncoder; var $_responseFormat; - var $_methods; - var $_methodSignatures; + var $_methods = array(); function PwgServer() { - $methods = array(); } /** @@ -435,9 +433,6 @@ Response format: ".@$this->_responseFormat." encoder:".$this->_responseEncoder." */ function addMethod($methodName, $callback, $params=array(), $description, $include_file='') { - $this->_methods[$methodName] = $callback; - $this->_methodDescriptions[$methodName] = $description; - if (!is_array($params)) { $params = array(); @@ -469,7 +464,13 @@ Response format: ".@$this->_responseFormat." encoder:".$this->_responseEncoder." $params[$param] = $options; } } - $this->_methodSignatures[$methodName] = $params; + + $this->_methods[$methodName] = array( + 'callback' => $callback, + 'description' => $description, + 'signature' => $params, + 'include' => $include_file, + ); } function hasMethod($methodName) @@ -479,13 +480,13 @@ Response format: ".@$this->_responseFormat." encoder:".$this->_responseEncoder." function getMethodDescription($methodName) { - $desc = @$this->_methodDescriptions[$methodName]; + $desc = @$this->_methods[$methodName]['description']; return isset($desc) ? $desc : ''; } function getMethodSignature($methodName) { - $signature = @$this->_methodSignatures[$methodName]; + $signature = @$this->_methods[$methodName]['signature']; return isset($signature) ? $signature : array(); } @@ -517,15 +518,15 @@ Response format: ".@$this->_responseFormat." encoder:".$this->_responseEncoder." */ function invoke($methodName, $params) { - $callback = @$this->_methods[$methodName]; + $method = @$this->_methods[$methodName]; - if ( $callback==null ) + if ( $method==null ) { return new PwgError(WS_ERR_INVALID_METHOD, 'Method name "'.$methodName.'" is not valid'); } // parameter check and data coercion ! - $signature = @$this->_methodSignatures[$methodName]; + $signature = $method['signature']; $missing_params = array(); foreach($signature as $name=>$options) { @@ -570,7 +571,11 @@ Response format: ".@$this->_responseFormat." encoder:".$this->_responseEncoder." $result = trigger_event('ws_invoke_allowed', true, $methodName, $params); if ( strtolower( get_class($result) )!='pwgerror') { - $result = call_user_func_array($callback, array($params, &$this) ); + if ( !empty($method['include']) ) + { + include_once( $method['include'] ); + } + $result = call_user_func_array($method['callback'], array($params, &$this) ); } return $result; } -- cgit v1.2.3