Mercurial > hg > vamp-website
comparison forum/Sources/Printpage.php @ 76:e3e11437ecea website
Add forum code
author | Chris Cannam |
---|---|
date | Sun, 07 Jul 2013 11:25:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
75:72f59aa7e503 | 76:e3e11437ecea |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * Simple Machines Forum (SMF) | |
5 * | |
6 * @package SMF | |
7 * @author Simple Machines http://www.simplemachines.org | |
8 * @copyright 2011 Simple Machines | |
9 * @license http://www.simplemachines.org/about/smf/license.php BSD | |
10 * | |
11 * @version 2.0 | |
12 */ | |
13 | |
14 if (!defined('SMF')) | |
15 die('Hacking attempt...'); | |
16 | |
17 /* This file contains just one function that formats a topic to be printer | |
18 friendly. | |
19 | |
20 void PrintTopic() | |
21 - is called to format a topic to be printer friendly. | |
22 - must be called with a topic specified. | |
23 - uses the Printpage (main sub template.) template. | |
24 - uses the print_above/print_below later without the main layer. | |
25 - is accessed via ?action=printpage. | |
26 */ | |
27 | |
28 function PrintTopic() | |
29 { | |
30 global $topic, $txt, $scripturl, $context, $user_info; | |
31 global $board_info, $smcFunc, $modSettings; | |
32 | |
33 // Redirect to the boardindex if no valid topic id is provided. | |
34 if (empty($topic)) | |
35 redirectexit(); | |
36 | |
37 // Whatever happens don't index this. | |
38 $context['robot_no_index'] = true; | |
39 | |
40 // Get the topic starter information. | |
41 $request = $smcFunc['db_query']('', ' | |
42 SELECT m.poster_time, IFNULL(mem.real_name, m.poster_name) AS poster_name | |
43 FROM {db_prefix}messages AS m | |
44 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) | |
45 WHERE m.id_topic = {int:current_topic} | |
46 ORDER BY m.id_msg | |
47 LIMIT 1', | |
48 array( | |
49 'current_topic' => $topic, | |
50 ) | |
51 ); | |
52 // Redirect to the boardindex if no valid topic id is provided. | |
53 if ($smcFunc['db_num_rows']($request) == 0) | |
54 redirectexit(); | |
55 $row = $smcFunc['db_fetch_assoc']($request); | |
56 $smcFunc['db_free_result']($request); | |
57 | |
58 // Lets "output" all that info. | |
59 loadTemplate('Printpage'); | |
60 $context['template_layers'] = array('print'); | |
61 $context['board_name'] = $board_info['name']; | |
62 $context['category_name'] = $board_info['cat']['name']; | |
63 $context['poster_name'] = $row['poster_name']; | |
64 $context['post_time'] = timeformat($row['poster_time'], false); | |
65 $context['parent_boards'] = array(); | |
66 foreach ($board_info['parent_boards'] as $parent) | |
67 $context['parent_boards'][] = $parent['name']; | |
68 | |
69 // Split the topics up so we can print them. | |
70 $request = $smcFunc['db_query']('', ' | |
71 SELECT subject, poster_time, body, IFNULL(mem.real_name, poster_name) AS poster_name | |
72 FROM {db_prefix}messages AS m | |
73 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) | |
74 WHERE m.id_topic = {int:current_topic}' . ($modSettings['postmod_active'] && !allowedTo('approve_posts') ? ' | |
75 AND (m.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR m.id_member = {int:current_member}') . ')' : '') . ' | |
76 ORDER BY m.id_msg', | |
77 array( | |
78 'current_topic' => $topic, | |
79 'is_approved' => 1, | |
80 'current_member' => $user_info['id'], | |
81 ) | |
82 ); | |
83 $context['posts'] = array(); | |
84 while ($row = $smcFunc['db_fetch_assoc']($request)) | |
85 { | |
86 // Censor the subject and message. | |
87 censorText($row['subject']); | |
88 censorText($row['body']); | |
89 | |
90 $context['posts'][] = array( | |
91 'subject' => $row['subject'], | |
92 'member' => $row['poster_name'], | |
93 'time' => timeformat($row['poster_time'], false), | |
94 'timestamp' => forum_time(true, $row['poster_time']), | |
95 'body' => parse_bbc($row['body'], 'print'), | |
96 ); | |
97 | |
98 if (!isset($context['topic_subject'])) | |
99 $context['topic_subject'] = $row['subject']; | |
100 } | |
101 $smcFunc['db_free_result']($request); | |
102 | |
103 // Set a canonical URL for this page. | |
104 $context['canonical_url'] = $scripturl . '?topic=' . $topic . '.0'; | |
105 } | |
106 | |
107 ?> |