[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH.'class/action/admin/adminpostmanagementcommonaction.class.php' ); 4 lt_include( PLOG_CLASS_PATH.'class/view/viewarticleview.class.php' ); 5 lt_include( PLOG_CLASS_PATH.'class/dao/article.class.php' ); 6 7 /** 8 * \ingroup Action 9 * @private 10 * 11 * Action that will allow us to preview a post, using the blog's very own 12 * template so that it looks and feels exactly like in the real blog, where it will 13 * be finally shown when we save it. 14 * 15 * It works by creating a dummy article that does not exist in the database and then 16 * using one of the blog views to show it. 17 */ 18 class AdminPreviewPostAction extends AdminPostManagementCommonAction 19 { 20 21 /** 22 * Constructor. If nothing else, it also has to call the constructor of the parent 23 * class, BlogAction with the same parameters 24 */ 25 function AdminPreviewPostAction( $actionInfo, $request ) 26 { 27 $this->AdminAction( $actionInfo, $request ); 28 } 29 30 /** 31 * loads a bunch of categories given their ids 32 * 33 * @param categoryIds 34 */ 35 function _loadArticleCategories( $categoryIds ) 36 { 37 $articleCategories = new ArticleCategories(); 38 $categories = Array(); 39 foreach( $categoryIds as $categoryId ) { 40 $category = $articleCategories->getCategory( $categoryId, $this->_blogInfo->getId()); 41 if( $category ) 42 array_push( $categories, $category ); 43 } 44 45 return $categories; 46 } 47 48 /** 49 * Carries out the specified action 50 */ 51 function perform() 52 { 53 //print_r($_REQUEST); 54 55 // fetch all the information that we need for the dummy Article object 56 $this->_fetchCommonData(); 57 58 // and now, create a harmless Article object with it 59 $postText = Textfilter::xhtmlize($this->_postText); 60 // create the main object 61 $article = new Article( $this->_postTopic, 62 $postText, 63 $this->_postCategories, 64 $this->_userInfo->getId(), 65 $this->_blogInfo->getId(), 66 POST_STATUS_PUBLISHED, 67 0, 68 Array(), 69 $this->_postSlug ); 70 // and a few more properties that we need to know about 71 $this->_fetchPostDateInformation(); 72 $article->setDateObject( $this->_postTimestamp ); 73 // we will not allow comments because it wouldn't work! 74 $article->setCommentsEnabled( false ); 75 $article->setFields( $this->_getArticleCustomFields()); 76 // the next two fields are also required in order to show an article 77 $article->setUserInfo( $this->_userInfo ); 78 $article->setBlogInfo( $this->_blogInfo ); 79 $article->setCategories( $this->_loadArticleCategories( $this->_postCategories )); 80 // and now trick the ViewArticleView class into thinking that we're showing 81 // a real article just fetched from the database (even though it makes no difference 82 // to the class itself whence the article came from :) 83 84 // throw the EVENT_ARTICLE_PREVIEW event in case a plugin wants to do something with it 85 $this->notifyEvent( EVENT_POST_PREVIEW, Array( "article" => &$article )); 86 87 // the 'random' parameter in the array is to provide the view with a random view id 88 // every time that we run the preview, otherwise when caching is enabled we would always be 89 // getting the same page!! 90 $this->_view = new ViewArticleView( $this->_blogInfo, Array( 'random' => md5(time()))); 91 $this->_view->setArticle( $article ); 92 //$this->setCommonData(); 93 94 return true; 95 } 96 } 97 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |