1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 03:30:48 +03:00
ifhub.club/classes/actions/ActionBlogs.class.php

136 lines
4.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
/**
* Экшен обработки УРЛа вида /comments/
*
* @package actions
* @since 1.0
*/
class ActionBlogs extends Action {
/**
* Инициализация
*/
public function Init() {
/**
* Загружаем в шаблон JS текстовки
*/
$this->Lang_AddLangJs(array(
'blog_join','blog_leave'
));
}
/**
* Регистрируем евенты
*/
protected function RegisterEvent() {
$this->AddEventPreg('/^(page([1-9]\d{0,5}))?$/i','EventShowBlogs');
$this->AddEventPreg('/^ajax-search$/i','EventAjaxSearch');
}
/**********************************************************************************
************************ РЕАЛИЗАЦИЯ ЭКШЕНА ***************************************
**********************************************************************************
*/
/**
* Поиск блогов по названию
*/
protected function EventAjaxSearch() {
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('json');
/**
* Получаем из реквеста первые буквы блога
*/
if ($sTitle=getRequestStr('blog_title')) {
$sTitle=str_replace('%','',$sTitle);
}
if (!$sTitle) {
$this->Message_AddErrorSingle($this->Lang_Get('system_error'));
return;
}
/**
* Ищем блоги
*/
$aResult=$this->Blog_GetBlogsByFilter(array('exclude_type' => 'personal','title'=>"%{$sTitle}%"),array('blog_title'=>'asc'),1,100);
/**
* Формируем и возвращает ответ
*/
$oViewer=$this->Viewer_GetLocalViewer();
$oViewer->Assign('aBlogs',$aResult['collection']);
$oViewer->Assign('oUserCurrent',$this->User_GetUserCurrent());
$oViewer->Assign('sBlogsEmptyList',$this->Lang_Get('blogs_search_empty'));
$this->Viewer_AssignAjax('sText',$oViewer->Fetch("blog_list.tpl"));
}
/**
* Отображение списка блогов
*/
protected function EventShowBlogs() {
/**
* По какому полю сортировать
*/
$sOrder='blog_rating';
if (getRequest('order')) {
$sOrder=getRequestStr('order');
}
/**
* В каком направлении сортировать
*/
$sOrderWay='desc';
if (getRequest('order_way')) {
$sOrderWay=getRequestStr('order_way');
}
/**
* Фильтр поиска блогов
*/
$aFilter=array(
'exclude_type' => 'personal'
);
/**
* Передан ли номер страницы
*/
$iPage= preg_match("/^\d+$/i",$this->GetEventMatch(2)) ? $this->GetEventMatch(2) : 1;
/**
* Получаем список блогов
*/
$aResult=$this->Blog_GetBlogsByFilter($aFilter,array($sOrder=>$sOrderWay),$iPage,Config::Get('module.blog.per_page'));
$aBlogs=$aResult['collection'];
/**
* Формируем постраничность
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.blog.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('blogs'),array('order'=>$sOrder,'order_way'=>$sOrderWay));
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aPaging',$aPaging);
$this->Viewer_Assign("aBlogs",$aBlogs);
$this->Viewer_Assign("sBlogOrder",htmlspecialchars($sOrder));
$this->Viewer_Assign("sBlogOrderWay",htmlspecialchars($sOrderWay));
$this->Viewer_Assign("sBlogOrderWayNext",htmlspecialchars($sOrderWay=='desc' ? 'asc' : 'desc'));
/**
* Устанавливаем title страницы
*/
$this->Viewer_AddHtmlTitle($this->Lang_Get('blog_menu_all_list'));
/**
* Устанавливаем шаблон вывода
*/
$this->SetTemplateAction('index');
}
}
?>