rssaction.class.php
查看本檔案說明文件.00001 <?php
00002
00003 include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
00004 include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
00005 include_once( PLOG_CLASS_PATH."class/view/rssview.class.php" );
00006 include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
00007 include_once( PLOG_CLASS_PATH."class/locale/locale.class.php" );
00008 include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
00009
00017 class RssAction extends BlogAction
00018 {
00019
00023 function RssAction( $blogInfo, $request )
00024 {
00025 $this->BlogAction( $blogInfo, $request );
00026 }
00027
00031 function perform()
00032 {
00033
00034 $rdfEnabled = $this->_config->getValue( "rdf_enabled" );
00035 if ( !$rdfEnabled ) {
00036 $message = $this->_locale->tr('error_rdf_syndication_not_allowed').'<br/><br/>';
00037 $this->_view = new ErrorView( $this->_blogInfo, $message );
00038 $this->setCommonData();
00039 $this->_view->render();
00040
00041 die();
00042 }
00043
00044
00045 $articles = new Articles();
00046 $blogSettings = $this->_blogInfo->getSettings();
00047 $localeCode = $blogSettings->getValue( "locale" );
00048
00049
00050 $defaultProfile = $this->_config->getValue( "default_rss_profile" );
00051 if( $defaultProfile == "" || $defaultProfile == null )
00052 $defaultProfile = DEFAULT_PROFILE;
00053
00054
00055
00056
00057 $profile = $this->_request->getValue( "profile" );
00058 if( $profile == "" ) $profile = $defaultProfile;
00059
00060
00061
00062 $categoryId = $this->_request->getValue( "categoryId" );
00063 if( !is_numeric($categoryId))
00064 $categoryId = 0;
00065
00066
00067 $this->_view = new RssView( $this->_blogInfo, $profile,
00068 Array( "profile" => $profile,
00069 "categoryId" => $categoryId ));
00070
00071
00072 if( $this->_view->isCached()) {
00073 return true;
00074 }
00075
00076
00077 $locale = Locales::getLocale( $localeCode );
00078
00079
00080 $amount = $blogSettings->getValue( "recent_posts_max", 15 );
00081 $t = new Timestamp();
00082 if( $blogSettings->getValue( 'show_future_posts_in_calendar' )) {
00083 $blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(), -1, $amount,
00084 $categoryId, POST_STATUS_PUBLISHED, 0 );
00085 }
00086 else {
00087 $today = $t->getTimestamp();
00088 $blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(), -1, $amount,
00089 $categoryId, POST_STATUS_PUBLISHED, 0, $today );
00090 }
00091
00092
00093 if( $categoryId > 0 ) {
00094 include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
00095 $articleCategories = new ArticleCategories();
00096 $category = $articleCategories->getCategory( $categoryId );
00097 $this->_view->setValue( "rsscategory", $category );
00098 }
00099
00100 $pm =& PluginManager::getPluginManager();
00101 $pm->setBlogInfo( $this->_blogInfo );
00102 $pm->setUserInfo( $this->_userInfo );
00103 $result = $pm->notifyEvent( EVENT_POSTS_LOADED, Array( 'articles' => &$blogArticles ));
00104 $articles = Array();
00105 foreach( $blogArticles as $article ) {
00106 $postText = $article->getIntroText();
00107 $postExtendedText = $article->getExtendedText();
00108 $pm->notifyEvent( EVENT_TEXT_FILTER, Array( "text" => &$postText ));
00109 $pm->notifyEvent( EVENT_TEXT_FILTER, Array( "text" => &$postExtendedText ));
00110 $article->setIntroText( $postText );
00111 $article->setExtendedText( $postExtendedText );
00112 array_push( $articles, $article );
00113 }
00114
00115 $this->_view->setValue( "locale", $locale );
00116 $this->_view->setValue( "posts", $articles );
00117 $this->setCommonData();
00118
00119 return true;
00120 }
00121 }
00122 ?>