91
irmtfan
Re: News 1.67 Final released for XOOPS 2.5.5
  • 2012/8/8 10:42

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Mamba i read and assess his codes in makepdf.php and they are professional, clean and easy to implement in all xoops modules!
Quote:

I hope that it will reflect the structure of TCPDF files, i.e. if the next version of TCPDF comes out, we only need to copy the selected files to the /Frameworks/tcpdf directory, and we are done, i.e. we don't have to make any changes to any files, and we don't have to change directories.

IMO we can do it but black_beard knows better.
My guide to use _RTL =true/false can help to have less conflicts with newer versions of TCPDF.

92
Mamba
Re: News 1.67 Final released for XOOPS 2.5.5
  • 2012/8/8 11:10

  • Mamba

  • Moderator

  • Posts: 11411

  • Since: 2004/4/23


Quote:
Mamba i read and assess his codes in makepdf.php and they are professional, clean and easy to implement in all xoops modules!

And where did I imply that he is not?????
Of course, he is!

I didn't say that his code is not professional, clean or easy to implement! I was not even talking about the code, but only about the directory structure and ease of updates in the future!

Quote:
IMO we can do it but black_beard knows better.

That's my assumption too, that's why I was asking him about it.

A good example is TinyMCE: I can just copy the files except the src. files and I am ready to go. I hope, we can achieve the same with TCPDF, i.e. we can just copy over the files from a new TCPDF release without the need to modify any files on XOOPS.
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

93
irmtfan
Re: News 1.67 Final released for XOOPS 2.5.5
  • 2012/8/8 11:25

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Mamba:
I stated that it is clean and professional because there was many messy methods for implementing pdf libraries like fpdf in xoops in the past and i was aware of them.
But the current tcpdf connection to xoops have the least dependencies to tcpdf as far as i can find.

as i specify in the last post we can delete these parts too:
if (is_file(XOOPS_ROOT_PATH.'/Frameworks/tcpdf/config/lang/'.$xoopsConfig['language'].'.php')) {
    require_once( 
XOOPS_ROOT_PATH.'/Frameworks/tcpdf/config/lang/'.$xoopsConfig['language'].'.php');
} else {
    require_once( 
XOOPS_ROOT_PATH.'/Frameworks/tcpdf/config/lang/english.php');
}

no need for them and it makes the work more cleaner. we can read them from xoops!

94
Roby73
Re: News 1.67 Final released for XOOPS 2.5.5
  • 2012/8/8 22:14

  • Roby73

  • Friend of XOOPS

  • Posts: 262

  • Since: 2011/6/15


i modify news 1.66 add SEO rewrite.
is my test, not a good programming, sorry is only in italian language

link

95
irmtfan
Re: News 1.67 Final released for XOOPS 2.5.5
  • 2012/8/9 4:12

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


black_beard:
IMO you can create a new class or new function (im not a coder) as a connection between xoops and tcpdf.
currently makepdf.php files in modules directly access the tcpdf functions but it can be changed to a xoops class or function.

Then it will be possible to just copy/paste the new version of tcpdf to /Frameworks/tcpdf/ and xoops can work with it without any hack into tcpdf files.
please let me know your technical idea.

96
black_beard
Re: News 1.67 Final released for XOOPS 2.5.5

I will put everyone agrees

Quote:

But i think it is better to define that _RTL in xoops and then remove Frameworks/tcpdf/config/lang/*.php


The idea is attractive but TCPDF is natively designed for UTF-8. All these files are in UTF-8. TCPDF manages and displays the ISO charset automatically.

Global.php file can be in UTF-8 but also by ISO. The fact inject ISO files in the configuration of TCPDF disturbs the automatic detection and causes display bugs (we return to the original problem)

Quote:

Also one thing that i forgot.
It can not read the [en] [/en] and [fa] [/fa] codes.
I mean when the website is english it just should makepdf from english content and vice verse.


this is a problem that I noticed. TCPDF does not detect the change of language natively. I plan to add this feature in the next version of tcpdf_for_xoops.

Quote:

Black_beard, whatever you choose, I hope that it will reflect the structure of TCPDF files, i.e. if the next version of TCPDF comes out, we only need to copy the selected files to the /Frameworks/tcpdf directory, and we are done, i.e. we don't have to make any changes to any files, and we don't have to change directories.


Compared to the original version of TCPDF, I modified some files to fit Xoops.
- Files in the directory. / Tcpdf / config / lang / have been renamed. This poses no problem, they are rarely changed.
- I have lightened the class files, history of weight divided by 2 (by some 3). One can easily recover the original files but they are bigger Lots.
- The file "tcpdf_config.php" is the only one where it will make adaptation (but it is rarely changed)

Optimization is my priority. The choices I made in adapting the code I was allowed to reduce memory consumption by 56% and reduce execution time by 36% (baseline version VS version 1.03 of tcpdf_for_xoops)

Quote:

My guide to use _RTL =true/false can help to have less conflicts with newer versions of TCPDF.


It is perhaps for Xoops. But increases the risk of conflict between ISO and UTF-8 (see above) in Tcpdf_for_xoops

Quote:

but only about the directory structure and ease of updates in the future!


The company that I lead will just follow up and updates of these frameworks (I use it for my clients).
I'm busy has put online wiki (french / english) to make best use tcpdf_for_xoops (see here, the site is still in draft form).

Quote:

A good example is TinyMCE: I can just copy the files except the src. files and I am ready to go. I hope, we can achieve the same with TCPDF, i.e. we can just copy over the files from a new TCPDF release without the need to modify any files on XOOPS.


This is my vision of labor.
The hours of work cost a very expensive

Quote:

no need for them and it makes the work more cleaner. we can read them from xoops!


I'll repeat myself. Xoops is written in iso or utf-8. The day will be 100% Xoops utf-8, we can remove some lines of code. Meanwhile, we must ensure coexistence between utf-8 and iso.*/

97
irmtfan
Re: News 1.67 Final released for XOOPS 2.5.5
  • 2012/8/9 14:24

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Thank you black_beard for your informative post.
firstly i want to repeat.
you never use these definitions in makepdf.php files so why you require them?
if (is_file(XOOPS_ROOT_PATH.'/Frameworks/tcpdf/config/lang/'.$xoopsConfig['language'].'.php')) { 
    require_once( 
XOOPS_ROOT_PATH.'/Frameworks/tcpdf/config/lang/'.$xoopsConfig['language'].'.php'); 
} else { 
    require_once( 
XOOPS_ROOT_PATH.'/Frameworks/tcpdf/config/lang/english.php'); 
}

So i think we safely can remove the above. i dont have access to my pc right now. I will test and inform you.

Quote:

The idea is attractive but TCPDF is natively designed for UTF-8. All these files are in UTF-8. TCPDF manages and displays the ISO charset automatically.
Global.php file can be in UTF-8 but also by ISO. The fact inject ISO files in the configuration of TCPDF disturbs the automatic detection and causes display bugs (we return to the original problem)

IMO no problem.
You already inject _CHARSET from XOOPS global.php into TCPDF when you create new tcpdf class in makepdf.php
$pdf = new TCPDF(PDF_PAGE_ORIENTATIONPDF_UNITPDF_PAGE_FORMATtrue_CHARSETfalse);


So we can use _RTL as the same. furthermore, _RTL is a 1/0 value and i think numbers are free from UTF-8 and ISO.
IMO our problem in the past came from the tcpdf itself.

black_beard:
there is an important to do list for newbb to create pdf from a topic.
this is very needed and honestly creating pdf from a single post is useless.
but im worry about memory consumption when it creates pdf from a topic that have 3000 posts. (in my website)

Quote:

Optimization is my priority. The choices I made in adapting the code I was allowed to reduce memory consumption by 56% and reduce execution time by 36% (baseline version VS version 1.03 of tcpdf_for_xoops)

This is vital.
my server admin suspended me because of makepdf.php in news 1.57. i now update to 1.68 but i still fear to turn the pdf option on.
how can i be sure that they dont suspend me again?

Also what is your idea about this?
Quote:

IMO you can create a new class or new function (im not a coder) as a connection between xoops and tcpdf.
currently makepdf.php files in modules directly access the tcpdf functions but it can be changed to a xoops class or function.

I mean now makepdf.php files directly access the tcpdf and there are many similar lines between them. eg: between news/makepdf.php and newbb/makepdf.php

If you write a new class in xoops those lines will be moved to that class so it will be like this in makefile.php.

$pdf = new TCPDF_for_XOOPS(PDF_PAGE_ORIENTATIONPDF_UNITPDF_PAGE_FORMATtrue_CHARSETfalse);

the above is just an example. it can get more input variables. Also it will guarantee that there would be no problem with XOOPS ISO and TCPDF UTF-8.


98
black_beard
Re: News 1.67 Final released for XOOPS 2.5.5

charset of the files in the directory ./Frameworks/tcpdf/config/lang are different from the charset of the document. Define them in these files match the make, not the document

99
irmtfan
Re: News 1.67 Final released for XOOPS 2.5.5
  • 2012/8/10 1:29

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


black_beard:
i said that tcpdf for xoops version 1.04 never use these config files ./Frameworks/tcpdf/config/lang in creating pdf because you should add below command to makepdf.php unless TCPDF dont use them.
$pdf->setLanguageArray($l);


It means in TCPDF only the above code read the configs from ./Frameworks/tcpdf/config/lang files.
In other words now in tcpdf for xoops version 1.04 ./Frameworks/tcpdf/config/lang files has been required but never used.

therefore i should add the above command for my persian language (to read the configs from ./Frameworks/tcpdf/config/lang/persian.php) unless i dont have a RTL Output pdf.

After that i reach to this point that we only need the RTL config from those files so the above code can be changed by this:
$pdf->setRTL(_RTL);

because we dont need charset or lang code.
then we are free from ./Frameworks/tcpdf/config/lang/*.php and can define _RTL in XOOPS.
i already sent a feature request to the core for adding _RTL=true/false
until that time we should hack global.php and add it.

*/

100
irmtfan
Re: News 1.67 Final released for XOOPS 2.5.5
  • 2012/8/11 4:29

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Ok,
I removed those language requirements lines and add RTL and everything works well.

newbb/makepdf.php is now like this:

// $Id: makepdf.php,v 1.1.1.1 2005/10/19 15:58:07 phppp Exp $
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 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 //
//  ------------------------------------------------------------------------ //
//  Author: phppp (D.J., infomax@gmail.com)                                  //
//  URL: http://xoopsforge.com, https://xoops.org.cn                          //
//  Project: Article Project                                                 //
//  ------------------------------------------------------------------------ //

error_reporting(0);
 
include_once 
dirname(__FILE__) . "/header.php";

$forum         = isset($_GET['forum']) ? intval($_GET['forum']) : 0;
$topic_id     = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : 0;
$post_id     = !empty($_GET['post_id']) ? intval($_GET['post_id']) : 0;
if (!
is_file(XOOPS_ROOT_PATH.'/Frameworks/tcpdf/tcpdf.php')) {
    
redirect_header(XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewtopic.php?topic_id='.$topic_id,3,'TCPF for Xoops not installed');
}
 
if ( empty(
$post_id) )  die(_MD_ERRORTOPIC);

$post_handler xoops_getmodulehandler('post''newbb');
$post $post_handler->get($post_id);
if(!
$approved $post->getVar('approved'))    die(_MD_NORIGHTTOVIEW);

$post_data $post_handler->getPostForPDF($post);
    
$topic_handler xoops_getmodulehandler('topic''newbb');
$forumtopic $topic_handler->getByPost($post_id);
$topic_id $forumtopic->getVar('topic_id');
if(!
$approved $forumtopic->getVar('approved'))    die(_MD_NORIGHTTOVIEW);

$forum_handler xoops_getmodulehandler('forum''newbb');
$forum = ($forum) ? $forum $forumtopic->getVar('forum_id');
$viewtopic_forum $forum_handler->get($forum);
if (!
$forum_handler->getPermission($viewtopic_forum))    die(_MD_NORIGHTTOACCESS);
if (!
$topic_handler->getPermission($viewtopic_forum$forumtopic->getVar('topic_status'), "view"))   die(_MD_NORIGHTTOVIEW);

$GLOBALS["xoopsOption"]["pdf_cache"] = 0;
$pdf_data['author'] = $myts->undoHtmlSpecialChars($post_data['author']);
$pdf_data['title'] = $myts->undoHtmlSpecialChars($post_data['subject']);
$content '';
$content .= ''.$pdf_data['title'].''
;
$content .= _MD_AUTHORC.' ' $pdf_data['author'].'';
$content .= _MD_POSTEDON ' ' formatTimestamp($post_data['date']).'';
$content .= $myts->undoHtmlSpecialChars($post_data['text']) . '';
$content str_replace('[pagebreak]','',$content);

require_once (
XOOPS_ROOT_PATH.'/Frameworks/tcpdf/tcpdf.php');

//create the A4-PDF...
$pdf=new TCPDF(PDF_PAGE_ORIENTATIONPDF_UNITPDF_PAGE_FORMATtrue_CHARSETfalse);
// START irmtfan hack to add RTL-LTR local
// until _RTL added to core 2.6.0
if (!defined('_RTL')) {
    
define('_RTL',false);
}
$pdf->setRTL(_RTL);
// END irmtfan hack to add RTL-LTR local

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(PDF_AUTHOR);
$pdf->SetTitle(NEWBB_PDF_SUBJECT.': '.$forumtopic->getVar('topic_title'));
$pdf->SetSubject(NEWBB_PDF_SUBJECT.': '.$forumtopic->getVar('topic_title'));
$pdf->SetKeywords(XOOPS_URL ', '.'SIMPLE-XOOPS, '.$forumtopic->getVar('topic_title'));

$firstLine $xoopsConfig['sitename'];
$secondLine $xoopsConfig['slogan'];
$pdf->SetHeaderData('''5'$firstLine$secondLine);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFTPDF_MARGIN_TOP PDF_MARGIN_RIGHT);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(true25);

$pdf->setHeaderFont(Array(PDF_FONT_NAME_SUB''PDF_FONT_SIZE_SUB));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA''PDF_FONT_SIZE_DATA));
$pdf->setFooterData($tc=array(0,64,0), $lc=array(0,64,128));

$pdf->Open();
$pdf->AddPage();
$pdf->SetFont(PDF_FONT_NAME_MAIN,PDF_FONT_STYLE_MAINPDF_FONT_SIZE_MAIN);
$pdf->writeHTML($contenttrue0);

$pdf->Output();
?>


Login

Who's Online

147 user(s) are online (105 user(s) are browsing Support Forums)


Members: 0


Guests: 147


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits