Changeset 80713b0054beb5197e1a9a4347a066496a08d939

Show
Ignore:
Timestamp:
12/02/09 21:24:04 (3 years ago)
Author:
Leo 'costela' Antunes <leo@…>
Parents:
e17861cf54208dc1c6dc231687cafc3ac2321d7d
git-committer:
Leo 'costela' Antunes <leo@…> (12/02/09 21:24:04)
Message:

minor reworking of the checkFreshness code

git-svn-id:  http://svn.costela.net/guck/trunk@51 0b27b881-053d-0410-9699-9726465f5fd6

Location:
src/classes
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • src/classes/base/View.class.php

    re17861c r80713b0  
    230230        } 
    231231 
    232         public static function checkFreshness($date)  
     232        /** 
     233         * Generates appropriate headers, based on document age. 
     234         * 
     235         * @param int $time     timestamp with the last update of the document being generated 
     236         */ 
     237        public static function checkFreshness($time) 
    233238        { 
    234239                $since = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']); 
    235240 
    236                 if( $since && $since > strtotime($date) ) 
     241                if( $since && $since > $time ) 
    237242                { 
    238243                        header('HTTP/1.1 304 Not Modified'); 
     
    241246                else 
    242247                { 
    243                         header('Last-Modified: '.gmdate('D, d M Y H:i:s', $date).' GMT'); 
    244                         header('ETag: '.md5($date)); 
     248                        header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); 
     249                        header('ETag: '.md5($time)); 
    245250                } 
    246251        } 
  • src/classes/view/PostsView.class.php

    r412005a r80713b0  
    6262                $posts = PostsLogic::getBatch($page); 
    6363                 
    64                 $this->view->checkFreshness($posts[0]->date); 
     64                $this->view->checkFreshness(strtotime($posts[0]->date)); 
    6565 
    6666                $this->view->assign('posts', $posts); 
     
    7474                 
    7575                $posts = PostsLogic::getBatch($page, Logic::getConfig()->POSTS_PER_PAGE); 
    76                 $this->view->checkFreshness($posts[0]->date); 
     76                $this->view->checkFreshness(strtotime($posts[0]->date)); 
    7777 
    7878                $this->view->assign('posts', $posts); 
     
    8383        { 
    8484                $posts = PostsLogic::getBatch(1, Logic::getConfig()->POSTS_PER_PAGE); 
    85                 $this->view->checkFreshness($posts[0]->date); 
     85                $this->view->checkFreshness(strtotime($posts[0]->date)); 
    8686 
    8787                $this->view->assign('posts', $posts); 
  • src/classes/view/UsersView.class.php

    r412005a r80713b0  
    4949                $posts = PostsLogic::getBatchByUser($page, $userId); 
    5050 
    51                 $this->view->checkFreshness($posts[0]->date); 
     51                $this->view->checkFreshness(strtotime($posts[0]->date)); 
    5252 
    5353                $this->view->assign('posts', $posts); 
     
    8888                $posts = PostsLogic::getBatchByUser($page, $_GET['userId']); 
    8989 
    90                 $this->view->checkFreshness($posts[0]->date); 
     90                $this->view->checkFreshness(strtotime($posts[0]->date)); 
    9191 
    9292                $this->view->assign('posts', $posts);