1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-01 14:05:07 +03:00

рефакторинг вывода тегов у топиков

This commit is contained in:
Mzhelskiy Maxim 2009-05-02 07:01:28 +00:00
parent 045e8dbfb8
commit 1ada3f8090
3 changed files with 12 additions and 19 deletions

View file

@ -100,21 +100,10 @@ class TopicEntity_Topic extends Entity
public function getCountCommentNew() {
return $this->_aData['count_comment_new'];
}
public function getTagsLink() {
$aTags=explode(',',$this->getTags());
foreach ($aTags as $key => $value) {
$aTags[$key]='<a href="'.DIR_WEB_ROOT.'/tag/'.htmlspecialchars($value).'/">'.htmlspecialchars($value).'</a>';
}
return trim(join(', ',$aTags));
}
public function getTagsLinkNew() {
$aTags=explode(',',$this->getTags());
foreach ($aTags as $key => $value) {
$aTags[$key]='<li><a href="'.DIR_WEB_ROOT.'/tag/'.htmlspecialchars($value).'/">'.htmlspecialchars($value).'</a></li>';
}
return trim(join(', ',$aTags));
}
}
public function getTagsArray() {
return explode(',',$this->getTags());
}
public function getUserLogin() {
return $this->_aData['user_login'];
}

View file

@ -50,7 +50,9 @@
{$oTopic->getText()}
</div>
<ul class="tags">
{$oTopic->getTagsLinkNew()}
{foreach from=$oTopic->getTagsArray() item=sTag name=tags_list}
<li><a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_TAG}/{$sTag|escape:'html'}/">{$sTag|escape:'html'}</a>{if !$smarty.foreach.tags_list.last}, {/if}</li>
{/foreach}
</ul>
<ul class="voting {if $oTopic->getUserIsVote() || ($oUserCurrent && $oTopic->getUserId()==$oUserCurrent->getId())|| strtotime($oTopic->getDateAdd())<$smarty.now-$VOTE_LIMIT_TIME_TOPIC}{if $oTopic->getRating()>0}positive{elseif $oTopic->getRating()<0}negative{/if}{/if} {if !$oUserCurrent || $oTopic->getUserId()==$oUserCurrent->getId() || strtotime($oTopic->getDateAdd())<$smarty.now-$VOTE_LIMIT_TIME_TOPIC}guest{/if} {if $oTopic->getUserIsVote()} voted {if $oTopic->getUserVoteDelta()>0}plus{elseif $oTopic->getUserVoteDelta()<0}minus{/if}{/if}">
<li class="plus"><a href="#" onclick="lsVote.vote({$oTopic->getId()},this,1,'topic'); return false;"></a></li>

View file

@ -60,7 +60,9 @@
{/if}
</div>
<ul class="tags">
{$oTopic->getTagsLinkNew()}
{foreach from=$oTopic->getTagsArray() item=sTag name=tags_list}
<li><a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_TAG}/{$sTag|escape:'html'}/">{$sTag|escape:'html'}</a>{if !$smarty.foreach.tags_list.last}, {/if}</li>
{/foreach}
</ul>
<ul class="voting {if $oTopic->getUserIsVote() || ($oUserCurrent && $oTopic->getUserId()==$oUserCurrent->getId()) || strtotime($oTopic->getDateAdd())<$smarty.now-$VOTE_LIMIT_TIME_TOPIC}{if $oTopic->getRating()>0}positive{elseif $oTopic->getRating()<0}negative{/if}{/if} {if !$oUserCurrent || $oTopic->getUserId()==$oUserCurrent->getId() || strtotime($oTopic->getDateAdd())<$smarty.now-$VOTE_LIMIT_TIME_TOPIC}guest{/if} {if $oTopic->getUserIsVote()} voted {if $oTopic->getUserVoteDelta()>0}plus{elseif $oTopic->getUserVoteDelta()<0}minus{/if}{/if}">
<li class="plus"><a href="#" onclick="lsVote.vote({$oTopic->getId()},this,1,'topic'); return false;"></a></li>
@ -73,9 +75,9 @@
<li class="author"><a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_PROFILE}/{$oTopic->getUserLogin()}/">{$oTopic->getUserLogin()}</a></li>
<li class="comments-total">
{if $oTopic->getCountComment()>0}
<a href="{$DIR_WEB_ROOT}/blog/{if $oTopic->getBlogUrl()}{$oTopic->getBlogUrl()}/{/if}{$oTopic->getId()}.html#comments" title="{$aLang.topic_comment_read}"><span class="red">{$oTopic->getCountComment()}</span>{if $oTopic->getCountCommentNew()}<span class="green">+{$oTopic->getCountCommentNew()}</span>{/if}</a>
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_BLOG}/{if $oTopic->getBlogUrl()}{$oTopic->getBlogUrl()}/{/if}{$oTopic->getId()}.html#comments" title="{$aLang.topic_comment_read}"><span class="red">{$oTopic->getCountComment()}</span>{if $oTopic->getCountCommentNew()}<span class="green">+{$oTopic->getCountCommentNew()}</span>{/if}</a>
{else}
<a href="{$DIR_WEB_ROOT}/blog/{if $oTopic->getBlogUrl()}{$oTopic->getBlogUrl()}/{/if}{$oTopic->getId()}.html#comments" title="{$aLang.topic_comment_add}"><span class="red">{$aLang.topic_comment_add}</span></a>
<a href="{$DIR_WEB_ROOT}/{$ROUTE_PAGE_BLOG}/{if $oTopic->getBlogUrl()}{$oTopic->getBlogUrl()}/{/if}{$oTopic->getId()}.html#comments" title="{$aLang.topic_comment_add}"><span class="red">{$aLang.topic_comment_add}</span></a>
{/if}
</li>
</ul>