1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-19 09:18:18 +03:00

Оптимизация вывода списка заметок

This commit is contained in:
Mzhelskiy Maxim 2014-01-28 16:17:04 +07:00
parent 9568c7e928
commit 7db6e50bf0
4 changed files with 43 additions and 28 deletions

View file

@ -732,7 +732,7 @@ class ActionProfile extends Action {
/**
* Получаем список заметок
*/
$aResult=$this->User_GetUserNotesByUserId($this->oUserProfile->getId(),$iPage,Config::Get('module.user.usernote_per_page'));
$aResult=$this->User_GetUsersByNoteAndUserId($this->oUserProfile->getId(),$iPage,Config::Get('module.user.usernote_per_page'));
$aNotes=$aResult['collection'];
/**
* Формируем постраничность
@ -742,7 +742,7 @@ class ActionProfile extends Action {
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aPaging',$aPaging);
$this->Viewer_Assign('aNotes',$aNotes);
$this->Viewer_Assign('aUsersList',$aNotes);
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile').' '.$this->oUserProfile->getLogin());
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_notes'));
/**

View file

@ -1390,6 +1390,20 @@ class ModuleUser extends Module {
}
return array('collection'=>$aResult,'count'=>$iCount);
}
/**
* Возвращает список пользователей к которым юзер оставлял заметку
*
* @param int $iUserId ID пользователя
* @param int $iCurrPage Номер страницы
* @param int $iPerPage Количество элементов на страницу
*
* @return array('collection'=>array,'count'=>int)
*/
public function GetUsersByNoteAndUserId($iUserId,$iCurrPage,$iPerPage) {
$aUsersId=$this->oMapper->GetUsersByNoteAndUserId($iUserId,$iCount,$iCurrPage,$iPerPage);
$aResult=$this->GetUsersAdditionalData($aUsersId);
return array('collection'=>$aResult,'count'=>$iCount);
}
/**
* Возвращает количество заметок у пользователя
*

View file

@ -983,6 +983,32 @@ class ModuleUser_MapperUser extends Mapper {
}
return $aReturn;
}
/**
* Возвращает список ID пользователей к которым юзер оставлял заметки
*
* @param int $iUserId ID пользователя
* @param int $iCount Возвращает общее количество элементов
* @param int $iCurrPage Номер страницы
* @param int $iPerPage Количество элементов на страницу
* @return array
*/
public function GetUsersByNoteAndUserId($iUserId,&$iCount,$iCurrPage,$iPerPage) {
$sql = "
SELECT target_user_id
FROM
".Config::Get('db.table.user_note')."
WHERE
user_id = ?d
ORDER BY id DESC
LIMIT ?d, ?d ";
$aReturn=array();
if ($aRows=$this->oDb->selectPage($iCount,$sql,$iUserId,($iCurrPage-1)*$iPerPage, $iPerPage)) {
foreach ($aRows as $aRow) {
$aReturn[]=$aRow['target_user_id'];
}
}
return $aReturn;
}
/**
* Возвращает количество заметок у пользователя
*

View file

@ -9,30 +9,5 @@
{block name='layout_content'}
{include file='navs/nav.user.created.tpl'}
{if $aNotes}
<ul class="object-list user-list">
{foreach $aNotes as $oNote}
{$oUser = $oNote->getTargetUser()}
<li class="object-list-item">
{* Аватар *}
<a href="{$oUser->getUserWebPath()}">
<img src="{$oUser->getProfileAvatarPath(100)}" width="100" height="100" alt="{$oUser->getLogin()}" class="object-list-item-image" />
</a>
{* Заголовок *}
<h2 class="object-list-item-title">
<a href="{$oUser->getUserWebPath()}">{$oUser->getDisplayName()}</a>
</h2>
{* Заметка *}
{include 'user_note.tpl' oUserNote=$oNote iUserNoteId=$oUser->getId()}
</li>
{/foreach}
</ul>
{else}
{include file='alert.tpl' mAlerts=$aLang.common.empty sAlertStyle='empty'}
{/if}
{include file='pagination.tpl' aPaging=$aPaging}
{include file='user_list.tpl'}
{/block}