ผู้เขียน หัวข้อ: Favourite (Favorite) Boards  (อ่าน 762 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ smf

  • [color=green][i]"ถ้าคุณไม่สามารถอธิบายอย่างง่ายๆ ให้คนอื่นเข้าใจได้แล้วล่ะก็ แสดงว่าคุณยังเข้าใจมันไม่ดีพอ"[/i][/color]
  • Administrator
  • Hero Member
  • *****
  • กระทู้: 1,368
  • พอยท์: 5
    • ดูรายละเอียด
    • pordoo.com
    • อีเมล์
Favourite (Favorite) Boards
« เมื่อ: 9 พฤศจิกายน 2015, 11:41:23 »
Mod Name:Favourite (Favorite) Boards
http://custom.simplemachines.org/mods/index.php?mod=2163








File Edits
./index.php
Find:
โค๊ด: [Select]
'findmember' => array('Subs-Auth.php', 'JSMembers'),Add Before:
โค๊ด: [Select]
'favourite' => array('Favourite.php', 'SetFavourite'),
./Sources/Subs-BoardIndex.php
Find:
โค๊ด: [Select]
// Find all boardsAdd Before:
โค๊ด: [Select]
// Get the user's favourite boards
$context['fav_boards'] = array();
$query = $smcFunc['db_query']('', '
SELECT f.id_board FROM {db_prefix}boards b INNER JOIN {db_prefix}favourite_boards f ON (f.id_board = b.id_board) WHERE {query_see_board} AND f.id_member = {int:id_member}
',
array(
'id_member' => $user_info['id'],
)
);
while($row = $smcFunc['db_fetch_row']($query)) {
$context['fav_boards'][] = $row[0];
}
$smcFunc['db_free_result']($query);
   
Find:
โค๊ด: [Select]
// Run through the categories
Add Before:
โค๊ด: [Select]
if ($boardIndexOptions['include_categories'] && !$context['user']['is_guest'])
$categories[0] = array(
'id' => 0,
'name' => $txt['my_fav'],
'is_collapsed' => false,
'can_collapse' => false,
'collapse_href' => '',
'collapse_image' => '',
'href' => $scripturl . '#c0',
'boards' => array(),
'new' => false,
'link' => '<a name="c0" href="' . $scripturl . '#c0">' . $txt['my_fav'] . '</a>',
);

Find:
โค๊ด: [Select]
// This is a parent board.Add Before:
โค๊ด: [Select]
// Add favourite boards to our magic category
if ($boardIndexOptions['include_categories'] && !$context['user']['is_guest']) {
if (!isset($categories[0]['boards'][$row_board['id_board']]) && in_array($row_board['id_board'], $context['fav_boards'])) {
$categories[0]['boards'][$row_board['id_board']] = array(
'new' => empty($row_board['is_read']),
'id' => $row_board['id_board'],
'name' => $row_board['board_name'],
'description' => $row_board['description'],
'moderators' => array(),
'link_moderators' => array(),
'children' => array(),
'link_children' => array(),
'children_new' => false,
'topics' => $row_board['num_topics'],
'posts' => $row_board['num_posts'],
'is_redirect' => $row_board['is_redirect'],
'unapproved_topics' => $row_board['unapproved_topics'],
'unapproved_posts' => $row_board['unapproved_posts'] - $row_board['unapproved_topics'],
'can_approve_posts' => !empty($user_info['mod_cache']['ap']) && ($user_info['mod_cache']['ap'] == array(0) || in_array($row_board['id_board'], $user_info['mod_cache']['ap'])),
'href' => $scripturl . '?board=' . $row_board['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['board_name'] . '</a>' . fav_links($row_board['id_board'])
);

censorText($row_board['subject']);
$row_board['short_subject'] = shorten_subject($row_board['subject'], 24);
$this_last_post = array(
'id' => $row_board['id_msg'],
'time' => $row_board['poster_time'] > 0 ? timeformat($row_board['poster_time']) : $txt['not_applicable'],
'timestamp' => forum_time(true, $row_board['poster_time']),
'subject' => $row_board['short_subject'],
'member' => array(
'id' => $row_board['id_member'],
'username' => $row_board['poster_name'] != '' ? $row_board['poster_name'] : $txt['not_applicable'],
'name' => $row_board['real_name'],
'href' => $row_board['poster_name'] != '' && !empty($row_board['id_member']) ? $scripturl . '?action=profile;u=' . $row_board['id_member'] : '',
'link' => $row_board['poster_name'] != '' ? (!empty($row_board['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row_board['id_member'] . '">' . $row_board['real_name'] . '</a>' : $row_board['real_name']) : $txt['not_applicable'],
),
'start' => 'msg' . $row_board['new_from'],
'topic' => $row_board['id_topic']
);

// Provide the href and link.
if ($row_board['subject'] != '')
{
$this_last_post['href'] = $scripturl . '?topic=' . $row_board['id_topic'] . '.msg' . ($user_info['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']) . (empty($row_board['is_read']) ? ';boardseen' : '') . '#new';
$this_last_post['link'] = '<a href="' . $this_last_post['href'] . '" title="' . $row_board['subject'] . '">' . $row_board['short_subject'] . '</a>';
}
else
{
$this_last_post['href'] = '';
$this_last_post['link'] = $txt['not_applicable'];
}

$categories[0]['boards'][$row_board['id_board']]['last_post'] = $this_last_post;
}
}

Find:
โค๊ด: [Select]
$row_board['board_name'] . '</a>'Replace With:
โค๊ด: [Select]
$row_board['board_name'] . '</a>' . fav_links($row_board['id_board'])
Find:
โค๊ด: [Select]
$row_board['board_name'] . '</a>'Replace With:
โค๊ด: [Select]
$row_board['board_name'] . '</a>' . fav_links($row_board['id_board'])
Find (at the end of the file):
โค๊ด: [Select]
?>
Add Before:
โค๊ด: [Select]
function fav_links($board_id, $return_to = 0) {
global $context, $txt, $scripturl, $settings;
if($context['user']['is_guest'])
return '';

$redirect = $return_to != 0 ? ';return=' . $return_to : '';

if(in_array($board_id, $context['fav_boards'])) {
return '&nbsp;<a href="' . $scripturl . '?action=favourite;sa=remove;board=' . $board_id . $redirect . '" title="' . $txt['rem_fav'] . '"><img src="' . $settings['images_url'] . '/fav_remove.gif" width="14" height="14" border="0"></a>';
} else {
return '&nbsp;<a href="' . $scripturl . '?action=favourite;sa=add;board=' . $board_id . $redirect . '" title="' . $txt['add_fav'] . '"><img src="' . $settings['images_url'] . '/fav_add.gif" width="14" height="14" border="0"></a>';
}
}

./Themes/default/BoardIndex.template.php
Find:
โค๊ด: [Select]
$board['name'], '</a>';Replace With:
โค๊ด: [Select]
$board['name'], '</a>', fav_links($board['id']);
Find:
โค๊ด: [Select]
// Has it posts awaiting approval?Add Before:
โค๊ด: [Select]
$child['link'] .= fav_links($child['id']);
Find:
โค๊ด: [Select]
if (!$context['user']['is_guest'] && !empty($category['show_unread']))
echo '
<a class="unreadlink" href="', $scripturl, '?action=unread;c=', $category['id'], '">', $txt['view_unread_category'], '</a>';
Replace With:
โค๊ด: [Select]
if (!$context['user']['is_guest'] && (($category['id'] == 0 && count($context['fav_boards']) > 0) || (!empty($category['show_unread']))))
echo '
<a class="unreadlink" href="', $scripturl, '?action=unread;c=', ($category['id'] != 0 ? $category['id'] : implode(',', $context['fav_boards'])), '">', $txt['view_unread_category'], '</a>';

./Themes/default/MessageIndex.template.php
Find:
โค๊ด: [Select]
$board['name'], '</a>';Replace With:
โค๊ด: [Select]
$board['name'], '</a>', fav_links($board['id'], $context['current_board']);
./Themes/default/languages/Modifications.english.php

Find (at the end of the file):
โค๊ด: [Select]
?>Add Before:
โค๊ด: [Select]
$txt['my_fav'] = 'My Favorite Boards';
$txt['add_fav'] = 'Add Favorite';
$txt['rem_fav'] = 'Remove Favorite';

./Themes/default/languages/Modifications.english-utf8.php
Find (at the end of the file):
โค๊ด: [Select]
?>Add Before:
โค๊ด: [Select]
$txt['my_fav'] = 'My Favorite Boards';
$txt['add_fav'] = 'Add Favorite';
$txt['rem_fav'] = 'Remove Favorite';
This operation isn't vital to the installation of this mod.

Code
smf2rc2/install20.php
This file should be able to execute standalone.

File Operations
Move the included file "smf2/Favourite.php" to "./Sources".
Move the included file "fav_add.gif" to "./Themes/default/images".
Move the included file "fav_remove.gif" to "./Themes/default/images".
« แก้ไขครั้งสุดท้าย: 9 พฤศจิกายน 2015, 11:52:56 โดย smf »