|
From: <be...@us...> - 2014-10-02 23:04:59
|
Revision: 12805
http://sourceforge.net/p/xoops/svn/12805
Author: beckmi
Date: 2014-10-02 23:04:57 +0000 (Thu, 02 Oct 2014)
Log Message:
-----------
updated makepdf.php file for the latest TCPDF
Modified Paths:
--------------
XoopsModules/modulepacks/x257basicmodulepack/trunk/modules/publisher/makepdf.php
Modified: XoopsModules/modulepacks/x257basicmodulepack/trunk/modules/publisher/makepdf.php
===================================================================
--- XoopsModules/modulepacks/x257basicmodulepack/trunk/modules/publisher/makepdf.php 2014-10-02 23:04:01 UTC (rev 12804)
+++ XoopsModules/modulepacks/x257basicmodulepack/trunk/modules/publisher/makepdf.php 2014-10-02 23:04:57 UTC (rev 12805)
@@ -1,38 +1,21 @@
<?php
-/*
- 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.
- */
-
/**
- * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
- * @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @package Publisher
- * @subpackage Action
- * @since 1.0
- * @author trabis <lus...@gm...>
- * @author Sina Asghari (AKA stranger) <str...@im...>
- * @version $Id: makepdf.php 335 2011-12-05 20:24:01Z lus...@gm... $
- */
+ * File : makefile.pdf for publisher
+ * For tcpdf_for_xoops 2.01 and higher
+ * Created by montuy337513 / philodenelle - http://www.chg-web.org
+**/
+error_reporting(0);
-error_reporting(0);
include_once __DIR__ . '/header.php';
-if (!is_file(XOOPS_PATH.'/vendor/tcpdf/tcpdf.php')) {
- redirect_header(XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewtopic.php?topic_id='.$topic_id,3,'TCPDF for Xoops not installed');
-}
-$itemid = PublisherRequest::getInt('itemid');
-$item_page_id = PublisherRequest::getInt('page', -1);
-
+$itemid = XoopsRequest::getInt('itemid');
+$item_page_id = XoopsRequest::getInt('page', -1);
if ($itemid == 0) {
redirect_header("javascript:history.go(-1)", 1, _MD_PUBLISHER_NOITEMSELECTED);
exit();
}
-
+if (!is_file(XOOPS_PATH.'/vendor/tcpdf/tcpdf.php')) {
+ redirect_header(XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewtopic.php?topic_id='.$itemid,3,'TCPF for Xoops not installed in ./xoops_lib/vendor/');
+}
// Creating the item object for the selected item
$itemObj = $publisher->getHandler('item')->get($itemid);
@@ -56,52 +39,60 @@
$dateformat = $itemObj->datesub();
$sender_inform = sprintf(_MD_PUBLISHER_WHO_WHEN, $itemObj->posterName(), $itemObj->datesub());
$mainImage = $itemObj->getMainImage();
-$pdf_data['author'] = $itemObj->posterName();
-$pdf_data['title'] = $myts->undoHtmlSpecialChars($categoryObj->name());
+
$content = '';
if ($mainImage['image_path'] != '') {
- $content .= '<img src="' . $mainImage['image_path'] . '" alt="' . $myts->undoHtmlSpecialChars($mainImage['image_name']) . '"/>';
+ $content .= '<img src="' . $mainImage['image_path'] . '" alt="' . $myts->undoHtmlSpecialChars($mainImage['image_name']) . '"/><br />';
}
-$content .= '<strong><i><u><a href="' . PUBLISHER_URL . '/item.php?itemid=' . $itemid . '" title="' . $myts->undoHtmlSpecialChars($itemObj->title()) . '">' . $myts->undoHtmlSpecialChars($itemObj->title()) . '</a></u></i></strong>';
-$content .= '<strong>' . _CO_PUBLISHER_CATEGORY . ' : <a href="' . PUBLISHER_URL . '/category.php?categoryid=' . $itemObj->categoryid() . '" title="' . $myts->undoHtmlSpecialChars($categoryObj->name()) . '">' . $myts->undoHtmlSpecialChars($categoryObj->name()) . '</a></strong>';
-$content .= '<br /><strong>' . $sender_inform . '</strong>';
+$content .= '<a href="' . PUBLISHER_URL . '/item.php?itemid=' . $itemid . '" style="text-decoration: none; color: black; font-size: 120%;" title="' . $myts->undoHtmlSpecialChars($itemObj->title()) . '">' . $myts->undoHtmlSpecialChars($itemObj->title()) . '</a>';
+$content .= '<br /><span style="color: #CCCCCC; font-weight: bold; font-size: 80%;">' . _CO_PUBLISHER_CATEGORY . ' : </span><a href="' . PUBLISHER_URL . '/category.php?categoryid=' . $itemObj->categoryid() . '" style="color: #CCCCCC; font-weight: bold; font-size: 80%;" title="' . $myts->undoHtmlSpecialChars($categoryObj->name()) . '">' . $myts->undoHtmlSpecialChars($categoryObj->name()) . '</a>';
+$content .= '<br /><span style="font-size: 80%; font-style: italic;">' . $sender_inform . '</span><br />';
$content .= $itemObj->plain_maintext();
+// Configuration for TCPDF_for_XOOPS
+$pdf_data = array (
+ 'author' => $itemObj->posterName(),
+ 'title' => $myts->undoHtmlSpecialChars($categoryObj->name()),
+ 'page_format' => 'A4',
+ 'page_orientation' => 'P',
+ 'unit' => 'mm',
+ 'rtl' => false //true if right to left
+);
require_once (XOOPS_PATH.'/vendor/tcpdf/tcpdf.php');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, _CHARSET, false);
-// load $localLanguageOptions array with language specific definitions and apply
-if (is_file(XOOPS_PATH.'/vendor/tcpdf/config/lang/'.$xoopsConfig['language'].'.php')) {
- require_once( XOOPS_PATH.'/vendor/tcpdf/config/lang/'.$xoopsConfig['language'].'.php');
-} else {
- require_once( XOOPS_PATH.'/vendor/tcpdf/config/lang/english.php');
-}
-$pdf->setLanguageArray($localLanguageOptions);
$doc_title = publisher_convertCharset($myts->undoHtmlSpecialChars($itemObj->title()));
-$doc_keywords = 'XOOPS';
+$docSubject = $myts->undoHtmlSpecialChars($categoryObj->name());
+$docKeywords = $myts->undoHtmlSpecialChars($itemObj->meta_keywords());
+if(array_key_exists('rtl',$pdf_data)) $pdf->setRTL($pdf_data['rtl']);
+;
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(PDF_AUTHOR);
$pdf->SetTitle($doc_title);
-$pdf->SetSubject($doc_title);
-$pdf->SetKeywords(XOOPS_URL . ', '.' by tcpdf_for_xoops (chg-web.org), '.$doc_title);
+$pdf->SetSubject($docSubject);
+//$pdf->SetKeywords(XOOPS_URL . ', '.' by TCPDF_for_XOOPS (chg-web.org), '.$doc_title);
+$pdf->SetKeywords($docKeywords);
-$firstLine = XOOPS_URL.' - '.publisher_convertCharset($xoopsConfig['sitename']);
+
+$firstLine = publisher_convertCharset($xoopsConfig['sitename']) . ' ('. XOOPS_URL.')';
$secondLine = publisher_convertCharset($xoopsConfig['slogan']);
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $firstLine, $secondLine);
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $firstLine, $secondLine, array(0, 64, 255), array(0, 64, 128));
+
+//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
+
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP , PDF_MARGIN_RIGHT);
-$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
-
+$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set image scale factor
$pdf->setHeaderFont(Array(PDF_FONT_NAME_SUB, '', PDF_FONT_SIZE_SUB));
@@ -111,6 +102,5 @@
//initialize document
$pdf->Open();
$pdf->AddPage();
-$pdf->SetFont(PDF_FONT_NAME_MAIN,PDF_FONT_STYLE_MAIN, PDF_FONT_SIZE_MAIN);
$pdf->writeHTML($content, true, 0, true, 0);
$pdf->Output();
|