- Совместимость
- не проверялся на совместимость
- Изменения в БД
- не требуются
- Автор
- frost444
- Общественное достояние
- да
Описание: добавляет возможность вывода облака поисковых тегов.
- Инструкция по установке
-
PHP:
----в нужный файл к примеру index.php if ($bb_cfg['tags']['on']) { if (!CACHE('bb_cache')->get('tags')) { $sql_t = DB()->fetch_rowset("SELECT t.topic_title FROM ".BB_BT_TORRENTS." AS tt, ".BB_TOPICS." AS t WHERE t.topic_id = tt.topic_id GROUP BY tt.reg_time DESC LIMIT 40"); $sql_t['tag'] = tag_encode(r_implode(" ", $sql_t)); $sql_t['tag'] = iconv("UTF-8", "CP1251//IGNORE", $sql_t['tag']); $sql_t['title'] = "Кешированные теги"; $row = array(); $row['tag'] = $sql_t['tag']; $row['title'] = $sql_t['title']; CACHE('bb_cache')->set('tags', $row, $bb_cfg['tags']['cache']*60*60, 'UTF-8'); }else{ $sql_t = CACHE('bb_cache')->get('tags'); } @$tagi = iconv("CP1251", "UTF-8", $sql_t['tag']); $tags = explode(" ", $tagi); $mycloud = new TagsCloud($tags); $tags_list = $mycloud->get_cloud(); foreach ($tags_list as $tag) { $nbsp = $bb_cfg['tags_flash'] ? '' : ' '; $template->assign_block_vars('tagrow', array( 'TAGS' => $tag.$nbsp )); } } ----в файл шаблона, к примеру index.tpl <!-- IF $bb_cfg['tags']['on'] --> <div class="post_body_m"> <a class="footeri"><u>Теги:</u></a> <script type="text/javascript"> $(document).ready(function(){ var f_color = ''; $("a.structure").hover(function() { f_color = this.style.color; $(this).animate({ backgroundColor: "#4f94d0", color: "#ffffff" }, 700); },function(){ $(this).animate({ backgroundColor: "white", color: "#4b73d4" }, 200); }); }); </script> <!-- BEGIN tagrow -->{tagrow.TAGS}<!-- END tagrow --> </div> <!-- ENDIF --> ----в config.php $bb_cfg['tags'] = array( 'on' => true, 'cache' => 2, //кеш держится в часах ); ----functions.php function tag_encode($str) { $str = mb_strtolower(trim($str), 'UTF-8'); $str = strip_tags($str); $search = array('#([\ri\n])[\s]+#is','#[^a-zа-я\/\s]#ui','#\s+#i','#[\/]#','#_+#'); $replace = array(' ',' ',' ',' ',' '); $str = preg_replace($search, $replace, $str); $str = strtr($str, array("а"=>"а","б"=>"б","в"=>"в","г"=>"г","д"=>"д","е"=>"е","ё"=>"е","ж"=>"ж","з"=>"з","и"=>"и","й"=>"й","к"=>"к","л"=>"л","м"=>"м","н"=>"н","о"=>"о","п"=>"п","р"=>"р","с"=>"с","т"=>"т","у"=>"у","ф"=>"ф","х"=>"х","ц"=>"ц","ч"=>"ч","ш"=>"ш","щ"=>"щ","ъ"=>"ъ","ы"=>"ы","ь"=>"ь","э"=>"э","ю"=>"ю","я"=>"я")); $str = preg_replace("/[\s]([^\s]{1,5})[\s]/", " ", str_replace(" ", " ", " ".$str." ")); $str = preg_replace('/ +/',' ' , $str); $str = trim($str, " "); return $str; } function r_implode( $glue, $pieces ) { foreach( $pieces as $r_pieces ) { if( is_array( $r_pieces ) ) { $retVal[] = r_implode( $glue, $r_pieces ); } else { $retVal[] = $r_pieces; } } return implode( $glue, $retVal ); }