2009-05-10 10:50:39 +03:00
|
|
|
|
<?php
|
2008-10-26 17:51:03 +02:00
|
|
|
|
/*-------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* 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/
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class ActionBlogs extends Action {
|
|
|
|
|
|
2010-02-06 02:09:44 +02:00
|
|
|
|
public function Init() {
|
2011-08-23 17:19:32 +03:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем в шаблон JS текстовки
|
|
|
|
|
*/
|
|
|
|
|
$this->Lang_AddLangJs(array(
|
|
|
|
|
'blog_join','blog_leave'
|
|
|
|
|
));
|
2008-10-26 17:51:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function RegisterEvent() {
|
2012-03-30 12:52:36 +03:00
|
|
|
|
$this->AddEventPreg('/^(page(\d+))?$/i','EventShowBlogs');
|
|
|
|
|
$this->AddEventPreg('/^ajax-search$/i','EventAjaxSearch');
|
2008-10-26 17:51:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************************
|
|
|
|
|
************************ РЕАЛИЗАЦИЯ ЭКШЕНА ***************************************
|
|
|
|
|
**********************************************************************************
|
|
|
|
|
*/
|
2012-03-30 12:52:36 +03:00
|
|
|
|
|
2012-03-30 17:09:32 +03:00
|
|
|
|
/**
|
|
|
|
|
* Поиск блогов
|
|
|
|
|
*/
|
2012-03-30 12:52:36 +03:00
|
|
|
|
protected function EventAjaxSearch() {
|
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
|
|
|
|
|
if ($sTitle=getRequest('blog_title') and is_string($sTitle)) {
|
|
|
|
|
$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('sBlogsEmptyList',$this->Lang_Get('blogs_search_empty'));
|
|
|
|
|
$this->Viewer_AssignAjax('sText',$oViewer->Fetch("blog_list.tpl"));
|
|
|
|
|
}
|
2008-10-26 17:51:03 +02:00
|
|
|
|
|
2012-03-30 12:52:36 +03:00
|
|
|
|
protected function EventShowBlogs() {
|
|
|
|
|
/**
|
|
|
|
|
* По какому полю сортировать
|
|
|
|
|
*/
|
|
|
|
|
$sOrder='blog_rating';
|
|
|
|
|
if (getRequest('order')) {
|
|
|
|
|
$sOrder=getRequest('order');
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* В каком направлении сортировать
|
|
|
|
|
*/
|
|
|
|
|
$sOrderWay='desc';
|
|
|
|
|
if (getRequest('order_way')) {
|
|
|
|
|
$sOrderWay=getRequest('order_way');
|
|
|
|
|
}
|
|
|
|
|
$aFilter=array(
|
|
|
|
|
'exclude_type' => 'personal'
|
|
|
|
|
);
|
|
|
|
|
|
2008-10-26 17:51:03 +02:00
|
|
|
|
/**
|
|
|
|
|
* Передан ли номер страницы
|
|
|
|
|
*/
|
|
|
|
|
$iPage= preg_match("/^\d+$/i",$this->GetEventMatch(2)) ? $this->GetEventMatch(2) : 1;
|
|
|
|
|
/**
|
|
|
|
|
* Получаем список блогов
|
|
|
|
|
*/
|
2012-03-30 12:52:36 +03:00
|
|
|
|
|
|
|
|
|
$aResult=$this->Blog_GetBlogsByFilter($aFilter,array($sOrder=>$sOrderWay),$iPage,Config::Get('module.blog.per_page'));
|
2008-10-26 17:51:03 +02:00
|
|
|
|
$aBlogs=$aResult['collection'];
|
|
|
|
|
/**
|
|
|
|
|
* Формируем постраничность
|
|
|
|
|
*/
|
2012-03-30 12:52:36 +03:00
|
|
|
|
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.blog.per_page'),4,Router::GetPath('blogs'),array('order'=>$sOrder,'order_way'=>$sOrderWay));
|
2008-10-26 17:51:03 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_Assign('aPaging',$aPaging);
|
|
|
|
|
$this->Viewer_Assign("aBlogs",$aBlogs);
|
2012-03-30 12:52:36 +03:00
|
|
|
|
$this->Viewer_Assign("sBlogOrder",htmlspecialchars($sOrder));
|
|
|
|
|
$this->Viewer_Assign("sBlogOrderWay",htmlspecialchars($sOrderWay));
|
|
|
|
|
$this->Viewer_Assign("sBlogOrderWayNext",htmlspecialchars($sOrderWay=='desc' ? 'asc' : 'desc'));
|
2009-01-10 21:23:36 +02:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('blog_menu_all_list'));
|
2008-10-26 17:51:03 +02:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
|
|
|
|
$this->SetTemplateAction('index');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|