Changeset 2543 for trunk/include/ws_core.inc.php
- Timestamp:
- Sep 17, 2008, 3:48:31 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_core.inc.php
r2521 r2543 36 36 define( 'WS_PARAM_OPTIONAL', 0x040000 ); 37 37 38 define( 'WS_ERR_INVALID_METHOD', 1001 );38 define( 'WS_ERR_INVALID_METHOD', 501 ); 39 39 define( 'WS_ERR_MISSING_PARAM', 1002 ); 40 40 define( 'WS_ERR_INVALID_PARAM', 1003 ); … … 48 48 class PwgError 49 49 { 50 var$_code;51 var$_codeText;50 private $_code; 51 private $_codeText; 52 52 53 53 function PwgError($code, $codeText) 54 54 { 55 set_status_header($code, $codeText); 55 if ($code>=400 and $code<600) 56 { 57 set_status_header($code, $codeText); 58 } 56 59 57 60 $this->_code = $code; … … 81 84 * xml attributes instead of xml child elements 82 85 */ 83 function PwgNamedArray( &$arr, $itemName, $xmlAttributes=array() )86 function PwgNamedArray($arr, $itemName, $xmlAttributes=array() ) 84 87 { 85 88 $this->_content = $arr; … … 135 138 136 139 /** 137 * Replace array_walk_recursive()138 *139 * @category PHP140 * @package PHP_Compat141 * @link http://php.net/function.array_walk_recursive142 * @author Tom Buskens <ortega@php.net>143 * @author Aidan Lister <aidan@php.net>144 * @version $Revision$145 * @since PHP 5146 * @require PHP 4.0.6 (is_callable)147 */148 if (!function_exists('array_walk_recursive')) {149 function array_walk_recursive(&$input, $funcname)150 {151 if (!is_callable($funcname)) {152 if (is_array($funcname)) {153 $funcname = $funcname[0] . '::' . $funcname[1];154 }155 user_error('array_walk_recursive() Not a valid callback ' . $user_func,156 E_USER_WARNING);157 return;158 }159 160 if (!is_array($input)) {161 user_error('array_walk_recursive() The argument should be an array',162 E_USER_WARNING);163 return;164 }165 166 $args = func_get_args();167 168 foreach ($input as $key => $item) {169 if (is_array($item)) {170 array_walk_recursive($item, $funcname, $args);171 $input[$key] = $item;172 } else {173 $args[0] = &$item;174 $args[1] = &$key;175 call_user_func_array($funcname, $args);176 $input[$key] = $item;177 }178 }179 }180 }181 182 /**183 140 * Abstract base class for request handlers. 184 141 */ … … 210 167 * NOT consecutive integers starting with 0) 211 168 */ 212 function is_struct(&$data)169 static function is_struct(&$data) 213 170 { 214 171 if (is_array($data) ) … … 226 183 * usually called by every response encoder, except rest xml. 227 184 */ 228 function flattenResponse(&$response)185 static function flattenResponse(&$response) 229 186 { 230 187 PwgResponseEncoder::_mergeAttributesAndContent($response); … … 240 197 } 241 198 242 /*private*/function _remove_named_callback(&$value, $key)199 private static function _remove_named_callback(&$value, $key) 243 200 { 244 201 do … … 252 209 } 253 210 254 /*private*/function _mergeAttributesAndContent(&$value)211 private static function _mergeAttributesAndContent(&$value) 255 212 { 256 213 if ( !is_array($value) ) … … 311 268 } 312 269 313 /*private*/function _removeNamedArray(&$value)270 private static function _removeNamedArray(&$value) 314 271 { 315 272 if ( strtolower( get_class($value) ) =='pwgnamedarray') … … 321 278 } 322 279 323 /*private*/function _removeNamedStruct(&$value)280 private static function _removeNamedStruct(&$value) 324 281 { 325 282 if ( strtolower( get_class($value) ) =='pwgnamedstruct') … … 389 346 if ( is_null($this->_requestHandler) ) 390 347 { 391 $this->sendResponse( 392 new PwgError(400, 'Unknown request format') 393 ); 348 $this->sendResponse( new PwgError(400, 'Unknown request format') ); 394 349 return; 395 350 } … … 584 539 * WS reflection method implementation: lists all available methods 585 540 */ 586 /*static*/function ws_getMethodList($params, &$service)541 static function ws_getMethodList($params, &$service) 587 542 { 588 543 return array('methods' => new PwgNamedArray( array_keys($service->_methods),'method' ) ); … … 592 547 * WS reflection method implementation: gets information about a given method 593 548 */ 594 /*static*/function ws_getMethodDetails($params, &$service)549 static function ws_getMethodDetails($params, &$service) 595 550 { 596 551 $methodName = $params['methodName'];
Note: See TracChangeset
for help on using the changeset viewer.