/**
  * Constructor. If nothing else, it also has to call the constructor of the parent
  * class, BlogAction with the same parameters
  */
 function AdminAddPostAction($actionInfo, $request)
 {
     $this->AdminPostManagementCommonAction($actionInfo, $request);
     // for data validation purposes, posts must have at least a topic, an intro text, and a category
     $this->registerFieldValidator("postText", new StringValidator());
     $this->registerFieldValidator("postTopic", new StringValidator());
     $this->registerFieldValidator("postCategories", new ArrayValidator());
     $view = new AdminNewPostView($this->_blogInfo);
     $view->setErrorMessage($this->_locale->tr("error_adding_post"));
     $this->setValidationErrorView($view);
     // these fields do not need to be validated but should be there when we show the view once again
     $this->registerField("postExtendedText");
     $this->registerField("postSlug");
     $this->registerField("postStatus");
     $this->registerField("sendNotification");
     $this->registerField("sendTrackbacks");
     $this->registerField("sendPings");
     $this->registerField("postId");
     $this->registerField("commentsEnabled");
     $this->registerField("customField");
     $this->registerField("postDateTime");
     $this->registerField("trackbackUrls");
 }
 function render()
 {
     // check if there is a notification for the article set up by this user
     if ($this->_article) {
         $notifications = new ArticleNotifications();
         $userNotification = $notifications->getUserArticleNotification($this->_article->getId(), $this->_blogInfo->getId(), $this->_userInfo->getId());
         // decide wether or not we should notify the user based on what we've just
         // fetched from the database
         if ($userNotification) {
             $this->setValue("sendNotification", true);
         } else {
             $this->setValue("sendNotification", false);
         }
         // set information about the post itself into the view
         $this->setValue("postTopic", $this->_article->getTopic());
         $this->setValue("postText", preg_replace('/&/', '&', $this->_article->getIntroText()));
         $this->setValue("postExtendedText", preg_replace('/&/', '&', $this->_article->getExtendedText()));
         $this->setValue("postSlug", $this->_article->getPostSlug());
         $this->setValue("postId", $this->_article->getId());
         if ($this->_article->getCommentsEnabled()) {
             $commentsEnabled = true;
         } else {
             $commentsEnabled = false;
         }
         $this->setValue("postCommentsEnabled", $commentsEnabled);
         $this->setValue("postCategories", $this->_article->getCategoryIds());
         $this->setValue("postStatus", $this->_article->getStatus());
         // we need to play a bit with the values of the fields, as the editpost.template page is
         // expecting them in a bit different way than if we just do an $article->getFields()
         $customFieldValues = $this->_article->getFields();
         $customField = array();
         foreach ($customFieldValues as $fieldValue) {
             $customField[$fieldValue->getFieldId()] = $fieldValue->getValue();
         }
         $this->setValue("customField", $customField);
         // related to the date
         $postDate = $this->_article->getDateObject();
         $this->setValue("postYear", $postDate->getYear());
         $this->setValue("postMonth", $postDate->getMonth());
         $this->setValue("postDay", $postDate->getDay());
         $this->setValue("postHour", $postDate->getHour());
         $this->setValue("postMinutes", $postDate->getMinutes());
     }
     // let our parent class do the rest...
     parent::render();
 }