From: <tim...@us...> - 2010-10-02 13:17:53
|
Revision: 4088 http://web-erp.svn.sourceforge.net/web-erp/?rev=4088&view=rev Author: tim_schofield Date: 2010-10-02 13:17:46 +0000 (Sat, 02 Oct 2010) Log Message: ----------- Make php 5.3 compatible Modified Paths: -------------- trunk/doc/Change.log.html trunk/fpdi/fpdf_tpl.php trunk/fpdi/fpdi.php Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-10-02 11:37:38 UTC (rev 4087) +++ trunk/doc/Change.log.html 2010-10-02 13:17:46 UTC (rev 4088) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>02/10/10 Tim: ppdf_tpl.php - Make php 5.3 compatible</p> <p>02/10/10 Tim: GLJournal.php - Fix to create a reversing journal even when non english language is used.</p> <p>02/10/10 Tim: PDFGrnHeader.php - Show correct column headings. Fixes bug 3072507</p> <p>30/09/10 Tim: Add form verification to prevent form spoofing</p> Modified: trunk/fpdi/fpdf_tpl.php =================================================================== --- trunk/fpdi/fpdf_tpl.php 2010-10-02 11:37:38 UTC (rev 4087) +++ trunk/fpdi/fpdf_tpl.php 2010-10-02 13:17:46 UTC (rev 4088) @@ -29,13 +29,13 @@ * @var int */ var $tpl = 0; - + /** * "In Template"-Flag * @var boolean */ var $_intpl = false; - + /** * Nameprefix of Templates used in Resources-Dictonary * @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an / @@ -47,14 +47,14 @@ * @var array */ var $_res = array(); - + /** * Last used Template data * * @var array */ var $lastUsedTemplateData = array(); - + /** * Start a Template * @@ -107,7 +107,7 @@ ); $this->SetAutoPageBreak(false); - + // Define own high and width to calculate possitions correct $this->h = $h; $this->w = $w; @@ -118,7 +118,7 @@ return $this->tpl; } - + /** * End Template * @@ -128,7 +128,7 @@ */ function endTemplate() { if ($this->_intpl) { - $this->_intpl = false; + $this->_intpl = false; $tpl =& $this->tpls[$this->tpl]; $this->SetXY($tpl['o_x'], $tpl['o_y']); $this->tMargin = $tpl['o_tMargin']; @@ -137,13 +137,13 @@ $this->h = $tpl['o_h']; $this->w = $tpl['o_w']; $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); - + return $this->tpl; } else { return false; } } - + /** * Use a Template in current Page or other Template * @@ -167,27 +167,27 @@ if (!isset($this->tpls[$tplidx])) $this->error("Template does not exist!"); - + if ($this->_intpl) { $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; } - + $tpl =& $this->tpls[$tplidx]; $w = $tpl['w']; $h = $tpl['h']; - + if ($_x == null) $_x = 0; if ($_y == null) $_y = 0; - + $_x += $tpl['x']; $_y += $tpl['y']; - + $wh = $this->getTemplateSize($tplidx, $_w, $_h); $_w = $wh['w']; $_h = $wh['h']; - + $tData = array( 'x' => $this->x, 'y' => $this->y, @@ -199,15 +199,15 @@ 'ty' => ($this->h-$_y-$_h), 'lty' => ($this->h-$_y-$_h) - ($this->h-$h) * ($_h/$h) ); - - $this->_out(sprintf("q %.4F 0 0 %.4F %.4F %.4F cm", $tData['scaleX'], $tData['scaleY'], $tData['tx']*$this->k, $tData['ty']*$this->k)); // Translate + + $this->_out(sprintf("q %.4F 0 0 %.4F %.4F %.4F cm", $tData['scaleX'], $tData['scaleY'], $tData['tx']*$this->k, $tData['ty']*$this->k)); // Translate $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); $this->lastUsedTemplateData = $tData; - + return array("w" => $_w, "h" => $_h); } - + /** * Get The calculated Size of a Template * @@ -225,7 +225,7 @@ $tpl =& $this->tpls[$tplidx]; $w = $tpl['w']; $h = $tpl['h']; - + if ($_w == 0 and $_h == 0) { $_w = $w; $_h = $h; @@ -235,10 +235,10 @@ $_w = $_h*$w/$h; if($_h==0) $_h = $_w*$h/$w; - + return array("w" => $_w, "h" => $_h); } - + /** * See FPDF/TCPDF-Documentation ;-) */ @@ -251,40 +251,40 @@ */ if ($this->_intpl) $this->FontFamily = ''; - + parent::SetFont($family, $style, $size, $fontfile); - + $fontkey = $this->FontFamily.$this->FontStyle; - + if ($this->_intpl) { $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; } else { $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; } } - + /** * See FPDF/TCPDF-Documentation ;-) */ - function Image($file, $x, $y, $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0) { - if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 7) { + function Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false) { + if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 7) { $this->Error('More than 7 arguments for the Image method are only available in TCPDF.'); } - - parent::Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border); + + parent::Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border, $fitbox, $hidden, $fitonpage); if ($this->_intpl) { $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; } else { $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; } } - + /** * See FPDF-Documentation ;-) * * AddPage is not available when you're "in" a template. */ - function AddPage($orientation='', $format='') { + function AddPage($orientation='', $format='', $keepmargins=false) { if ($this->_intpl) $this->Error('Adding pages in templates isn\'t possible!'); parent::AddPage($orientation, $format); @@ -297,24 +297,24 @@ if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 5) { $this->Error('More than 7 arguments for the Image method are only available in TCPDF.'); } - + if ($this->_intpl) $this->Error('Using links in templates aren\'t possible!'); parent::Link($x, $y, $w, $h, $link, $spaces); } - + function AddLink() { if ($this->_intpl) $this->Error('Adding links in templates aren\'t possible!'); return parent::AddLink(); } - + function SetLink($link, $y=0, $page=-1) { if ($this->_intpl) $this->Error('Setting links in templates aren\'t possible!'); parent::SetLink($link, $y, $page); } - + /** * Private Method that writes the form xobjects */ @@ -339,13 +339,13 @@ // ury ($tpl['h']-$tpl['y'])*$this->k )); - + if ($tpl['x'] != 0 || $tpl['y'] != 0) { $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', -$tpl['x']*$this->k*2, $tpl['y']*$this->k*2 )); } - + $this->_out('/Resources '); $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); @@ -355,7 +355,7 @@ $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); $this->_out('>>'); } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || + if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { $this->_out('/XObject <<'); @@ -370,13 +370,13 @@ $this->_out('>>'); } $this->_out('>>'); - + $this->_out('/Length '.strlen($p).' >>'); $this->_putstream($p); $this->_out('endobj'); } } - + /** * Overwritten to add _putformxobjects() after _putimages() * @@ -385,10 +385,10 @@ parent::_putimages(); $this->_putformxobjects(); } - + function _putxobjectdict() { parent::_putxobjectdict(); - + if (count($this->tpls)) { foreach($this->tpls as $tplidx => $tpl) { $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); Modified: trunk/fpdi/fpdi.php =================================================================== --- trunk/fpdi/fpdi.php 2010-10-02 11:37:38 UTC (rev 4087) +++ trunk/fpdi/fpdi.php 2010-10-02 13:17:46 UTC (rev 4088) @@ -40,19 +40,19 @@ * @var array */ var $parsers; - + /** * Current parser * @var object */ var $current_parser; - + /** * object stack * @var array */ var $_obj_stack; - + /** * done object stack * @var array @@ -64,16 +64,16 @@ * @var integer */ var $_current_obj_id; - + /** * The name of the last imported page box * @var string */ var $lastUsedPageBox; - + var $_importedPages = array(); - - + + /** * Set a source-file * @@ -85,12 +85,12 @@ $fn =& $this->current_filename; if (!isset($this->parsers[$fn])) - $this->parsers[$fn] =& new fpdi_pdf_parser($fn, $this); + $this->parsers[$fn] = new fpdi_pdf_parser($fn, $this); $this->current_parser =& $this->parsers[$fn]; - + return $this->parsers[$fn]->getPageCount(); } - + /** * Import a page * @@ -101,14 +101,14 @@ if ($this->_intpl) { return $this->error('Please import the desired pages before creating a new template.'); } - + $fn =& $this->current_filename; - + // check if page already imported $pageKey = $fn.((int)$pageno).$boxName; if (isset($this->_importedPages[$pageKey])) return $this->_importedPages[$pageKey]; - + $parser =& $this->parsers[$fn]; $parser->setPageno($pageno); @@ -118,11 +118,11 @@ $tpl['parser'] =& $parser; $tpl['resources'] = $parser->getPageResources(); $tpl['buffer'] = $parser->getContent(); - + if (!in_array($boxName, $parser->availableBoxes)) return $this->Error(sprintf('Unknown box: %s', $boxName)); $pageboxes = $parser->getPageBoxes($pageno); - + /** * MediaBox * CropBox: Default -> MediaBox @@ -134,46 +134,46 @@ $boxName = '/CropBox'; if (!isset($pageboxes[$boxName]) && $boxName == '/CropBox') $boxName = '/MediaBox'; - + if (!isset($pageboxes[$boxName])) return false; $this->lastUsedPageBox = $boxName; - + $box = $pageboxes[$boxName]; $tpl['box'] = $box; - + // To build an array that can be used by PDF_TPL::useTemplate() $this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl],$box); - + // An imported page will start at 0,0 everytime. Translation will be set in _putformxobjects() $tpl['x'] = 0; $tpl['y'] = 0; - + $page =& $parser->pages[$parser->pageno]; - + // handle rotated pages $rotation = $parser->getPageRotation($pageno); $tpl['_rotationAngle'] = 0; if (isset($rotation[1]) && ($angle = $rotation[1] % 360) != 0) { $steps = $angle / 90; - + $_w = $tpl['w']; $_h = $tpl['h']; $tpl['w'] = $steps % 2 == 0 ? $_w : $_h; $tpl['h'] = $steps % 2 == 0 ? $_h : $_w; - + $tpl['_rotationAngle'] = $angle*-1; } - + $this->_importedPages[$pageKey] = $this->tpl; - + return $this->tpl; } - + function getLastUsedPageBox() { return $this->lastUsedPageBox; } - + function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0, $adjustPageSize=false) { if ($adjustPageSize == true && is_null($_x) && is_null($_y)) { $size = $this->getTemplateSize($tplidx, $_w, $_h); @@ -188,13 +188,13 @@ $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); } } - + $this->_out('q 0 J 1 w 0 j 0 G 0 g'); // reset standard values $s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h); $this->_out('Q'); return $s; } - + /** * Private method, that rebuilds all needed objects of source files */ @@ -205,15 +205,15 @@ if (isset($this->_obj_stack[$filename]) && is_array($this->_obj_stack[$filename])) { while(($n = key($this->_obj_stack[$filename])) !== null) { $nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c,$this->_obj_stack[$filename][$n][1]); - + $this->_newobj($this->_obj_stack[$filename][$n][0]); - + if ($nObj[0] == PDF_TYPE_STREAM) { $this->pdf_write_value ($nObj); } else { $this->pdf_write_value ($nObj[1]); } - + $this->_out('endobj'); $this->_obj_stack[$filename][$n] = null; // free memory unset($this->_obj_stack[$filename][$n]); @@ -223,8 +223,8 @@ } } } - - + + /** * Private Method that writes the form xobjects */ @@ -235,33 +235,33 @@ $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; $this->_newobj(); $cN = $this->n; // TCPDF/Protection: rem current "n" - + $this->tpls[$tplidx]['n'] = $this->n; $this->_out('<<'.$filter.'/Type /XObject'); $this->_out('/Subtype /Form'); $this->_out('/FormType 1'); - - $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', + + $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', (isset($tpl['box']['llx']) ? $tpl['box']['llx'] : $tpl['x'])*$this->k, (isset($tpl['box']['lly']) ? $tpl['box']['lly'] : -$tpl['y'])*$this->k, (isset($tpl['box']['urx']) ? $tpl['box']['urx'] : $tpl['w'] + $tpl['x'])*$this->k, (isset($tpl['box']['ury']) ? $tpl['box']['ury'] : $tpl['h']-$tpl['y'])*$this->k )); - + $c = 1; $s = 0; $tx = 0; $ty = 0; - + if (isset($tpl['box'])) { $tx = -$tpl['box']['llx']; $ty = -$tpl['box']['lly']; - + if ($tpl['_rotationAngle'] <> 0) { $angle = $tpl['_rotationAngle'] * M_PI/180; $c=cos($angle); $s=sin($angle); - + switch($tpl['_rotationAngle']) { case -90: $tx = -$tpl['box']['lly']; @@ -281,16 +281,16 @@ $tx = -$tpl['x']*2; $ty = $tpl['y']*2; } - + $tx *= $this->k; $ty *= $this->k; - + if ($c != 1 || $s != 0 || $tx != 0 || $ty != 0) { $this->_out(sprintf('/Matrix [%.5F %.5F %.5F %.5F %.5F %.5F]', $c, $s, -$s, $c, $tx, $ty )); } - + $this->_out('/Resources '); if (isset($tpl['resources'])) { @@ -304,7 +304,7 @@ $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); $this->_out('>>'); } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || + if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { $this->_out('/XObject <<'); @@ -328,7 +328,7 @@ $this->_out('endobj'); $this->n = $nN; // TCPDF: reset to new "n" } - + $this->_putimportedobjects(); } @@ -359,7 +359,7 @@ if (is_subclass_of($this, 'TCPDF')) { parent::pdf_write_value($value); } - + switch ($value[0]) { case PDF_TYPE_TOKEN : @@ -373,7 +373,7 @@ $this->_straightOut($value[1] . ' '); } break; - + case PDF_TYPE_ARRAY : // An array. Output the proper @@ -407,7 +407,7 @@ // An indirect object reference // Fill the object stack if needed $cpfn =& $this->current_parser->filename; - + if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) { $this->_newobj(false,true); $this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value); @@ -442,7 +442,7 @@ case PDF_TYPE_BOOLEAN : $this->_straightOut($value[1] ? 'true ' : 'false '); break; - + case PDF_TYPE_NULL : // The null object. @@ -450,8 +450,8 @@ break; } } - - + + /** * Modified so not each call will add a newline to the output. */ @@ -485,7 +485,7 @@ parent::_enddoc(); $this->_closeParsers(); } - + /** * close all files opened by parsers */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |