/**
  * Carries out the specified action
  */
 function perform()
 {
     //print_r($_REQUEST);
     // fetch all the information that we need for the dummy Article object
     $this->_fetchCommonData();
     // and now, create a harmless Article object with it
     $postText = Textfilter::xhtmlize($this->_postText) . POST_EXTENDED_TEXT_MODIFIER . Textfilter::xhtmlize($this->_postExtendedText);
     // create the main object
     $article = new Article($this->_postTopic, $postText, $this->_postCategories, $this->_userInfo->getId(), $this->_blogInfo->getId(), $status, 0, array(), $this->_postSlug);
     // and a few more properties that we need to know about
     $this->_fetchPostDateInformation();
     $article->setDateObject($this->_postTimestamp);
     // we will not allow comments because it wouldn't work!
     $article->setCommentsEnabled(false);
     $article->setFields($this->_getArticleCustomFields());
     // the next two fields are also required in order to show an article
     $article->setUserInfo($this->_userInfo);
     $article->setBlogInfo($this->_blogInfo);
     $article->setCategories($this->_loadArticleCategories($this->_postCategories));
     // and now trick the ViewArticleView class into thinking that we're showing
     // a real article just fetched from the database (even though it makes no difference
     // to the class itself whence the article came from :)
     // the 'random' parameter in the array is to provide the view with a random view id
     // every time that we run the preview, otherwise when caching is enabled we would always be
     // getting the same page!!
     $this->_view = new ViewArticleView($this->_blogInfo, array('random' => md5(time())));
     $this->_view->setArticle($article);
     //$this->setCommonData();
     return true;
 }
 /**
  * @private
  */
 function _fillArticleHeaderInformation($query_result, $includeHiddenFields = true)
 {
     $id = $query_result['id'];
     if (isset($this->cache[$id])) {
         return $this->cache[$id];
     }
     // this is a little dirty trick or otherwise the old
     // that don't have the 'properties' field will not work
     // as they will appear to have comments disabled
     if ($query_result['properties'] == "") {
         $tmpArray = array('comments_enabled' => true);
         $query_result['properties'] = serialize($tmpArray);
     }
     // ---
     // this, i do not like... but I couldn't find a more
     // "elegant" way to arrange it! This makes this method
     // totally dependant on the blog configuration so it basically
     // means an additional query every time we fetch an article
     // (just in case we didn't have enough!)
     // ---
     //
     // if there's a time difference applied to all dates, then we'd better
     // calculate it here!!
     //
     if ($this->_blogInfo == null) {
         $blogId = $query_result['blog_id'];
         $this->_blogInfo = $this->blogs->getBlogInfo($blogId);
         $this->_blogSettings = $this->_blogInfo->getSettings();
         $this->_timeDiff = $this->_blogSettings->getValue('time_offset');
     }
     // we can use this auxiliary function to help us...
     $date = Timestamp::getDateWithOffset($query_result['date'], $this->_timeDiff);
     // postText does not exist here.. maybe a copy/paste problem?
     // anyway.. it works without postText, so i'll just set this to
     // null. oscar, pls double check.. original code:
     // $article = new Article( $postText['topic'],
     //                         $postText['text'],
     //                         NULL,
     $article = new Article(NULL, NULL, NULL, $query_result['user_id'], $query_result['blog_id'], $query_result['status'], $query_result['num_reads'], unserialize($query_result['properties']), $query_result['slug'], $query_result['id']);
     // and fill in all the fields with the information we just got from the db
     $article->setDate($date);
     $article->setTimeOffset($this->_timeDiff);
     $article->setBlogInfo($this->_blogInfo);
     $article->setUserInfo($this->users->getUserInfoFromId($query_result['user_id']));
     return $article;
 }