[ 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/summary/view/ -> summarypostlistview.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/summary/view/summarycachedview.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" ); 
   6      lt_include( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
   9      
  10      /**
  11       * shows a paged list of blogs
  12       */
  13      class SummaryPostListView extends SummaryCachedView
  14      {
  15          var $_numArticlesPerPage;
  16      
  17  		function SummaryPostListView( $data = Array())
  18          {
  19              // get the page
  20              $this->_page = $this->getCurrentPageFromRequest();
  21              
  22              $this->SummaryCachedView( "postslist", $data );
  23              
  24              // items per page
  25              $config =& Config::getConfig();
  26              $this->_numArticlesPerPage = $config->getValue( "summary_items_per_page", SUMMARY_DEFAULT_ITEMS_PER_PAGE );
  27          }
  28          
  29  		function render()
  30          {
  31              // do nothing if the contents of our view are cached
  32              if( $this->isCached()) {
  33                  parent::render();
  34                  return true;
  35              }
  36              // get all blog category
  37              $categories = new GlobalArticleCategories();
  38              $globalArticleCategories = $categories->getGlobalArticleCategories();
  39  
  40              $min = 0;
  41              $max = 0;
  42   
  43              foreach( $globalArticleCategories as $globalArticleCategory ){
  44                  $numActiveArticles = $globalArticleCategory->getNumActiveArticles();
  45                  if( $numActiveArticles < $min ) {
  46                      $min = $numActiveArticles;
  47                      continue;
  48                  }
  49                  if( $numActiveArticles > $max ) {
  50                      $max = $numActiveArticles;
  51                      continue;
  52                  }
  53              }
  54              
  55              $step = ( $max - $min )/6;
  56              if($step == 0) 
  57                  $step = $min + 1;            
  58              
  59              // get current globalArticleCategoryId
  60              $globalArticleCategoryId = $this->_params->getValue( "globalArticleCategoryId" );
  61              $currentGlobalArticleCategory = $categories->getGlobalArticleCategory( $globalArticleCategoryId );
  62  
  63              if( empty($currentGlobalArticleCategory) )
  64                  $globalArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES;
  65  
  66              // get the data itself
  67              $stats = new SummaryStats();
  68              $posts = $stats->getPostsByGlobalCategory( $globalArticleCategoryId, $this->_page, $this->_numArticlesPerPage );
  69              $numPosts = $stats->getNumPostsByGlobalCategory( $globalArticleCategoryId );
  70              
  71              if( !$posts ) {
  72                  // if there was an error, show the error view
  73                  $posts = Array();
  74              }
  75              
  76              // calculate the links to the different pages
  77              $pager = new Pager( "?op=PostList&amp;globalArticleCategoryId=".$globalArticleCategoryId."&amp;page=",
  78                                  $this->_page, 
  79                                  $numPosts, 
  80                                  $this->_numArticlesPerPage );
  81  
  82              $this->setValue( "recentPosts", $posts );
  83              $this->setValue( "numRecentPosts", $numPosts );
  84              $this->setValue( "pager", $pager );
  85              $this->setValue( "globalArticleCategories", $globalArticleCategories );
  86              $this->setValue( "currentGlobalArticleCategory", $currentGlobalArticleCategory); 
  87              $this->setValue( "min", $min );
  88              $this->setValue( "step", $step );
  89                      
  90              // let the parent view do its job
  91              parent::render();
  92          }
  93      }
  94  ?>


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