[ 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/ -> blogprofileaction.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      
   6      /**
   7       * by default, how many posts show as recent from this blog
   8       */
   9      define( "SUMMARY_DEFAULT_RECENT_BLOG_POSTS", 5 );
  10  
  11      /**
  12       * shows a user profile
  13       */
  14       class BlogProfileAction extends SummaryAction
  15       {
  16       
  17          var $_blogId;
  18  
  19          function BlogProfileAction( $actionInfo, $request )
  20          {
  21              $this->SummaryAction( $actionInfo, $request );
  22              
  23              // data validation
  24              $this->registerFieldValidator( "blogId", new IntegerValidator());
  25              $view = new SummaryView( "error" );
  26              $view->setValue( "message", $this->_locale->tr("error_incorrect_blog_id"));
  27              $this->setValidationErrorView( $view );
  28          }
  29  
  30          /**
  31           * Loads the blog info and show it
  32           */
  33          function perform()
  34          {
  35              $this->_blogId = $this->_request->getValue( "blogId" );            
  36              
  37              $this->_view = new SummaryCachedView( "blogprofile", Array( "summary" => "BlogProfile", 
  38                                                                          "blogId" => $this->_blogId,
  39                                                                          "locale" => $this->_locale->getLocaleCode()));
  40              if( $this->_view->isCached()) {
  41                  // nothing to do, the view is cached
  42                  $this->setCommonData();
  43                  return true;
  44              }
  45              
  46              lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
  47              lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
  48              lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
  49              
  50              // load some information about the user
  51              $blogs = new Blogs();
  52              $blogInfo = $blogs->getBlogInfo( $this->_blogId, true );
  53              
  54              // if there was no blog or the status was incorrect, let's not show it!
  55              if( !$blogInfo || $blogInfo->getStatus() != BLOG_STATUS_ACTIVE ) {
  56                  $this->_view = new SummaryView( "error" );
  57                  $this->_view->setValue( "message", $this->_locale->tr("error_incorrect_blog_id"));
  58                  return false;
  59              }
  60              
  61              // fetch the blog latest posts
  62              $posts = Array();
  63              $articles = new Articles();            
  64              $t = new Timestamp();
  65              $posts = $articles->getBlogArticles( $blogInfo->getId(),
  66                                                   -1,
  67                                                   SUMMARY_DEFAULT_RECENT_BLOG_POSTS,
  68                                                   0,
  69                                                   POST_STATUS_PUBLISHED,
  70                                                   0,
  71                                                   $t->getTimestamp());
  72                                                   
  73              
  74              $this->_view->setValue( "blog", $blogInfo );
  75              $this->_view->setValue( "blogposts", $posts );
  76              
  77              $this->setCommonData();            
  78          
  79              return true;
  80          }
  81       }     
  82  ?>


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