mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-03 06:55:03 +03:00
Система тегов работает с учетом закрытых тегов (отображение заметок по тегу и формирование облака).
This commit is contained in:
parent
46a148947f
commit
c68eb7204c
|
@ -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);
|
||||
/**
|
||||
* Расчитываем логарифмическое облако тегов
|
||||
*/
|
||||
|
|
|
@ -796,8 +796,12 @@ class LsTopic extends Module {
|
|||
* @return unknown
|
||||
*/
|
||||
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;
|
||||
|
|
|
@ -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,11 +217,17 @@ 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'];
|
||||
}
|
||||
|
@ -258,12 +264,15 @@ 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
|
||||
WHERE
|
||||
1=1
|
||||
{AND tt.topic_id NOT IN(?a) }
|
||||
GROUP BY
|
||||
tt.topic_tag_text
|
||||
ORDER BY
|
||||
|
@ -272,7 +281,12 @@ class Mapper_Topic extends Mapper {
|
|||
";
|
||||
$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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue