From 049bae3a583b4542c051a2480d88ef1540ef9574 Mon Sep 17 00:00:00 2001 From: Mzhelskiy Maxim Date: Sat, 27 Jun 2009 15:05:17 +0000 Subject: [PATCH] --- classes/modules/rating/Rating.class.php | 2 +- classes/modules/topic/Topic.class.php | 51 +++++++++++++------ .../topic/mapper/Topic.mapper.class.php | 42 ++------------- classes/modules/user/User.class.php | 3 +- .../modules/user/mapper/User.mapper.class.php | 15 ++---- .../skin/new/actions/ActionBlog/blog.tpl | 14 ++--- .../skin/new/actions/ActionProfile/whois.tpl | 12 ++--- templates/skin/new/block.stream_comment.tpl | 2 +- templates/skin/new/block.stream_topic.tpl | 7 ++- templates/skin/new/comment.tpl | 4 +- templates/skin/new/comment_list.tpl | 4 +- templates/skin/new/topic.tpl | 2 +- templates/skin/new/topic_list.tpl | 2 +- 13 files changed, 71 insertions(+), 89 deletions(-) diff --git a/classes/modules/rating/Rating.class.php b/classes/modules/rating/Rating.class.php index ef4a133c..85bc94ac 100644 --- a/classes/modules/rating/Rating.class.php +++ b/classes/modules/rating/Rating.class.php @@ -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) { /** * Устанавливаем рейтинг комментария */ diff --git a/classes/modules/topic/Topic.class.php b/classes/modules/topic/Topic.class.php index df51d32b..70cd1dda 100644 --- a/classes/modules/topic/Topic.class.php +++ b/classes/modules/topic/Topic.class.php @@ -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); } /** diff --git a/classes/modules/topic/mapper/Topic.mapper.class.php b/classes/modules/topic/mapper/Topic.mapper.class.php index 497a30cc..7c1619d7 100644 --- a/classes/modules/topic/mapper/Topic.mapper.class.php +++ b/classes/modules/topic/mapper/Topic.mapper.class.php @@ -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(); diff --git a/classes/modules/user/User.class.php b/classes/modules/user/User.class.php index ad9a59db..8ef66981 100644 --- a/classes/modules/user/User.class.php +++ b/classes/modules/user/User.class.php @@ -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; } /** diff --git a/classes/modules/user/mapper/User.mapper.class.php b/classes/modules/user/mapper/User.mapper.class.php index 5873fea3..911da151 100644 --- a/classes/modules/user/mapper/User.mapper.class.php +++ b/classes/modules/user/mapper/User.mapper.class.php @@ -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; diff --git a/templates/skin/new/actions/ActionBlog/blog.tpl b/templates/skin/new/actions/ActionBlog/blog.tpl index f5f6e45f..3ec11201 100644 --- a/templates/skin/new/actions/ActionBlog/blog.tpl +++ b/templates/skin/new/actions/ActionBlog/blog.tpl @@ -62,10 +62,10 @@ function toggleBlogInfo(id,link) {
  • - +
    - {$oUserOwner->getLogin()} + {$oUserOwner->getLogin()}
  • @@ -75,10 +75,10 @@ function toggleBlogInfo(id,link) {
  • - +
    - {$oUser->getLogin()} + {$oUser->getLogin()}
  • @@ -98,10 +98,10 @@ function toggleBlogInfo(id,link) {
  • - +
    - {$oUser->getLogin()} + {$oUser->getLogin()}
  • @@ -117,7 +117,7 @@ function toggleBlogInfo(id,link) { {else} diff --git a/templates/skin/new/actions/ActionProfile/whois.tpl b/templates/skin/new/actions/ActionProfile/whois.tpl index b05010ef..25dd0892 100644 --- a/templates/skin/new/actions/ActionProfile/whois.tpl +++ b/templates/skin/new/actions/ActionProfile/whois.tpl @@ -96,23 +96,23 @@

    {$aLang.profile_activity}

    - {if $aUsersFrend} + {if $aUsersFriend} {/if} - {if $aUsersSelfFrend} + {if $aUsersSelfFriend} diff --git a/templates/skin/new/block.stream_comment.tpl b/templates/skin/new/block.stream_comment.tpl index 387e7379..2649ec39 100644 --- a/templates/skin/new/block.stream_comment.tpl +++ b/templates/skin/new/block.stream_comment.tpl @@ -5,7 +5,7 @@ {assign var="oBlog" value=$oTopic->getBlog()}
  • - {$oUser->getLogin()} → + {$oUser->getLogin()} → {$oTopic->getTitle()|escape:'html'} {$oTopic->getCountComment()} в {$oBlog->getTitle()|escape:'html'}
  • diff --git a/templates/skin/new/block.stream_topic.tpl b/templates/skin/new/block.stream_topic.tpl index 91bb703e..09621871 100644 --- a/templates/skin/new/block.stream_topic.tpl +++ b/templates/skin/new/block.stream_topic.tpl @@ -1,9 +1,12 @@ \ No newline at end of file diff --git a/templates/skin/new/comment.tpl b/templates/skin/new/comment.tpl index 78048c20..f3c96355 100644 --- a/templates/skin/new/comment.tpl +++ b/templates/skin/new/comment.tpl @@ -34,8 +34,8 @@
    - avatar -

    {$oUser->getLogin()}

    + avatar +

    {$oUser->getLogin()}

    - avatar -

    {$oUser->getLogin()}

    + avatar +

    {$oUser->getLogin()}

    \ No newline at end of file diff --git a/templates/skin/new/topic_list.tpl b/templates/skin/new/topic_list.tpl index 318857ec..8b361e73 100644 --- a/templates/skin/new/topic_list.tpl +++ b/templates/skin/new/topic_list.tpl @@ -74,7 +74,7 @@ {if $oTopic->getType()=='link'} {/if} -
  • {$oUser->getLogin()}
  • +
  • {$oUser->getLogin()}
  • {if $oTopic->getCountComment()>0} {$oTopic->getCountComment()}{if $oTopic->getCountCommentNew()}+{$oTopic->getCountCommentNew()}{/if}
  • {$aLang.profile_friends}: - {foreach from=$aUsersFrend item=oUserFrend} - {$oUserFrend->getLogin()}  + {foreach from=$aUsersFriend item=oUser} + {$oUser->getLogin()}  {/foreach}
    {$aLang.profile_friends_self}: - {foreach from=$aUsersSelfFrend item=oUserFrend} - {$oUserFrend->getLogin()}  + {foreach from=$aUsersSelfFriend item=oUser} + {$oUser->getLogin()}  {/foreach}