ActionComments

Package actions
Inheritance class ActionComments » Action » LsObject
Since 1.0
Source Code /classes/actions/ActionComments.class.php
Экшен обработки УРЛа вида /comments/

Protected Properties

Hide inherited properties

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

Public Methods

Hide inherited methods

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

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
AddEvent() Добавляет евент в экшен Action
AddEventPreg() Добавляет евент в экшен, используя регулярное вырожение для евента и параметров Action
EventComments() Выводим список комментариев ActionComments
EventNotFound() Вызывается в том случаи если не найден евент который запросили через URL Action
EventShowComment() Обрабатывает ссылку на конкретный комментарий, определят к какому топику он относится и перенаправляет на него ActionComments
GetEventMatch() Возвращает элементы совпадения по регулярному выражению для евента Action
GetParamEventMatch() Возвращает элементы совпадения по регулярному выражению для параметров евента Action
RegisterEvent() Регистрация евентов ActionComments
SetTemplate() Устанавливает какой шаблон выводить Action
SetTemplateAction() Устанавливает какой шаблон выводить Action

Property Details

oUserCurrent property
protected ModuleUser_EntityUser|null $oUserCurrent;

Текущий юзер

sMenuHeadItemSelect property
protected string $sMenuHeadItemSelect;

Главное меню

Method Details

EventComments() method
protected void EventComments()
Source Code: /classes/actions/ActionComments.class.php#62 (show)
protected function EventComments() {
    
/**
     * Передан ли номер страницы
     */
    
$iPage=$this->GetEventMatch(2) ? $this->GetEventMatch(2) : 1;
    
/**
     * Исключаем из выборки идентификаторы закрытых блогов (target_parent_id)
     */
    
$aCloseBlogs = ($this->oUserCurrent)
        ? 
$this->Blog_GetInaccessibleBlogsByUser($this->oUserCurrent)
        : 
$this->Blog_GetInaccessibleBlogsByUser();
    
/**
     * Получаем список комментов
     */
    
$aResult=$this->Comment_GetCommentsAll('topic',$iPage,Config::Get('module.comment.per_page'),array(),$aCloseBlogs);
    
$aComments=$aResult['collection'];
    
/**
     * Формируем постраничность
     */
    
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.comment.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('comments'));
    
/**
     * Загружаем переменные в шаблон
     */
    
$this->Viewer_Assign('aPaging',$aPaging);
    
$this->Viewer_Assign("aComments",$aComments);
    
/**
     * Устанавливаем title страницы
     */
    
$this->Viewer_AddHtmlTitle($this->Lang_Get('comments_all'));
    
$this->Viewer_SetHtmlRssAlternate(Router::GetPath('rss').'allcomments/',$this->Lang_Get('comments_all'));
    
/**
     * Устанавливаем шаблон вывода
     */
    
$this->SetTemplateAction('index');
}

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

EventShowComment() method
protected void EventShowComment()
Source Code: /classes/actions/ActionComments.class.php#101 (show)
protected function EventShowComment() {
    
$iCommentId=$this->sCurrentEvent;
    
/**
     * Проверяем к чему относится комментарий
     */
    
if (!($oComment=$this->Comment_GetCommentById($iCommentId))) {
        return 
parent::EventNotFound();
    }
    if (
$oComment->getTargetType()!='topic' or !($oTopic=$oComment->getTarget())) {
        return 
parent::EventNotFound();
    }
    
/**
     * Определяем необходимую страницу для отображения комментария
     */
    
if (!Config::Get('module.comment.use_nested') or !Config::Get('module.comment.nested_per_page')) {
        
Router::Location($oTopic->getUrl().'#comment'.$oComment->getId());
    }
    
$iPage=$this->Comment_GetPageCommentByTargetId($oComment->getTargetId(),$oComment->getTargetType(),$oComment);
    if (
$iPage==1) {
        
Router::Location($oTopic->getUrl().'#comment'.$oComment->getId());
    } else {
        
Router::Location($oTopic->getUrl()."?cmtpage={$iPage}#comment".$oComment->getId());
    }
    exit();
}

Обрабатывает ссылку на конкретный комментарий, определят к какому топику он относится и перенаправляет на него Актуально при использовании постраничности комментариев

EventShutdown() method
public void EventShutdown()
Source Code: /classes/actions/ActionComments.class.php#130 (show)
public function EventShutdown() {
    
/**
     * Загружаем в шаблон необходимые переменные
     */
    
$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
}

Выполняется при завершении работы экшена

Init() method
public void Init()
Source Code: /classes/actions/ActionComments.class.php#41 (show)
public function Init() {
    
$this->oUserCurrent=$this->User_GetUserCurrent();
}

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

RegisterEvent() method
protected void RegisterEvent()
Source Code: /classes/actions/ActionComments.class.php#47 (show)
protected function RegisterEvent() {
    
$this->AddEventPreg('/^(page([1-9]\d{0,5}))?$/i','EventComments');
    
$this->AddEventPreg('/^\d+$/i','EventShowComment');
}

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