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

   1  <?php
   2  
   3      lt_include( PLOG_CLASS_PATH."class/view/admin/adminnewpostview.class.php" );
   4      lt_include( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );
   5      
   6      /**

   7       * \ingroup View

   8       * @private

   9       *    

  10       * shows the view that will allow to edit an article

  11       */
  12      class AdminEditPostView extends AdminNewPostView
  13      {
  14          
  15          var $_article;
  16      
  17  		function AdminEditPostView( $blogInfo )
  18          {
  19              $this->AdminTemplatedView( $blogInfo, "editpost" );
  20              
  21              // by default, we have no article

  22              $this->_article = null;
  23          }
  24          
  25          /**

  26           * passes an article to the view

  27           * 

  28           * @param article

  29           * @return nothing

  30           */
  31  		function setArticle( $article )
  32          {
  33              $this->_article = $article;
  34              $this->setValue( "post", $article );
  35          }
  36          
  37  		function render()
  38          {
  39              // check if there is a notification for the article set up by this user

  40              if( $this->_article ) {
  41                  $notifications = new ArticleNotifications();
  42                  $userNotification = $notifications->getUserArticleNotification( $this->_article->getId(), $this->_blogInfo->getId(), $this->_userInfo->getId());
  43                  
  44                  // decide wether or not we should notify the user based on what we've just

  45                  // fetched from the database

  46                  if( $userNotification )
  47                      $this->setValue( "sendNotification", true );
  48                  else
  49                      $this->setValue( "sendNotification", false );            
  50                  
  51                  // set information about the post itself into the view

  52                  $this->setValue( "postTopic", $this->_article->getTopic());
  53                  $this->setValue( "postText", str_replace('&', '&amp;', $this->_article->getText( false )));
  54                  $this->setValue( "postSlug", $this->_article->getPostSlug());
  55                  $this->setValue( "postId", $this->_article->getId());
  56                  $this->setValue( "postUser", $this->_article->getUserId());
  57                  if( $this->_article->getCommentsEnabled())
  58                      $commentsEnabled = true;
  59                  else
  60                      $commentsEnabled = false;
  61                  $this->setValue( "postCommentsEnabled", $commentsEnabled );
  62                  $this->setValue( "postCategories", $this->_article->getCategoryIds());
  63                  $this->setValue( "postStatus", $this->_article->getStatus());
  64                  
  65                  // we need to play a bit with the values of the fields, as the editpost.template page is

  66                  // expecting them in a bit different way than if we just do an $article->getFields()

  67                  $customFieldValues = $this->_article->getCustomFields();
  68                  $customField = Array();
  69                  foreach( $customFieldValues as $fieldValue )
  70                      $customField[$fieldValue->getFieldId()] = $fieldValue->getValue();
  71                  $this->setValue( "customField", $customField );
  72                  
  73                  // related to the date

  74                  $postDate = $this->_article->getDateObject();
  75                  $this->setValue( "postYear", $postDate->getYear());
  76                  $this->setValue( "postMonth", $postDate->getMonth());
  77                  $this->setValue( "postDay", $postDate->getDay());
  78                  $this->setValue( "postHour", $postDate->getHour());
  79                  $this->setValue( "postMinutes", $postDate->getMinutes());
  80                  $this->setValue( "globalArticleCategoryId", $this->_article->getGlobalCategoryId());
  81              }
  82                          
  83              // let our parent class do the rest...

  84              parent::render();
  85          }
  86      }
  87  ?>


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