ActionIndex
Package | actions |
---|---|
Inheritance | class ActionIndex » Action » LsObject |
Since | 1.0 |
Source Code | /classes/actions/ActionIndex.class.php |
Обработка главной страницы, т.е. УРЛа вида /index/
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
aParams | array | Список параметров из URL | Action |
aParamsEventMatch | array | Список совпадений по регулярному выражению для евента | Action |
aRegisterEvent | array | Список зарегистрированных евентов | Action |
iCountTopicsCollectiveNew | int | Число новых топиков в коллективных блогах | ActionIndex |
iCountTopicsNew | int | Число новых топиков | ActionIndex |
iCountTopicsPersonalNew | int | Число новых топиков в персональных блогах | ActionIndex |
oEngine | Engine|null | Объект ядра | Action |
sActionTemplate | string|null | Шаблон экшена | Action |
sCurrentAction | null|string | Текущий экшен | Action |
sCurrentEvent | string|null | Текущий евент | Action |
sCurrentEventName | string|null | Имя текущий евента | Action |
sDefaultEvent | string|null | Дефолтный евент | Action |
sMenuHeadItemSelect | string | Главное меню | ActionIndex |
sMenuItemSelect | string | Меню | ActionIndex |
sMenuSubItemSelect | string | Субменю | ActionIndex |
Public Methods
Method | Description | Defined By |
---|---|---|
EventShutdown() | При завершении экшена загружаем переменные в шаблон | ActionIndex |
ExecEvent() | Запускает евент на выполнение | Action |
GetActionClass() | Получить каталог с шаблонами экшена(совпадает с именем класса) | Action |
GetCurrentEventName() | Возвращает имя евента | Action |
GetDefaultEvent() | Получает евент по умолчанию | Action |
GetParam() | Получает параметр из URL по его номеру, если его нет то null | Action |
GetParams() | Получает список параметров из УРЛ | Action |
GetTemplate() | Получить шаблон | Action |
Init() | Инициализация | ActionIndex |
SetDefaultEvent() | Устанавливает евент по умолчанию | Action |
SetParam() | Установить значение параметра(эмуляция параметра в URL). | Action |
__call() | Ставим хук на вызов неизвестного метода и считаем что хотели вызвать метод какого либо модуля | Action |
__construct() | Конструктор | Action |
Protected Methods
Method | Description | Defined By |
---|---|---|
AddEvent() | Добавляет евент в экшен | Action |
AddEventPreg() | Добавляет евент в экшен, используя регулярное вырожение для евента и параметров | Action |
EventDiscussed() | Вывод обсуждаемых топиков | ActionIndex |
EventIndex() | Вывод интересных на главную | ActionIndex |
EventNew() | Вывод новых топиков | ActionIndex |
EventNewAll() | Вывод ВСЕХ новых топиков | ActionIndex |
EventNotFound() | Вызывается в том случаи если не найден евент который запросили через URL | Action |
EventTop() | Вывод рейтинговых топиков | ActionIndex |
GetEventMatch() | Возвращает элементы совпадения по регулярному выражению для евента | Action |
GetParamEventMatch() | Возвращает элементы совпадения по регулярному выражению для параметров евента | Action |
RegisterEvent() | Регистрация евентов | ActionIndex |
SetTemplate() | Устанавливает какой шаблон выводить | Action |
SetTemplateAction() | Устанавливает какой шаблон выводить | Action |
Property Details
iCountTopicsCollectiveNew
property
protected int $iCountTopicsCollectiveNew;
Число новых топиков в коллективных блогах
iCountTopicsNew
property
protected int $iCountTopicsNew;
Число новых топиков
iCountTopicsPersonalNew
property
protected int $iCountTopicsPersonalNew;
Число новых топиков в персональных блогах
sMenuHeadItemSelect
property
protected string $sMenuHeadItemSelect;
Главное меню
sMenuItemSelect
property
protected string $sMenuItemSelect;
Меню
sMenuSubItemSelect
property
protected string $sMenuSubItemSelect;
Субменю
Method Details
EventDiscussed()
method
protected void EventDiscussed()
|
Source Code: /classes/actions/ActionIndex.class.php#146 (show)
protected function EventDiscussed() {
$sPeriod=1; // по дефолту 1 день
if (in_array(getRequest('period'),array(1,7,30,'all'))) {
$sPeriod=getRequest('period');
}
/**
* Меню
*/
$this->sMenuSubItemSelect='discussed';
/**
* Передан ли номер страницы
*/
$iPage=$this->GetParamEventMatch(0,2) ? $this->GetParamEventMatch(0,2) : 1;
if ($iPage==1 and !getRequest('period')) {
$this->Viewer_SetHtmlCanonical(Router::GetPath('index').'discussed/');
}
/**
* Получаем список топиков
*/
$aResult=$this->Topic_GetTopicsDiscussed($iPage,Config::Get('module.topic.per_page'),$sPeriod=='all' ? null : $sPeriod*60*60*24);
/**
* Если нет топиков за 1 день, то показываем за неделю (7)
*/
if (!$aResult['count'] and $iPage==1 and !getRequest('period')) {
$sPeriod=7;
$aResult=$this->Topic_GetTopicsDiscussed($iPage,Config::Get('module.topic.per_page'),$sPeriod=='all' ? null : $sPeriod*60*60*24);
}
$aTopics=$aResult['collection'];
/**
* Вызов хуков
*/
$this->Hook_Run('topics_list_show',array('aTopics'=>$aTopics));
/**
* Формируем постраничность
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.topic.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('index').'discussed',array('period'=>$sPeriod));
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aTopics',$aTopics);
$this->Viewer_Assign('aPaging',$aPaging);
$this->Viewer_Assign('sPeriodSelectCurrent',$sPeriod);
$this->Viewer_Assign('sPeriodSelectRoot',Router::GetPath('index').'discussed/');
/**
* Устанавливаем шаблон вывода
*/
$this->SetTemplateAction('index');
}
Вывод обсуждаемых топиков
EventIndex()
method
protected void EventIndex()
|
Source Code: /classes/actions/ActionIndex.class.php#270 (show)
protected function EventIndex() {
$this->Viewer_SetHtmlRssAlternate(Router::GetPath('rss').'index/',Config::Get('view.name'));
/**
* Меню
*/
$this->sMenuSubItemSelect='good';
/**
* Передан ли номер страницы
*/
$iPage=$this->GetEventMatch(2) ? $this->GetEventMatch(2) : 1;
/**
* Устанавливаем основной URL для поисковиков
*/
if ($iPage==1) {
$this->Viewer_SetHtmlCanonical(Config::Get('path.root.web').'/');
}
/**
* Получаем список топиков
*/
$aResult=$this->Topic_GetTopicsGood($iPage,Config::Get('module.topic.per_page'));
$aTopics=$aResult['collection'];
/**
* Вызов хуков
*/
$this->Hook_Run('topics_list_show',array('aTopics'=>$aTopics));
/**
* Формируем постраничность
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.topic.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('index'));
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aTopics',$aTopics);
$this->Viewer_Assign('aPaging',$aPaging);
/**
* Устанавливаем шаблон вывода
*/
$this->SetTemplateAction('index');
}
Вывод интересных на главную
EventNew()
method
protected void EventNew()
|
Source Code: /classes/actions/ActionIndex.class.php#197 (show)
protected function EventNew() {
$this->Viewer_SetHtmlRssAlternate(Router::GetPath('rss').'new/',Config::Get('view.name'));
/**
* Меню
*/
$this->sMenuSubItemSelect='new';
/**
* Передан ли номер страницы
*/
$iPage=$this->GetParamEventMatch(0,2) ? $this->GetParamEventMatch(0,2) : 1;
/**
* Получаем список топиков
*/
$aResult=$this->Topic_GetTopicsNew($iPage,Config::Get('module.topic.per_page'));
$aTopics=$aResult['collection'];
/**
* Вызов хуков
*/
$this->Hook_Run('topics_list_show',array('aTopics'=>$aTopics));
/**
* Формируем постраничность
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.topic.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('index').'new');
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aTopics',$aTopics);
$this->Viewer_Assign('aPaging',$aPaging);
/**
* Устанавливаем шаблон вывода
*/
$this->SetTemplateAction('index');
}
Вывод новых топиков
EventNewAll()
method
protected void EventNewAll()
|
Source Code: /classes/actions/ActionIndex.class.php#233 (show)
protected function EventNewAll() {
$this->Viewer_SetHtmlRssAlternate(Router::GetPath('rss').'new/',Config::Get('view.name'));
/**
* Меню
*/
$this->sMenuSubItemSelect='new';
/**
* Передан ли номер страницы
*/
$iPage=$this->GetParamEventMatch(0,2) ? $this->GetParamEventMatch(0,2) : 1;
/**
* Получаем список топиков
*/
$aResult=$this->Topic_GetTopicsNewAll($iPage,Config::Get('module.topic.per_page'));
$aTopics=$aResult['collection'];
/**
* Вызов хуков
*/
$this->Hook_Run('topics_list_show',array('aTopics'=>$aTopics));
/**
* Формируем постраничность
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.topic.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('index').'newall');
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aTopics',$aTopics);
$this->Viewer_Assign('aPaging',$aPaging);
/**
* Устанавливаем шаблон вывода
*/
$this->SetTemplateAction('index');
}
Вывод ВСЕХ новых топиков
EventShutdown()
method
public void EventShutdown()
|
Source Code: /classes/actions/ActionIndex.class.php#313 (show)
public function EventShutdown() {
$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
$this->Viewer_Assign('sMenuItemSelect',$this->sMenuItemSelect);
$this->Viewer_Assign('sMenuSubItemSelect',$this->sMenuSubItemSelect);
$this->Viewer_Assign('iCountTopicsNew',$this->iCountTopicsNew);
$this->Viewer_Assign('iCountTopicsCollectiveNew',$this->iCountTopicsCollectiveNew);
$this->Viewer_Assign('iCountTopicsPersonalNew',$this->iCountTopicsPersonalNew);
}
При завершении экшена загружаем переменные в шаблон
EventTop()
method
protected void EventTop()
|
Source Code: /classes/actions/ActionIndex.class.php#95 (show)
protected function EventTop() {
$sPeriod=1; // по дефолту 1 день
if (in_array(getRequest('period'),array(1,7,30,'all'))) {
$sPeriod=getRequest('period');
}
/**
* Меню
*/
$this->sMenuSubItemSelect='top';
/**
* Передан ли номер страницы
*/
$iPage=$this->GetParamEventMatch(0,2) ? $this->GetParamEventMatch(0,2) : 1;
if ($iPage==1 and !getRequest('period')) {
$this->Viewer_SetHtmlCanonical(Router::GetPath('index').'top/');
}
/**
* Получаем список топиков
*/
$aResult=$this->Topic_GetTopicsTop($iPage,Config::Get('module.topic.per_page'),$sPeriod=='all' ? null : $sPeriod*60*60*24);
/**
* Если нет топиков за 1 день, то показываем за неделю (7)
*/
if (!$aResult['count'] and $iPage==1 and !getRequest('period')) {
$sPeriod=7;
$aResult=$this->Topic_GetTopicsTop($iPage,Config::Get('module.topic.per_page'),$sPeriod=='all' ? null : $sPeriod*60*60*24);
}
$aTopics=$aResult['collection'];
/**
* Вызов хуков
*/
$this->Hook_Run('topics_list_show',array('aTopics'=>$aTopics));
/**
* Формируем постраничность
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.topic.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('index').'top',array('period'=>$sPeriod));
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aTopics',$aTopics);
$this->Viewer_Assign('aPaging',$aPaging);
$this->Viewer_Assign('sPeriodSelectCurrent',$sPeriod);
$this->Viewer_Assign('sPeriodSelectRoot',Router::GetPath('index').'top/');
/**
* Устанавливаем шаблон вывода
*/
$this->SetTemplateAction('index');
}
Вывод рейтинговых топиков
Init()
method
public void Init()
|
Source Code: /classes/actions/ActionIndex.class.php#66 (show)
public function Init() {
/**
* Подсчитываем новые топики
*/
$this->iCountTopicsCollectiveNew=$this->Topic_GetCountTopicsCollectiveNew();
$this->iCountTopicsPersonalNew=$this->Topic_GetCountTopicsPersonalNew();
$this->iCountTopicsNew=$this->iCountTopicsCollectiveNew+$this->iCountTopicsPersonalNew;
}
Инициализация
RegisterEvent()
method
protected void RegisterEvent()
|
Source Code: /classes/actions/ActionIndex.class.php#78 (show)
protected function RegisterEvent() {
$this->AddEventPreg('/^(page([1-9]\d{0,5}))?$/i','EventIndex');
$this->AddEventPreg('/^new$/i','/^(page([1-9]\d{0,5}))?$/i','EventNew');
$this->AddEventPreg('/^newall$/i','/^(page([1-9]\d{0,5}))?$/i','EventNewAll');
$this->AddEventPreg('/^discussed/i','/^(page([1-9]\d{0,5}))?$/i','EventDiscussed');
$this->AddEventPreg('/^top/i','/^(page([1-9]\d{0,5}))?$/i','EventTop');
}
Регистрация евентов