[ 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/action/ -> summarydefaultaction.class.php (source)

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/summary/action/summaryaction.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
   5      lt_include( PLOG_CLASS_PATH."class/summary/dao/summarystatsconstants.class.php" );  
   6      lt_include( PLOG_CLASS_PATH."class/summary/net/summaryrequestgenerator.class.php" );      
   7  
   8       /**
   9        * This is the one and only default action. It simply fetches all the most recent
  10        * posts from the database and shows them. The default locale is the one specified
  11        * in the configuration file and the amount of posts shown in this page is also
  12        * configurable through the config file.
  13        */
  14       class SummaryDefaultAction extends SummaryAction
  15       {
  16          function SummaryDefaultAction( $actionInfo, $request )
  17          {
  18              $this->SummaryAction( $actionInfo, $request );
  19          }
  20  
  21          /**
  22           * Loads the posts and shows them.
  23           */
  24          function perform()
  25          {
  26              // get the blogCategoryId from request
  27              $globalArticleCategoryId = $this->_request->getValue( "globalArticleCategoryId" );
  28              $val = new IntegerValidator();
  29              if( !$val->validate( $globalArticleCategoryId ))
  30                  $globalArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES;
  31                  
  32              $this->_view = new SummaryCachedView( "index", 
  33                                                    Array( "summary" => "default",
  34                                                    "globalArticleCategoryId" => $globalArticleCategoryId,
  35                                                    "locale" => $this->_locale->getLocaleCode()));
  36                                                  
  37              if( $this->_view->isCached()) {
  38                  // if the view is already cached... move along! nothing to see here
  39                  $this->setCommonData();
  40                  return true;
  41              }
  42  
  43              lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
  44              lt_include( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
  45              lt_include( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
  46              $blogs       = new Blogs();
  47              $stats       = new SummaryStats();
  48  
  49              // get all blog category
  50              $categories = new GlobalArticleCategories();
  51              $globalArticleCategories = $categories->getGlobalArticleCategories();
  52  
  53              $min = 0;
  54              $max = 0;
  55   
  56              foreach( $globalArticleCategories as $globalArticleCategory ){
  57                  $numActiveArticles = $globalArticleCategory->getNumActiveArticles();
  58                  if( $numActiveArticles < $min ) {
  59                      $min = $numActiveArticles;
  60                      continue;
  61                  }
  62                  if( $numActiveArticles > $max ) {
  63                      $max = $numActiveArticles;
  64                      continue;
  65                  }
  66              }
  67              
  68              $step = ( $max - $min )/6;
  69              if($step == 0) 
  70                  $step = $min + 1;  
  71              
  72              if( $globalArticleCategoryId != ALL_GLOBAL_ARTICLE_CATEGORIES )
  73              {
  74                  $currentGlobalArticleCategory = $categories->getGlobalArticleCategory( $globalArticleCategoryId );
  75                  $this->_view->setValue( "currentGlobalArticleCategory", $currentGlobalArticleCategory);
  76              }
  77              
  78              // export the value for global article categories
  79              $this->_view->setValue( "summaryStats", $stats );
  80              $this->_view->setValue( "globalArticleCategories", $globalArticleCategories );
  81              $this->_view->setValue( "min", $min );
  82              $this->_view->setValue( "step", $step );
  83              $this->_view->setValue( "globalArticleCategoryId", $globalArticleCategoryId );
  84          
  85              // summary request generator
  86              $this->_view->setValue( "url", new SummaryRequestGenerator());
  87              
  88              $this->setCommonData();
  89  
  90              return true;
  91          }
  92       }
  93  ?>


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