- Timestamp:
- 10/06/08 22:57:48 (2 years ago)
- Files:
-
- fCore.php (modified) (5 diffs)
- fGrammar.php (modified) (3 diffs)
- fMoney.php (modified) (2 diffs)
- fNumber.php (modified) (2 diffs)
- fORM.php (modified) (2 diffs)
- fORMFile.php (modified) (1 diff)
- fRecordSet.php (modified) (2 diffs)
- fSQLTranslation.php (modified) (1 diff)
- fTimestamp.php (modified) (1 diff)
- fValidation.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
fCore.php
r270 r271 Hide Line Numbers 185 185 186 186 /** 187 * Performs a call_user_func_array, while translating PHP 5.2 static callback syntax for PHP 5.1 and 5.0 188 * 189 * To pass parameters by reference they must be assigned to the parameters 187 * Performs a call_user_func, while translating PHP 5.2 static callback syntax for PHP 5.1 and 5.0 188 * 189 * Parameters can be passed either as a single array of parameters or as 190 * multiple parameters. 191 * 192 * <code> 193 * // Passing multiple parameters in a normal fashion 194 * fCore::call('Class::method', TRUE, 0, 'test'); 195 * 196 * // Passing multiple parameters in a parameters array 197 * fCore::call('Class::method', array(TRUE, 0, 'test')); 198 * </code> 199 * 200 * To pass parameters by reference they must be assigned to an 190 201 * array by reference and the function/method being called must accept those 191 202 * parameters by reference. If either condition is not met, the parameter 192 203 * will be passed by value. 193 204 * 205 * <code> 206 * // Passing parameters by reference 207 * fCore::call('Class::method', array(&$var1, &$var2)); 208 * </code> 209 * 194 210 * @param callback $callback The function or method to call 195 211 * @param array $parameters The parameters to pass to the function/method … … 203 219 } 204 220 221 $parameters = array_shift(func_get_args()); 222 if (sizeof($parameters) == 1 && is_array($parameters[0])) { 223 $parameters = $parameters[0]; 224 } 225 205 226 return call_user_func_array($callback, $parameters); 227 } 228 229 230 /** 231 * Translates a Class::method style static method callback to array style for compatibility with PHP 5.0 and 5.1 and built-in PHP functions 232 * 233 * @param callback $callback The callback to translate 234 * @return array The translated callback 235 */ 236 static public function callback($callback) 237 { 238 if (!is_string($callback) || strpos($callback, '::') === FALSE) { 239 fCore::toss( 240 'fProgrammerException', 241 fGrammar::compose( 242 'Only string static method callbacks can be translated with this method' 243 ) 244 ); 245 } 246 247 if (self::getPHPVersion() < '5.2.0') { 248 return explode('::', $callback); 249 } 250 251 return $callback; 206 252 } 207 253 … … 367 413 self::$error_destination = $destination; 368 414 self::$handles_errors = TRUE; 369 set_error_handler( array('fCore', 'handleError'));415 set_error_handler(self::callback(self::handleError)); 370 416 } 371 417 … … 391 437 settype($parameters, 'array'); 392 438 self::$exception_handler_parameters = $parameters; 393 set_exception_handler( array('fCore', 'handleException'));439 set_exception_handler(self::callback(self::handleException)); 394 440 } 395 441 … … 646 692 static $registered_function = FALSE; 647 693 if (!$registered_function) { 648 register_shutdown_function( array('fCore', 'sendMessagesOnShutdown'));694 register_shutdown_function(self::callback(self::sendMessagesOnShutdown)); 649 695 $registered_function = TRUE; 650 696 } fGrammar.php
r270 r271 Hide Line Numbers 221 221 if (self::$compose_callbacks) { 222 222 foreach (self::$compose_callbacks['pre'] as $callback) { 223 $message = fCore::call($callback, array($message));223 $message = fCore::call($callback, $message); 224 224 } 225 225 } … … 230 230 if (self::$compose_callbacks) { 231 231 foreach (self::$compose_callbacks['post'] as $callback) { 232 $message = fCore::call($callback, array($message));232 $message = fCore::call($callback, $message); 233 233 } 234 234 } … … 344 344 345 345 if (self::$join_array_callback) { 346 return fCore::call(self::$join_array_callback, array($strings, $type));346 return fCore::call(self::$join_array_callback, $strings, $type); 347 347 } 348 348 fMoney.php
r270 r271 Hide Line Numbers 242 242 // Unformat any money value 243 243 if (self::$unformat_callback !== NULL) { 244 $amount = fCore::call(self::$unformat_callback, array($amount, $this->currency));244 $amount = fCore::call(self::$unformat_callback, $amount, $this->currency); 245 245 } else { 246 246 $amount = str_replace( … … 426 426 { 427 427 if (self::$format_callback !== NULL) { 428 return fCore::call(self::$format_callback, array($this->value, $this->currency));428 return fCore::call(self::$format_callback, $this->value, $this->currency); 429 429 } 430 430 fNumber.php
r270 r271 Hide Line Numbers 258 258 259 259 if (self::$unformat_callback) { 260 $number = fCore::call(self::$unformat_callback, array($number));260 $number = fCore::call(self::$unformat_callback, $number); 261 261 } else { 262 262 $number = str_replace(',', '', $number); … … 1102 1102 { 1103 1103 if (self::$format_callback !== NULL) { 1104 return fCore::call(self::$format_callback, array($this->value));1104 return fCore::call(self::$format_callback, $this->value); 1105 1105 } 1106 1106 fORM.php
r270 r271 Hide Line Numbers 462 462 463 463 if (!empty(self::$objectify_callbacks[$class][$column])) { 464 return fCore::call(self::$objectify_callbacks[$class][$column], array($class, $column, $value));464 return fCore::call(self::$objectify_callbacks[$class][$column], $class, $column, $value); 465 465 } 466 466 … … 763 763 764 764 if (!empty(self::$scalarize_callbacks[$class][$column])) { 765 return fCore::call(self::$scalarize_callbacks[$class][$column], array($class, $column, $value));765 return fCore::call(self::$scalarize_callbacks[$class][$column], $class, $column, $value); 766 766 } 767 767 fORMFile.php
r270 r271 Hide Line Numbers 159 159 160 160 self::$fupload_method_calls[$class][$column][] = array( 161 'callback' => array('fUpload', $method),161 'callback' => 'fUpload::' . $method, 162 162 'parameters' => $parameters 163 163 ); fRecordSet.php
r270 r271 Hide Line Numbers 521 521 $value = $record->$method(); 522 522 } else { 523 $value = fCore::call($callback, array($record));523 $value = fCore::call($callback, $record); 524 524 } 525 525 if ($value) { … … 953 953 954 954 foreach($values as $value) { 955 $result = fCore::call($callback, array($result, $value));955 $result = fCore::call($callback, $result, $value); 956 956 } 957 957 fSQLTranslation.php
r265 r271 Hide Line Numbers 387 387 $functions[] = array('ceiling', 'ceil', 1); 388 388 $functions[] = array('cos', 'cos', 1); 389 $functions[] = array('cot', array('fSQLTranslation', 'sqliteCotangent'),1);389 $functions[] = array('cot', fCore::callback(self::sqliteCotangent), 1); 390 390 $functions[] = array('degrees', 'rad2deg', 1); 391 391 $functions[] = array('exp', 'exp', 1); 392 392 $functions[] = array('floor', 'floor', 1); 393 393 $functions[] = array('ln', 'log', 1); 394 $functions[] = array('log', array('fSQLTranslation', 'sqliteLogBaseFirst'),2);394 $functions[] = array('log', fCore::callback(self::sqliteLogBaseFirst), 2); 395 395 $functions[] = array('pi', 'pi', 1); 396 396 $functions[] = array('power', 'pow', 1); 397 397 $functions[] = array('radians', 'deg2rad', 1); 398 $functions[] = array('sign', array('fSQLTranslation', 'sqliteSign'),1);398 $functions[] = array('sign', fCore::callback(self::sqliteSign), 1); 399 399 $functions[] = array('sqrt', 'sqrt', 1); 400 400 $functions[] = array('sin', 'sin', 1); fTimestamp.php
r270 r271 Hide Line Numbers 53 53 { 54 54 if (self::$format_callback) { 55 return fCore::call(self::$format_callback, array($formatted_string));55 return fCore::call(self::$format_callback, $formatted_string); 56 56 } 57 57 return $formatted_string; fValidation.php
r267 r271 Hide Line Numbers 221 221 222 222 if (!$found) { 223 $required_field = array_map( array('fGrammar', 'humanize'), $required_field);223 $required_field = array_map(fCore::callback(fGrammar::humanize), $required_field); 224 224 $messages[] = fGrammar::compose( 225 225 '%s: Please enter at least one',
