Changeset 327 for trunk

Show
Ignore:
Timestamp:
09/26/09 09:40:51 (3 years ago)
Author:
john
Message:

AR changed the count on paginated queries, added session_cookie_domain to the Trax class

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

Legend:

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

    r326 r327  
    219219        $this->template_path = "{$this->template_root}/".Inflector::underscore(get_class($this)); 
    220220        $this->template = $this->template ? $this->template : $method_name;         
    221         $this->headers = $this->headers ? $this->headers : array(); 
    222         $this->body = $this->body ? $this->body : array(); 
     221        #$this->headers = $this->headers ? $this->headers : array(); 
     222        $this->headers = array(); 
     223        #$this->body = $this->body ? $this->body : array();     
     224        $this->body = null; 
    223225        $this->default_from = "nobody@".($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : 'domain.com'); 
    224226        $this->head_charset = $this->head_charset ? $this->head_charset : $this->default_charset; 
  • trunk/trax/vendor/trax/action_view/helpers/active_record_helper.php

    r316 r327  
    729729        } 
    730730        $end = $object->rows_per_page * $object->page; 
    731         $start = $end - ($object->rows_per_page - 1); 
     731        $start = $end - ($object->rows_per_page - 1);   
    732732        if($end >= $object->pagination_count) { 
    733733            $end = $object->pagination_count; 
    734         } 
     734        }  
    735735 
    736736        return $object->pagination_count ? sprintf($format, $start, $end, $object->pagination_count) : null; 
  • trunk/trax/vendor/trax/active_record.php

    r315 r327  
    10411041            if(@array_key_exists("foreign_key", $parameters)) { 
    10421042                $foreign_key = $parameters['foreign_key']; 
    1043             }          
     1043            }   
     1044            if(@array_key_exists("primary_key", $parameters)) { 
     1045                $other_primary_key = $parameters['primary_key']; 
     1046            }        
    10441047            if(@array_key_exists("class_name", $parameters)) { 
    10451048                $other_object_name = $parameters['class_name']; 
     
    10521055        $other_class_object = new $other_class_name(); 
    10531056 
    1054         # This class primary key 
    1055         $other_primary_key = $other_class_object->primary_keys[0]; 
     1057        # This class primary key    
     1058        if(!$other_primary_key) { 
     1059            $other_primary_key = $other_class_object->primary_keys[0]; 
     1060        }         
    10561061 
    10571062        if(!$foreign_key) { 
     
    11181123        #echo "$aggregate_type sql:$sql<br>"; 
    11191124        //print_r($parameters[0]); 
    1120         //echo $sql; 
     1125        //echo $sql;  
     1126        #error_log("$aggregate_type:$sql"); 
    11211127        $rs = $this->query($sql, true); 
    11221128        $row = $rs->fetchRow(); 
     
    14551461 
    14561462        # Test source of SQL for query  
    1457         if(stristr($conditions, "SELECT ")) { 
    1458             # SQL completely specified in argument so use it as is 
    1459             $sql = $conditions; 
    1460         }  
    1461         else { 
     1463        if(stristr($conditions, "SELECT ")) {         
     1464            # SQL completely specified in argument so use it as is 
     1465            $sql = $conditions;       
     1466        } else { 
    14621467 
    14631468            # If select fields not specified just do a SELECT * 
     
    14831488            } elseif(array_key_exists('conditions', $this->default_scope)  
    14841489                     && !is_null($this->default_scope['conditions'])) { 
    1485                 $sql .= "WHERE ".$this->default_scope['conditions']." "; 
     1490                $conditions = $this->default_scope['conditions']; 
     1491                $sql .= "WHERE {$conditions} "; 
    14861492            } 
    14871493             
     
    15421548                } 
    15431549 
    1544                 $sql .= "LIMIT {$this->rows_per_page} OFFSET {$offset}"; 
    1545                 # $sql .= "LIMIT $offset, $this->rows_per_page"; 
    1546                  
    1547                 if($paginate) { 
    1548                     #error_log("I am going to paginate."); 
    1549                     # Set number of total pages in result set 
    1550                     if($count = $this->count_all($this->primary_keys[0], $conditions, $joins)) { 
     1550                if($paginate) {       
     1551                    #error_log("pagination sql:$sql");                           
     1552                    $pagination_rs = $this->query($sql);  
     1553                    if($count = $pagination_rs->numRows()) { 
    15511554                        $this->pagination_count = $count; 
    15521555                        $this->pages = (($count % $this->rows_per_page) == 0) 
    15531556                            ? $count / $this->rows_per_page 
    15541557                            : floor($count / $this->rows_per_page) + 1;  
    1555                     } 
    1556                 } 
     1558                    }  
     1559                    /*                   
     1560                    #error_log("I am going to paginate."); 
     1561                    # Set number of total pages in result set           
     1562                    $count_all_params = array( 
     1563                        'conditions' => $conditions, 
     1564                        'joins' => $joins, 
     1565                        'group' => $group, 
     1566                        'having' => $having 
     1567                    );    
     1568                     
     1569                    if($count = $this->count_all($this->primary_keys[0], $count_all_params)) { 
     1570                        $this->pagination_count = $count; 
     1571                        $this->pages = (($count % $this->rows_per_page) == 0) 
     1572                            ? $count / $this->rows_per_page 
     1573                            : floor($count / $this->rows_per_page) + 1;  
     1574                    }   
     1575                    */ 
     1576                }   
     1577                 
     1578                $sql .= "LIMIT {$this->rows_per_page} OFFSET {$offset}"; 
     1579                # $sql .= "LIMIT $offset, $this->rows_per_page";                 
     1580                 
    15571581            } 
    15581582        } 
     
    16361660            } 
    16371661            # If callback is defined in model run it. 
    1638             # this will probably hurt performance... 
    1639             if(method_exists($object, 'after_find')) { 
     1662            # this will probably hurt performance...   
     1663            if(method_exists($object, 'after_find')) {  
    16401664                $object->after_find();     
    1641             } 
     1665            } elseif(isset($this->after_find) && method_exists($object, $this->after_find)) {    
     1666                $object->{$this->after_find}(); 
     1667            } 
    16421668            unset($object); 
    16431669        } 
     
    19551981            $this->raise($primary_key_value->getMessage()); 
    19561982        }             
    1957         $this->$primary_key = $primary_key_value; 
     1983        $this->$primary_key = $primary_key_value;   
     1984        $this->new_record = false; 
    19581985        if($primary_key_value != '') { 
    19591986            if($this->auto_save_habtm) { 
  • trunk/trax/vendor/trax/session.php

    r316 r327  
    9898        Trax::$session_maxlifetime_minutes = Trax::$session_maxlifetime_minutes ? Trax::$session_maxlifetime_minutes : self::TRAX_SESSION_MAXLIFETIME_MINUTES; 
    9999         
    100         # set the session default for this app 
     100        # set the session default for this app  
    101101        ini_set('session.name', Trax::$session_name); 
    102         ini_set('session.use_cookies', 1); 
     102        ini_set('session.use_cookies', 1);      
     103        if(Trax::$session_cookie_domain) { 
     104            ini_set('session.cookie_domain',  Trax::$session_cookie_domain);  
     105        }        
    103106        ini_set('session.cookie_lifetime', Trax::$session_lifetime); 
    104107        ini_set('session.gc_probability', 1); 
  • trunk/trax/vendor/trax/trax.php

    r325 r327  
    6565        $session_save_path = "", 
    6666        $session_name = "TRAXSESSID", 
     67        $session_cookie_domain = null, 
    6768        $session_lifetime = "0", 
    6869        $session_maxlifetime_minutes = "20",