1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-01 05:55:02 +03:00
This commit is contained in:
Mzhelskiy Maxim 2009-06-27 15:05:17 +00:00
parent 3186698abd
commit 049bae3a58
13 changed files with 71 additions and 89 deletions

View file

@ -34,7 +34,7 @@ class LsRating extends Module {
* @param UserEntity_User $oUser
* @param CommentEntity_TopicComment $oComment
*/
public function VoteComment(UserEntity_User $oUser, CommentEntity_TopicComment $oComment, $iValue) {
public function VoteComment(UserEntity_User $oUser, CommentEntity_Comment $oComment, $iValue) {
/**
* Устанавливаем рейтинг комментария
*/

View file

@ -31,8 +31,7 @@ class LsTopic extends Module {
*
*/
public function Init() {
$this->oMapperTopic=new Mapper_Topic($this->Database_GetConnect());
$this->oMapperTopic->SetUserCurrent($this->User_GetUserCurrent());
$this->oMapperTopic=new Mapper_Topic($this->Database_GetConnect());
$this->oUserCurrent=$this->User_GetUserCurrent();
}
/**
@ -153,7 +152,8 @@ class LsTopic extends Module {
* @return unknown
*/
public function AddTopicVote(TopicEntity_TopicVote $oTopicVote) {
if ($this->oMapperTopic->AddTopicVote($oTopicVote)) {
if ($this->oMapperTopic->AddTopicVote($oTopicVote)) {
$this->Cache_Delete("topic_vote_{$oTopicVote->getTopicId()}_{$oTopicVote->getVoterId()}");
return true;
}
return false;
@ -177,7 +177,8 @@ class LsTopic extends Module {
public function DeleteTopic($sTopicId) {
$oTopic=$this->GetTopicById($sTopicId);
//чистим зависимые кеши
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array('topic_update',"topic_update_{$oTopic->getId()}","topic_update_user_{$oTopic->getUserId()}","topic_update_blog_{$oTopic->getBlogId()}"));
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array('topic_update',"topic_update_user_{$oTopic->getUserId()}","topic_update_blog_{$oTopic->getBlogId()}"));
$this->Cache_Delete("topic_{$sTopicId}");
return $this->oMapperTopic->DeleteTopic($sTopicId);
}
/**
@ -217,7 +218,7 @@ class LsTopic extends Module {
/**
* Обновляем избранное
*/
$this->oMapperTopic->SetFavouriteTopicPublish($oTopic->getId(),$oTopic->getPublish());
$this->SetFavouriteTopicPublish($oTopic->getId(),$oTopic->getPublish());
/**
* Удаляем комментарий топика из прямого эфира
*/
@ -230,7 +231,8 @@ class LsTopic extends Module {
$this->Comment_SetCommentsPublish($oTopic->getId(),'topic',$oTopic->getPublish());
}
//чистим зависимые кеши
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array('topic_update',"topic_update_{$oTopic->getId()}","topic_update_user_{$oTopic->getUserId()}","topic_update_blog_{$oTopic->getBlogId()}"));
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array('topic_update',"topic_update_user_{$oTopic->getUserId()}","topic_update_blog_{$oTopic->getBlogId()}"));
$this->Cache_Delete("topic_{$oTopic->getId()}");
return true;
}
return false;
@ -291,7 +293,7 @@ class LsTopic extends Module {
* Добавляем к результату и сохраняем в кеш
*/
$aTopics[$oTopic->getId()]=$oTopic;
$this->Cache_Set($oTopic, "topic_{$oTopic->getId()}", array("topic_update_{$oTopic->getId()}"), 60*60*24*4);
$this->Cache_Set($oTopic, "topic_{$oTopic->getId()}", array(), 60*60*24*4);
$aTopicIdNeedStore=array_diff($aTopicIdNeedStore,array($oTopic->getId()));
}
}
@ -299,7 +301,7 @@ class LsTopic extends Module {
* Сохраняем в кеш запросы не вернувшие результата
*/
foreach ($aTopicIdNeedStore as $sId) {
$this->Cache_Set(null, "topic_{$sId}", array("topic_update_{$sId}"), 60*60*24*4);
$this->Cache_Set(null, "topic_{$sId}", array(), 60*60*24*4);
}
/**
* Сортируем результат согласно входящему массиву
@ -319,7 +321,7 @@ class LsTopic extends Module {
public function GetTopicsFavouriteByUserId($sUserId,$iCurrPage,$iPerPage) {
if (false === ($data = $this->Cache_Get("topic_favourite_user_{$sUserId}_{$iCurrPage}_{$iPerPage}"))) {
$data = array('collection'=>$this->oMapperTopic->GetTopicsFavouriteByUserId($sUserId,$iCount,$iCurrPage,$iPerPage),'count'=>$iCount);
$this->Cache_Set($data, "topic_favourite_user_{$sUserId}_{$iCurrPage}_{$iPerPage}", array('topic_update',"favourite_topic_change_user_{$sUserId}"), 60*60*24*1);
$this->Cache_Set($data, "topic_favourite_user_{$sUserId}_{$iCurrPage}_{$iPerPage}", array('favourite_topic_change',"favourite_topic_change_user_{$sUserId}"), 60*60*24*1);
}
$data['collection']=$this->GetTopicsAdditionalData($data['collection']);
return $data;
@ -333,11 +335,18 @@ class LsTopic extends Module {
public function GetCountTopicsFavouriteByUserId($sUserId) {
if (false === ($data = $this->Cache_Get("topic_count_favourite_user_{$sUserId}"))) {
$data = $this->oMapperTopic->GetCountTopicsFavouriteByUserId($sUserId);
$this->Cache_Set($data, "topic_count_favourite_user_{$sUserId}", array('topic_update',"favourite_topic_change_user_{$sUserId}"), 60*60*24*1);
$this->Cache_Set($data, "topic_count_favourite_user_{$sUserId}", array('favourite_topic_change',"favourite_topic_change_user_{$sUserId}"), 60*60*24*1);
}
return $data;
}
/**
* Список топиков по фильтру
*
* @param unknown_type $aFilter
* @param unknown_type $iPage
* @param unknown_type $iPerPage
* @return unknown
*/
protected function GetTopicsByFilter($aFilter,$iPage,$iPerPage) {
$s=serialize($aFilter);
if (false === ($data = $this->Cache_Get("topic_filter_{$s}_{$iPage}_{$iPerPage}"))) {
@ -347,7 +356,12 @@ class LsTopic extends Module {
$data['collection']=$this->GetTopicsAdditionalData($data['collection']);
return $data;
}
/**
* Количество топиков по фильтру
*
* @param unknown_type $aFilter
* @return unknown
*/
protected function GetCountTopicsByFilter($aFilter) {
$s=serialize($aFilter);
if (false === ($data = $this->Cache_Get("topic_count_{$s}"))) {
@ -640,7 +654,7 @@ class LsTopic extends Module {
public function GetTopicsByTag($sTag,$iPage,$iPerPage) {
if (false === ($data = $this->Cache_Get("topic_tag_{$sTag}_{$iPage}_{$iPerPage}"))) {
$data = array('collection'=>$this->oMapperTopic->GetTopicsByTag($sTag,$iCount,$iPage,$iPerPage),'count'=>$iCount);
$this->Cache_Set($data, "topic_tag_{$sTag}_{$iPage}_{$iPerPage}", array('topic_update','topic_new'), 60*15);
$this->Cache_Set($data, "topic_tag_{$sTag}_{$iPage}_{$iPerPage}", array('topic_update','topic_new'), 60*60*24*2);
}
$data['collection']=$this->GetTopicsAdditionalData($data['collection']);
return $data;
@ -737,8 +751,8 @@ class LsTopic extends Module {
* @param unknown_type $sTopicId
* @return unknown
*/
public function increaseTopicCountComment($sTopicId) {
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("topic_update_{$sTopicId}"));
public function increaseTopicCountComment($sTopicId) {
$this->Cache_Delete("topic_{$sTopicId}");
return $this->oMapperTopic->increaseTopicCountComment($sTopicId);
}
/**
@ -837,6 +851,10 @@ class LsTopic extends Module {
$this->Cache_Delete("favourite_topic_{$oFavouriteTopic->getTopicId()}_{$oFavouriteTopic->getUserId()}");
return $this->oMapperTopic->DeleteFavouriteTopic($oFavouriteTopic);
}
public function SetFavouriteTopicPublish($sTopicId,$iPublish) {
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("favourite_topic_change"));
return $this->oMapperTopic->SetFavouriteTopicPublish($sTopicId,$iPublish);
}
/**
* Получает список тегов по первым буквам тега
*
@ -846,7 +864,7 @@ class LsTopic extends Module {
public function GetTopicTagsByLike($sTag,$iLimit) {
if (false === ($data = $this->Cache_Get("tag_like_{$sTag}_{$iLimit}"))) {
$data = $this->oMapperTopic->GetTopicTagsByLike($sTag,$iLimit);
$this->Cache_Set($data, "tag_like_{$sTag}_{$iLimit}", array("topic_update","topic_new"), 60*15);
$this->Cache_Set($data, "tag_like_{$sTag}_{$iLimit}", array("topic_update","topic_new"), 60*60*24*3);
}
return $data;
}
@ -1015,6 +1033,7 @@ class LsTopic extends Module {
* @param TopicEntity_TopicQuestionVote $oTopicQuestionVote
*/
public function AddTopicQuestionVote(TopicEntity_TopicQuestionVote $oTopicQuestionVote) {
$this->Cache_Delete("topic_question_vote_{$oTopicQuestionVote->getTopicId()}_{$oTopicQuestionVote->getVoterId()}");
return $this->oMapperTopic->AddTopicQuestionVote($oTopicQuestionVote);
}
/**

View file

@ -16,12 +16,7 @@
*/
class Mapper_Topic extends Mapper {
protected $oUserCurrent=null;
public function SetUserCurrent($oUserCurrent) {
$this->oUserCurrent=$oUserCurrent;
}
public function AddTopic(TopicEntity_Topic $oTopic) {
$sql = "INSERT INTO ".DB_TABLE_TOPIC."
(blog_id,
@ -427,13 +422,7 @@ class Mapper_Topic extends Mapper {
return $this->oDb->query($sql,$iPublish,$sTopicId);
}
public function GetFavouriteTopic($sTopicId,$sUserId) {
$sql = "SELECT * FROM ".DB_TABLE_FAVOURITE_TOPIC." WHERE topic_id = ?d and user_id = ?d ";
if ($aRow=$this->oDb->selectRow($sql,$sTopicId,$sUserId)) {
return new TopicEntity_FavouriteTopic($aRow);
}
return null;
}
public function GetFavouriteTopicsByArray($aArrayId,$sUserId) {
if (!is_array($aArrayId) or count($aArrayId)==0) {
@ -542,23 +531,7 @@ class Mapper_Topic extends Mapper {
return $this->oDb->query($sql,$oTopicRead->getCommentCountLast(),$oTopicRead->getCommentIdLast(),$oTopicRead->getDateRead(),$oTopicRead->getTopicId(),$oTopicRead->getUserId());
}
public function GetTopicRead($sTopicId,$sUserId) {
$sql = "SELECT
*
FROM
".DB_TABLE_TOPIC_READ."
WHERE
topic_id = ?d
AND
user_id = ?d
;
";
if ($aRow=$this->oDb->selectRow($sql,$sTopicId,$sUserId)) {
return new TopicEntity_TopicRead($aRow);
}
return false;
}
public function GetTopicsReadByArray($aArrayId,$sUserId) {
if (!is_array($aArrayId) or count($aArrayId)==0) {
return array();
@ -597,14 +570,7 @@ class Mapper_Topic extends Mapper {
return false;
}
public function GetTopicQuestionVote($sTopicId,$sUserId) {
$sql = "SELECT * FROM ".DB_TABLE_TOPIC_QUESTION_VOTE." WHERE topic_id = ?d and user_voter_id = ?d ";
if ($aRow=$this->oDb->selectRow($sql,$sTopicId,$sUserId)) {
return new TopicEntity_TopicQuestionVote($aRow);
}
return null;
}
public function GetTopicsQuestionVoteByArray($aArrayId,$sUserId) {
if (!is_array($aArrayId) or count($aArrayId)==0) {
return array();

View file

@ -703,8 +703,9 @@ class LsUser extends Module {
public function GetUsersSelfFriend($sUserId) {
if (false === ($data = $this->Cache_Get("user_self_friend_{$sUserId}"))) {
$data = $this->oMapper->GetUsersSelfFriend($sUserId);
$this->Cache_Set($data, "user_self_friend_{$sUserId}", array("friend_change_user_{$sUserId}"), 60*5);
$this->Cache_Set($data, "user_self_friend_{$sUserId}", array("friend_change_friend_{$sUserId}"), 60*5);
}
$data=$this->GetUsersAdditionalData($data);
return $data;
}
/**

View file

@ -457,22 +457,15 @@ class Mapper_User extends Mapper {
public function GetUsersSelfFriend($sUserId) {
$sql = "SELECT
u.*
user_id
FROM
".DB_TABLE_FRIEND." as uf,
".DB_TABLE_USER." as u
".DB_TABLE_FRIEND."
WHERE
uf.user_friend_id = ?d
AND
uf.user_id = u.user_id
AND
u.user_activate = 1
ORDER BY u.user_login;
";
user_friend_id = ?d ";
$aUsers=array();
if ($aRows=$this->oDb->select($sql,$sUserId)) {
foreach ($aRows as $aUser) {
$aUsers[]=new UserEntity_User($aUser);
$aUsers[]=$aUser['user_id'];
}
}
return $aUsers;

View file

@ -62,10 +62,10 @@ function toggleBlogInfo(id,link) {
<li>
<dl>
<dt>
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUserOwner->getLogin()}/"><img src="{$oUserOwner->getProfileAvatarPath(48)}" alt="" title="{$oUserOwner->getLogin()}"/></a>
<a href="{$oUserOwner->getUserWebPath()}"><img src="{$oUserOwner->getProfileAvatarPath(48)}" alt="" title="{$oUserOwner->getLogin()}"/></a>
</dt>
<dd>
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUserOwner->getLogin()}/">{$oUserOwner->getLogin()}</a>
<a href="{$oUserOwner->getUserWebPath()}">{$oUserOwner->getLogin()}</a>
</dd>
</dl>
</li>
@ -75,10 +75,10 @@ function toggleBlogInfo(id,link) {
<li>
<dl>
<dt>
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/"><img src="{$oUser->getProfileAvatarPath(48)}" alt="" title="{$oUser->getLogin()}"/></a>
<a href="{$oUser->getUserWebPath()}"><img src="{$oUser->getProfileAvatarPath(48)}" alt="" title="{$oUser->getLogin()}"/></a>
</dt>
<dd>
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/">{$oUser->getLogin()}</a>
<a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a>
</dd>
</dl>
</li>
@ -98,10 +98,10 @@ function toggleBlogInfo(id,link) {
<li>
<dl>
<dt>
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/"><img src="{$oUser->getProfileAvatarPath(48)}" alt="" title="{$oUser->getLogin()}"/></a>
<a href="{$oUser->getUserWebPath()}"><img src="{$oUser->getProfileAvatarPath(48)}" alt="" title="{$oUser->getLogin()}"/></a>
</dt>
<dd>
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/">{$oUser->getLogin()}</a>
<a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a>
</dd>
</dl>
</li>
@ -117,7 +117,7 @@ function toggleBlogInfo(id,link) {
<ul class="reader-list">
{foreach from=$aBlogUsers item=oBlogUser}
{assign var="oUser" value=$oBlogUser->getUser()}
<li><a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/">{$oUser->getLogin()}</a></li>
<li><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></li>
{/foreach}
</ul>
{else}

View file

@ -96,23 +96,23 @@
<br />
<h1 class="title">{$aLang.profile_activity}</h1>
<table>
{if $aUsersFrend}
{if $aUsersFriend}
<tr>
<td class="var">{$aLang.profile_friends}:</td>
<td class="friends">
{foreach from=$aUsersFrend item=oUserFrend}
<a href="{$oUserFrend->getUserWebPath()}">{$oUserFrend->getLogin()}</a>&nbsp;
{foreach from=$aUsersFriend item=oUser}
<a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a>&nbsp;
{/foreach}
</td>
</tr>
{/if}
{if $aUsersSelfFrend}
{if $aUsersSelfFriend}
<tr>
<td class="var">{$aLang.profile_friends_self}:</td>
<td class="friends">
{foreach from=$aUsersSelfFrend item=oUserFrend}
<a href="{$oUserFrend->getUserWebPath()}">{$oUserFrend->getLogin()}</a>&nbsp;
{foreach from=$aUsersSelfFriend item=oUser}
<a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a>&nbsp;
{/foreach}
</td>
</tr>

View file

@ -5,7 +5,7 @@
{assign var="oBlog" value=$oTopic->getBlog()}
<li {if $smarty.foreach.cmt.iteration % 2 == 1}class="even"{/if}>
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/" class="stream-author">{$oUser->getLogin()}</a>&nbsp;&#8594;
<a href="{$oUser->getUserWebPath()}" class="stream-author">{$oUser->getLogin()}</a>&nbsp;&#8594;
<span class="stream-comment-icon"></span><a href="{$oTopic->getUrl()}#comment{$oComment->getId()}" class="stream-comment">{$oTopic->getTitle()|escape:'html'}</a>
<span> {$oTopic->getCountComment()}</span> в <a href="{$oBlog->getUrlFull()}" class="stream-blog">{$oBlog->getTitle()|escape:'html'}</a>
</li>

View file

@ -1,9 +1,12 @@
<ul class="stream-content">
{foreach from=$oTopics item=oTopic name="cmt"}
{assign var="oUser" value=$oTopic->getUser()}
{assign var="oBlog" value=$oTopic->getBlog()}
<li {if $smarty.foreach.cmt.iteration % 2 == 1}class="even"{/if}>
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oTopic->getUserLogin()}/" class="stream-author">{$oTopic->getUserLogin()}</a>&nbsp;&#8594;
<a href="{$oUser->getUserWebPath()}" class="stream-author">{$oUser->getLogin()}</a>&nbsp;&#8594;
<span class="stream-topic-icon"></span><a href="{$oTopic->getUrl()}" class="stream-topic">{$oTopic->getTitle()|escape:'html'}</a>
<span>{$oTopic->getCountComment()}</span> в <a href="{$oTopic->getBlogUrlFull()}" class="stream-blog">{$oTopic->getBlogTitle()|escape:'html'}</a>
<span>{$oTopic->getCountComment()}</span> в <a href="{$oBlog->getUrlFull()}" class="stream-blog">{$oBlog->getTitle()|escape:'html'}</a>
</li>
{/foreach}
</ul>

View file

@ -34,8 +34,8 @@
<div class="bl"><div class="bb"><div class="br"></div></div></div>
</div>
<div class="info">
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/"><img src="{$oUser->getProfileAvatarPath(24)}" alt="avatar" class="avatar" /></a>
<p><a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/" class="author">{$oUser->getLogin()}</a></p>
<a href="{$oUser->getUserWebPath()}"><img src="{$oUser->getProfileAvatarPath(24)}" alt="avatar" class="avatar" /></a>
<p><a href="{$oUser->getUserWebPath()}" class="author">{$oUser->getLogin()}</a></p>
<ul>
<li class="date">{date_format date=$oComment->getDate()}</li>
{if $oUserCurrent and !$oComment->getDelete() and !$bAllowNewComment}

View file

@ -25,8 +25,8 @@
<div class="bl"><div class="bb"><div class="br"></div></div></div>
</div>
<div class="info">
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/"><img src="{$oUser->getProfileAvatarPath(24)}" alt="avatar" class="avatar" /></a>
<p><a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/" class="author">{$oUser->getLogin()}</a></p>
<a href="{$oUser->getUserWebPath()}"><img src="{$oUser->getProfileAvatarPath(24)}" alt="avatar" class="avatar" /></a>
<p><a href="{$oUser->getUserWebPath()}" class="author">{$oUser->getLogin()}</a></p>
<ul>
<li class="date">{date_format date=$oComment->getDate()}</li>
<li><a href="{$oTopic->getUrl()}#comment{$oComment->getId()}" class="imglink link"></a></li>

View file

@ -63,7 +63,7 @@
{if $oTopic->getType()=='link'}
<li class="link"><a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_LINK}/go/{$oTopic->getId()}/" title="{$aLang.topic_link_count_jump}: {$oTopic->getLinkCountJump()}">{$oTopic->getLinkUrl(true)}</a></li>
{/if}
<li class="author"><a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/">{$oUser->getLogin()}</a></li>
<li class="author"><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></li>
</ul>
</div>
<!-- /Topic -->

View file

@ -74,7 +74,7 @@
{if $oTopic->getType()=='link'}
<li class="link"><a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_LINK}/go/{$oTopic->getId()}/" title="{$aLang.topic_link_count_jump}: {$oTopic->getLinkCountJump()}">{$oTopic->getLinkUrl(true)}</a></li>
{/if}
<li class="author"><a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oUser->getLogin()}/">{$oUser->getLogin()}</a></li>
<li class="author"><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></li>
<li class="comments-total">
{if $oTopic->getCountComment()>0}
<a href="{$oTopic->getUrl()}#comments" title="{$aLang.topic_comment_read}"><span class="red">{$oTopic->getCountComment()}</span>{if $oTopic->getCountCommentNew()}<span class="green">+{$oTopic->getCountCommentNew()}</span>{/if}</a>