00001 <?php
00002
00003 lt_include( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
00004 lt_include( PLOG_CLASS_PATH."class/view/rssview.class.php" );
00005 lt_include( PLOG_CLASS_PATH."class/data/validator/templatenamevalidator.class.php" );
00006 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
00007
00008
00016 class RssAction extends BlogAction
00017 {
00018
00022 function RssAction( $blogInfo, $request )
00023 {
00024 $this->BlogAction( $blogInfo, $request );
00025
00026 $this->registerFieldValidator( "categoryId", new IntegerValidator(), true );
00027 $this->registerFieldValidator( "userId", new IntegerValidator(), true );
00028 $this->registerFieldValidator( "profile", new TemplateNameValidator());
00029
00030
00031 $view = new RssView( $this->_blogInfo, RSS_VIEW_DEFAULT_PROFILE );
00032 $view->setValue( "articles", Array());
00033 $this->setValidationErrorView( $view );
00034 }
00035
00039 function perform()
00040 {
00041
00042 $rdfEnabled = $this->_config->getValue( "rdf_enabled" );
00043 if ( !$rdfEnabled ) {
00044 lt_include( PLOG_CLASS_PATH."class/view/errorview.class.php" );
00045 $message = $this->_locale->tr('error_rdf_syndication_not_allowed').'<br/><br/>';
00046 $this->_view = new ErrorView( $this->_blogInfo, $message );
00047 $this->setCommonData();
00048 $this->_view->render();
00049
00050 die();
00051 }
00052
00053
00054 $blogSettings = $this->_blogInfo->getSettings();
00055
00056
00057
00058 $defaultProfile = $this->_config->getValue( "default_rss_profile" );
00059 if( $defaultProfile == "" || $defaultProfile == null )
00060 $defaultProfile = RSS_VIEW_DEFAULT_PROFILE;
00061
00062
00063
00064
00065 $profile = $this->_request->getValue( "profile" );
00066 if( $profile == "" ) $profile = $defaultProfile;
00067
00068
00069 $profile = str_replace( ".", "", $profile );
00070 $profile = str_replace( "/", "", $profile );
00071 $profile = str_replace( "%", "", $profile );
00072
00073
00074
00075 $categoryId = $this->_request->getValue( "categoryId" );
00076 if( !is_numeric($categoryId))
00077 $categoryId = 0;
00078
00079
00080 $userId = $this->_request->getValue( "userId", -1 );
00081
00082
00083 $this->_view = new RssView( $this->_blogInfo, $profile,
00084 Array( "profile" => $profile,
00085 "categoryId" => $categoryId,
00086 "userId" => $userId ));
00087
00088
00089 if( $this->_view->isCached()) {
00090 $this->setCommonData();
00091 return true;
00092 }
00093
00094 lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
00095 lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
00096 lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
00097 lt_include( PLOG_CLASS_PATH."class/config/siteconfig.class.php" );
00098
00099 $articles = new Articles();
00100
00101
00102 $hardLimit = SiteConfig::getHardRecentPostsMax();
00103 $amount = $blogSettings->getValue( "recent_posts_max", 15 );
00104 if( $amount > $hardLimit ) $amount = $hardLimit;
00105
00106 $t = new Timestamp();
00107 if( $blogSettings->getValue( 'show_future_posts_in_calendar' )) {
00108 $blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(),
00109 -1,
00110 $amount,
00111 $categoryId,
00112 POST_STATUS_PUBLISHED,
00113 $userId );
00114 }
00115 else {
00116 $today = $t->getTimestamp();
00117 $blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(),
00118 -1,
00119 $amount,
00120 $categoryId,
00121 POST_STATUS_PUBLISHED,
00122 $userId,
00123 $today );
00124 }
00125
00126
00127 if( $categoryId > 0 ) {
00128 lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
00129 $articleCategories = new ArticleCategories();
00130 $category = $articleCategories->getCategory( $categoryId );
00131 $this->_view->setValue( "rsscategory", $category );
00132 }
00133
00134 $pm =& PluginManager::getPluginManager();
00135 $pm->setBlogInfo( $this->_blogInfo );
00136 $pm->setUserInfo( $this->_userInfo );
00137 $result = $pm->notifyEvent( EVENT_POSTS_LOADED, Array( 'articles' => &$blogArticles ));
00138 $articles = Array();
00139
00140 foreach( $blogArticles as $article ) {
00141 $postText = $article->getIntroText();
00142 $postExtendedText = $article->getExtendedText();
00143 $pm->notifyEvent( EVENT_TEXT_FILTER, Array( "text" => &$postText ));
00144 $pm->notifyEvent( EVENT_TEXT_FILTER, Array( "text" => &$postExtendedText ));
00145 $article->setIntroText( $postText );
00146 $article->setExtendedText( $postExtendedText );
00147 array_push( $articles, $article );
00148 }
00149
00150 $this->_view->setValue( "locale", $this->_locale );
00151 $this->_view->setValue( "posts", $articles );
00152 $this->setCommonData();
00153
00154 return true;
00155 }
00156 }
00157 ?>