-------------------------------------------------------------------------
SQL запросы в базу
-------------------------------------------------------------------------
Код:
ALTER TABLE `bb_categories` ADD `cat_tags` VARCHAR( 255 ) NOT NULL ,
ADD `cat_tags_full` TEXT NOT NULL ;
-------------------------------------------------------------------------
admin_forums.php
-------------------------------------------------------------------------
найти
PHP:
'cat_order' => (int) $order['max_order'] + 10,
ниже добавить
PHP:
'cat_tags' => (string) trim($_POST['cat_tags'], ','),
найти
PHP:
'CAT_TITLE' => htmlCHR($cat_info['cat_title']),
ниже добавить
PHP:
'CAT_TAGS' => $cat_info['cat_tags'],
'CAT_ID' => $cat_id,
найти
PHP:
if ($cur_cat_title && $cur_cat_title !== $new_cat_title)
{
check_name_dup('cat', $new_cat_title);
$new_cat_title_sql = DB()->escape($new_cat_title);
DB()->query("
UPDATE ". BB_CATEGORIES ." SET
cat_title = '$new_cat_title_sql'
WHERE cat_id = $cat_id
");
}
заменить
PHP:
$new_cat_title_sql = DB()->escape($new_cat_title);
DB()->query("
UPDATE ". BB_CATEGORIES ." SET
cat_title = '$new_cat_title_sql',
cat_tags = '". trim($_POST['cat_tags'], ',') ."'
WHERE cat_id = $cat_id
");
if ($tags = CACHE('bb_cache')->get("cat_tags_$cat_id"))
{
foreach($tags as $text => $num)
{
if($num > 2) $tags_sql[] = array($text => $num);
}
DB()->query("
UPDATE ". BB_CATEGORIES ." SET
cat_title = '$new_cat_title_sql',
cat_tags_full = '". serialize($tags_sql) ."'
WHERE cat_id = $cat_id
");
}
найти
PHP:
$sql = "SELECT cat_id, cat_title, cat_order
заменить
найти
PHP:
'CAT_DESC' => htmlCHR($category_rows[$i]['cat_title']),
ниже добавить
PHP:
'CAT_TAGS' => htmlCHR($category_rows[$i]['cat_tags']),
----------------------------------------------------------------------
manage_admin.php
----------------------------------------------------------------------
найти
PHP:
}
$this->response['mode'] = $mode;
заменить
PHP:
case 'cat_tags':
$cat_id = (int) $this->request['cat_id'];
$sql = DB()->fetch_rowset("SELECT t.topic_title FROM ". BB_FORUMS ." f, ". BB_TOPICS ." t WHERE f.cat_id = $cat_id AND f.forum_id = t.forum_id", 'topic_title');
if(!$sql) bb_die('Нет раздач в форумах');
foreach($sql as $row)
{
$sql2 = title_replace($row);
foreach($sql2 as $row2)
{
$text[$row2] = !empty($text[$row2]) ? ($text[$row2] + 1) : 1;
}
}
CACHE('bb_cache')->set("cat_tags_$cat_id", $text);
$html = '';
foreach($text as $text2 => $num)
{
if($num > 3) $html .= "<a href=\"#\" onclick=\"add_tag('$text2'); return false;\">$text2</a> ($num), ";
}
$this->response['html'] = $html;
break;
}
$this->response['mode'] = $mode;
function title_replace($text)
{
$text = mb_strtolower(trim($text), 'UTF-8');
$text = html_ent_decode($text);
$text = preg_replace('#[^a-zа-я0-9\/\s]#ui', '', $text);
$text = str_replace(' ', ' ', $text);
$text = explode(' ', $text);
return $text;
}
-----------------------------------------------------------------------------
sessions_cleanup.php
-----------------------------------------------------------------------------
в конец добавить:
PHP:
$tags = array();
$sql = DB()->fetch_rowset("SELECT cat_tags_full FROM ". BB_CATEGORIES ." WHERE cat_tags_full != ''", 'cat_tags_full');
foreach($sql as $row)
{
$sql2 = explode(', ', $row);
foreach($sql2 as $row2)
{
$tags[$row2] = !empty($tags[$row2]) ? ($tags[$row2] + 1) : 1;
}
}
bb_log($tags, 'tags');
---------------------------------------------------------------------------------
build_cat_forums.php
---------------------------------------------------------------------------------
найти
PHP:
'cat_title_html' => array(),
ниже добавить
PHP:
'cat_tags_html' => array(),
найти
PHP:
$data['cat_title_html'][$row['cat_id']] = htmlCHR($row['cat_title']);
ниже добавить
PHP:
$data['cat_tags_html'][$row['cat_id']] = htmlCHR($row['cat_tags']);
-------------------------------------------------------------------------------
page_header.php
-------------------------------------------------------------------------------
найти
ниже добавить
PHP:
$tags = array();
$sql = DB()->fetch_rowset("SELECT cat_tags_full FROM ". BB_CATEGORIES ." WHERE cat_tags_full != ''", 'cat_tags_full');
foreach($sql as $row)
{
foreach(unserialize($row) as $num => $array)
{
foreach($array as $text => $num)
{
$tags[$text] = !empty($tags[$text]) ? ($tags[$text] + $num) : $num;
}
}
}
$max = max($tags) - min($tags);
$html_tags = '';
foreach($tags as $text => $num)
{
if(mb_strlen($text, 'UTF-8') > 2) $html_tags .= "<a href='tracker.php?nm=". $text ."' class='". proc($num, $max) ."'>$text</a>\n";
}
function proc($num, $max)
{
$proc = (100*$num)/$max;
if($proc >= 0)
{
$style = 'tag1';
}
if($proc >= 10)
{
$style = 'tag2';
}
if($proc >= 20)
{
$style = 'tag3';
}
if($proc >= 30)
{
$style = 'tag4';
}
if($proc >= 40)
{
$style = 'tag5';
}
if($proc >= 50)
{
$style = 'tag6';
}
if($proc >= 60)
{
$style = 'tag7';
}
if($proc >= 70)
{
$style = 'tag8';
}
if($proc >= 80)
{
$style = 'tag9';
}
if($proc >= 90)
{
$style = 'tag10';
}
return $style;
}
найти
PHP:
'SIMPLE_HEADER' => !empty($gen_simple_header),
ниже добавить
PHP:
'HTML_TAGS' => $html_tags,
-------------------------------------------------------------------------------
index.php
-------------------------------------------------------------------------------
найти
PHP:
$cat_title_html = $forums['cat_title_html'];
ниже добавить
PHP:
$cat_tags_html = $forums['cat_tags_html'];
найти
PHP:
'U_VIEWCAT' => "index.php?c=$cid",
ниже добавить
PHP:
'CAT_TAGS' => $cat_tags_html[$cid],
-------------------------------------------------------------------------------
viewforum.php ??? (не уверен надо ли оно здесь)
-------------------------------------------------------------------------------
найти
PHP:
if (!$forum_id OR !$forum_data = @$forums['forum'][$forum_id])
{
bb_die($lang['FORUM_NOT_EXIST']);
}
ниже добавить
PHP:
$cat_title_html = $forums['cat_title_html'];
$template->assign_vars(array(
'CAT_ID' => $forum_data['cat_id'],
'CAT_NAME' => $cat_title_html[$forum_data['cat_id']],
));
------------------------------------------------------------------------------
viewtopic.php ??? (не уверен надо ли оно здесь)
------------------------------------------------------------------------------
найти
PHP:
if ($parent_id = $t_data['forum_parent'])
{
if (!$forums = $datastore->get('cat_forums'))
{
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
заменить
PHP:
if (!$forums = $datastore->get('cat_forums'))
{
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
}
$cat_title_html = $forums['cat_title_html'];
if ($parent_id = $t_data['forum_parent'])
{
найти
PHP:
'FORUM_NAME' => htmlCHR($forum_name),
ниже добавить
PHP:
'CAT_ID' => $t_data['cat_id'],
'CAT_NAME' => $cat_title_html[$t_data['cat_id']],
---------------------------------------------------------------------------------
admin_forums.tpl
---------------------------------------------------------------------------------
найти
HTML:
<h1>{L_EDIT_CATEGORY}</h1>
выше добавить
HTML:
<script type="text/javascript">
function add_tag(tag)
{
var message = $('#tags').val();
if(!message) $('#tags').attr('value', tag);
else $('#tags').attr('value', message +', '+ tag);
$('#tags').focus();
}
ajax.callback.manage_admin = function(data) {
$('#'+data.mode).html(data.html);
};
</script>
найти
HTML:
<td class="pad_12 tCenter">
{L_CATEGORY}:
<input type="text" name="cat_title" size="60" value="{CAT_TITLE}" />
<input type="submit" name="submit" value="{S_SUBMIT_VALUE}" class="bold" />
</td>
заменить
HTML:
<td class="pad_12 tCenter">
{L_CATEGORY}:
<input type="text" name="cat_title" size="60" value="{CAT_TITLE}" /><br /><br />
Tags:
<input type="text" name="cat_tags" id="tags" size="100" value="{CAT_TAGS}" /> (через запятую)<br />
<div id="cat_tags" class="pad_4" align="center"></div>
<input type="submit" name="submit" value="{S_SUBMIT_VALUE}" class="bold" />
<input type="button" onclick="ajax.exec({action: 'manage_admin', mode: 'cat_tags', cat_id: {CAT_ID}});" value="Сгенерировать теги" class="bold">
</td>
найти
HTML:
<a href="{c.U_VIEWCAT}"><span class="gen"><b>{c.CAT_DESC}</b></span></a>
заменить
HTML:
<a href="{c.U_VIEWCAT}"><span class="gen"><b>{c.CAT_DESC}</b> ({c.CAT_TAGS})</span></a>
найти
HTML:
<input class="post" type="text" name="categoryname" />
ниже добавить
HTML:
Tags: <input type="text" name="cat_tags" size="100" value="" /> (через запятую)
---------------------------------------------------------------------------------
main.css
---------------------------------------------------------------------------------
Код:
.tagcloud {
background: #f7f3da url(/templates/default/images/tagcloudbg.jpg) repeat-x;
padding: 4px 20px 2px 20px;
text-align: center;
line-height: 220%;
width: auto;
}
.tagcloud a {
color: #a4812a;
margin: 0 3px;
white-space: nowrap;
font-family: Georgia, "Times New Roman", Times, serif;
text-decoration: none;
}
.tagcloud a.tag1 {
font-size: 100%;
}
.tagcloud a.tag2 {
font-size: 120%;
}
.tagcloud a.tag3 {
font-size: 140%;
}
.tagcloud a.tag4 {
font-size: 160%;
}
.tagcloud a.tag5 {
font-size: 180%;
}
.tagcloud a.tag6 {
font-size: 200%;
}
.tagcloud a.tag7 {
font-size: 220%;
}
.tagcloud a.tag8 {
font-size: 240%;
}
.tagcloud a.tag9 {
font-size: 260%;
}
.tagcloud a.tag10 {
font-size: 280%;
}
.tagcloud a:hover {
border-bottom: 1px solid #a4812a;
}
---------------------------------------------------------------------------------
index.tpl после <h3 class="cat_title"><a href="{c.U_VIEWCAT}">{c.CAT_TITLE}</a></h3>
---------------------------------------------------------------------------------
HTML:
<!-- IF c.CAT_TAGS -->
<h5 class="lightgrey">{L_TAGS}</h5>
<span class="cat_tags{c.CAT_ID}">{c.CAT_TAGS}</span><br />
<script type="text/javascript">
$(document).ready(function(){
var tags = $('.cat_tags{c.CAT_ID}').html();
var html_tags = '';
data = tags.split(', ');
for(i=0; i < data.length; i++) {
if(i != (data.length - 1)) pp = ', ';
else pp = '';
html_tags += '<a href="{U_TRACKER}?nm='+ data[i] +'">'+ data[i] +'</a>'+ pp;
}
$('.cat_tags{c.CAT_ID}').html(html_tags);
});
</script>
<!-- ENDIF -->
---------------------------------------------------------------------------------
page_header.tpl после <!-- ENDIF / SHOW_ONLY_NEW_MENU -->
---------------------------------------------------------------------------------
HTML:
<div id="tagcloud" class="tagcloud">
{HTML_TAGS}
</div>
в общем кто рискнет поставить, отпишитесь.