สำหรับ SMF 2.0.xxแก้ไขไฟล์:file $boarddir/index.php
ค้นหา -->>
'register2' => array('Register.php', 'Register2'),
เพิ่มไว้หลัง -->>
'related' => array('Subs-Related.php', 'Related'),
file $sourcedir/Admin.php
ค้นหา -->>
'current_theme' => array(
เพิ่มไว้ก่อน -->>
'relatedtopics' => array(
'label' => $txt['admin_related_topic'],
'file' => 'RelatedTopics.php',
'function' => 'RelatedTopicsAdmin',
'subsections' => array(
'main' => array($txt['admin_related_topics_information']),
'settings' => array($txt['admin_related_topics_settings']),
'methods' => array($txt['admin_related_topics_methods']),
),
),
ค้นหา -->>
// Mod Authors for a "ADD AFTER" on this line. Ensure you end your change with a comma. For example:
เพิ่มไว้หลัง -->>
'related' => array($txt['admin_related_topic']),
file $sourcedir/RemoveTopic.php
ค้นหา -->>
// Recycle topics that aren't in the recycle board...
เพิ่มไว้ก่อน -->>
// Added by Related Topics
require_once($sourcedir . '/Subs-Related.php');
relatedRemoveTopics($topics);
// Related Topics END
file $sourcedir/Subs-Post.php
ค้นหา -->>
$topicOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}topics', 'id_topic');
เพิ่มไว้หลัง -->>
// Added by Related Topics
global $sourcedir;
require_once($sourcedir . '/Subs-Related.php');
relatedUpdateTopics($topicOptions['id']);
// Related Topics END
ค้นหา -->>
if ($smcFunc['db_num_rows']($request) == 1)
updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
แก้เป็น -->>
if ($smcFunc['db_num_rows']($request) == 1)
{
updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
// Added by Related Topics
global $sourcedir;
require_once($sourcedir . '/Subs-Related.php');
relatedUpdateTopics($topicOptions['id']);
// Related Topics END
}
file $sourcedir/Display.php
ค้นหา -->>
$topicinfo = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
เพิ่มไว้หลัง -->>
// Added by Related Topics
if (!empty($modSettings['relatedTopicsEnabled']))
{
require_once($sourcedir . '/Subs-Related.php');
loadRelated($topic);
}
file $themedir/Display.template.php
ค้นหา -->>
if ($context['show_spellchecking'])
echo '
<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value="" /></form>
เพิ่มไว้ก่อน -->>
// Added by Related Topics
if (!empty($context['related_topics'])) // TODO: Have ability to display no related topics?
{
echo '
<h3 class="titlebg"><span class="left"></span>', $txt['related_topics'], '</h3>
<div class="tborder topic_table" id="messageindex">
<table class="table_grid" cellspacing="0">
<thead>
<tr>';
// Are there actually any topics to show?
if (!empty($context['related_topics']))
{
echo '
<th scope="col" class="smalltext first_th" width="8%" colspan="2"> </th>
<th scope="col" class="smalltext">', $txt['subject'], ' / ', $txt['started_by'], '</th>
<th scope="col" class="smalltext center" width="14%">', $txt['replies'], '</th>
<th scope="col" class="smalltext last_th" width="22%">', $txt['last_post'], '</th>';
}
// No topics.... just say, "sorry bub".
else
echo '
<th scope="col" class="smalltext first_th" width="8%"> </th>
<th class="smalltext" colspan="3"><strong>', $txt['msg_alert_none'], '</strong></th>
<th scope="col" class="smalltext last_th" width="8%"> </th>';
echo '
</tr>
</thead>
<tbody>';
foreach ($context['related_topics'] as $topic)
{
// Is this topic pending approval, or does it have any posts pending approval?
if ($topic['board']['can_approve_posts'] && $topic['unapproved_posts'])
$color_class = !$topic['approved'] ? 'approvetbg' : 'approvebg';
// We start with locked and sticky topics.
elseif ($topic['is_sticky'] && $topic['is_locked'])
$color_class = 'stickybg locked_sticky';
// Sticky topics should get a different color, too.
elseif ($topic['is_sticky'])
$color_class = 'stickybg';
// Locked topics get special treatment as well.
elseif ($topic['is_locked'])
$color_class = 'lockedbg';
// Last, but not least: regular topics.
else
$color_class = 'windowbg';
// Some columns require a different shade of the color class.
$alternate_class = $color_class . '2';
echo '
<tr>
<td class="icon1 ', $color_class, '">
<img src="', $settings['images_url'], '/topic/', $topic['class'], '.gif" alt="" />
</td>
<td class="icon2 ', $color_class, '">
<img src="', $topic['first_post']['icon_url'], '" alt="" />
</td>
<td class="subject ', $alternate_class, '">
<div ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\', \'' . $context['session_id'] . '\', \'' . $context['session_var'] . '\');"' : ''), '>
', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], (!$topic['board']['can_approve_posts'] && !$topic['approved'] ? ' <em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', $topic['is_sticky'] ? '</strong>' : '' ;
// Is this topic new? (assuming they are logged in!)
if ($topic['new'] && $context['user']['is_logged'])
echo '
<a href="', $topic['new_href'], '" id="newicon' . $topic['first_post']['id'] . '"><img src="', $settings['lang_images_url'], '/new.gif" alt="', $txt['new'], '" /></a>';
echo '
<p>', $txt['started_by'], ' ', $topic['first_post']['member']['link'], '
<small id="pages' . $topic['first_post']['id'] . '">', $topic['pages'], '</small>
<small>', $topic['board']['link'], '</small>
</p>
</div>
</td>
<td class="stats ', $color_class, '">
', $topic['replies'], ' ', $txt['replies'], '
<br />
', $topic['views'], ' ', $txt['views'], '
</td>
<td class="lastpost ', $alternate_class, '">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" /></a>
', $topic['last_post']['time'], '<br />
', $txt['by'], ' ', $topic['last_post']['member']['link'], '
</td>
</tr>';
}
echo '
</table>
</div><br />';
}
file $languagedir/Modifications.thai-utf8.php
เพิ่ม -->>
// Added by Related Topics
$txt['admin_related_topic'] = 'Related Topics';
$txt['admin_related_topics_information'] = 'Information';
$txt['admin_related_topics_settings'] = 'Settings';
$txt['admin_related_topics_methods'] = 'Methods';
$txt['related_topics_admin_title'] = 'Related Topics';
$txt['related_topics_admin_desc'] = '';
$txt['related_latest_news'] = 'Latest News';
$txt['related_news_unable_to_connect'] = 'Unable to connect to <a href="http://www.smfarcade.info">SMFArcade.info</a> for latest news...';
$txt['related_version_info'] = 'Version Information';
$txt['related_installed_version'] = 'Installed Version';
$txt['related_latest_version'] = 'Latest Version';
$txt['related_topics_settings_title'] = 'Related Topics';
$txt['related_topics_methods_title'] = 'Methods';
$txt['related_topics_methods'] = 'Select methods used for determining Related Topics<div class="smalltext">Rebuild of index is required after changing these settings</div>';
$txt['related_topics_index'] = 'Index';
$txt['related_topics_rebuild'] = 'Rebuild Indexes';
$txt['related_topics_rebuild_desc'] = 'Use this after changing settings or to build initial cache';
$txt['relatedFulltext'] = 'Fulltext';
$txt['relatedTopicsEnabled'] = 'Enable Related Topics';
$txt['relatedTopicsCount'] = 'How many related topics to show';
$txt['relatedIgnoredboards'] = 'Ignored Boards<div class="smalltext">board ids separated with commas</div>';
$txt['no_methods_selected'] = 'You haven\'t selected which methods to use to determine related topics';
$txt['related_topics'] = 'Related Topics';
// END Added by Related Topics
ดาวน์โหลด: Related.rar
ขออภัย! ท่านไม่สามารถเข้าถึงข้อมูลส่วนนี้ได้ กรุณาอ่าน เงื่อนไขการใช้งาน DexMore.Comแตกไฟล์แล้วอัพโหลดไปไว้ที่
file RelatedTopics.php -->> $sourcedir
file Subs-Related.php -->> $sourcedir
file Subs-RelatedFulltext.php -->> $sourcedir
file RelatedTopicsAdmin.template.php -->> $themedir
สร้างไฟล์: related_topics.php เพื่อสร้างฐานข้อมูล ไว้ใน $boarddir (ที่เดียวกับไฟล์ SSI.php) รัน http://www.your_url.xxx/$boarddir/related_topics.php -->> Enter เสร็จแล้วลบทิ้ง
<?php
/*******************************************************************************
This is script for installing Related Topics
ATTENTION: If you are trying to INSTALL this package, please access
it directly, with a URL like the following:
http://www.yourdomain.tld/forum/related_topics.php (or similar.)
*******************************************************************************/
global $db_prefix, $db_type;
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
$index_type = $db_type == 'mysql' ? 'fulltext' : '';
$relatedSettings = array(
'relatedTopicsEnabled' => array(0, false),
'relatedTopicsCount' => array(5, false),
'relatedIndex' => array($index_type, false),
'relatedIgnoredboards' => array('', false),
);
$tables = array(
'related_topics' => array(
'name' => 'related_topics',
'columns' => array(
array(
'name' => 'id_topic_first',
'type' => 'int',
'null' => false,
'unsigned' => true,
),
array(
'name' => 'id_topic_second',
'type' => 'int',
'null' => false,
'unsigned' => true,
),
array(
'name' => 'score',
'type' => 'float',
'null' => false,
'unsigned' => true,
),
),
'indexes' => array(
array(
'type' => 'primary',
'columns' => array('id_topic_first', 'id_topic_second')
),
)
),
);
doSettings($relatedSettings);
doTables($tables);
// Functions
function doTables($tables, $columnRename = array())
{
global $smcFunc, $db_prefix, $db_type, $db_show_debug;
$log = array();
$existingTables = $smcFunc['db_list_tables']();
foreach ($tables as $table)
{
$table_name = $table['name'];
$tableExists = in_array($db_prefix . $table_name, $existingTables);
// Create table
if (!$tableExists && empty($table['smf']))
$smcFunc['db_create_table']('{db_prefix}' . $table_name, $table['columns'], $table['indexes']);
// Update table
else
{
$currentTable = $smcFunc['db_table_structure']('{db_prefix}' . $table_name);
// Renames in this table?
if (!empty($table['rename']))
{
foreach ($currentTable['columns'] as $column)
{
if (isset($table['rename'][$column['name']]))
{
$old_name = $column['name'];
$column['name'] = $table['rename'][$column['name']];
$smcFunc['db_change_column']('{db_prefix}' . $table_name, $old_name, $column);
}
}
}
// Global renames? (should be avoided)
if (!empty($columnRename))
{
foreach ($currentTable['columns'] as $column)
{
if (isset($columnRename[$column['name']]))
{
$old_name = $column['name'];
$column['name'] = $columnRename[$column['name']];
$smcFunc['db_change_column']('{db_prefix}' . $table_name, $old_name, $column);
}
}
}
// Check that all columns are in
foreach ($table['columns'] as $id => $col)
{
$exists = false;
// TODO: Check that definition is correct
foreach ($currentTable['columns'] as $col2)
{
if ($col['name'] === $col2['name'])
{
$exists = true;
break;
}
}
// Add missing columns
if (!$exists)
$smcFunc['db_add_column']('{db_prefix}' . $table_name, $col);
}
// Remove any unnecassary columns
foreach ($currentTable['columns'] as $col)
{
$exists = false;
foreach ($table['columns'] as $col2)
{
if ($col['name'] === $col2['name'])
{
$exists = true;
break;
}
}
if (!$exists && isset($table['upgrade']['columns'][$col['name']]))
{
if ($table['upgrade']['columns'][$col['name']] == 'drop')
$smcFunc['db_remove_column']('{db_prefix}' . $table_name, $col['name']);
}
elseif (!$exists && !empty($db_show_debug) && empty($table['smf']))
$log[] = sprintf('Table %s has non-required column %s', $table_name, $col['name']);
}
// Check that all indexes are in and correct
foreach ($table['indexes'] as $id => $index)
{
$exists = false;
foreach ($currentTable['indexes'] as $index2)
{
// Primary is special case
if ($index['type'] == 'primary' && $index2['type'] == 'primary')
{
$exists = true;
if ($index['columns'] !== $index2['columns'])
{
$smcFunc['db_remove_index']('{db_prefix}' . $table_name, 'primary');
$smcFunc['db_add_index']('{db_prefix}' . $table_name, $index);
}
break;
}
// Make sure index is correct
elseif (isset($index['name']) && isset($index2['name']) && $index['name'] == $index2['name'])
{
$exists = true;
// Need to be changed?
if ($index['type'] != $index2['type'] || $index['columns'] !== $index2['columns'])
{
$smcFunc['db_remove_index']('{db_prefix}' . $table_name, $index['name']);
$smcFunc['db_add_index']('{db_prefix}' . $table_name, $index);
}
break;
}
}
if (!$exists)
$smcFunc['db_add_index']('{db_prefix}' . $table_name, $index);
}
// Remove unnecassary indexes
foreach ($currentTable['indexes'] as $index)
{
$exists = false;
foreach ($table['indexes'] as $index2)
{
// Primary is special case
if ($index['type'] == 'primary' && $index2['type'] == 'primary')
$exists = true;
// Make sure index is correct
elseif (isset($index['name']) && isset($index2['name']) && $index['name'] == $index2['name'])
$exists = true;
}
if (!$exists)
{
if (isset($table['upgrade']['indexes']))
{
foreach ($table['upgrade']['indexes'] as $index2)
{
if ($index['type'] == 'primary' && $index2['type'] == 'primary' && $index['columns'] === $index2['columns'])
$smcFunc['db_remove_index']('{db_prefix}' . $table_name, 'primary');
elseif (isset($index['name']) && isset($index2['name']) && $index['name'] == $index2['name'] && $index['type'] == $index2['type'] && $index['columns'] === $index2['columns'])
$smcFunc['db_remove_index']('{db_prefix}' . $table_name, $index['name']);
elseif (!empty($db_show_debug))
$log[] = $table_name . ' has Unneeded index ' . var_dump($index);
}
}
elseif (!empty($db_show_debug))
$log[] = $table_name . ' has Unneeded index ' . var_dump($index);
}
}
}
}
if (!empty($log))
log_error(implode('<br />', $log));
return $log;
}
function doSettings($addSettings)
{
global $smcFunc, $modSettings;
$update = array();
foreach ($addSettings as $variable => $value)
{
list ($value, $overwrite) = $value;
if ($overwrite || !isset($modSettings[$variable]))
$update[$variable] = $value;
}
if (!empty($update))
updateSettings($update);
}
function doPermission($permissions)
{
global $smcFunc;
$perm = array();
foreach ($permissions as $permission => $default)
{
$result = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}permissions
WHERE permission = {string:permission}',
array(
'permission' => $permission
)
);
list ($num) = $smcFunc['db_fetch_row']($result);
if ($num == 0)
{
foreach ($default as $grp)
$perm[] = array($grp, $permission);
}
}
if (empty($perm))
return;
$smcFunc['db_insert']('insert',
'{db_prefix}permissions',
array(
'id_group' => 'int',
'permission' => 'string'
),
$perm,
array()
);
}
function updateAdminFeatures($item, $enabled = false)
{
global $modSettings;
$admin_features = isset($modSettings['admin_features']) ? explode(',', $modSettings['admin_features']) : array('cd,cp,k,w,rg,ml,pm');
if (!is_array($item))
$item = array($item);
if ($enabled)
$admin_features = array_merge($admin_features, $item);
else
$admin_features = array_diff($admin_features, $item);
updateSettings(array('admin_features' => implode(',', $admin_features)));
return true;
}
?>
ลิงค์หัวข้อ:
http://dexmore.com/topic/2305