1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 11:40:48 +03:00

Возможность для избранных топиков добавлять с вои теги

This commit is contained in:
Mzhelskiy Maxim 2012-03-27 14:45:52 +04:00
parent f3f278fc5b
commit 4fbb8fe7fe
21 changed files with 618 additions and 16 deletions

View file

@ -36,6 +36,7 @@ class ActionAjax extends Action {
$this->AddEventPreg('/^vote$/i','/^user$/','EventVoteUser');
$this->AddEventPreg('/^vote$/i','/^question$/','EventVoteQuestion');
$this->AddEventPreg('/^favourite$/i','/^save-tags/','EventFavouriteSaveTags');
$this->AddEventPreg('/^favourite$/i','/^topic$/','EventFavouriteTopic');
$this->AddEventPreg('/^favourite$/i','/^comment$/','EventFavouriteComment');
$this->AddEventPreg('/^favourite$/i','/^talk$/','EventFavouriteTalk');
@ -454,6 +455,46 @@ class ActionAjax extends Action {
}
}
/**
* Сохраняет теги для избранного
*
* @return mixed
*/
protected function EventFavouriteSaveTags() {
if (!$this->oUserCurrent) {
$this->Message_AddErrorSingle($this->Lang_Get('need_authorization'),$this->Lang_Get('error'));
return;
}
if ($oFavourite=$this->Favourite_GetFavourite(getRequest('target_id'),getRequest('target_type'),$this->oUserCurrent->getId())) {
$aTags=explode(',',trim(getRequest('tags'),"\r\n\t\0\x0B ."));
$aTagsNew=array();
$aTagsNewLow=array();
$aTagsReturn=array();
foreach ($aTags as $sTag) {
$sTag=trim($sTag);
if (func_check($sTag,'text',2,50) and !in_array(mb_strtolower($sTag,'UTF-8'),$aTagsNewLow)) {
$sTagEsc=htmlspecialchars($sTag);
$aTagsNew[]=$sTagEsc;
$aTagsReturn[]=array(
'tag' => $sTagEsc,
'url' => $this->oUserCurrent->getUserWebPath().'favourites/'.$oFavourite->getTargetType().'s/tag/'.$sTagEsc.'/', // костыль для URL с множественным числом
);
$aTagsNewLow[]=mb_strtolower($sTag,'UTF-8');
}
}
if (!count($aTagsNew)) {
$oFavourite->setTags('');
} else {
$oFavourite->setTags(join(',',$aTagsNew));
}
$this->Viewer_AssignAjax('aTags',$aTagsReturn);
$this->Favourite_UpdateFavourite($oFavourite);
return;
}
$this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error'));
}
/**
* Обработка избранного - топик
*

View file

@ -51,6 +51,7 @@ class ActionProfile extends Action {
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^comments$/i','/^(page(\d+))?$/i','EventFavouriteComments');
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^(page(\d+))?$/i','EventFavourite');
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^topics/i','/^(page(\d+))?$/i','EventFavourite');
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^topics/i','/^tag/i','/^.+/i','/^(page(\d+))?$/i','EventFavouriteTopicsTag');
$this->AddEventPreg('/^.+$/i','/^created/i','/^notes/i','/^(page(\d+))?$/i','EventCreatedNotes');
$this->AddEventPreg('/^.+$/i','/^created/i','/^(page(\d+))?$/i','EventCreatedTopics');
@ -234,6 +235,49 @@ class ActionProfile extends Action {
*/
$this->SetTemplateAction('favourite_topics');
}
/**
* Список топиков из избранного по тегу
*/
protected function EventFavouriteTopicsTag() {
if (!$this->CheckUserProfile()) {
return parent::EventNotFound();
}
if (!$this->oUserCurrent or $this->oUserProfile->getId()!=$this->oUserCurrent->getId()) {
return parent::EventNotFound();
}
$sTag=$this->GetParamEventMatch(3,0);
/*
* Передан ли номер страницы
*/
$iPage=$this->GetParamEventMatch(4,2) ? $this->GetParamEventMatch(4,2) : 1;
/**
* Получаем список избранных топиков
*/
$aResult=$this->Favourite_GetTags(array('target_type'=>'topic','user_id'=>$this->oUserProfile->getId(),'text'=>$sTag),array('target_id'=>'desc'),$iPage,Config::Get('module.topic.per_page'));
$aTopicId=array();
foreach($aResult['collection'] as $oTag) {
$aTopicId[]=$oTag->getTargetId();
}
$aTopics=$this->Topic_GetTopicsAdditionalData($aTopicId);
/**
* Формируем постраничность
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.topic.per_page'),4,$this->oUserProfile->getUserWebPath().'favourites/topics/tag/'.htmlspecialchars($sTag));
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aPaging',$aPaging);
$this->Viewer_Assign('aTopics',$aTopics);
$this->Viewer_Assign('sFavouriteTag',htmlspecialchars($sTag));
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile').' '.$this->oUserProfile->getLogin());
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_favourites'));
/**
* Устанавливаем шаблон вывода
*/
$this->SetTemplateAction('favourite_topics');
}
/**
* Выводит список избранноего юзера
*

View file

@ -0,0 +1,56 @@
<?php
/*-------------------------------------------------------
*
* 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
*
---------------------------------------------------------
*/
/**
* Обрабатывает блок облака тегов для избранного
*
*/
class BlockTagsFavouriteTopic extends Block {
public function Exec() {
if ($oUserCurrent = $this->User_getUserCurrent()) {
if (!($oUser=$this->getParam('user'))) {
$oUser=$oUserCurrent;
}
/**
* Получаем список тегов
*/
$aTags=$this->oEngine->Favourite_GetGroupTags($oUser->getId(),'topic',null,70);
/**
* Расчитываем логарифмическое облако тегов
*/
$this->Tools_MakeCloud($aTags);
/**
* Устанавливаем шаблон вывода
*/
$this->Viewer_Assign("aFavouriteTopicTags",$aTags);
/**
* Получаем список тегов пользователя
*/
$aTags=$this->oEngine->Favourite_GetGroupTags($oUser->getId(),'topic',true,70);
/**
* Расчитываем логарифмическое облако тегов
*/
$this->Tools_MakeCloud($aTags);
/**
* Устанавливаем шаблон вывода
*/
$this->Viewer_Assign("aFavouriteTopicUserTags",$aTags);
$this->Viewer_Assign("oFavouriteUser",$oUser);
}
}
}
?>

View file

@ -295,11 +295,66 @@ class ModuleFavourite extends Module {
* @return bool
*/
public function AddFavourite(ModuleFavourite_EntityFavourite $oFavourite) {
if (!$oFavourite->getTags()) {
$oFavourite->setTags('');
}
$this->SetFavouriteTags($oFavourite);
//чистим зависимые кеши
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("favourite_{$oFavourite->getTargetType()}_change_user_{$oFavourite->getUserId()}"));
$this->Cache_Delete("favourite_{$oFavourite->getTargetType()}_{$oFavourite->getTargetId()}_{$oFavourite->getUserId()}");
return $this->oMapper->AddFavourite($oFavourite);
}
/**
* Обновляет запись об избранном
*
* @param ModuleFavourite_EntityFavourite $oFavourite
* @return mixed
*/
public function UpdateFavourite(ModuleFavourite_EntityFavourite $oFavourite) {
if (!$oFavourite->getTags()) {
$oFavourite->setTags('');
}
$this->SetFavouriteTags($oFavourite);
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("favourite_{$oFavourite->getTargetType()}_change_user_{$oFavourite->getUserId()}"));
$this->Cache_Delete("favourite_{$oFavourite->getTargetType()}_{$oFavourite->getTargetId()}_{$oFavourite->getUserId()}");
return $this->oMapper->UpdateFavourite($oFavourite);
}
/**
* Устанавливает список тегов для избранного
*
* @param $oFavourite
*/
public function SetFavouriteTags($oFavourite,$bAddNew=true) {
/**
* Удаляем все теги
*/
$this->oMapper->DeleteTags($oFavourite);
/**
* Добавляем новые
*/
if ($bAddNew and $oFavourite->getTags()) {
/**
* Добавляем теги объекта избранного, если есть
*/
if ($aTags=$this->GetTagsTarget($oFavourite->getTargetType(),$oFavourite->getTargetId())) {
foreach($aTags as $sTag) {
$oTag=Engine::GetEntity('ModuleFavourite_EntityTag',$oFavourite->_getData());
$oTag->setText(htmlspecialchars($sTag));
$oTag->setIsUser(0);
$this->oMapper->AddTag($oTag);
}
}
/**
* Добавляем пользовательские теги
*/
foreach($oFavourite->getTagsArray() as $sTag) {
$oTag=Engine::GetEntity('ModuleFavourite_EntityTag',$oFavourite->_getData());
$oTag->setText($sTag); // htmlspecialchars уже используется при установке тегов
$oTag->setIsUser(1);
$this->oMapper->AddTag($oTag);
}
}
}
/**
* Удаляет таргет из избранного
*
@ -307,6 +362,7 @@ class ModuleFavourite extends Module {
* @return bool
*/
public function DeleteFavourite(ModuleFavourite_EntityFavourite $oFavourite) {
$this->SetFavouriteTags($oFavourite,false);
//чистим зависимые кеши
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("favourite_{$oFavourite->getTargetType()}_change_user_{$oFavourite->getUserId()}"));
$this->Cache_Delete("favourite_{$oFavourite->getTargetType()}_{$oFavourite->getTargetId()}_{$oFavourite->getUserId()}");
@ -339,7 +395,58 @@ class ModuleFavourite extends Module {
* Чистим зависимые кеши
*/
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("favourite_{$sTargetType}_change"));
$this->DeleteTagByTarget($aTargetId,$sTargetType);
return $this->oMapper->DeleteFavouriteByTargetId($aTargetId,$sTargetType);
}
/**
* Возвращает список тегов для объекта избранного
*
* @param $sTargetType
* @param $iTargetId
* @return bool | array
*/
public function GetTagsTarget($sTargetType,$iTargetId) {
$sMethod = 'GetTagsTarget'.func_camelize($sTargetType);
if (method_exists($this,$sMethod)) {
return $this->$sMethod($iTargetId);
}
return false;
}
/**
* Возвращает наиболее часто используемые теги
*
* @param $iUserId
* @param $sTargetType
* @param $bIsUser
* @param $iLimit
* @return mixed
*/
public function GetGroupTags($iUserId,$sTargetType,$bIsUser,$iLimit) {
return $this->oMapper->GetGroupTags($iUserId,$sTargetType,$bIsUser,$iLimit);
}
/**
* Возвращает список тегов по фильтру
*
* @param $aFilter
* @param $aOrder
* @param $iCurrPage
* @param $iPerPage
* @return array('collection'=>array,'count'=>int)
*/
public function GetTags($aFilter,$aOrder,$iCurrPage,$iPerPage) {
return array('collection'=>$this->oMapper->GetTags($aFilter,$aOrder,$iCount,$iCurrPage,$iPerPage),'count'=>$iCount);
}
/**
* Возвращает список тегов для топика, название метода формируется автоматически из GetTagsTarget()
*
* @param $iTargetId
* @return bool | array
*/
public function GetTagsTargetTopic($iTargetId) {
if ($oTopic=$this->Topic_GetTopicById($iTargetId)) {
return $oTopic->getTagsArray();
}
return false;
}
}
?>

View file

@ -29,6 +29,12 @@ class ModuleFavourite_EntityFavourite extends Entity
public function getTargetType() {
return $this->_aData['target_type'];
}
public function getTagsArray() {
if ($this->getTags()) {
return explode(',',$this->getTags());
}
return array();
}
public function setTargetId($data) {
$this->_aData['target_id']=$data;

View file

@ -0,0 +1,21 @@
<?php
/*-------------------------------------------------------
*
* 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
*
---------------------------------------------------------
*/
class ModuleFavourite_EntityTag extends Entity {
}
?>

View file

@ -20,20 +20,38 @@ class ModuleFavourite_MapperFavourite extends Mapper {
public function AddFavourite(ModuleFavourite_EntityFavourite $oFavourite) {
$sql = "
INSERT INTO ".Config::Get('db.table.favourite')."
( target_id, target_type, user_id )
( target_id, target_type, user_id, tags )
VALUES
(?d, ?, ?d)
(?d, ?, ?d, ?)
";
if ($this->oDb->query(
$sql,
$oFavourite->getTargetId(),
$oFavourite->getTargetType(),
$oFavourite->getUserId()
$oFavourite->getUserId(),
$oFavourite->getTags()
)===0) {
return true;
}
return false;
}
public function UpdateFavourite(ModuleFavourite_EntityFavourite $oFavourite) {
$sql = "
UPDATE ".Config::Get('db.table.favourite')."
SET tags = ? WHERE user_id = ?d and target_id = ?d and target_type = ?
";
if ($this->oDb->query(
$sql,
$oFavourite->getTags(),
$oFavourite->getUserId(),
$oFavourite->getTargetId(),
$oFavourite->getTargetType()
)!==false) {
return true;
}
return false;
}
public function GetFavouritesByArray($aArrayId,$sTargetType,$sUserId) {
if (!is_array($aArrayId) or count($aArrayId)==0) {
@ -76,6 +94,45 @@ class ModuleFavourite_MapperFavourite extends Mapper {
}
return false;
}
public function DeleteTags($oFavourite) {
$sql = "
DELETE FROM ".Config::Get('db.table.favourite_tag')."
WHERE
user_id = ?d
AND
target_type = ?
AND
target_id = ?d
";
if ($this->oDb->query(
$sql,
$oFavourite->getUserId(),
$oFavourite->getTargetType(),
$oFavourite->getTargetId()
)) {
return true;
}
return false;
}
public function AddTag($oTag) {
$sql = "
INSERT INTO ".Config::Get('db.table.favourite_tag')."
SET target_id = ?d, target_type = ?, user_id = ?d, is_user = ?d, text =?
";
if ($this->oDb->query(
$sql,
$oTag->getTargetId(),
$oTag->getTargetType(),
$oTag->getUserId(),
$oTag->getIsUser(),
$oTag->getText()
)===0) {
return true;
}
return false;
}
public function SetFavouriteTargetPublish($aTargetId,$sTargetType,$iPublish) {
$sql = "
@ -279,6 +336,96 @@ class ModuleFavourite_MapperFavourite extends Mapper {
return true;
}
return false;
}
}
public function DeleteTagByTarget($aTargetId,$sTargetType) {
$sql = "
DELETE FROM ".Config::Get('db.table.favourite_tag')."
WHERE
target_type = ?
AND
target_id IN(?a)
";
if ($this->oDb->query($sql,$sTargetType,$aTargetId)) {
return true;
}
return false;
}
public function GetGroupTags($iUserId,$sTargetType,$bIsUser,$iLimit) {
$sql = "SELECT
text,
count(text) as count
FROM
".Config::Get('db.table.favourite_tag')."
WHERE
1=1
{AND user_id = ?d }
{AND target_type = ? }
{AND is_user = ?d }
GROUP BY
text
ORDER BY
count desc
LIMIT 0, ?d
";
$aReturn=array();
$aReturnSort=array();
if ($aRows=$this->oDb->select($sql,$iUserId,$sTargetType,is_null($bIsUser) ? DBSIMPLE_SKIP : $bIsUser,$iLimit)) {
foreach ($aRows as $aRow) {
$aReturn[mb_strtolower($aRow['text'],'UTF-8')]=$aRow;
}
ksort($aReturn);
foreach ($aReturn as $aRow) {
$aReturnSort[]=Engine::GetEntity('ModuleFavourite_EntityTag',$aRow);
}
}
return $aReturnSort;
}
public function GetTags($aFilter,$aOrder,&$iCount,$iCurrPage,$iPerPage) {
$aOrderAllow=array('target_id','user_id','is_user');
$sOrder='';
foreach ($aOrder as $key=>$value) {
if (!in_array($key,$aOrderAllow)) {
unset($aOrder[$key]);
} elseif (in_array($value,array('asc','desc'))) {
$sOrder.=" {$key} {$value},";
}
}
$sOrder=trim($sOrder,',');
if ($sOrder=='') {
$sOrder=' target_id desc ';
}
$sql = "SELECT
*
FROM
".Config::Get('db.table.favourite_tag')."
WHERE
1 = 1
{ AND user_id = ?d }
{ AND target_type = ? }
{ AND target_id = ?d }
{ AND is_user = ?d }
{ AND text = ? }
ORDER by {$sOrder}
LIMIT ?d, ?d ;
";
$aResult=array();
if ($aRows=$this->oDb->selectPage($iCount,$sql,
isset($aFilter['user_id']) ? $aFilter['user_id'] : DBSIMPLE_SKIP,
isset($aFilter['target_type']) ? $aFilter['target_type'] : DBSIMPLE_SKIP,
isset($aFilter['target_id']) ? $aFilter['target_id'] : DBSIMPLE_SKIP,
isset($aFilter['is_user']) ? $aFilter['is_user'] : DBSIMPLE_SKIP,
isset($aFilter['text']) ? $aFilter['text'] : DBSIMPLE_SKIP,
($iCurrPage-1)*$iPerPage, $iPerPage
)) {
foreach ($aRows as $aRow) {
$aResult[]=Engine::GetEntity('ModuleFavourite_EntityTag',$aRow);
}
}
return $aResult;
}
}
?>

View file

@ -105,9 +105,9 @@ class ModuleTopic extends Module {
$oTopic->setVote(null);
}
if (isset($aFavouriteTopics[$oTopic->getId()])) {
$oTopic->setIsFavourite(true);
$oTopic->setFavourite($aFavouriteTopics[$oTopic->getId()]);
} else {
$oTopic->setIsFavourite(false);
$oTopic->setFavourite(null);
}
if (isset($aTopicsQuestionVote[$oTopic->getId()])) {
$oTopic->setUserQuestionIsVote(true);

View file

@ -137,7 +137,10 @@ class ModuleTopic_EntityTopic extends Entity
return $this->_aData['user_question_is_vote'];
}
public function getIsFavourite() {
return $this->_aData['topic_is_favourite'];
if ($this->getFavourite()) {
return true;
}
return false;
}
public function getCountFavourite() {
return $this->_aData['topic_count_favourite'];
@ -418,9 +421,6 @@ class ModuleTopic_EntityTopic extends Entity
public function setDateRead($data) {
$this->_aData['date_read']=$data;
}
public function setIsFavourite($data) {
$this->_aData['topic_is_favourite']=$data;
}
public function setCountFavourite($data) {
$this->_aData['topic_count_favourite']=$data;
}

View file

@ -308,6 +308,7 @@ $config['db']['table']['vote'] = '___db.table.prefix___vote';
$config['db']['table']['topic_read'] = '___db.table.prefix___topic_read';
$config['db']['table']['blog_user'] = '___db.table.prefix___blog_user';
$config['db']['table']['favourite'] = '___db.table.prefix___favourite';
$config['db']['table']['favourite_tag'] = '___db.table.prefix___favourite_tag';
$config['db']['table']['talk'] = '___db.table.prefix___talk';
$config['db']['table']['talk_user'] = '___db.table.prefix___talk_user';
$config['db']['table']['talk_blacklist'] = '___db.table.prefix___talk_blacklist';

View file

@ -53,6 +53,21 @@ ls.blocks = (function ($) {
}.bind(this));
};
/**
* Переключает вкладки в блоке, без использования Ajax
* @param obj
* @param block
*/
this.switchTab = function(obj, block) {
$('[id^="'+block+'_item"]').removeClass(this.options.active);
$(obj).addClass(this.options.active);
$('[id^="'+block+'_content"]').hide();
var id = $(obj).attr('id');
var idContent=$(obj).attr('id').replace(block+'_item_',block+'_content_');
$('#'+idContent).show();
};
/**
* Отображение процесса загрузки
*/

View file

@ -47,12 +47,73 @@ ls.favourite = (function ($) {
this.objFavourite.removeClass(this.options.active);
if (result.bState) {
this.objFavourite.addClass(this.options.active);
this.showTags(type,idTarget);
} else {
this.hideTags(type,idTarget);
}
ls.hook.run('ls_favourite_toggle_after',[idTarget,objFavourite,type,params,result],this);
}
}.bind(this));
return false;
}
};
this.showEditTags = function(idTarget,type,obj) {
var form=$('#favourite-form-tags');
$('#favourite-form-tags-target-type').val(type);
$('#favourite-form-tags-target-id').val(idTarget);
var text='';
var tags=$('.js-favourite-tags-'+$('#favourite-form-tags-target-type').val()+'-'+$('#favourite-form-tags-target-id').val());
tags.find('.js-favourite-tag-user a').each(function(k,tag){
if (text) {
text=text+', '+$(tag).text();
} else {
text=$(tag).text();
}
});
$('#favourite-form-tags-tags').val(text);
$(obj).parents('.js-favourite-insert-after-form').after(form);
form.show();
return false;
};
this.hideEditTags = function() {
$('#favourite-form-tags').hide();
return false;
};
this.saveTags = function(form) {
var url=aRouter['ajax']+'favourite/save-tags/';
'*saveTagsBefore*'; '*/saveTagsBefore*';
ls.ajaxSubmit(url, $(form), function(result) {
if (result.bStateError) {
ls.msg.error(null, result.sMsg);
} else {
this.hideEditTags();
var type=$('#favourite-form-tags-target-type').val();
var tags=$('.js-favourite-tags-'+type+'-'+$('#favourite-form-tags-target-id').val());
tags.find('.js-favourite-tag-user').detach();
var edit=tags.find('.js-favourite-tag-edit');
$.each(result.aTags,function(k,v){
edit.before('<li class="'+type+'-tags-user js-favourite-tag-user">, <a rel="tag" href="'+v.url+'">'+v.tag+'</a></li>');
});
ls.hook.run('ls_favourite_save_tags_after',[form,result],this);
}
}.bind(this));
return false;
};
this.hideTags = function(targetType,targetId) {
var tags=$('.js-favourite-tags-'+targetType+'-'+targetId);
tags.find('.js-favourite-tag-user').detach();
tags.find('.js-favourite-tag-edit').hide();
this.hideEditTags();
};
this.showTags = function(targetType,targetId) {
$('.js-favourite-tags-'+targetType+'-'+targetId).find('.js-favourite-tag-edit').show();
};
return this;
}).call(ls.favourite || {},jQuery);

View file

@ -56,4 +56,17 @@ CREATE TABLE IF NOT EXISTS `prefix_user_note` (
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
KEY `target_user_id` (`target_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `prefix_favourite` ADD `tags` VARCHAR( 250 ) NOT NULL;
CREATE TABLE IF NOT EXISTS `prefix_favourite_tag` (
`user_id` int(10) unsigned NOT NULL,
`target_id` int(11) NOT NULL,
`target_type` enum('topic','comment','talk') NOT NULL,
`is_user` tinyint(1) NOT NULL DEFAULT '0',
`text` varchar(50) NOT NULL,
KEY `user_id_target_type_id` (`user_id`,`target_type`,`target_id`),
KEY `target_type_id` (`target_type`,`target_id`),
KEY `is_user` (`is_user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View file

@ -192,6 +192,9 @@ return array(
'topic_favourite_add_already' => 'This topic is already in your favourites',
'topic_favourite_del' => 'Remove from favourites',
'topic_favourite_del_ok' => 'Topic removed from favourites',
'topic_favourite_tags_block' => 'Tags of favourite',
'topic_favourite_tags_block_all' => 'All tags',
'topic_favourite_tags_block_user' => 'My tags',
'error_favorite_topic_is_draft' => 'Topic of the draft can not be added to favorites',
'block_stream_comments_all' => 'All comment block',
'block_stream_topics_all' => 'All topics block',
@ -936,6 +939,12 @@ return array(
'geo_select_country' => 'Select country',
'geo_select_region' => 'Select region',
'geo_select_city' => 'Select city',
/**
* Favourite, general
*/
'favourite_form_tags_button_save' => 'Save',
'favourite_form_tags_button_cancel' => 'Cancel',
'favourite_form_tags_button_show' => 'edit my tags',
/**
* System
*/

View file

@ -192,6 +192,9 @@ return array(
'topic_favourite_add_already' => 'Этот топик уже есть в вашем избранном',
'topic_favourite_del' => 'удалить из избранного',
'topic_favourite_del_ok' => 'Топик удален из избранного',
'topic_favourite_tags_block' => 'Теги избранного',
'topic_favourite_tags_block_all' => 'Все теги',
'topic_favourite_tags_block_user' => 'Мои теги',
'error_favorite_topic_is_draft' => 'Топик из черновиков нельзя добавить в избранное',
'block_stream_comments_all' => 'Весь эфир',
'block_stream_topics_all' => 'Весь эфир',
@ -936,6 +939,12 @@ return array(
'geo_select_country' => 'Выберите страну',
'geo_select_region' => 'Укажите регион',
'geo_select_city' => 'Укажите город',
/**
* Избранное, общее
*/
'favourite_form_tags_button_save' => 'Сохранить',
'favourite_form_tags_button_cancel' => 'Отмена',
'favourite_form_tags_button_show' => 'изменить свои теги',
/**
* Системные сообщения
*/

View file

@ -7,6 +7,11 @@
{include file='menu.profile_favourite.tpl'}
{if $oUserCurrent and $oUserCurrent->getId()==$oUserProfile->getId()}
{$aBlockParams.user=$oUserProfile}
{insert name="block" block=tagsFavouriteTopic params=$aBlock.params}
{/if}
{include file='topic_list.tpl'}

View file

@ -0,0 +1,37 @@
<section class="block">
<header class="block-header">
<h3>{$aLang.topic_favourite_tags_block}</h3>
</header>
<div class="block-content">
<ul class="nav nav-pills">
<li id="block_favourite_topic_tags_item_all" class="active"><a href="#">{$aLang.topic_favourite_tags_block_all}</a></li>
<li id="block_favourite_topic_tags_item_user"><a href="#">{$aLang.topic_favourite_tags_block_user}</a></li>
{hook run='block_stream_nav_item'}
</ul>
<div id="block_favourite_topic_tags_content_all">
{if $aFavouriteTopicTags}
<ul class="tag-cloud">
{foreach from=$aFavouriteTopicTags item=oTag}
<li><a class="tag-size-{$oTag->getSize()} {if $sFavouriteTag==$oTag->getText()}tag-current{/if}" title="{$oTag->getCount()}" href="{$oFavouriteUser->getUserWebPath()}favourites/topics/tag/{$oTag->getText()|escape:'url'}/">{$oTag->getText()}</a></li>
{/foreach}
</ul>
{else}
<div class="notice-empty">{$aLang.block_empty_no_tags}</div>
{/if}
</div>
<div id="block_favourite_topic_tags_content_user" style="display: none;">
{if $aFavouriteTopicUserTags}
<ul class="tag-cloud">
{foreach from=$aFavouriteTopicUserTags item=oTag}
<li><a class="tag-size-{$oTag->getSize()}" title="{$oTag->getCount()}" href="{$oFavouriteUser->getUserWebPath()}favourites/topics/tag/{$oTag->getText()|escape:'url'}/">{$oTag->getText()}</a></li>
{/foreach}
</ul>
{else}
<div class="notice-empty">{$aLang.block_empty_no_tags}</div>
{/if}
</div>
</div>
</section>

View file

@ -0,0 +1,12 @@
{if $oUserCurrent}
<div id="favourite-form-tags" style="display:none;">
<form onsubmit="return ls.favourite.saveTags(this);">
<input type="hidden" name="target_type" value="" id="favourite-form-tags-target-type">
<input type="hidden" name="target_id" value="" id="favourite-form-tags-target-id">
<input type="text" name="tags" value="" id="favourite-form-tags-tags" class="autocomplete-tags-sep"><br/>
<button name="" class="button button-primary" />{$aLang.favourite_form_tags_button_save}</button>
<button name="" class="button" onclick="return ls.favourite.hideEditTags();" />{$aLang.favourite_form_tags_button_cancel}</button>
</form>
</div>
{/if}

View file

@ -95,6 +95,7 @@
{/if}
<div id="content" role="main" {if $noSidebar}class="content-full-width"{/if} {if $sidebarPosition == 'left'}class="content-right"{/if}>
{include file='favourite_form_tags.tpl'}
{include file='window_login.tpl'}
{include file='nav_content.tpl'}
{include file='system_message.tpl'}

View file

@ -34,6 +34,7 @@ jQuery(document).ready(function($){
// Автокомплит
ls.autocomplete.add($(".autocomplete-tags-sep"), aRouter['ajax']+'autocompleter/tag/', true);
ls.autocomplete.add($(".autocomplete-tags-sep"), aRouter['ajax']+'autocompleter/tag/', true);
ls.autocomplete.add($(".autocomplete-users"), aRouter['ajax']+'autocompleter/user/', true);
@ -63,6 +64,11 @@ jQuery(function($){
ls.blocks.load(this, 'block_blogs');
return false;
});
$('[id^="block_favourite_topic_tags_item"]').click(function(){
ls.blocks.switchTab(this, 'block_favourite_topic_tags');
return false;
});
});

View file

@ -1,6 +1,7 @@
{assign var="oBlog" value=$oTopic->getBlog()}
{assign var="oUser" value=$oTopic->getUser()}
{assign var="oVote" value=$oTopic->getVote()}
{assign var="oFavourite" value=$oTopic->getFavourite()}
<footer class="topic-footer">
@ -15,11 +16,21 @@
</ul>
<ul class="topic-tags">
<ul class="topic-tags js-favourite-insert-after-form js-favourite-tags-topic-{$oTopic->getId()}">
<li>{$aLang.block_tags}:</li>
{foreach from=$oTopic->getTagsArray() item=sTag name=tags_list}
<li><a rel="tag" href="{router page='tag'}{$sTag|escape:'url'}/">{$sTag|escape:'html'}</a>{if !$smarty.foreach.tags_list.last}, {/if}</li>
{/foreach}
{strip}
{foreach from=$oTopic->getTagsArray() item=sTag name=tags_list}
<li>{if !$smarty.foreach.tags_list.first}, {/if}<a rel="tag" href="{router page='tag'}{$sTag|escape:'url'}/">{$sTag|escape:'html'}</a></li>
{/foreach}
{if $oUserCurrent}
{if $oFavourite}
{foreach from=$oFavourite->getTagsArray() item=sTag name=tags_list_user}
<li class="topic-tags-user js-favourite-tag-user">, <a rel="tag" href="{$oUserCurrent->getUserWebPath()}favourites/topics/tag/{$sTag|escape:'url'}/">{$sTag|escape:'html'}</a></li>
{/foreach}
{/if}
<li class="topic-tags-edit js-favourite-tag-edit" {if !$oFavourite}style="display:none;"{/if}><a href="#" onclick="return ls.favourite.showEditTags({$oTopic->getId()},'topic',this);">{$aLang.favourite_form_tags_button_show}</a></li>
{/if}
{/strip}
</ul>