1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-02 22:45:02 +03:00
ifhub.club/classes/actions/ActionPeople.class.php

307 lines
9.2 KiB
PHP
Raw Normal View History

<?php
2008-09-21 09:36:57 +03: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
*
---------------------------------------------------------
*/
/**
* Экшен обработки статистики юзеров, т.е. УРЛа вида /people/
2008-09-21 09:36:57 +03:00
*
* @package actions
* @since 1.0
2008-09-21 09:36:57 +03:00
*/
class ActionPeople extends Action {
2012-04-13 20:37:50 +03:00
/**
* Главное меню
*
* @var string
2012-04-13 20:37:50 +03:00
*/
protected $sMenuHeadItemSelect='people';
/**
* Меню
*
* @var string
*/
2012-04-20 13:36:07 +03:00
protected $sMenuItemSelect='all';
2012-04-16 17:40:14 +03:00
2008-09-21 09:36:57 +03:00
/**
* Инициализация
*
*/
public function Init() {
/**
* Устанавливаем title страницы
*/
$this->Viewer_AddHtmlTitle($this->Lang_Get('people'));
2008-09-21 09:36:57 +03:00
}
/**
* Регистрируем евенты
*
*/
2012-04-16 17:40:14 +03:00
protected function RegisterEvent() {
$this->AddEvent('online','EventOnline');
$this->AddEvent('new','EventNew');
$this->AddEventPreg('/^(index)?$/i','/^(page(\d+))?$/i','/^$/i','EventIndex');
$this->AddEventPreg('/^ajax-search$/i','EventAjaxSearch');
$this->AddEventPreg('/^country$/i','/^\d+$/i','/^(page(\d+))?$/i','EventCountry');
$this->AddEventPreg('/^city$/i','/^\d+$/i','/^(page(\d+))?$/i','EventCity');
2008-09-21 09:36:57 +03:00
}
2012-04-16 17:40:14 +03:00
2008-09-21 09:36:57 +03:00
/**********************************************************************************
************************ РЕАЛИЗАЦИЯ ЭКШЕНА ***************************************
**********************************************************************************
*/
/**
* Поиск пользователей по логину
*/
protected function EventAjaxSearch() {
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('json');
/**
* Получаем из реквеста первые быквы для поиска пользователей по логину
*/
2012-04-16 17:40:14 +03:00
$sTitle=getRequest('user_login');
if (is_string($sTitle) and mb_strlen($sTitle,'utf-8')) {
$sTitle=str_replace(array('_','%'),array('\_','\%'),$sTitle);
} else {
$this->Message_AddErrorSingle($this->Lang_Get('system_error'));
return;
}
/**
* Как именно искать: совпадение в любой частилогина, или только начало или конец логина
*/
if (getRequest('isPrefix')) {
$sTitle.='%';
} elseif (getRequest('isPostfix')) {
$sTitle='%'.$sTitle;
} else {
$sTitle='%'.$sTitle.'%';
}
/**
* Ищем пользователей
*/
2012-04-13 03:31:51 +03:00
$aResult=$this->User_GetUsersByFilter(array('activate' => 1,'login'=>$sTitle),array('user_rating'=>'desc'),1,50);
/**
* Формируем ответ
*/
$oViewer=$this->Viewer_GetLocalViewer();
$oViewer->Assign('aUsersList',$aResult['collection']);
2012-05-11 17:10:47 +03:00
$oViewer->Assign('oUserCurrent',$this->User_GetUserCurrent());
$oViewer->Assign('sUserListEmpty',$this->Lang_Get('user_search_empty'));
$this->Viewer_AssignAjax('sText',$oViewer->Fetch("user_list.tpl"));
}
/**
* Показывает юзеров по стране
*
*/
2012-04-16 17:40:14 +03:00
protected function EventCountry() {
/**
* Страна существует?
*/
if (!($oCountry=$this->Geo_GetCountryById($this->getParam(0)))) {
2009-04-07 17:59:43 +03:00
return parent::EventNotFound();
}
/**
* Получаем статистику
*/
2012-04-16 17:40:14 +03:00
$this->GetStats();
/**
* Передан ли номер страницы
*/
2012-04-16 17:40:14 +03:00
$iPage=$this->GetParamEventMatch(1,2) ? $this->GetParamEventMatch(1,2) : 1;
/**
* Получаем список вязей пользователей со страной
2012-04-16 17:40:14 +03:00
*/
$aResult=$this->Geo_GetTargets(array('country_id'=>$oCountry->getId(),'target_type'=>'user'),$iPage,Config::Get('module.user.per_page'));
$aUsersId=array();
foreach($aResult['collection'] as $oTarget) {
$aUsersId[]=$oTarget->getTargetId();
}
$aUsersCountry=$this->User_GetUsersAdditionalData($aUsersId);
/**
* Формируем постраничность
2012-04-16 17:40:14 +03:00
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.user.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('people').$this->sCurrentEvent.'/'.$oCountry->getId());
/**
* Загружаем переменные в шаблон
*/
if ($aUsersCountry) {
2012-04-16 17:40:14 +03:00
$this->Viewer_Assign('aPaging',$aPaging);
}
$this->Viewer_Assign('oCountry',$oCountry);
2012-04-16 17:40:14 +03:00
$this->Viewer_Assign('aUsersCountry',$aUsersCountry);
}
/**
* Показывает юзеров по городу
*
*/
2012-04-16 17:40:14 +03:00
protected function EventCity() {
/**
* Город существует?
*/
if (!($oCity=$this->Geo_GetCityById($this->getParam(0)))) {
2009-04-07 17:59:43 +03:00
return parent::EventNotFound();
}
/**
* Получаем статистику
*/
2012-04-16 17:40:14 +03:00
$this->GetStats();
/**
* Передан ли номер страницы
*/
2012-04-16 17:40:14 +03:00
$iPage=$this->GetParamEventMatch(1,2) ? $this->GetParamEventMatch(1,2) : 1;
/**
* Получаем список юзеров
*/
$aResult=$this->Geo_GetTargets(array('city_id'=>$oCity->getId(),'target_type'=>'user'),$iPage,Config::Get('module.user.per_page'));
$aUsersId=array();
foreach($aResult['collection'] as $oTarget) {
$aUsersId[]=$oTarget->getTargetId();
}
$aUsersCity=$this->User_GetUsersAdditionalData($aUsersId);
/**
* Формируем постраничность
2012-04-16 17:40:14 +03:00
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.user.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('people').$this->sCurrentEvent.'/'.$oCity->getId());
/**
* Загружаем переменные в шаблон
*/
if ($aUsersCity) {
2012-04-16 17:40:14 +03:00
$this->Viewer_Assign('aPaging',$aPaging);
}
$this->Viewer_Assign('oCity',$oCity);
2012-04-16 17:40:14 +03:00
$this->Viewer_Assign('aUsersCity',$aUsersCity);
}
/**
* Показываем последних на сайте
*
*/
protected function EventOnline() {
2012-04-20 13:36:07 +03:00
$this->sMenuItemSelect='online';
2009-08-08 12:33:32 +03:00
/**
* Последние по визиту на сайт
*/
$aUsersLast=$this->User_GetUsersByDateLast(15);
$this->Viewer_Assign('aUsersLast',$aUsersLast);
/**
* Получаем статистику
*/
2012-04-16 17:40:14 +03:00
$this->GetStats();
}
/**
* Показываем новых на сайте
*
*/
protected function EventNew() {
2012-04-20 13:36:07 +03:00
$this->sMenuItemSelect='new';
2009-08-08 12:33:32 +03:00
/**
* Последние по регистрации
*/
$aUsersRegister=$this->User_GetUsersByDateRegister(15);
$this->Viewer_Assign('aUsersRegister',$aUsersRegister);
/**
* Получаем статистику
*/
2012-04-16 17:40:14 +03:00
$this->GetStats();
}
2008-09-21 09:36:57 +03:00
/**
* Показываем юзеров
2008-09-21 09:36:57 +03:00
*
*/
protected function EventIndex() {
2008-09-21 09:36:57 +03:00
/**
* Получаем статистику
*/
$this->GetStats();
2008-09-21 09:36:57 +03:00
/**
* По какому полю сортировать
2008-09-21 09:36:57 +03:00
*/
$sOrder='user_rating';
if (getRequest('order')) {
$sOrder=getRequest('order');
}
2008-09-21 09:36:57 +03:00
/**
* В каком направлении сортировать
*/
$sOrderWay='desc';
if (getRequest('order_way')) {
$sOrderWay=getRequest('order_way');
}
$aFilter=array(
'activate' => 1
);
2008-09-21 09:36:57 +03:00
/**
* Передан ли номер страницы
2008-09-21 09:36:57 +03:00
*/
$iPage=$this->GetParamEventMatch(0,2) ? $this->GetParamEventMatch(0,2) : 1;
2008-09-21 09:36:57 +03:00
/**
* Получаем список юзеров
2008-09-21 09:36:57 +03:00
*/
$aResult=$this->User_GetUsersByFilter($aFilter,array($sOrder=>$sOrderWay),$iPage,Config::Get('module.user.per_page'));
$aUsers=$aResult['collection'];
/**
* Формируем постраничность
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.user.per_page'),Config::Get('pagination.pages.count'),Router::GetPath('people').'index',array('order'=>$sOrder,'order_way'=>$sOrderWay));
/**
* Получаем алфавитный указатель на список пользователей
*/
$aPrefixUser=$this->User_GetGroupPrefixUser(1);
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aPaging',$aPaging);
$this->Viewer_Assign('aUsersRating',$aUsers);
$this->Viewer_Assign('aPrefixUser',$aPrefixUser);
$this->Viewer_Assign("sUsersOrder",htmlspecialchars($sOrder));
$this->Viewer_Assign("sUsersOrderWay",htmlspecialchars($sOrderWay));
$this->Viewer_Assign("sUsersOrderWayNext",htmlspecialchars($sOrderWay=='desc' ? 'asc' : 'desc'));
2008-09-21 09:36:57 +03:00
/**
* Устанавливаем шаблон вывода
2012-04-16 17:40:14 +03:00
*/
2008-09-21 09:36:57 +03:00
$this->SetTemplateAction('index');
}
/**
* Получение статистики
*
*/
protected function GetStats() {
/**
* Статистика кто, где и т.п.
*/
2012-04-16 17:40:14 +03:00
$aStat=$this->User_GetStatUsers();
2008-09-21 09:36:57 +03:00
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aStat',$aStat);
}
2012-04-13 20:37:50 +03:00
/**
* Выполняется при завершении работы экшена
*
*/
public function EventShutdown() {
/**
* Загружаем в шаблон необходимые переменные
*/
$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
2012-04-20 13:36:07 +03:00
$this->Viewer_Assign('sMenuItemSelect',$this->sMenuItemSelect);
2012-04-13 20:37:50 +03:00
}
2008-09-21 09:36:57 +03:00
}
?>