XoopsModules25x /
news
| 1 | <?php |
||
| 2 | /* |
||
| 3 | * You may not change or alter any portion of this comment or credits |
||
| 4 | * of supporting developers from this source code or any supporting source code |
||
| 5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | * |
||
| 7 | * This program is distributed in the hope that it will be useful, |
||
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @copyright XOOPS Project https://xoops.org/ |
||
| 14 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 15 | * @package |
||
| 16 | * @since |
||
| 17 | * @author XOOPS Development Team, Kazumi Ono (AKA onokazu) |
||
| 18 | */ |
||
| 19 | |||
| 20 | use Xmf\Request; |
||
| 21 | use XoopsModules\News; |
||
| 22 | use XoopsModules\News\NewsStory; |
||
| 23 | |||
| 24 | error_reporting(0); |
||
| 25 | |||
| 26 | require_once __DIR__ . '/header.php'; |
||
| 27 | //2.5.8 |
||
| 28 | if (!is_file(XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php')) { |
||
| 29 | redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $topic_id, 3, 'TCPDF for Xoops not installed'); |
||
| 30 | } else { |
||
| 31 | require_once XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php'; |
||
| 32 | } |
||
| 33 | |||
| 34 | $myts = \MyTextSanitizer::getInstance(); |
||
| 35 | // require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
||
| 36 | |||
| 37 | $storyid = Request::getInt('storyid', 0, 'GET'); |
||
| 38 | |||
| 39 | if (empty($storyid)) { |
||
| 40 | redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); |
||
| 41 | } |
||
| 42 | |||
| 43 | $article = new NewsStory($storyid); |
||
| 44 | // Not yet published |
||
| 45 | if (0 == $article->published() || $article->published() > time()) { |
||
| 46 | redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); |
||
| 47 | } |
||
| 48 | |||
| 49 | // Expired |
||
| 50 | if (0 != $article->expired() && $article->expired() < time()) { |
||
| 51 | redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 55 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 56 | if (is_object($xoopsUser)) { |
||
| 57 | $groups = $xoopsUser->getGroups(); |
||
| 58 | } else { |
||
| 59 | $groups = XOOPS_GROUP_ANONYMOUS; |
||
| 60 | } |
||
| 61 | if (!$grouppermHandler->checkRight('news_view', $article->topicid(), $groups, $xoopsModule->getVar('mid'))) { |
||
| 62 | redirect_header(XOOPS_URL . '/modules/news/index.php', 3, _NOPERM); |
||
| 63 | } |
||
| 64 | |||
| 65 | $dateformat = News\Utility::getModuleOption('dateformat'); |
||
| 66 | $article_data = $article->hometext() . $article->bodytext(); |
||
| 67 | $article_title = $article->title(); |
||
| 68 | $article_title = News\Utility::html2text($myts->undoHtmlSpecialChars($article_title)); |
||
| 69 | $forumdata['topic_title'] = $article_title; |
||
| 70 | $pdf_data['title'] = $article->title(); |
||
| 71 | $topic_title = $article->topic_title(); |
||
| 72 | $topic_title = News\Utility::html2text($myts->undoHtmlSpecialChars($topic_title)); |
||
| 73 | $pdf_data['subtitle'] = $topic_title; |
||
| 74 | $pdf_data['subsubtitle'] = $article->subtitle(); |
||
| 75 | $pdf_data['date'] = formatTimestamp($article->published(), $dateformat); |
||
| 76 | $pdf_data['filename'] = preg_replace("/[^0-9a-z\-_\.]/i", '', htmlspecialchars($article->topic_title(), ENT_QUOTES | ENT_HTML5) . ' - ' . $article->title()); |
||
| 77 | $hometext = $article->hometext(); |
||
| 78 | $bodytext = $article->bodytext(); |
||
| 79 | $content = $myts->undoHtmlSpecialChars($hometext) . '<br><br>' . $myts->undoHtmlSpecialChars($bodytext); |
||
| 80 | $content = str_replace('[pagebreak]', '<br><br>', $content); |
||
| 81 | $pdf_data['content'] = $content; |
||
| 82 | |||
| 83 | $pdf_data['author'] = $article->uname(); |
||
| 84 | |||
| 85 | //Other stuff |
||
| 86 | $puff = '<br>'; |
||
| 87 | $puffer = '<br><br>'; |
||
| 88 | |||
| 89 | //create the A4-PDF... |
||
| 90 | $pdf_config['slogan'] = XOOPS_URL . ' - ' . $xoopsConfig['sitename'] . ' - ' . $xoopsConfig['slogan']; |
||
| 91 | |||
| 92 | $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, _CHARSET, false); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
The type
TCPDF was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 93 | |||
| 94 | //$pdf->setLanguageArray($localLanguageOptions); |
||
| 95 | |||
| 96 | $pdf->SetCreator(PDF_CREATOR); |
||
|
0 ignored issues
–
show
|
|||
| 97 | |||
| 98 | $pdf->SetTitle($pdf_data['title']); |
||
| 99 | $pdf->SetAuthor(PDF_AUTHOR); |
||
|
0 ignored issues
–
show
|
|||
| 100 | $pdf->SetSubject($pdf_data['author']); |
||
| 101 | $out = PDF_AUTHOR . ', ' . $pdf_data['author'] . ', ' . $pdf_data['title'] . ', ' . $pdf_data['subtitle'] . ', ' . $pdf_data['subsubtitle']; |
||
| 102 | $pdf->SetKeywords($out); |
||
| 103 | $pdf->SetAutoPageBreak(true, 25); |
||
| 104 | $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); |
||
|
0 ignored issues
–
show
|
|||
| 105 | $pdf->setFooterMargin(PDF_MARGIN_FOOTER); |
||
|
0 ignored issues
–
show
|
|||
| 106 | //$pdf->setHeaderFont(array(PDF_FONT_NAME_SUB, '', PDF_FONT_SIZE_SUB)); |
||
| 107 | $pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]); |
||
|
0 ignored issues
–
show
|
|||
| 108 | $pdf->setFooterData($tc = [0, 64, 0], $lc = [0, 64, 128]); |
||
| 109 | //$pdf->SetHeaderData('','5',$pdf_config['slogan']); |
||
| 110 | $pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $pdf_config['slogan'], [0, 64, 255], [0, 64, 128]); |
||
|
0 ignored issues
–
show
|
|||
| 111 | //set margins |
||
| 112 | $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); |
||
| 113 | $pdf->setHeaderMargin(PDF_MARGIN_HEADER); |
||
|
0 ignored issues
–
show
|
|||
| 114 | $pdf->setFooterMargin(PDF_MARGIN_FOOTER); |
||
| 115 | |||
| 116 | $pdf->Open(); |
||
| 117 | //First page |
||
| 118 | $pdf->AddPage(); |
||
| 119 | $pdf->SetXY(24, 25); |
||
| 120 | $pdf->SetTextColor(10, 60, 160); |
||
| 121 | //$pdf->SetFont(PDF_FONT_NAME_TITLE, PDF_FONT_STYLE_TITLE, PDF_FONT_SIZE_TITLE); |
||
| 122 | $pdf->writeHTML($pdf_data['title'] . ' - ' . $pdf_data['subtitle'], K_TITLE_MAGNIFICATION); |
||
|
0 ignored issues
–
show
|
|||
| 123 | //$pdf->Line(25,20,190,20); |
||
| 124 | if ('' !== $pdf_data['subsubtitle']) { |
||
| 125 | $pdf->writeHTML($puff, K_XSMALL_RATIO); |
||
|
0 ignored issues
–
show
|
|||
| 126 | // $pdf->SetFont(PDF_FONT_NAME_SUBSUB, PDF_FONT_STYLE_SUBSUB, PDF_FONT_SIZE_SUBSUB); |
||
| 127 | $pdf->writeHTML($pdf_data['subsubtitle'], '1'); |
||
| 128 | } |
||
| 129 | $pdf->writeHTML($puff, '0.2'); |
||
| 130 | //$pdf->SetFont(PDF_FONT_NAME_DATA, PDF_FONT_STYLE_DATA, PDF_FONT_SIZE_DATA); |
||
| 131 | $out = NEWS_PDF_AUTHOR . ': ' . $pdf_data['author'] . '<br>'; |
||
|
0 ignored issues
–
show
|
|||
| 132 | $pdf->writeHTML($out, '0.2'); |
||
| 133 | $out = NEWS_PDF_DATE . ': ' . $pdf_data['date'] . '<br>'; |
||
|
0 ignored issues
–
show
|
|||
| 134 | $pdf->writeHTML($out, '0.2'); |
||
| 135 | $pdf->SetTextColor(0, 0, 0); |
||
| 136 | $pdf->writeHTML($puffer, '1'); |
||
| 137 | |||
| 138 | //$pdf->SetFont(PDF_FONT_NAME_MAIN, PDF_FONT_STYLE_MAIN, PDF_FONT_SIZE_MAIN); |
||
| 139 | $pdf->writeHTML($pdf_data['content'], $pdf_config['scale']); |
||
| 140 | |||
| 141 | //2.5.8 |
||
| 142 | $pdf->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]); |
||
|
0 ignored issues
–
show
|
|||
| 143 | $pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]); |
||
| 144 | |||
| 145 | $pdf->setFooterData($tc = [0, 64, 0], $lc = [0, 64, 128]); |
||
| 146 | |||
| 147 | //initialize document |
||
| 148 | $pdf->Open(); |
||
| 149 | $pdf->AddPage(); |
||
| 150 | $pdf->writeHTML($content, true, 0, true, 0); |
||
| 151 | |||
| 152 | $pdf->Output(); |
||
| 153 |