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:
Alexey Kachayev 2009-09-19 18:25:11 +00:00
parent 46a148947f
commit c68eb7204c
5 changed files with 40 additions and 15 deletions

View file

@ -63,7 +63,7 @@ class ActionTag extends Action {
/**
* Получаем список топиков
*/
$aResult=$this->Topic_GetTopicsByTag($sTag,$iPage,Config::Get('module.topic.per_page'));
$aResult=$this->Topic_GetTopicsByTag($sTag,$iPage,Config::Get('module.topic.per_page'));
$aTopics=$aResult['collection'];
/**
* Формируем постраничность

View file

@ -21,11 +21,18 @@
*/
class BlockTags extends Block {
public function Exec() {
/**
* Получаем список закрытых статей
*/
$oUserCurrent = $this->oEngine->User_GetUserCurrent();
$aCloseTopics = ($oUserCurrent)
? $this->oEngine->Topic_GetTopicsCloseByUser($oUserCurrent->getId())
: $this->oEngine->Topic_GetTopicsCloseByUser();
/**
* Получаем список тегов
*/
$aTags=$this->oEngine->Topic_GetTopicTags(70);
//dump($aTags);
$aTags=$this->oEngine->Topic_GetTopicTags(70,$aCloseTopics);
/**
* Расчитываем логарифмическое облако тегов
*/

View file

@ -795,9 +795,13 @@ class LsTopic extends Module {
* @param unknown_type $iPerPage
* @return unknown
*/
public function GetTopicsByTag($sTag,$iPage,$iPerPage) {
public function GetTopicsByTag($sTag,$iPage,$iPerPage) {
$aCloseTopics = ($this->oUserCurrent)
? $this->GetTopicsCloseByUser($this->oUserCurrent->getId())
: $this->GetTopicsCloseByUser();
if (false === ($data = $this->Cache_Get("topic_tag_{$sTag}_{$iPage}_{$iPerPage}"))) {
$data = array('collection'=>$this->oMapperTopic->GetTopicsByTag($sTag,$iCount,$iPage,$iPerPage),'count'=>$iCount);
$data = array('collection'=>$this->oMapperTopic->GetTopicsByTag($sTag,$aCloseTopics,$iCount,$iPage,$iPerPage),'count'=>$iCount);
$this->Cache_Set($data, "topic_tag_{$sTag}_{$iPage}_{$iPerPage}", array('topic_update','topic_new'), 60*60*24*2);
}
$data['collection']=$this->GetTopicsAdditionalData($data['collection']);
@ -809,9 +813,9 @@ class LsTopic extends Module {
* @param unknown_type $iLimit
* @return unknown
*/
public function GetTopicTags($iLimit) {
public function GetTopicTags($iLimit,$aExcludeTopic=array()) {
if (false === ($data = $this->Cache_Get("tag_{$iLimit}"))) {
$data = $this->oMapperTopic->GetTopicTags($iLimit);
$data = $this->oMapperTopic->GetTopicTags($iLimit,$aExcludeTopic);
$this->Cache_Set($data, "tag_{$iLimit}", array('topic_update','topic_new'), 60*60*24*3);
}
return $data;

View file

@ -209,7 +209,7 @@ class Mapper_Topic extends Mapper {
return $aTopics;
}
public function GetTopicsByTag($sTag,&$iCount,$iCurrPage,$iPerPage) {
public function GetTopicsByTag($sTag,$aExcludeTopic,&$iCount,$iCurrPage,$iPerPage) {
$sql = "
SELECT
topic_id
@ -217,14 +217,20 @@ class Mapper_Topic extends Mapper {
".Config::Get('db.table.topic_tag')."
WHERE
topic_tag_text = ?
{ AND topic_id NOT IN (?a) }
ORDER BY topic_id DESC
LIMIT ?d, ?d ";
$aTopics=array();
if ($aRows=$this->oDb->selectPage($iCount,$sql,$sTag,($iCurrPage-1)*$iPerPage, $iPerPage)) {
if ($aRows=$this->oDb->selectPage(
$iCount,$sql,$sTag,
(is_array($aExcludeTopic)&&count($aExcludeTopic)) ? $aExcludeTopic : DBSIMPLE_SKIP,
($iCurrPage-1)*$iPerPage, $iPerPage
)
) {
foreach ($aRows as $aTopic) {
$aTopics[]=$aTopic['topic_id'];
}
}
}
return $aTopics;
}
@ -258,21 +264,29 @@ class Mapper_Topic extends Mapper {
return $aTopics;
}
public function GetTopicTags($iLimit) {
public function GetTopicTags($iLimit,$aExcludeTopic=array()) {
$sql = "SELECT
tt.topic_tag_text,
count(tt.topic_tag_text) as count
FROM
".Config::Get('db.table.topic_tag')." as tt
".Config::Get('db.table.topic_tag')." as tt
WHERE
1=1
{AND tt.topic_id NOT IN(?a) }
GROUP BY
tt.topic_tag_text
ORDER BY
count desc
LIMIT 0, ?d
LIMIT 0, ?d
";
$aReturn=array();
$aReturnSort=array();
if ($aRows=$this->oDb->select($sql,$iLimit)) {
if ($aRows=$this->oDb->select(
$sql,
(is_array($aExcludeTopic)&&count($aExcludeTopic)) ? $aExcludeTopic : DBSIMPLE_SKIP,
$iLimit
)
) {
foreach ($aRows as $aRow) {
$aReturn[mb_strtolower($aRow['topic_tag_text'],'UTF-8')]=$aRow;
}

View file

@ -45,7 +45,7 @@ if (!function_exists('mb_strtolower')) {
*/
if (defined('SYS_HACKER_CONSOLE')) {
if (SYS_HACKER_CONSOLE) {
require_once DIR_SERVER_ROOT."/classes/lib/external/HackerConsole/Main.php";
require_once Config::Get('path.root.server')."/engine/lib/external/HackerConsole/Main.php";
new Debug_HackerConsole_Main(true);
}
}