[ 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/ -> summarybloglistview.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/blogs.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
   8      lt_include( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );     
   9      
  10      /**
  11       * shows a paged list of blogs
  12       */
  13      class SummaryBlogListView extends SummaryCachedView
  14      {
  15          var $_numBlogsPerPage;
  16      
  17  		function SummaryBlogListView( $data = Array())
  18          {
  19              // get the page
  20              $this->_page = $this->getCurrentPageFromRequest();
  21              
  22              $this->SummaryCachedView( "blogslist", $data );
  23              
  24              // items per page
  25              $config =& Config::getConfig();
  26              $this->_numBlogsPerPage = $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 BlogCategories();
  38              $blogCategories = $categories->getBlogCategories();
  39              
  40              $min = 0;
  41              $max = 0;
  42   
  43              foreach( $blogCategories as $blogCategory ){
  44                  $numActiveBlogs = $blogCategory->getNumActiveBlogs();
  45                  if( $numActiveBlogs < $min ) {
  46                      $min = $numActiveBlogs;
  47                      continue;
  48                  }
  49                  if( $numActiveBlogs > $max ) {
  50                      $max = $numActiveBlogs;
  51                      continue;
  52                  }
  53              }
  54              
  55              $step = ( $max - $min )/6;
  56              if($step == 0) 
  57                  $step = $min + 1;                
  58              
  59              // get current blogCategory
  60              $blogCategoryId = $this->_params->getValue( "blogCategoryId" );
  61              $currentBlogCategory = $categories->getBlogCategory( $blogCategoryId );
  62              if( !$currentBlogCategory )
  63                  $blogCategoryId = ALL_BLOG_CATEGORIES;
  64  
  65              // get the data itself
  66              $blogs = new Blogs();                        
  67              $siteBlogs = $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, $blogCategoryId, "", $this->_page, $this->_numBlogsPerPage );
  68              $numBlogs = $blogs->getNumBlogs( BLOG_STATUS_ACTIVE, $blogCategoryId );        
  69              
  70              if( !$siteBlogs ) {
  71                  // if there was an error, show the error view
  72                  $siteBlogs = Array();
  73              }
  74              
  75              // calculate the links to the different pages
  76              $pager = new Pager( "?op=BlogList&amp;blogCategoryId=".$blogCategoryId."&amp;page=",
  77                                  $this->_page, 
  78                                  $numBlogs, 
  79                                  $this->_numBlogsPerPage );
  80  
  81              $this->setValue( "blogs", $siteBlogs );
  82              $this->setValue( "pager", $pager );
  83              $this->setValue( "blogCategories", $blogCategories );
  84              $this->setValue( "currentBlogCategory", $currentBlogCategory);
  85              $this->setValue( "min", $min );
  86              $this->setValue( "step", $step );
  87  
  88              // let the parent view do its job
  89              parent::render();
  90          }
  91      }
  92  ?>


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