Changeset 313 for trunk/trax/vendor
- Timestamp:
- 07/07/09 21:57:06 (3 years ago)
- Location:
- trunk/trax/vendor/trax
- Files:
-
- 4 modified
-
action_mailer.php (modified) (1 diff)
-
active_record.php (modified) (3 diffs)
-
php_shell.php (modified) (2 diffs)
-
php_shell/shell.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/trax/vendor/trax/action_mailer.php
r289 r313 221 221 $this->headers = $this->headers ? $this->headers : array(); 222 222 $this->body = $this->body ? $this->body : array(); 223 $this->default_from = "nobody@". $_SERVER['HTTP_HOST'];223 $this->default_from = "nobody@".($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : 'domain.com'); 224 224 $this->head_charset = $this->head_charset ? $this->head_charset : $this->default_charset; 225 225 $this->html_charset = $this->html_charset ? $this->html_charset : $this->default_charset; -
trunk/trax/vendor/trax/active_record.php
r311 r313 667 667 switch($association_type) { 668 668 case "has_many": 669 $parameters = is_array($this->has_many) && @array_key_exists($method_name, $this->has_many) ?669 $parameters = is_array($this->has_many) && @array_key_exists($method_name, $this->has_many) && !is_null($this->has_many[$method_name]) ? 670 670 array_merge($this->has_many[$method_name], $parameters) : $parameters; 671 671 $result = $this->find_all_has_many($method_name, $parameters); 672 672 break; 673 673 case "has_one": 674 $parameters = is_array($this->has_one) && @array_key_exists($method_name, $this->has_one) ?674 $parameters = is_array($this->has_one) && @array_key_exists($method_name, $this->has_one) && !is_null($this->has_one[$method_name]) ? 675 675 array_merge($this->has_one[$method_name], $parameters) : $parameters; 676 676 $result = $this->find_one_has_one($method_name, $parameters); 677 677 break; 678 678 case "belongs_to": 679 $parameters = is_array($this->belongs_to) && @array_key_exists($method_name, $this->belongs_to) ?679 $parameters = is_array($this->belongs_to) && @array_key_exists($method_name, $this->belongs_to) && !is_null($this->belongs_to[$method_name]) ? 680 680 array_merge($this->belongs_to[$method_name], $parameters) : $parameters; 681 681 $result = $this->find_one_belongs_to($method_name, $parameters); 682 682 break; 683 683 case "has_and_belongs_to_many": 684 $parameters = is_array($this->has_and_belongs_to_many) && @array_key_exists($method_name, $this->has_and_belongs_to_many) ?684 $parameters = is_array($this->has_and_belongs_to_many) && @array_key_exists($method_name, $this->has_and_belongs_to_many) && !is_null($this->has_and_belongs_to_many[$method_name]) ? 685 685 array_merge($this->has_and_belongs_to_many[$method_name], $parameters) : $parameters; 686 686 $result = $this->find_all_habtm($method_name, $parameters); … … 760 760 $options['per_page'] = $parameters['per_page']; 761 761 } 762 if(@array_key_exists("group", $parameters)) { 763 $options['group'] = $parameters['group']; 764 } 765 if(@array_key_exists("having", $parameters)) { 766 $options['having'] = $parameters['having']; 767 } 762 768 if(@array_key_exists("class_name", $parameters)) { 763 769 $other_object_name = $parameters['class_name']; … … 2248 2254 unset($attributes); 2249 2255 $attributes[$this_foreign_key] = $this_foreign_value; 2250 $attributes[$other_foreign_key] = $other_foreign_value; 2256 $attributes[$other_foreign_key] = $other_foreign_value; 2257 #error_log("HABTM - this_foreign_value:$this_foreign_value other_foreign_value:$other_foreign_value"); 2258 if(in_array('', array($this_foreign_value, $other_foreign_value))) { 2259 # this will cause an error so don't insert 2260 continue; 2261 } 2251 2262 if($sort_field) { 2252 2263 $attributes[$sort_field] = $sort_value; -
trunk/trax/vendor/trax/php_shell.php
r310 r313 50 50 function __shell_default_error_handler($errno, $errstr, $errfile, $errline, $errctx) { 51 51 ## ... what is this errno again ? 52 if(in_array($errno, array(8,2048))) return; 53 print sprintf("\r\nError No:%d - %s", $errno, $errstr); 54 #throw new Exception(sprintf("%s:%d\r\n%s", $errfile, $errline, $errstr)); 52 if ($errno == 2048 || $errno == 8) return; 53 throw new Exception(sprintf("%s:%d\r\n%s", $errfile, $errline, $errstr)); 55 54 } 56 55 … … 98 97 if (function_exists("__shell_print_var")) { 99 98 __shell_print_var($__shell_retval, $__shell->getVerbose()); 100 } else { 101 if(is_object($__shell_retval) && get_parent_class($__shell_retval) == 'ActiveRecord') {102 print $__shell_retval;99 } else { 100 if(is_object($__shell_retval) && method_exists($__shell_retval, '__toString')) { 101 echo "Class:".get_class($__shell_retval)."\n".$__shell_retval->__toString(); 103 102 } else { 104 103 var_export($__shell_retval); -
trunk/trax/vendor/trax/php_shell/shell.php
r227 r313 212 212 * @see registerColourScheme 213 213 */ 214 protected $colour_scheme; 214 protected $colour_scheme; 215 216 protected $virtual_methods = array('find_by', 'find_all_by', 'count_all', 'sum_all', 'avg_all'); 215 217 216 218 # shell colours … … 294 296 'description' => $help 295 297 ); 298 } 299 300 public function classMethodExists($object, $method) { 301 if(preg_grep("/^(find|find_all)_by.*$/", $this->virtual_methods) || method_exists($object, $method)) { 302 return true; 303 } 304 return false; 296 305 } 297 306 … … 459 468 /* obj */ 460 469 461 if (! method_exists($object, $method)) {470 if (!$this->classMethodExists($object, $method)) { 462 471 throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", 463 472 $objname, get_class($object), $method)); … … 491 500 /* obj */ 492 501 493 if (! method_exists($object, $method)) {502 if (!in_array($method, $this->virtual_methods) && !method_exists($object, $method)) { 494 503 throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", 495 504 $objname, get_class($object), $method)); … … 534 543 /* obj */ 535 544 536 if (! method_exists($object, $method)) {545 if (!in_array($method, $this->virtual_methods) && !method_exists($object, $method)) { 537 546 throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", 538 547 $objname, get_class($object), $method)); … … 555 564 $method = $ts[$last - 1]['value']; 556 565 557 if (!in_array($method, get_class_methods($classname))) {566 if (!in_array($method, $this->virtual_methods) && !in_array($method, get_class_methods($classname))) { 558 567 throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'", 559 568 $classname, $method)); … … 580 589 $method = $GLOBALS[ltrim($methodname, '$')]; 581 590 582 if (!in_array($method, get_class_methods($classname))) {591 if (!in_array($method, $this->virtual_methods) && !in_array($method, get_class_methods($classname))) { 583 592 throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'", 584 593 $classname, $method)); … … 812 821 return false; 813 822 } 814 } 815 $l = fgets($this->stdin); 823 } 824 825 $l = fgets($this->stdin); 816 826 } 817 827 return $l;
