aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_core.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-08-19 23:58:35 +0000
committerrvelices <rv-github@modusoptimus.com>2008-08-19 23:58:35 +0000
commitdcbaefafdfb955f61c9b83eb8d2e15eea2880694 (patch)
tree0e35d4a8466e3b0f8027059dbe81979ad5baab0f /include/ws_core.inc.php
parent9a346cc2378bf752c7099a1875b10919f0f7235e (diff)
- 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
Diffstat (limited to 'include/ws_core.inc.php')
-rw-r--r--include/ws_core.inc.php31
1 files changed, 18 insertions, 13 deletions
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;
}