Changeset 313 for trunk/trax/vendor

Show
Ignore:
Timestamp:
07/07/09 21:57:06 (3 years ago)
Author:
john
Message:

updates

Location:
trunk/trax/vendor/trax
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/trax/vendor/trax/action_mailer.php

    r289 r313  
    221221        $this->headers = $this->headers ? $this->headers : array(); 
    222222        $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'); 
    224224        $this->head_charset = $this->head_charset ? $this->head_charset : $this->default_charset; 
    225225        $this->html_charset = $this->html_charset ? $this->html_charset : $this->default_charset; 
  • trunk/trax/vendor/trax/active_record.php

    r311 r313  
    667667            switch($association_type) { 
    668668                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]) ?  
    670670                        array_merge($this->has_many[$method_name], $parameters) : $parameters; 
    671671                    $result = $this->find_all_has_many($method_name, $parameters); 
    672672                    break; 
    673673                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]) ?  
    675675                        array_merge($this->has_one[$method_name], $parameters) : $parameters; 
    676676                    $result = $this->find_one_has_one($method_name, $parameters); 
    677677                    break; 
    678678                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]) ?  
    680680                        array_merge($this->belongs_to[$method_name], $parameters) : $parameters; 
    681681                    $result = $this->find_one_belongs_to($method_name, $parameters); 
    682682                    break; 
    683683                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]) ?  
    685685                        array_merge($this->has_and_belongs_to_many[$method_name], $parameters) : $parameters; 
    686686                    $result = $this->find_all_habtm($method_name, $parameters);  
     
    760760                $options['per_page'] = $parameters['per_page']; 
    761761            } 
     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            }                        
    762768            if(@array_key_exists("class_name", $parameters)) { 
    763769                $other_object_name = $parameters['class_name']; 
     
    22482254                        unset($attributes); 
    22492255                        $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                        }                          
    22512262                        if($sort_field) { 
    22522263                            $attributes[$sort_field] = $sort_value; 
  • trunk/trax/vendor/trax/php_shell.php

    r310 r313  
    5050function __shell_default_error_handler($errno, $errstr, $errfile, $errline, $errctx) { 
    5151    ## ... 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)); 
    5554} 
    5655 
     
    9897                if (function_exists("__shell_print_var")) { 
    9998                    __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(); 
    103102                    } else { 
    104103                        var_export($__shell_retval);                         
  • trunk/trax/vendor/trax/php_shell/shell.php

    r227 r313  
    212212    * @see registerColourScheme 
    213213    */ 
    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'); 
    215217 
    216218    # shell colours 
     
    294296            'description' => $help 
    295297        ); 
     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; 
    296305    } 
    297306     
     
    459468                        /* obj */ 
    460469                         
    461                         if (!method_exists($object, $method)) { 
     470                        if (!$this->classMethodExists($object, $method)) { 
    462471                            throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'",  
    463472                                $objname, get_class($object), $method)); 
     
    491500                        /* obj */ 
    492501                         
    493                         if (!method_exists($object, $method)) { 
     502                        if (!in_array($method, $this->virtual_methods) && !method_exists($object, $method)) { 
    494503                            throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'",  
    495504                                $objname, get_class($object), $method)); 
     
    534543                        /* obj */ 
    535544                         
    536                         if (!method_exists($object, $method)) { 
     545                        if (!in_array($method, $this->virtual_methods) && !method_exists($object, $method)) { 
    537546                            throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'",  
    538547                                $objname, get_class($object), $method)); 
     
    555564                        $method = $ts[$last - 1]['value']; 
    556565 
    557                         if (!in_array($method, get_class_methods($classname))) { 
     566                        if (!in_array($method, $this->virtual_methods) && !in_array($method, get_class_methods($classname))) { 
    558567                            throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'",  
    559568                                $classname, $method)); 
     
    580589                        $method = $GLOBALS[ltrim($methodname, '$')]; 
    581590 
    582                         if (!in_array($method, get_class_methods($classname))) { 
     591                        if (!in_array($method, $this->virtual_methods) && !in_array($method, get_class_methods($classname))) { 
    583592                            throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'",  
    584593                                $classname, $method)); 
     
    812821                    return false; 
    813822                } 
    814             } 
    815             $l = fgets($this->stdin); 
     823            }   
     824                                  
     825            $l = fgets($this->stdin);  
    816826        } 
    817827        return $l;