[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/dao/ -> recentarticles.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/dao/daocacheconstants.properties.php" );    
   5  
   6      /**
   7       * small wrapper to Articles that loads and caches recent articles. As an API user, you probably
   8       * don't need to use this class unless you're implementing your own front-end to LifeType.
   9       */
  10      
  11      /**
  12       * @see Articles
  13       */
  14      class RecentArticles extends Articles
  15      {
  16          /**
  17           * @param blogId
  18           * @param amount
  19           * @return An array of Article objects
  20           * @see Article 
  21           */
  22  		function getRecentArticles( $blogId, $amount ) 
  23          {
  24              // check if the data is there
  25              $recentPosts = $this->_cache->getData( $blogId, CACHE_RECENT_ARTICLES_BY_BLOG );
  26              if( !$recentPosts ) {        
  27                  lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
  28                  $t = new Timestamp();
  29                  $todayTimestamp = $t->getTimestamp();
  30                  
  31                  // load the data if not available
  32                  $recentPosts = $this->getBlogArticles( $blogId,
  33                                                         -1, 
  34                                                         $amount,
  35                                                         0, 
  36                                                         1, 
  37                                                         0, 
  38                                                         $todayTimestamp);
  39                                                         
  40                  // and cache it for future use
  41                  $this->_cache->setData( $blogId, CACHE_RECENT_ARTICLES_BY_BLOG, $recentPosts );
  42              }
  43              
  44              return( $recentPosts );
  45          }
  46          
  47          /**
  48           * Called whenever the cache needs to be cleaned up.
  49           * @static
  50           */
  51  		function resetRecentArticlesCache( $blogId ) 
  52          {
  53              $cache =& CacheManager::getCache();
  54              $cache->removeData( $blogId, CACHE_RECENT_ARTICLES_BY_BLOG );
  55          }
  56      }
  57  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics