1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-16 14:50:48 +03:00

Доработка тегов #725

This commit is contained in:
Mzhelskiy Maxim 2015-11-23 17:05:14 +07:00
parent 06eec61ca7
commit 285fca189f
6 changed files with 53 additions and 5 deletions

View file

@ -80,6 +80,29 @@ class ModuleFavourite_EntityFavourite extends Entity
return array(); return array();
} }
/**
* Возвращает массив тегов в виде объектов
*
* @return array
*/
public function getTagsObjects()
{
$aReturn = array();
if ($aTags = $this->getTagsArray()) {
foreach ($aTags as $sTag) {
if ($sTag) {
$aReturn[] = Engine::GetEntity('ModuleFavourite_EntityTag', array(
'target_type' => $this->getTargetType(),
'target_id' => $this->getTargetId(),
'user_id' => $this->getUserId(),
'text' => $sTag,
));
}
}
}
return $aReturn;
}
/** /**
* Устанавливает ID владельца * Устанавливает ID владельца
* *

View file

@ -29,6 +29,7 @@ class ModuleFavourite_EntityTag extends Entity
{ {
/** /**
* Возвращает URL страницы тега * Возвращает URL страницы тега
* todo: на странице списка топиков получение пользователя может стать узким местом
* *
* @return string * @return string
*/ */

View file

@ -506,6 +506,7 @@ class ModuleFavourite_MapperFavourite extends Mapper
{ {
$sql = "SELECT $sql = "SELECT
text, text,
user_id,
count(text) as count count(text) as count
FROM FROM
" . Config::Get('db.table.favourite_tag') . " " . Config::Get('db.table.favourite_tag') . "

View file

@ -613,6 +613,29 @@ class ModuleTopic_EntityTopic extends Entity
return array(); return array();
} }
/**
* Возвращает массив тегов в виде объектов
*
* @return array
*/
public function getTagsObjects()
{
$aReturn = array();
if ($aTags = $this->getTagsArray()) {
foreach ($aTags as $sTag) {
if ($sTag) {
$aReturn[] = Engine::GetEntity('ModuleTopic_EntityTopicTag', array(
'topic_id' => $this->getId(),
'user_id' => $this->getUserId(),
'blog_id' => $this->getBlogId(),
'topic_tag_text' => $sTag,
));
}
}
}
return $aReturn;
}
/** /**
* Возвращает количество новых комментариев в топике для текущего пользователя * Возвращает количество новых комментариев в топике для текущего пользователя
* *

View file

@ -140,13 +140,13 @@
{$favourite = $topic->getFavourite()} {$favourite = $topic->getFavourite()}
{if ! $isPreview} {if ! $isPreview}
{*component 'tags-personal' {component 'tags-personal'
classes = 'js-tags-favourite' classes = 'js-tags-favourite'
tags = $topic->getTags() tags = $topic->getTagsObjects()
tagsPersonal = ( $favourite ) ? $favourite->getTags() : [] tagsPersonal = ( $favourite ) ? $favourite->getTagsObjects() : []
isEditable = ! $favourite isEditable = ! $favourite
targetType = 'topic' targetType = 'topic'
targetId = $topic->getId()*} targetId = $topic->getId()}
{/if} {/if}
{/if} {/if}

@ -1 +1 @@
Subproject commit 30d7b8fa02e20c4869dce81be41117ddd1333ce2 Subproject commit 09ee27d08208a2cb80ac95b70db1115178e17d73