forked from XoopsModules25x/news
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print.php
312 lines (298 loc) · 14.3 KB
/
print.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?php
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000-2016 XOOPS.org //
// <http://xoops.org/> //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
/**
* Print an article
*
* This page is used to print an article. The advantage of this script is that you
* only see the article and nothing else.
*
* @package News
* @author Xoops Modules Dev Team
* @copyright (c) XOOPS Project (http://xoops.org)
*
* Parameters received by this page :
* @page_param int storyid Id of news to print
*
* @page_title Story's title - Printer Friendly Page - Topic's title - Site's name
*
* @template_name This page does not use any template
*
*/
include dirname(dirname(__DIR__)) . '/mainfile.php';
include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php';
$storyid = isset($_GET['storyid']) ? (int)$_GET['storyid'] : 0;
if (empty($storyid)) {
redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY);
}
// Verify that the article is published
$story = new NewsStory($storyid);
// Not yet published
if ($story->published() == 0 || $story->published() > time()) {
redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY);
}
// Expired
if ($story->expired() != 0 && $story->expired() < time()) {
redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY);
}
// Verify permissions
$gperm_handler = xoops_getHandler('groupperm');
if (is_object($xoopsUser)) {
$groups = $xoopsUser->getGroups();
} else {
$groups = XOOPS_GROUP_ANONYMOUS;
}
if (!$gperm_handler->checkRight('news_view', $story->topicid(), $groups, $xoopsModule->getVar('mid'))) {
redirect_header(XOOPS_URL . '/modules/news/index.php', 3, _NOPERM);
}
$xoops_meta_keywords = '';
$xoops_meta_description = '';
if (trim($story->keywords()) !== '') {
$xoops_meta_keywords = $story->keywords();
} else {
$xoops_meta_keywords = news_createmeta_keywords($story->hometext() . ' ' . $story->bodytext());
}
if (trim($story->description()) !== '') {
$xoops_meta_description = $story->description();
} else {
$xoops_meta_description = strip_tags($story->title());
}
function PrintPage()
{
global $xoopsConfig, $xoopsModule, $story, $xoops_meta_keywords, $xoops_meta_description;
$myts = MyTextSanitizer::getInstance();
$datetime = formatTimestamp($story->published(), news_getmoduleoption('dateformat'));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo _LANGCODE;
?>" lang="<?php echo _LANGCODE;
?>">
<?php
echo "<head>\n";
echo '<title>' . $myts->htmlSpecialChars($story->title()) . ' - ' . _NW_PRINTER . ' - ' . $myts->htmlSpecialChars($story->topic_title()) . ' - ' . $xoopsConfig['sitename'] . '</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=' . _CHARSET . '" />';
echo '<meta name="author" content="XOOPS" />';
echo '<meta name="keywords" content="' . $xoops_meta_keywords . '" />';
echo '<meta name="COPYRIGHT" content="Copyright (c) 2014 by ' . $xoopsConfig['sitename'] . '" />';
echo '<meta name="DESCRIPTION" content="' . $xoops_meta_description . '" />';
echo '<meta name="generator" content="XOOPS" />';
echo '<meta name="robots" content="noindex,nofollow" />';
if (file_exists(XOOPS_ROOT_PATH . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/style.css')) {
echo '<link rel="stylesheet" type="text/css" media="all" title="Style sheet" href="' . XOOPS_URL . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/style.css" />';
} else {
echo '<link rel="stylesheet" type="text/css" media="all" title="Style sheet" href="' . XOOPS_URL . '/language/english/style.css" />';
}
echo '<link rel="stylesheet" type="text/css" media="all" title="Style sheet" href="' . XOOPS_URL . '/modules/news/assets/css/print.css" />';
$supplemental = '';
if (news_getmoduleoption('footNoteLinks')) {
$supplemental = "footnoteLinks('content','content'); ";
?>
<script type="text/javascript">
// <![CDATA[
/*------------------------------------------------------------------------------
Function: footnoteLinks()
Author: Aaron Gustafson (aaron at easy-designs dot net)
Creation Date: 8 May 2005
Version: 1.3
Homepage: http://www.easy-designs.net/code/footnoteLinks/
License: Creative Commons Attribution-ShareAlike 2.0 License
http://creativecommons.org/licenses/by-sa/2.0/
Note: This version has reduced functionality as it is a demo of
the script's development
------------------------------------------------------------------------------*/
function footnoteLinks(containerID, targetID) {
if (!document.getElementById || !document.getElementsByTagName || !document.createElement) return false;
if (!document.getElementById(containerID) || !document.getElementById(targetID)) return false;
var container = document.getElementById(containerID);
var target = document.getElementById(targetID);
var h2 = document.createElement('h2');
addClass.apply(h2, ['printOnly']);
var h2_txt = document.createTextNode('<?php echo _NW_LINKS;
?>');
h2.appendChild(h2_txt);
var coll = container.getElementsByTagName('*');
var ol = document.createElement('ol');
addClass.apply(ol, ['printOnly']);
var myArr = [];
var thisLink;
var num = 1;
for (var i = 0; i < coll.length; i++) {
if (coll[i].getAttribute('href') ||
coll[i].getAttribute('cite')) {
thisLink = coll[i].getAttribute('href') ? coll[i].href : coll[i].cite;
var note = document.createElement('sup');
addClass.apply(note, ['printOnly']);
var note_txt;
var j = inArray.apply(myArr, [thisLink]);
if (j || j === 0) { // if a duplicate
// get the corresponding number from
// the array of used links
note_txt = document.createTextNode(j + 1);
} else { // if not a duplicate
var li = document.createElement('li');
var li_txt = document.createTextNode(thisLink);
li.appendChild(li_txt);
ol.appendChild(li);
myArr.push(thisLink);
note_txt = document.createTextNode(num);
num++;
}
note.appendChild(note_txt);
if (coll[i].tagName.toLowerCase() == 'blockquote') {
var lastChild = lastChildContainingText.apply(coll[i]);
lastChild.appendChild(note);
} else {
coll[i].parentNode.insertBefore(note, coll[i].nextSibling);
}
}
}
target.appendChild(h2);
target.appendChild(ol);
return true;
}
// ]]>
</script>
<script type="text/javascript">
// <![CDATA[
/*------------------------------------------------------------------------------
Excerpts from the jsUtilities Library
Version: 2.1
Homepage: http://www.easy-designs.net/code/jsUtilities/
License: Creative Commons Attribution-ShareAlike 2.0 License
http://creativecommons.org/licenses/by-sa/2.0/
Note: If you change or improve on this script, please let us know.
------------------------------------------------------------------------------*/
if (Array.prototype.push == null) {
Array.prototype.push = function (item) {
this[this.length] = item;
return this.length;
};
}
// ---------------------------------------------------------------------
// function.apply (if unsupported)
// Courtesy of Aaron Boodman - http://youngpup.net
// ---------------------------------------------------------------------
if (!Function.prototype.apply) {
Function.prototype.apply = function (oScope, args) {
var sarg = [];
var rtrn, call;
if (!oScope) oScope = window;
if (!args) args = [];
for (var i = 0; i < args.length; i++) {
sarg[i] = "args[" + i + "]";
}
call = "oScope.__applyTemp__(" + sarg.join(",") + ");";
oScope.__applyTemp__ = this;
rtrn = eval(call);
oScope.__applyTemp__ = null;
return rtrn;
};
}
function inArray(needle) {
for (var i = 0; i < this.length; i++) {
if (this[i] === needle) {
return i;
}
}
return false;
}
function addClass(theClass) {
if (this.className !== '') {
this.className += ' ' + theClass;
} else {
this.className = theClass;
}
}
function lastChildContainingText() {
var testChild = this.lastChild;
var contentCntnr = ['p', 'li', 'dd'];
while (testChild.nodeType != 1) {
testChild = testChild.previousSibling;
}
var tag = testChild.tagName.toLowerCase();
var tagInArr = inArray.apply(contentCntnr, [tag]);
if (!tagInArr && tagInArr !== 0) {
testChild = lastChildContainingText.apply(testChild);
}
return testChild;
}
// ]]>
</script>
<style type="text/css" media="screen">
.printOnly {
display: none;
}
</style>
<?php
}
echo '</head>';
echo '<body bgcolor="#ffffff" text="#000000" onload="' . $supplemental . ' window.print()">
<div id="content">
<table border="0"><tr><td align="center">
<table border="0" width="100%" cellpadding="0" cellspacing="1" bgcolor="#000000"><tr><td>
<table border="0" width="100%" cellpadding="20" cellspacing="1" bgcolor="#ffffff"><tr><td align="center">
<img src="' . XOOPS_URL . '/images/logo.png" border="0" alt="" /><br><br>
<h3>' . $story->title() . '</h3>
<small><b>' . _NW_DATE . '</b> ' . $datetime . ' | <b>' . _NW_TOPICC . '</b> ' . $myts->htmlSpecialChars($story->topic_title()) . '</small><br><br></td></tr>';
echo '<tr valign="top" style="font:12px;"><td>' . $story->hometext() . '<br>';
$bodytext = $story->bodytext();
$bodytext = str_replace('[pagebreak]', "<br style=\"page-break-after:always;\" />", $bodytext);
if ($bodytext !== '') {
echo $bodytext . '<br><br>';
}
echo '</td></tr></table></td></tr></table>
<br><br>';
printf(_NW_THISCOMESFROM, htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES));
echo '<br><a href="'
. XOOPS_URL
. '/">'
. XOOPS_URL
. '</a><br><br>
'
. _NW_URLFORSTORY
. ' <!-- Tag below can be used to display Permalink image --><!--img src="'
. XOOPS_URL
. '/modules/'
. $xoopsModule->dirname()
. '/assets/images/x.gif" /--><br>
<a class="ignore" href="'
. XOOPS_URL
. '/modules/'
. $xoopsModule->dirname()
. '/article.php?storyid='
. $story->storyid()
. '">'
. XOOPS_URL
. '/modules/news/article.php?storyid='
. $story->storyid()
. '</a>
</td></tr></table></div>
</body>
</html>
';
}
PrintPage();