ActionRss

Package actions
Inheritance class ActionRss » Action » LsObject
Since 1.0
Source Code /classes/actions/ActionRss.class.php
Экшен бработки RSS Автор класса vovazol(http://livestreet.ru/profile/vovazol/)

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
aParams array Список параметров из URL Action
aParamsEventMatch array Список совпадений по регулярному выражению для евента Action
aRegisterEvent array Список зарегистрированных евентов Action
oEngine Engine|null Объект ядра Action
sActionTemplate string|null Шаблон экшена Action
sCurrentAction null|string Текущий экшен Action
sCurrentEvent string|null Текущий евент Action
sCurrentEventName string|null Имя текущий евента Action
sDefaultEvent string|null Дефолтный евент Action

Public Methods

Hide inherited methods

MethodDescriptionDefined By
EventShutdown() Выполняется при завершение экшена, после вызова основного евента Action
ExecEvent() Запускает евент на выполнение Action
GetActionClass() Получить каталог с шаблонами экшена(совпадает с именем класса) Action
GetCurrentEventName() Возвращает имя евента Action
GetDefaultEvent() Получает евент по умолчанию Action
GetParam() Получает параметр из URL по его номеру, если его нет то null Action
GetParams() Получает список параметров из УРЛ Action
GetTemplate() Получить шаблон Action
Init() Инициализация ActionRss
SetDefaultEvent() Устанавливает евент по умолчанию Action
SetParam() Установить значение параметра(эмуляция параметра в URL). Action
__call() Ставим хук на вызов неизвестного метода и считаем что хотели вызвать метод какого либо модуля Action
__construct() Конструктор Action

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
AddEvent() Добавляет евент в экшен Action
AddEventPreg() Добавляет евент в экшен, используя регулярное вырожение для евента и параметров Action
EventNotFound() Вызывается в том случаи если не найден евент который запросили через URL Action
GetEventMatch() Возвращает элементы совпадения по регулярному выражению для евента Action
GetParamEventMatch() Возвращает элементы совпадения по регулярному выражению для параметров евента Action
InitRss() Указывает браузеру правильный content type в случае вывода RSS-ленты ActionRss
RegisterEvent() Регистрация евентов ActionRss
RssColectiveBlog() Вывод RSS топиков из коллективного блога ActionRss
RssComments() Вывод RSS последних комментариев ActionRss
RssGood() Вывод RSS интересных топиков ActionRss
RssNew() Вывод RSS новых топиков ActionRss
RssPersonalBlog() Вывод RSS топиков из персонального блога или всех персональных ActionRss
RssTag() Вывод RSS топиков по определенному тегу ActionRss
RssTopicComments() Вывод RSS комментариев конкретного топика ActionRss
SetTemplate() Устанавливает какой шаблон выводить Action
SetTemplateAction() Устанавливает какой шаблон выводить Action
getTopicText() Формирует текст топика для RSS ActionRss

Method Details

Init() method
public void Init()
Source Code: /classes/actions/ActionRss.class.php#29 (show)
public function Init() {
    
$this->SetDefaultEvent('index');
    
Router::SetIsShowStats(false);
}

Инициализация

InitRss() method
protected void InitRss()
Source Code: /classes/actions/ActionRss.class.php#36 (show)
protected function InitRss() {
    
header('Content-Type: application/rss+xml; charset=utf-8');
}

Указывает браузеру правильный content type в случае вывода RSS-ленты

RegisterEvent() method
protected void RegisterEvent()
Source Code: /classes/actions/ActionRss.class.php#42 (show)
protected function RegisterEvent() {
    
$this->AddEvent('index','RssGood');
    
$this->AddEvent('new','RssNew');
    
$this->AddEvent('allcomments','RssComments');
    
$this->AddEvent('comments','RssTopicComments');
    
$this->AddEvent('tag','RssTag');
    
$this->AddEvent('blog','RssColectiveBlog');
    
$this->AddEvent('personal_blog','RssPersonalBlog');
}

Регистрация евентов

RssColectiveBlog() method
protected void RssColectiveBlog()
Source Code: /classes/actions/ActionRss.class.php#266 (show)
protected function RssColectiveBlog() {
    
$sBlogUrl=$this->GetParam(0);
    
/**
     * Если блог существует, то получаем записи
     */
    
if (!$sBlogUrl or !($oBlog=$this->Blog_GetBlogByUrl($sBlogUrl)) or $oBlog->getType()=="close") {
        return 
parent::EventNotFound();
    }else{
        
$aResult=$this->Topic_GetTopicsByBlog($oBlog,1,Config::Get('module.topic.per_page')*2,'good');
    }
    
$aTopics=$aResult['collection'];
    
/**
     * Формируем данные канала RSS
     */
    
$aChannel['title']=Config::Get('view.name');
    
$aChannel['link']=Config::Get('path.root.web');
    
$aChannel['description']=Config::Get('path.root.web').' / '.$oBlog->getTitle().' / RSS channel';
    
$aChannel['language']='ru';
    
$aChannel['managingEditor']=Config::Get('general.rss_editor_mail');
    
$aChannel['generator']=Config::Get('path.root.web');
    
/**
     * Формируем записи RSS
     */
    
$topics=array();
    foreach (
$aTopics as $oTopic){
        
$item['title']=$oTopic->getTitle();
        
$item['guid']=$oTopic->getUrl();
        
$item['link']=$oTopic->getUrl();
        
$item['description']=$this->getTopicText($oTopic);
        
$item['pubDate']=$oTopic->getDateAdd();
        
$item['author']=$oTopic->getUser()->getLogin();
        
$item['category']=htmlspecialchars($oTopic->getTags());
        
$topics[]=$item;
    }
    
/**
     * Формируем ответ
     */
    
$this->InitRss();
    
$this->Viewer_Assign('aChannel',$aChannel);
    
$this->Viewer_Assign('aItems',$topics);
    
$this->SetTemplateAction('index');
}

Вывод RSS топиков из коллективного блога

RssComments() method
protected void RssComments()
Source Code: /classes/actions/ActionRss.class.php#134 (show)
protected function RssComments() {
    
/**
     * Получаем закрытые блоги, чтобы исключить их из выдачи
     */
    
$aCloseBlogs $this->Blog_GetInaccessibleBlogsByUser();
    
/**
     * Получаем комментарии
     */
    
$aResult=$this->Comment_GetCommentsAll('topic',1,Config::Get('module.comment.per_page')*2,array(),$aCloseBlogs);
    
$aComments=$aResult['collection'];
    
/**
     * Формируем данные канала RSS
     */
    
$aChannel['title']=Config::Get('view.name');
    
$aChannel['link']=Config::Get('path.root.web');
    
$aChannel['description']=Config::Get('path.root.web').' / RSS channel';
    
$aChannel['language']='ru';
    
$aChannel['managingEditor']=Config::Get('general.rss_editor_mail');
    
$aChannel['generator']=Config::Get('path.root.web');
    
/**
     * Формируем записи RSS
     */
    
$comments=array();
    foreach (
$aComments as $oComment){
        
$item['title']='Comments: '.$oComment->getTarget()->getTitle();
        
$item['guid']=$oComment->getTarget()->getUrl().'#comment'.$oComment->getId();
        
$item['link']=$oComment->getTarget()->getUrl().'#comment'.$oComment->getId();
        
$item['description']=$oComment->getText();
        
$item['pubDate']=$oComment->getDate();
        
$item['author']=$oComment->getUser()->getLogin();
        
$item['category']='comments';
        
$comments[]=$item;
    }
    
/**
     * Формируем ответ
     */
    
$this->InitRss();
    
$this->Viewer_Assign('aChannel',$aChannel);
    
$this->Viewer_Assign('aItems',$comments);
    
$this->SetTemplateAction('index');
}

Вывод RSS последних комментариев

RssGood() method
protected void RssGood()
Source Code: /classes/actions/ActionRss.class.php#54 (show)
protected function RssGood() {
    
/**
     * Получаем топики
     */
    
$aResult=$this->Topic_GetTopicsGood(1,Config::Get('module.topic.per_page')*2,false);
    
$aTopics=$aResult['collection'];
    
/**
     * Формируем данные канала RSS
     */
    
$aChannel['title']=Config::Get('view.name');
    
$aChannel['link']=Config::Get('path.root.web');
    
$aChannel['description']=Config::Get('view.name').' / RSS channel';
    
$aChannel['language']='ru';
    
$aChannel['managingEditor']=Config::Get('general.rss_editor_mail');
    
$aChannel['generator']=Config::Get('view.name');
    
/**
     * Формируем записи RSS
     */
    
$topics=array();
    foreach (
$aTopics as $oTopic){
        
$item['title']=$oTopic->getTitle();
        
$item['guid']=$oTopic->getUrl();
        
$item['link']=$oTopic->getUrl();
        
$item['description']=$this->getTopicText($oTopic);
        
$item['pubDate']=$oTopic->getDateAdd();
        
$item['author']=$oTopic->getUser()->getLogin();
        
$item['category']=htmlspecialchars($oTopic->getTags());
        
$topics[]=$item;
    }
    
/**
     * Формируем ответ
     */
    
$this->InitRss();
    
$this->Viewer_Assign('aChannel',$aChannel);
    
$this->Viewer_Assign('aItems',$topics);
    
$this->SetTemplateAction('index');
}

Вывод RSS интересных топиков

RssNew() method
protected void RssNew()
Source Code: /classes/actions/ActionRss.class.php#94 (show)
protected function RssNew() {
    
/**
     * Получаем топики
     */
    
$aResult=$this->Topic_GetTopicsNew(1,Config::Get('module.topic.per_page')*2,false);
    
$aTopics=$aResult['collection'];
    
/**
     * Формируем данные канала RSS
     */
    
$aChannel['title']=Config::Get('view.name');
    
$aChannel['link']=Config::Get('path.root.web');
    
$aChannel['description']=Config::Get('path.root.web').' / RSS channel';
    
$aChannel['language']='ru';
    
$aChannel['managingEditor']=Config::Get('general.rss_editor_mail');
    
$aChannel['generator']=Config::Get('path.root.web');
    
/**
     * Формируем записи RSS
     */
    
$topics = array();
    foreach (
$aTopics as $oTopic){
        
$item['title']=$oTopic->getTitle();
        
$item['guid']=$oTopic->getUrl();
        
$item['link']=$oTopic->getUrl();
        
$item['description']=$this->getTopicText($oTopic);
        
$item['pubDate']=$oTopic->getDateAdd();
        
$item['author']=$oTopic->getUser()->getLogin();
        
$item['category']=htmlspecialchars($oTopic->getTags());
        
$topics[]=$item;
    }
    
/**
     * Формируем ответ
     */
    
$this->InitRss();
    
$this->Viewer_Assign('aChannel',$aChannel);
    
$this->Viewer_Assign('aItems',$topics);
    
$this->SetTemplateAction('index');
}

Вывод RSS новых топиков

RssPersonalBlog() method
protected void RssPersonalBlog()
Source Code: /classes/actions/ActionRss.class.php#311 (show)
protected function RssPersonalBlog() {
    
$this->sUserLogin=$this->GetParam(0);
    if(!
$this->sUserLogin){
        
/**
         * RSS-лента всех записей из персональных блогов
         */
        
$aResult=$this->Topic_GetTopicsPersonal(1,Config::Get('module.topic.per_page')*2);
    }elseif(!
$oUser=$this->User_GetUserByLogin($this->sUserLogin)){
        return 
parent::EventNotFound();
    }else{
        
/**
         * RSS-лента записей персонального блога указанного пользователя
         */
        
$aResult=$this->Topic_GetTopicsPersonalByUser($oUser->getId(),1,1,Config::Get('module.topic.per_page')*2);
    }
    
$aTopics=$aResult['collection'];
    
/**
     * Формируем данные канала RSS
     */
    
$aChannel['title']=Config::Get('view.name');
    
$aChannel['link']=Config::Get('path.root.web');
    
$aChannel['description']=($this->sUserLogin)
        ? 
Config::Get('path.root.web').' / '.$oUser->getLogin().' / RSS channel'
        
Config::Get('path.root.web').' / RSS channel';
    
$aChannel['language']='ru';
    
$aChannel['managingEditor']=Config::Get('general.rss_editor_mail');
    
$aChannel['generator']=Config::Get('path.root.web');
    
/**
     * Формируем записи RSS
     */
    
$topics=array();
    foreach (
$aTopics as $oTopic){
        
$item['title']=$oTopic->getTitle();
        
$item['guid']=$oTopic->getUrl();
        
$item['link']=$oTopic->getUrl();
        
$item['description']=$this->getTopicText($oTopic);
        
$item['pubDate']=$oTopic->getDateAdd();
        
$item['author']=$oTopic->getUser()->getLogin();
        
$item['category']=htmlspecialchars($oTopic->getTags());
        
$topics[]=$item;
    }
    
/**
     * Формируем ответ
     */
    
$this->InitRss();
    
$this->Viewer_Assign('aChannel',$aChannel);
    
$this->Viewer_Assign('aItems',$topics);
    
$this->SetTemplateAction('index');
}

Вывод RSS топиков из персонального блога или всех персональных

RssTag() method
protected void RssTag()
Source Code: /classes/actions/ActionRss.class.php#225 (show)
protected function RssTag() {
    
$sTag=urldecode($this->GetParam(0));
    
/**
     * Получаем топики
     */
    
$aResult=$this->Topic_GetTopicsByTag($sTag,1,Config::Get('module.topic.per_page')*2,false);
    
$aTopics=$aResult['collection'];
    
/**
     * Формируем данные канала RSS
     */
    
$aChannel['title']=Config::Get('view.name');
    
$aChannel['link']=Config::Get('path.root.web');
    
$aChannel['description']=Config::Get('path.root.web').' / RSS channel';
    
$aChannel['language']='ru';
    
$aChannel['managingEditor']=Config::Get('general.rss_editor_mail');
    
$aChannel['generator']=Config::Get('path.root.web');
    
/**
     * Формируем записи RSS
     */
    
$topics=array();
    foreach (
$aTopics as $oTopic){
        
$item['title']=$oTopic->getTitle();
        
$item['guid']=$oTopic->getUrl();
        
$item['link']=$oTopic->getUrl();
        
$item['description']=$this->getTopicText($oTopic);
        
$item['pubDate']=$oTopic->getDateAdd();
        
$item['author']=$oTopic->getUser()->getLogin();
        
$item['category']=htmlspecialchars($oTopic->getTags());
        
$topics[]=$item;
    }
    
/**
     * Формируем ответ
     */
    
$this->InitRss();
    
$this->Viewer_Assign('aChannel',$aChannel);
    
$this->Viewer_Assign('aItems',$topics);
    
$this->SetTemplateAction('index');
}

Вывод RSS топиков по определенному тегу

RssTopicComments() method
protected void RssTopicComments()
Source Code: /classes/actions/ActionRss.class.php#178 (show)
protected function RssTopicComments() {
    
$sTopicId=$this->GetParam(0);
    
/**
     * Топик существует?
     */
    
if (!($oTopic=$this->Topic_GetTopicById($sTopicId)) or !$oTopic->getPublish() or $oTopic->getBlog()->getType()=='close') {
        return 
parent::EventNotFound();
    }
    
/**
     * Получаем комментарии
     */
    
$aResult=$this->Comment_GetCommentsByFilter(array('target_id'=>$oTopic->getId(),'target_type'=>'topic','delete'=>0),array('comment_id'=>'desc'),1,100);
    
$aComments=$aResult['collection'];
    
/**
     * Формируем данные канала RSS
     */
    
$aChannel['title']=Config::Get('view.name');
    
$aChannel['link']=Config::Get('path.root.web');
    
$aChannel['description']=Config::Get('path.root.web').' / RSS channel';
    
$aChannel['language']='ru';
    
$aChannel['managingEditor']=Config::Get('general.rss_editor_mail');
    
$aChannel['generator']=Config::Get('path.root.web');
    
/**
     * Формируем записи RSS
     */
    
$comments=array();
    foreach (
$aComments as $oComment){
        
$item['title']='Comments: '.$oTopic->getTitle();
        
$item['guid']=$oTopic->getUrl().'#comment'.$oComment->getId();
        
$item['link']=$oTopic->getUrl().'#comment'.$oComment->getId();
        
$item['description']=$oComment->getText();
        
$item['pubDate']=$oComment->getDate();
        
$item['author']=$oComment->getUser()->getLogin();
        
$item['category']='comments';
        
$comments[]=$item;
    }
    
/**
     * Формируем ответ
     */
    
$this->InitRss();
    
$this->Viewer_Assign('aChannel',$aChannel);
    
$this->Viewer_Assign('aItems',$comments);
    
$this->SetTemplateAction('index');
}

Вывод RSS комментариев конкретного топика

getTopicText() method
protected void getTopicText($oTopic)
$oTopic
Source Code: /classes/actions/ActionRss.class.php#364 (show)
protected function getTopicText($oTopic) {
    
$sText=$oTopic->getTextShort();
    if (
$oTopic->getTextShort()!=$oTopic->getText()) {
        
$sText.="<br><a href=\"{$oTopic->getUrl()}#cut\" title=\"{$this->Lang_Get('topic_read_more')}\">";
        if (
$oTopic->getCutText()) {
            
$sText.=htmlspecialchars($oTopic->getCutText());
        } else {
            
$sText.=$this->Lang_Get('topic_read_more');
        }
        
$sText.="</a>";
    }
    return 
$sText;
}

Формирует текст топика для RSS