@@ -1,15 +1,15 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 2 | -$fpdf_charwidths['helveticaB']=array( |
|
| 3 | - chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, |
|
| 4 | - chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584, |
|
| 5 | - ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722, |
|
| 6 | - 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, |
|
| 7 | - 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889, |
|
| 8 | - 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556, |
|
| 9 | - chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, |
|
| 10 | - chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, |
|
| 11 | - chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, |
|
| 12 | - chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, |
|
| 13 | - chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611, |
|
| 14 | - chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556); |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | +$fpdf_charwidths['helveticaB'] = array( |
|
| 3 | + chr(0)=>278, chr(1)=>278, chr(2)=>278, chr(3)=>278, chr(4)=>278, chr(5)=>278, chr(6)=>278, chr(7)=>278, chr(8)=>278, chr(9)=>278, chr(10)=>278, chr(11)=>278, chr(12)=>278, chr(13)=>278, chr(14)=>278, chr(15)=>278, chr(16)=>278, chr(17)=>278, chr(18)=>278, chr(19)=>278, chr(20)=>278, chr(21)=>278, |
|
| 4 | + chr(22)=>278, chr(23)=>278, chr(24)=>278, chr(25)=>278, chr(26)=>278, chr(27)=>278, chr(28)=>278, chr(29)=>278, chr(30)=>278, chr(31)=>278, ' '=>278, '!'=>333, '"'=>474, '#'=>556, '$'=>556, '%'=>889, '&'=>722, '\''=>238, '('=>333, ')'=>333, '*'=>389, '+'=>584, |
|
| 5 | + ','=>278, '-'=>333, '.'=>278, '/'=>278, '0'=>556, '1'=>556, '2'=>556, '3'=>556, '4'=>556, '5'=>556, '6'=>556, '7'=>556, '8'=>556, '9'=>556, ':'=>333, ';'=>333, '<'=>584, '='=>584, '>'=>584, '?'=>611, '@'=>975, 'A'=>722, |
|
| 6 | + 'B'=>722, 'C'=>722, 'D'=>722, 'E'=>667, 'F'=>611, 'G'=>778, 'H'=>722, 'I'=>278, 'J'=>556, 'K'=>722, 'L'=>611, 'M'=>833, 'N'=>722, 'O'=>778, 'P'=>667, 'Q'=>778, 'R'=>722, 'S'=>667, 'T'=>611, 'U'=>722, 'V'=>667, 'W'=>944, |
|
| 7 | + 'X'=>667, 'Y'=>667, 'Z'=>611, '['=>333, '\\'=>278, ']'=>333, '^'=>584, '_'=>556, '`'=>333, 'a'=>556, 'b'=>611, 'c'=>556, 'd'=>611, 'e'=>556, 'f'=>333, 'g'=>611, 'h'=>611, 'i'=>278, 'j'=>278, 'k'=>556, 'l'=>278, 'm'=>889, |
|
| 8 | + 'n'=>611, 'o'=>611, 'p'=>611, 'q'=>611, 'r'=>389, 's'=>556, 't'=>333, 'u'=>611, 'v'=>556, 'w'=>778, 'x'=>556, 'y'=>556, 'z'=>500, '{'=>389, '|'=>280, '}'=>389, '~'=>584, chr(127)=>350, chr(128)=>556, chr(129)=>350, chr(130)=>278, chr(131)=>556, |
|
| 9 | + chr(132)=>500, chr(133)=>1000, chr(134)=>556, chr(135)=>556, chr(136)=>333, chr(137)=>1000, chr(138)=>667, chr(139)=>333, chr(140)=>1000, chr(141)=>350, chr(142)=>611, chr(143)=>350, chr(144)=>350, chr(145)=>278, chr(146)=>278, chr(147)=>500, chr(148)=>500, chr(149)=>350, chr(150)=>556, chr(151)=>1000, chr(152)=>333, chr(153)=>1000, |
|
| 10 | + chr(154)=>556, chr(155)=>333, chr(156)=>944, chr(157)=>350, chr(158)=>500, chr(159)=>667, chr(160)=>278, chr(161)=>333, chr(162)=>556, chr(163)=>556, chr(164)=>556, chr(165)=>556, chr(166)=>280, chr(167)=>556, chr(168)=>333, chr(169)=>737, chr(170)=>370, chr(171)=>556, chr(172)=>584, chr(173)=>333, chr(174)=>737, chr(175)=>333, |
|
| 11 | + chr(176)=>400, chr(177)=>584, chr(178)=>333, chr(179)=>333, chr(180)=>333, chr(181)=>611, chr(182)=>556, chr(183)=>278, chr(184)=>333, chr(185)=>333, chr(186)=>365, chr(187)=>556, chr(188)=>834, chr(189)=>834, chr(190)=>834, chr(191)=>611, chr(192)=>722, chr(193)=>722, chr(194)=>722, chr(195)=>722, chr(196)=>722, chr(197)=>722, |
|
| 12 | + chr(198)=>1000, chr(199)=>722, chr(200)=>667, chr(201)=>667, chr(202)=>667, chr(203)=>667, chr(204)=>278, chr(205)=>278, chr(206)=>278, chr(207)=>278, chr(208)=>722, chr(209)=>722, chr(210)=>778, chr(211)=>778, chr(212)=>778, chr(213)=>778, chr(214)=>778, chr(215)=>584, chr(216)=>778, chr(217)=>722, chr(218)=>722, chr(219)=>722, |
|
| 13 | + chr(220)=>722, chr(221)=>667, chr(222)=>667, chr(223)=>611, chr(224)=>556, chr(225)=>556, chr(226)=>556, chr(227)=>556, chr(228)=>556, chr(229)=>556, chr(230)=>889, chr(231)=>556, chr(232)=>556, chr(233)=>556, chr(234)=>556, chr(235)=>556, chr(236)=>278, chr(237)=>278, chr(238)=>278, chr(239)=>278, chr(240)=>611, chr(241)=>611, |
|
| 14 | + chr(242)=>611, chr(243)=>611, chr(244)=>611, chr(245)=>611, chr(246)=>611, chr(247)=>584, chr(248)=>611, chr(249)=>611, chr(250)=>611, chr(251)=>611, chr(252)=>611, chr(253)=>556, chr(254)=>611, chr(255)=>556); |
|
| 15 | 15 | ?> |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | $fpdf_charwidths['helveticaB']=array( |
| 3 | 5 | chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, |
| 4 | 6 | chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584, |
@@ -1,15 +1,15 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 2 | -$fpdf_charwidths['zapfdingbats']=array( |
|
| 3 | - chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0, |
|
| 4 | - chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939, |
|
| 5 | - ','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692, |
|
| 6 | - 'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776, |
|
| 7 | - 'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873, |
|
| 8 | - 'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317, |
|
| 9 | - chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0, |
|
| 10 | - chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788, |
|
| 11 | - chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788, |
|
| 12 | - chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918, |
|
| 13 | - chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874, |
|
| 14 | - chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0); |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | +$fpdf_charwidths['zapfdingbats'] = array( |
|
| 3 | + chr(0)=>0, chr(1)=>0, chr(2)=>0, chr(3)=>0, chr(4)=>0, chr(5)=>0, chr(6)=>0, chr(7)=>0, chr(8)=>0, chr(9)=>0, chr(10)=>0, chr(11)=>0, chr(12)=>0, chr(13)=>0, chr(14)=>0, chr(15)=>0, chr(16)=>0, chr(17)=>0, chr(18)=>0, chr(19)=>0, chr(20)=>0, chr(21)=>0, |
|
| 4 | + chr(22)=>0, chr(23)=>0, chr(24)=>0, chr(25)=>0, chr(26)=>0, chr(27)=>0, chr(28)=>0, chr(29)=>0, chr(30)=>0, chr(31)=>0, ' '=>278, '!'=>974, '"'=>961, '#'=>974, '$'=>980, '%'=>719, '&'=>789, '\''=>790, '('=>791, ')'=>690, '*'=>960, '+'=>939, |
|
| 5 | + ','=>549, '-'=>855, '.'=>911, '/'=>933, '0'=>911, '1'=>945, '2'=>974, '3'=>755, '4'=>846, '5'=>762, '6'=>761, '7'=>571, '8'=>677, '9'=>763, ':'=>760, ';'=>759, '<'=>754, '='=>494, '>'=>552, '?'=>537, '@'=>577, 'A'=>692, |
|
| 6 | + 'B'=>786, 'C'=>788, 'D'=>788, 'E'=>790, 'F'=>793, 'G'=>794, 'H'=>816, 'I'=>823, 'J'=>789, 'K'=>841, 'L'=>823, 'M'=>833, 'N'=>816, 'O'=>831, 'P'=>923, 'Q'=>744, 'R'=>723, 'S'=>749, 'T'=>790, 'U'=>792, 'V'=>695, 'W'=>776, |
|
| 7 | + 'X'=>768, 'Y'=>792, 'Z'=>759, '['=>707, '\\'=>708, ']'=>682, '^'=>701, '_'=>826, '`'=>815, 'a'=>789, 'b'=>789, 'c'=>707, 'd'=>687, 'e'=>696, 'f'=>689, 'g'=>786, 'h'=>787, 'i'=>713, 'j'=>791, 'k'=>785, 'l'=>791, 'm'=>873, |
|
| 8 | + 'n'=>761, 'o'=>762, 'p'=>762, 'q'=>759, 'r'=>759, 's'=>892, 't'=>892, 'u'=>788, 'v'=>784, 'w'=>438, 'x'=>138, 'y'=>277, 'z'=>415, '{'=>392, '|'=>392, '}'=>668, '~'=>668, chr(127)=>0, chr(128)=>390, chr(129)=>390, chr(130)=>317, chr(131)=>317, |
|
| 9 | + chr(132)=>276, chr(133)=>276, chr(134)=>509, chr(135)=>509, chr(136)=>410, chr(137)=>410, chr(138)=>234, chr(139)=>234, chr(140)=>334, chr(141)=>334, chr(142)=>0, chr(143)=>0, chr(144)=>0, chr(145)=>0, chr(146)=>0, chr(147)=>0, chr(148)=>0, chr(149)=>0, chr(150)=>0, chr(151)=>0, chr(152)=>0, chr(153)=>0, |
|
| 10 | + chr(154)=>0, chr(155)=>0, chr(156)=>0, chr(157)=>0, chr(158)=>0, chr(159)=>0, chr(160)=>0, chr(161)=>732, chr(162)=>544, chr(163)=>544, chr(164)=>910, chr(165)=>667, chr(166)=>760, chr(167)=>760, chr(168)=>776, chr(169)=>595, chr(170)=>694, chr(171)=>626, chr(172)=>788, chr(173)=>788, chr(174)=>788, chr(175)=>788, |
|
| 11 | + chr(176)=>788, chr(177)=>788, chr(178)=>788, chr(179)=>788, chr(180)=>788, chr(181)=>788, chr(182)=>788, chr(183)=>788, chr(184)=>788, chr(185)=>788, chr(186)=>788, chr(187)=>788, chr(188)=>788, chr(189)=>788, chr(190)=>788, chr(191)=>788, chr(192)=>788, chr(193)=>788, chr(194)=>788, chr(195)=>788, chr(196)=>788, chr(197)=>788, |
|
| 12 | + chr(198)=>788, chr(199)=>788, chr(200)=>788, chr(201)=>788, chr(202)=>788, chr(203)=>788, chr(204)=>788, chr(205)=>788, chr(206)=>788, chr(207)=>788, chr(208)=>788, chr(209)=>788, chr(210)=>788, chr(211)=>788, chr(212)=>894, chr(213)=>838, chr(214)=>1016, chr(215)=>458, chr(216)=>748, chr(217)=>924, chr(218)=>748, chr(219)=>918, |
|
| 13 | + chr(220)=>927, chr(221)=>928, chr(222)=>928, chr(223)=>834, chr(224)=>873, chr(225)=>828, chr(226)=>924, chr(227)=>924, chr(228)=>917, chr(229)=>930, chr(230)=>931, chr(231)=>463, chr(232)=>883, chr(233)=>836, chr(234)=>836, chr(235)=>867, chr(236)=>867, chr(237)=>696, chr(238)=>696, chr(239)=>874, chr(240)=>0, chr(241)=>874, |
|
| 14 | + chr(242)=>760, chr(243)=>946, chr(244)=>771, chr(245)=>865, chr(246)=>771, chr(247)=>888, chr(248)=>967, chr(249)=>888, chr(250)=>831, chr(251)=>873, chr(252)=>927, chr(253)=>970, chr(254)=>918, chr(255)=>0); |
|
| 15 | 15 | ?> |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | $fpdf_charwidths['zapfdingbats']=array( |
| 3 | 5 | chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0, |
| 4 | 6 | chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939, |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /******************************************************************************* |
@@ -13,360 +13,360 @@ discard block |
||
| 13 | 13 | * Auteur : Olivier PLATHEY * |
| 14 | 14 | *******************************************************************************/ |
| 15 | 15 | |
| 16 | -define('FPDF_VERSION','1.6'); |
|
| 16 | +define('FPDF_VERSION', '1.6'); |
|
| 17 | 17 | |
| 18 | 18 | class wpshop_FPDF |
| 19 | 19 | { |
| 20 | -var $page; //current page number |
|
| 21 | -var $n; //current object number |
|
| 22 | -var $offsets; //array of object offsets |
|
| 23 | -var $buffer; //buffer holding in-memory PDF |
|
| 24 | -var $pages; //array containing pages |
|
| 25 | -var $state; //current document state |
|
| 26 | -var $compress; //compression flag |
|
| 27 | -var $k; //scale factor (number of points in user unit) |
|
| 28 | -var $DefOrientation; //default orientation |
|
| 29 | -var $CurOrientation; //current orientation |
|
| 30 | -var $PageFormats; //available page formats |
|
| 31 | -var $DefPageFormat; //default page format |
|
| 32 | -var $CurPageFormat; //current page format |
|
| 33 | -var $PageSizes; //array storing non-default page sizes |
|
| 34 | -var $wPt,$hPt; //dimensions of current page in points |
|
| 35 | -var $w,$h; //dimensions of current page in user unit |
|
| 36 | -var $lMargin; //left margin |
|
| 37 | -var $tMargin; //top margin |
|
| 38 | -var $rMargin; //right margin |
|
| 39 | -var $bMargin; //page break margin |
|
| 40 | -var $cMargin; //cell margin |
|
| 41 | -var $x,$y; //current position in user unit |
|
| 42 | -var $lasth; //height of last printed cell |
|
| 43 | -var $LineWidth; //line width in user unit |
|
| 44 | -var $CoreFonts; //array of standard font names |
|
| 45 | -var $fonts; //array of used fonts |
|
| 46 | -var $FontFiles; //array of font files |
|
| 47 | -var $diffs; //array of encoding differences |
|
| 48 | -var $FontFamily; //current font family |
|
| 49 | -var $FontStyle; //current font style |
|
| 50 | -var $underline; //underlining flag |
|
| 51 | -var $CurrentFont; //current font info |
|
| 52 | -var $FontSizePt; //current font size in points |
|
| 53 | -var $FontSize; //current font size in user unit |
|
| 54 | -var $DrawColor; //commands for drawing color |
|
| 55 | -var $FillColor; //commands for filling color |
|
| 56 | -var $TextColor; //commands for text color |
|
| 57 | -var $ColorFlag; //indicates whether fill and text colors are different |
|
| 58 | -var $ws; //word spacing |
|
| 59 | -var $images; //array of used images |
|
| 60 | -var $PageLinks; //array of links in pages |
|
| 61 | -var $links; //array of internal links |
|
| 62 | -var $AutoPageBreak; //automatic page breaking |
|
| 63 | -var $PageBreakTrigger; //threshold used to trigger page breaks |
|
| 64 | -var $InHeader; //flag set when processing header |
|
| 65 | -var $InFooter; //flag set when processing footer |
|
| 66 | -var $ZoomMode; //zoom display mode |
|
| 67 | -var $LayoutMode; //layout display mode |
|
| 68 | -var $title; //title |
|
| 69 | -var $subject; //subject |
|
| 70 | -var $author; //author |
|
| 71 | -var $keywords; //keywords |
|
| 72 | -var $creator; //creator |
|
| 73 | -var $AliasNbPages; //alias for total number of pages |
|
| 74 | -var $PDFVersion; //PDF version number |
|
| 20 | +var $page; //current page number |
|
| 21 | +var $n; //current object number |
|
| 22 | +var $offsets; //array of object offsets |
|
| 23 | +var $buffer; //buffer holding in-memory PDF |
|
| 24 | +var $pages; //array containing pages |
|
| 25 | +var $state; //current document state |
|
| 26 | +var $compress; //compression flag |
|
| 27 | +var $k; //scale factor (number of points in user unit) |
|
| 28 | +var $DefOrientation; //default orientation |
|
| 29 | +var $CurOrientation; //current orientation |
|
| 30 | +var $PageFormats; //available page formats |
|
| 31 | +var $DefPageFormat; //default page format |
|
| 32 | +var $CurPageFormat; //current page format |
|
| 33 | +var $PageSizes; //array storing non-default page sizes |
|
| 34 | +var $wPt, $hPt; //dimensions of current page in points |
|
| 35 | +var $w, $h; //dimensions of current page in user unit |
|
| 36 | +var $lMargin; //left margin |
|
| 37 | +var $tMargin; //top margin |
|
| 38 | +var $rMargin; //right margin |
|
| 39 | +var $bMargin; //page break margin |
|
| 40 | +var $cMargin; //cell margin |
|
| 41 | +var $x, $y; //current position in user unit |
|
| 42 | +var $lasth; //height of last printed cell |
|
| 43 | +var $LineWidth; //line width in user unit |
|
| 44 | +var $CoreFonts; //array of standard font names |
|
| 45 | +var $fonts; //array of used fonts |
|
| 46 | +var $FontFiles; //array of font files |
|
| 47 | +var $diffs; //array of encoding differences |
|
| 48 | +var $FontFamily; //current font family |
|
| 49 | +var $FontStyle; //current font style |
|
| 50 | +var $underline; //underlining flag |
|
| 51 | +var $CurrentFont; //current font info |
|
| 52 | +var $FontSizePt; //current font size in points |
|
| 53 | +var $FontSize; //current font size in user unit |
|
| 54 | +var $DrawColor; //commands for drawing color |
|
| 55 | +var $FillColor; //commands for filling color |
|
| 56 | +var $TextColor; //commands for text color |
|
| 57 | +var $ColorFlag; //indicates whether fill and text colors are different |
|
| 58 | +var $ws; //word spacing |
|
| 59 | +var $images; //array of used images |
|
| 60 | +var $PageLinks; //array of links in pages |
|
| 61 | +var $links; //array of internal links |
|
| 62 | +var $AutoPageBreak; //automatic page breaking |
|
| 63 | +var $PageBreakTrigger; //threshold used to trigger page breaks |
|
| 64 | +var $InHeader; //flag set when processing header |
|
| 65 | +var $InFooter; //flag set when processing footer |
|
| 66 | +var $ZoomMode; //zoom display mode |
|
| 67 | +var $LayoutMode; //layout display mode |
|
| 68 | +var $title; //title |
|
| 69 | +var $subject; //subject |
|
| 70 | +var $author; //author |
|
| 71 | +var $keywords; //keywords |
|
| 72 | +var $creator; //creator |
|
| 73 | +var $AliasNbPages; //alias for total number of pages |
|
| 74 | +var $PDFVersion; //PDF version number |
|
| 75 | 75 | |
| 76 | 76 | /******************************************************************************* |
| 77 | 77 | * * |
| 78 | 78 | * Public methods * |
| 79 | 79 | * * |
| 80 | 80 | *******************************************************************************/ |
| 81 | -function wpshop_FPDF($orientation='P', $unit='mm', $format='A4') |
|
| 81 | +function wpshop_FPDF($orientation = 'P', $unit = 'mm', $format = 'A4') |
|
| 82 | 82 | { |
| 83 | 83 | //Some checks |
| 84 | 84 | $this->_dochecks(); |
| 85 | 85 | //Initialization of properties |
| 86 | - $this->page=0; |
|
| 87 | - $this->n=2; |
|
| 88 | - $this->buffer=''; |
|
| 89 | - $this->pages=array(); |
|
| 90 | - $this->PageSizes=array(); |
|
| 91 | - $this->state=0; |
|
| 92 | - $this->fonts=array(); |
|
| 93 | - $this->FontFiles=array(); |
|
| 94 | - $this->diffs=array(); |
|
| 95 | - $this->images=array(); |
|
| 96 | - $this->links=array(); |
|
| 97 | - $this->InHeader=false; |
|
| 98 | - $this->InFooter=false; |
|
| 99 | - $this->lasth=0; |
|
| 100 | - $this->FontFamily=''; |
|
| 101 | - $this->FontStyle=''; |
|
| 102 | - $this->FontSizePt=12; |
|
| 103 | - $this->underline=false; |
|
| 104 | - $this->DrawColor='0 G'; |
|
| 105 | - $this->FillColor='0 g'; |
|
| 106 | - $this->TextColor='0 g'; |
|
| 107 | - $this->ColorFlag=false; |
|
| 108 | - $this->ws=0; |
|
| 86 | + $this->page = 0; |
|
| 87 | + $this->n = 2; |
|
| 88 | + $this->buffer = ''; |
|
| 89 | + $this->pages = array(); |
|
| 90 | + $this->PageSizes = array(); |
|
| 91 | + $this->state = 0; |
|
| 92 | + $this->fonts = array(); |
|
| 93 | + $this->FontFiles = array(); |
|
| 94 | + $this->diffs = array(); |
|
| 95 | + $this->images = array(); |
|
| 96 | + $this->links = array(); |
|
| 97 | + $this->InHeader = false; |
|
| 98 | + $this->InFooter = false; |
|
| 99 | + $this->lasth = 0; |
|
| 100 | + $this->FontFamily = ''; |
|
| 101 | + $this->FontStyle = ''; |
|
| 102 | + $this->FontSizePt = 12; |
|
| 103 | + $this->underline = false; |
|
| 104 | + $this->DrawColor = '0 G'; |
|
| 105 | + $this->FillColor = '0 g'; |
|
| 106 | + $this->TextColor = '0 g'; |
|
| 107 | + $this->ColorFlag = false; |
|
| 108 | + $this->ws = 0; |
|
| 109 | 109 | //Standard fonts |
| 110 | - $this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique', |
|
| 110 | + $this->CoreFonts = array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique', |
|
| 111 | 111 | 'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique', |
| 112 | 112 | 'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic', |
| 113 | 113 | 'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats'); |
| 114 | 114 | //Scale factor |
| 115 | - if($unit=='pt') |
|
| 116 | - $this->k=1; |
|
| 117 | - elseif($unit=='mm') |
|
| 118 | - $this->k=72/25.4; |
|
| 119 | - elseif($unit=='cm') |
|
| 120 | - $this->k=72/2.54; |
|
| 121 | - elseif($unit=='in') |
|
| 122 | - $this->k=72; |
|
| 115 | + if ($unit == 'pt') |
|
| 116 | + $this->k = 1; |
|
| 117 | + elseif ($unit == 'mm') |
|
| 118 | + $this->k = 72 / 25.4; |
|
| 119 | + elseif ($unit == 'cm') |
|
| 120 | + $this->k = 72 / 2.54; |
|
| 121 | + elseif ($unit == 'in') |
|
| 122 | + $this->k = 72; |
|
| 123 | 123 | else |
| 124 | - $this->Error('Incorrect unit: '.$unit); |
|
| 124 | + $this->Error('Incorrect unit: ' . $unit); |
|
| 125 | 125 | //Page format |
| 126 | - $this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), |
|
| 127 | - 'letter'=>array(612,792), 'legal'=>array(612,1008)); |
|
| 128 | - if(is_string($format)) |
|
| 129 | - $format=$this->_getpageformat($format); |
|
| 130 | - $this->DefPageFormat=$format; |
|
| 131 | - $this->CurPageFormat=$format; |
|
| 126 | + $this->PageFormats = array('a3'=>array(841.89, 1190.55), 'a4'=>array(595.28, 841.89), 'a5'=>array(420.94, 595.28), |
|
| 127 | + 'letter'=>array(612, 792), 'legal'=>array(612, 1008)); |
|
| 128 | + if (is_string($format)) |
|
| 129 | + $format = $this->_getpageformat($format); |
|
| 130 | + $this->DefPageFormat = $format; |
|
| 131 | + $this->CurPageFormat = $format; |
|
| 132 | 132 | //Page orientation |
| 133 | - $orientation=strtolower($orientation); |
|
| 134 | - if($orientation=='p' || $orientation=='portrait') |
|
| 133 | + $orientation = strtolower($orientation); |
|
| 134 | + if ($orientation == 'p' || $orientation == 'portrait') |
|
| 135 | 135 | { |
| 136 | - $this->DefOrientation='P'; |
|
| 137 | - $this->w=$this->DefPageFormat[0]; |
|
| 138 | - $this->h=$this->DefPageFormat[1]; |
|
| 136 | + $this->DefOrientation = 'P'; |
|
| 137 | + $this->w = $this->DefPageFormat[0]; |
|
| 138 | + $this->h = $this->DefPageFormat[1]; |
|
| 139 | 139 | } |
| 140 | - elseif($orientation=='l' || $orientation=='landscape') |
|
| 140 | + elseif ($orientation == 'l' || $orientation == 'landscape') |
|
| 141 | 141 | { |
| 142 | - $this->DefOrientation='L'; |
|
| 143 | - $this->w=$this->DefPageFormat[1]; |
|
| 144 | - $this->h=$this->DefPageFormat[0]; |
|
| 142 | + $this->DefOrientation = 'L'; |
|
| 143 | + $this->w = $this->DefPageFormat[1]; |
|
| 144 | + $this->h = $this->DefPageFormat[0]; |
|
| 145 | 145 | } |
| 146 | 146 | else |
| 147 | - $this->Error('Incorrect orientation: '.$orientation); |
|
| 148 | - $this->CurOrientation=$this->DefOrientation; |
|
| 149 | - $this->wPt=$this->w*$this->k; |
|
| 150 | - $this->hPt=$this->h*$this->k; |
|
| 147 | + $this->Error('Incorrect orientation: ' . $orientation); |
|
| 148 | + $this->CurOrientation = $this->DefOrientation; |
|
| 149 | + $this->wPt = $this->w * $this->k; |
|
| 150 | + $this->hPt = $this->h * $this->k; |
|
| 151 | 151 | //Page margins (1 cm) |
| 152 | - $margin=28.35/$this->k; |
|
| 153 | - $this->SetMargins($margin,$margin); |
|
| 152 | + $margin = 28.35 / $this->k; |
|
| 153 | + $this->SetMargins($margin, $margin); |
|
| 154 | 154 | //Interior cell margin (1 mm) |
| 155 | - $this->cMargin=$margin/10; |
|
| 155 | + $this->cMargin = $margin / 10; |
|
| 156 | 156 | //Line width (0.2 mm) |
| 157 | - $this->LineWidth=.567/$this->k; |
|
| 157 | + $this->LineWidth = .567 / $this->k; |
|
| 158 | 158 | //Automatic page break |
| 159 | - $this->SetAutoPageBreak(true,2*$margin); |
|
| 159 | + $this->SetAutoPageBreak(true, 2 * $margin); |
|
| 160 | 160 | //Full width display mode |
| 161 | 161 | $this->SetDisplayMode('fullwidth'); |
| 162 | 162 | //Enable compression |
| 163 | 163 | $this->SetCompression(true); |
| 164 | 164 | //Set default PDF version number |
| 165 | - $this->PDFVersion='1.3'; |
|
| 165 | + $this->PDFVersion = '1.3'; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | -function SetMargins($left, $top, $right=null) |
|
| 168 | +function SetMargins($left, $top, $right = null) |
|
| 169 | 169 | { |
| 170 | 170 | //Set left, top and right margins |
| 171 | - $this->lMargin=$left; |
|
| 172 | - $this->tMargin=$top; |
|
| 173 | - if($right===null) |
|
| 174 | - $right=$left; |
|
| 175 | - $this->rMargin=$right; |
|
| 171 | + $this->lMargin = $left; |
|
| 172 | + $this->tMargin = $top; |
|
| 173 | + if ($right === null) |
|
| 174 | + $right = $left; |
|
| 175 | + $this->rMargin = $right; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | function SetLeftMargin($margin) |
| 179 | 179 | { |
| 180 | 180 | //Set left margin |
| 181 | - $this->lMargin=$margin; |
|
| 182 | - if($this->page>0 && $this->x<$margin) |
|
| 183 | - $this->x=$margin; |
|
| 181 | + $this->lMargin = $margin; |
|
| 182 | + if ($this->page > 0 && $this->x < $margin) |
|
| 183 | + $this->x = $margin; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | function SetTopMargin($margin) |
| 187 | 187 | { |
| 188 | 188 | //Set top margin |
| 189 | - $this->tMargin=$margin; |
|
| 189 | + $this->tMargin = $margin; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | function SetRightMargin($margin) |
| 193 | 193 | { |
| 194 | 194 | //Set right margin |
| 195 | - $this->rMargin=$margin; |
|
| 195 | + $this->rMargin = $margin; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | -function SetAutoPageBreak($auto, $margin=0) |
|
| 198 | +function SetAutoPageBreak($auto, $margin = 0) |
|
| 199 | 199 | { |
| 200 | 200 | //Set auto page break mode and triggering margin |
| 201 | - $this->AutoPageBreak=$auto; |
|
| 202 | - $this->bMargin=$margin; |
|
| 203 | - $this->PageBreakTrigger=$this->h-$margin; |
|
| 201 | + $this->AutoPageBreak = $auto; |
|
| 202 | + $this->bMargin = $margin; |
|
| 203 | + $this->PageBreakTrigger = $this->h - $margin; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | -function SetDisplayMode($zoom, $layout='continuous') |
|
| 206 | +function SetDisplayMode($zoom, $layout = 'continuous') |
|
| 207 | 207 | { |
| 208 | 208 | //Set display mode in viewer |
| 209 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
| 210 | - $this->ZoomMode=$zoom; |
|
| 209 | + if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom)) |
|
| 210 | + $this->ZoomMode = $zoom; |
|
| 211 | 211 | else |
| 212 | - $this->Error('Incorrect zoom display mode: '.$zoom); |
|
| 213 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
| 214 | - $this->LayoutMode=$layout; |
|
| 212 | + $this->Error('Incorrect zoom display mode: ' . $zoom); |
|
| 213 | + if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default') |
|
| 214 | + $this->LayoutMode = $layout; |
|
| 215 | 215 | else |
| 216 | - $this->Error('Incorrect layout display mode: '.$layout); |
|
| 216 | + $this->Error('Incorrect layout display mode: ' . $layout); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | function SetCompression($compress) |
| 220 | 220 | { |
| 221 | 221 | //Set page compression |
| 222 | - if(function_exists('gzcompress')) |
|
| 223 | - $this->compress=$compress; |
|
| 222 | + if (function_exists('gzcompress')) |
|
| 223 | + $this->compress = $compress; |
|
| 224 | 224 | else |
| 225 | - $this->compress=false; |
|
| 225 | + $this->compress = false; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | -function SetTitle($title, $isUTF8=false) |
|
| 228 | +function SetTitle($title, $isUTF8 = false) |
|
| 229 | 229 | { |
| 230 | 230 | //Title of document |
| 231 | - if($isUTF8) |
|
| 232 | - $title=$this->_UTF8toUTF16($title); |
|
| 233 | - $this->title=$title; |
|
| 231 | + if ($isUTF8) |
|
| 232 | + $title = $this->_UTF8toUTF16($title); |
|
| 233 | + $this->title = $title; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | -function SetSubject($subject, $isUTF8=false) |
|
| 236 | +function SetSubject($subject, $isUTF8 = false) |
|
| 237 | 237 | { |
| 238 | 238 | //Subject of document |
| 239 | - if($isUTF8) |
|
| 240 | - $subject=$this->_UTF8toUTF16($subject); |
|
| 241 | - $this->subject=$subject; |
|
| 239 | + if ($isUTF8) |
|
| 240 | + $subject = $this->_UTF8toUTF16($subject); |
|
| 241 | + $this->subject = $subject; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | -function SetAuthor($author, $isUTF8=false) |
|
| 244 | +function SetAuthor($author, $isUTF8 = false) |
|
| 245 | 245 | { |
| 246 | 246 | //Author of document |
| 247 | - if($isUTF8) |
|
| 248 | - $author=$this->_UTF8toUTF16($author); |
|
| 249 | - $this->author=$author; |
|
| 247 | + if ($isUTF8) |
|
| 248 | + $author = $this->_UTF8toUTF16($author); |
|
| 249 | + $this->author = $author; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | -function SetKeywords($keywords, $isUTF8=false) |
|
| 252 | +function SetKeywords($keywords, $isUTF8 = false) |
|
| 253 | 253 | { |
| 254 | 254 | //Keywords of document |
| 255 | - if($isUTF8) |
|
| 256 | - $keywords=$this->_UTF8toUTF16($keywords); |
|
| 257 | - $this->keywords=$keywords; |
|
| 255 | + if ($isUTF8) |
|
| 256 | + $keywords = $this->_UTF8toUTF16($keywords); |
|
| 257 | + $this->keywords = $keywords; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | -function SetCreator($creator, $isUTF8=false) |
|
| 260 | +function SetCreator($creator, $isUTF8 = false) |
|
| 261 | 261 | { |
| 262 | 262 | //Creator of document |
| 263 | - if($isUTF8) |
|
| 264 | - $creator=$this->_UTF8toUTF16($creator); |
|
| 265 | - $this->creator=$creator; |
|
| 263 | + if ($isUTF8) |
|
| 264 | + $creator = $this->_UTF8toUTF16($creator); |
|
| 265 | + $this->creator = $creator; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | -function AliasNbPages($alias='{nb}') |
|
| 268 | +function AliasNbPages($alias = '{nb}') |
|
| 269 | 269 | { |
| 270 | 270 | //Define an alias for total number of pages |
| 271 | - $this->AliasNbPages=$alias; |
|
| 271 | + $this->AliasNbPages = $alias; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | function Error($msg) |
| 275 | 275 | { |
| 276 | 276 | //Fatal error |
| 277 | - die('<b>FPDF error:</b> '.$msg); |
|
| 277 | + die('<b>FPDF error:</b> ' . $msg); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | function Open() |
| 281 | 281 | { |
| 282 | 282 | //Begin document |
| 283 | - $this->state=1; |
|
| 283 | + $this->state = 1; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | function Close() |
| 287 | 287 | { |
| 288 | 288 | //Terminate document |
| 289 | - if($this->state==3) |
|
| 289 | + if ($this->state == 3) |
|
| 290 | 290 | return; |
| 291 | - if($this->page==0) |
|
| 291 | + if ($this->page == 0) |
|
| 292 | 292 | $this->AddPage(); |
| 293 | 293 | //Page footer |
| 294 | - $this->InFooter=true; |
|
| 294 | + $this->InFooter = true; |
|
| 295 | 295 | $this->Footer(); |
| 296 | - $this->InFooter=false; |
|
| 296 | + $this->InFooter = false; |
|
| 297 | 297 | //Close page |
| 298 | 298 | $this->_endpage(); |
| 299 | 299 | //Close document |
| 300 | 300 | $this->_enddoc(); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | -function AddPage($orientation='', $format='') |
|
| 303 | +function AddPage($orientation = '', $format = '') |
|
| 304 | 304 | { |
| 305 | 305 | //Start a new page |
| 306 | - if($this->state==0) |
|
| 306 | + if ($this->state == 0) |
|
| 307 | 307 | $this->Open(); |
| 308 | - $family=$this->FontFamily; |
|
| 309 | - $style=$this->FontStyle.($this->underline ? 'U' : ''); |
|
| 310 | - $size=$this->FontSizePt; |
|
| 311 | - $lw=$this->LineWidth; |
|
| 312 | - $dc=$this->DrawColor; |
|
| 313 | - $fc=$this->FillColor; |
|
| 314 | - $tc=$this->TextColor; |
|
| 315 | - $cf=$this->ColorFlag; |
|
| 316 | - if($this->page>0) |
|
| 308 | + $family = $this->FontFamily; |
|
| 309 | + $style = $this->FontStyle . ($this->underline ? 'U' : ''); |
|
| 310 | + $size = $this->FontSizePt; |
|
| 311 | + $lw = $this->LineWidth; |
|
| 312 | + $dc = $this->DrawColor; |
|
| 313 | + $fc = $this->FillColor; |
|
| 314 | + $tc = $this->TextColor; |
|
| 315 | + $cf = $this->ColorFlag; |
|
| 316 | + if ($this->page > 0) |
|
| 317 | 317 | { |
| 318 | 318 | //Page footer |
| 319 | - $this->InFooter=true; |
|
| 319 | + $this->InFooter = true; |
|
| 320 | 320 | $this->Footer(); |
| 321 | - $this->InFooter=false; |
|
| 321 | + $this->InFooter = false; |
|
| 322 | 322 | //Close page |
| 323 | 323 | $this->_endpage(); |
| 324 | 324 | } |
| 325 | 325 | //Start new page |
| 326 | - $this->_beginpage($orientation,$format); |
|
| 326 | + $this->_beginpage($orientation, $format); |
|
| 327 | 327 | //Set line cap style to square |
| 328 | 328 | $this->_out('2 J'); |
| 329 | 329 | //Set line width |
| 330 | - $this->LineWidth=$lw; |
|
| 331 | - $this->_out(sprintf('%.2F w',$lw*$this->k)); |
|
| 330 | + $this->LineWidth = $lw; |
|
| 331 | + $this->_out(sprintf('%.2F w', $lw * $this->k)); |
|
| 332 | 332 | //Set font |
| 333 | - if($family) |
|
| 334 | - $this->SetFont($family,$style,$size); |
|
| 333 | + if ($family) |
|
| 334 | + $this->SetFont($family, $style, $size); |
|
| 335 | 335 | //Set colors |
| 336 | - $this->DrawColor=$dc; |
|
| 337 | - if($dc!='0 G') |
|
| 336 | + $this->DrawColor = $dc; |
|
| 337 | + if ($dc != '0 G') |
|
| 338 | 338 | $this->_out($dc); |
| 339 | - $this->FillColor=$fc; |
|
| 340 | - if($fc!='0 g') |
|
| 339 | + $this->FillColor = $fc; |
|
| 340 | + if ($fc != '0 g') |
|
| 341 | 341 | $this->_out($fc); |
| 342 | - $this->TextColor=$tc; |
|
| 343 | - $this->ColorFlag=$cf; |
|
| 342 | + $this->TextColor = $tc; |
|
| 343 | + $this->ColorFlag = $cf; |
|
| 344 | 344 | //Page header |
| 345 | - $this->InHeader=true; |
|
| 345 | + $this->InHeader = true; |
|
| 346 | 346 | $this->Header(); |
| 347 | - $this->InHeader=false; |
|
| 347 | + $this->InHeader = false; |
|
| 348 | 348 | //Restore line width |
| 349 | - if($this->LineWidth!=$lw) |
|
| 349 | + if ($this->LineWidth != $lw) |
|
| 350 | 350 | { |
| 351 | - $this->LineWidth=$lw; |
|
| 352 | - $this->_out(sprintf('%.2F w',$lw*$this->k)); |
|
| 351 | + $this->LineWidth = $lw; |
|
| 352 | + $this->_out(sprintf('%.2F w', $lw * $this->k)); |
|
| 353 | 353 | } |
| 354 | 354 | //Restore font |
| 355 | - if($family) |
|
| 356 | - $this->SetFont($family,$style,$size); |
|
| 355 | + if ($family) |
|
| 356 | + $this->SetFont($family, $style, $size); |
|
| 357 | 357 | //Restore colors |
| 358 | - if($this->DrawColor!=$dc) |
|
| 358 | + if ($this->DrawColor != $dc) |
|
| 359 | 359 | { |
| 360 | - $this->DrawColor=$dc; |
|
| 360 | + $this->DrawColor = $dc; |
|
| 361 | 361 | $this->_out($dc); |
| 362 | 362 | } |
| 363 | - if($this->FillColor!=$fc) |
|
| 363 | + if ($this->FillColor != $fc) |
|
| 364 | 364 | { |
| 365 | - $this->FillColor=$fc; |
|
| 365 | + $this->FillColor = $fc; |
|
| 366 | 366 | $this->_out($fc); |
| 367 | 367 | } |
| 368 | - $this->TextColor=$tc; |
|
| 369 | - $this->ColorFlag=$cf; |
|
| 368 | + $this->TextColor = $tc; |
|
| 369 | + $this->ColorFlag = $cf; |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | function Header() |
@@ -385,230 +385,230 @@ discard block |
||
| 385 | 385 | return $this->page; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | -function SetDrawColor($r, $g=null, $b=null) |
|
| 388 | +function SetDrawColor($r, $g = null, $b = null) |
|
| 389 | 389 | { |
| 390 | 390 | //Set color for all stroking operations |
| 391 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 392 | - $this->DrawColor=sprintf('%.3F G',$r/255); |
|
| 391 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
| 392 | + $this->DrawColor = sprintf('%.3F G', $r / 255); |
|
| 393 | 393 | else |
| 394 | - $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
| 395 | - if($this->page>0) |
|
| 394 | + $this->DrawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255); |
|
| 395 | + if ($this->page > 0) |
|
| 396 | 396 | $this->_out($this->DrawColor); |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | -function SetFillColor($r, $g=null, $b=null) |
|
| 399 | +function SetFillColor($r, $g = null, $b = null) |
|
| 400 | 400 | { |
| 401 | 401 | //Set color for all filling operations |
| 402 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 403 | - $this->FillColor=sprintf('%.3F g',$r/255); |
|
| 402 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
| 403 | + $this->FillColor = sprintf('%.3F g', $r / 255); |
|
| 404 | 404 | else |
| 405 | - $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 406 | - $this->ColorFlag=($this->FillColor!=$this->TextColor); |
|
| 407 | - if($this->page>0) |
|
| 405 | + $this->FillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255); |
|
| 406 | + $this->ColorFlag = ($this->FillColor != $this->TextColor); |
|
| 407 | + if ($this->page > 0) |
|
| 408 | 408 | $this->_out($this->FillColor); |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | -function SetTextColor($r, $g=null, $b=null) |
|
| 411 | +function SetTextColor($r, $g = null, $b = null) |
|
| 412 | 412 | { |
| 413 | 413 | //Set color for text |
| 414 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 415 | - $this->TextColor=sprintf('%.3F g',$r/255); |
|
| 414 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
| 415 | + $this->TextColor = sprintf('%.3F g', $r / 255); |
|
| 416 | 416 | else |
| 417 | - $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 418 | - $this->ColorFlag=($this->FillColor!=$this->TextColor); |
|
| 417 | + $this->TextColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255); |
|
| 418 | + $this->ColorFlag = ($this->FillColor != $this->TextColor); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | function GetStringWidth($s) |
| 422 | 422 | { |
| 423 | 423 | //Get width of a string in the current font |
| 424 | - $s=(string)$s; |
|
| 425 | - $cw=&$this->CurrentFont['cw']; |
|
| 426 | - $w=0; |
|
| 427 | - $l=strlen($s); |
|
| 428 | - for($i=0;$i<$l;$i++) |
|
| 429 | - $w+=$cw[$s[$i]]; |
|
| 430 | - return $w*$this->FontSize/1000; |
|
| 424 | + $s = (string)$s; |
|
| 425 | + $cw = &$this->CurrentFont['cw']; |
|
| 426 | + $w = 0; |
|
| 427 | + $l = strlen($s); |
|
| 428 | + for ($i = 0; $i < $l; $i++) |
|
| 429 | + $w += $cw[$s[$i]]; |
|
| 430 | + return $w * $this->FontSize / 1000; |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | function SetLineWidth($width) |
| 434 | 434 | { |
| 435 | 435 | //Set line width |
| 436 | - $this->LineWidth=$width; |
|
| 437 | - if($this->page>0) |
|
| 438 | - $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 436 | + $this->LineWidth = $width; |
|
| 437 | + if ($this->page > 0) |
|
| 438 | + $this->_out(sprintf('%.2F w', $width * $this->k)); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | function Line($x1, $y1, $x2, $y2) |
| 442 | 442 | { |
| 443 | 443 | //Draw a line |
| 444 | - $this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k)); |
|
| 444 | + $this->_out(sprintf('%.2F %.2F m %.2F %.2F l S', $x1 * $this->k, ($this->h - $y1) * $this->k, $x2 * $this->k, ($this->h - $y2) * $this->k)); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | -function Rect($x, $y, $w, $h, $style='') |
|
| 447 | +function Rect($x, $y, $w, $h, $style = '') |
|
| 448 | 448 | { |
| 449 | 449 | //Draw a rectangle |
| 450 | - if($style=='F') |
|
| 451 | - $op='f'; |
|
| 452 | - elseif($style=='FD' || $style=='DF') |
|
| 453 | - $op='B'; |
|
| 450 | + if ($style == 'F') |
|
| 451 | + $op = 'f'; |
|
| 452 | + elseif ($style == 'FD' || $style == 'DF') |
|
| 453 | + $op = 'B'; |
|
| 454 | 454 | else |
| 455 | - $op='S'; |
|
| 456 | - $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); |
|
| 455 | + $op = 'S'; |
|
| 456 | + $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s', $x * $this->k, ($this->h - $y) * $this->k, $w * $this->k, -$h * $this->k, $op)); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | -function AddFont($family, $style='', $file='') |
|
| 459 | +function AddFont($family, $style = '', $file = '') |
|
| 460 | 460 | { |
| 461 | 461 | //Add a TrueType or Type1 font |
| 462 | - $family=strtolower($family); |
|
| 463 | - if($file=='') |
|
| 464 | - $file=str_replace(' ','',$family).strtolower($style).'.php'; |
|
| 465 | - if($family=='arial') |
|
| 466 | - $family='helvetica'; |
|
| 467 | - $style=strtoupper($style); |
|
| 468 | - if($style=='IB') |
|
| 469 | - $style='BI'; |
|
| 470 | - $fontkey=$family.$style; |
|
| 471 | - if(isset($this->fonts[$fontkey])) |
|
| 462 | + $family = strtolower($family); |
|
| 463 | + if ($file == '') |
|
| 464 | + $file = str_replace(' ', '', $family) . strtolower($style) . '.php'; |
|
| 465 | + if ($family == 'arial') |
|
| 466 | + $family = 'helvetica'; |
|
| 467 | + $style = strtoupper($style); |
|
| 468 | + if ($style == 'IB') |
|
| 469 | + $style = 'BI'; |
|
| 470 | + $fontkey = $family . $style; |
|
| 471 | + if (isset($this->fonts[$fontkey])) |
|
| 472 | 472 | return; |
| 473 | - include($this->_getfontpath().$file); |
|
| 474 | - if(!isset($name)) |
|
| 473 | + include($this->_getfontpath() . $file); |
|
| 474 | + if (!isset($name)) |
|
| 475 | 475 | $this->Error('Could not include font definition file'); |
| 476 | - $i=count($this->fonts)+1; |
|
| 477 | - $this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file); |
|
| 478 | - if($diff) |
|
| 476 | + $i = count($this->fonts) + 1; |
|
| 477 | + $this->fonts[$fontkey] = array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file); |
|
| 478 | + if ($diff) |
|
| 479 | 479 | { |
| 480 | 480 | //Search existing encodings |
| 481 | - $d=0; |
|
| 482 | - $nb=count($this->diffs); |
|
| 483 | - for($i=1;$i<=$nb;$i++) |
|
| 481 | + $d = 0; |
|
| 482 | + $nb = count($this->diffs); |
|
| 483 | + for ($i = 1; $i <= $nb; $i++) |
|
| 484 | 484 | { |
| 485 | - if($this->diffs[$i]==$diff) |
|
| 485 | + if ($this->diffs[$i] == $diff) |
|
| 486 | 486 | { |
| 487 | - $d=$i; |
|
| 487 | + $d = $i; |
|
| 488 | 488 | break; |
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | - if($d==0) |
|
| 491 | + if ($d == 0) |
|
| 492 | 492 | { |
| 493 | - $d=$nb+1; |
|
| 494 | - $this->diffs[$d]=$diff; |
|
| 493 | + $d = $nb + 1; |
|
| 494 | + $this->diffs[$d] = $diff; |
|
| 495 | 495 | } |
| 496 | - $this->fonts[$fontkey]['diff']=$d; |
|
| 496 | + $this->fonts[$fontkey]['diff'] = $d; |
|
| 497 | 497 | } |
| 498 | - if($file) |
|
| 498 | + if ($file) |
|
| 499 | 499 | { |
| 500 | - if($type=='TrueType') |
|
| 501 | - $this->FontFiles[$file]=array('length1'=>$originalsize); |
|
| 500 | + if ($type == 'TrueType') |
|
| 501 | + $this->FontFiles[$file] = array('length1'=>$originalsize); |
|
| 502 | 502 | else |
| 503 | - $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2); |
|
| 503 | + $this->FontFiles[$file] = array('length1'=>$size1, 'length2'=>$size2); |
|
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | -function SetFont($family, $style='', $size=0) |
|
| 507 | +function SetFont($family, $style = '', $size = 0) |
|
| 508 | 508 | { |
| 509 | 509 | //Select a font; size given in points |
| 510 | 510 | global $fpdf_charwidths; |
| 511 | 511 | |
| 512 | - $family=strtolower($family); |
|
| 513 | - if($family=='') |
|
| 514 | - $family=$this->FontFamily; |
|
| 515 | - if($family=='arial') |
|
| 516 | - $family='helvetica'; |
|
| 517 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 518 | - $style=''; |
|
| 519 | - $style=strtoupper($style); |
|
| 520 | - if(strpos($style,'U')!==false) |
|
| 512 | + $family = strtolower($family); |
|
| 513 | + if ($family == '') |
|
| 514 | + $family = $this->FontFamily; |
|
| 515 | + if ($family == 'arial') |
|
| 516 | + $family = 'helvetica'; |
|
| 517 | + elseif ($family == 'symbol' || $family == 'zapfdingbats') |
|
| 518 | + $style = ''; |
|
| 519 | + $style = strtoupper($style); |
|
| 520 | + if (strpos($style, 'U') !== false) |
|
| 521 | 521 | { |
| 522 | - $this->underline=true; |
|
| 523 | - $style=str_replace('U','',$style); |
|
| 522 | + $this->underline = true; |
|
| 523 | + $style = str_replace('U', '', $style); |
|
| 524 | 524 | } |
| 525 | 525 | else |
| 526 | - $this->underline=false; |
|
| 527 | - if($style=='IB') |
|
| 528 | - $style='BI'; |
|
| 529 | - if($size==0) |
|
| 530 | - $size=$this->FontSizePt; |
|
| 526 | + $this->underline = false; |
|
| 527 | + if ($style == 'IB') |
|
| 528 | + $style = 'BI'; |
|
| 529 | + if ($size == 0) |
|
| 530 | + $size = $this->FontSizePt; |
|
| 531 | 531 | //Test if font is already selected |
| 532 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
| 532 | + if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size) |
|
| 533 | 533 | return; |
| 534 | 534 | //Test if used for the first time |
| 535 | - $fontkey=$family.$style; |
|
| 536 | - if(!isset($this->fonts[$fontkey])) |
|
| 535 | + $fontkey = $family . $style; |
|
| 536 | + if (!isset($this->fonts[$fontkey])) |
|
| 537 | 537 | { |
| 538 | 538 | //Check if one of the standard fonts |
| 539 | - if(isset($this->CoreFonts[$fontkey])) |
|
| 539 | + if (isset($this->CoreFonts[$fontkey])) |
|
| 540 | 540 | { |
| 541 | - if(!isset($fpdf_charwidths[$fontkey])) |
|
| 541 | + if (!isset($fpdf_charwidths[$fontkey])) |
|
| 542 | 542 | { |
| 543 | 543 | //Load metric file |
| 544 | - $file=$family; |
|
| 545 | - if($family=='times' || $family=='helvetica') |
|
| 546 | - $file.=strtolower($style); |
|
| 547 | - include($this->_getfontpath().$file.'.php'); |
|
| 548 | - if(!isset($fpdf_charwidths[$fontkey])) |
|
| 544 | + $file = $family; |
|
| 545 | + if ($family == 'times' || $family == 'helvetica') |
|
| 546 | + $file .= strtolower($style); |
|
| 547 | + include($this->_getfontpath() . $file . '.php'); |
|
| 548 | + if (!isset($fpdf_charwidths[$fontkey])) |
|
| 549 | 549 | $this->Error('Could not include font metric file'); |
| 550 | 550 | } |
| 551 | - $i=count($this->fonts)+1; |
|
| 552 | - $name=$this->CoreFonts[$fontkey]; |
|
| 553 | - $cw=$fpdf_charwidths[$fontkey]; |
|
| 554 | - $this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw); |
|
| 551 | + $i = count($this->fonts) + 1; |
|
| 552 | + $name = $this->CoreFonts[$fontkey]; |
|
| 553 | + $cw = $fpdf_charwidths[$fontkey]; |
|
| 554 | + $this->fonts[$fontkey] = array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw); |
|
| 555 | 555 | } |
| 556 | 556 | else |
| 557 | - $this->Error('Undefined font: '.$family.' '.$style); |
|
| 557 | + $this->Error('Undefined font: ' . $family . ' ' . $style); |
|
| 558 | 558 | } |
| 559 | 559 | //Select it |
| 560 | - $this->FontFamily=$family; |
|
| 561 | - $this->FontStyle=$style; |
|
| 562 | - $this->FontSizePt=$size; |
|
| 563 | - $this->FontSize=$size/$this->k; |
|
| 564 | - $this->CurrentFont=&$this->fonts[$fontkey]; |
|
| 565 | - if($this->page>0) |
|
| 566 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 560 | + $this->FontFamily = $family; |
|
| 561 | + $this->FontStyle = $style; |
|
| 562 | + $this->FontSizePt = $size; |
|
| 563 | + $this->FontSize = $size / $this->k; |
|
| 564 | + $this->CurrentFont = &$this->fonts[$fontkey]; |
|
| 565 | + if ($this->page > 0) |
|
| 566 | + $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | function SetFontSize($size) |
| 570 | 570 | { |
| 571 | 571 | //Set font size in points |
| 572 | - if($this->FontSizePt==$size) |
|
| 572 | + if ($this->FontSizePt == $size) |
|
| 573 | 573 | return; |
| 574 | - $this->FontSizePt=$size; |
|
| 575 | - $this->FontSize=$size/$this->k; |
|
| 576 | - if($this->page>0) |
|
| 577 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 574 | + $this->FontSizePt = $size; |
|
| 575 | + $this->FontSize = $size / $this->k; |
|
| 576 | + if ($this->page > 0) |
|
| 577 | + $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | function AddLink() |
| 581 | 581 | { |
| 582 | 582 | //Create a new internal link |
| 583 | - $n=count($this->links)+1; |
|
| 584 | - $this->links[$n]=array(0, 0); |
|
| 583 | + $n = count($this->links) + 1; |
|
| 584 | + $this->links[$n] = array(0, 0); |
|
| 585 | 585 | return $n; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | -function SetLink($link, $y=0, $page=-1) |
|
| 588 | +function SetLink($link, $y = 0, $page = -1) |
|
| 589 | 589 | { |
| 590 | 590 | //Set destination of internal link |
| 591 | - if($y==-1) |
|
| 592 | - $y=$this->y; |
|
| 593 | - if($page==-1) |
|
| 594 | - $page=$this->page; |
|
| 595 | - $this->links[$link]=array($page, $y); |
|
| 591 | + if ($y == -1) |
|
| 592 | + $y = $this->y; |
|
| 593 | + if ($page == -1) |
|
| 594 | + $page = $this->page; |
|
| 595 | + $this->links[$link] = array($page, $y); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | function Link($x, $y, $w, $h, $link) |
| 599 | 599 | { |
| 600 | 600 | //Put a link on the page |
| 601 | - $this->PageLinks[$this->page][]=array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link); |
|
| 601 | + $this->PageLinks[$this->page][] = array($x * $this->k, $this->hPt - $y * $this->k, $w * $this->k, $h * $this->k, $link); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | function Text($x, $y, $txt) |
| 605 | 605 | { |
| 606 | 606 | //Output a string |
| 607 | - $s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); |
|
| 608 | - if($this->underline && $txt!='') |
|
| 609 | - $s.=' '.$this->_dounderline($x,$y,$txt); |
|
| 610 | - if($this->ColorFlag) |
|
| 611 | - $s='q '.$this->TextColor.' '.$s.' Q'; |
|
| 607 | + $s = sprintf('BT %.2F %.2F Td (%s) Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $this->_escape($txt)); |
|
| 608 | + if ($this->underline && $txt != '') |
|
| 609 | + $s .= ' ' . $this->_dounderline($x, $y, $txt); |
|
| 610 | + if ($this->ColorFlag) |
|
| 611 | + $s = 'q ' . $this->TextColor . ' ' . $s . ' Q'; |
|
| 612 | 612 | $this->_out($s); |
| 613 | 613 | } |
| 614 | 614 | |
@@ -618,268 +618,268 @@ discard block |
||
| 618 | 618 | return $this->AutoPageBreak; |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | -function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') |
|
| 621 | +function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '') |
|
| 622 | 622 | { |
| 623 | 623 | //Output a cell |
| 624 | - $k=$this->k; |
|
| 625 | - if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
| 624 | + $k = $this->k; |
|
| 625 | + if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
| 626 | 626 | { |
| 627 | 627 | //Automatic page break |
| 628 | - $x=$this->x; |
|
| 629 | - $ws=$this->ws; |
|
| 630 | - if($ws>0) |
|
| 628 | + $x = $this->x; |
|
| 629 | + $ws = $this->ws; |
|
| 630 | + if ($ws > 0) |
|
| 631 | 631 | { |
| 632 | - $this->ws=0; |
|
| 632 | + $this->ws = 0; |
|
| 633 | 633 | $this->_out('0 Tw'); |
| 634 | 634 | } |
| 635 | - $this->AddPage($this->CurOrientation,$this->CurPageFormat); |
|
| 636 | - $this->x=$x; |
|
| 637 | - if($ws>0) |
|
| 635 | + $this->AddPage($this->CurOrientation, $this->CurPageFormat); |
|
| 636 | + $this->x = $x; |
|
| 637 | + if ($ws > 0) |
|
| 638 | 638 | { |
| 639 | - $this->ws=$ws; |
|
| 640 | - $this->_out(sprintf('%.3F Tw',$ws*$k)); |
|
| 639 | + $this->ws = $ws; |
|
| 640 | + $this->_out(sprintf('%.3F Tw', $ws * $k)); |
|
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | - if($w==0) |
|
| 644 | - $w=$this->w-$this->rMargin-$this->x; |
|
| 645 | - $s=''; |
|
| 646 | - if($fill || $border==1) |
|
| 643 | + if ($w == 0) |
|
| 644 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 645 | + $s = ''; |
|
| 646 | + if ($fill || $border == 1) |
|
| 647 | 647 | { |
| 648 | - if($fill) |
|
| 649 | - $op=($border==1) ? 'B' : 'f'; |
|
| 648 | + if ($fill) |
|
| 649 | + $op = ($border == 1) ? 'B' : 'f'; |
|
| 650 | 650 | else |
| 651 | - $op='S'; |
|
| 652 | - $s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
|
| 651 | + $op = 'S'; |
|
| 652 | + $s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op); |
|
| 653 | 653 | } |
| 654 | - if(is_string($border)) |
|
| 654 | + if (is_string($border)) |
|
| 655 | 655 | { |
| 656 | - $x=$this->x; |
|
| 657 | - $y=$this->y; |
|
| 658 | - if(strpos($border,'L')!==false) |
|
| 659 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
| 660 | - if(strpos($border,'T')!==false) |
|
| 661 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
| 662 | - if(strpos($border,'R')!==false) |
|
| 663 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 664 | - if(strpos($border,'B')!==false) |
|
| 665 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 656 | + $x = $this->x; |
|
| 657 | + $y = $this->y; |
|
| 658 | + if (strpos($border, 'L') !== false) |
|
| 659 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k); |
|
| 660 | + if (strpos($border, 'T') !== false) |
|
| 661 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k); |
|
| 662 | + if (strpos($border, 'R') !== false) |
|
| 663 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); |
|
| 664 | + if (strpos($border, 'B') !== false) |
|
| 665 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); |
|
| 666 | 666 | } |
| 667 | - if($txt!=='') |
|
| 667 | + if ($txt !== '') |
|
| 668 | 668 | { |
| 669 | - if($align=='R') |
|
| 670 | - $dx=$w-$this->cMargin-$this->GetStringWidth($txt); |
|
| 671 | - elseif($align=='C') |
|
| 672 | - $dx=($w-$this->GetStringWidth($txt))/2; |
|
| 669 | + if ($align == 'R') |
|
| 670 | + $dx = $w - $this->cMargin - $this->GetStringWidth($txt); |
|
| 671 | + elseif ($align == 'C') |
|
| 672 | + $dx = ($w - $this->GetStringWidth($txt)) / 2; |
|
| 673 | 673 | else |
| 674 | - $dx=$this->cMargin; |
|
| 675 | - if($this->ColorFlag) |
|
| 676 | - $s.='q '.$this->TextColor.' '; |
|
| 677 | - $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); |
|
| 678 | - $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); |
|
| 679 | - if($this->underline) |
|
| 680 | - $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
| 681 | - if($this->ColorFlag) |
|
| 682 | - $s.=' Q'; |
|
| 683 | - if($link) |
|
| 684 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
| 674 | + $dx = $this->cMargin; |
|
| 675 | + if ($this->ColorFlag) |
|
| 676 | + $s .= 'q ' . $this->TextColor . ' '; |
|
| 677 | + $txt2 = str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt))); |
|
| 678 | + $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $txt2); |
|
| 679 | + if ($this->underline) |
|
| 680 | + $s .= ' ' . $this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt); |
|
| 681 | + if ($this->ColorFlag) |
|
| 682 | + $s .= ' Q'; |
|
| 683 | + if ($link) |
|
| 684 | + $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link); |
|
| 685 | 685 | } |
| 686 | - if($s) |
|
| 686 | + if ($s) |
|
| 687 | 687 | $this->_out($s); |
| 688 | - $this->lasth=$h; |
|
| 689 | - if($ln>0) |
|
| 688 | + $this->lasth = $h; |
|
| 689 | + if ($ln > 0) |
|
| 690 | 690 | { |
| 691 | 691 | //Go to next line |
| 692 | - $this->y+=$h; |
|
| 693 | - if($ln==1) |
|
| 694 | - $this->x=$this->lMargin; |
|
| 692 | + $this->y += $h; |
|
| 693 | + if ($ln == 1) |
|
| 694 | + $this->x = $this->lMargin; |
|
| 695 | 695 | } |
| 696 | 696 | else |
| 697 | - $this->x+=$w; |
|
| 697 | + $this->x += $w; |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | -function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) |
|
| 700 | +function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false) |
|
| 701 | 701 | { |
| 702 | 702 | //Output text with automatic or explicit line breaks |
| 703 | - $cw=&$this->CurrentFont['cw']; |
|
| 704 | - if($w==0) |
|
| 705 | - $w=$this->w-$this->rMargin-$this->x; |
|
| 706 | - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
| 707 | - $s=str_replace("\r",'',$txt); |
|
| 708 | - $nb=strlen($s); |
|
| 709 | - if($nb>0 && $s[$nb-1]=="\n") |
|
| 703 | + $cw = &$this->CurrentFont['cw']; |
|
| 704 | + if ($w == 0) |
|
| 705 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 706 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
| 707 | + $s = str_replace("\r", '', $txt); |
|
| 708 | + $nb = strlen($s); |
|
| 709 | + if ($nb > 0 && $s[$nb - 1] == "\n") |
|
| 710 | 710 | $nb--; |
| 711 | - $b=0; |
|
| 712 | - if($border) |
|
| 711 | + $b = 0; |
|
| 712 | + if ($border) |
|
| 713 | 713 | { |
| 714 | - if($border==1) |
|
| 714 | + if ($border == 1) |
|
| 715 | 715 | { |
| 716 | - $border='LTRB'; |
|
| 717 | - $b='LRT'; |
|
| 718 | - $b2='LR'; |
|
| 716 | + $border = 'LTRB'; |
|
| 717 | + $b = 'LRT'; |
|
| 718 | + $b2 = 'LR'; |
|
| 719 | 719 | } |
| 720 | 720 | else |
| 721 | 721 | { |
| 722 | - $b2=''; |
|
| 723 | - if(strpos($border,'L')!==false) |
|
| 724 | - $b2.='L'; |
|
| 725 | - if(strpos($border,'R')!==false) |
|
| 726 | - $b2.='R'; |
|
| 727 | - $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2; |
|
| 722 | + $b2 = ''; |
|
| 723 | + if (strpos($border, 'L') !== false) |
|
| 724 | + $b2 .= 'L'; |
|
| 725 | + if (strpos($border, 'R') !== false) |
|
| 726 | + $b2 .= 'R'; |
|
| 727 | + $b = (strpos($border, 'T') !== false) ? $b2 . 'T' : $b2; |
|
| 728 | 728 | } |
| 729 | 729 | } |
| 730 | - $sep=-1; |
|
| 731 | - $i=0; |
|
| 732 | - $j=0; |
|
| 733 | - $l=0; |
|
| 734 | - $ns=0; |
|
| 735 | - $nl=1; |
|
| 736 | - while($i<$nb) |
|
| 730 | + $sep = -1; |
|
| 731 | + $i = 0; |
|
| 732 | + $j = 0; |
|
| 733 | + $l = 0; |
|
| 734 | + $ns = 0; |
|
| 735 | + $nl = 1; |
|
| 736 | + while ($i < $nb) |
|
| 737 | 737 | { |
| 738 | 738 | //Get next character |
| 739 | - $c=$s[$i]; |
|
| 740 | - if($c=="\n") |
|
| 739 | + $c = $s[$i]; |
|
| 740 | + if ($c == "\n") |
|
| 741 | 741 | { |
| 742 | 742 | //Explicit line break |
| 743 | - if($this->ws>0) |
|
| 743 | + if ($this->ws > 0) |
|
| 744 | 744 | { |
| 745 | - $this->ws=0; |
|
| 745 | + $this->ws = 0; |
|
| 746 | 746 | $this->_out('0 Tw'); |
| 747 | 747 | } |
| 748 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
| 748 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
| 749 | 749 | $i++; |
| 750 | - $sep=-1; |
|
| 751 | - $j=$i; |
|
| 752 | - $l=0; |
|
| 753 | - $ns=0; |
|
| 750 | + $sep = -1; |
|
| 751 | + $j = $i; |
|
| 752 | + $l = 0; |
|
| 753 | + $ns = 0; |
|
| 754 | 754 | $nl++; |
| 755 | - if($border && $nl==2) |
|
| 756 | - $b=$b2; |
|
| 755 | + if ($border && $nl == 2) |
|
| 756 | + $b = $b2; |
|
| 757 | 757 | continue; |
| 758 | 758 | } |
| 759 | - if($c==' ') |
|
| 759 | + if ($c == ' ') |
|
| 760 | 760 | { |
| 761 | - $sep=$i; |
|
| 762 | - $ls=$l; |
|
| 761 | + $sep = $i; |
|
| 762 | + $ls = $l; |
|
| 763 | 763 | $ns++; |
| 764 | 764 | } |
| 765 | - $l+=$cw[$c]; |
|
| 766 | - if($l>$wmax) |
|
| 765 | + $l += $cw[$c]; |
|
| 766 | + if ($l > $wmax) |
|
| 767 | 767 | { |
| 768 | 768 | //Automatic line break |
| 769 | - if($sep==-1) |
|
| 769 | + if ($sep == -1) |
|
| 770 | 770 | { |
| 771 | - if($i==$j) |
|
| 771 | + if ($i == $j) |
|
| 772 | 772 | $i++; |
| 773 | - if($this->ws>0) |
|
| 773 | + if ($this->ws > 0) |
|
| 774 | 774 | { |
| 775 | - $this->ws=0; |
|
| 775 | + $this->ws = 0; |
|
| 776 | 776 | $this->_out('0 Tw'); |
| 777 | 777 | } |
| 778 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
| 778 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
| 779 | 779 | } |
| 780 | 780 | else |
| 781 | 781 | { |
| 782 | - if($align=='J') |
|
| 782 | + if ($align == 'J') |
|
| 783 | 783 | { |
| 784 | - $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; |
|
| 785 | - $this->_out(sprintf('%.3F Tw',$this->ws*$this->k)); |
|
| 784 | + $this->ws = ($ns > 1) ? ($wmax - $ls) / 1000 * $this->FontSize / ($ns - 1) : 0; |
|
| 785 | + $this->_out(sprintf('%.3F Tw', $this->ws * $this->k)); |
|
| 786 | 786 | } |
| 787 | - $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); |
|
| 788 | - $i=$sep+1; |
|
| 787 | + $this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill); |
|
| 788 | + $i = $sep + 1; |
|
| 789 | 789 | } |
| 790 | - $sep=-1; |
|
| 791 | - $j=$i; |
|
| 792 | - $l=0; |
|
| 793 | - $ns=0; |
|
| 790 | + $sep = -1; |
|
| 791 | + $j = $i; |
|
| 792 | + $l = 0; |
|
| 793 | + $ns = 0; |
|
| 794 | 794 | $nl++; |
| 795 | - if($border && $nl==2) |
|
| 796 | - $b=$b2; |
|
| 795 | + if ($border && $nl == 2) |
|
| 796 | + $b = $b2; |
|
| 797 | 797 | } |
| 798 | 798 | else |
| 799 | 799 | $i++; |
| 800 | 800 | } |
| 801 | 801 | //Last chunk |
| 802 | - if($this->ws>0) |
|
| 802 | + if ($this->ws > 0) |
|
| 803 | 803 | { |
| 804 | - $this->ws=0; |
|
| 804 | + $this->ws = 0; |
|
| 805 | 805 | $this->_out('0 Tw'); |
| 806 | 806 | } |
| 807 | - if($border && strpos($border,'B')!==false) |
|
| 808 | - $b.='B'; |
|
| 809 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
| 810 | - $this->x=$this->lMargin; |
|
| 807 | + if ($border && strpos($border, 'B') !== false) |
|
| 808 | + $b .= 'B'; |
|
| 809 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
| 810 | + $this->x = $this->lMargin; |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | -function Write($h, $txt, $link='') |
|
| 813 | +function Write($h, $txt, $link = '') |
|
| 814 | 814 | { |
| 815 | 815 | //Output text in flowing mode |
| 816 | - $cw=&$this->CurrentFont['cw']; |
|
| 817 | - $w=$this->w-$this->rMargin-$this->x; |
|
| 818 | - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
| 819 | - $s=str_replace("\r",'',$txt); |
|
| 820 | - $nb=strlen($s); |
|
| 821 | - $sep=-1; |
|
| 822 | - $i=0; |
|
| 823 | - $j=0; |
|
| 824 | - $l=0; |
|
| 825 | - $nl=1; |
|
| 826 | - while($i<$nb) |
|
| 816 | + $cw = &$this->CurrentFont['cw']; |
|
| 817 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 818 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
| 819 | + $s = str_replace("\r", '', $txt); |
|
| 820 | + $nb = strlen($s); |
|
| 821 | + $sep = -1; |
|
| 822 | + $i = 0; |
|
| 823 | + $j = 0; |
|
| 824 | + $l = 0; |
|
| 825 | + $nl = 1; |
|
| 826 | + while ($i < $nb) |
|
| 827 | 827 | { |
| 828 | 828 | //Get next character |
| 829 | - $c=$s[$i]; |
|
| 830 | - if($c=="\n") |
|
| 829 | + $c = $s[$i]; |
|
| 830 | + if ($c == "\n") |
|
| 831 | 831 | { |
| 832 | 832 | //Explicit line break |
| 833 | - $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
|
| 833 | + $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link); |
|
| 834 | 834 | $i++; |
| 835 | - $sep=-1; |
|
| 836 | - $j=$i; |
|
| 837 | - $l=0; |
|
| 838 | - if($nl==1) |
|
| 835 | + $sep = -1; |
|
| 836 | + $j = $i; |
|
| 837 | + $l = 0; |
|
| 838 | + if ($nl == 1) |
|
| 839 | 839 | { |
| 840 | - $this->x=$this->lMargin; |
|
| 841 | - $w=$this->w-$this->rMargin-$this->x; |
|
| 842 | - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
| 840 | + $this->x = $this->lMargin; |
|
| 841 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 842 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
| 843 | 843 | } |
| 844 | 844 | $nl++; |
| 845 | 845 | continue; |
| 846 | 846 | } |
| 847 | - if($c==' ') |
|
| 848 | - $sep=$i; |
|
| 849 | - $l+=$cw[$c]; |
|
| 850 | - if($l>$wmax) |
|
| 847 | + if ($c == ' ') |
|
| 848 | + $sep = $i; |
|
| 849 | + $l += $cw[$c]; |
|
| 850 | + if ($l > $wmax) |
|
| 851 | 851 | { |
| 852 | 852 | //Automatic line break |
| 853 | - if($sep==-1) |
|
| 853 | + if ($sep == -1) |
|
| 854 | 854 | { |
| 855 | - if($this->x>$this->lMargin) |
|
| 855 | + if ($this->x > $this->lMargin) |
|
| 856 | 856 | { |
| 857 | 857 | //Move to next line |
| 858 | - $this->x=$this->lMargin; |
|
| 859 | - $this->y+=$h; |
|
| 860 | - $w=$this->w-$this->rMargin-$this->x; |
|
| 861 | - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
| 858 | + $this->x = $this->lMargin; |
|
| 859 | + $this->y += $h; |
|
| 860 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 861 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
| 862 | 862 | $i++; |
| 863 | 863 | $nl++; |
| 864 | 864 | continue; |
| 865 | 865 | } |
| 866 | - if($i==$j) |
|
| 866 | + if ($i == $j) |
|
| 867 | 867 | $i++; |
| 868 | - $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
|
| 868 | + $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link); |
|
| 869 | 869 | } |
| 870 | 870 | else |
| 871 | 871 | { |
| 872 | - $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); |
|
| 873 | - $i=$sep+1; |
|
| 872 | + $this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', 0, $link); |
|
| 873 | + $i = $sep + 1; |
|
| 874 | 874 | } |
| 875 | - $sep=-1; |
|
| 876 | - $j=$i; |
|
| 877 | - $l=0; |
|
| 878 | - if($nl==1) |
|
| 875 | + $sep = -1; |
|
| 876 | + $j = $i; |
|
| 877 | + $l = 0; |
|
| 878 | + if ($nl == 1) |
|
| 879 | 879 | { |
| 880 | - $this->x=$this->lMargin; |
|
| 881 | - $w=$this->w-$this->rMargin-$this->x; |
|
| 882 | - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
| 880 | + $this->x = $this->lMargin; |
|
| 881 | + $w = $this->w - $this->rMargin - $this->x; |
|
| 882 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
| 883 | 883 | } |
| 884 | 884 | $nl++; |
| 885 | 885 | } |
@@ -887,74 +887,74 @@ discard block |
||
| 887 | 887 | $i++; |
| 888 | 888 | } |
| 889 | 889 | //Last chunk |
| 890 | - if($i!=$j) |
|
| 891 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); |
|
| 890 | + if ($i != $j) |
|
| 891 | + $this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', 0, $link); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | -function Ln($h=null) |
|
| 894 | +function Ln($h = null) |
|
| 895 | 895 | { |
| 896 | 896 | //Line feed; default value is last cell height |
| 897 | - $this->x=$this->lMargin; |
|
| 898 | - if($h===null) |
|
| 899 | - $this->y+=$this->lasth; |
|
| 897 | + $this->x = $this->lMargin; |
|
| 898 | + if ($h === null) |
|
| 899 | + $this->y += $this->lasth; |
|
| 900 | 900 | else |
| 901 | - $this->y+=$h; |
|
| 901 | + $this->y += $h; |
|
| 902 | 902 | } |
| 903 | 903 | |
| 904 | -function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') |
|
| 904 | +function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '') |
|
| 905 | 905 | { |
| 906 | 906 | //Put an image on the page |
| 907 | - if(!isset($this->images[$file])) |
|
| 907 | + if (!isset($this->images[$file])) |
|
| 908 | 908 | { |
| 909 | 909 | //First use of this image, get info |
| 910 | - if($type=='') |
|
| 910 | + if ($type == '') |
|
| 911 | 911 | { |
| 912 | - $pos=strrpos($file,'.'); |
|
| 913 | - if(!$pos) |
|
| 914 | - $this->Error('Image file has no extension and no type was specified: '.$file); |
|
| 915 | - $type=substr($file,$pos+1); |
|
| 912 | + $pos = strrpos($file, '.'); |
|
| 913 | + if (!$pos) |
|
| 914 | + $this->Error('Image file has no extension and no type was specified: ' . $file); |
|
| 915 | + $type = substr($file, $pos + 1); |
|
| 916 | 916 | } |
| 917 | - $type=strtolower($type); |
|
| 918 | - if($type=='jpeg') |
|
| 919 | - $type='jpg'; |
|
| 920 | - $mtd='_parse'.$type; |
|
| 921 | - if(!method_exists($this,$mtd)) |
|
| 922 | - $this->Error('Unsupported image type: '.$type); |
|
| 923 | - $info=$this->$mtd($file); |
|
| 924 | - $info['i']=count($this->images)+1; |
|
| 925 | - $this->images[$file]=$info; |
|
| 917 | + $type = strtolower($type); |
|
| 918 | + if ($type == 'jpeg') |
|
| 919 | + $type = 'jpg'; |
|
| 920 | + $mtd = '_parse' . $type; |
|
| 921 | + if (!method_exists($this, $mtd)) |
|
| 922 | + $this->Error('Unsupported image type: ' . $type); |
|
| 923 | + $info = $this->$mtd($file); |
|
| 924 | + $info['i'] = count($this->images) + 1; |
|
| 925 | + $this->images[$file] = $info; |
|
| 926 | 926 | } |
| 927 | 927 | else |
| 928 | - $info=$this->images[$file]; |
|
| 928 | + $info = $this->images[$file]; |
|
| 929 | 929 | //Automatic width and height calculation if needed |
| 930 | - if($w==0 && $h==0) |
|
| 930 | + if ($w == 0 && $h == 0) |
|
| 931 | 931 | { |
| 932 | 932 | //Put image at 72 dpi |
| 933 | - $w=$info['w']/$this->k; |
|
| 934 | - $h=$info['h']/$this->k; |
|
| 933 | + $w = $info['w'] / $this->k; |
|
| 934 | + $h = $info['h'] / $this->k; |
|
| 935 | 935 | } |
| 936 | - elseif($w==0) |
|
| 937 | - $w=$h*$info['w']/$info['h']; |
|
| 938 | - elseif($h==0) |
|
| 939 | - $h=$w*$info['h']/$info['w']; |
|
| 936 | + elseif ($w == 0) |
|
| 937 | + $w = $h * $info['w'] / $info['h']; |
|
| 938 | + elseif ($h == 0) |
|
| 939 | + $h = $w * $info['h'] / $info['w']; |
|
| 940 | 940 | //Flowing mode |
| 941 | - if($y===null) |
|
| 941 | + if ($y === null) |
|
| 942 | 942 | { |
| 943 | - if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
| 943 | + if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
| 944 | 944 | { |
| 945 | 945 | //Automatic page break |
| 946 | - $x2=$this->x; |
|
| 947 | - $this->AddPage($this->CurOrientation,$this->CurPageFormat); |
|
| 948 | - $this->x=$x2; |
|
| 946 | + $x2 = $this->x; |
|
| 947 | + $this->AddPage($this->CurOrientation, $this->CurPageFormat); |
|
| 948 | + $this->x = $x2; |
|
| 949 | 949 | } |
| 950 | - $y=$this->y; |
|
| 951 | - $this->y+=$h; |
|
| 950 | + $y = $this->y; |
|
| 951 | + $this->y += $h; |
|
| 952 | 952 | } |
| 953 | - if($x===null) |
|
| 954 | - $x=$this->x; |
|
| 955 | - $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i'])); |
|
| 956 | - if($link) |
|
| 957 | - $this->Link($x,$y,$w,$h,$link); |
|
| 953 | + if ($x === null) |
|
| 954 | + $x = $this->x; |
|
| 955 | + $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q', $w * $this->k, $h * $this->k, $x * $this->k, ($this->h - ($y + $h)) * $this->k, $info['i'])); |
|
| 956 | + if ($link) |
|
| 957 | + $this->Link($x, $y, $w, $h, $link); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | function GetX() |
@@ -966,10 +966,10 @@ discard block |
||
| 966 | 966 | function SetX($x) |
| 967 | 967 | { |
| 968 | 968 | //Set x position |
| 969 | - if($x>=0) |
|
| 970 | - $this->x=$x; |
|
| 969 | + if ($x >= 0) |
|
| 970 | + $this->x = $x; |
|
| 971 | 971 | else |
| 972 | - $this->x=$this->w+$x; |
|
| 972 | + $this->x = $this->w + $x; |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | function GetY() |
@@ -981,11 +981,11 @@ discard block |
||
| 981 | 981 | function SetY($y) |
| 982 | 982 | { |
| 983 | 983 | //Set y position and reset x |
| 984 | - $this->x=$this->lMargin; |
|
| 985 | - if($y>=0) |
|
| 986 | - $this->y=$y; |
|
| 984 | + $this->x = $this->lMargin; |
|
| 985 | + if ($y >= 0) |
|
| 986 | + $this->y = $y; |
|
| 987 | 987 | else |
| 988 | - $this->y=$this->h+$y; |
|
| 988 | + $this->y = $this->h + $y; |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | function SetXY($x, $y) |
@@ -995,69 +995,69 @@ discard block |
||
| 995 | 995 | $this->SetX($x); |
| 996 | 996 | } |
| 997 | 997 | |
| 998 | -function Output($name='', $dest='') |
|
| 998 | +function Output($name = '', $dest = '') |
|
| 999 | 999 | { |
| 1000 | 1000 | //Output PDF to some destination |
| 1001 | - if($this->state<3) |
|
| 1001 | + if ($this->state < 3) |
|
| 1002 | 1002 | $this->Close(); |
| 1003 | - $dest=strtoupper($dest); |
|
| 1004 | - if($dest=='') |
|
| 1003 | + $dest = strtoupper($dest); |
|
| 1004 | + if ($dest == '') |
|
| 1005 | 1005 | { |
| 1006 | - if($name=='') |
|
| 1006 | + if ($name == '') |
|
| 1007 | 1007 | { |
| 1008 | - $name='doc.pdf'; |
|
| 1009 | - $dest='I'; |
|
| 1008 | + $name = 'doc.pdf'; |
|
| 1009 | + $dest = 'I'; |
|
| 1010 | 1010 | } |
| 1011 | 1011 | else |
| 1012 | - $dest='F'; |
|
| 1012 | + $dest = 'F'; |
|
| 1013 | 1013 | } |
| 1014 | - switch($dest) |
|
| 1014 | + switch ($dest) |
|
| 1015 | 1015 | { |
| 1016 | 1016 | case 'I': |
| 1017 | 1017 | //Send to standard output |
| 1018 | - if(ob_get_length()) |
|
| 1018 | + if (ob_get_length()) |
|
| 1019 | 1019 | $this->Error('Some data has already been output, can\'t send PDF file'); |
| 1020 | - if(php_sapi_name()!='cli') |
|
| 1020 | + if (php_sapi_name() != 'cli') |
|
| 1021 | 1021 | { |
| 1022 | 1022 | //We send to a browser |
| 1023 | 1023 | header('Content-Type: application/pdf'); |
| 1024 | - if(headers_sent()) |
|
| 1024 | + if (headers_sent()) |
|
| 1025 | 1025 | $this->Error('Some data has already been output, can\'t send PDF file'); |
| 1026 | - header('Content-Length: '.strlen($this->buffer)); |
|
| 1027 | - header('Content-Disposition: inline; filename="'.$name.'"'); |
|
| 1026 | + header('Content-Length: ' . strlen($this->buffer)); |
|
| 1027 | + header('Content-Disposition: inline; filename="' . $name . '"'); |
|
| 1028 | 1028 | header('Cache-Control: private, max-age=0, must-revalidate'); |
| 1029 | 1029 | header('Pragma: public'); |
| 1030 | - ini_set('zlib.output_compression','0'); |
|
| 1030 | + ini_set('zlib.output_compression', '0'); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | echo $this->buffer; |
| 1033 | 1033 | break; |
| 1034 | 1034 | case 'D': |
| 1035 | 1035 | //Download file |
| 1036 | - if(ob_get_length()) |
|
| 1036 | + if (ob_get_length()) |
|
| 1037 | 1037 | $this->Error('Some data has already been output, can\'t send PDF file'); |
| 1038 | 1038 | header('Content-Type: application/x-download'); |
| 1039 | - if(headers_sent()) |
|
| 1039 | + if (headers_sent()) |
|
| 1040 | 1040 | $this->Error('Some data has already been output, can\'t send PDF file'); |
| 1041 | - header('Content-Length: '.strlen($this->buffer)); |
|
| 1042 | - header('Content-Disposition: attachment; filename="'.$name.'"'); |
|
| 1041 | + header('Content-Length: ' . strlen($this->buffer)); |
|
| 1042 | + header('Content-Disposition: attachment; filename="' . $name . '"'); |
|
| 1043 | 1043 | header('Cache-Control: private, max-age=0, must-revalidate'); |
| 1044 | 1044 | header('Pragma: public'); |
| 1045 | - ini_set('zlib.output_compression','0'); |
|
| 1045 | + ini_set('zlib.output_compression', '0'); |
|
| 1046 | 1046 | echo $this->buffer; |
| 1047 | 1047 | break; |
| 1048 | 1048 | case 'F': |
| 1049 | 1049 | //Save to local file |
| 1050 | - $f=fopen($name,'wb'); |
|
| 1051 | - if(!$f) |
|
| 1052 | - $this->Error('Unable to create output file: '.$name); |
|
| 1053 | - fwrite($f,$this->buffer,strlen($this->buffer)); |
|
| 1050 | + $f = fopen($name, 'wb'); |
|
| 1051 | + if (!$f) |
|
| 1052 | + $this->Error('Unable to create output file: ' . $name); |
|
| 1053 | + fwrite($f, $this->buffer, strlen($this->buffer)); |
|
| 1054 | 1054 | fclose($f); |
| 1055 | 1055 | break; |
| 1056 | 1056 | case 'S': |
| 1057 | 1057 | //Return as a string |
| 1058 | 1058 | return $this->buffer; |
| 1059 | 1059 | default: |
| 1060 | - $this->Error('Incorrect output destination: '.$dest); |
|
| 1060 | + $this->Error('Incorrect output destination: ' . $dest); |
|
| 1061 | 1061 | } |
| 1062 | 1062 | return ''; |
| 1063 | 1063 | } |
@@ -1070,124 +1070,124 @@ discard block |
||
| 1070 | 1070 | function _dochecks() |
| 1071 | 1071 | { |
| 1072 | 1072 | //Check availability of %F |
| 1073 | - if(sprintf('%.1F',1.0)!='1.0') |
|
| 1073 | + if (sprintf('%.1F', 1.0) != '1.0') |
|
| 1074 | 1074 | $this->Error('This version of PHP is not supported'); |
| 1075 | 1075 | //Check mbstring overloading |
| 1076 | - if(ini_get('mbstring.func_overload') & 2) |
|
| 1076 | + if (ini_get('mbstring.func_overload') & 2) |
|
| 1077 | 1077 | $this->Error('mbstring overloading must be disabled'); |
| 1078 | 1078 | //Disable runtime magic quotes |
| 1079 | - if(get_magic_quotes_runtime()) |
|
| 1079 | + if (get_magic_quotes_runtime()) |
|
| 1080 | 1080 | @set_magic_quotes_runtime(0); |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | function _getpageformat($format) |
| 1084 | 1084 | { |
| 1085 | - $format=strtolower($format); |
|
| 1086 | - if(!isset($this->PageFormats[$format])) |
|
| 1087 | - $this->Error('Unknown page format: '.$format); |
|
| 1088 | - $a=$this->PageFormats[$format]; |
|
| 1089 | - return array($a[0]/$this->k, $a[1]/$this->k); |
|
| 1085 | + $format = strtolower($format); |
|
| 1086 | + if (!isset($this->PageFormats[$format])) |
|
| 1087 | + $this->Error('Unknown page format: ' . $format); |
|
| 1088 | + $a = $this->PageFormats[$format]; |
|
| 1089 | + return array($a[0] / $this->k, $a[1] / $this->k); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | function _getfontpath() |
| 1093 | 1093 | { |
| 1094 | - if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) |
|
| 1095 | - define('FPDF_FONTPATH',dirname(__FILE__).'/font/'); |
|
| 1094 | + if (!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__) . '/font')) |
|
| 1095 | + define('FPDF_FONTPATH', dirname(__FILE__) . '/font/'); |
|
| 1096 | 1096 | return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : ''; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | 1099 | function _beginpage($orientation, $format) |
| 1100 | 1100 | { |
| 1101 | 1101 | $this->page++; |
| 1102 | - $this->pages[$this->page]=''; |
|
| 1103 | - $this->state=2; |
|
| 1104 | - $this->x=$this->lMargin; |
|
| 1105 | - $this->y=$this->tMargin; |
|
| 1106 | - $this->FontFamily=''; |
|
| 1102 | + $this->pages[$this->page] = ''; |
|
| 1103 | + $this->state = 2; |
|
| 1104 | + $this->x = $this->lMargin; |
|
| 1105 | + $this->y = $this->tMargin; |
|
| 1106 | + $this->FontFamily = ''; |
|
| 1107 | 1107 | //Check page size |
| 1108 | - if($orientation=='') |
|
| 1109 | - $orientation=$this->DefOrientation; |
|
| 1108 | + if ($orientation == '') |
|
| 1109 | + $orientation = $this->DefOrientation; |
|
| 1110 | 1110 | else |
| 1111 | - $orientation=strtoupper($orientation[0]); |
|
| 1112 | - if($format=='') |
|
| 1113 | - $format=$this->DefPageFormat; |
|
| 1111 | + $orientation = strtoupper($orientation[0]); |
|
| 1112 | + if ($format == '') |
|
| 1113 | + $format = $this->DefPageFormat; |
|
| 1114 | 1114 | else |
| 1115 | 1115 | { |
| 1116 | - if(is_string($format)) |
|
| 1117 | - $format=$this->_getpageformat($format); |
|
| 1116 | + if (is_string($format)) |
|
| 1117 | + $format = $this->_getpageformat($format); |
|
| 1118 | 1118 | } |
| 1119 | - if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) |
|
| 1119 | + if ($orientation != $this->CurOrientation || $format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1]) |
|
| 1120 | 1120 | { |
| 1121 | 1121 | //New size |
| 1122 | - if($orientation=='P') |
|
| 1122 | + if ($orientation == 'P') |
|
| 1123 | 1123 | { |
| 1124 | - $this->w=$format[0]; |
|
| 1125 | - $this->h=$format[1]; |
|
| 1124 | + $this->w = $format[0]; |
|
| 1125 | + $this->h = $format[1]; |
|
| 1126 | 1126 | } |
| 1127 | 1127 | else |
| 1128 | 1128 | { |
| 1129 | - $this->w=$format[1]; |
|
| 1130 | - $this->h=$format[0]; |
|
| 1129 | + $this->w = $format[1]; |
|
| 1130 | + $this->h = $format[0]; |
|
| 1131 | 1131 | } |
| 1132 | - $this->wPt=$this->w*$this->k; |
|
| 1133 | - $this->hPt=$this->h*$this->k; |
|
| 1134 | - $this->PageBreakTrigger=$this->h-$this->bMargin; |
|
| 1135 | - $this->CurOrientation=$orientation; |
|
| 1136 | - $this->CurPageFormat=$format; |
|
| 1132 | + $this->wPt = $this->w * $this->k; |
|
| 1133 | + $this->hPt = $this->h * $this->k; |
|
| 1134 | + $this->PageBreakTrigger = $this->h - $this->bMargin; |
|
| 1135 | + $this->CurOrientation = $orientation; |
|
| 1136 | + $this->CurPageFormat = $format; |
|
| 1137 | 1137 | } |
| 1138 | - if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) |
|
| 1139 | - $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); |
|
| 1138 | + if ($orientation != $this->DefOrientation || $format[0] != $this->DefPageFormat[0] || $format[1] != $this->DefPageFormat[1]) |
|
| 1139 | + $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | 1142 | function _endpage() |
| 1143 | 1143 | { |
| 1144 | - $this->state=1; |
|
| 1144 | + $this->state = 1; |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | function _escape($s) |
| 1148 | 1148 | { |
| 1149 | 1149 | //Escape special characters in strings |
| 1150 | - $s=str_replace('\\','\\\\',$s); |
|
| 1151 | - $s=str_replace('(','\\(',$s); |
|
| 1152 | - $s=str_replace(')','\\)',$s); |
|
| 1153 | - $s=str_replace("\r",'\\r',$s); |
|
| 1150 | + $s = str_replace('\\', '\\\\', $s); |
|
| 1151 | + $s = str_replace('(', '\\(', $s); |
|
| 1152 | + $s = str_replace(')', '\\)', $s); |
|
| 1153 | + $s = str_replace("\r", '\\r', $s); |
|
| 1154 | 1154 | return $s; |
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | function _textstring($s) |
| 1158 | 1158 | { |
| 1159 | 1159 | //Format a text string |
| 1160 | - return '('.$this->_escape($s).')'; |
|
| 1160 | + return '(' . $this->_escape($s) . ')'; |
|
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | function _UTF8toUTF16($s) |
| 1164 | 1164 | { |
| 1165 | 1165 | //Convert UTF-8 to UTF-16BE with BOM |
| 1166 | - $res="\xFE\xFF"; |
|
| 1167 | - $nb=strlen($s); |
|
| 1168 | - $i=0; |
|
| 1169 | - while($i<$nb) |
|
| 1166 | + $res = "\xFE\xFF"; |
|
| 1167 | + $nb = strlen($s); |
|
| 1168 | + $i = 0; |
|
| 1169 | + while ($i < $nb) |
|
| 1170 | 1170 | { |
| 1171 | - $c1=ord($s[$i++]); |
|
| 1172 | - if($c1>=224) |
|
| 1171 | + $c1 = ord($s[$i++]); |
|
| 1172 | + if ($c1 >= 224) |
|
| 1173 | 1173 | { |
| 1174 | 1174 | //3-byte character |
| 1175 | - $c2=ord($s[$i++]); |
|
| 1176 | - $c3=ord($s[$i++]); |
|
| 1177 | - $res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
|
| 1178 | - $res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
|
| 1175 | + $c2 = ord($s[$i++]); |
|
| 1176 | + $c3 = ord($s[$i++]); |
|
| 1177 | + $res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2)); |
|
| 1178 | + $res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F)); |
|
| 1179 | 1179 | } |
| 1180 | - elseif($c1>=192) |
|
| 1180 | + elseif ($c1 >= 192) |
|
| 1181 | 1181 | { |
| 1182 | 1182 | //2-byte character |
| 1183 | - $c2=ord($s[$i++]); |
|
| 1184 | - $res.=chr(($c1 & 0x1C)>>2); |
|
| 1185 | - $res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
|
| 1183 | + $c2 = ord($s[$i++]); |
|
| 1184 | + $res .= chr(($c1 & 0x1C) >> 2); |
|
| 1185 | + $res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F)); |
|
| 1186 | 1186 | } |
| 1187 | 1187 | else |
| 1188 | 1188 | { |
| 1189 | 1189 | //Single-byte character |
| 1190 | - $res.="\0".chr($c1); |
|
| 1190 | + $res .= "\0" . chr($c1); |
|
| 1191 | 1191 | } |
| 1192 | 1192 | } |
| 1193 | 1193 | return $res; |
@@ -1196,32 +1196,32 @@ discard block |
||
| 1196 | 1196 | function _dounderline($x, $y, $txt) |
| 1197 | 1197 | { |
| 1198 | 1198 | //Underline text |
| 1199 | - $up=$this->CurrentFont['up']; |
|
| 1200 | - $ut=$this->CurrentFont['ut']; |
|
| 1201 | - $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); |
|
| 1202 | - return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt); |
|
| 1199 | + $up = $this->CurrentFont['up']; |
|
| 1200 | + $ut = $this->CurrentFont['ut']; |
|
| 1201 | + $w = $this->GetStringWidth($txt) + $this->ws * substr_count($txt, ' '); |
|
| 1202 | + return sprintf('%.2F %.2F %.2F %.2F re f', $x * $this->k, ($this->h - ($y - $up / 1000 * $this->FontSize)) * $this->k, $w * $this->k, -$ut / 1000 * $this->FontSizePt); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | function _parsejpg($file) |
| 1206 | 1206 | { |
| 1207 | 1207 | //Extract info from a JPEG file |
| 1208 | - $a=GetImageSize($file); |
|
| 1209 | - if(!$a) |
|
| 1210 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1211 | - if($a[2]!=2) |
|
| 1212 | - $this->Error('Not a JPEG file: '.$file); |
|
| 1213 | - if(!isset($a['channels']) || $a['channels']==3) |
|
| 1214 | - $colspace='DeviceRGB'; |
|
| 1215 | - elseif($a['channels']==4) |
|
| 1216 | - $colspace='DeviceCMYK'; |
|
| 1208 | + $a = GetImageSize($file); |
|
| 1209 | + if (!$a) |
|
| 1210 | + $this->Error('Missing or incorrect image file: ' . $file); |
|
| 1211 | + if ($a[2] != 2) |
|
| 1212 | + $this->Error('Not a JPEG file: ' . $file); |
|
| 1213 | + if (!isset($a['channels']) || $a['channels'] == 3) |
|
| 1214 | + $colspace = 'DeviceRGB'; |
|
| 1215 | + elseif ($a['channels'] == 4) |
|
| 1216 | + $colspace = 'DeviceCMYK'; |
|
| 1217 | 1217 | else |
| 1218 | - $colspace='DeviceGray'; |
|
| 1219 | - $bpc=isset($a['bits']) ? $a['bits'] : 8; |
|
| 1218 | + $colspace = 'DeviceGray'; |
|
| 1219 | + $bpc = isset($a['bits']) ? $a['bits'] : 8; |
|
| 1220 | 1220 | //Read whole file |
| 1221 | - $f=fopen($file,'rb'); |
|
| 1222 | - $data=''; |
|
| 1223 | - while(!feof($f)) |
|
| 1224 | - $data.=fread($f,8192); |
|
| 1221 | + $f = fopen($file, 'rb'); |
|
| 1222 | + $data = ''; |
|
| 1223 | + while (!feof($f)) |
|
| 1224 | + $data .= fread($f, 8192); |
|
| 1225 | 1225 | fclose($f); |
| 1226 | 1226 | return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); |
| 1227 | 1227 | } |
@@ -1229,82 +1229,82 @@ discard block |
||
| 1229 | 1229 | function _parsepng($file) |
| 1230 | 1230 | { |
| 1231 | 1231 | //Extract info from a PNG file |
| 1232 | - $f=fopen($file,'rb'); |
|
| 1233 | - if(!$f) |
|
| 1234 | - $this->Error('Can\'t open image file: '.$file); |
|
| 1232 | + $f = fopen($file, 'rb'); |
|
| 1233 | + if (!$f) |
|
| 1234 | + $this->Error('Can\'t open image file: ' . $file); |
|
| 1235 | 1235 | //Check signature |
| 1236 | - if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
| 1237 | - $this->Error('Not a PNG file: '.$file); |
|
| 1236 | + if ($this->_readstream($f, 8) != chr(137) . 'PNG' . chr(13) . chr(10) . chr(26) . chr(10)) |
|
| 1237 | + $this->Error('Not a PNG file: ' . $file); |
|
| 1238 | 1238 | //Read header chunk |
| 1239 | - $this->_readstream($f,4); |
|
| 1240 | - if($this->_readstream($f,4)!='IHDR') |
|
| 1241 | - $this->Error('Incorrect PNG file: '.$file); |
|
| 1242 | - $w=$this->_readint($f); |
|
| 1243 | - $h=$this->_readint($f); |
|
| 1244 | - $bpc=ord($this->_readstream($f,1)); |
|
| 1245 | - if($bpc>8) |
|
| 1246 | - $this->Error('16-bit depth not supported: '.$file); |
|
| 1247 | - $ct=ord($this->_readstream($f,1)); |
|
| 1248 | - if($ct==0) |
|
| 1249 | - $colspace='DeviceGray'; |
|
| 1250 | - elseif($ct==2) |
|
| 1251 | - $colspace='DeviceRGB'; |
|
| 1252 | - elseif($ct==3) |
|
| 1253 | - $colspace='Indexed'; |
|
| 1239 | + $this->_readstream($f, 4); |
|
| 1240 | + if ($this->_readstream($f, 4) != 'IHDR') |
|
| 1241 | + $this->Error('Incorrect PNG file: ' . $file); |
|
| 1242 | + $w = $this->_readint($f); |
|
| 1243 | + $h = $this->_readint($f); |
|
| 1244 | + $bpc = ord($this->_readstream($f, 1)); |
|
| 1245 | + if ($bpc > 8) |
|
| 1246 | + $this->Error('16-bit depth not supported: ' . $file); |
|
| 1247 | + $ct = ord($this->_readstream($f, 1)); |
|
| 1248 | + if ($ct == 0) |
|
| 1249 | + $colspace = 'DeviceGray'; |
|
| 1250 | + elseif ($ct == 2) |
|
| 1251 | + $colspace = 'DeviceRGB'; |
|
| 1252 | + elseif ($ct == 3) |
|
| 1253 | + $colspace = 'Indexed'; |
|
| 1254 | 1254 | else |
| 1255 | - $this->Error('Alpha channel not supported: '.$file); |
|
| 1256 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1257 | - $this->Error('Unknown compression method: '.$file); |
|
| 1258 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1259 | - $this->Error('Unknown filter method: '.$file); |
|
| 1260 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1261 | - $this->Error('Interlacing not supported: '.$file); |
|
| 1262 | - $this->_readstream($f,4); |
|
| 1263 | - $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>'; |
|
| 1255 | + $this->Error('Alpha channel not supported: ' . $file); |
|
| 1256 | + if (ord($this->_readstream($f, 1)) != 0) |
|
| 1257 | + $this->Error('Unknown compression method: ' . $file); |
|
| 1258 | + if (ord($this->_readstream($f, 1)) != 0) |
|
| 1259 | + $this->Error('Unknown filter method: ' . $file); |
|
| 1260 | + if (ord($this->_readstream($f, 1)) != 0) |
|
| 1261 | + $this->Error('Interlacing not supported: ' . $file); |
|
| 1262 | + $this->_readstream($f, 4); |
|
| 1263 | + $parms = '/DecodeParms <</Predictor 15 /Colors ' . ($ct == 2 ? 3 : 1) . ' /BitsPerComponent ' . $bpc . ' /Columns ' . $w . '>>'; |
|
| 1264 | 1264 | //Scan chunks looking for palette, transparency and image data |
| 1265 | - $pal=''; |
|
| 1266 | - $trns=''; |
|
| 1267 | - $data=''; |
|
| 1265 | + $pal = ''; |
|
| 1266 | + $trns = ''; |
|
| 1267 | + $data = ''; |
|
| 1268 | 1268 | do |
| 1269 | 1269 | { |
| 1270 | - $n=$this->_readint($f); |
|
| 1271 | - $type=$this->_readstream($f,4); |
|
| 1272 | - if($type=='PLTE') |
|
| 1270 | + $n = $this->_readint($f); |
|
| 1271 | + $type = $this->_readstream($f, 4); |
|
| 1272 | + if ($type == 'PLTE') |
|
| 1273 | 1273 | { |
| 1274 | 1274 | //Read palette |
| 1275 | - $pal=$this->_readstream($f,$n); |
|
| 1276 | - $this->_readstream($f,4); |
|
| 1275 | + $pal = $this->_readstream($f, $n); |
|
| 1276 | + $this->_readstream($f, 4); |
|
| 1277 | 1277 | } |
| 1278 | - elseif($type=='tRNS') |
|
| 1278 | + elseif ($type == 'tRNS') |
|
| 1279 | 1279 | { |
| 1280 | 1280 | //Read transparency info |
| 1281 | - $t=$this->_readstream($f,$n); |
|
| 1282 | - if($ct==0) |
|
| 1283 | - $trns=array(ord(substr($t,1,1))); |
|
| 1284 | - elseif($ct==2) |
|
| 1285 | - $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1281 | + $t = $this->_readstream($f, $n); |
|
| 1282 | + if ($ct == 0) |
|
| 1283 | + $trns = array(ord(substr($t, 1, 1))); |
|
| 1284 | + elseif ($ct == 2) |
|
| 1285 | + $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1))); |
|
| 1286 | 1286 | else |
| 1287 | 1287 | { |
| 1288 | - $pos=strpos($t,chr(0)); |
|
| 1289 | - if($pos!==false) |
|
| 1290 | - $trns=array($pos); |
|
| 1288 | + $pos = strpos($t, chr(0)); |
|
| 1289 | + if ($pos !== false) |
|
| 1290 | + $trns = array($pos); |
|
| 1291 | 1291 | } |
| 1292 | - $this->_readstream($f,4); |
|
| 1292 | + $this->_readstream($f, 4); |
|
| 1293 | 1293 | } |
| 1294 | - elseif($type=='IDAT') |
|
| 1294 | + elseif ($type == 'IDAT') |
|
| 1295 | 1295 | { |
| 1296 | 1296 | //Read image data block |
| 1297 | - $data.=$this->_readstream($f,$n); |
|
| 1298 | - $this->_readstream($f,4); |
|
| 1297 | + $data .= $this->_readstream($f, $n); |
|
| 1298 | + $this->_readstream($f, 4); |
|
| 1299 | 1299 | } |
| 1300 | - elseif($type=='IEND') |
|
| 1300 | + elseif ($type == 'IEND') |
|
| 1301 | 1301 | break; |
| 1302 | 1302 | else |
| 1303 | - $this->_readstream($f,$n+4); |
|
| 1303 | + $this->_readstream($f, $n + 4); |
|
| 1304 | 1304 | } |
| 1305 | - while($n); |
|
| 1306 | - if($colspace=='Indexed' && empty($pal)) |
|
| 1307 | - $this->Error('Missing palette in '.$file); |
|
| 1305 | + while ($n); |
|
| 1306 | + if ($colspace == 'Indexed' && empty($pal)) |
|
| 1307 | + $this->Error('Missing palette in ' . $file); |
|
| 1308 | 1308 | fclose($f); |
| 1309 | 1309 | return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data); |
| 1310 | 1310 | } |
@@ -1312,16 +1312,16 @@ discard block |
||
| 1312 | 1312 | function _readstream($f, $n) |
| 1313 | 1313 | { |
| 1314 | 1314 | //Read n bytes from stream |
| 1315 | - $res=''; |
|
| 1316 | - while($n>0 && !feof($f)) |
|
| 1315 | + $res = ''; |
|
| 1316 | + while ($n > 0 && !feof($f)) |
|
| 1317 | 1317 | { |
| 1318 | - $s=fread($f,$n); |
|
| 1319 | - if($s===false) |
|
| 1318 | + $s = fread($f, $n); |
|
| 1319 | + if ($s === false) |
|
| 1320 | 1320 | $this->Error('Error while reading stream'); |
| 1321 | - $n-=strlen($s); |
|
| 1322 | - $res.=$s; |
|
| 1321 | + $n -= strlen($s); |
|
| 1322 | + $res .= $s; |
|
| 1323 | 1323 | } |
| 1324 | - if($n>0) |
|
| 1324 | + if ($n > 0) |
|
| 1325 | 1325 | $this->Error('Unexpected end of stream'); |
| 1326 | 1326 | return $res; |
| 1327 | 1327 | } |
@@ -1329,28 +1329,28 @@ discard block |
||
| 1329 | 1329 | function _readint($f) |
| 1330 | 1330 | { |
| 1331 | 1331 | //Read a 4-byte integer from stream |
| 1332 | - $a=unpack('Ni',$this->_readstream($f,4)); |
|
| 1332 | + $a = unpack('Ni', $this->_readstream($f, 4)); |
|
| 1333 | 1333 | return $a['i']; |
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | function _parsegif($file) |
| 1337 | 1337 | { |
| 1338 | 1338 | //Extract info from a GIF file (via PNG conversion) |
| 1339 | - if(!function_exists('imagepng')) |
|
| 1339 | + if (!function_exists('imagepng')) |
|
| 1340 | 1340 | $this->Error('GD extension is required for GIF support'); |
| 1341 | - if(!function_exists('imagecreatefromgif')) |
|
| 1341 | + if (!function_exists('imagecreatefromgif')) |
|
| 1342 | 1342 | $this->Error('GD has no GIF read support'); |
| 1343 | - $im=imagecreatefromgif($file); |
|
| 1344 | - if(!$im) |
|
| 1345 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1346 | - imageinterlace($im,0); |
|
| 1347 | - $tmp=tempnam('.','gif'); |
|
| 1348 | - if(!$tmp) |
|
| 1343 | + $im = imagecreatefromgif($file); |
|
| 1344 | + if (!$im) |
|
| 1345 | + $this->Error('Missing or incorrect image file: ' . $file); |
|
| 1346 | + imageinterlace($im, 0); |
|
| 1347 | + $tmp = tempnam('.', 'gif'); |
|
| 1348 | + if (!$tmp) |
|
| 1349 | 1349 | $this->Error('Unable to create a temporary file'); |
| 1350 | - if(!imagepng($im,$tmp)) |
|
| 1350 | + if (!imagepng($im, $tmp)) |
|
| 1351 | 1351 | $this->Error('Error while saving to temporary file'); |
| 1352 | 1352 | imagedestroy($im); |
| 1353 | - $info=$this->_parsepng($tmp); |
|
| 1353 | + $info = $this->_parsepng($tmp); |
|
| 1354 | 1354 | unlink($tmp); |
| 1355 | 1355 | return $info; |
| 1356 | 1356 | } |
@@ -1359,8 +1359,8 @@ discard block |
||
| 1359 | 1359 | { |
| 1360 | 1360 | //Begin a new object |
| 1361 | 1361 | $this->n++; |
| 1362 | - $this->offsets[$this->n]=strlen($this->buffer); |
|
| 1363 | - $this->_out($this->n.' 0 obj'); |
|
| 1362 | + $this->offsets[$this->n] = strlen($this->buffer); |
|
| 1363 | + $this->_out($this->n . ' 0 obj'); |
|
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | 1366 | function _putstream($s) |
@@ -1373,162 +1373,162 @@ discard block |
||
| 1373 | 1373 | function _out($s) |
| 1374 | 1374 | { |
| 1375 | 1375 | //Add a line to the document |
| 1376 | - if($this->state==2) |
|
| 1377 | - $this->pages[$this->page].=$s."\n"; |
|
| 1376 | + if ($this->state == 2) |
|
| 1377 | + $this->pages[$this->page] .= $s . "\n"; |
|
| 1378 | 1378 | else |
| 1379 | - $this->buffer.=$s."\n"; |
|
| 1379 | + $this->buffer .= $s . "\n"; |
|
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | 1382 | function _putpages() |
| 1383 | 1383 | { |
| 1384 | - $nb=$this->page; |
|
| 1385 | - if(!empty($this->AliasNbPages)) |
|
| 1384 | + $nb = $this->page; |
|
| 1385 | + if (!empty($this->AliasNbPages)) |
|
| 1386 | 1386 | { |
| 1387 | 1387 | //Replace number of pages |
| 1388 | - for($n=1;$n<=$nb;$n++) |
|
| 1389 | - $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]); |
|
| 1388 | + for ($n = 1; $n <= $nb; $n++) |
|
| 1389 | + $this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]); |
|
| 1390 | 1390 | } |
| 1391 | - if($this->DefOrientation=='P') |
|
| 1391 | + if ($this->DefOrientation == 'P') |
|
| 1392 | 1392 | { |
| 1393 | - $wPt=$this->DefPageFormat[0]*$this->k; |
|
| 1394 | - $hPt=$this->DefPageFormat[1]*$this->k; |
|
| 1393 | + $wPt = $this->DefPageFormat[0] * $this->k; |
|
| 1394 | + $hPt = $this->DefPageFormat[1] * $this->k; |
|
| 1395 | 1395 | } |
| 1396 | 1396 | else |
| 1397 | 1397 | { |
| 1398 | - $wPt=$this->DefPageFormat[1]*$this->k; |
|
| 1399 | - $hPt=$this->DefPageFormat[0]*$this->k; |
|
| 1398 | + $wPt = $this->DefPageFormat[1] * $this->k; |
|
| 1399 | + $hPt = $this->DefPageFormat[0] * $this->k; |
|
| 1400 | 1400 | } |
| 1401 | - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; |
|
| 1402 | - for($n=1;$n<=$nb;$n++) |
|
| 1401 | + $filter = ($this->compress) ? '/Filter /FlateDecode ' : ''; |
|
| 1402 | + for ($n = 1; $n <= $nb; $n++) |
|
| 1403 | 1403 | { |
| 1404 | 1404 | //Page |
| 1405 | 1405 | $this->_newobj(); |
| 1406 | 1406 | $this->_out('<</Type /Page'); |
| 1407 | 1407 | $this->_out('/Parent 1 0 R'); |
| 1408 | - if(isset($this->PageSizes[$n])) |
|
| 1409 | - $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); |
|
| 1408 | + if (isset($this->PageSizes[$n])) |
|
| 1409 | + $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1])); |
|
| 1410 | 1410 | $this->_out('/Resources 2 0 R'); |
| 1411 | - if(isset($this->PageLinks[$n])) |
|
| 1411 | + if (isset($this->PageLinks[$n])) |
|
| 1412 | 1412 | { |
| 1413 | 1413 | //Links |
| 1414 | - $annots='/Annots ['; |
|
| 1415 | - foreach($this->PageLinks[$n] as $pl) |
|
| 1414 | + $annots = '/Annots ['; |
|
| 1415 | + foreach ($this->PageLinks[$n] as $pl) |
|
| 1416 | 1416 | { |
| 1417 | - $rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); |
|
| 1418 | - $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
|
| 1419 | - if(is_string($pl[4])) |
|
| 1420 | - $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1417 | + $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]); |
|
| 1418 | + $annots .= '<</Type /Annot /Subtype /Link /Rect [' . $rect . '] /Border [0 0 0] '; |
|
| 1419 | + if (is_string($pl[4])) |
|
| 1420 | + $annots .= '/A <</S /URI /URI ' . $this->_textstring($pl[4]) . '>>>>'; |
|
| 1421 | 1421 | else |
| 1422 | 1422 | { |
| 1423 | - $l=$this->links[$pl[4]]; |
|
| 1424 | - $h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; |
|
| 1425 | - $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k); |
|
| 1423 | + $l = $this->links[$pl[4]]; |
|
| 1424 | + $h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; |
|
| 1425 | + $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', 1 + 2 * $l[0], $h - $l[1] * $this->k); |
|
| 1426 | 1426 | } |
| 1427 | 1427 | } |
| 1428 | - $this->_out($annots.']'); |
|
| 1428 | + $this->_out($annots . ']'); |
|
| 1429 | 1429 | } |
| 1430 | - $this->_out('/Contents '.($this->n+1).' 0 R>>'); |
|
| 1430 | + $this->_out('/Contents ' . ($this->n + 1) . ' 0 R>>'); |
|
| 1431 | 1431 | $this->_out('endobj'); |
| 1432 | 1432 | //Page content |
| 1433 | - $p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n]; |
|
| 1433 | + $p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n]; |
|
| 1434 | 1434 | $this->_newobj(); |
| 1435 | - $this->_out('<<'.$filter.'/Length '.strlen($p).'>>'); |
|
| 1435 | + $this->_out('<<' . $filter . '/Length ' . strlen($p) . '>>'); |
|
| 1436 | 1436 | $this->_putstream($p); |
| 1437 | 1437 | $this->_out('endobj'); |
| 1438 | 1438 | } |
| 1439 | 1439 | //Pages root |
| 1440 | - $this->offsets[1]=strlen($this->buffer); |
|
| 1440 | + $this->offsets[1] = strlen($this->buffer); |
|
| 1441 | 1441 | $this->_out('1 0 obj'); |
| 1442 | 1442 | $this->_out('<</Type /Pages'); |
| 1443 | - $kids='/Kids ['; |
|
| 1444 | - for($i=0;$i<$nb;$i++) |
|
| 1445 | - $kids.=(3+2*$i).' 0 R '; |
|
| 1446 | - $this->_out($kids.']'); |
|
| 1447 | - $this->_out('/Count '.$nb); |
|
| 1448 | - $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt)); |
|
| 1443 | + $kids = '/Kids ['; |
|
| 1444 | + for ($i = 0; $i < $nb; $i++) |
|
| 1445 | + $kids .= (3 + 2 * $i) . ' 0 R '; |
|
| 1446 | + $this->_out($kids . ']'); |
|
| 1447 | + $this->_out('/Count ' . $nb); |
|
| 1448 | + $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $wPt, $hPt)); |
|
| 1449 | 1449 | $this->_out('>>'); |
| 1450 | 1450 | $this->_out('endobj'); |
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | function _putfonts() |
| 1454 | 1454 | { |
| 1455 | - $nf=$this->n; |
|
| 1456 | - foreach($this->diffs as $diff) |
|
| 1455 | + $nf = $this->n; |
|
| 1456 | + foreach ($this->diffs as $diff) |
|
| 1457 | 1457 | { |
| 1458 | 1458 | //Encodings |
| 1459 | 1459 | $this->_newobj(); |
| 1460 | - $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>'); |
|
| 1460 | + $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [' . $diff . ']>>'); |
|
| 1461 | 1461 | $this->_out('endobj'); |
| 1462 | 1462 | } |
| 1463 | - foreach($this->FontFiles as $file=>$info) |
|
| 1463 | + foreach ($this->FontFiles as $file=>$info) |
|
| 1464 | 1464 | { |
| 1465 | 1465 | //Font file embedding |
| 1466 | 1466 | $this->_newobj(); |
| 1467 | - $this->FontFiles[$file]['n']=$this->n; |
|
| 1468 | - $font=''; |
|
| 1469 | - $f=fopen($this->_getfontpath().$file,'rb',1); |
|
| 1470 | - if(!$f) |
|
| 1467 | + $this->FontFiles[$file]['n'] = $this->n; |
|
| 1468 | + $font = ''; |
|
| 1469 | + $f = fopen($this->_getfontpath() . $file, 'rb', 1); |
|
| 1470 | + if (!$f) |
|
| 1471 | 1471 | $this->Error('Font file not found'); |
| 1472 | - while(!feof($f)) |
|
| 1473 | - $font.=fread($f,8192); |
|
| 1472 | + while (!feof($f)) |
|
| 1473 | + $font .= fread($f, 8192); |
|
| 1474 | 1474 | fclose($f); |
| 1475 | - $compressed=(substr($file,-2)=='.z'); |
|
| 1476 | - if(!$compressed && isset($info['length2'])) |
|
| 1475 | + $compressed = (substr($file, -2) == '.z'); |
|
| 1476 | + if (!$compressed && isset($info['length2'])) |
|
| 1477 | 1477 | { |
| 1478 | - $header=(ord($font[0])==128); |
|
| 1479 | - if($header) |
|
| 1478 | + $header = (ord($font[0]) == 128); |
|
| 1479 | + if ($header) |
|
| 1480 | 1480 | { |
| 1481 | 1481 | //Strip first binary header |
| 1482 | - $font=substr($font,6); |
|
| 1482 | + $font = substr($font, 6); |
|
| 1483 | 1483 | } |
| 1484 | - if($header && ord($font[$info['length1']])==128) |
|
| 1484 | + if ($header && ord($font[$info['length1']]) == 128) |
|
| 1485 | 1485 | { |
| 1486 | 1486 | //Strip second binary header |
| 1487 | - $font=substr($font,0,$info['length1']).substr($font,$info['length1']+6); |
|
| 1487 | + $font = substr($font, 0, $info['length1']) . substr($font, $info['length1'] + 6); |
|
| 1488 | 1488 | } |
| 1489 | 1489 | } |
| 1490 | - $this->_out('<</Length '.strlen($font)); |
|
| 1491 | - if($compressed) |
|
| 1490 | + $this->_out('<</Length ' . strlen($font)); |
|
| 1491 | + if ($compressed) |
|
| 1492 | 1492 | $this->_out('/Filter /FlateDecode'); |
| 1493 | - $this->_out('/Length1 '.$info['length1']); |
|
| 1494 | - if(isset($info['length2'])) |
|
| 1495 | - $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1493 | + $this->_out('/Length1 ' . $info['length1']); |
|
| 1494 | + if (isset($info['length2'])) |
|
| 1495 | + $this->_out('/Length2 ' . $info['length2'] . ' /Length3 0'); |
|
| 1496 | 1496 | $this->_out('>>'); |
| 1497 | 1497 | $this->_putstream($font); |
| 1498 | 1498 | $this->_out('endobj'); |
| 1499 | 1499 | } |
| 1500 | - foreach($this->fonts as $k=>$font) |
|
| 1500 | + foreach ($this->fonts as $k=>$font) |
|
| 1501 | 1501 | { |
| 1502 | 1502 | //Font objects |
| 1503 | - $this->fonts[$k]['n']=$this->n+1; |
|
| 1504 | - $type=$font['type']; |
|
| 1505 | - $name=$font['name']; |
|
| 1506 | - if($type=='core') |
|
| 1503 | + $this->fonts[$k]['n'] = $this->n + 1; |
|
| 1504 | + $type = $font['type']; |
|
| 1505 | + $name = $font['name']; |
|
| 1506 | + if ($type == 'core') |
|
| 1507 | 1507 | { |
| 1508 | 1508 | //Standard font |
| 1509 | 1509 | $this->_newobj(); |
| 1510 | 1510 | $this->_out('<</Type /Font'); |
| 1511 | - $this->_out('/BaseFont /'.$name); |
|
| 1511 | + $this->_out('/BaseFont /' . $name); |
|
| 1512 | 1512 | $this->_out('/Subtype /Type1'); |
| 1513 | - if($name!='Symbol' && $name!='ZapfDingbats') |
|
| 1513 | + if ($name != 'Symbol' && $name != 'ZapfDingbats') |
|
| 1514 | 1514 | $this->_out('/Encoding /WinAnsiEncoding'); |
| 1515 | 1515 | $this->_out('>>'); |
| 1516 | 1516 | $this->_out('endobj'); |
| 1517 | 1517 | } |
| 1518 | - elseif($type=='Type1' || $type=='TrueType') |
|
| 1518 | + elseif ($type == 'Type1' || $type == 'TrueType') |
|
| 1519 | 1519 | { |
| 1520 | 1520 | //Additional Type1 or TrueType font |
| 1521 | 1521 | $this->_newobj(); |
| 1522 | 1522 | $this->_out('<</Type /Font'); |
| 1523 | - $this->_out('/BaseFont /'.$name); |
|
| 1524 | - $this->_out('/Subtype /'.$type); |
|
| 1523 | + $this->_out('/BaseFont /' . $name); |
|
| 1524 | + $this->_out('/Subtype /' . $type); |
|
| 1525 | 1525 | $this->_out('/FirstChar 32 /LastChar 255'); |
| 1526 | - $this->_out('/Widths '.($this->n+1).' 0 R'); |
|
| 1527 | - $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); |
|
| 1528 | - if($font['enc']) |
|
| 1526 | + $this->_out('/Widths ' . ($this->n + 1) . ' 0 R'); |
|
| 1527 | + $this->_out('/FontDescriptor ' . ($this->n + 2) . ' 0 R'); |
|
| 1528 | + if ($font['enc']) |
|
| 1529 | 1529 | { |
| 1530 | - if(isset($font['diff'])) |
|
| 1531 | - $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); |
|
| 1530 | + if (isset($font['diff'])) |
|
| 1531 | + $this->_out('/Encoding ' . ($nf + $font['diff']) . ' 0 R'); |
|
| 1532 | 1532 | else |
| 1533 | 1533 | $this->_out('/Encoding /WinAnsiEncoding'); |
| 1534 | 1534 | } |
@@ -1536,29 +1536,29 @@ discard block |
||
| 1536 | 1536 | $this->_out('endobj'); |
| 1537 | 1537 | //Widths |
| 1538 | 1538 | $this->_newobj(); |
| 1539 | - $cw=&$font['cw']; |
|
| 1540 | - $s='['; |
|
| 1541 | - for($i=32;$i<=255;$i++) |
|
| 1542 | - $s.=$cw[chr($i)].' '; |
|
| 1543 | - $this->_out($s.']'); |
|
| 1539 | + $cw = &$font['cw']; |
|
| 1540 | + $s = '['; |
|
| 1541 | + for ($i = 32; $i <= 255; $i++) |
|
| 1542 | + $s .= $cw[chr($i)] . ' '; |
|
| 1543 | + $this->_out($s . ']'); |
|
| 1544 | 1544 | $this->_out('endobj'); |
| 1545 | 1545 | //Descriptor |
| 1546 | 1546 | $this->_newobj(); |
| 1547 | - $s='<</Type /FontDescriptor /FontName /'.$name; |
|
| 1548 | - foreach($font['desc'] as $k=>$v) |
|
| 1549 | - $s.=' /'.$k.' '.$v; |
|
| 1550 | - $file=$font['file']; |
|
| 1551 | - if($file) |
|
| 1552 | - $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
|
| 1553 | - $this->_out($s.'>>'); |
|
| 1547 | + $s = '<</Type /FontDescriptor /FontName /' . $name; |
|
| 1548 | + foreach ($font['desc'] as $k=>$v) |
|
| 1549 | + $s .= ' /' . $k . ' ' . $v; |
|
| 1550 | + $file = $font['file']; |
|
| 1551 | + if ($file) |
|
| 1552 | + $s .= ' /FontFile' . ($type == 'Type1' ? '' : '2') . ' ' . $this->FontFiles[$file]['n'] . ' 0 R'; |
|
| 1553 | + $this->_out($s . '>>'); |
|
| 1554 | 1554 | $this->_out('endobj'); |
| 1555 | 1555 | } |
| 1556 | 1556 | else |
| 1557 | 1557 | { |
| 1558 | 1558 | //Allow for additional types |
| 1559 | - $mtd='_put'.strtolower($type); |
|
| 1560 | - if(!method_exists($this,$mtd)) |
|
| 1561 | - $this->Error('Unsupported font type: '.$type); |
|
| 1559 | + $mtd = '_put' . strtolower($type); |
|
| 1560 | + if (!method_exists($this, $mtd)) |
|
| 1561 | + $this->Error('Unsupported font type: ' . $type); |
|
| 1562 | 1562 | $this->$mtd($font); |
| 1563 | 1563 | } |
| 1564 | 1564 | } |
@@ -1566,46 +1566,46 @@ discard block |
||
| 1566 | 1566 | |
| 1567 | 1567 | function _putimages() |
| 1568 | 1568 | { |
| 1569 | - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; |
|
| 1569 | + $filter = ($this->compress) ? '/Filter /FlateDecode ' : ''; |
|
| 1570 | 1570 | reset($this->images); |
| 1571 | - while(list($file,$info)=each($this->images)) |
|
| 1571 | + while (list($file, $info) = each($this->images)) |
|
| 1572 | 1572 | { |
| 1573 | 1573 | $this->_newobj(); |
| 1574 | - $this->images[$file]['n']=$this->n; |
|
| 1574 | + $this->images[$file]['n'] = $this->n; |
|
| 1575 | 1575 | $this->_out('<</Type /XObject'); |
| 1576 | 1576 | $this->_out('/Subtype /Image'); |
| 1577 | - $this->_out('/Width '.$info['w']); |
|
| 1578 | - $this->_out('/Height '.$info['h']); |
|
| 1579 | - if($info['cs']=='Indexed') |
|
| 1580 | - $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1577 | + $this->_out('/Width ' . $info['w']); |
|
| 1578 | + $this->_out('/Height ' . $info['h']); |
|
| 1579 | + if ($info['cs'] == 'Indexed') |
|
| 1580 | + $this->_out('/ColorSpace [/Indexed /DeviceRGB ' . (strlen($info['pal']) / 3 - 1) . ' ' . ($this->n + 1) . ' 0 R]'); |
|
| 1581 | 1581 | else |
| 1582 | 1582 | { |
| 1583 | - $this->_out('/ColorSpace /'.$info['cs']); |
|
| 1584 | - if($info['cs']=='DeviceCMYK') |
|
| 1583 | + $this->_out('/ColorSpace /' . $info['cs']); |
|
| 1584 | + if ($info['cs'] == 'DeviceCMYK') |
|
| 1585 | 1585 | $this->_out('/Decode [1 0 1 0 1 0 1 0]'); |
| 1586 | 1586 | } |
| 1587 | - $this->_out('/BitsPerComponent '.$info['bpc']); |
|
| 1588 | - if(isset($info['f'])) |
|
| 1589 | - $this->_out('/Filter /'.$info['f']); |
|
| 1590 | - if(isset($info['parms'])) |
|
| 1587 | + $this->_out('/BitsPerComponent ' . $info['bpc']); |
|
| 1588 | + if (isset($info['f'])) |
|
| 1589 | + $this->_out('/Filter /' . $info['f']); |
|
| 1590 | + if (isset($info['parms'])) |
|
| 1591 | 1591 | $this->_out($info['parms']); |
| 1592 | - if(isset($info['trns']) && is_array($info['trns'])) |
|
| 1592 | + if (isset($info['trns']) && is_array($info['trns'])) |
|
| 1593 | 1593 | { |
| 1594 | - $trns=''; |
|
| 1595 | - for($i=0;$i<count($info['trns']);$i++) |
|
| 1596 | - $trns.=$info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1597 | - $this->_out('/Mask ['.$trns.']'); |
|
| 1594 | + $trns = ''; |
|
| 1595 | + for ($i = 0; $i < count($info['trns']); $i++) |
|
| 1596 | + $trns .= $info['trns'][$i] . ' ' . $info['trns'][$i] . ' '; |
|
| 1597 | + $this->_out('/Mask [' . $trns . ']'); |
|
| 1598 | 1598 | } |
| 1599 | - $this->_out('/Length '.strlen($info['data']).'>>'); |
|
| 1599 | + $this->_out('/Length ' . strlen($info['data']) . '>>'); |
|
| 1600 | 1600 | $this->_putstream($info['data']); |
| 1601 | 1601 | unset($this->images[$file]['data']); |
| 1602 | 1602 | $this->_out('endobj'); |
| 1603 | 1603 | //Palette |
| 1604 | - if($info['cs']=='Indexed') |
|
| 1604 | + if ($info['cs'] == 'Indexed') |
|
| 1605 | 1605 | { |
| 1606 | 1606 | $this->_newobj(); |
| 1607 | - $pal=($this->compress) ? gzcompress($info['pal']) : $info['pal']; |
|
| 1608 | - $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>'); |
|
| 1607 | + $pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal']; |
|
| 1608 | + $this->_out('<<' . $filter . '/Length ' . strlen($pal) . '>>'); |
|
| 1609 | 1609 | $this->_putstream($pal); |
| 1610 | 1610 | $this->_out('endobj'); |
| 1611 | 1611 | } |
@@ -1614,16 +1614,16 @@ discard block |
||
| 1614 | 1614 | |
| 1615 | 1615 | function _putxobjectdict() |
| 1616 | 1616 | { |
| 1617 | - foreach($this->images as $image) |
|
| 1618 | - $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1617 | + foreach ($this->images as $image) |
|
| 1618 | + $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); |
|
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | 1621 | function _putresourcedict() |
| 1622 | 1622 | { |
| 1623 | 1623 | $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
| 1624 | 1624 | $this->_out('/Font <<'); |
| 1625 | - foreach($this->fonts as $font) |
|
| 1626 | - $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1625 | + foreach ($this->fonts as $font) |
|
| 1626 | + $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); |
|
| 1627 | 1627 | $this->_out('>>'); |
| 1628 | 1628 | $this->_out('/XObject <<'); |
| 1629 | 1629 | $this->_putxobjectdict(); |
@@ -1635,7 +1635,7 @@ discard block |
||
| 1635 | 1635 | $this->_putfonts(); |
| 1636 | 1636 | $this->_putimages(); |
| 1637 | 1637 | //Resource dictionary |
| 1638 | - $this->offsets[2]=strlen($this->buffer); |
|
| 1638 | + $this->offsets[2] = strlen($this->buffer); |
|
| 1639 | 1639 | $this->_out('2 0 obj'); |
| 1640 | 1640 | $this->_out('<<'); |
| 1641 | 1641 | $this->_putresourcedict(); |
@@ -1645,50 +1645,50 @@ discard block |
||
| 1645 | 1645 | |
| 1646 | 1646 | function _putinfo() |
| 1647 | 1647 | { |
| 1648 | - $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION)); |
|
| 1649 | - if(!empty($this->title)) |
|
| 1650 | - $this->_out('/Title '.$this->_textstring($this->title)); |
|
| 1651 | - if(!empty($this->subject)) |
|
| 1652 | - $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
| 1653 | - if(!empty($this->author)) |
|
| 1654 | - $this->_out('/Author '.$this->_textstring($this->author)); |
|
| 1655 | - if(!empty($this->keywords)) |
|
| 1656 | - $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
| 1657 | - if(!empty($this->creator)) |
|
| 1658 | - $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
| 1659 | - $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); |
|
| 1648 | + $this->_out('/Producer ' . $this->_textstring('FPDF ' . FPDF_VERSION)); |
|
| 1649 | + if (!empty($this->title)) |
|
| 1650 | + $this->_out('/Title ' . $this->_textstring($this->title)); |
|
| 1651 | + if (!empty($this->subject)) |
|
| 1652 | + $this->_out('/Subject ' . $this->_textstring($this->subject)); |
|
| 1653 | + if (!empty($this->author)) |
|
| 1654 | + $this->_out('/Author ' . $this->_textstring($this->author)); |
|
| 1655 | + if (!empty($this->keywords)) |
|
| 1656 | + $this->_out('/Keywords ' . $this->_textstring($this->keywords)); |
|
| 1657 | + if (!empty($this->creator)) |
|
| 1658 | + $this->_out('/Creator ' . $this->_textstring($this->creator)); |
|
| 1659 | + $this->_out('/CreationDate ' . $this->_textstring('D:' . @date('YmdHis'))); |
|
| 1660 | 1660 | } |
| 1661 | 1661 | |
| 1662 | 1662 | function _putcatalog() |
| 1663 | 1663 | { |
| 1664 | 1664 | $this->_out('/Type /Catalog'); |
| 1665 | 1665 | $this->_out('/Pages 1 0 R'); |
| 1666 | - if($this->ZoomMode=='fullpage') |
|
| 1666 | + if ($this->ZoomMode == 'fullpage') |
|
| 1667 | 1667 | $this->_out('/OpenAction [3 0 R /Fit]'); |
| 1668 | - elseif($this->ZoomMode=='fullwidth') |
|
| 1668 | + elseif ($this->ZoomMode == 'fullwidth') |
|
| 1669 | 1669 | $this->_out('/OpenAction [3 0 R /FitH null]'); |
| 1670 | - elseif($this->ZoomMode=='real') |
|
| 1670 | + elseif ($this->ZoomMode == 'real') |
|
| 1671 | 1671 | $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); |
| 1672 | - elseif(!is_string($this->ZoomMode)) |
|
| 1673 | - $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); |
|
| 1674 | - if($this->LayoutMode=='single') |
|
| 1672 | + elseif (!is_string($this->ZoomMode)) |
|
| 1673 | + $this->_out('/OpenAction [3 0 R /XYZ null null ' . ($this->ZoomMode / 100) . ']'); |
|
| 1674 | + if ($this->LayoutMode == 'single') |
|
| 1675 | 1675 | $this->_out('/PageLayout /SinglePage'); |
| 1676 | - elseif($this->LayoutMode=='continuous') |
|
| 1676 | + elseif ($this->LayoutMode == 'continuous') |
|
| 1677 | 1677 | $this->_out('/PageLayout /OneColumn'); |
| 1678 | - elseif($this->LayoutMode=='two') |
|
| 1678 | + elseif ($this->LayoutMode == 'two') |
|
| 1679 | 1679 | $this->_out('/PageLayout /TwoColumnLeft'); |
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | 1682 | function _putheader() |
| 1683 | 1683 | { |
| 1684 | - $this->_out('%PDF-'.$this->PDFVersion); |
|
| 1684 | + $this->_out('%PDF-' . $this->PDFVersion); |
|
| 1685 | 1685 | } |
| 1686 | 1686 | |
| 1687 | 1687 | function _puttrailer() |
| 1688 | 1688 | { |
| 1689 | - $this->_out('/Size '.($this->n+1)); |
|
| 1690 | - $this->_out('/Root '.$this->n.' 0 R'); |
|
| 1691 | - $this->_out('/Info '.($this->n-1).' 0 R'); |
|
| 1689 | + $this->_out('/Size ' . ($this->n + 1)); |
|
| 1690 | + $this->_out('/Root ' . $this->n . ' 0 R'); |
|
| 1691 | + $this->_out('/Info ' . ($this->n - 1) . ' 0 R'); |
|
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | 1694 | function _enddoc() |
@@ -1709,12 +1709,12 @@ discard block |
||
| 1709 | 1709 | $this->_out('>>'); |
| 1710 | 1710 | $this->_out('endobj'); |
| 1711 | 1711 | //Cross-ref |
| 1712 | - $o=strlen($this->buffer); |
|
| 1712 | + $o = strlen($this->buffer); |
|
| 1713 | 1713 | $this->_out('xref'); |
| 1714 | - $this->_out('0 '.($this->n+1)); |
|
| 1714 | + $this->_out('0 ' . ($this->n + 1)); |
|
| 1715 | 1715 | $this->_out('0000000000 65535 f '); |
| 1716 | - for($i=1;$i<=$this->n;$i++) |
|
| 1717 | - $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 1716 | + for ($i = 1; $i <= $this->n; $i++) |
|
| 1717 | + $this->_out(sprintf('%010d 00000 n ', $this->offsets[$i])); |
|
| 1718 | 1718 | //Trailer |
| 1719 | 1719 | $this->_out('trailer'); |
| 1720 | 1720 | $this->_out('<<'); |
@@ -1723,13 +1723,13 @@ discard block |
||
| 1723 | 1723 | $this->_out('startxref'); |
| 1724 | 1724 | $this->_out($o); |
| 1725 | 1725 | $this->_out('%%EOF'); |
| 1726 | - $this->state=3; |
|
| 1726 | + $this->state = 3; |
|
| 1727 | 1727 | } |
| 1728 | 1728 | //End of class |
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | 1731 | //Handle special IE contype request |
| 1732 | -if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype') |
|
| 1732 | +if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] == 'contype') |
|
| 1733 | 1733 | { |
| 1734 | 1734 | header('Content-Type: application/pdf'); |
| 1735 | 1735 | exit; |
@@ -112,21 +112,23 @@ discard block |
||
| 112 | 112 | 'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic', |
| 113 | 113 | 'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats'); |
| 114 | 114 | //Scale factor |
| 115 | - if($unit=='pt') |
|
| 116 | - $this->k=1; |
|
| 117 | - elseif($unit=='mm') |
|
| 118 | - $this->k=72/25.4; |
|
| 119 | - elseif($unit=='cm') |
|
| 120 | - $this->k=72/2.54; |
|
| 121 | - elseif($unit=='in') |
|
| 122 | - $this->k=72; |
|
| 123 | - else |
|
| 124 | - $this->Error('Incorrect unit: '.$unit); |
|
| 115 | + if($unit=='pt') { |
|
| 116 | + $this->k=1; |
|
| 117 | + } elseif($unit=='mm') { |
|
| 118 | + $this->k=72/25.4; |
|
| 119 | + } elseif($unit=='cm') { |
|
| 120 | + $this->k=72/2.54; |
|
| 121 | + } elseif($unit=='in') { |
|
| 122 | + $this->k=72; |
|
| 123 | + } else { |
|
| 124 | + $this->Error('Incorrect unit: '.$unit); |
|
| 125 | + } |
|
| 125 | 126 | //Page format |
| 126 | 127 | $this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), |
| 127 | 128 | 'letter'=>array(612,792), 'legal'=>array(612,1008)); |
| 128 | - if(is_string($format)) |
|
| 129 | - $format=$this->_getpageformat($format); |
|
| 129 | + if(is_string($format)) { |
|
| 130 | + $format=$this->_getpageformat($format); |
|
| 131 | + } |
|
| 130 | 132 | $this->DefPageFormat=$format; |
| 131 | 133 | $this->CurPageFormat=$format; |
| 132 | 134 | //Page orientation |
@@ -136,15 +138,14 @@ discard block |
||
| 136 | 138 | $this->DefOrientation='P'; |
| 137 | 139 | $this->w=$this->DefPageFormat[0]; |
| 138 | 140 | $this->h=$this->DefPageFormat[1]; |
| 139 | - } |
|
| 140 | - elseif($orientation=='l' || $orientation=='landscape') |
|
| 141 | + } elseif($orientation=='l' || $orientation=='landscape') |
|
| 141 | 142 | { |
| 142 | 143 | $this->DefOrientation='L'; |
| 143 | 144 | $this->w=$this->DefPageFormat[1]; |
| 144 | 145 | $this->h=$this->DefPageFormat[0]; |
| 146 | + } else { |
|
| 147 | + $this->Error('Incorrect orientation: '.$orientation); |
|
| 145 | 148 | } |
| 146 | - else |
|
| 147 | - $this->Error('Incorrect orientation: '.$orientation); |
|
| 148 | 149 | $this->CurOrientation=$this->DefOrientation; |
| 149 | 150 | $this->wPt=$this->w*$this->k; |
| 150 | 151 | $this->hPt=$this->h*$this->k; |
@@ -170,8 +171,9 @@ discard block |
||
| 170 | 171 | //Set left, top and right margins |
| 171 | 172 | $this->lMargin=$left; |
| 172 | 173 | $this->tMargin=$top; |
| 173 | - if($right===null) |
|
| 174 | - $right=$left; |
|
| 174 | + if($right===null) { |
|
| 175 | + $right=$left; |
|
| 176 | + } |
|
| 175 | 177 | $this->rMargin=$right; |
| 176 | 178 | } |
| 177 | 179 | |
@@ -179,9 +181,10 @@ discard block |
||
| 179 | 181 | { |
| 180 | 182 | //Set left margin |
| 181 | 183 | $this->lMargin=$margin; |
| 182 | - if($this->page>0 && $this->x<$margin) |
|
| 183 | - $this->x=$margin; |
|
| 184 | -} |
|
| 184 | + if($this->page>0 && $this->x<$margin) { |
|
| 185 | + $this->x=$margin; |
|
| 186 | + } |
|
| 187 | + } |
|
| 185 | 188 | |
| 186 | 189 | function SetTopMargin($margin) |
| 187 | 190 | { |
@@ -206,62 +209,70 @@ discard block |
||
| 206 | 209 | function SetDisplayMode($zoom, $layout='continuous') |
| 207 | 210 | { |
| 208 | 211 | //Set display mode in viewer |
| 209 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
| 210 | - $this->ZoomMode=$zoom; |
|
| 211 | - else |
|
| 212 | - $this->Error('Incorrect zoom display mode: '.$zoom); |
|
| 213 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
| 214 | - $this->LayoutMode=$layout; |
|
| 215 | - else |
|
| 216 | - $this->Error('Incorrect layout display mode: '.$layout); |
|
| 217 | -} |
|
| 212 | + if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) { |
|
| 213 | + $this->ZoomMode=$zoom; |
|
| 214 | + } else { |
|
| 215 | + $this->Error('Incorrect zoom display mode: '.$zoom); |
|
| 216 | + } |
|
| 217 | + if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') { |
|
| 218 | + $this->LayoutMode=$layout; |
|
| 219 | + } else { |
|
| 220 | + $this->Error('Incorrect layout display mode: '.$layout); |
|
| 221 | + } |
|
| 222 | + } |
|
| 218 | 223 | |
| 219 | 224 | function SetCompression($compress) |
| 220 | 225 | { |
| 221 | 226 | //Set page compression |
| 222 | - if(function_exists('gzcompress')) |
|
| 223 | - $this->compress=$compress; |
|
| 224 | - else |
|
| 225 | - $this->compress=false; |
|
| 226 | -} |
|
| 227 | + if(function_exists('gzcompress')) { |
|
| 228 | + $this->compress=$compress; |
|
| 229 | + } else { |
|
| 230 | + $this->compress=false; |
|
| 231 | + } |
|
| 232 | + } |
|
| 227 | 233 | |
| 228 | 234 | function SetTitle($title, $isUTF8=false) |
| 229 | 235 | { |
| 230 | 236 | //Title of document |
| 231 | - if($isUTF8) |
|
| 232 | - $title=$this->_UTF8toUTF16($title); |
|
| 237 | + if($isUTF8) { |
|
| 238 | + $title=$this->_UTF8toUTF16($title); |
|
| 239 | + } |
|
| 233 | 240 | $this->title=$title; |
| 234 | 241 | } |
| 235 | 242 | |
| 236 | 243 | function SetSubject($subject, $isUTF8=false) |
| 237 | 244 | { |
| 238 | 245 | //Subject of document |
| 239 | - if($isUTF8) |
|
| 240 | - $subject=$this->_UTF8toUTF16($subject); |
|
| 246 | + if($isUTF8) { |
|
| 247 | + $subject=$this->_UTF8toUTF16($subject); |
|
| 248 | + } |
|
| 241 | 249 | $this->subject=$subject; |
| 242 | 250 | } |
| 243 | 251 | |
| 244 | 252 | function SetAuthor($author, $isUTF8=false) |
| 245 | 253 | { |
| 246 | 254 | //Author of document |
| 247 | - if($isUTF8) |
|
| 248 | - $author=$this->_UTF8toUTF16($author); |
|
| 255 | + if($isUTF8) { |
|
| 256 | + $author=$this->_UTF8toUTF16($author); |
|
| 257 | + } |
|
| 249 | 258 | $this->author=$author; |
| 250 | 259 | } |
| 251 | 260 | |
| 252 | 261 | function SetKeywords($keywords, $isUTF8=false) |
| 253 | 262 | { |
| 254 | 263 | //Keywords of document |
| 255 | - if($isUTF8) |
|
| 256 | - $keywords=$this->_UTF8toUTF16($keywords); |
|
| 264 | + if($isUTF8) { |
|
| 265 | + $keywords=$this->_UTF8toUTF16($keywords); |
|
| 266 | + } |
|
| 257 | 267 | $this->keywords=$keywords; |
| 258 | 268 | } |
| 259 | 269 | |
| 260 | 270 | function SetCreator($creator, $isUTF8=false) |
| 261 | 271 | { |
| 262 | 272 | //Creator of document |
| 263 | - if($isUTF8) |
|
| 264 | - $creator=$this->_UTF8toUTF16($creator); |
|
| 273 | + if($isUTF8) { |
|
| 274 | + $creator=$this->_UTF8toUTF16($creator); |
|
| 275 | + } |
|
| 265 | 276 | $this->creator=$creator; |
| 266 | 277 | } |
| 267 | 278 | |
@@ -286,10 +297,12 @@ discard block |
||
| 286 | 297 | function Close() |
| 287 | 298 | { |
| 288 | 299 | //Terminate document |
| 289 | - if($this->state==3) |
|
| 290 | - return; |
|
| 291 | - if($this->page==0) |
|
| 292 | - $this->AddPage(); |
|
| 300 | + if($this->state==3) { |
|
| 301 | + return; |
|
| 302 | + } |
|
| 303 | + if($this->page==0) { |
|
| 304 | + $this->AddPage(); |
|
| 305 | + } |
|
| 293 | 306 | //Page footer |
| 294 | 307 | $this->InFooter=true; |
| 295 | 308 | $this->Footer(); |
@@ -303,8 +316,9 @@ discard block |
||
| 303 | 316 | function AddPage($orientation='', $format='') |
| 304 | 317 | { |
| 305 | 318 | //Start a new page |
| 306 | - if($this->state==0) |
|
| 307 | - $this->Open(); |
|
| 319 | + if($this->state==0) { |
|
| 320 | + $this->Open(); |
|
| 321 | + } |
|
| 308 | 322 | $family=$this->FontFamily; |
| 309 | 323 | $style=$this->FontStyle.($this->underline ? 'U' : ''); |
| 310 | 324 | $size=$this->FontSizePt; |
@@ -330,15 +344,18 @@ discard block |
||
| 330 | 344 | $this->LineWidth=$lw; |
| 331 | 345 | $this->_out(sprintf('%.2F w',$lw*$this->k)); |
| 332 | 346 | //Set font |
| 333 | - if($family) |
|
| 334 | - $this->SetFont($family,$style,$size); |
|
| 347 | + if($family) { |
|
| 348 | + $this->SetFont($family,$style,$size); |
|
| 349 | + } |
|
| 335 | 350 | //Set colors |
| 336 | 351 | $this->DrawColor=$dc; |
| 337 | - if($dc!='0 G') |
|
| 338 | - $this->_out($dc); |
|
| 352 | + if($dc!='0 G') { |
|
| 353 | + $this->_out($dc); |
|
| 354 | + } |
|
| 339 | 355 | $this->FillColor=$fc; |
| 340 | - if($fc!='0 g') |
|
| 341 | - $this->_out($fc); |
|
| 356 | + if($fc!='0 g') { |
|
| 357 | + $this->_out($fc); |
|
| 358 | + } |
|
| 342 | 359 | $this->TextColor=$tc; |
| 343 | 360 | $this->ColorFlag=$cf; |
| 344 | 361 | //Page header |
@@ -352,8 +369,9 @@ discard block |
||
| 352 | 369 | $this->_out(sprintf('%.2F w',$lw*$this->k)); |
| 353 | 370 | } |
| 354 | 371 | //Restore font |
| 355 | - if($family) |
|
| 356 | - $this->SetFont($family,$style,$size); |
|
| 372 | + if($family) { |
|
| 373 | + $this->SetFont($family,$style,$size); |
|
| 374 | + } |
|
| 357 | 375 | //Restore colors |
| 358 | 376 | if($this->DrawColor!=$dc) |
| 359 | 377 | { |
@@ -388,33 +406,38 @@ discard block |
||
| 388 | 406 | function SetDrawColor($r, $g=null, $b=null) |
| 389 | 407 | { |
| 390 | 408 | //Set color for all stroking operations |
| 391 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 392 | - $this->DrawColor=sprintf('%.3F G',$r/255); |
|
| 393 | - else |
|
| 394 | - $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
| 395 | - if($this->page>0) |
|
| 396 | - $this->_out($this->DrawColor); |
|
| 397 | -} |
|
| 409 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 410 | + $this->DrawColor=sprintf('%.3F G',$r/255); |
|
| 411 | + } else { |
|
| 412 | + $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
| 413 | + } |
|
| 414 | + if($this->page>0) { |
|
| 415 | + $this->_out($this->DrawColor); |
|
| 416 | + } |
|
| 417 | + } |
|
| 398 | 418 | |
| 399 | 419 | function SetFillColor($r, $g=null, $b=null) |
| 400 | 420 | { |
| 401 | 421 | //Set color for all filling operations |
| 402 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 403 | - $this->FillColor=sprintf('%.3F g',$r/255); |
|
| 404 | - else |
|
| 405 | - $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 422 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 423 | + $this->FillColor=sprintf('%.3F g',$r/255); |
|
| 424 | + } else { |
|
| 425 | + $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 426 | + } |
|
| 406 | 427 | $this->ColorFlag=($this->FillColor!=$this->TextColor); |
| 407 | - if($this->page>0) |
|
| 408 | - $this->_out($this->FillColor); |
|
| 409 | -} |
|
| 428 | + if($this->page>0) { |
|
| 429 | + $this->_out($this->FillColor); |
|
| 430 | + } |
|
| 431 | + } |
|
| 410 | 432 | |
| 411 | 433 | function SetTextColor($r, $g=null, $b=null) |
| 412 | 434 | { |
| 413 | 435 | //Set color for text |
| 414 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 415 | - $this->TextColor=sprintf('%.3F g',$r/255); |
|
| 416 | - else |
|
| 417 | - $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 436 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 437 | + $this->TextColor=sprintf('%.3F g',$r/255); |
|
| 438 | + } else { |
|
| 439 | + $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 440 | + } |
|
| 418 | 441 | $this->ColorFlag=($this->FillColor!=$this->TextColor); |
| 419 | 442 | } |
| 420 | 443 | |
@@ -425,8 +448,9 @@ discard block |
||
| 425 | 448 | $cw=&$this->CurrentFont['cw']; |
| 426 | 449 | $w=0; |
| 427 | 450 | $l=strlen($s); |
| 428 | - for($i=0;$i<$l;$i++) |
|
| 429 | - $w+=$cw[$s[$i]]; |
|
| 451 | + for($i=0;$i<$l;$i++) { |
|
| 452 | + $w+=$cw[$s[$i]]; |
|
| 453 | + } |
|
| 430 | 454 | return $w*$this->FontSize/1000; |
| 431 | 455 | } |
| 432 | 456 | |
@@ -434,9 +458,10 @@ discard block |
||
| 434 | 458 | { |
| 435 | 459 | //Set line width |
| 436 | 460 | $this->LineWidth=$width; |
| 437 | - if($this->page>0) |
|
| 438 | - $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 439 | -} |
|
| 461 | + if($this->page>0) { |
|
| 462 | + $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 463 | + } |
|
| 464 | + } |
|
| 440 | 465 | |
| 441 | 466 | function Line($x1, $y1, $x2, $y2) |
| 442 | 467 | { |
@@ -447,12 +472,13 @@ discard block |
||
| 447 | 472 | function Rect($x, $y, $w, $h, $style='') |
| 448 | 473 | { |
| 449 | 474 | //Draw a rectangle |
| 450 | - if($style=='F') |
|
| 451 | - $op='f'; |
|
| 452 | - elseif($style=='FD' || $style=='DF') |
|
| 453 | - $op='B'; |
|
| 454 | - else |
|
| 455 | - $op='S'; |
|
| 475 | + if($style=='F') { |
|
| 476 | + $op='f'; |
|
| 477 | + } elseif($style=='FD' || $style=='DF') { |
|
| 478 | + $op='B'; |
|
| 479 | + } else { |
|
| 480 | + $op='S'; |
|
| 481 | + } |
|
| 456 | 482 | $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); |
| 457 | 483 | } |
| 458 | 484 | |
@@ -460,19 +486,24 @@ discard block |
||
| 460 | 486 | { |
| 461 | 487 | //Add a TrueType or Type1 font |
| 462 | 488 | $family=strtolower($family); |
| 463 | - if($file=='') |
|
| 464 | - $file=str_replace(' ','',$family).strtolower($style).'.php'; |
|
| 465 | - if($family=='arial') |
|
| 466 | - $family='helvetica'; |
|
| 489 | + if($file=='') { |
|
| 490 | + $file=str_replace(' ','',$family).strtolower($style).'.php'; |
|
| 491 | + } |
|
| 492 | + if($family=='arial') { |
|
| 493 | + $family='helvetica'; |
|
| 494 | + } |
|
| 467 | 495 | $style=strtoupper($style); |
| 468 | - if($style=='IB') |
|
| 469 | - $style='BI'; |
|
| 496 | + if($style=='IB') { |
|
| 497 | + $style='BI'; |
|
| 498 | + } |
|
| 470 | 499 | $fontkey=$family.$style; |
| 471 | - if(isset($this->fonts[$fontkey])) |
|
| 472 | - return; |
|
| 500 | + if(isset($this->fonts[$fontkey])) { |
|
| 501 | + return; |
|
| 502 | + } |
|
| 473 | 503 | include($this->_getfontpath().$file); |
| 474 | - if(!isset($name)) |
|
| 475 | - $this->Error('Could not include font definition file'); |
|
| 504 | + if(!isset($name)) { |
|
| 505 | + $this->Error('Could not include font definition file'); |
|
| 506 | + } |
|
| 476 | 507 | $i=count($this->fonts)+1; |
| 477 | 508 | $this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file); |
| 478 | 509 | if($diff) |
@@ -497,10 +528,11 @@ discard block |
||
| 497 | 528 | } |
| 498 | 529 | if($file) |
| 499 | 530 | { |
| 500 | - if($type=='TrueType') |
|
| 501 | - $this->FontFiles[$file]=array('length1'=>$originalsize); |
|
| 502 | - else |
|
| 503 | - $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2); |
|
| 531 | + if($type=='TrueType') { |
|
| 532 | + $this->FontFiles[$file]=array('length1'=>$originalsize); |
|
| 533 | + } else { |
|
| 534 | + $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2); |
|
| 535 | + } |
|
| 504 | 536 | } |
| 505 | 537 | } |
| 506 | 538 | |
@@ -510,27 +542,32 @@ discard block |
||
| 510 | 542 | global $fpdf_charwidths; |
| 511 | 543 | |
| 512 | 544 | $family=strtolower($family); |
| 513 | - if($family=='') |
|
| 514 | - $family=$this->FontFamily; |
|
| 515 | - if($family=='arial') |
|
| 516 | - $family='helvetica'; |
|
| 517 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 518 | - $style=''; |
|
| 545 | + if($family=='') { |
|
| 546 | + $family=$this->FontFamily; |
|
| 547 | + } |
|
| 548 | + if($family=='arial') { |
|
| 549 | + $family='helvetica'; |
|
| 550 | + } elseif($family=='symbol' || $family=='zapfdingbats') { |
|
| 551 | + $style=''; |
|
| 552 | + } |
|
| 519 | 553 | $style=strtoupper($style); |
| 520 | 554 | if(strpos($style,'U')!==false) |
| 521 | 555 | { |
| 522 | 556 | $this->underline=true; |
| 523 | 557 | $style=str_replace('U','',$style); |
| 558 | + } else { |
|
| 559 | + $this->underline=false; |
|
| 560 | + } |
|
| 561 | + if($style=='IB') { |
|
| 562 | + $style='BI'; |
|
| 563 | + } |
|
| 564 | + if($size==0) { |
|
| 565 | + $size=$this->FontSizePt; |
|
| 524 | 566 | } |
| 525 | - else |
|
| 526 | - $this->underline=false; |
|
| 527 | - if($style=='IB') |
|
| 528 | - $style='BI'; |
|
| 529 | - if($size==0) |
|
| 530 | - $size=$this->FontSizePt; |
|
| 531 | 567 | //Test if font is already selected |
| 532 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
| 533 | - return; |
|
| 568 | + if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) { |
|
| 569 | + return; |
|
| 570 | + } |
|
| 534 | 571 | //Test if used for the first time |
| 535 | 572 | $fontkey=$family.$style; |
| 536 | 573 | if(!isset($this->fonts[$fontkey])) |
@@ -542,19 +579,21 @@ discard block |
||
| 542 | 579 | { |
| 543 | 580 | //Load metric file |
| 544 | 581 | $file=$family; |
| 545 | - if($family=='times' || $family=='helvetica') |
|
| 546 | - $file.=strtolower($style); |
|
| 582 | + if($family=='times' || $family=='helvetica') { |
|
| 583 | + $file.=strtolower($style); |
|
| 584 | + } |
|
| 547 | 585 | include($this->_getfontpath().$file.'.php'); |
| 548 | - if(!isset($fpdf_charwidths[$fontkey])) |
|
| 549 | - $this->Error('Could not include font metric file'); |
|
| 586 | + if(!isset($fpdf_charwidths[$fontkey])) { |
|
| 587 | + $this->Error('Could not include font metric file'); |
|
| 588 | + } |
|
| 550 | 589 | } |
| 551 | 590 | $i=count($this->fonts)+1; |
| 552 | 591 | $name=$this->CoreFonts[$fontkey]; |
| 553 | 592 | $cw=$fpdf_charwidths[$fontkey]; |
| 554 | 593 | $this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw); |
| 594 | + } else { |
|
| 595 | + $this->Error('Undefined font: '.$family.' '.$style); |
|
| 555 | 596 | } |
| 556 | - else |
|
| 557 | - $this->Error('Undefined font: '.$family.' '.$style); |
|
| 558 | 597 | } |
| 559 | 598 | //Select it |
| 560 | 599 | $this->FontFamily=$family; |
@@ -562,20 +601,23 @@ discard block |
||
| 562 | 601 | $this->FontSizePt=$size; |
| 563 | 602 | $this->FontSize=$size/$this->k; |
| 564 | 603 | $this->CurrentFont=&$this->fonts[$fontkey]; |
| 565 | - if($this->page>0) |
|
| 566 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 567 | -} |
|
| 604 | + if($this->page>0) { |
|
| 605 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 606 | + } |
|
| 607 | + } |
|
| 568 | 608 | |
| 569 | 609 | function SetFontSize($size) |
| 570 | 610 | { |
| 571 | 611 | //Set font size in points |
| 572 | - if($this->FontSizePt==$size) |
|
| 573 | - return; |
|
| 612 | + if($this->FontSizePt==$size) { |
|
| 613 | + return; |
|
| 614 | + } |
|
| 574 | 615 | $this->FontSizePt=$size; |
| 575 | 616 | $this->FontSize=$size/$this->k; |
| 576 | - if($this->page>0) |
|
| 577 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 578 | -} |
|
| 617 | + if($this->page>0) { |
|
| 618 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 619 | + } |
|
| 620 | + } |
|
| 579 | 621 | |
| 580 | 622 | function AddLink() |
| 581 | 623 | { |
@@ -588,10 +630,12 @@ discard block |
||
| 588 | 630 | function SetLink($link, $y=0, $page=-1) |
| 589 | 631 | { |
| 590 | 632 | //Set destination of internal link |
| 591 | - if($y==-1) |
|
| 592 | - $y=$this->y; |
|
| 593 | - if($page==-1) |
|
| 594 | - $page=$this->page; |
|
| 633 | + if($y==-1) { |
|
| 634 | + $y=$this->y; |
|
| 635 | + } |
|
| 636 | + if($page==-1) { |
|
| 637 | + $page=$this->page; |
|
| 638 | + } |
|
| 595 | 639 | $this->links[$link]=array($page, $y); |
| 596 | 640 | } |
| 597 | 641 | |
@@ -605,10 +649,12 @@ discard block |
||
| 605 | 649 | { |
| 606 | 650 | //Output a string |
| 607 | 651 | $s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); |
| 608 | - if($this->underline && $txt!='') |
|
| 609 | - $s.=' '.$this->_dounderline($x,$y,$txt); |
|
| 610 | - if($this->ColorFlag) |
|
| 611 | - $s='q '.$this->TextColor.' '.$s.' Q'; |
|
| 652 | + if($this->underline && $txt!='') { |
|
| 653 | + $s.=' '.$this->_dounderline($x,$y,$txt); |
|
| 654 | + } |
|
| 655 | + if($this->ColorFlag) { |
|
| 656 | + $s='q '.$this->TextColor.' '.$s.' Q'; |
|
| 657 | + } |
|
| 612 | 658 | $this->_out($s); |
| 613 | 659 | } |
| 614 | 660 | |
@@ -640,74 +686,89 @@ discard block |
||
| 640 | 686 | $this->_out(sprintf('%.3F Tw',$ws*$k)); |
| 641 | 687 | } |
| 642 | 688 | } |
| 643 | - if($w==0) |
|
| 644 | - $w=$this->w-$this->rMargin-$this->x; |
|
| 689 | + if($w==0) { |
|
| 690 | + $w=$this->w-$this->rMargin-$this->x; |
|
| 691 | + } |
|
| 645 | 692 | $s=''; |
| 646 | 693 | if($fill || $border==1) |
| 647 | 694 | { |
| 648 | - if($fill) |
|
| 649 | - $op=($border==1) ? 'B' : 'f'; |
|
| 650 | - else |
|
| 651 | - $op='S'; |
|
| 695 | + if($fill) { |
|
| 696 | + $op=($border==1) ? 'B' : 'f'; |
|
| 697 | + } else { |
|
| 698 | + $op='S'; |
|
| 699 | + } |
|
| 652 | 700 | $s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
| 653 | 701 | } |
| 654 | 702 | if(is_string($border)) |
| 655 | 703 | { |
| 656 | 704 | $x=$this->x; |
| 657 | 705 | $y=$this->y; |
| 658 | - if(strpos($border,'L')!==false) |
|
| 659 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
| 660 | - if(strpos($border,'T')!==false) |
|
| 661 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
| 662 | - if(strpos($border,'R')!==false) |
|
| 663 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 664 | - if(strpos($border,'B')!==false) |
|
| 665 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 706 | + if(strpos($border,'L')!==false) { |
|
| 707 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
| 708 | + } |
|
| 709 | + if(strpos($border,'T')!==false) { |
|
| 710 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
| 711 | + } |
|
| 712 | + if(strpos($border,'R')!==false) { |
|
| 713 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 714 | + } |
|
| 715 | + if(strpos($border,'B')!==false) { |
|
| 716 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 717 | + } |
|
| 666 | 718 | } |
| 667 | 719 | if($txt!=='') |
| 668 | 720 | { |
| 669 | - if($align=='R') |
|
| 670 | - $dx=$w-$this->cMargin-$this->GetStringWidth($txt); |
|
| 671 | - elseif($align=='C') |
|
| 672 | - $dx=($w-$this->GetStringWidth($txt))/2; |
|
| 673 | - else |
|
| 674 | - $dx=$this->cMargin; |
|
| 675 | - if($this->ColorFlag) |
|
| 676 | - $s.='q '.$this->TextColor.' '; |
|
| 721 | + if($align=='R') { |
|
| 722 | + $dx=$w-$this->cMargin-$this->GetStringWidth($txt); |
|
| 723 | + } elseif($align=='C') { |
|
| 724 | + $dx=($w-$this->GetStringWidth($txt))/2; |
|
| 725 | + } else { |
|
| 726 | + $dx=$this->cMargin; |
|
| 727 | + } |
|
| 728 | + if($this->ColorFlag) { |
|
| 729 | + $s.='q '.$this->TextColor.' '; |
|
| 730 | + } |
|
| 677 | 731 | $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); |
| 678 | 732 | $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); |
| 679 | - if($this->underline) |
|
| 680 | - $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
| 681 | - if($this->ColorFlag) |
|
| 682 | - $s.=' Q'; |
|
| 683 | - if($link) |
|
| 684 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
| 685 | - } |
|
| 686 | - if($s) |
|
| 687 | - $this->_out($s); |
|
| 733 | + if($this->underline) { |
|
| 734 | + $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
| 735 | + } |
|
| 736 | + if($this->ColorFlag) { |
|
| 737 | + $s.=' Q'; |
|
| 738 | + } |
|
| 739 | + if($link) { |
|
| 740 | + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
| 741 | + } |
|
| 742 | + } |
|
| 743 | + if($s) { |
|
| 744 | + $this->_out($s); |
|
| 745 | + } |
|
| 688 | 746 | $this->lasth=$h; |
| 689 | 747 | if($ln>0) |
| 690 | 748 | { |
| 691 | 749 | //Go to next line |
| 692 | 750 | $this->y+=$h; |
| 693 | - if($ln==1) |
|
| 694 | - $this->x=$this->lMargin; |
|
| 751 | + if($ln==1) { |
|
| 752 | + $this->x=$this->lMargin; |
|
| 753 | + } |
|
| 754 | + } else { |
|
| 755 | + $this->x+=$w; |
|
| 756 | + } |
|
| 695 | 757 | } |
| 696 | - else |
|
| 697 | - $this->x+=$w; |
|
| 698 | -} |
|
| 699 | 758 | |
| 700 | 759 | function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) |
| 701 | 760 | { |
| 702 | 761 | //Output text with automatic or explicit line breaks |
| 703 | 762 | $cw=&$this->CurrentFont['cw']; |
| 704 | - if($w==0) |
|
| 705 | - $w=$this->w-$this->rMargin-$this->x; |
|
| 763 | + if($w==0) { |
|
| 764 | + $w=$this->w-$this->rMargin-$this->x; |
|
| 765 | + } |
|
| 706 | 766 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
| 707 | 767 | $s=str_replace("\r",'',$txt); |
| 708 | 768 | $nb=strlen($s); |
| 709 | - if($nb>0 && $s[$nb-1]=="\n") |
|
| 710 | - $nb--; |
|
| 769 | + if($nb>0 && $s[$nb-1]=="\n") { |
|
| 770 | + $nb--; |
|
| 771 | + } |
|
| 711 | 772 | $b=0; |
| 712 | 773 | if($border) |
| 713 | 774 | { |
@@ -716,14 +777,15 @@ discard block |
||
| 716 | 777 | $border='LTRB'; |
| 717 | 778 | $b='LRT'; |
| 718 | 779 | $b2='LR'; |
| 719 | - } |
|
| 720 | - else |
|
| 780 | + } else |
|
| 721 | 781 | { |
| 722 | 782 | $b2=''; |
| 723 | - if(strpos($border,'L')!==false) |
|
| 724 | - $b2.='L'; |
|
| 725 | - if(strpos($border,'R')!==false) |
|
| 726 | - $b2.='R'; |
|
| 783 | + if(strpos($border,'L')!==false) { |
|
| 784 | + $b2.='L'; |
|
| 785 | + } |
|
| 786 | + if(strpos($border,'R')!==false) { |
|
| 787 | + $b2.='R'; |
|
| 788 | + } |
|
| 727 | 789 | $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2; |
| 728 | 790 | } |
| 729 | 791 | } |
@@ -752,8 +814,9 @@ discard block |
||
| 752 | 814 | $l=0; |
| 753 | 815 | $ns=0; |
| 754 | 816 | $nl++; |
| 755 | - if($border && $nl==2) |
|
| 756 | - $b=$b2; |
|
| 817 | + if($border && $nl==2) { |
|
| 818 | + $b=$b2; |
|
| 819 | + } |
|
| 757 | 820 | continue; |
| 758 | 821 | } |
| 759 | 822 | if($c==' ') |
@@ -768,16 +831,16 @@ discard block |
||
| 768 | 831 | //Automatic line break |
| 769 | 832 | if($sep==-1) |
| 770 | 833 | { |
| 771 | - if($i==$j) |
|
| 772 | - $i++; |
|
| 834 | + if($i==$j) { |
|
| 835 | + $i++; |
|
| 836 | + } |
|
| 773 | 837 | if($this->ws>0) |
| 774 | 838 | { |
| 775 | 839 | $this->ws=0; |
| 776 | 840 | $this->_out('0 Tw'); |
| 777 | 841 | } |
| 778 | 842 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
| 779 | - } |
|
| 780 | - else |
|
| 843 | + } else |
|
| 781 | 844 | { |
| 782 | 845 | if($align=='J') |
| 783 | 846 | { |
@@ -792,11 +855,12 @@ discard block |
||
| 792 | 855 | $l=0; |
| 793 | 856 | $ns=0; |
| 794 | 857 | $nl++; |
| 795 | - if($border && $nl==2) |
|
| 796 | - $b=$b2; |
|
| 858 | + if($border && $nl==2) { |
|
| 859 | + $b=$b2; |
|
| 860 | + } |
|
| 861 | + } else { |
|
| 862 | + $i++; |
|
| 797 | 863 | } |
| 798 | - else |
|
| 799 | - $i++; |
|
| 800 | 864 | } |
| 801 | 865 | //Last chunk |
| 802 | 866 | if($this->ws>0) |
@@ -804,8 +868,9 @@ discard block |
||
| 804 | 868 | $this->ws=0; |
| 805 | 869 | $this->_out('0 Tw'); |
| 806 | 870 | } |
| 807 | - if($border && strpos($border,'B')!==false) |
|
| 808 | - $b.='B'; |
|
| 871 | + if($border && strpos($border,'B')!==false) { |
|
| 872 | + $b.='B'; |
|
| 873 | + } |
|
| 809 | 874 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
| 810 | 875 | $this->x=$this->lMargin; |
| 811 | 876 | } |
@@ -844,8 +909,9 @@ discard block |
||
| 844 | 909 | $nl++; |
| 845 | 910 | continue; |
| 846 | 911 | } |
| 847 | - if($c==' ') |
|
| 848 | - $sep=$i; |
|
| 912 | + if($c==' ') { |
|
| 913 | + $sep=$i; |
|
| 914 | + } |
|
| 849 | 915 | $l+=$cw[$c]; |
| 850 | 916 | if($l>$wmax) |
| 851 | 917 | { |
@@ -863,11 +929,11 @@ discard block |
||
| 863 | 929 | $nl++; |
| 864 | 930 | continue; |
| 865 | 931 | } |
| 866 | - if($i==$j) |
|
| 867 | - $i++; |
|
| 932 | + if($i==$j) { |
|
| 933 | + $i++; |
|
| 934 | + } |
|
| 868 | 935 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
| 869 | - } |
|
| 870 | - else |
|
| 936 | + } else |
|
| 871 | 937 | { |
| 872 | 938 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); |
| 873 | 939 | $i=$sep+1; |
@@ -882,24 +948,26 @@ discard block |
||
| 882 | 948 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
| 883 | 949 | } |
| 884 | 950 | $nl++; |
| 951 | + } else { |
|
| 952 | + $i++; |
|
| 885 | 953 | } |
| 886 | - else |
|
| 887 | - $i++; |
|
| 888 | 954 | } |
| 889 | 955 | //Last chunk |
| 890 | - if($i!=$j) |
|
| 891 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); |
|
| 892 | -} |
|
| 956 | + if($i!=$j) { |
|
| 957 | + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); |
|
| 958 | + } |
|
| 959 | + } |
|
| 893 | 960 | |
| 894 | 961 | function Ln($h=null) |
| 895 | 962 | { |
| 896 | 963 | //Line feed; default value is last cell height |
| 897 | 964 | $this->x=$this->lMargin; |
| 898 | - if($h===null) |
|
| 899 | - $this->y+=$this->lasth; |
|
| 900 | - else |
|
| 901 | - $this->y+=$h; |
|
| 902 | -} |
|
| 965 | + if($h===null) { |
|
| 966 | + $this->y+=$this->lasth; |
|
| 967 | + } else { |
|
| 968 | + $this->y+=$h; |
|
| 969 | + } |
|
| 970 | + } |
|
| 903 | 971 | |
| 904 | 972 | function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') |
| 905 | 973 | { |
@@ -910,33 +978,36 @@ discard block |
||
| 910 | 978 | if($type=='') |
| 911 | 979 | { |
| 912 | 980 | $pos=strrpos($file,'.'); |
| 913 | - if(!$pos) |
|
| 914 | - $this->Error('Image file has no extension and no type was specified: '.$file); |
|
| 981 | + if(!$pos) { |
|
| 982 | + $this->Error('Image file has no extension and no type was specified: '.$file); |
|
| 983 | + } |
|
| 915 | 984 | $type=substr($file,$pos+1); |
| 916 | 985 | } |
| 917 | 986 | $type=strtolower($type); |
| 918 | - if($type=='jpeg') |
|
| 919 | - $type='jpg'; |
|
| 987 | + if($type=='jpeg') { |
|
| 988 | + $type='jpg'; |
|
| 989 | + } |
|
| 920 | 990 | $mtd='_parse'.$type; |
| 921 | - if(!method_exists($this,$mtd)) |
|
| 922 | - $this->Error('Unsupported image type: '.$type); |
|
| 991 | + if(!method_exists($this,$mtd)) { |
|
| 992 | + $this->Error('Unsupported image type: '.$type); |
|
| 993 | + } |
|
| 923 | 994 | $info=$this->$mtd($file); |
| 924 | 995 | $info['i']=count($this->images)+1; |
| 925 | 996 | $this->images[$file]=$info; |
| 997 | + } else { |
|
| 998 | + $info=$this->images[$file]; |
|
| 926 | 999 | } |
| 927 | - else |
|
| 928 | - $info=$this->images[$file]; |
|
| 929 | 1000 | //Automatic width and height calculation if needed |
| 930 | 1001 | if($w==0 && $h==0) |
| 931 | 1002 | { |
| 932 | 1003 | //Put image at 72 dpi |
| 933 | 1004 | $w=$info['w']/$this->k; |
| 934 | 1005 | $h=$info['h']/$this->k; |
| 1006 | + } elseif($w==0) { |
|
| 1007 | + $w=$h*$info['w']/$info['h']; |
|
| 1008 | + } elseif($h==0) { |
|
| 1009 | + $h=$w*$info['h']/$info['w']; |
|
| 935 | 1010 | } |
| 936 | - elseif($w==0) |
|
| 937 | - $w=$h*$info['w']/$info['h']; |
|
| 938 | - elseif($h==0) |
|
| 939 | - $h=$w*$info['h']/$info['w']; |
|
| 940 | 1011 | //Flowing mode |
| 941 | 1012 | if($y===null) |
| 942 | 1013 | { |
@@ -950,12 +1021,14 @@ discard block |
||
| 950 | 1021 | $y=$this->y; |
| 951 | 1022 | $this->y+=$h; |
| 952 | 1023 | } |
| 953 | - if($x===null) |
|
| 954 | - $x=$this->x; |
|
| 1024 | + if($x===null) { |
|
| 1025 | + $x=$this->x; |
|
| 1026 | + } |
|
| 955 | 1027 | $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i'])); |
| 956 | - if($link) |
|
| 957 | - $this->Link($x,$y,$w,$h,$link); |
|
| 958 | -} |
|
| 1028 | + if($link) { |
|
| 1029 | + $this->Link($x,$y,$w,$h,$link); |
|
| 1030 | + } |
|
| 1031 | + } |
|
| 959 | 1032 | |
| 960 | 1033 | function GetX() |
| 961 | 1034 | { |
@@ -966,11 +1039,12 @@ discard block |
||
| 966 | 1039 | function SetX($x) |
| 967 | 1040 | { |
| 968 | 1041 | //Set x position |
| 969 | - if($x>=0) |
|
| 970 | - $this->x=$x; |
|
| 971 | - else |
|
| 972 | - $this->x=$this->w+$x; |
|
| 973 | -} |
|
| 1042 | + if($x>=0) { |
|
| 1043 | + $this->x=$x; |
|
| 1044 | + } else { |
|
| 1045 | + $this->x=$this->w+$x; |
|
| 1046 | + } |
|
| 1047 | + } |
|
| 974 | 1048 | |
| 975 | 1049 | function GetY() |
| 976 | 1050 | { |
@@ -982,11 +1056,12 @@ discard block |
||
| 982 | 1056 | { |
| 983 | 1057 | //Set y position and reset x |
| 984 | 1058 | $this->x=$this->lMargin; |
| 985 | - if($y>=0) |
|
| 986 | - $this->y=$y; |
|
| 987 | - else |
|
| 988 | - $this->y=$this->h+$y; |
|
| 989 | -} |
|
| 1059 | + if($y>=0) { |
|
| 1060 | + $this->y=$y; |
|
| 1061 | + } else { |
|
| 1062 | + $this->y=$this->h+$y; |
|
| 1063 | + } |
|
| 1064 | + } |
|
| 990 | 1065 | |
| 991 | 1066 | function SetXY($x, $y) |
| 992 | 1067 | { |
@@ -998,8 +1073,9 @@ discard block |
||
| 998 | 1073 | function Output($name='', $dest='') |
| 999 | 1074 | { |
| 1000 | 1075 | //Output PDF to some destination |
| 1001 | - if($this->state<3) |
|
| 1002 | - $this->Close(); |
|
| 1076 | + if($this->state<3) { |
|
| 1077 | + $this->Close(); |
|
| 1078 | + } |
|
| 1003 | 1079 | $dest=strtoupper($dest); |
| 1004 | 1080 | if($dest=='') |
| 1005 | 1081 | { |
@@ -1007,22 +1083,24 @@ discard block |
||
| 1007 | 1083 | { |
| 1008 | 1084 | $name='doc.pdf'; |
| 1009 | 1085 | $dest='I'; |
| 1086 | + } else { |
|
| 1087 | + $dest='F'; |
|
| 1010 | 1088 | } |
| 1011 | - else |
|
| 1012 | - $dest='F'; |
|
| 1013 | 1089 | } |
| 1014 | 1090 | switch($dest) |
| 1015 | 1091 | { |
| 1016 | 1092 | case 'I': |
| 1017 | 1093 | //Send to standard output |
| 1018 | - if(ob_get_length()) |
|
| 1019 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1094 | + if(ob_get_length()) { |
|
| 1095 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1096 | + } |
|
| 1020 | 1097 | if(php_sapi_name()!='cli') |
| 1021 | 1098 | { |
| 1022 | 1099 | //We send to a browser |
| 1023 | 1100 | header('Content-Type: application/pdf'); |
| 1024 | - if(headers_sent()) |
|
| 1025 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1101 | + if(headers_sent()) { |
|
| 1102 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1103 | + } |
|
| 1026 | 1104 | header('Content-Length: '.strlen($this->buffer)); |
| 1027 | 1105 | header('Content-Disposition: inline; filename="'.$name.'"'); |
| 1028 | 1106 | header('Cache-Control: private, max-age=0, must-revalidate'); |
@@ -1033,11 +1111,13 @@ discard block |
||
| 1033 | 1111 | break; |
| 1034 | 1112 | case 'D': |
| 1035 | 1113 | //Download file |
| 1036 | - if(ob_get_length()) |
|
| 1037 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1114 | + if(ob_get_length()) { |
|
| 1115 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1116 | + } |
|
| 1038 | 1117 | header('Content-Type: application/x-download'); |
| 1039 | - if(headers_sent()) |
|
| 1040 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1118 | + if(headers_sent()) { |
|
| 1119 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1120 | + } |
|
| 1041 | 1121 | header('Content-Length: '.strlen($this->buffer)); |
| 1042 | 1122 | header('Content-Disposition: attachment; filename="'.$name.'"'); |
| 1043 | 1123 | header('Cache-Control: private, max-age=0, must-revalidate'); |
@@ -1048,8 +1128,9 @@ discard block |
||
| 1048 | 1128 | case 'F': |
| 1049 | 1129 | //Save to local file |
| 1050 | 1130 | $f=fopen($name,'wb'); |
| 1051 | - if(!$f) |
|
| 1052 | - $this->Error('Unable to create output file: '.$name); |
|
| 1131 | + if(!$f) { |
|
| 1132 | + $this->Error('Unable to create output file: '.$name); |
|
| 1133 | + } |
|
| 1053 | 1134 | fwrite($f,$this->buffer,strlen($this->buffer)); |
| 1054 | 1135 | fclose($f); |
| 1055 | 1136 | break; |
@@ -1070,29 +1151,34 @@ discard block |
||
| 1070 | 1151 | function _dochecks() |
| 1071 | 1152 | { |
| 1072 | 1153 | //Check availability of %F |
| 1073 | - if(sprintf('%.1F',1.0)!='1.0') |
|
| 1074 | - $this->Error('This version of PHP is not supported'); |
|
| 1154 | + if(sprintf('%.1F',1.0)!='1.0') { |
|
| 1155 | + $this->Error('This version of PHP is not supported'); |
|
| 1156 | + } |
|
| 1075 | 1157 | //Check mbstring overloading |
| 1076 | - if(ini_get('mbstring.func_overload') & 2) |
|
| 1077 | - $this->Error('mbstring overloading must be disabled'); |
|
| 1158 | + if(ini_get('mbstring.func_overload') & 2) { |
|
| 1159 | + $this->Error('mbstring overloading must be disabled'); |
|
| 1160 | + } |
|
| 1078 | 1161 | //Disable runtime magic quotes |
| 1079 | - if(get_magic_quotes_runtime()) |
|
| 1080 | - @set_magic_quotes_runtime(0); |
|
| 1081 | -} |
|
| 1162 | + if(get_magic_quotes_runtime()) { |
|
| 1163 | + @set_magic_quotes_runtime(0); |
|
| 1164 | + } |
|
| 1165 | + } |
|
| 1082 | 1166 | |
| 1083 | 1167 | function _getpageformat($format) |
| 1084 | 1168 | { |
| 1085 | 1169 | $format=strtolower($format); |
| 1086 | - if(!isset($this->PageFormats[$format])) |
|
| 1087 | - $this->Error('Unknown page format: '.$format); |
|
| 1170 | + if(!isset($this->PageFormats[$format])) { |
|
| 1171 | + $this->Error('Unknown page format: '.$format); |
|
| 1172 | + } |
|
| 1088 | 1173 | $a=$this->PageFormats[$format]; |
| 1089 | 1174 | return array($a[0]/$this->k, $a[1]/$this->k); |
| 1090 | 1175 | } |
| 1091 | 1176 | |
| 1092 | 1177 | function _getfontpath() |
| 1093 | 1178 | { |
| 1094 | - if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) |
|
| 1095 | - define('FPDF_FONTPATH',dirname(__FILE__).'/font/'); |
|
| 1179 | + if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) { |
|
| 1180 | + define('FPDF_FONTPATH',dirname(__FILE__).'/font/'); |
|
| 1181 | + } |
|
| 1096 | 1182 | return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : ''; |
| 1097 | 1183 | } |
| 1098 | 1184 | |
@@ -1105,16 +1191,18 @@ discard block |
||
| 1105 | 1191 | $this->y=$this->tMargin; |
| 1106 | 1192 | $this->FontFamily=''; |
| 1107 | 1193 | //Check page size |
| 1108 | - if($orientation=='') |
|
| 1109 | - $orientation=$this->DefOrientation; |
|
| 1110 | - else |
|
| 1111 | - $orientation=strtoupper($orientation[0]); |
|
| 1112 | - if($format=='') |
|
| 1113 | - $format=$this->DefPageFormat; |
|
| 1114 | - else |
|
| 1194 | + if($orientation=='') { |
|
| 1195 | + $orientation=$this->DefOrientation; |
|
| 1196 | + } else { |
|
| 1197 | + $orientation=strtoupper($orientation[0]); |
|
| 1198 | + } |
|
| 1199 | + if($format=='') { |
|
| 1200 | + $format=$this->DefPageFormat; |
|
| 1201 | + } else |
|
| 1115 | 1202 | { |
| 1116 | - if(is_string($format)) |
|
| 1117 | - $format=$this->_getpageformat($format); |
|
| 1203 | + if(is_string($format)) { |
|
| 1204 | + $format=$this->_getpageformat($format); |
|
| 1205 | + } |
|
| 1118 | 1206 | } |
| 1119 | 1207 | if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) |
| 1120 | 1208 | { |
@@ -1123,8 +1211,7 @@ discard block |
||
| 1123 | 1211 | { |
| 1124 | 1212 | $this->w=$format[0]; |
| 1125 | 1213 | $this->h=$format[1]; |
| 1126 | - } |
|
| 1127 | - else |
|
| 1214 | + } else |
|
| 1128 | 1215 | { |
| 1129 | 1216 | $this->w=$format[1]; |
| 1130 | 1217 | $this->h=$format[0]; |
@@ -1135,9 +1222,10 @@ discard block |
||
| 1135 | 1222 | $this->CurOrientation=$orientation; |
| 1136 | 1223 | $this->CurPageFormat=$format; |
| 1137 | 1224 | } |
| 1138 | - if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) |
|
| 1139 | - $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); |
|
| 1140 | -} |
|
| 1225 | + if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) { |
|
| 1226 | + $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); |
|
| 1227 | + } |
|
| 1228 | + } |
|
| 1141 | 1229 | |
| 1142 | 1230 | function _endpage() |
| 1143 | 1231 | { |
@@ -1176,15 +1264,13 @@ discard block |
||
| 1176 | 1264 | $c3=ord($s[$i++]); |
| 1177 | 1265 | $res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
| 1178 | 1266 | $res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
| 1179 | - } |
|
| 1180 | - elseif($c1>=192) |
|
| 1267 | + } elseif($c1>=192) |
|
| 1181 | 1268 | { |
| 1182 | 1269 | //2-byte character |
| 1183 | 1270 | $c2=ord($s[$i++]); |
| 1184 | 1271 | $res.=chr(($c1 & 0x1C)>>2); |
| 1185 | 1272 | $res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
| 1186 | - } |
|
| 1187 | - else |
|
| 1273 | + } else |
|
| 1188 | 1274 | { |
| 1189 | 1275 | //Single-byte character |
| 1190 | 1276 | $res.="\0".chr($c1); |
@@ -1206,22 +1292,26 @@ discard block |
||
| 1206 | 1292 | { |
| 1207 | 1293 | //Extract info from a JPEG file |
| 1208 | 1294 | $a=GetImageSize($file); |
| 1209 | - if(!$a) |
|
| 1210 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1211 | - if($a[2]!=2) |
|
| 1212 | - $this->Error('Not a JPEG file: '.$file); |
|
| 1213 | - if(!isset($a['channels']) || $a['channels']==3) |
|
| 1214 | - $colspace='DeviceRGB'; |
|
| 1215 | - elseif($a['channels']==4) |
|
| 1216 | - $colspace='DeviceCMYK'; |
|
| 1217 | - else |
|
| 1218 | - $colspace='DeviceGray'; |
|
| 1295 | + if(!$a) { |
|
| 1296 | + $this->Error('Missing or incorrect image file: '.$file); |
|
| 1297 | + } |
|
| 1298 | + if($a[2]!=2) { |
|
| 1299 | + $this->Error('Not a JPEG file: '.$file); |
|
| 1300 | + } |
|
| 1301 | + if(!isset($a['channels']) || $a['channels']==3) { |
|
| 1302 | + $colspace='DeviceRGB'; |
|
| 1303 | + } elseif($a['channels']==4) { |
|
| 1304 | + $colspace='DeviceCMYK'; |
|
| 1305 | + } else { |
|
| 1306 | + $colspace='DeviceGray'; |
|
| 1307 | + } |
|
| 1219 | 1308 | $bpc=isset($a['bits']) ? $a['bits'] : 8; |
| 1220 | 1309 | //Read whole file |
| 1221 | 1310 | $f=fopen($file,'rb'); |
| 1222 | 1311 | $data=''; |
| 1223 | - while(!feof($f)) |
|
| 1224 | - $data.=fread($f,8192); |
|
| 1312 | + while(!feof($f)) { |
|
| 1313 | + $data.=fread($f,8192); |
|
| 1314 | + } |
|
| 1225 | 1315 | fclose($f); |
| 1226 | 1316 | return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); |
| 1227 | 1317 | } |
@@ -1230,35 +1320,43 @@ discard block |
||
| 1230 | 1320 | { |
| 1231 | 1321 | //Extract info from a PNG file |
| 1232 | 1322 | $f=fopen($file,'rb'); |
| 1233 | - if(!$f) |
|
| 1234 | - $this->Error('Can\'t open image file: '.$file); |
|
| 1323 | + if(!$f) { |
|
| 1324 | + $this->Error('Can\'t open image file: '.$file); |
|
| 1325 | + } |
|
| 1235 | 1326 | //Check signature |
| 1236 | - if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
| 1237 | - $this->Error('Not a PNG file: '.$file); |
|
| 1327 | + if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { |
|
| 1328 | + $this->Error('Not a PNG file: '.$file); |
|
| 1329 | + } |
|
| 1238 | 1330 | //Read header chunk |
| 1239 | 1331 | $this->_readstream($f,4); |
| 1240 | - if($this->_readstream($f,4)!='IHDR') |
|
| 1241 | - $this->Error('Incorrect PNG file: '.$file); |
|
| 1332 | + if($this->_readstream($f,4)!='IHDR') { |
|
| 1333 | + $this->Error('Incorrect PNG file: '.$file); |
|
| 1334 | + } |
|
| 1242 | 1335 | $w=$this->_readint($f); |
| 1243 | 1336 | $h=$this->_readint($f); |
| 1244 | 1337 | $bpc=ord($this->_readstream($f,1)); |
| 1245 | - if($bpc>8) |
|
| 1246 | - $this->Error('16-bit depth not supported: '.$file); |
|
| 1338 | + if($bpc>8) { |
|
| 1339 | + $this->Error('16-bit depth not supported: '.$file); |
|
| 1340 | + } |
|
| 1247 | 1341 | $ct=ord($this->_readstream($f,1)); |
| 1248 | - if($ct==0) |
|
| 1249 | - $colspace='DeviceGray'; |
|
| 1250 | - elseif($ct==2) |
|
| 1251 | - $colspace='DeviceRGB'; |
|
| 1252 | - elseif($ct==3) |
|
| 1253 | - $colspace='Indexed'; |
|
| 1254 | - else |
|
| 1255 | - $this->Error('Alpha channel not supported: '.$file); |
|
| 1256 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1257 | - $this->Error('Unknown compression method: '.$file); |
|
| 1258 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1259 | - $this->Error('Unknown filter method: '.$file); |
|
| 1260 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1261 | - $this->Error('Interlacing not supported: '.$file); |
|
| 1342 | + if($ct==0) { |
|
| 1343 | + $colspace='DeviceGray'; |
|
| 1344 | + } elseif($ct==2) { |
|
| 1345 | + $colspace='DeviceRGB'; |
|
| 1346 | + } elseif($ct==3) { |
|
| 1347 | + $colspace='Indexed'; |
|
| 1348 | + } else { |
|
| 1349 | + $this->Error('Alpha channel not supported: '.$file); |
|
| 1350 | + } |
|
| 1351 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1352 | + $this->Error('Unknown compression method: '.$file); |
|
| 1353 | + } |
|
| 1354 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1355 | + $this->Error('Unknown filter method: '.$file); |
|
| 1356 | + } |
|
| 1357 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1358 | + $this->Error('Interlacing not supported: '.$file); |
|
| 1359 | + } |
|
| 1262 | 1360 | $this->_readstream($f,4); |
| 1263 | 1361 | $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>'; |
| 1264 | 1362 | //Scan chunks looking for palette, transparency and image data |
@@ -1274,37 +1372,37 @@ discard block |
||
| 1274 | 1372 | //Read palette |
| 1275 | 1373 | $pal=$this->_readstream($f,$n); |
| 1276 | 1374 | $this->_readstream($f,4); |
| 1277 | - } |
|
| 1278 | - elseif($type=='tRNS') |
|
| 1375 | + } elseif($type=='tRNS') |
|
| 1279 | 1376 | { |
| 1280 | 1377 | //Read transparency info |
| 1281 | 1378 | $t=$this->_readstream($f,$n); |
| 1282 | - if($ct==0) |
|
| 1283 | - $trns=array(ord(substr($t,1,1))); |
|
| 1284 | - elseif($ct==2) |
|
| 1285 | - $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1286 | - else |
|
| 1379 | + if($ct==0) { |
|
| 1380 | + $trns=array(ord(substr($t,1,1))); |
|
| 1381 | + } elseif($ct==2) { |
|
| 1382 | + $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1383 | + } else |
|
| 1287 | 1384 | { |
| 1288 | 1385 | $pos=strpos($t,chr(0)); |
| 1289 | - if($pos!==false) |
|
| 1290 | - $trns=array($pos); |
|
| 1386 | + if($pos!==false) { |
|
| 1387 | + $trns=array($pos); |
|
| 1388 | + } |
|
| 1291 | 1389 | } |
| 1292 | 1390 | $this->_readstream($f,4); |
| 1293 | - } |
|
| 1294 | - elseif($type=='IDAT') |
|
| 1391 | + } elseif($type=='IDAT') |
|
| 1295 | 1392 | { |
| 1296 | 1393 | //Read image data block |
| 1297 | 1394 | $data.=$this->_readstream($f,$n); |
| 1298 | 1395 | $this->_readstream($f,4); |
| 1396 | + } elseif($type=='IEND') { |
|
| 1397 | + break; |
|
| 1398 | + } else { |
|
| 1399 | + $this->_readstream($f,$n+4); |
|
| 1299 | 1400 | } |
| 1300 | - elseif($type=='IEND') |
|
| 1301 | - break; |
|
| 1302 | - else |
|
| 1303 | - $this->_readstream($f,$n+4); |
|
| 1304 | 1401 | } |
| 1305 | 1402 | while($n); |
| 1306 | - if($colspace=='Indexed' && empty($pal)) |
|
| 1307 | - $this->Error('Missing palette in '.$file); |
|
| 1403 | + if($colspace=='Indexed' && empty($pal)) { |
|
| 1404 | + $this->Error('Missing palette in '.$file); |
|
| 1405 | + } |
|
| 1308 | 1406 | fclose($f); |
| 1309 | 1407 | return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data); |
| 1310 | 1408 | } |
@@ -1316,13 +1414,15 @@ discard block |
||
| 1316 | 1414 | while($n>0 && !feof($f)) |
| 1317 | 1415 | { |
| 1318 | 1416 | $s=fread($f,$n); |
| 1319 | - if($s===false) |
|
| 1320 | - $this->Error('Error while reading stream'); |
|
| 1417 | + if($s===false) { |
|
| 1418 | + $this->Error('Error while reading stream'); |
|
| 1419 | + } |
|
| 1321 | 1420 | $n-=strlen($s); |
| 1322 | 1421 | $res.=$s; |
| 1323 | 1422 | } |
| 1324 | - if($n>0) |
|
| 1325 | - $this->Error('Unexpected end of stream'); |
|
| 1423 | + if($n>0) { |
|
| 1424 | + $this->Error('Unexpected end of stream'); |
|
| 1425 | + } |
|
| 1326 | 1426 | return $res; |
| 1327 | 1427 | } |
| 1328 | 1428 | |
@@ -1336,19 +1436,24 @@ discard block |
||
| 1336 | 1436 | function _parsegif($file) |
| 1337 | 1437 | { |
| 1338 | 1438 | //Extract info from a GIF file (via PNG conversion) |
| 1339 | - if(!function_exists('imagepng')) |
|
| 1340 | - $this->Error('GD extension is required for GIF support'); |
|
| 1341 | - if(!function_exists('imagecreatefromgif')) |
|
| 1342 | - $this->Error('GD has no GIF read support'); |
|
| 1439 | + if(!function_exists('imagepng')) { |
|
| 1440 | + $this->Error('GD extension is required for GIF support'); |
|
| 1441 | + } |
|
| 1442 | + if(!function_exists('imagecreatefromgif')) { |
|
| 1443 | + $this->Error('GD has no GIF read support'); |
|
| 1444 | + } |
|
| 1343 | 1445 | $im=imagecreatefromgif($file); |
| 1344 | - if(!$im) |
|
| 1345 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1446 | + if(!$im) { |
|
| 1447 | + $this->Error('Missing or incorrect image file: '.$file); |
|
| 1448 | + } |
|
| 1346 | 1449 | imageinterlace($im,0); |
| 1347 | 1450 | $tmp=tempnam('.','gif'); |
| 1348 | - if(!$tmp) |
|
| 1349 | - $this->Error('Unable to create a temporary file'); |
|
| 1350 | - if(!imagepng($im,$tmp)) |
|
| 1351 | - $this->Error('Error while saving to temporary file'); |
|
| 1451 | + if(!$tmp) { |
|
| 1452 | + $this->Error('Unable to create a temporary file'); |
|
| 1453 | + } |
|
| 1454 | + if(!imagepng($im,$tmp)) { |
|
| 1455 | + $this->Error('Error while saving to temporary file'); |
|
| 1456 | + } |
|
| 1352 | 1457 | imagedestroy($im); |
| 1353 | 1458 | $info=$this->_parsepng($tmp); |
| 1354 | 1459 | unlink($tmp); |
@@ -1373,11 +1478,12 @@ discard block |
||
| 1373 | 1478 | function _out($s) |
| 1374 | 1479 | { |
| 1375 | 1480 | //Add a line to the document |
| 1376 | - if($this->state==2) |
|
| 1377 | - $this->pages[$this->page].=$s."\n"; |
|
| 1378 | - else |
|
| 1379 | - $this->buffer.=$s."\n"; |
|
| 1380 | -} |
|
| 1481 | + if($this->state==2) { |
|
| 1482 | + $this->pages[$this->page].=$s."\n"; |
|
| 1483 | + } else { |
|
| 1484 | + $this->buffer.=$s."\n"; |
|
| 1485 | + } |
|
| 1486 | + } |
|
| 1381 | 1487 | |
| 1382 | 1488 | function _putpages() |
| 1383 | 1489 | { |
@@ -1385,15 +1491,15 @@ discard block |
||
| 1385 | 1491 | if(!empty($this->AliasNbPages)) |
| 1386 | 1492 | { |
| 1387 | 1493 | //Replace number of pages |
| 1388 | - for($n=1;$n<=$nb;$n++) |
|
| 1389 | - $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]); |
|
| 1494 | + for($n=1;$n<=$nb;$n++) { |
|
| 1495 | + $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]); |
|
| 1496 | + } |
|
| 1390 | 1497 | } |
| 1391 | 1498 | if($this->DefOrientation=='P') |
| 1392 | 1499 | { |
| 1393 | 1500 | $wPt=$this->DefPageFormat[0]*$this->k; |
| 1394 | 1501 | $hPt=$this->DefPageFormat[1]*$this->k; |
| 1395 | - } |
|
| 1396 | - else |
|
| 1502 | + } else |
|
| 1397 | 1503 | { |
| 1398 | 1504 | $wPt=$this->DefPageFormat[1]*$this->k; |
| 1399 | 1505 | $hPt=$this->DefPageFormat[0]*$this->k; |
@@ -1405,8 +1511,9 @@ discard block |
||
| 1405 | 1511 | $this->_newobj(); |
| 1406 | 1512 | $this->_out('<</Type /Page'); |
| 1407 | 1513 | $this->_out('/Parent 1 0 R'); |
| 1408 | - if(isset($this->PageSizes[$n])) |
|
| 1409 | - $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); |
|
| 1514 | + if(isset($this->PageSizes[$n])) { |
|
| 1515 | + $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); |
|
| 1516 | + } |
|
| 1410 | 1517 | $this->_out('/Resources 2 0 R'); |
| 1411 | 1518 | if(isset($this->PageLinks[$n])) |
| 1412 | 1519 | { |
@@ -1416,9 +1523,9 @@ discard block |
||
| 1416 | 1523 | { |
| 1417 | 1524 | $rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); |
| 1418 | 1525 | $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
| 1419 | - if(is_string($pl[4])) |
|
| 1420 | - $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1421 | - else |
|
| 1526 | + if(is_string($pl[4])) { |
|
| 1527 | + $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1528 | + } else |
|
| 1422 | 1529 | { |
| 1423 | 1530 | $l=$this->links[$pl[4]]; |
| 1424 | 1531 | $h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; |
@@ -1441,8 +1548,9 @@ discard block |
||
| 1441 | 1548 | $this->_out('1 0 obj'); |
| 1442 | 1549 | $this->_out('<</Type /Pages'); |
| 1443 | 1550 | $kids='/Kids ['; |
| 1444 | - for($i=0;$i<$nb;$i++) |
|
| 1445 | - $kids.=(3+2*$i).' 0 R '; |
|
| 1551 | + for($i=0;$i<$nb;$i++) { |
|
| 1552 | + $kids.=(3+2*$i).' 0 R '; |
|
| 1553 | + } |
|
| 1446 | 1554 | $this->_out($kids.']'); |
| 1447 | 1555 | $this->_out('/Count '.$nb); |
| 1448 | 1556 | $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt)); |
@@ -1467,10 +1575,12 @@ discard block |
||
| 1467 | 1575 | $this->FontFiles[$file]['n']=$this->n; |
| 1468 | 1576 | $font=''; |
| 1469 | 1577 | $f=fopen($this->_getfontpath().$file,'rb',1); |
| 1470 | - if(!$f) |
|
| 1471 | - $this->Error('Font file not found'); |
|
| 1472 | - while(!feof($f)) |
|
| 1473 | - $font.=fread($f,8192); |
|
| 1578 | + if(!$f) { |
|
| 1579 | + $this->Error('Font file not found'); |
|
| 1580 | + } |
|
| 1581 | + while(!feof($f)) { |
|
| 1582 | + $font.=fread($f,8192); |
|
| 1583 | + } |
|
| 1474 | 1584 | fclose($f); |
| 1475 | 1585 | $compressed=(substr($file,-2)=='.z'); |
| 1476 | 1586 | if(!$compressed && isset($info['length2'])) |
@@ -1488,11 +1598,13 @@ discard block |
||
| 1488 | 1598 | } |
| 1489 | 1599 | } |
| 1490 | 1600 | $this->_out('<</Length '.strlen($font)); |
| 1491 | - if($compressed) |
|
| 1492 | - $this->_out('/Filter /FlateDecode'); |
|
| 1601 | + if($compressed) { |
|
| 1602 | + $this->_out('/Filter /FlateDecode'); |
|
| 1603 | + } |
|
| 1493 | 1604 | $this->_out('/Length1 '.$info['length1']); |
| 1494 | - if(isset($info['length2'])) |
|
| 1495 | - $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1605 | + if(isset($info['length2'])) { |
|
| 1606 | + $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1607 | + } |
|
| 1496 | 1608 | $this->_out('>>'); |
| 1497 | 1609 | $this->_putstream($font); |
| 1498 | 1610 | $this->_out('endobj'); |
@@ -1510,12 +1622,12 @@ discard block |
||
| 1510 | 1622 | $this->_out('<</Type /Font'); |
| 1511 | 1623 | $this->_out('/BaseFont /'.$name); |
| 1512 | 1624 | $this->_out('/Subtype /Type1'); |
| 1513 | - if($name!='Symbol' && $name!='ZapfDingbats') |
|
| 1514 | - $this->_out('/Encoding /WinAnsiEncoding'); |
|
| 1625 | + if($name!='Symbol' && $name!='ZapfDingbats') { |
|
| 1626 | + $this->_out('/Encoding /WinAnsiEncoding'); |
|
| 1627 | + } |
|
| 1515 | 1628 | $this->_out('>>'); |
| 1516 | 1629 | $this->_out('endobj'); |
| 1517 | - } |
|
| 1518 | - elseif($type=='Type1' || $type=='TrueType') |
|
| 1630 | + } elseif($type=='Type1' || $type=='TrueType') |
|
| 1519 | 1631 | { |
| 1520 | 1632 | //Additional Type1 or TrueType font |
| 1521 | 1633 | $this->_newobj(); |
@@ -1527,10 +1639,11 @@ discard block |
||
| 1527 | 1639 | $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); |
| 1528 | 1640 | if($font['enc']) |
| 1529 | 1641 | { |
| 1530 | - if(isset($font['diff'])) |
|
| 1531 | - $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); |
|
| 1532 | - else |
|
| 1533 | - $this->_out('/Encoding /WinAnsiEncoding'); |
|
| 1642 | + if(isset($font['diff'])) { |
|
| 1643 | + $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); |
|
| 1644 | + } else { |
|
| 1645 | + $this->_out('/Encoding /WinAnsiEncoding'); |
|
| 1646 | + } |
|
| 1534 | 1647 | } |
| 1535 | 1648 | $this->_out('>>'); |
| 1536 | 1649 | $this->_out('endobj'); |
@@ -1538,27 +1651,30 @@ discard block |
||
| 1538 | 1651 | $this->_newobj(); |
| 1539 | 1652 | $cw=&$font['cw']; |
| 1540 | 1653 | $s='['; |
| 1541 | - for($i=32;$i<=255;$i++) |
|
| 1542 | - $s.=$cw[chr($i)].' '; |
|
| 1654 | + for($i=32;$i<=255;$i++) { |
|
| 1655 | + $s.=$cw[chr($i)].' '; |
|
| 1656 | + } |
|
| 1543 | 1657 | $this->_out($s.']'); |
| 1544 | 1658 | $this->_out('endobj'); |
| 1545 | 1659 | //Descriptor |
| 1546 | 1660 | $this->_newobj(); |
| 1547 | 1661 | $s='<</Type /FontDescriptor /FontName /'.$name; |
| 1548 | - foreach($font['desc'] as $k=>$v) |
|
| 1549 | - $s.=' /'.$k.' '.$v; |
|
| 1662 | + foreach($font['desc'] as $k=>$v) { |
|
| 1663 | + $s.=' /'.$k.' '.$v; |
|
| 1664 | + } |
|
| 1550 | 1665 | $file=$font['file']; |
| 1551 | - if($file) |
|
| 1552 | - $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
|
| 1666 | + if($file) { |
|
| 1667 | + $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
|
| 1668 | + } |
|
| 1553 | 1669 | $this->_out($s.'>>'); |
| 1554 | 1670 | $this->_out('endobj'); |
| 1555 | - } |
|
| 1556 | - else |
|
| 1671 | + } else |
|
| 1557 | 1672 | { |
| 1558 | 1673 | //Allow for additional types |
| 1559 | 1674 | $mtd='_put'.strtolower($type); |
| 1560 | - if(!method_exists($this,$mtd)) |
|
| 1561 | - $this->Error('Unsupported font type: '.$type); |
|
| 1675 | + if(!method_exists($this,$mtd)) { |
|
| 1676 | + $this->Error('Unsupported font type: '.$type); |
|
| 1677 | + } |
|
| 1562 | 1678 | $this->$mtd($font); |
| 1563 | 1679 | } |
| 1564 | 1680 | } |
@@ -1576,24 +1692,28 @@ discard block |
||
| 1576 | 1692 | $this->_out('/Subtype /Image'); |
| 1577 | 1693 | $this->_out('/Width '.$info['w']); |
| 1578 | 1694 | $this->_out('/Height '.$info['h']); |
| 1579 | - if($info['cs']=='Indexed') |
|
| 1580 | - $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1581 | - else |
|
| 1695 | + if($info['cs']=='Indexed') { |
|
| 1696 | + $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1697 | + } else |
|
| 1582 | 1698 | { |
| 1583 | 1699 | $this->_out('/ColorSpace /'.$info['cs']); |
| 1584 | - if($info['cs']=='DeviceCMYK') |
|
| 1585 | - $this->_out('/Decode [1 0 1 0 1 0 1 0]'); |
|
| 1700 | + if($info['cs']=='DeviceCMYK') { |
|
| 1701 | + $this->_out('/Decode [1 0 1 0 1 0 1 0]'); |
|
| 1702 | + } |
|
| 1586 | 1703 | } |
| 1587 | 1704 | $this->_out('/BitsPerComponent '.$info['bpc']); |
| 1588 | - if(isset($info['f'])) |
|
| 1589 | - $this->_out('/Filter /'.$info['f']); |
|
| 1590 | - if(isset($info['parms'])) |
|
| 1591 | - $this->_out($info['parms']); |
|
| 1705 | + if(isset($info['f'])) { |
|
| 1706 | + $this->_out('/Filter /'.$info['f']); |
|
| 1707 | + } |
|
| 1708 | + if(isset($info['parms'])) { |
|
| 1709 | + $this->_out($info['parms']); |
|
| 1710 | + } |
|
| 1592 | 1711 | if(isset($info['trns']) && is_array($info['trns'])) |
| 1593 | 1712 | { |
| 1594 | 1713 | $trns=''; |
| 1595 | - for($i=0;$i<count($info['trns']);$i++) |
|
| 1596 | - $trns.=$info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1714 | + for($i=0;$i<count($info['trns']);$i++) { |
|
| 1715 | + $trns.=$info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1716 | + } |
|
| 1597 | 1717 | $this->_out('/Mask ['.$trns.']'); |
| 1598 | 1718 | } |
| 1599 | 1719 | $this->_out('/Length '.strlen($info['data']).'>>'); |
@@ -1614,16 +1734,18 @@ discard block |
||
| 1614 | 1734 | |
| 1615 | 1735 | function _putxobjectdict() |
| 1616 | 1736 | { |
| 1617 | - foreach($this->images as $image) |
|
| 1618 | - $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1619 | -} |
|
| 1737 | + foreach($this->images as $image) { |
|
| 1738 | + $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1739 | + } |
|
| 1740 | + } |
|
| 1620 | 1741 | |
| 1621 | 1742 | function _putresourcedict() |
| 1622 | 1743 | { |
| 1623 | 1744 | $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
| 1624 | 1745 | $this->_out('/Font <<'); |
| 1625 | - foreach($this->fonts as $font) |
|
| 1626 | - $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1746 | + foreach($this->fonts as $font) { |
|
| 1747 | + $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1748 | + } |
|
| 1627 | 1749 | $this->_out('>>'); |
| 1628 | 1750 | $this->_out('/XObject <<'); |
| 1629 | 1751 | $this->_putxobjectdict(); |
@@ -1646,16 +1768,21 @@ discard block |
||
| 1646 | 1768 | function _putinfo() |
| 1647 | 1769 | { |
| 1648 | 1770 | $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION)); |
| 1649 | - if(!empty($this->title)) |
|
| 1650 | - $this->_out('/Title '.$this->_textstring($this->title)); |
|
| 1651 | - if(!empty($this->subject)) |
|
| 1652 | - $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
| 1653 | - if(!empty($this->author)) |
|
| 1654 | - $this->_out('/Author '.$this->_textstring($this->author)); |
|
| 1655 | - if(!empty($this->keywords)) |
|
| 1656 | - $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
| 1657 | - if(!empty($this->creator)) |
|
| 1658 | - $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
| 1771 | + if(!empty($this->title)) { |
|
| 1772 | + $this->_out('/Title '.$this->_textstring($this->title)); |
|
| 1773 | + } |
|
| 1774 | + if(!empty($this->subject)) { |
|
| 1775 | + $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
| 1776 | + } |
|
| 1777 | + if(!empty($this->author)) { |
|
| 1778 | + $this->_out('/Author '.$this->_textstring($this->author)); |
|
| 1779 | + } |
|
| 1780 | + if(!empty($this->keywords)) { |
|
| 1781 | + $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
| 1782 | + } |
|
| 1783 | + if(!empty($this->creator)) { |
|
| 1784 | + $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
| 1785 | + } |
|
| 1659 | 1786 | $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); |
| 1660 | 1787 | } |
| 1661 | 1788 | |
@@ -1663,21 +1790,23 @@ discard block |
||
| 1663 | 1790 | { |
| 1664 | 1791 | $this->_out('/Type /Catalog'); |
| 1665 | 1792 | $this->_out('/Pages 1 0 R'); |
| 1666 | - if($this->ZoomMode=='fullpage') |
|
| 1667 | - $this->_out('/OpenAction [3 0 R /Fit]'); |
|
| 1668 | - elseif($this->ZoomMode=='fullwidth') |
|
| 1669 | - $this->_out('/OpenAction [3 0 R /FitH null]'); |
|
| 1670 | - elseif($this->ZoomMode=='real') |
|
| 1671 | - $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); |
|
| 1672 | - elseif(!is_string($this->ZoomMode)) |
|
| 1673 | - $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); |
|
| 1674 | - if($this->LayoutMode=='single') |
|
| 1675 | - $this->_out('/PageLayout /SinglePage'); |
|
| 1676 | - elseif($this->LayoutMode=='continuous') |
|
| 1677 | - $this->_out('/PageLayout /OneColumn'); |
|
| 1678 | - elseif($this->LayoutMode=='two') |
|
| 1679 | - $this->_out('/PageLayout /TwoColumnLeft'); |
|
| 1680 | -} |
|
| 1793 | + if($this->ZoomMode=='fullpage') { |
|
| 1794 | + $this->_out('/OpenAction [3 0 R /Fit]'); |
|
| 1795 | + } elseif($this->ZoomMode=='fullwidth') { |
|
| 1796 | + $this->_out('/OpenAction [3 0 R /FitH null]'); |
|
| 1797 | + } elseif($this->ZoomMode=='real') { |
|
| 1798 | + $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); |
|
| 1799 | + } elseif(!is_string($this->ZoomMode)) { |
|
| 1800 | + $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); |
|
| 1801 | + } |
|
| 1802 | + if($this->LayoutMode=='single') { |
|
| 1803 | + $this->_out('/PageLayout /SinglePage'); |
|
| 1804 | + } elseif($this->LayoutMode=='continuous') { |
|
| 1805 | + $this->_out('/PageLayout /OneColumn'); |
|
| 1806 | + } elseif($this->LayoutMode=='two') { |
|
| 1807 | + $this->_out('/PageLayout /TwoColumnLeft'); |
|
| 1808 | + } |
|
| 1809 | + } |
|
| 1681 | 1810 | |
| 1682 | 1811 | function _putheader() |
| 1683 | 1812 | { |
@@ -1713,8 +1842,9 @@ discard block |
||
| 1713 | 1842 | $this->_out('xref'); |
| 1714 | 1843 | $this->_out('0 '.($this->n+1)); |
| 1715 | 1844 | $this->_out('0000000000 65535 f '); |
| 1716 | - for($i=1;$i<=$this->n;$i++) |
|
| 1717 | - $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 1845 | + for($i=1;$i<=$this->n;$i++) { |
|
| 1846 | + $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 1847 | + } |
|
| 1718 | 1848 | //Trailer |
| 1719 | 1849 | $this->_out('trailer'); |
| 1720 | 1850 | $this->_out('<<'); |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | DEFINE('EUR', chr(128)); // Sigle � |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | function WordWrap(&$text, $maxwidth) { |
| 23 | 23 | $text = trim($text); |
| 24 | - if ($text==='') |
|
| 24 | + if ($text === '') |
|
| 25 | 25 | return 0; |
| 26 | 26 | $space = $this->GetStringWidth(' '); |
| 27 | 27 | $lines = explode("\n", $text); |
@@ -39,16 +39,16 @@ discard block |
||
| 39 | 39 | if ($width + $wordwidth <= $maxwidth) |
| 40 | 40 | { |
| 41 | 41 | $width += $wordwidth + $space; |
| 42 | - $text .= $word.' '; |
|
| 42 | + $text .= $word . ' '; |
|
| 43 | 43 | } |
| 44 | 44 | else |
| 45 | 45 | { |
| 46 | 46 | $width = $wordwidth + $space; |
| 47 | - $text = rtrim($text)."\n".$word.' '; |
|
| 47 | + $text = rtrim($text) . "\n" . $word . ' '; |
|
| 48 | 48 | $count++; |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | - $text = rtrim($text)."\n"; |
|
| 51 | + $text = rtrim($text) . "\n"; |
|
| 52 | 52 | $count++; |
| 53 | 53 | } |
| 54 | 54 | $text = rtrim($text); |
@@ -65,28 +65,28 @@ discard block |
||
| 65 | 65 | return; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - while(!@is_dir(dirname(end($folder_path))) && dirname(end($folder_path)) != '/' && dirname(end($folder_path)) != '.' && dirname(end($folder_path)) != '') { |
|
| 68 | + while (!@is_dir(dirname(end($folder_path))) && dirname(end($folder_path)) != '/' && dirname(end($folder_path)) != '.' && dirname(end($folder_path)) != '') { |
|
| 69 | 69 | array_push($folder_path, dirname(end($folder_path))); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - while($parent_folder_path = array_pop($folder_path)) { |
|
| 73 | - if(!@mkdir($parent_folder_path, $rights)) { |
|
| 72 | + while ($parent_folder_path = array_pop($folder_path)) { |
|
| 73 | + if (!@mkdir($parent_folder_path, $rights)) { |
|
| 74 | 74 | user_error("Can't create folder \"$parent_folder_path\".\n"); |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - function invoice_export( $order_id, $invoice_id = null ) { |
|
| 79 | + function invoice_export($order_id, $invoice_id = null) { |
|
| 80 | 80 | |
| 81 | 81 | $current_user_id = get_current_user_id(); |
| 82 | 82 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 83 | 83 | |
| 84 | - if($order['customer_id']==$current_user_id OR is_admin()) { |
|
| 84 | + if ($order['customer_id'] == $current_user_id OR is_admin()) { |
|
| 85 | 85 | |
| 86 | 86 | if (in_array($order['order_status'], array('completed', 'shipped', 'partially_paid'))) { |
| 87 | 87 | $invoice_dir = WP_CONTENT_DIR . "/uploads/wpshop_invoices/"; |
| 88 | 88 | $filename = $this->get_invoice_filename($order_id); |
| 89 | - $invoice_url = $invoice_dir.$filename; |
|
| 89 | + $invoice_url = $invoice_dir . $filename; |
|
| 90 | 90 | |
| 91 | 91 | // If the invoice has not been already generated |
| 92 | 92 | // if ( !file_exists($invoice_url) ) { |
@@ -94,15 +94,15 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | // Currency management |
| 96 | 96 | $currency = $order['order_currency']; |
| 97 | - if($currency == 'EUR')$currency = EUR; |
|
| 98 | - else $currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) ); |
|
| 97 | + if ($currency == 'EUR')$currency = EUR; |
|
| 98 | + else $currency = html_entity_decode(wpshop_tools::wpshop_get_sigle($currency)); |
|
| 99 | 99 | |
| 100 | 100 | // On d�finit un alias pour le nombre de pages total |
| 101 | 101 | $this->AliasNbPages(); |
| 102 | 102 | // On ajoute une page au document |
| 103 | 103 | $this->AddPage(); |
| 104 | 104 | // On lui applique une police |
| 105 | - $this->SetFont('Arial','',10); |
|
| 105 | + $this->SetFont('Arial', '', 10); |
|
| 106 | 106 | // Coordonn�es magasin |
| 107 | 107 | $this->store_head($order_id); |
| 108 | 108 | // Coordonn�es client |
@@ -125,14 +125,14 @@ discard block |
||
| 125 | 125 | $path = $invoice_url; |
| 126 | 126 | $this->Output($path, "F"); |
| 127 | 127 | // On force le t�l�chargement de la facture |
| 128 | - $Fichier_a_telecharger = $refdate.".pdf"; |
|
| 128 | + $Fichier_a_telecharger = $refdate . ".pdf"; |
|
| 129 | 129 | $this->forceDownload($Fichier_a_telecharger, $path, filesize($path)); |
| 130 | 130 | // } |
| 131 | 131 | // else $this->forceDownload($filename, $invoice_url, filesize($invoice_url)); |
| 132 | 132 | } |
| 133 | - else echo __('The payment regarding the invoice you requested isn\'t completed','wpshop'); |
|
| 133 | + else echo __('The payment regarding the invoice you requested isn\'t completed', 'wpshop'); |
|
| 134 | 134 | } |
| 135 | - else echo __('You don\'t have the rights to access this invoice.','wpshop'); |
|
| 135 | + else echo __('You don\'t have the rights to access this invoice.', 'wpshop'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** Force le t�l�chargement d'un fichier */ |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | $emails = get_option('wpshop_emails', array()); |
| 158 | 158 | |
| 159 | 159 | //Positionnement |
| 160 | - $this->SetY(55);$this->SetX(12); |
|
| 160 | + $this->SetY(55); $this->SetX(12); |
|
| 161 | 161 | // Cadre client destinataire |
| 162 | 162 | $this->rect(10, 52, 80, 40); |
| 163 | 163 | |
| 164 | 164 | $xsize = 80; |
| 165 | 165 | |
| 166 | - if(!empty($company) && !empty($emails)) { |
|
| 166 | + if (!empty($company) && !empty($emails)) { |
|
| 167 | 167 | // Infos |
| 168 | 168 | $store_name = utf8_decode(utf8_encode($company['company_name'])); |
| 169 | 169 | $store_email = !empty($emails['contact_email']) ? $emails['contact_email'] : null; |
@@ -176,19 +176,19 @@ discard block |
||
| 176 | 176 | $store_country = utf8_decode(utf8_encode($company['company_country'])); |
| 177 | 177 | |
| 178 | 178 | // Gras pour le titre |
| 179 | - $this->SetFont('','B',10); |
|
| 180 | - $this->Cell($xsize,5,$store_name,0,1,'L'); $this->SetX(12); |
|
| 179 | + $this->SetFont('', 'B', 10); |
|
| 180 | + $this->Cell($xsize, 5, $store_name, 0, 1, 'L'); $this->SetX(12); |
|
| 181 | 181 | // Police normale pour le reste |
| 182 | - $this->SetFont('','',9); |
|
| 183 | - $this->Cell($xsize,4,$store_street_adress,0,1,'L'); $this->SetX(12); |
|
| 184 | - if (!empty($store_suburb)){$this->Cell(80,4,$store_suburb,0,1,'L');} $this->SetX(12); |
|
| 185 | - $this->Cell($xsize,4,$store_postcode . ' ' . $store_city,0,1,'L'); $this->SetX(12); |
|
| 182 | + $this->SetFont('', '', 9); |
|
| 183 | + $this->Cell($xsize, 4, $store_street_adress, 0, 1, 'L'); $this->SetX(12); |
|
| 184 | + if (!empty($store_suburb)) {$this->Cell(80, 4, $store_suburb, 0, 1, 'L'); } $this->SetX(12); |
|
| 185 | + $this->Cell($xsize, 4, $store_postcode . ' ' . $store_city, 0, 1, 'L'); $this->SetX(12); |
|
| 186 | 186 | //if ($store_state != ''){$this->Cell(80,4,$store_state,0,1,'L');} $this->SetX(12); |
| 187 | - $this->Cell($xsize,4,$store_country,0,1,'L'); $this->SetX(12); |
|
| 188 | - $this->Cell($xsize,4,$store_email,0,1,'L'); $this->SetX(12); |
|
| 187 | + $this->Cell($xsize, 4, $store_country, 0, 1, 'L'); $this->SetX(12); |
|
| 188 | + $this->Cell($xsize, 4, $store_email, 0, 1, 'L'); $this->SetX(12); |
|
| 189 | 189 | } |
| 190 | 190 | else { |
| 191 | - $this->Cell($xsize,5,_('Nc','wpshop'),0,1,'L'); |
|
| 191 | + $this->Cell($xsize, 5, _('Nc', 'wpshop'), 0, 1, 'L'); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
@@ -198,16 +198,16 @@ discard block |
||
| 198 | 198 | $customer_data = $customer_data['billing']['address']; |
| 199 | 199 | |
| 200 | 200 | // FPDF ne d�codant pas l'UTF-8, on le fait via PHP |
| 201 | - $customer_firstname = ( !empty($customer_data['address_first_name']) ) ? utf8_decode(utf8_encode($customer_data['address_first_name'])) : null; |
|
| 202 | - $customer_lastname = ( !empty($customer_data['address_last_name']) ) ? utf8_decode(utf8_encode($customer_data['address_last_name'])) : null; |
|
| 203 | - $customer_company = ( !empty($customer_data['company']) ) ? utf8_decode(utf8_encode($customer_data['company'])) : null; |
|
| 204 | - $customer_street_adress = ( !empty($customer_data['address']) ) ? utf8_decode(utf8_encode($customer_data['address'])) : null; |
|
| 205 | - $customer_city = ( !empty($customer_data['city']) ) ? utf8_decode(utf8_encode($customer_data['city'])) : null; |
|
| 206 | - $customer_postcode = ( !empty($customer_data['postcode']) ) ? utf8_decode(utf8_encode($customer_data['postcode'])) : null; |
|
| 207 | - $customer_state = ( !empty($customer_data['state']) ) ? utf8_decode(utf8_encode($customer_data['state'])) : null; |
|
| 208 | - $customer_country = ( !empty($customer_data['country']) ) ? utf8_decode(utf8_encode($customer_data['country'])) : null; |
|
| 201 | + $customer_firstname = (!empty($customer_data['address_first_name'])) ? utf8_decode(utf8_encode($customer_data['address_first_name'])) : null; |
|
| 202 | + $customer_lastname = (!empty($customer_data['address_last_name'])) ? utf8_decode(utf8_encode($customer_data['address_last_name'])) : null; |
|
| 203 | + $customer_company = (!empty($customer_data['company'])) ? utf8_decode(utf8_encode($customer_data['company'])) : null; |
|
| 204 | + $customer_street_adress = (!empty($customer_data['address'])) ? utf8_decode(utf8_encode($customer_data['address'])) : null; |
|
| 205 | + $customer_city = (!empty($customer_data['city'])) ? utf8_decode(utf8_encode($customer_data['city'])) : null; |
|
| 206 | + $customer_postcode = (!empty($customer_data['postcode'])) ? utf8_decode(utf8_encode($customer_data['postcode'])) : null; |
|
| 207 | + $customer_state = (!empty($customer_data['state'])) ? utf8_decode(utf8_encode($customer_data['state'])) : null; |
|
| 208 | + $customer_country = (!empty($customer_data['country'])) ? utf8_decode(utf8_encode($customer_data['country'])) : null; |
|
| 209 | 209 | |
| 210 | - $customer_tva_intra = ( !empty($customer_data['company_tva_intra']) ) ? utf8_decode(utf8_encode($customer_data['company_tva_intra'])) : null; |
|
| 210 | + $customer_tva_intra = (!empty($customer_data['company_tva_intra'])) ? utf8_decode(utf8_encode($customer_data['company_tva_intra'])) : null; |
|
| 211 | 211 | |
| 212 | 212 | $xsize = 80; |
| 213 | 213 | |
@@ -219,16 +219,16 @@ discard block |
||
| 219 | 219 | // Et on �cris |
| 220 | 220 | // On r�gle la police d'�criture |
| 221 | 221 | // gras pour le titre |
| 222 | - $this->SetFont('','B',10); |
|
| 223 | - $this->Cell($xsize,5,$customer_lastname.' '.$customer_firstname.(!empty($customer_company)?', '.$customer_company:null),0,1,'L'); $this->SetX(102); |
|
| 222 | + $this->SetFont('', 'B', 10); |
|
| 223 | + $this->Cell($xsize, 5, $customer_lastname . ' ' . $customer_firstname . (!empty($customer_company) ? ', ' . $customer_company : null), 0, 1, 'L'); $this->SetX(102); |
|
| 224 | 224 | // Police normale pour le reste |
| 225 | - $this->SetFont('','',9); |
|
| 226 | - $this->Cell($xsize,4,$customer_street_adress,0,1,'L'); $this->SetX(102); |
|
| 227 | - if (!empty($customer_suburb)){$this->Cell($xsize,4,$customer_suburb,0,1,'L');} $this->SetX(102); |
|
| 228 | - $this->Cell($xsize,4,$customer_postcode . ' ' . $customer_city,0,1,'L'); $this->SetX(102); |
|
| 229 | - if ($customer_state != ''){$this->Cell($xsize,4,$customer_state,0,1,'L');} $this->SetX(102); |
|
| 230 | - $this->Cell($xsize,4,$customer_country . ' ',0,1,'L'); $this->SetX(102); |
|
| 231 | - if ($customer_tva_intra != ''){$this->Cell($xsize,4,__('TVA Intracommunautaire','wpshop').' : '.$customer_tva_intra,0,1,'L');} |
|
| 225 | + $this->SetFont('', '', 9); |
|
| 226 | + $this->Cell($xsize, 4, $customer_street_adress, 0, 1, 'L'); $this->SetX(102); |
|
| 227 | + if (!empty($customer_suburb)) {$this->Cell($xsize, 4, $customer_suburb, 0, 1, 'L'); } $this->SetX(102); |
|
| 228 | + $this->Cell($xsize, 4, $customer_postcode . ' ' . $customer_city, 0, 1, 'L'); $this->SetX(102); |
|
| 229 | + if ($customer_state != '') {$this->Cell($xsize, 4, $customer_state, 0, 1, 'L'); } $this->SetX(102); |
|
| 230 | + $this->Cell($xsize, 4, $customer_country . ' ', 0, 1, 'L'); $this->SetX(102); |
|
| 231 | + if ($customer_tva_intra != '') {$this->Cell($xsize, 4, __('TVA Intracommunautaire', 'wpshop') . ' : ' . $customer_tva_intra, 0, 1, 'L'); } |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // R�f�rence et date de facturation |
@@ -238,34 +238,34 @@ discard block |
||
| 238 | 238 | // On r�cup�re la r�f�rence |
| 239 | 239 | //$invoice_ref = 'FA'.date('ym').'-0001'; |
| 240 | 240 | // On r�cup�re la date de facturation |
| 241 | - $invoice_add_date = substr($order['order_date'],0,10); |
|
| 241 | + $invoice_add_date = substr($order['order_date'], 0, 10); |
|
| 242 | 242 | // On r�cup�re la date d'�ch�ance |
| 243 | 243 | //$invoice_max_date = ''; |
| 244 | 244 | |
| 245 | 245 | // Positionnement |
| 246 | - $this->SetY(25); $this->SetX(135); $this->SetFont('','B',14); |
|
| 247 | - $this->Cell(50, 5, utf8_decode(__( 'Ref. : ', 'wpshop' )) . $invoice_ref,0,1,'L'); |
|
| 246 | + $this->SetY(25); $this->SetX(135); $this->SetFont('', 'B', 14); |
|
| 247 | + $this->Cell(50, 5, utf8_decode(__('Ref. : ', 'wpshop')) . $invoice_ref, 0, 1, 'L'); |
|
| 248 | 248 | // Positionnement |
| 249 | - $this->SetX(135); $this->SetFont('','',9); |
|
| 250 | - $this->Cell(50, 4, utf8_decode(__( 'Billing date : ', 'wpshop' )) . $invoice_add_date,0,1,'L'); |
|
| 249 | + $this->SetX(135); $this->SetFont('', '', 9); |
|
| 250 | + $this->Cell(50, 4, utf8_decode(__('Billing date : ', 'wpshop')) . $invoice_add_date, 0, 1, 'L'); |
|
| 251 | 251 | |
| 252 | - $this->SetX(135); $this->SetFont('','',9); |
|
| 253 | - $this->Cell(50, 4, utf8_decode(__( 'Payment method : ', 'wpshop' )) . utf8_decode(wpshop_payment::get_payment_method($order_id)), 0, 1, 'L'); |
|
| 252 | + $this->SetX(135); $this->SetFont('', '', 9); |
|
| 253 | + $this->Cell(50, 4, utf8_decode(__('Payment method : ', 'wpshop')) . utf8_decode(wpshop_payment::get_payment_method($order_id)), 0, 1, 'L'); |
|
| 254 | 254 | |
| 255 | - $this->SetX(135); $this->SetFont('','',9); |
|
| 256 | - $this->Cell(50, 4, utf8_decode(__( 'Transaction id : ', 'wpshop' )) . wpshop_payment::get_payment_transaction_number($order_id), 0, 1, 'L'); |
|
| 255 | + $this->SetX(135); $this->SetFont('', '', 9); |
|
| 256 | + $this->Cell(50, 4, utf8_decode(__('Transaction id : ', 'wpshop')) . wpshop_payment::get_payment_transaction_number($order_id), 0, 1, 'L'); |
|
| 257 | 257 | |
| 258 | 258 | //$this->SetX(135); |
| 259 | 259 | //$this->Cell(50, 4, utf8_decode(__( 'Date d\'�ch�ance : ', 'wpshop' )) . $invoice_max_date,0,1,'L'); |
| 260 | 260 | |
| 261 | - return $invoice_ref.'_'.$invoice_add_date; |
|
| 261 | + return $invoice_ref . '_' . $invoice_add_date; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | function get_invoice_filename($order_id) { |
| 265 | 265 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 266 | - $invoice_add_date = substr($order['order_date'],0,10); |
|
| 266 | + $invoice_add_date = substr($order['order_date'], 0, 10); |
|
| 267 | 267 | $order_invoice_ref = $order['order_invoice_ref']; |
| 268 | - return $order_invoice_ref.'_'.$invoice_add_date.'.pdf'; |
|
| 268 | + return $order_invoice_ref . '_' . $invoice_add_date . '.pdf'; |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -275,13 +275,13 @@ discard block |
||
| 275 | 275 | * @param integer $invoice_id Optionnal An invoice ID, this parameter could be used to call an invoice for a partial payment |
| 276 | 276 | */ |
| 277 | 277 | function rows($order_id, $currency, $invoice_id = null) { |
| 278 | - $title_ref = utf8_decode(__( 'Reference', 'wpshop' )); |
|
| 279 | - $title_name = utf8_decode(__( 'Designation', 'wpshop' )); |
|
| 280 | - $title_qty = utf8_decode(__( 'Qty', 'wpshop' )); |
|
| 281 | - $title_baseprice = utf8_decode(__( 'PU HT', 'wpshop' )); |
|
| 282 | - $title_discount = utf8_decode(__( 'Discount', 'wpshop' )); |
|
| 283 | - $title_tax = utf8_decode(__( 'TVA (Tax)', 'wpshop' )); |
|
| 284 | - $title_price = utf8_decode(__( 'Total ET', 'wpshop' )); |
|
| 278 | + $title_ref = utf8_decode(__('Reference', 'wpshop')); |
|
| 279 | + $title_name = utf8_decode(__('Designation', 'wpshop')); |
|
| 280 | + $title_qty = utf8_decode(__('Qty', 'wpshop')); |
|
| 281 | + $title_baseprice = utf8_decode(__('PU HT', 'wpshop')); |
|
| 282 | + $title_discount = utf8_decode(__('Discount', 'wpshop')); |
|
| 283 | + $title_tax = utf8_decode(__('TVA (Tax)', 'wpshop')); |
|
| 284 | + $title_price = utf8_decode(__('Total ET', 'wpshop')); |
|
| 285 | 285 | |
| 286 | 286 | /** Set title for invoice line table */ |
| 287 | 287 | $header = array($title_ref, $title_name, $title_qty, $title_baseprice, $title_discount, $title_tax, $title_price); |
@@ -289,23 +289,23 @@ discard block |
||
| 289 | 289 | /** Set column size */ |
| 290 | 290 | $w = array(26, 75, 10, 15, 15, 30, 20); |
| 291 | 291 | |
| 292 | - $this->setXY(10,100); |
|
| 293 | - for($i=0;$i<count($header);$i++) { |
|
| 294 | - $this->Cell($w[$i],5,$header[$i],1,0,'C'); |
|
| 292 | + $this->setXY(10, 100); |
|
| 293 | + for ($i = 0; $i < count($header); $i++) { |
|
| 294 | + $this->Cell($w[$i], 5, $header[$i], 1, 0, 'C'); |
|
| 295 | 295 | } |
| 296 | 296 | $this->Ln(); |
| 297 | 297 | |
| 298 | 298 | /** Get the order content */ |
| 299 | 299 | $order_data = get_post_meta($order_id, '_order_postmeta', true); |
| 300 | - if ( in_array($order_data['order_status'], array('completed', 'shipped') ) ) { |
|
| 300 | + if (in_array($order_data['order_status'], array('completed', 'shipped'))) { |
|
| 301 | 301 | /** Foreach item in order: add a row to invoice */ |
| 302 | 302 | foreach ($order_data['order_items'] as $o) { |
| 303 | 303 | $this->row($o, $w, $currency); |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | - else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) { |
|
| 307 | - foreach ( $order_data['order_payment']['received'] as $payment_info ) { |
|
| 308 | - if ( !is_array($payment_info) ) { |
|
| 306 | + else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received'])) { |
|
| 307 | + foreach ($order_data['order_payment']['received'] as $payment_info) { |
|
| 308 | + if (!is_array($payment_info)) { |
|
| 309 | 309 | |
| 310 | 310 | } |
| 311 | 311 | } |
@@ -326,13 +326,13 @@ discard block |
||
| 326 | 326 | $total_ht = !empty($row['item_total_ht']) ? $row['item_total_ht'] : 'Nc'; |
| 327 | 327 | |
| 328 | 328 | // On affiche les valeurs |
| 329 | - $this->Cell($dim_array[0],8,$product_reference,'LRB',0,'C'); |
|
| 330 | - $this->Cell($dim_array[1],8,$product_name,'LRB',0,'L'); |
|
| 331 | - $this->Cell($dim_array[2],8,$qty_invoiced,'LRB',0,'C'); |
|
| 332 | - $this->Cell($dim_array[3],8,number_format($item_pu_ht,2,'.',' ').' '.$currency,'LRB',0,'C'); |
|
| 333 | - $this->Cell($dim_array[4],8,number_format($discount_amount,2,'.',' ').' '.$currency,'LRB',0,'C'); |
|
| 334 | - $this->Cell($dim_array[5],8,number_format($item_tva_total_amount,2,'.',' ').' '.$currency.' (' . round($tax_rate, 2) . '%)','LRB',0,'C'); |
|
| 335 | - $this->Cell($dim_array[6],8,number_format($total_ht,2,'.',' ').' '.$currency,'LRB',0,'C'); |
|
| 329 | + $this->Cell($dim_array[0], 8, $product_reference, 'LRB', 0, 'C'); |
|
| 330 | + $this->Cell($dim_array[1], 8, $product_name, 'LRB', 0, 'L'); |
|
| 331 | + $this->Cell($dim_array[2], 8, $qty_invoiced, 'LRB', 0, 'C'); |
|
| 332 | + $this->Cell($dim_array[3], 8, number_format($item_pu_ht, 2, '.', ' ') . ' ' . $currency, 'LRB', 0, 'C'); |
|
| 333 | + $this->Cell($dim_array[4], 8, number_format($discount_amount, 2, '.', ' ') . ' ' . $currency, 'LRB', 0, 'C'); |
|
| 334 | + $this->Cell($dim_array[5], 8, number_format($item_tva_total_amount, 2, '.', ' ') . ' ' . $currency . ' (' . round($tax_rate, 2) . '%)', 'LRB', 0, 'C'); |
|
| 335 | + $this->Cell($dim_array[6], 8, number_format($total_ht, 2, '.', ' ') . ' ' . $currency, 'LRB', 0, 'C'); |
|
| 336 | 336 | $this->Ln(); |
| 337 | 337 | } |
| 338 | 338 | |
@@ -344,30 +344,30 @@ discard block |
||
| 344 | 344 | // D�calage |
| 345 | 345 | $this->Ln(); |
| 346 | 346 | |
| 347 | - $this->Cell(105,10); |
|
| 348 | - $this->Cell(50,8,__('Total ET','wpshop'),1); |
|
| 349 | - $this->Cell(35,8,number_format($order['order_total_ht'],2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln(); |
|
| 347 | + $this->Cell(105, 10); |
|
| 348 | + $this->Cell(50, 8, __('Total ET', 'wpshop'), 1); |
|
| 349 | + $this->Cell(35, 8, number_format($order['order_total_ht'], 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln(); |
|
| 350 | 350 | |
| 351 | - foreach($order['order_tva'] as $k => $v) { |
|
| 352 | - $this->Cell(105,10); |
|
| 353 | - $this->Cell(50,8,__('Tax','wpshop').' '.$k.'%',1); $this->Cell(35,8,number_format($v,2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln(); |
|
| 351 | + foreach ($order['order_tva'] as $k => $v) { |
|
| 352 | + $this->Cell(105, 10); |
|
| 353 | + $this->Cell(50, 8, __('Tax', 'wpshop') . ' ' . $k . '%', 1); $this->Cell(35, 8, number_format($v, 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln(); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - $this->Cell(105,10); |
|
| 357 | - $this->Cell(50,8,__('Shipping','wpshop'),1); $this->Cell(35,8,number_format($order['order_shipping_cost'],2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln(); |
|
| 356 | + $this->Cell(105, 10); |
|
| 357 | + $this->Cell(50, 8, __('Shipping', 'wpshop'), 1); $this->Cell(35, 8, number_format($order['order_shipping_cost'], 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln(); |
|
| 358 | 358 | |
| 359 | - if(!empty($order['order_grand_total_before_discount']) && $order['order_grand_total_before_discount'] != $order['order_grand_total']){ |
|
| 360 | - $this->Cell(105,10); |
|
| 361 | - $this->Cell(50,8,utf8_decode(__('Total ATI before discount','wpshop')),1); |
|
| 362 | - $this->Cell(35,8,number_format($order['order_grand_total_before_discount'],2).' '.$currency,1,0,'C'); $this->Ln(); |
|
| 359 | + if (!empty($order['order_grand_total_before_discount']) && $order['order_grand_total_before_discount'] != $order['order_grand_total']) { |
|
| 360 | + $this->Cell(105, 10); |
|
| 361 | + $this->Cell(50, 8, utf8_decode(__('Total ATI before discount', 'wpshop')), 1); |
|
| 362 | + $this->Cell(35, 8, number_format($order['order_grand_total_before_discount'], 2) . ' ' . $currency, 1, 0, 'C'); $this->Ln(); |
|
| 363 | 363 | |
| 364 | - $this->Cell(105,10); |
|
| 365 | - $this->Cell(50,8,__('Discount','wpshop'),1); |
|
| 366 | - $this->Cell(35,8,'-'.number_format($order['order_discount_amount_total_cart'],2).' '.$currency,1,0,'C'); $this->Ln(); |
|
| 364 | + $this->Cell(105, 10); |
|
| 365 | + $this->Cell(50, 8, __('Discount', 'wpshop'), 1); |
|
| 366 | + $this->Cell(35, 8, '-' . number_format($order['order_discount_amount_total_cart'], 2) . ' ' . $currency, 1, 0, 'C'); $this->Ln(); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - $this->Cell(105,10); |
|
| 370 | - $this->Cell(50,8,__('Total ATI','wpshop'),1); $this->SetFont('','B',10); $this->Cell(35,8,number_format($order['order_grand_total'],2,'.',' ') . ' ' . $currency,1,0,'C'); $this->Ln(); |
|
| 369 | + $this->Cell(105, 10); |
|
| 370 | + $this->Cell(50, 8, __('Total ATI', 'wpshop'), 1); $this->SetFont('', 'B', 10); $this->Cell(35, 8, number_format($order['order_grand_total'], 2, '.', ' ') . ' ' . $currency, 1, 0, 'C'); $this->Ln(); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | function rib($store_number) |
@@ -414,25 +414,25 @@ discard block |
||
| 414 | 414 | $tva_intra = $store['company_tva_intra']; |
| 415 | 415 | $currency = wpshop_tools::wpshop_get_currency(true); |
| 416 | 416 | |
| 417 | - $this->SetFont('','',10); |
|
| 418 | - $this->SetXY(10,-50); |
|
| 417 | + $this->SetFont('', '', 10); |
|
| 418 | + $this->SetXY(10, -50); |
|
| 419 | 419 | |
| 420 | - if(isset($store['company_member_of_a_approved_management_center']) && $store['company_member_of_a_approved_management_center']) { |
|
| 421 | - $this->MultiCell(190,4,utf8_decode(__('Member of an approved management center, accepting as such payments by check.', 'wpshop')),0,'L',FALSE); |
|
| 420 | + if (isset($store['company_member_of_a_approved_management_center']) && $store['company_member_of_a_approved_management_center']) { |
|
| 421 | + $this->MultiCell(190, 4, utf8_decode(__('Member of an approved management center, accepting as such payments by check.', 'wpshop')), 0, 'L', FALSE); |
|
| 422 | 422 | $this->Ln(); |
| 423 | 423 | } |
| 424 | - $this->MultiCell(190,4,utf8_decode(__('Law 83-629 of 07.12.83, Art. 8: "The administrative authorization does not confer any official character to the company or persons who benefit. It is in no way the responsibility of government."', 'wpshop')),0,'L',FALSE); |
|
| 424 | + $this->MultiCell(190, 4, utf8_decode(__('Law 83-629 of 07.12.83, Art. 8: "The administrative authorization does not confer any official character to the company or persons who benefit. It is in no way the responsibility of government."', 'wpshop')), 0, 'L', FALSE); |
|
| 425 | 425 | $this->Ln(); |
| 426 | - $this->MultiCell(190,4,utf8_decode($store_name.', '.$society_type.__(' capital of ', 'wpshop').$society_capital.' '.$currency.'. SIRET : '.$siret.'. TVA Intracommunautaire : '.$tva_intra),0,'L',FALSE); |
|
| 426 | + $this->MultiCell(190, 4, utf8_decode($store_name . ', ' . $society_type . __(' capital of ', 'wpshop') . $society_capital . ' ' . $currency . '. SIRET : ' . $siret . '. TVA Intracommunautaire : ' . $tva_intra), 0, 'L', FALSE); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | //En-t�te |
| 430 | 430 | function Header( ) { |
| 431 | - $this->SetFont('Arial','B',15); |
|
| 431 | + $this->SetFont('Arial', 'B', 15); |
|
| 432 | 432 | //D�calage � droite |
| 433 | 433 | $this->Cell(70); |
| 434 | 434 | //Titre |
| 435 | - $this->Cell(30,10,'FACTURE',0,0,'L'); |
|
| 435 | + $this->Cell(30, 10, 'FACTURE', 0, 0, 'L'); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | //Pied de page |
@@ -440,9 +440,9 @@ discard block |
||
| 440 | 440 | //Positionnement � 1,5 cm du bas |
| 441 | 441 | $this->SetY(-15); |
| 442 | 442 | //Police Arial italique 8 |
| 443 | - $this->SetFont('Arial','I',8); |
|
| 443 | + $this->SetFont('Arial', 'I', 8); |
|
| 444 | 444 | //Num�ro de page |
| 445 | - $this->Cell(0,10,$this->PageNo() . '/{nb}',0,0,'C'); |
|
| 445 | + $this->Cell(0, 10, $this->PageNo() . '/{nb}', 0, 0, 'C'); |
|
| 446 | 446 | } |
| 447 | 447 | } |
| 448 | 448 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -21,8 +23,9 @@ discard block |
||
| 21 | 23 | |
| 22 | 24 | function WordWrap(&$text, $maxwidth) { |
| 23 | 25 | $text = trim($text); |
| 24 | - if ($text==='') |
|
| 25 | - return 0; |
|
| 26 | + if ($text==='') { |
|
| 27 | + return 0; |
|
| 28 | + } |
|
| 26 | 29 | $space = $this->GetStringWidth(' '); |
| 27 | 30 | $lines = explode("\n", $text); |
| 28 | 31 | $text = ''; |
@@ -40,8 +43,7 @@ discard block |
||
| 40 | 43 | { |
| 41 | 44 | $width += $wordwidth + $space; |
| 42 | 45 | $text .= $word.' '; |
| 43 | - } |
|
| 44 | - else |
|
| 46 | + } else |
|
| 45 | 47 | { |
| 46 | 48 | $width = $wordwidth + $space; |
| 47 | 49 | $text = rtrim($text)."\n".$word.' '; |
@@ -60,8 +62,7 @@ discard block |
||
| 60 | 62 | function make_recursiv_dir($path, $rights = 0777) { |
| 61 | 63 | if (!@is_dir($path)) { |
| 62 | 64 | $folder_path = array($path); |
| 63 | - } |
|
| 64 | - else { |
|
| 65 | + } else { |
|
| 65 | 66 | return; |
| 66 | 67 | } |
| 67 | 68 | |
@@ -94,8 +95,11 @@ discard block |
||
| 94 | 95 | |
| 95 | 96 | // Currency management |
| 96 | 97 | $currency = $order['order_currency']; |
| 97 | - if($currency == 'EUR')$currency = EUR; |
|
| 98 | - else $currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) ); |
|
| 98 | + if($currency == 'EUR') { |
|
| 99 | + $currency = EUR; |
|
| 100 | + } else { |
|
| 101 | + $currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) ); |
|
| 102 | + } |
|
| 99 | 103 | |
| 100 | 104 | // On d�finit un alias pour le nombre de pages total |
| 101 | 105 | $this->AliasNbPages(); |
@@ -129,10 +133,12 @@ discard block |
||
| 129 | 133 | $this->forceDownload($Fichier_a_telecharger, $path, filesize($path)); |
| 130 | 134 | // } |
| 131 | 135 | // else $this->forceDownload($filename, $invoice_url, filesize($invoice_url)); |
| 136 | + } else { |
|
| 137 | + echo __('The payment regarding the invoice you requested isn\'t completed','wpshop'); |
|
| 132 | 138 | } |
| 133 | - else echo __('The payment regarding the invoice you requested isn\'t completed','wpshop'); |
|
| 139 | + } else { |
|
| 140 | + echo __('You don\'t have the rights to access this invoice.','wpshop'); |
|
| 134 | 141 | } |
| 135 | - else echo __('You don\'t have the rights to access this invoice.','wpshop'); |
|
| 136 | 142 | } |
| 137 | 143 | |
| 138 | 144 | /** Force le t�l�chargement d'un fichier */ |
@@ -186,8 +192,7 @@ discard block |
||
| 186 | 192 | //if ($store_state != ''){$this->Cell(80,4,$store_state,0,1,'L');} $this->SetX(12); |
| 187 | 193 | $this->Cell($xsize,4,$store_country,0,1,'L'); $this->SetX(12); |
| 188 | 194 | $this->Cell($xsize,4,$store_email,0,1,'L'); $this->SetX(12); |
| 189 | - } |
|
| 190 | - else { |
|
| 195 | + } else { |
|
| 191 | 196 | $this->Cell($xsize,5,_('Nc','wpshop'),0,1,'L'); |
| 192 | 197 | } |
| 193 | 198 | } |
@@ -302,8 +307,7 @@ discard block |
||
| 302 | 307 | foreach ($order_data['order_items'] as $o) { |
| 303 | 308 | $this->row($o, $w, $currency); |
| 304 | 309 | } |
| 305 | - } |
|
| 306 | - else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) { |
|
| 310 | + } else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) { |
|
| 307 | 311 | foreach ( $order_data['order_payment']['received'] as $payment_info ) { |
| 308 | 312 | if ( !is_array($payment_info) ) { |
| 309 | 313 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -63,8 +65,10 @@ discard block |
||
| 63 | 65 | } |
| 64 | 66 | $message .= '</ul></div>'; |
| 65 | 67 | return $message; |
| 66 | - else : |
|
| 68 | + else { |
|
| 69 | + : |
|
| 67 | 70 | return null; |
| 71 | + } |
|
| 68 | 72 | endif; |
| 69 | 73 | } |
| 70 | 74 | |
@@ -96,8 +100,7 @@ discard block |
||
| 96 | 100 | $email_exist = email_exists($value); |
| 97 | 101 | if(!is_email($value)) { |
| 98 | 102 | $this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'),$attribute_definition['label'])); |
| 99 | - } |
|
| 100 | - elseif ( empty($from) && (($user_id > 0 && !empty($email_exist) && $email_exist !== $user_id) || (!empty($email_exist) && $user_id <= 0)) ) { |
|
| 103 | + } elseif ( empty($from) && (($user_id > 0 && !empty($email_exist) && $email_exist !== $user_id) || (!empty($email_exist) && $user_id <= 0)) ) { |
|
| 101 | 104 | $this->add_error(__('An account is already registered with your email address. Please login.', 'wpshop')); |
| 102 | 105 | } |
| 103 | 106 | break; |
@@ -26,43 +26,43 @@ discard block |
||
| 26 | 26 | var $filters = array(); // Stores store filters |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * Add an error |
|
| 30 | - */ |
|
| 29 | + * Add an error |
|
| 30 | + */ |
|
| 31 | 31 | function add_error( $error ) { |
| 32 | 32 | $this->errors[] = $error; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | - * Add a message |
|
| 37 | - */ |
|
| 36 | + * Add a message |
|
| 37 | + */ |
|
| 38 | 38 | function add_message( $message ) { |
| 39 | 39 | $this->messages[] = $message; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * Add a filter |
|
| 44 | - */ |
|
| 43 | + * Add a filter |
|
| 44 | + */ |
|
| 45 | 45 | function add_filter( $attribute_frontend_verification, $function ) { |
| 46 | 46 | $this->filters[$attribute_frontend_verification] = $function; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | - * Get error count |
|
| 51 | - */ |
|
| 50 | + * Get error count |
|
| 51 | + */ |
|
| 52 | 52 | function error_count() { |
| 53 | 53 | return sizeof($this->errors); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | - * Get message count |
|
| 58 | - */ |
|
| 57 | + * Get message count |
|
| 58 | + */ |
|
| 59 | 59 | function message_count() { |
| 60 | 60 | return sizeof($this->messages); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | - * Output the errors and messages |
|
| 65 | - */ |
|
| 64 | + * Output the errors and messages |
|
| 65 | + */ |
|
| 66 | 66 | function show_messages() { |
| 67 | 67 | if (!empty($this->errors) && $this->error_count()>0) : |
| 68 | 68 | $message = '<div class="error_bloc">'.__('Errors were detected', 'wpshop').' :<ul>'; |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** Valide les champs d'un formlaire |
| 80 | - * @param array $array : Champs a lire |
|
| 81 | - * @return boolean |
|
| 82 | - */ |
|
| 80 | + * @param array $array : Champs a lire |
|
| 81 | + * @return boolean |
|
| 82 | + */ |
|
| 83 | 83 | function validateForm($array, $values = array(), $from = '', $partial = false, $user = 0) { |
| 84 | 84 | |
| 85 | 85 | |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -28,21 +28,21 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * Add an error |
| 30 | 30 | */ |
| 31 | - function add_error( $error ) { |
|
| 31 | + function add_error($error) { |
|
| 32 | 32 | $this->errors[] = $error; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Add a message |
| 37 | 37 | */ |
| 38 | - function add_message( $message ) { |
|
| 38 | + function add_message($message) { |
|
| 39 | 39 | $this->messages[] = $message; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Add a filter |
| 44 | 44 | */ |
| 45 | - function add_filter( $attribute_frontend_verification, $function ) { |
|
| 45 | + function add_filter($attribute_frontend_verification, $function) { |
|
| 46 | 46 | $this->filters[$attribute_frontend_verification] = $function; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | * Output the errors and messages |
| 65 | 65 | */ |
| 66 | 66 | function show_messages() { |
| 67 | - if (!empty($this->errors) && $this->error_count()>0) : |
|
| 68 | - $message = '<div class="error_bloc">'.__('Errors were detected', 'wpshop').' :<ul>'; |
|
| 69 | - foreach($this->errors as $e) { |
|
| 70 | - $message .= '<li>'.$e.'</li>'; |
|
| 67 | + if (!empty($this->errors) && $this->error_count() > 0) : |
|
| 68 | + $message = '<div class="error_bloc">' . __('Errors were detected', 'wpshop') . ' :<ul>'; |
|
| 69 | + foreach ($this->errors as $e) { |
|
| 70 | + $message .= '<li>' . $e . '</li>'; |
|
| 71 | 71 | } |
| 72 | 72 | $message .= '</ul></div>'; |
| 73 | 73 | return $message; |
@@ -83,42 +83,42 @@ discard block |
||
| 83 | 83 | function validateForm($array, $values = array(), $from = '', $partial = false, $user = 0) { |
| 84 | 84 | |
| 85 | 85 | |
| 86 | - $user_id = empty( $user ) ? get_current_user_id() : $user; |
|
| 87 | - foreach($array as $attribute_id => $attribute_definition): |
|
| 88 | - $values_array = !empty($values) ? $values : (array) $_POST['attribute']; |
|
| 89 | - $value = ( !empty($values_array[$attribute_definition['data_type']][$attribute_definition['name']]) ) ? $values_array[$attribute_definition['data_type']][$attribute_definition['name']] : ''; |
|
| 86 | + $user_id = empty($user) ? get_current_user_id() : $user; |
|
| 87 | + foreach ($array as $attribute_id => $attribute_definition): |
|
| 88 | + $values_array = !empty($values) ? $values : (array)$_POST['attribute']; |
|
| 89 | + $value = (!empty($values_array[$attribute_definition['data_type']][$attribute_definition['name']])) ? $values_array[$attribute_definition['data_type']][$attribute_definition['name']] : ''; |
|
| 90 | 90 | |
| 91 | 91 | // Si le champ est obligatoire |
| 92 | - if ( empty($value) && ($attribute_definition['required'] == 'yes') ) { |
|
| 93 | - $this->add_error(sprintf(__('The field "%s" is required','wpshop'),__( $attribute_definition['label'], 'wpshop' ) )); |
|
| 92 | + if (empty($value) && ($attribute_definition['required'] == 'yes')) { |
|
| 93 | + $this->add_error(sprintf(__('The field "%s" is required', 'wpshop'), __($attribute_definition['label'], 'wpshop'))); |
|
| 94 | 94 | } |
| 95 | - if( $partial == false && $attribute_definition['_need_verification'] == 'yes' ) { |
|
| 96 | - $value2 = $values_array[$attribute_definition['data_type']][$attribute_definition['name'].'2']; |
|
| 97 | - if ( $value != $value2) { |
|
| 98 | - $this->add_error(sprintf(__('The "%s" confirmation is incorrect','wpshop'),__($attribute_definition['label'], 'wpshop') )); |
|
| 95 | + if ($partial == false && $attribute_definition['_need_verification'] == 'yes') { |
|
| 96 | + $value2 = $values_array[$attribute_definition['data_type']][$attribute_definition['name'] . '2']; |
|
| 97 | + if ($value != $value2) { |
|
| 98 | + $this->add_error(sprintf(__('The "%s" confirmation is incorrect', 'wpshop'), __($attribute_definition['label'], 'wpshop'))); |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | - if(!empty($value) && !empty($attribute_definition['type'])) { |
|
| 102 | - switch($attribute_definition['frontend_verification']) { |
|
| 101 | + if (!empty($value) && !empty($attribute_definition['type'])) { |
|
| 102 | + switch ($attribute_definition['frontend_verification']) { |
|
| 103 | 103 | case 'email': |
| 104 | 104 | $email_exist = email_exists($value); |
| 105 | - if(!is_email($value)) { |
|
| 106 | - $this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'),$attribute_definition['label'])); |
|
| 105 | + if (!is_email($value)) { |
|
| 106 | + $this->add_error(sprintf(__('The field "%s" is incorrect', 'wpshop'), $attribute_definition['label'])); |
|
| 107 | 107 | } |
| 108 | - elseif ( empty($from) && (($user_id > 0 && !empty($email_exist) && $email_exist !== $user_id) || (!empty($email_exist) && $user_id <= 0)) ) { |
|
| 108 | + elseif (empty($from) && (($user_id > 0 && !empty($email_exist) && $email_exist !== $user_id) || (!empty($email_exist) && $user_id <= 0))) { |
|
| 109 | 109 | $this->add_error(__('An account is already registered with your email address. Please login.', 'wpshop')); |
| 110 | 110 | } |
| 111 | 111 | break; |
| 112 | 112 | |
| 113 | 113 | case 'postcode': |
| 114 | - if(!wpshop_tools::is_postcode($value)) { |
|
| 115 | - $this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'),__( $attribute_definition['label'], 'wpshop' ) )); |
|
| 114 | + if (!wpshop_tools::is_postcode($value)) { |
|
| 115 | + $this->add_error(sprintf(__('The field "%s" is incorrect', 'wpshop'), __($attribute_definition['label'], 'wpshop'))); |
|
| 116 | 116 | } |
| 117 | 117 | break; |
| 118 | 118 | |
| 119 | 119 | case 'phone': |
| 120 | - if(!wpshop_tools::is_phone($value)) { |
|
| 121 | - $this->add_error(sprintf(__('The field "%s" is incorrect','wpshop'), __( $attribute_definition['label'], 'wpshop' ) )); |
|
| 120 | + if (!wpshop_tools::is_phone($value)) { |
|
| 121 | + $this->add_error(sprintf(__('The field "%s" is incorrect', 'wpshop'), __($attribute_definition['label'], 'wpshop'))); |
|
| 122 | 122 | } |
| 123 | 123 | break; |
| 124 | 124 | |
@@ -126,22 +126,22 @@ discard block |
||
| 126 | 126 | $username_exists = username_exists($value); |
| 127 | 127 | // On s'assure que le nom d'utilisateur est libre |
| 128 | 128 | if (!validate_username($value)) : |
| 129 | - $this->add_error( __('Invalid email/username.', 'wpshop') ); |
|
| 130 | - elseif ( ($user_id > 0) && !empty($username_exists) && ($username_exists !== $user_id) || !empty($username_exists) && ($user_id <= 0) ) : |
|
| 131 | - $this->add_error( __('An account is already registered with that username. Please choose another.', 'wpshop') ); |
|
| 129 | + $this->add_error(__('Invalid email/username.', 'wpshop')); |
|
| 130 | + elseif (($user_id > 0) && !empty($username_exists) && ($username_exists !== $user_id) || !empty($username_exists) && ($user_id <= 0)) : |
|
| 131 | + $this->add_error(__('An account is already registered with that username. Please choose another.', 'wpshop')); |
|
| 132 | 132 | endif; |
| 133 | 133 | break; |
| 134 | 134 | } |
| 135 | 135 | if (array_key_exists($attribute_definition['name'], $this->filters) && is_callable($this->filters[$attribute_definition['name']])) { |
| 136 | 136 | $validation = call_user_func($this->filters[$attribute_definition['name']], $value); |
| 137 | - if( !filter_var($validation, FILTER_VALIDATE_BOOLEAN) ) { |
|
| 138 | - $this->add_error( $validation ); |
|
| 137 | + if (!filter_var($validation, FILTER_VALIDATE_BOOLEAN)) { |
|
| 138 | + $this->add_error($validation); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | endforeach; |
| 143 | 143 | |
| 144 | - return ($this->error_count()==0); |
|
| 144 | + return ($this->error_count() == 0); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | } |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /* Check if file is include. No direct access possible with file url */ |
| 3 | 5 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
| 4 | 6 | die( __('Access is not allowed by this way', 'wpshop') ); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /* Check if file is include. No direct access possible with file url */ |
| 3 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 4 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 3 | +if (!defined('WPSHOP_VERSION')) { |
|
| 4 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -19,36 +19,36 @@ discard block |
||
| 19 | 19 | * @package wpshop |
| 20 | 20 | * @subpackage librairies |
| 21 | 21 | */ |
| 22 | -class wpshop_notices{ |
|
| 22 | +class wpshop_notices { |
|
| 23 | 23 | |
| 24 | 24 | /** Notice the user to install the plugin */ |
| 25 | 25 | public static function sale_shop_notice() { |
| 26 | - $plug_version = substr( WPSHOP_VERSION, 0, 5 ); |
|
| 26 | + $plug_version = substr(WPSHOP_VERSION, 0, 5); |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - $notice_display_user_option = get_user_meta( get_current_user_id(), '_wps_hide_notice_messages_indicator', true); |
|
| 29 | + $notice_display_user_option = get_user_meta(get_current_user_id(), '_wps_hide_notice_messages_indicator', true); |
|
| 30 | 30 | |
| 31 | 31 | $notice = ''; |
| 32 | 32 | $messages_to_hide = ''; |
| 33 | 33 | /* Check that the user has already choose a payment method */ |
| 34 | - $paymentMethod = get_option( 'wps_payment_mode' ); |
|
| 34 | + $paymentMethod = get_option('wps_payment_mode'); |
|
| 35 | 35 | $no_payment_mode_configurated = true; |
| 36 | - if ( !empty($paymentMethod ) && !empty($paymentMethod['mode']) ) { |
|
| 37 | - foreach( $paymentMethod['mode'] as $k => $pm ) { |
|
| 38 | - if ( !empty($pm['active'] ) ) { |
|
| 36 | + if (!empty($paymentMethod) && !empty($paymentMethod['mode'])) { |
|
| 37 | + foreach ($paymentMethod['mode'] as $k => $pm) { |
|
| 38 | + if (!empty($pm['active'])) { |
|
| 39 | 39 | $no_payment_mode_configurated = false; |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if( $no_payment_mode_configurated ) { |
|
| 45 | - $notice .= '<li>' . __('Payment method are missing', 'wpshop') . ' <a href="' . admin_url('options-general.php?page='.WPSHOP_URL_SLUG_OPTION.'#wpshop_payments_option') . '" class="button-primary wpshop_missing_parameters_button" >' . __('Choose a payment method', 'wpshop') . '</a></li>'; |
|
| 44 | + if ($no_payment_mode_configurated) { |
|
| 45 | + $notice .= '<li>' . __('Payment method are missing', 'wpshop') . ' <a href="' . admin_url('options-general.php?page=' . WPSHOP_URL_SLUG_OPTION . '#wpshop_payments_option') . '" class="button-primary wpshop_missing_parameters_button" >' . __('Choose a payment method', 'wpshop') . '</a></li>'; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /* Check that the user has already choose a payment method */ |
| 49 | 49 | $emails = get_option('wpshop_emails', array()); |
| 50 | - if(empty($emails)) { |
|
| 51 | - $notice .= '<li>' . __('Shop emails are misssing', 'wpshop') . ' <a href="' . admin_url('options-general.php?page='.WPSHOP_URL_SLUG_OPTION.'#wpshop_emails_option') . '" class="button-primary wpshop_missing_parameters_button" >' . __('Configure shop emails', 'wpshop') . '</a></li>'; |
|
| 50 | + if (empty($emails)) { |
|
| 51 | + $notice .= '<li>' . __('Shop emails are misssing', 'wpshop') . ' <a href="' . admin_url('options-general.php?page=' . WPSHOP_URL_SLUG_OPTION . '#wpshop_emails_option') . '" class="button-primary wpshop_missing_parameters_button" >' . __('Configure shop emails', 'wpshop') . '</a></li>'; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -58,20 +58,20 @@ discard block |
||
| 58 | 58 | $messages_to_hide .= 'SLICKSHOP,'; |
| 59 | 59 | }*/ |
| 60 | 60 | |
| 61 | - $install = !empty( $_GET[ 'install' ] ) ? sanitize_text_field( $_GET[ 'install' ] ) : ''; |
|
| 61 | + $install = !empty($_GET['install']) ? sanitize_text_field($_GET['install']) : ''; |
|
| 62 | 62 | |
| 63 | - if(!empty($notice) && ( empty( $install ) ) ) { |
|
| 64 | - $notice='<p>'.__('You configure your shop to be a sale shop. But some configuration are missing for this type of shop using', 'wpshop').'</p><ul>'.$notice.'</ul>'; |
|
| 65 | - if ( !empty($messages_to_hide) ) { |
|
| 66 | - $notice .= '<button data-nonce="' . wp_create_nonce( 'wps_hide_notice_messages' ) . '" class="wps_hide_notice_message button-secondary" id="wps_hide_notice_message">' .__('Hide this message', 'wpshop'). '</button>'; |
|
| 67 | - $notice .= '<input type="hidden" id="hide_messages_indicator" value="' .$messages_to_hide. '"/>'; |
|
| 63 | + if (!empty($notice) && (empty($install))) { |
|
| 64 | + $notice = '<p>' . __('You configure your shop to be a sale shop. But some configuration are missing for this type of shop using', 'wpshop') . '</p><ul>' . $notice . '</ul>'; |
|
| 65 | + if (!empty($messages_to_hide)) { |
|
| 66 | + $notice .= '<button data-nonce="' . wp_create_nonce('wps_hide_notice_messages') . '" class="wps_hide_notice_message button-secondary" id="wps_hide_notice_message">' . __('Hide this message', 'wpshop') . '</button>'; |
|
| 67 | + $notice .= '<input type="hidden" id="hide_messages_indicator" value="' . $messages_to_hide . '"/>'; |
|
| 68 | 68 | } |
| 69 | 69 | self::admin_notice_container($notice, 'wpshop_shop_sale_type_notice'); |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** */ |
| 74 | - public static function admin_notice_container($message, $container_class = ''){ |
|
| 74 | + public static function admin_notice_container($message, $container_class = '') { |
|
| 75 | 75 | ?> |
| 76 | 76 | <div class="updated wpshop_admin_notice <?php echo $container_class; ?>" id="<?php echo $container_class; ?>" > |
| 77 | 77 | <h3><?php _e('Configure my shop', 'wpshop') ?></h3> |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | - * Reduce the stock regarding the order |
|
| 222 | - */ |
|
| 221 | + * Reduce the stock regarding the order |
|
| 222 | + */ |
|
| 223 | 223 | function the_order_payment_is_completed($order_id, $txn_id = null) { |
| 224 | 224 | // Donnees commandes |
| 225 | 225 | $order = get_post_meta($order_id, '_order_postmeta', true); |
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | - * Get payment method |
|
| 297 | - */ |
|
| 296 | + * Get payment method |
|
| 297 | + */ |
|
| 298 | 298 | function get_payment_method($post_id){ |
| 299 | 299 | $pm = __('Nc','wpshop'); |
| 300 | 300 | $order_postmeta = get_post_meta($post_id, '_order_postmeta', true); |
@@ -321,8 +321,8 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
| 324 | - * Set payment transaction number |
|
| 325 | - */ |
|
| 324 | + * Set payment transaction number |
|
| 325 | + */ |
|
| 326 | 326 | function display_payment_receiver_interface($post_id) { |
| 327 | 327 | $payment_validation = ''; |
| 328 | 328 | $display_button = false; |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -20,29 +20,29 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $wpshop_paypal = new wpshop_paypal(); |
| 22 | 22 | // If the CIC payment method is active |
| 23 | - $wpshop_paymentMethod = get_option( 'wps_payment_mode' ); |
|
| 24 | - if(WPSHOP_PAYMENT_METHOD_CIC && ( !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']) ) ) { |
|
| 23 | + $wpshop_paymentMethod = get_option('wps_payment_mode'); |
|
| 24 | + if (WPSHOP_PAYMENT_METHOD_CIC && (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']) && !empty($wpshop_paymentMethod['mode']['cic']['active']))) { |
|
| 25 | 25 | $wpshop_cic = new wpshop_CIC(); |
| 26 | 26 | } |
| 27 | - wpshop_tools::create_custom_hook ('wpshop_bankserver_reponse'); |
|
| 27 | + wpshop_tools::create_custom_hook('wpshop_bankserver_reponse'); |
|
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public static function get_success_payment_url() { |
| 32 | - $url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_page_id') ) ); |
|
| 32 | + $url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_page_id'))); |
|
| 33 | 33 | return self::construct_url_parameters($url, 'paymentResult', 'success'); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public static function get_cancel_payment_url() { |
| 37 | - $url = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_payment_return_nok_page_id') ) ); |
|
| 37 | + $url = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_payment_return_nok_page_id'))); |
|
| 38 | 38 | return $url; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public static function construct_url_parameters($url, $param, $value) { |
| 42 | 42 | $interoguation_marker_pos = strpos($url, '?'); |
| 43 | - if($interoguation_marker_pos===false) |
|
| 44 | - return $url.'?'.$param.'='.$value; |
|
| 45 | - else return $url.'&'.$param.'='.$value; |
|
| 43 | + if ($interoguation_marker_pos === false) |
|
| 44 | + return $url . '?' . $param . '=' . $value; |
|
| 45 | + else return $url . '&' . $param . '=' . $value; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -51,23 +51,23 @@ discard block |
||
| 51 | 51 | public static function wpshop_payment_result() { |
| 52 | 52 | global $wpdb; |
| 53 | 53 | $user_ID = get_current_user_id(); |
| 54 | - $query = $wpdb->prepare('SELECT MAX(ID) FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID); |
|
| 55 | - $order_post_id = $wpdb->get_var( $query ); |
|
| 56 | - if ( !empty($order_post_id) ) { |
|
| 57 | - $order_postmeta = get_post_meta($order_post_id , '_wpshop_order_status', true); |
|
| 58 | - if ( !empty($order_postmeta) ) { |
|
| 59 | - switch ( $order_postmeta ) { |
|
| 54 | + $query = $wpdb->prepare('SELECT MAX(ID) FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_ORDER, $user_ID); |
|
| 55 | + $order_post_id = $wpdb->get_var($query); |
|
| 56 | + if (!empty($order_post_id)) { |
|
| 57 | + $order_postmeta = get_post_meta($order_post_id, '_wpshop_order_status', true); |
|
| 58 | + if (!empty($order_postmeta)) { |
|
| 59 | + switch ($order_postmeta) { |
|
| 60 | 60 | case 'awaiting_payment': |
| 61 | - echo __('We wait your payment.','wpshop'); |
|
| 61 | + echo __('We wait your payment.', 'wpshop'); |
|
| 62 | 62 | break; |
| 63 | 63 | case 'completed': |
| 64 | - echo __('Thank you ! Your payment has been recorded.','wpshop'); |
|
| 64 | + echo __('Thank you ! Your payment has been recorded.', 'wpshop'); |
|
| 65 | 65 | break; |
| 66 | 66 | case 'partially_paid': |
| 67 | - echo __('Thank you ! Your first payment has been recorded.','wpshop'); |
|
| 67 | + echo __('Thank you ! Your first payment has been recorded.', 'wpshop'); |
|
| 68 | 68 | break; |
| 69 | 69 | default: |
| 70 | - echo __('Your payment and your order has been cancelled.','wpshop'); |
|
| 70 | + echo __('Your payment and your order has been cancelled.', 'wpshop'); |
|
| 71 | 71 | break; |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -88,56 +88,56 @@ discard block |
||
| 88 | 88 | * @param integer $order_id The order id if existing - Useful when user does not finish its order and want to validateit later |
| 89 | 89 | * @return string The different payment method |
| 90 | 90 | */ |
| 91 | - function __display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') { |
|
| 91 | + function __display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') { |
|
| 92 | 92 | $output = ''; |
| 93 | 93 | /** Get available payment method */ |
| 94 | 94 | $paymentMethod = get_option('wpshop_paymentMethod', array()); |
| 95 | 95 | |
| 96 | - if(!empty($order_id) && is_numeric($order_id)) { |
|
| 97 | - $output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />'; |
|
| 96 | + if (!empty($order_id) && is_numeric($order_id)) { |
|
| 97 | + $output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | if ($cart_type == 'cart') { |
| 101 | 101 | $payment_methods = array(); |
| 102 | - if(!empty($paymentMethod['paypal'])) { |
|
| 102 | + if (!empty($paymentMethod['paypal'])) { |
|
| 103 | 103 | $payment_methods['paypal'] = array('payment_method_name' => __('CB with Paypal', 'wpshop'), |
| 104 | 104 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/paypal.png', |
| 105 | - 'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.','wpshop') |
|
| 105 | + 'payment_method_explanation' => __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.', 'wpshop') |
|
| 106 | 106 | ); |
| 107 | 107 | } |
| 108 | - if(!empty($paymentMethod['checks'])) { |
|
| 108 | + if (!empty($paymentMethod['checks'])) { |
|
| 109 | 109 | $payment_methods['check'] = array('payment_method_name' => __('Check', 'wpshop'), |
| 110 | 110 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png', |
| 111 | - 'payment_method_explanation' => __('Reservation of products upon receipt of the check.','wpshop') |
|
| 111 | + 'payment_method_explanation' => __('Reservation of products upon receipt of the check.', 'wpshop') |
|
| 112 | 112 | ); |
| 113 | 113 | } |
| 114 | - if(!empty($paymentMethod['banktransfer'])) { |
|
| 114 | + if (!empty($paymentMethod['banktransfer'])) { |
|
| 115 | 115 | $payment_methods['banktransfer'] = array('payment_method_name' => __('Bank transfer', 'wpshop'), |
| 116 | 116 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cheque.png', |
| 117 | - 'payment_method_explanation' =>__('Reservation of product receipt of payment.','wpshop') |
|
| 117 | + 'payment_method_explanation' =>__('Reservation of product receipt of payment.', 'wpshop') |
|
| 118 | 118 | ); |
| 119 | 119 | } |
| 120 | - if(WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) { |
|
| 120 | + if (WPSHOP_PAYMENT_METHOD_CIC || !empty($paymentMethod['cic'])) { |
|
| 121 | 121 | $payment_methods['cic'] = array('payment_method_name' =>__('Credit card', 'wpshop'), |
| 122 | 122 | 'payment_method_icon' => WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg', |
| 123 | - 'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.','wpshop') |
|
| 123 | + 'payment_method_explanation' =>__('Reservation of products upon confirmation of payment.', 'wpshop') |
|
| 124 | 124 | ); |
| 125 | 125 | } |
| 126 | 126 | $payment_methods = apply_filters('wpshop_payment_method', $payment_methods); |
| 127 | 127 | |
| 128 | 128 | $payment_method_table = array(); |
| 129 | 129 | |
| 130 | - if ( !empty( $paymentMethod['display_position'] ) ) { |
|
| 130 | + if (!empty($paymentMethod['display_position'])) { |
|
| 131 | 131 | $position_determinated = false; |
| 132 | - foreach ( $paymentMethod['display_position'] as $key => $position) { |
|
| 133 | - if ( $position != null) { |
|
| 132 | + foreach ($paymentMethod['display_position'] as $key => $position) { |
|
| 133 | + if ($position != null) { |
|
| 134 | 134 | $position_determinated = true; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | - if ( $position_determinated ) { |
|
| 138 | - for ( $i = 1; $i < count( $paymentMethod['display_position'] ) + 1; $i++) { |
|
| 139 | - foreach ( $paymentMethod['display_position'] as $key => $position ) { |
|
| 140 | - if ( $position == $i && !empty($paymentMethod[$key])) { |
|
| 137 | + if ($position_determinated) { |
|
| 138 | + for ($i = 1; $i < count($paymentMethod['display_position']) + 1; $i++) { |
|
| 139 | + foreach ($paymentMethod['display_position'] as $key => $position) { |
|
| 140 | + if ($position == $i && !empty($paymentMethod[$key])) { |
|
| 141 | 141 | if ($key == 'checks') { |
| 142 | 142 | $key = 'check'; |
| 143 | 143 | } |
@@ -148,16 +148,16 @@ discard block |
||
| 148 | 148 | $payment_methods = $payment_method_table; |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | - if (!empty($payment_methods) ) { |
|
| 151 | + if (!empty($payment_methods)) { |
|
| 152 | 152 | |
| 153 | - foreach( $payment_methods as $payment_method_identifier => $payment_method_def ) { |
|
| 153 | + foreach ($payment_methods as $payment_method_identifier => $payment_method_def) { |
|
| 154 | 154 | $tpl_component = array(); |
| 155 | 155 | $checked = $active = ''; |
| 156 | 156 | $payment_identifier_for_test = $payment_method_identifier; |
| 157 | 157 | if ($payment_method_identifier == 'check') { |
| 158 | 158 | $payment_identifier_for_test = 'checks'; |
| 159 | 159 | } |
| 160 | - if ( !empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) { |
|
| 160 | + if (!empty($paymentMethod['default_method']) && $paymentMethod['default_method'] == $payment_identifier_for_test) { |
|
| 161 | 161 | $checked = ' checked="checked"'; |
| 162 | 162 | $active = ' active'; |
| 163 | 163 | |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | $tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = $active; |
| 166 | 166 | $tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = $checked; |
| 167 | 167 | $tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier; |
| 168 | - if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) { |
|
| 169 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : ''; |
|
| 168 | + if (!empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0) { |
|
| 169 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? wp_get_attachment_image($payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo')) : ''; |
|
| 170 | 170 | } |
| 171 | 171 | else { |
| 172 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : ''; |
|
| 172 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_method_def['payment_method_icon'])) ? '<img src="' . $payment_method_def['payment_method_icon'] . '" alt="" />' : ''; |
|
| 173 | 173 | } |
| 174 | 174 | //$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon']; |
| 175 | 175 | $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = $payment_method_def['payment_method_name']; |
@@ -180,32 +180,32 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - return array( $output, $paymentMethod['mode'] ); |
|
| 183 | + return array($output, $paymentMethod['mode']); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
| 187 | - public static function display_payment_methods_choice_form($order_id=0, $cart_type = 'cart') { |
|
| 188 | - $payment_option = get_option( 'wps_payment_mode' ); |
|
| 187 | + public static function display_payment_methods_choice_form($order_id = 0, $cart_type = 'cart') { |
|
| 188 | + $payment_option = get_option('wps_payment_mode'); |
|
| 189 | 189 | $output = ''; |
| 190 | - if(!empty($order_id) && is_numeric($order_id)) { |
|
| 191 | - $output .= '<input type="hidden" name="order_id" value="'.$order_id.'" />'; |
|
| 190 | + if (!empty($order_id) && is_numeric($order_id)) { |
|
| 191 | + $output .= '<input type="hidden" name="order_id" value="' . $order_id . '" />'; |
|
| 192 | 192 | } |
| 193 | - if( $cart_type == 'cart' ) { |
|
| 194 | - if ( !empty($payment_option) && !empty($payment_option['mode']) ) { |
|
| 195 | - foreach( $payment_option['mode'] as $payment_id => $payment_config ) { |
|
| 196 | - if( !empty($payment_config['active']) ) { |
|
| 197 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? ' active' : ''); |
|
| 198 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ( ( !empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id ) ? 'checked="checked"' : ''); |
|
| 193 | + if ($cart_type == 'cart') { |
|
| 194 | + if (!empty($payment_option) && !empty($payment_option['mode'])) { |
|
| 195 | + foreach ($payment_option['mode'] as $payment_id => $payment_config) { |
|
| 196 | + if (!empty($payment_config['active'])) { |
|
| 197 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_STATE_CLASS'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? ' active' : ''); |
|
| 198 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_INPUT_STATE'] = ((!empty($payment_option['default_choice']) && $payment_option['default_choice'] == $payment_id) ? 'checked="checked"' : ''); |
|
| 199 | 199 | $tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_id; |
| 200 | 200 | |
| 201 | - if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) { |
|
| 202 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : ''; |
|
| 201 | + if (!empty($payment_config['logo']) && (int)$payment_config['logo'] != 0) { |
|
| 202 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? wp_get_attachment_image($payment_config['logo'], 'thumbnail', false) : ''; |
|
| 203 | 203 | } |
| 204 | 204 | else { |
| 205 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : ''; |
|
| 205 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = (!empty($payment_config['logo'])) ? '<img src="' . $payment_config['logo'] . '" alt="' . $payment_config['name'] . '" />' : ''; |
|
| 206 | 206 | } |
| 207 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : ''; |
|
| 208 | - $tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = ( !empty($payment_config['description']) ) ? $payment_config['description'] : ''; |
|
| 207 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = (!empty($payment_config['name'])) ? $payment_config['name'] : ''; |
|
| 208 | + $tpl_component['CHECKOUT_PAYMENT_METHOD_EXPLANATION'] = (!empty($payment_config['description'])) ? $payment_config['description'] : ''; |
|
| 209 | 209 | $output .= wpshop_display::display_template_element('wpshop_checkout_page_payment_method_bloc', $tpl_component, array('type' => 'payment_method', 'id' => $payment_id)); |
| 210 | 210 | unset($tpl_component); |
| 211 | 211 | } |
@@ -227,13 +227,13 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | $wps_message = new wps_message_ctr(); |
| 229 | 229 | |
| 230 | - if(!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) { |
|
| 231 | - $email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : '' ); |
|
| 232 | - $first_name = ( !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' ); |
|
| 233 | - $last_name = ( !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' ); |
|
| 230 | + if (!empty($order) && !empty($order_info) && empty($order['order_invoice_ref'])) { |
|
| 231 | + $email = (!empty($order_info['billing']['address']['address_user_email']) ? $order_info['billing']['address']['address_user_email'] : ''); |
|
| 232 | + $first_name = (!empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : ''); |
|
| 233 | + $last_name = (!empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : ''); |
|
| 234 | 234 | |
| 235 | 235 | // Envoie du message de confirmation de paiement au client |
| 236 | - switch($order['payment_method']) { |
|
| 236 | + switch ($order['payment_method']) { |
|
| 237 | 237 | case 'check': |
| 238 | 238 | $wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date'])); |
| 239 | 239 | break; |
@@ -250,24 +250,24 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
| 253 | - function setOrderPaymentStatus( $order_id, $payment_status ) { |
|
| 253 | + function setOrderPaymentStatus($order_id, $payment_status) { |
|
| 254 | 254 | /** Get order main information */ |
| 255 | 255 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 256 | 256 | $send_email = false; |
| 257 | 257 | |
| 258 | - if ( !empty($order) ) { |
|
| 258 | + if (!empty($order)) { |
|
| 259 | 259 | /** Change order status to given status */ |
| 260 | 260 | $order['order_status'] = strtolower($payment_status); |
| 261 | 261 | /** Put order status into a single meta, allowing to use it easily later */ |
| 262 | 262 | update_post_meta($order_id, '_wpshop_order_status', $order['order_status']); |
| 263 | 263 | |
| 264 | 264 | /** In case the set status is completed, make specific treatment: add the completed date */ |
| 265 | - if ( $payment_status == 'completed' ) { |
|
| 265 | + if ($payment_status == 'completed') { |
|
| 266 | 266 | /** Read order items list, if not empty and check if each item is set to manage stock or not */ |
| 267 | 267 | if (!empty($order['order_items'])) { |
| 268 | 268 | foreach ($order['order_items'] as $o) { |
| 269 | - $product = wpshop_products::get_product_data( $o['item_id'] ); |
|
| 270 | - if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop') ) { |
|
| 269 | + $product = wpshop_products::get_product_data($o['item_id']); |
|
| 270 | + if (!empty($product) && !empty($product['manage_stock']) && __($product['manage_stock'], 'wpshop') == __('Yes', 'wpshop')) { |
|
| 271 | 271 | wpshop_products::reduce_product_stock_qty($o['item_id'], $o['item_qty']); |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** Send email to customer when specific case need it */ |
| 284 | - if ( $send_email ) { |
|
| 284 | + if ($send_email) { |
|
| 285 | 285 | /** Get information about customer that make the order */ |
| 286 | 286 | $order_info = get_post_meta($order_id, '_order_info', true); |
| 287 | 287 | $mail_tpl_component = array('order_key' => $order['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order['order_date']); |
@@ -295,25 +295,25 @@ discard block |
||
| 295 | 295 | /** |
| 296 | 296 | * Get payment method |
| 297 | 297 | */ |
| 298 | - function get_payment_method($post_id){ |
|
| 299 | - $pm = __('Nc','wpshop'); |
|
| 298 | + function get_payment_method($post_id) { |
|
| 299 | + $pm = __('Nc', 'wpshop'); |
|
| 300 | 300 | $order_postmeta = get_post_meta($post_id, '_order_postmeta', true); |
| 301 | - if ( !empty($order_postmeta['payment_method']) ) { |
|
| 302 | - switch($order_postmeta['payment_method']){ |
|
| 301 | + if (!empty($order_postmeta['payment_method'])) { |
|
| 302 | + switch ($order_postmeta['payment_method']) { |
|
| 303 | 303 | case 'check': |
| 304 | - $pm = __('Check','wpshop'); |
|
| 304 | + $pm = __('Check', 'wpshop'); |
|
| 305 | 305 | break; |
| 306 | 306 | case 'paypal': |
| 307 | - $pm = __('Paypal','wpshop'); |
|
| 307 | + $pm = __('Paypal', 'wpshop'); |
|
| 308 | 308 | break; |
| 309 | 309 | case 'banktransfer': |
| 310 | - $pm = __('Bank transfer','wpshop'); |
|
| 310 | + $pm = __('Bank transfer', 'wpshop'); |
|
| 311 | 311 | break; |
| 312 | 312 | case 'cic': |
| 313 | - $pm = __('Credit card','wpshop'); |
|
| 313 | + $pm = __('Credit card', 'wpshop'); |
|
| 314 | 314 | break; |
| 315 | 315 | default: |
| 316 | - $pm = __('Nc','wpshop'); |
|
| 316 | + $pm = __('Nc', 'wpshop'); |
|
| 317 | 317 | break; |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -333,38 +333,38 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | $paymentMethod = $paymentMethod['mode']; |
| 335 | 335 | $payment_validation .= ' |
| 336 | -<div id="order_payment_method_'.$post_id.'" class="wpshop_cls wpshopHide" > |
|
| 337 | - <input type="hidden" id="used_method_payment_'.$post_id.'" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/> |
|
| 338 | - <input type="hidden" id="used_method_payment_transaction_id_'.$post_id.'" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>'; |
|
| 336 | +<div id="order_payment_method_'.$post_id . '" class="wpshop_cls wpshopHide" > |
|
| 337 | + <input type="hidden" id="used_method_payment_'.$post_id . '" value="' . (!empty($order_postmeta['payment_method']) ? $order_postmeta['payment_method'] : 'no_method') . '"/> |
|
| 338 | + <input type="hidden" id="used_method_payment_transaction_id_'.$post_id . '" value="' . (!empty($transaction_indentifier) ? $transaction_indentifier : 0) . '"/>'; |
|
| 339 | 339 | |
| 340 | - if(!empty($order_postmeta['payment_method'])){ |
|
| 340 | + if (!empty($order_postmeta['payment_method'])) { |
|
| 341 | 341 | $payment_validation .= sprintf(__('Selected payment method: %s', 'wpshop'), __($order_postmeta['payment_method'], 'wpshop')) . '<br/>'; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if(!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) { |
|
| 344 | + if (!empty($paymentMethod['paypal']) && empty($order_postmeta['payment_method'])) { |
|
| 345 | 345 | $payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="paypal" id="payment_method_paypal" /><label for="payment_method_paypal" >' . __('Paypal', 'wpshop') . '</label><br/>'; |
| 346 | 346 | $display_button = true; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - if(!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) { |
|
| 349 | + if (!empty($paymentMethod['checks']) && empty($order_postmeta['payment_method'])) { |
|
| 350 | 350 | $payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="check" id="payment_method_check" /><label for="payment_method_check" >' . __('Check', 'wpshop') . '</label><br/>'; |
| 351 | 351 | $display_button = true; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $wpshop_paymentMethod = get_option( 'wps_payment_mode' ); |
|
| 355 | - if((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) ) && empty($order_postmeta['payment_method'])) { |
|
| 354 | + $wpshop_paymentMethod = get_option('wps_payment_mode'); |
|
| 355 | + if ((WPSHOP_PAYMENT_METHOD_CIC || (!empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic']))) && empty($order_postmeta['payment_method'])) { |
|
| 356 | 356 | $payment_validation .= '<input type="radio" class="payment_method" name="payment_method" value="cb" id="payment_method_cb" /><label for="payment_method_cb" >' . __('Credit card', 'wpshop') . '</label><br/>'; |
| 357 | 357 | $display_button = true; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if(empty($payment_transaction)){ |
|
| 361 | - $payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . ' : <input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_'.$post_id.'" />'; |
|
| 360 | + if (empty($payment_transaction)) { |
|
| 361 | + $payment_validation .= '<hr/>' . __('Transaction number', 'wpshop') . ' : <input type="text" value="" name="payment_method_transaction_number" id="payment_method_transaction_number_' . $post_id . '" />'; |
|
| 362 | 362 | $display_button = true; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - if($display_button){ |
|
| 365 | + if ($display_button) { |
|
| 366 | 366 | $payment_validation .= ' |
| 367 | - <br/><br/><a class="button payment_method_validate order_'.$post_id.' wpshop_clear" >'.__('Validate payment method', 'wpshop').'</a>'; |
|
| 367 | + <br/><br/><a class="button payment_method_validate order_'.$post_id . ' wpshop_clear" >' . __('Validate payment method', 'wpshop') . '</a>'; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | $payment_validation .= ' |
@@ -379,21 +379,21 @@ discard block |
||
| 379 | 379 | * @param float $current_order_total The current order total to pay before partial amount calcul |
| 380 | 380 | * @return array The amount to pay / A html output with amount to pay and different information |
| 381 | 381 | */ |
| 382 | - function partial_payment_calcul( $current_order_total, $for = 'for_all' ) { |
|
| 382 | + function partial_payment_calcul($current_order_total, $for = 'for_all') { |
|
| 383 | 383 | $output = ''; |
| 384 | 384 | $tpl_component = array(); |
| 385 | 385 | |
| 386 | 386 | /** Get current configuration */ |
| 387 | 387 | $partial_payment_configuration = get_option('wpshop_payment_partial', array($for => array(), 'for_quotation' => array())); |
| 388 | - if ( !empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on') ) { |
|
| 388 | + if (!empty($partial_payment_configuration[$for]) && (!empty($partial_payment_configuration[$for]['activate'])) && ($partial_payment_configuration[$for]['activate'] == 'on')) { |
|
| 389 | 389 | $amount_of_partial_payment = 0; |
| 390 | - if ( !empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate']) ) { |
|
| 390 | + if (!empty($partial_payment_configuration[$for]['value']) && !empty($partial_payment_configuration[$for]['activate'])) { |
|
| 391 | 391 | $amount_of_partial_payment = $partial_payment_configuration[$for]['value']; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | $partial_amount_to_pay = 0; |
| 395 | 395 | $type_of_partial_payment = null; |
| 396 | - if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type']) ) { |
|
| 396 | + if (!empty($partial_payment_configuration[$for]) && !empty($partial_payment_configuration[$for]['type'])) { |
|
| 397 | 397 | switch ($partial_payment_configuration[$for]['type']) { |
| 398 | 398 | case 'percentage': |
| 399 | 399 | $type_of_partial_payment = '%'; |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | function set_payment_transaction_number($order_id, $transaction_number) { |
| 454 | 454 | $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
| 455 | 455 | |
| 456 | - if ( !empty($order_postmeta['order_payment']['received']) ) { |
|
| 456 | + if (!empty($order_postmeta['order_payment']['received'])) { |
|
| 457 | 457 | if (count($order_postmeta['order_payment']['received']) == 1) { |
| 458 | 458 | $order_postmeta['order_payment']['received'][0]['payment_reference'] = $transaction_number; |
| 459 | 459 | } |
@@ -467,10 +467,10 @@ discard block |
||
| 467 | 467 | * |
| 468 | 468 | * @param integer $order_id |
| 469 | 469 | */ |
| 470 | - function save_payment_return_data( $order_id ) { |
|
| 470 | + function save_payment_return_data($order_id) { |
|
| 471 | 471 | $data = wpshop_tools::getMethode(); |
| 472 | 472 | |
| 473 | - $current_payment_return = get_post_meta( $order_id, '_wpshop_payment_return_data', true); |
|
| 473 | + $current_payment_return = get_post_meta($order_id, '_wpshop_payment_return_data', true); |
|
| 474 | 474 | $current_payment_return[] = $data; |
| 475 | 475 | |
| 476 | 476 | update_post_meta($order_id, '_wpshop_payment_return_data', $current_payment_return); |
@@ -484,23 +484,23 @@ discard block |
||
| 484 | 484 | * @param array $params : infos sended by the bank, array structure : ('method', 'waited amount', 'status', 'author', 'payment reference', 'date', 'received amount') |
| 485 | 485 | * @return array The order new meta informations |
| 486 | 486 | */ |
| 487 | - public static function add_new_payment_to_order( $order_id, $order_meta, $payment_index, $params, $bank_response ) { |
|
| 488 | - |
|
| 489 | - $order_meta['order_payment']['received'][$payment_index]['method'] = ( !empty($params['method']) ) ? $params['method'] : null; |
|
| 490 | - $order_meta['order_payment']['received'][$payment_index]['waited_amount'] = ( !empty($params['waited_amount']) ) ? $params['waited_amount'] : null; |
|
| 491 | - $order_meta['order_payment']['received'][$payment_index]['status'] = ( !empty($params['status']) ) ? $params['status'] : null; |
|
| 492 | - $order_meta['order_payment']['received'][$payment_index]['author'] = ( !empty($params['author']) ) ? $params['author'] : get_current_user_id(); |
|
| 493 | - $order_meta['order_payment']['received'][$payment_index]['payment_reference'] =( !empty($params['payment_reference']) ) ? $params['payment_reference'] : null; |
|
| 494 | - $order_meta['order_payment']['received'][$payment_index]['date'] = ( !empty($params['date']) ) ? $params['date'] : null; |
|
| 495 | - $order_meta['order_payment']['received'][$payment_index]['received_amount'] = ( !empty($params['received_amount']) ) ? $params['received_amount'] : null; |
|
| 487 | + public static function add_new_payment_to_order($order_id, $order_meta, $payment_index, $params, $bank_response) { |
|
| 488 | + |
|
| 489 | + $order_meta['order_payment']['received'][$payment_index]['method'] = (!empty($params['method'])) ? $params['method'] : null; |
|
| 490 | + $order_meta['order_payment']['received'][$payment_index]['waited_amount'] = (!empty($params['waited_amount'])) ? $params['waited_amount'] : null; |
|
| 491 | + $order_meta['order_payment']['received'][$payment_index]['status'] = (!empty($params['status'])) ? $params['status'] : null; |
|
| 492 | + $order_meta['order_payment']['received'][$payment_index]['author'] = (!empty($params['author'])) ? $params['author'] : get_current_user_id(); |
|
| 493 | + $order_meta['order_payment']['received'][$payment_index]['payment_reference'] = (!empty($params['payment_reference'])) ? $params['payment_reference'] : null; |
|
| 494 | + $order_meta['order_payment']['received'][$payment_index]['date'] = (!empty($params['date'])) ? $params['date'] : null; |
|
| 495 | + $order_meta['order_payment']['received'][$payment_index]['received_amount'] = (!empty($params['received_amount'])) ? $params['received_amount'] : null; |
|
| 496 | 496 | $order_meta['order_payment']['received'][$payment_index]['comment'] = ''; |
| 497 | 497 | |
| 498 | 498 | $order_info = get_post_meta($order_id, '_order_info', true); |
| 499 | - if(!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) { |
|
| 499 | + if (!empty($order_meta) && !empty($order_info) && ($bank_response == 'completed')) { |
|
| 500 | 500 | |
| 501 | 501 | /** Generate an invoice number for the current payment. Check if the payment is complete or not */ |
| 502 | - if ( empty($order_meta['order_invoice_ref']) ) { |
|
| 503 | - $order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number( $order_id ); |
|
| 502 | + if (empty($order_meta['order_invoice_ref'])) { |
|
| 503 | + $order_meta['order_payment']['received'][$payment_index]['invoice_ref'] = wpshop_modules_billing::generate_invoice_number($order_id); |
|
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | * @param string $payment_method |
| 514 | 514 | * @return integer $key : array id of [order_payment][received] in the order postmeta |
| 515 | 515 | */ |
| 516 | - public static function get_order_waiting_payment_array_id ( $oid, $payment_method ) { |
|
| 516 | + public static function get_order_waiting_payment_array_id($oid, $payment_method) { |
|
| 517 | 517 | $key = 0; |
| 518 | - $order_meta = get_post_meta( $oid, '_order_postmeta', true); |
|
| 519 | - if ( !empty($order_meta) ) { |
|
| 520 | - $key = count( $order_meta['order_payment']['received'] ); |
|
| 521 | - foreach ( $order_meta['order_payment']['received'] as $k => $payment_test) { |
|
| 522 | - if ( !array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */ ) { |
|
| 518 | + $order_meta = get_post_meta($oid, '_order_postmeta', true); |
|
| 519 | + if (!empty($order_meta)) { |
|
| 520 | + $key = count($order_meta['order_payment']['received']); |
|
| 521 | + foreach ($order_meta['order_payment']['received'] as $k => $payment_test) { |
|
| 522 | + if (!array_key_exists('received_amount', $payment_test) /* && $order_meta['order_payment']['received'][$k]['method'] == $payment_method */) { |
|
| 523 | 523 | $key = $k; |
| 524 | 524 | } |
| 525 | 525 | } |
@@ -534,52 +534,52 @@ discard block |
||
| 534 | 534 | * @param array $params_array |
| 535 | 535 | * @return string |
| 536 | 536 | */ |
| 537 | - public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true ) { |
|
| 537 | + public static function check_order_payment_total_amount($order_id, $params_array, $bank_response, $order_meta = array(), $save_metadata = true) { |
|
| 538 | 538 | global $wpshop_payment; global $wpdb; |
| 539 | - $order_meta = ( !empty($order_meta) ) ? $order_meta : get_post_meta( $order_id, '_order_postmeta', true); |
|
| 539 | + $order_meta = (!empty($order_meta)) ? $order_meta : get_post_meta($order_id, '_order_postmeta', true); |
|
| 540 | 540 | |
| 541 | 541 | $wps_message = new wps_message_ctr(); |
| 542 | - if ( !empty($order_meta) ) { |
|
| 542 | + if (!empty($order_meta)) { |
|
| 543 | 543 | $order_info = get_post_meta($order_id, '_order_info', true); |
| 544 | - $user_data = get_userdata( $order_meta['customer_id'] ); |
|
| 545 | - $email = ( !empty($user_data) && !empty($user_data->user_email) ) ? $user_data->user_email : ''; |
|
| 544 | + $user_data = get_userdata($order_meta['customer_id']); |
|
| 545 | + $email = (!empty($user_data) && !empty($user_data->user_email)) ? $user_data->user_email : ''; |
|
| 546 | 546 | // $email = ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '' ; |
| 547 | - $first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : '' ); |
|
| 548 | - $last_name = ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : '' ); |
|
| 547 | + $first_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_first_name']) ? $order_info['billing']['address']['address_first_name'] : ''); |
|
| 548 | + $last_name = (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']['address_last_name']) ? $order_info['billing']['address']['address_last_name'] : ''); |
|
| 549 | 549 | |
| 550 | - $key = self::get_order_waiting_payment_array_id( $order_id, $params_array['method']); |
|
| 550 | + $key = self::get_order_waiting_payment_array_id($order_id, $params_array['method']); |
|
| 551 | 551 | $order_grand_total = $order_meta['order_grand_total']; |
| 552 | - $total_received = ( ( !empty($params_array['status']) && ( $params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount']) ) ? $params_array['received_amount'] : 0 ); |
|
| 553 | - foreach ( $order_meta['order_payment']['received'] as $received ) { |
|
| 554 | - $total_received += ( ( !empty($received['status']) && ( $received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount']) ) ? $received['received_amount'] : 0 ); |
|
| 552 | + $total_received = ((!empty($params_array['status']) && ($params_array['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($params_array['received_amount'])) ? $params_array['received_amount'] : 0); |
|
| 553 | + foreach ($order_meta['order_payment']['received'] as $received) { |
|
| 554 | + $total_received += ((!empty($received['status']) && ($received['status'] == 'payment_received') && ($bank_response == 'completed') && !empty($received['received_amount'])) ? $received['received_amount'] : 0); |
|
| 555 | 555 | } |
| 556 | 556 | $order_meta['order_amount_to_pay_now'] = $order_grand_total - $total_received; |
| 557 | - $order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order( $order_id, $order_meta, $key, $params_array, $bank_response ); |
|
| 557 | + $order_meta['order_payment']['received'][$key] = self::add_new_payment_to_order($order_id, $order_meta, $key, $params_array, $bank_response); |
|
| 558 | 558 | |
| 559 | 559 | if ($bank_response == 'completed') { |
| 560 | 560 | |
| 561 | - if ( number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total,2, '.', '') ) { |
|
| 561 | + if (number_format((float)$total_received, 2, '.', '') >= number_format((float)$order_grand_total, 2, '.', '')) { |
|
| 562 | 562 | $payment_status = 'completed'; |
| 563 | 563 | |
| 564 | - $order_meta['order_invoice_ref'] = ( empty ($order_meta['order_invoice_ref'] ) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : ( empty($order_meta['order_invoice_ref']) ? null : $order_meta['order_invoice_ref'] ) ; |
|
| 564 | + $order_meta['order_invoice_ref'] = (empty ($order_meta['order_invoice_ref']) && !empty($order_meta['order_payment']['received'][$key]) && !empty($order_meta['order_payment']['received'][$key]['invoice_ref'])) ? $order_meta['order_payment']['received'][$key]['invoice_ref'] : (empty($order_meta['order_invoice_ref']) ? null : $order_meta['order_invoice_ref']); |
|
| 565 | 565 | $order_meta['order_invoice_date'] = current_time('mysql', 0); |
| 566 | 566 | |
| 567 | 567 | if (!empty($order_meta['order_items'])) { |
| 568 | 568 | foreach ($order_meta['order_items'] as $item_id => $o) { |
| 569 | 569 | $pid = $o['item_id']; |
| 570 | - if (strpos($item_id,'__') !== false) { |
|
| 571 | - $product_data_id = explode( '__', $item_id ); |
|
| 572 | - $pid = ( !empty($product_data_id) && !empty($product_data_id[1]) ) ? $product_data_id[1] : $pid; |
|
| 570 | + if (strpos($item_id, '__') !== false) { |
|
| 571 | + $product_data_id = explode('__', $item_id); |
|
| 572 | + $pid = (!empty($product_data_id) && !empty($product_data_id[1])) ? $product_data_id[1] : $pid; |
|
| 573 | 573 | } |
| 574 | - $product = wpshop_products::get_product_data( $pid ); |
|
| 575 | - if ( get_post_type( $pid ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 576 | - $parent_def = wpshop_products::get_parent_variation ( $pid ); |
|
| 574 | + $product = wpshop_products::get_product_data($pid); |
|
| 575 | + if (get_post_type($pid) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 576 | + $parent_def = wpshop_products::get_parent_variation($pid); |
|
| 577 | 577 | $parent_post = $parent_def['parent_post']; |
| 578 | - $product = wpshop_products::get_product_data( $parent_post->ID ); |
|
| 578 | + $product = wpshop_products::get_product_data($parent_post->ID); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if (!empty($product) && !empty($product['manage_stock']) && strtolower( __($product['manage_stock'], 'wpshop') ) == strtolower( __('Yes', 'wpshop') ) ) { |
|
| 582 | - wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid ); |
|
| 581 | + if (!empty($product) && !empty($product['manage_stock']) && strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop'))) { |
|
| 582 | + wpshop_products::reduce_product_stock_qty($product['product_id'], $o['item_qty'], $pid); |
|
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | } |
@@ -588,45 +588,45 @@ discard block |
||
| 588 | 588 | update_post_meta($order_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '_completed_date', current_time('mysql', 0)); |
| 589 | 589 | |
| 590 | 590 | /** Check if the order content a downloadable product **/ |
| 591 | - if ( !empty($order_meta['order_items']) ) { |
|
| 592 | - foreach( $order_meta['order_items'] as $key_value => $item ) { |
|
| 591 | + if (!empty($order_meta['order_items'])) { |
|
| 592 | + foreach ($order_meta['order_items'] as $key_value => $item) { |
|
| 593 | 593 | $key_value = $item['item_id']; |
| 594 | 594 | /** Check if it's a product with signle variation, check the parent product **/ |
| 595 | - if ( !empty($item['item_id']) && get_post_type( $item['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 596 | - $parent_item = wpshop_products::get_parent_variation( $item['item_id'] ); |
|
| 595 | + if (!empty($item['item_id']) && get_post_type($item['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 596 | + $parent_item = wpshop_products::get_parent_variation($item['item_id']); |
|
| 597 | 597 | $key_value = $parent_item['parent_post']->ID; |
| 598 | 598 | $parent_post_metadata = $parent_item['parent_post_meta']; |
| 599 | - if ( !empty($parent_post_metadata['is_downloadable_']) ) { |
|
| 600 | - $query = $wpdb->prepare( 'SELECT value FROM '. WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS .' WHERE id = %d', $parent_post_metadata['is_downloadable_'] ); |
|
| 601 | - $downloadable_option_value = $wpdb->get_var( $query ); |
|
| 602 | - if ( !empty( $downloadable_option_value) ) { |
|
| 599 | + if (!empty($parent_post_metadata['is_downloadable_'])) { |
|
| 600 | + $query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $parent_post_metadata['is_downloadable_']); |
|
| 601 | + $downloadable_option_value = $wpdb->get_var($query); |
|
| 602 | + if (!empty($downloadable_option_value)) { |
|
| 603 | 603 | $item['item_is_downloadable_'] = $downloadable_option_value; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | - if ( !empty($item) && !empty($item['item_is_downloadable_']) && ( strtolower( __( $item['item_is_downloadable_'], 'wpshop') ) == strtolower( __('Yes', 'wpshop') ) ) ) { |
|
| 610 | - $download_codes = get_user_meta($order_meta['customer_id'], '_order_download_codes_'.$order_id, true); |
|
| 609 | + if (!empty($item) && !empty($item['item_is_downloadable_']) && (strtolower(__($item['item_is_downloadable_'], 'wpshop')) == strtolower(__('Yes', 'wpshop')))) { |
|
| 610 | + $download_codes = get_user_meta($order_meta['customer_id'], '_order_download_codes_' . $order_id, true); |
|
| 611 | 611 | |
| 612 | - if ( !empty($download_codes) && !empty($download_codes[$key_value]) && !empty($download_codes[$key_value]['download_code']) ) { |
|
| 613 | - $link = '<a href="' . admin_url( 'admin-post.php?action=wps_download_file&oid=' . $order_id . '&download=' . $download_codes[$key_value]['download_code'] ) . '">' . __('Download','wpshop') . '</a>'; |
|
| 614 | - $wps_message->wpshop_prepared_email($email, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'download_product_link' => $link), array() ); |
|
| 612 | + if (!empty($download_codes) && !empty($download_codes[$key_value]) && !empty($download_codes[$key_value]['download_code'])) { |
|
| 613 | + $link = '<a href="' . admin_url('admin-post.php?action=wps_download_file&oid=' . $order_id . '&download=' . $download_codes[$key_value]['download_code']) . '">' . __('Download', 'wpshop') . '</a>'; |
|
| 614 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_DOWNLOADABLE_FILE_IS_AVAILABLE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'download_product_link' => $link), array()); |
|
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | // Send confirmation e-mail to administrator |
| 621 | - if ( empty($_SESSION['wps-pos-addon']) ) { |
|
| 621 | + if (empty($_SESSION['wps-pos-addon'])) { |
|
| 622 | 622 | $email_option = get_option('wpshop_emails'); |
| 623 | - if( !empty($email_option) && !empty($email_option['send_confirmation_order_message']) ){ |
|
| 624 | - wpshop_checkout::send_order_email_to_administrator( $order_id, $user_data ); |
|
| 623 | + if (!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) { |
|
| 624 | + wpshop_checkout::send_order_email_to_administrator($order_id, $user_data); |
|
| 625 | 625 | } |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | // POS Status |
| 629 | - if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) { |
|
| 629 | + if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos') { |
|
| 630 | 630 | $payment_status = 'pos'; |
| 631 | 631 | } |
| 632 | 632 | } |
@@ -635,27 +635,27 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | $order_meta['order_status'] = $payment_status; |
| 638 | - update_post_meta( $order_id, '_order_postmeta', $order_meta); |
|
| 638 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 639 | 639 | $save_metadata = false; |
| 640 | 640 | |
| 641 | - $allow_send_invoice = get_option( 'wpshop_send_invoice' ); |
|
| 642 | - $invoice_attachment_file = ( !empty($allow_send_invoice) ) ? wpshop_modules_billing::generate_invoice_for_email( $order_id, empty( $order_meta['order_payment']['received'][$key]['invoice_ref'] ) ? $order_meta['order_invoice_ref'] : $order_meta['order_payment']['received'][$key]['invoice_ref'] ) : ''; |
|
| 641 | + $allow_send_invoice = get_option('wpshop_send_invoice'); |
|
| 642 | + $invoice_attachment_file = (!empty($allow_send_invoice)) ? wpshop_modules_billing::generate_invoice_for_email($order_id, empty($order_meta['order_payment']['received'][$key]['invoice_ref']) ? $order_meta['order_invoice_ref'] : $order_meta['order_payment']['received'][$key]['invoice_ref']) : ''; |
|
| 643 | 643 | |
| 644 | - $email_option = get_option( 'wpshop_emails' ); |
|
| 644 | + $email_option = get_option('wpshop_emails'); |
|
| 645 | 645 | |
| 646 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
| 647 | - $shipping_method = ( !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order_meta['order_payment']['shipping_method'] : '' ); |
|
| 646 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
| 647 | + $shipping_method = (!empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order_meta['order_payment']['shipping_method'] : ''); |
|
| 648 | 648 | |
| 649 | - $payment_method_option = get_option( 'wps_payment_mode' ); |
|
| 650 | - $order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]) ) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method']; |
|
| 649 | + $payment_method_option = get_option('wps_payment_mode'); |
|
| 650 | + $order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method']; |
|
| 651 | 651 | |
| 652 | - if ( !empty( $email_option ) && !empty( $email_option['send_confirmation_order_message'] ) && $payment_status == 'completed' |
|
| 653 | - && ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) ) { |
|
| 654 | - $wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ( ( !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : ''),'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method ) ); |
|
| 652 | + if (!empty($email_option) && !empty($email_option['send_confirmation_order_message']) && $payment_status == 'completed' |
|
| 653 | + && (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email']))) { |
|
| 654 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ((!empty($order_meta['order_key'])) ? $order_meta['order_key'] : ''), 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method)); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - if ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) { |
|
| 658 | - $wps_message->wpshop_prepared_email( $email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file); |
|
| 657 | + if (!isset($params_array['send_received_payment_email']) || (true == $params_array['send_received_payment_email'])) { |
|
| 658 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file); |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | else { |
@@ -663,13 +663,13 @@ discard block |
||
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | $order_meta['order_status'] = $payment_status; |
| 666 | - if( !$save_metadata ) { |
|
| 666 | + if (!$save_metadata) { |
|
| 667 | 667 | return $order_meta; |
| 668 | 668 | } |
| 669 | 669 | else { |
| 670 | - update_post_meta( $order_id, '_order_postmeta', $order_meta); |
|
| 670 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 671 | 671 | } |
| 672 | - update_post_meta( $order_id, '_wpshop_order_status', $payment_status); |
|
| 672 | + update_post_meta($order_id, '_wpshop_order_status', $payment_status); |
|
| 673 | 673 | } |
| 674 | 674 | } |
| 675 | 675 | |
@@ -681,11 +681,11 @@ discard block |
||
| 681 | 681 | * @param integer $order_id The order identifier we want to get the old transaction reference for |
| 682 | 682 | * @return integer |
| 683 | 683 | */ |
| 684 | - public static function get_payment_transaction_number_old_way($order_id){ |
|
| 684 | + public static function get_payment_transaction_number_old_way($order_id) { |
|
| 685 | 685 | $order_postmeta = get_post_meta($order_id, '_order_postmeta', true); |
| 686 | 686 | $transaction_indentifier = 0; |
| 687 | - if(!empty($order_postmeta['payment_method'])){ |
|
| 688 | - switch($order_postmeta['payment_method']){ |
|
| 687 | + if (!empty($order_postmeta['payment_method'])) { |
|
| 688 | + switch ($order_postmeta['payment_method']) { |
|
| 689 | 689 | case 'check': |
| 690 | 690 | $transaction_indentifier = get_post_meta($order_id, '_order_check_number', true); |
| 691 | 691 | break; |
@@ -704,26 +704,26 @@ discard block |
||
| 704 | 704 | return $transaction_indentifier; |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - public static function reverify_payment_invoice_ref( $order_id, $index_payment ) { |
|
| 707 | + public static function reverify_payment_invoice_ref($order_id, $index_payment) { |
|
| 708 | 708 | $status = false; |
| 709 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 710 | - if( !empty( $order_meta ) && !empty( $order_meta['order_payment'] ) && !empty( $order_meta['order_payment']['received'] ) && !empty( $order_meta['order_payment']['received'][$index_payment] ) && empty( $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] ) ) { |
|
| 709 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 710 | + if (!empty($order_meta) && !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received']) && !empty($order_meta['order_payment']['received'][$index_payment]) && empty($order_meta['order_payment']['received'][$index_payment]['invoice_ref'])) { |
|
| 711 | 711 | $order_invoice = $invoice_ref = false; |
| 712 | 712 | |
| 713 | - end( $order_meta['order_payment']['received'] ); |
|
| 714 | - $last_payment = key( $order_meta['order_payment']['received'] ); |
|
| 715 | - if( $last_payment == $index_payment ) { |
|
| 713 | + end($order_meta['order_payment']['received']); |
|
| 714 | + $last_payment = key($order_meta['order_payment']['received']); |
|
| 715 | + if ($last_payment == $index_payment) { |
|
| 716 | 716 | $payments = 0; |
| 717 | - foreach( $order_meta['order_payment']['received'] as $payment ) { |
|
| 718 | - $payments += ( $payment['status'] == 'payment_received' ) ? $payment['received_amount'] : 0; |
|
| 717 | + foreach ($order_meta['order_payment']['received'] as $payment) { |
|
| 718 | + $payments += ($payment['status'] == 'payment_received') ? $payment['received_amount'] : 0; |
|
| 719 | 719 | } |
| 720 | - if( $order_meta['order_grand_total'] <= $payments ) { |
|
| 721 | - if( $order_meta['order_status'] == 'partially_paid' ) { |
|
| 722 | - $order_status_meta = get_post_meta( $order_id, '_wpshop_order_status', true ); |
|
| 720 | + if ($order_meta['order_grand_total'] <= $payments) { |
|
| 721 | + if ($order_meta['order_status'] == 'partially_paid') { |
|
| 722 | + $order_status_meta = get_post_meta($order_id, '_wpshop_order_status', true); |
|
| 723 | 723 | $order_meta['order_status'] = 'completed'; |
| 724 | - $status = (bool)update_post_meta( $order_id, '_wpshop_order_status', 'completed' ); |
|
| 724 | + $status = (bool)update_post_meta($order_id, '_wpshop_order_status', 'completed'); |
|
| 725 | 725 | } |
| 726 | - if( !empty( $order_meta['order_invoice_ref'] ) ) { |
|
| 726 | + if (!empty($order_meta['order_invoice_ref'])) { |
|
| 727 | 727 | $invoice_ref = $order_meta['order_invoice_ref']; |
| 728 | 728 | $status = true; |
| 729 | 729 | } else { |
@@ -734,16 +734,16 @@ discard block |
||
| 734 | 734 | $status = true; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - if( $status ) { |
|
| 738 | - if( empty( $invoice_ref ) ) { |
|
| 739 | - $invoice_ref = wpshop_modules_billing::generate_invoice_number( $order_id ); |
|
| 740 | - if( $order_invoice ) { |
|
| 737 | + if ($status) { |
|
| 738 | + if (empty($invoice_ref)) { |
|
| 739 | + $invoice_ref = wpshop_modules_billing::generate_invoice_number($order_id); |
|
| 740 | + if ($order_invoice) { |
|
| 741 | 741 | $order_meta['order_invoice_ref'] = $invoice_ref; |
| 742 | 742 | } |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | $order_meta['order_payment']['received'][$index_payment]['invoice_ref'] = $invoice_ref; |
| 746 | - $status = (bool)update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
| 746 | + $status = (bool)update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
| 747 | 747 | } |
| 748 | 748 | } |
| 749 | 749 | return $status; |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -40,9 +42,11 @@ discard block |
||
| 40 | 42 | |
| 41 | 43 | public static function construct_url_parameters($url, $param, $value) { |
| 42 | 44 | $interoguation_marker_pos = strpos($url, '?'); |
| 43 | - if($interoguation_marker_pos===false) |
|
| 44 | - return $url.'?'.$param.'='.$value; |
|
| 45 | - else return $url.'&'.$param.'='.$value; |
|
| 45 | + if($interoguation_marker_pos===false) { |
|
| 46 | + return $url.'?'.$param.'='.$value; |
|
| 47 | + } else { |
|
| 48 | + return $url.'&'.$param.'='.$value; |
|
| 49 | + } |
|
| 46 | 50 | } |
| 47 | 51 | |
| 48 | 52 | /** |
@@ -167,8 +171,7 @@ discard block |
||
| 167 | 171 | $tpl_component['CHECKOUT_PAYMENT_METHOD_IDENTIFIER'] = $payment_method_identifier; |
| 168 | 172 | if ( !empty($payment_mode['logo']) && (int)$payment_mode['logo'] != 0 ) { |
| 169 | 173 | $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? wp_get_attachment_image( $payment_method_def['payment_method_icon'], 'thumbnail', false, array('class' => 'wps_shipping_mode_logo') ) : ''; |
| 170 | - } |
|
| 171 | - else { |
|
| 174 | + } else { |
|
| 172 | 175 | $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_method_def['payment_method_icon']) ) ? '<img src="' .$payment_method_def['payment_method_icon']. '" alt="" />' : ''; |
| 173 | 176 | } |
| 174 | 177 | //$tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = $payment_method_def['payment_method_icon']; |
@@ -200,8 +203,7 @@ discard block |
||
| 200 | 203 | |
| 201 | 204 | if ( !empty($payment_config['logo']) && (int)$payment_config['logo'] != 0 ) { |
| 202 | 205 | $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? wp_get_attachment_image( $payment_config['logo'], 'thumbnail', false ) : ''; |
| 203 | - } |
|
| 204 | - else { |
|
| 206 | + } else { |
|
| 205 | 207 | $tpl_component['CHECKOUT_PAYMENT_METHOD_ICON'] = ( !empty($payment_config['logo']) ) ? '<img src="' .$payment_config['logo']. '" alt="' .$payment_config['name']. '" />' : ''; |
| 206 | 208 | } |
| 207 | 209 | $tpl_component['CHECKOUT_PAYMENT_METHOD_NAME'] = ( !empty($payment_config['name']) ) ? $payment_config['name'] : ''; |
@@ -629,8 +631,7 @@ discard block |
||
| 629 | 631 | if( !empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['shipping_method']) && $order_meta['order_payment']['shipping_method'] == 'default_shipping_mode_for_pos' ) { |
| 630 | 632 | $payment_status = 'pos'; |
| 631 | 633 | } |
| 632 | - } |
|
| 633 | - else { |
|
| 634 | + } else { |
|
| 634 | 635 | $payment_status = 'partially_paid'; |
| 635 | 636 | } |
| 636 | 637 | |
@@ -657,16 +658,14 @@ discard block |
||
| 657 | 658 | if ( !isset( $params_array[ 'send_received_payment_email' ] ) || ( true == $params_array[ 'send_received_payment_email' ] ) ) { |
| 658 | 659 | $wps_message->wpshop_prepared_email( $email, 'WPSHOP_OTHERS_PAYMENT_CONFIRMATION_MESSAGE', array('order_key' => $order_meta['order_key'], 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'order_date' => $order_meta['order_date'], 'order_shipping_method' => $shipping_method), array(), $invoice_attachment_file); |
| 659 | 660 | } |
| 660 | - } |
|
| 661 | - else { |
|
| 661 | + } else { |
|
| 662 | 662 | $payment_status = $bank_response; |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | $order_meta['order_status'] = $payment_status; |
| 666 | 666 | if( !$save_metadata ) { |
| 667 | 667 | return $order_meta; |
| 668 | - } |
|
| 669 | - else { |
|
| 668 | + } else { |
|
| 670 | 669 | update_post_meta( $order_id, '_order_postmeta', $order_meta); |
| 671 | 670 | } |
| 672 | 671 | update_post_meta( $order_id, '_wpshop_order_status', $payment_status); |
@@ -198,22 +198,22 @@ |
||
| 198 | 198 | // ---------------------------------------------------------------------------- |
| 199 | 199 | function HtmlEncode ($data) |
| 200 | 200 | { |
| 201 | - $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-"; |
|
| 202 | - $encoded_data = ""; |
|
| 203 | - $result = ""; |
|
| 204 | - for ($i=0; $i<strlen($data); $i++) |
|
| 205 | - { |
|
| 206 | - if (strchr($SAFE_OUT_CHARS, $data{$i})) { |
|
| 207 | - $result .= $data{$i}; |
|
| 208 | - } |
|
| 209 | - else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){ |
|
| 210 | - $result .= "&#x" . $var . ";"; |
|
| 211 | - } |
|
| 212 | - else |
|
| 213 | - $result .= $data{$i}; |
|
| 214 | - |
|
| 215 | - } |
|
| 216 | - return $result; |
|
| 201 | + $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-"; |
|
| 202 | + $encoded_data = ""; |
|
| 203 | + $result = ""; |
|
| 204 | + for ($i=0; $i<strlen($data); $i++) |
|
| 205 | + { |
|
| 206 | + if (strchr($SAFE_OUT_CHARS, $data{$i})) { |
|
| 207 | + $result .= $data{$i}; |
|
| 208 | + } |
|
| 209 | + else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){ |
|
| 210 | + $result .= "&#x" . $var . ";"; |
|
| 211 | + } |
|
| 212 | + else |
|
| 213 | + $result .= $data{$i}; |
|
| 214 | + |
|
| 215 | + } |
|
| 216 | + return $result; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | class wpshop_CIC { |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -81,9 +83,10 @@ discard block |
||
| 81 | 83 | |
| 82 | 84 | private function _checkTpeParams($aConstants) { |
| 83 | 85 | |
| 84 | - for ($i = 0; $i < count($aConstants); $i++) |
|
| 85 | - if (!defined($aConstants[$i])) |
|
| 86 | + for ($i = 0; $i < count($aConstants); $i++) { |
|
| 87 | + if (!defined($aConstants[$i])) |
|
| 86 | 88 | die ("Erreur param�tre " . $aConstants[$i] . " ind�fini"); |
| 89 | + } |
|
| 87 | 90 | } |
| 88 | 91 | |
| 89 | 92 | } |
@@ -126,13 +129,14 @@ discard block |
||
| 126 | 129 | |
| 127 | 130 | $cca0=ord($hexFinal); |
| 128 | 131 | |
| 129 | - if ($cca0>70 && $cca0<97) |
|
| 130 | - $hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1); |
|
| 131 | - else { |
|
| 132 | - if (substr($hexFinal, 1, 1)=="M") |
|
| 133 | - $hexStrKey .= substr($hexFinal, 0, 1) . "0"; |
|
| 134 | - else |
|
| 135 | - $hexStrKey .= substr($hexFinal, 0, 2); |
|
| 132 | + if ($cca0>70 && $cca0<97) { |
|
| 133 | + $hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1); |
|
| 134 | + } else { |
|
| 135 | + if (substr($hexFinal, 1, 1)=="M") { |
|
| 136 | + $hexStrKey .= substr($hexFinal, 0, 1) . "0"; |
|
| 137 | + } else { |
|
| 138 | + $hexStrKey .= substr($hexFinal, 0, 2); |
|
| 139 | + } |
|
| 136 | 140 | } |
| 137 | 141 | |
| 138 | 142 | return pack("H*", $hexStrKey); |
@@ -205,12 +209,11 @@ discard block |
||
| 205 | 209 | { |
| 206 | 210 | if (strchr($SAFE_OUT_CHARS, $data{$i})) { |
| 207 | 211 | $result .= $data{$i}; |
| 208 | - } |
|
| 209 | - else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){ |
|
| 212 | + } else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){ |
|
| 210 | 213 | $result .= "&#x" . $var . ";"; |
| 214 | + } else { |
|
| 215 | + $result .= $data{$i}; |
|
| 211 | 216 | } |
| 212 | - else |
|
| 213 | - $result .= $data{$i}; |
|
| 214 | 217 | |
| 215 | 218 | } |
| 216 | 219 | return $result; |
@@ -329,8 +332,7 @@ discard block |
||
| 329 | 332 | wpshop_payment::check_order_payment_total_amount($CMCIC_bruteVars['reference'], $params_array, $payment_status); |
| 330 | 333 | |
| 331 | 334 | $receipt = CMCIC_CGI2_MACOK; |
| 332 | - } |
|
| 333 | - else { |
|
| 335 | + } else { |
|
| 334 | 336 | // your code if the HMAC doesn't match |
| 335 | 337 | $receipt = CMCIC_CGI2_MACNOTOK.$cgi2_fields; |
| 336 | 338 | } |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | ***************************************************************************************/ |
| 14 | 14 | |
| 15 | 15 | |
| 16 | -define("CMCIC_CTLHMAC","V1.04.sha1.php--[CtlHmac%s%s]-%s"); |
|
| 16 | +define("CMCIC_CTLHMAC", "V1.04.sha1.php--[CtlHmac%s%s]-%s"); |
|
| 17 | 17 | define("CMCIC_CTLHMACSTR", "CtlHmac%s%s"); |
| 18 | -define("CMCIC_CGI2_RECEIPT","version=2\ncdr=%s"); |
|
| 19 | -define("CMCIC_CGI2_MACOK","0"); |
|
| 20 | -define("CMCIC_CGI2_MACNOTOK","1\n"); |
|
| 18 | +define("CMCIC_CGI2_RECEIPT", "version=2\ncdr=%s"); |
|
| 19 | +define("CMCIC_CGI2_MACOK", "0"); |
|
| 20 | +define("CMCIC_CGI2_MACNOTOK", "1\n"); |
|
| 21 | 21 | define("CMCIC_CGI2_FIELDS", "%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*"); |
| 22 | 22 | define("CMCIC_CGI1_FIELDS", "%s*%s*%s%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s"); |
| 23 | 23 | define("CMCIC_URLPAIEMENT", "paiement.cgi"); |
@@ -25,15 +25,15 @@ discard block |
||
| 25 | 25 | class CMCIC_Tpe { |
| 26 | 26 | |
| 27 | 27 | |
| 28 | - public $sVersion; // Version du TPE - TPE Version (Ex : 3.0) |
|
| 29 | - public $sNumero; // Numero du TPE - TPE Number (Ex : 1234567) |
|
| 30 | - public $sCodeSociete; // Code Societe - Company code (Ex : companyname) |
|
| 31 | - public $sLangue; // Langue - Language (Ex : FR, DE, EN, ..) |
|
| 32 | - public $sUrlOK; // Url de retour OK - Return URL OK |
|
| 33 | - public $sUrlKO; // Url de retour KO - Return URL KO |
|
| 34 | - public $sUrlPaiement; // Url du serveur de paiement - Payment Server URL (Ex : https://paiement.creditmutuel.fr/paiement.cgi) |
|
| 28 | + public $sVersion; // Version du TPE - TPE Version (Ex : 3.0) |
|
| 29 | + public $sNumero; // Numero du TPE - TPE Number (Ex : 1234567) |
|
| 30 | + public $sCodeSociete; // Code Societe - Company code (Ex : companyname) |
|
| 31 | + public $sLangue; // Langue - Language (Ex : FR, DE, EN, ..) |
|
| 32 | + public $sUrlOK; // Url de retour OK - Return URL OK |
|
| 33 | + public $sUrlKO; // Url de retour KO - Return URL KO |
|
| 34 | + public $sUrlPaiement; // Url du serveur de paiement - Payment Server URL (Ex : https://paiement.creditmutuel.fr/paiement.cgi) |
|
| 35 | 35 | |
| 36 | - private $_sCle; // La cl� - The Key |
|
| 36 | + private $_sCle; // La cl� - The Key |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | // Constructeur / Constructor |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | $this->sCodeSociete = CMCIC_CODESOCIETE; |
| 53 | 53 | $this->sLangue = $sLangue; |
| 54 | 54 | |
| 55 | - $this->sUrlOK = wpshop_payment::get_success_payment_url();; |
|
| 56 | - $this->sUrlKO = wpshop_payment::get_cancel_payment_url();; |
|
| 55 | + $this->sUrlOK = wpshop_payment::get_success_payment_url(); ; |
|
| 56 | + $this->sUrlKO = wpshop_payment::get_cancel_payment_url(); ; |
|
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | class CMCIC_Hmac { |
| 99 | 99 | |
| 100 | - private $_sUsableKey; // La cl� du TPE en format op�rationnel / The usable TPE key |
|
| 100 | + private $_sUsableKey; // La cl� du TPE en format op�rationnel / The usable TPE key |
|
| 101 | 101 | |
| 102 | 102 | // ---------------------------------------------------------------------------- |
| 103 | 103 | // |
@@ -119,17 +119,17 @@ discard block |
||
| 119 | 119 | // |
| 120 | 120 | // ---------------------------------------------------------------------------- |
| 121 | 121 | |
| 122 | - private function _getUsableKey($oTpe){ |
|
| 122 | + private function _getUsableKey($oTpe) { |
|
| 123 | 123 | |
| 124 | 124 | $hexStrKey = substr($oTpe->getCle(), 0, 38); |
| 125 | 125 | $hexFinal = "" . substr($oTpe->getCle(), 38, 2) . "00"; |
| 126 | 126 | |
| 127 | - $cca0=ord($hexFinal); |
|
| 127 | + $cca0 = ord($hexFinal); |
|
| 128 | 128 | |
| 129 | - if ($cca0>70 && $cca0<97) |
|
| 130 | - $hexStrKey .= chr($cca0-23) . substr($hexFinal, 1, 1); |
|
| 129 | + if ($cca0 > 70 && $cca0 < 97) |
|
| 130 | + $hexStrKey .= chr($cca0 - 23) . substr($hexFinal, 1, 1); |
|
| 131 | 131 | else { |
| 132 | - if (substr($hexFinal, 1, 1)=="M") |
|
| 132 | + if (substr($hexFinal, 1, 1) == "M") |
|
| 133 | 133 | $hexStrKey .= substr($hexFinal, 0, 1) . "0"; |
| 134 | 134 | else |
| 135 | 135 | $hexStrKey .= substr($hexFinal, 0, 2); |
@@ -170,17 +170,17 @@ discard block |
||
| 170 | 170 | // |
| 171 | 171 | // ---------------------------------------------------------------------------- |
| 172 | 172 | |
| 173 | - public function hmac_sha1 ($key, $data) { |
|
| 173 | + public function hmac_sha1($key, $data) { |
|
| 174 | 174 | |
| 175 | 175 | $length = 64; // block length for SHA1 |
| 176 | - if (strlen($key) > $length) { $key = pack("H*",sha1($key)); } |
|
| 176 | + if (strlen($key) > $length) { $key = pack("H*", sha1($key)); } |
|
| 177 | 177 | $key = str_pad($key, $length, chr(0x00)); |
| 178 | 178 | $ipad = str_pad('', $length, chr(0x36)); |
| 179 | 179 | $opad = str_pad('', $length, chr(0x5c)); |
| 180 | - $k_ipad = $key ^ $ipad ; |
|
| 180 | + $k_ipad = $key ^ $ipad; |
|
| 181 | 181 | $k_opad = $key ^ $opad; |
| 182 | 182 | |
| 183 | - return sha1($k_opad . pack("H*",sha1($k_ipad . $data))); |
|
| 183 | + return sha1($k_opad . pack("H*", sha1($k_ipad . $data))); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | } |
@@ -196,17 +196,17 @@ discard block |
||
| 196 | 196 | // ******************** |
| 197 | 197 | // Encodage des caract�res sp�ciaux au format HTML |
| 198 | 198 | // ---------------------------------------------------------------------------- |
| 199 | -function HtmlEncode ($data) |
|
| 199 | +function HtmlEncode($data) |
|
| 200 | 200 | { |
| 201 | 201 | $SAFE_OUT_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-"; |
| 202 | 202 | $encoded_data = ""; |
| 203 | 203 | $result = ""; |
| 204 | - for ($i=0; $i<strlen($data); $i++) |
|
| 204 | + for ($i = 0; $i < strlen($data); $i++) |
|
| 205 | 205 | { |
| 206 | 206 | if (strchr($SAFE_OUT_CHARS, $data{$i})) { |
| 207 | 207 | $result .= $data{$i}; |
| 208 | 208 | } |
| 209 | - else if (($var = bin2hex(substr($data,$i,1))) <= "7F"){ |
|
| 209 | + else if (($var = bin2hex(substr($data, $i, 1))) <= "7F") { |
|
| 210 | 210 | $result .= "&#x" . $var . ";"; |
| 211 | 211 | } |
| 212 | 212 | else |
@@ -220,21 +220,21 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | public function __construct() { |
| 222 | 222 | global $wpshop; |
| 223 | - $cic_option = get_option( 'wpshop_addons' ); |
|
| 224 | - if ( !empty($cic_option) && !empty($cic_option['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC']) ) { |
|
| 223 | + $cic_option = get_option('wpshop_addons'); |
|
| 224 | + if (!empty($cic_option) && !empty($cic_option['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC'])) { |
|
| 225 | 225 | /** Check if SystemPay is registred in Payment Main Option **/ |
| 226 | - $payment_option = get_option( 'wps_payment_mode' ); |
|
| 227 | - if ( !empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('cic', $payment_option['mode']) ) { |
|
| 226 | + $payment_option = get_option('wps_payment_mode'); |
|
| 227 | + if (!empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('cic', $payment_option['mode'])) { |
|
| 228 | 228 | $payment_option['mode']['cic']['name'] = __('CIC', 'wpshop'); |
| 229 | - $payment_option['mode']['cic']['logo'] = WPSHOP_TEMPLATES_URL.'wpshop/medias/cic_payment_logo.jpg'; |
|
| 229 | + $payment_option['mode']['cic']['logo'] = WPSHOP_TEMPLATES_URL . 'wpshop/medias/cic_payment_logo.jpg'; |
|
| 230 | 230 | $payment_option['mode']['cic']['description'] = __('Reservation of products upon confirmation of payment.', 'wpshop'); |
| 231 | - update_option( 'wps_payment_mode', $payment_option ); |
|
| 231 | + update_option('wps_payment_mode', $payment_option); |
|
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $paymentListener = !empty( $_GET['paymentListener'] ) ? sanitize_text_field( $_GET['paymentListener'] ) : ''; |
|
| 235 | + $paymentListener = !empty($_GET['paymentListener']) ? sanitize_text_field($_GET['paymentListener']) : ''; |
|
| 236 | 236 | |
| 237 | - if(!empty($paymentListener) && $paymentListener=='cic') { |
|
| 237 | + if (!empty($paymentListener) && $paymentListener == 'cic') { |
|
| 238 | 238 | header("Pragma: no-cache"); |
| 239 | 239 | header("Content-type: text/plain"); |
| 240 | 240 | self::display_response(); |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | if ($oHmac->computeHmac($cgi2_fields) == strtolower($CMCIC_bruteVars['MAC'])) { |
| 279 | 279 | wpshop_payment::save_payment_return_data($CMCIC_bruteVars['reference']); |
| 280 | 280 | $payment_status = 'denied'; |
| 281 | - switch($CMCIC_bruteVars['code-retour']) { |
|
| 281 | + switch ($CMCIC_bruteVars['code-retour']) { |
|
| 282 | 282 | case "Annulation" : |
| 283 | 283 | // Attention : an autorization may still be delivered for this payment |
| 284 | 284 | //wpshop_payment::setOrderPaymentStatus($CMCIC_bruteVars['reference'], 'denied'); |
@@ -319,15 +319,15 @@ discard block |
||
| 319 | 319 | break; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - $order_meta = get_post_meta( $CMCIC_bruteVars['reference'], '_order_postmeta', true); |
|
| 322 | + $order_meta = get_post_meta($CMCIC_bruteVars['reference'], '_order_postmeta', true); |
|
| 323 | 323 | $params_array = array( |
| 324 | 324 | 'method' => 'cic', |
| 325 | - 'waited_amount' => number_format( (float)$order_meta['order_amount_to_pay_now'], 2, '.', ''), |
|
| 326 | - 'status' => (($payment_status == 'completed') ? ( ( number_format( (float)$order_meta['order_amount_to_pay_now'], 2, '.', '') == number_format( (float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '' ) ) ? 'payment_received' : 'incorrect_amount' ) : $payment_status), |
|
| 325 | + 'waited_amount' => number_format((float)$order_meta['order_amount_to_pay_now'], 2, '.', ''), |
|
| 326 | + 'status' => (($payment_status == 'completed') ? ((number_format((float)$order_meta['order_amount_to_pay_now'], 2, '.', '') == number_format((float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '')) ? 'payment_received' : 'incorrect_amount') : $payment_status), |
|
| 327 | 327 | 'author' => $order_meta['customer_id'], |
| 328 | 328 | 'payment_reference' => $CMCIC_bruteVars['numauto'], |
| 329 | 329 | 'date' => current_time('mysql', 0), |
| 330 | - 'received_amount' => number_format( (float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '' ) |
|
| 330 | + 'received_amount' => number_format((float)substr($CMCIC_bruteVars['montant'], 0, -3), 2, '.', '') |
|
| 331 | 331 | ); |
| 332 | 332 | wpshop_payment::check_order_payment_total_amount($CMCIC_bruteVars['reference'], $params_array, $payment_status); |
| 333 | 333 | |
@@ -335,11 +335,11 @@ discard block |
||
| 335 | 335 | } |
| 336 | 336 | else { |
| 337 | 337 | // your code if the HMAC doesn't match |
| 338 | - $receipt = CMCIC_CGI2_MACNOTOK.$cgi2_fields; |
|
| 338 | + $receipt = CMCIC_CGI2_MACNOTOK . $cgi2_fields; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // Send receipt to CMCIC server |
| 342 | - printf (CMCIC_CGI2_RECEIPT, $receipt); |
|
| 342 | + printf(CMCIC_CGI2_RECEIPT, $receipt); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | public static function display_form($oid) { |
@@ -349,10 +349,10 @@ discard block |
||
| 349 | 349 | $order_customer_info = get_post_meta($oid, '_order_info', true); |
| 350 | 350 | //$currency_code = wpshop_tools::wpshop_get_currency($code=true); |
| 351 | 351 | $current_currency = get_option('wpshop_shop_default_currency'); |
| 352 | - $query = $wpdb->prepare('SELECT code_iso FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency ); |
|
| 353 | - $currency_code = $wpdb->get_var( $query ); |
|
| 352 | + $query = $wpdb->prepare('SELECT code_iso FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency); |
|
| 353 | + $currency_code = $wpdb->get_var($query); |
|
| 354 | 354 | |
| 355 | - if(!empty($order) && !empty($currency_code)) { |
|
| 355 | + if (!empty($order) && !empty($currency_code)) { |
|
| 356 | 356 | |
| 357 | 357 | $sOptions = ""; |
| 358 | 358 | // ---------------------------------------------------------------------------- |
@@ -360,12 +360,12 @@ discard block |
||
| 360 | 360 | // That's your job to set actual order fields. Here is a stub. |
| 361 | 361 | // ----------------------------------------------------------------------------- |
| 362 | 362 | $sReference = $oid; // Reference: unique, alphaNum (A-Z a-z 0-9), 12 characters max |
| 363 | - $sMontant = number_format($order['order_grand_total'],2,'.',''); // Amount : format "xxxxx.yy" (no spaces) |
|
| 363 | + $sMontant = number_format($order['order_grand_total'], 2, '.', ''); // Amount : format "xxxxx.yy" (no spaces) |
|
| 364 | 364 | $sDevise = $currency_code; // Currency : ISO 4217 compliant |
| 365 | 365 | $sTexteLibre = ""; // free texte : a bigger reference, session context for the return on the merchant website |
| 366 | 366 | $sDate = date("d/m/Y:H:i:s"); // transaction date : format d/m/y:h:m:s |
| 367 | 367 | $sLangue = "FR"; // Language of the company code |
| 368 | - $sEmail = $order_customer_info['billing']['address']['address_user_email'];//"[email protected]"; // customer email |
|
| 368 | + $sEmail = $order_customer_info['billing']['address']['address_user_email']; //"[email protected]"; // customer email |
|
| 369 | 369 | /////////////////////////////////////////////////////////////////////////////////////////// |
| 370 | 370 | $sNbrEch = ""; //$sNbrEch = "4"; // between 2 and 4 |
| 371 | 371 | $sDateEcheance1 = ""; // date echeance 1 - format dd/mm/yyyy //$sDateEcheance1 = date("d/m/Y"); |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | $CtlHmac = sprintf(CMCIC_CTLHMAC, $oTpe->sVersion, $oTpe->sNumero, $oHmac->computeHmac(sprintf(CMCIC_CTLHMACSTR, $oTpe->sVersion, $oTpe->sNumero))); |
| 387 | 387 | |
| 388 | 388 | // Data to certify |
| 389 | - $PHP1_FIELDS = sprintf(CMCIC_CGI1_FIELDS, $oTpe->sNumero, |
|
| 389 | + $PHP1_FIELDS = sprintf(CMCIC_CGI1_FIELDS, $oTpe->sNumero, |
|
| 390 | 390 | $sDate, |
| 391 | 391 | $sMontant, |
| 392 | 392 | $sDevise, |
@@ -413,30 +413,30 @@ discard block |
||
| 413 | 413 | ?> |
| 414 | 414 | <script type="text/javascript">jQuery(document).ready(function(){ jQuery('#PaymentRequest_cic').submit(); });</script> |
| 415 | 415 | <div class="paypalPaymentLoading"><span><?php _e('Redirect to the CIC site in progress, please wait...', 'wpshop'); ?></span></div> |
| 416 | - <form action="<?php echo $oTpe->sUrlPaiement;?>" method="post" id="PaymentRequest_cic"> |
|
| 417 | - <input type="hidden" name="version" id="version" value="<?php echo $oTpe->sVersion;?>" /> |
|
| 418 | - <input type="hidden" name="TPE" id="TPE" value="<?php echo $oTpe->sNumero;?>" /> |
|
| 419 | - <input type="hidden" name="date" id="date" value="<?php echo $sDate;?>" /> |
|
| 420 | - <input type="hidden" name="montant" id="montant" value="<?php echo $sMontant . $sDevise;?>" /> |
|
| 421 | - <input type="hidden" name="reference" id="reference" value="<?php echo $sReference;?>" /> |
|
| 422 | - <input type="hidden" name="MAC" id="MAC" value="<?php echo $sMAC;?>" /> |
|
| 423 | - <input type="hidden" name="url_retour" id="url_retour" value="<?php echo $oTpe->sUrlKO;?>" /> |
|
| 424 | - <input type="hidden" name="url_retour_ok" id="url_retour_ok" value="<?php echo $oTpe->sUrlOK;?>" /> |
|
| 425 | - <input type="hidden" name="url_retour_err" id="url_retour_err" value="<?php echo $oTpe->sUrlKO;?>" /> |
|
| 426 | - <input type="hidden" name="lgue" id="lgue" value="<?php echo $oTpe->sLangue;?>" /> |
|
| 427 | - <input type="hidden" name="societe" id="societe" value="<?php echo $oTpe->sCodeSociete;?>" /> |
|
| 428 | - <input type="hidden" name="texte-libre" id="texte-libre" value="<?php echo HtmlEncode($sTexteLibre);?>" /> |
|
| 429 | - <input type="hidden" name="mail" id="mail" value="<?php echo $sEmail;?>" /> |
|
| 416 | + <form action="<?php echo $oTpe->sUrlPaiement; ?>" method="post" id="PaymentRequest_cic"> |
|
| 417 | + <input type="hidden" name="version" id="version" value="<?php echo $oTpe->sVersion; ?>" /> |
|
| 418 | + <input type="hidden" name="TPE" id="TPE" value="<?php echo $oTpe->sNumero; ?>" /> |
|
| 419 | + <input type="hidden" name="date" id="date" value="<?php echo $sDate; ?>" /> |
|
| 420 | + <input type="hidden" name="montant" id="montant" value="<?php echo $sMontant . $sDevise; ?>" /> |
|
| 421 | + <input type="hidden" name="reference" id="reference" value="<?php echo $sReference; ?>" /> |
|
| 422 | + <input type="hidden" name="MAC" id="MAC" value="<?php echo $sMAC; ?>" /> |
|
| 423 | + <input type="hidden" name="url_retour" id="url_retour" value="<?php echo $oTpe->sUrlKO; ?>" /> |
|
| 424 | + <input type="hidden" name="url_retour_ok" id="url_retour_ok" value="<?php echo $oTpe->sUrlOK; ?>" /> |
|
| 425 | + <input type="hidden" name="url_retour_err" id="url_retour_err" value="<?php echo $oTpe->sUrlKO; ?>" /> |
|
| 426 | + <input type="hidden" name="lgue" id="lgue" value="<?php echo $oTpe->sLangue; ?>" /> |
|
| 427 | + <input type="hidden" name="societe" id="societe" value="<?php echo $oTpe->sCodeSociete; ?>" /> |
|
| 428 | + <input type="hidden" name="texte-libre" id="texte-libre" value="<?php echo HtmlEncode($sTexteLibre); ?>" /> |
|
| 429 | + <input type="hidden" name="mail" id="mail" value="<?php echo $sEmail; ?>" /> |
|
| 430 | 430 | <!-- Uniquement pour le Paiement fractionn� --> |
| 431 | - <input type="hidden" name="nbrech" id="nbrech" value="<?php echo $sNbrEch;?>" /> |
|
| 432 | - <input type="hidden" name="dateech1" id="dateech1" value="<?php echo $sDateEcheance1;?>" /> |
|
| 433 | - <input type="hidden" name="montantech1" id="montantech1" value="<?php echo $sMontantEcheance1;?>" /> |
|
| 434 | - <input type="hidden" name="dateech2" id="dateech2" value="<?php echo $sDateEcheance2;?>" /> |
|
| 435 | - <input type="hidden" name="montantech2" id="montantech2" value="<?php echo $sMontantEcheance2;?>" /> |
|
| 436 | - <input type="hidden" name="dateech3" id="dateech3" value="<?php echo $sDateEcheance3;?>" /> |
|
| 437 | - <input type="hidden" name="montantech3" id="montantech3" value="<?php echo $sMontantEcheance3;?>" /> |
|
| 438 | - <input type="hidden" name="dateech4" id="dateech4" value="<?php echo $sDateEcheance4;?>" /> |
|
| 439 | - <input type="hidden" name="montantech4" id="montantech4" value="<?php echo $sMontantEcheance4;?>" /> |
|
| 431 | + <input type="hidden" name="nbrech" id="nbrech" value="<?php echo $sNbrEch; ?>" /> |
|
| 432 | + <input type="hidden" name="dateech1" id="dateech1" value="<?php echo $sDateEcheance1; ?>" /> |
|
| 433 | + <input type="hidden" name="montantech1" id="montantech1" value="<?php echo $sMontantEcheance1; ?>" /> |
|
| 434 | + <input type="hidden" name="dateech2" id="dateech2" value="<?php echo $sDateEcheance2; ?>" /> |
|
| 435 | + <input type="hidden" name="montantech2" id="montantech2" value="<?php echo $sMontantEcheance2; ?>" /> |
|
| 436 | + <input type="hidden" name="dateech3" id="dateech3" value="<?php echo $sDateEcheance3; ?>" /> |
|
| 437 | + <input type="hidden" name="montantech3" id="montantech3" value="<?php echo $sMontantEcheance3; ?>" /> |
|
| 438 | + <input type="hidden" name="dateech4" id="dateech4" value="<?php echo $sDateEcheance4; ?>" /> |
|
| 439 | + <input type="hidden" name="montantech4" id="montantech4" value="<?php echo $sMontantEcheance4; ?>" /> |
|
| 440 | 440 | <!-- --> |
| 441 | 441 | <noscript><input type="submit" name="bouton" id="bouton" value="Connexion / Connection" /></noscript> |
| 442 | 442 | </form> |
@@ -447,16 +447,16 @@ discard block |
||
| 447 | 447 | return $output; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - public static function display_admin_part( $k ) { |
|
| 450 | + public static function display_admin_part($k) { |
|
| 451 | 451 | $cmcic_params = get_option('wpshop_cmcic_params', array()); |
| 452 | 452 | $output = ''; |
| 453 | - $output .= '<h2>' .__('CIC configurations', 'wpshop'). '</h2>'; |
|
| 453 | + $output .= '<h2>' . __('CIC configurations', 'wpshop') . '</h2>'; |
|
| 454 | 454 | $output .= '<div class="wps_shipping_mode_configuration_part">'; |
| 455 | - $output .= '<label class="simple_right">'.__('Key', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[cle]" type="text" value="'. ( !empty( $cmcic_params ) && !empty( $cmcic_params[ 'cle' ] ) ? $cmcic_params['cle'] : '' ).'" /><br />'; |
|
| 456 | - $output .= '<label class="simple_right">'.__('TPE', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[tpe]" type="text" value="'. ( !empty( $cmcic_params ) && !empty( $cmcic_params[ 'tpe' ] ) ? $cmcic_params['tpe']: '' ).'" /><br />'; |
|
| 457 | - $output .= '<label class="simple_right">'.__('Version', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[version]" type="text" value="'. ( !empty( $cmcic_params ) && !empty( $cmcic_params[ 'version' ] ) ? $cmcic_params['version']: '' ).'" /> => 3.0<br />'; |
|
| 458 | - $output .= '<label class="simple_right">'.__('Serveur', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[serveur]" type="text" value="'. ( !empty( $cmcic_params ) && !empty( $cmcic_params[ 'serveur' ] ) ? $cmcic_params['serveur']: '' ).'" /><br />'; |
|
| 459 | - $output .= '<label class="simple_right">'.__('Company code', 'wpshop').'</label><br/><input name="wpshop_cmcic_params[codesociete]" type="text" value="'. ( !empty( $cmcic_params ) && !empty( $cmcic_params[ 'codesociete' ] ) ? $cmcic_params['codesociete']: '' ).'" /><br />'; |
|
| 455 | + $output .= '<label class="simple_right">' . __('Key', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[cle]" type="text" value="' . (!empty($cmcic_params) && !empty($cmcic_params['cle']) ? $cmcic_params['cle'] : '') . '" /><br />'; |
|
| 456 | + $output .= '<label class="simple_right">' . __('TPE', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[tpe]" type="text" value="' . (!empty($cmcic_params) && !empty($cmcic_params['tpe']) ? $cmcic_params['tpe'] : '') . '" /><br />'; |
|
| 457 | + $output .= '<label class="simple_right">' . __('Version', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[version]" type="text" value="' . (!empty($cmcic_params) && !empty($cmcic_params['version']) ? $cmcic_params['version'] : '') . '" /> => 3.0<br />'; |
|
| 458 | + $output .= '<label class="simple_right">' . __('Serveur', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[serveur]" type="text" value="' . (!empty($cmcic_params) && !empty($cmcic_params['serveur']) ? $cmcic_params['serveur'] : '') . '" /><br />'; |
|
| 459 | + $output .= '<label class="simple_right">' . __('Company code', 'wpshop') . '</label><br/><input name="wpshop_cmcic_params[codesociete]" type="text" value="' . (!empty($cmcic_params) && !empty($cmcic_params['codesociete']) ? $cmcic_params['codesociete'] : '') . '" /><br />'; |
|
| 460 | 460 | $output .= '</div>'; |
| 461 | 461 | |
| 462 | 462 | return $output; |
@@ -149,8 +149,8 @@ |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | - * Display the paypal form in order to redirect correctly to paypal |
|
| 153 | - */ |
|
| 152 | + * Display the paypal form in order to redirect correctly to paypal |
|
| 153 | + */ |
|
| 154 | 154 | public static function display_form($oid) { |
| 155 | 155 | global $wpdb; |
| 156 | 156 | $order = get_post_meta($oid, '_order_postmeta', true); |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -45,8 +47,7 @@ discard block |
||
| 45 | 47 | if($paypalMode == 'sandbox') { |
| 46 | 48 | $fp = fsockopen ('ssl://sandbox.paypal.com', 443, $errno, $errstr, 30); |
| 47 | 49 | $host = "www.sandbox.paypal.com"; |
| 48 | - } |
|
| 49 | - else { |
|
| 50 | + } else { |
|
| 50 | 51 | $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); |
| 51 | 52 | $host = "www.paypal.com"; |
| 52 | 53 | } |
@@ -84,8 +85,7 @@ discard block |
||
| 84 | 85 | |
| 85 | 86 | if (!$fp){ |
| 86 | 87 | echo 'HTTP ERROR!'; |
| 87 | - } |
|
| 88 | - else { |
|
| 88 | + } else { |
|
| 89 | 89 | fputs ($fp, $header.$req); |
| 90 | 90 | while (!feof($fp)) { |
| 91 | 91 | $res = fgets ($fp, 1024); |
@@ -113,13 +113,11 @@ discard block |
||
| 113 | 113 | /* Check if the paid amount is equal to the order amount */ |
| 114 | 114 | if ( $amount_paid == $amount2pay ) { |
| 115 | 115 | $payment_status = 'completed'; |
| 116 | - } |
|
| 117 | - else { |
|
| 116 | + } else { |
|
| 118 | 117 | $payment_status = 'incorrect_amount'; |
| 119 | 118 | } |
| 120 | 119 | |
| 121 | - } |
|
| 122 | - else { |
|
| 120 | + } else { |
|
| 123 | 121 | @mail($notify_email, 'VERIFIED DUPLICATED TRANSACTION', 'VERIFIED DUPLICATED TRANSACTION'); |
| 124 | 122 | $payment_status = 'completed'; |
| 125 | 123 | } |
@@ -164,8 +162,11 @@ discard block |
||
| 164 | 162 | if(!empty($paypalBusinessEmail)) { |
| 165 | 163 | |
| 166 | 164 | $paypalMode = get_option('wpshop_paypalMode', null); |
| 167 | - if($paypalMode == 'sandbox') $paypal = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 168 | - else $paypal = 'https://www.paypal.com/cgi-bin/webscr'; |
|
| 165 | + if($paypalMode == 'sandbox') { |
|
| 166 | + $paypal = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 167 | + } else { |
|
| 168 | + $paypal = 'https://www.paypal.com/cgi-bin/webscr'; |
|
| 169 | + } |
|
| 169 | 170 | |
| 170 | 171 | $current_currency = get_option('wpshop_shop_default_currency'); |
| 171 | 172 | $query = $wpdb->prepare('SELECT code_iso FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency ); |
@@ -202,8 +203,7 @@ discard block |
||
| 202 | 203 | <input id="quantity_'.$i.'" name="quantity_'.$i.'" type="hidden" value="1" /> |
| 203 | 204 | <input id="amount_'.$i.'" name="amount_'.$i.'" type="hidden" value="'.number_format($order['order_amount_to_pay_now'], 2, '.', '').'" /> |
| 204 | 205 | '; |
| 205 | - } |
|
| 206 | - else { |
|
| 206 | + } else { |
|
| 207 | 207 | |
| 208 | 208 | $output .= ' |
| 209 | 209 | <input id="item_number_'.$i.'" name="item_number_'.$i.'" type="hidden" value="' .$order['order_key']. '" /> |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -18,38 +18,38 @@ discard block |
||
| 18 | 18 | class wpshop_paypal { |
| 19 | 19 | |
| 20 | 20 | public function __construct() { |
| 21 | - add_filter( 'wps_payment_mode_interface_paypal', array( &$this, 'display_admin_part') ); |
|
| 21 | + add_filter('wps_payment_mode_interface_paypal', array(&$this, 'display_admin_part')); |
|
| 22 | 22 | |
| 23 | 23 | /** Check if SystemPay is registred in Payment Main Option **/ |
| 24 | - $payment_option = get_option( 'wps_payment_mode' ); |
|
| 25 | - if ( !empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('paypal', $payment_option['mode']) ) { |
|
| 24 | + $payment_option = get_option('wps_payment_mode'); |
|
| 25 | + if (!empty($payment_option) && !empty($payment_option['mode']) && !array_key_exists('paypal', $payment_option['mode'])) { |
|
| 26 | 26 | $payment_option['mode']['paypal']['name'] = __('Paypal', 'wpshop'); |
| 27 | - $payment_option['mode']['paypal']['logo'] = WPSHOP_TEMPLATES_URL.'wpshop/medias/paypal.png'; |
|
| 27 | + $payment_option['mode']['paypal']['logo'] = WPSHOP_TEMPLATES_URL . 'wpshop/medias/paypal.png'; |
|
| 28 | 28 | $payment_option['mode']['paypal']['description'] = __('<strong>Tips</strong> : If you have a Paypal account, by choosing this payment method, you will be redirected to the secure payment site Paypal to make your payment. Debit your PayPal account, immediate booking products.', 'wpshop'); |
| 29 | - update_option( 'wps_payment_mode', $payment_option ); |
|
| 29 | + update_option('wps_payment_mode', $payment_option); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $payment_listener = !empty( $_GET['paymentListener'] ) ? sanitize_text_field( $_GET['paymentListener'] ) : ''; |
|
| 32 | + $payment_listener = !empty($_GET['paymentListener']) ? sanitize_text_field($_GET['paymentListener']) : ''; |
|
| 33 | 33 | |
| 34 | - if(!empty($payment_listener) && $payment_listener=='paypal') { |
|
| 34 | + if (!empty($payment_listener) && $payment_listener == 'paypal') { |
|
| 35 | 35 | $payment_status = 'denied'; |
| 36 | 36 | // read the post from PayPal system and add 'cmd' |
| 37 | 37 | $req = 'cmd=_notify-validate'; |
| 38 | 38 | // @TODO : REQUEST |
| 39 | - $post = !empty($_POST) ? (array) $_POST : array(); |
|
| 40 | - foreach ( $post as $key => $value) { |
|
| 39 | + $post = !empty($_POST) ? (array)$_POST : array(); |
|
| 40 | + foreach ($post as $key => $value) { |
|
| 41 | 41 | $value = urlencode(stripslashes($value)); |
| 42 | 42 | $req .= "&$key=$value"; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // If testing on Sandbox use: |
| 46 | 46 | $paypalMode = get_option('wpshop_paypalMode', null); |
| 47 | - if($paypalMode == 'sandbox') { |
|
| 48 | - $fp = fsockopen ('ssl://sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
| 47 | + if ($paypalMode == 'sandbox') { |
|
| 48 | + $fp = fsockopen('ssl://sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
| 49 | 49 | $host = "www.sandbox.paypal.com"; |
| 50 | 50 | } |
| 51 | 51 | else { |
| 52 | - $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); |
|
| 52 | + $fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30); |
|
| 53 | 53 | $host = "www.paypal.com"; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -64,45 +64,45 @@ discard block |
||
| 64 | 64 | $shipping = $_POST['mc_shipping']; // frais de livraison |
| 65 | 65 | $business = $_POST['business']; // compte pro |
| 66 | 66 | $order_id = (int)$_POST['invoice']; // num de facture |
| 67 | - $receiver_email = sanitize_text_field( $_POST['receiver_email'] ); |
|
| 67 | + $receiver_email = sanitize_text_field($_POST['receiver_email']); |
|
| 68 | 68 | $amount_paid = $_POST['mc_gross']; // total (hors frais livraison) |
| 69 | 69 | $txn_id = $_POST['txn_id']; // num�ro de transaction |
| 70 | 70 | $payment_status = $_POST['payment_status']; // status du paiement |
| 71 | 71 | $payer_email = $_POST['payer_email']; // email du client |
| 72 | - $txn_type = sanitize_text_field( $_POST['txn_type'] ); |
|
| 72 | + $txn_type = sanitize_text_field($_POST['txn_type']); |
|
| 73 | 73 | |
| 74 | 74 | // @TODO : REQUEST |
| 75 | - $post = !empty($_POST) ? (array) $_POST : array(); |
|
| 76 | - if ( !empty($post) ) { |
|
| 77 | - foreach ( $post as $key => $value) { |
|
| 78 | - if ( substr($key, 0, 9) == 'item_name' ) { |
|
| 75 | + $post = !empty($_POST) ? (array)$_POST : array(); |
|
| 76 | + if (!empty($post)) { |
|
| 77 | + foreach ($post as $key => $value) { |
|
| 78 | + if (substr($key, 0, 9) == 'item_name') { |
|
| 79 | 79 | //$_POST[$key] = htmlentities($value); |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** Save paypal return data automatically */ |
| 85 | - wpshop_payment::save_payment_return_data( $order_id ); |
|
| 85 | + wpshop_payment::save_payment_return_data($order_id); |
|
| 86 | 86 | |
| 87 | 87 | $notify_email = get_option('wpshop_paypalEmail', null); // email address to which debug emails are sent to |
| 88 | 88 | |
| 89 | - if (!$fp){ |
|
| 89 | + if (!$fp) { |
|
| 90 | 90 | echo 'HTTP ERROR!'; |
| 91 | 91 | } |
| 92 | 92 | else { |
| 93 | - fputs ($fp, $header.$req); |
|
| 93 | + fputs($fp, $header . $req); |
|
| 94 | 94 | while (!feof($fp)) { |
| 95 | - $res = fgets ($fp, 1024); |
|
| 96 | - if (strcmp ($res, "VERIFIED") == 0) { |
|
| 95 | + $res = fgets($fp, 1024); |
|
| 96 | + if (strcmp($res, "VERIFIED") == 0) { |
|
| 97 | 97 | $paypalBusinessEmail = get_option('wpshop_paypalEmail', null); |
| 98 | 98 | |
| 99 | 99 | /** Check if payment has been send to good paypal account */ |
| 100 | 100 | if ($receiver_email == $paypalBusinessEmail) { |
| 101 | 101 | /** Get the payment transaction identifier */ |
| 102 | - $paypal_txn_id = wpshop_payment::get_payment_transaction_number( $order_id, wpshop_payment::get_order_waiting_payment_array_id( $order_id, 'paypal')); |
|
| 102 | + $paypal_txn_id = wpshop_payment::get_payment_transaction_number($order_id, wpshop_payment::get_order_waiting_payment_array_id($order_id, 'paypal')); |
|
| 103 | 103 | |
| 104 | 104 | /** If no transaction reference has been saved for this order */ |
| 105 | - if ( empty($paypal_txn_id) ) { |
|
| 105 | + if (empty($paypal_txn_id)) { |
|
| 106 | 106 | /** Set the payment reference for the order */ |
| 107 | 107 | wpshop_payment::set_payment_transaction_number($order_id, $txn_id); |
| 108 | 108 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $amount_paid = number_format(floatval($amount_paid), 2, '.', ''); |
| 116 | 116 | |
| 117 | 117 | /* Check if the paid amount is equal to the order amount */ |
| 118 | - if ( $amount_paid == $amount2pay ) { |
|
| 118 | + if ($amount_paid == $amount2pay) { |
|
| 119 | 119 | $payment_status = 'completed'; |
| 120 | 120 | } |
| 121 | 121 | else { |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | // if the IPN POST was 'INVALID'...do this |
| 133 | - elseif (strcmp ($res, "INVALID") == 0) { |
|
| 133 | + elseif (strcmp($res, "INVALID") == 0) { |
|
| 134 | 134 | @mail($notify_email, "INVALID IPN", "$res\n $req"); |
| 135 | 135 | $payment_status = 'payment_refused'; |
| 136 | 136 | } |
@@ -138,15 +138,15 @@ discard block |
||
| 138 | 138 | fclose($fp); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - $mc_gross = !empty( $_POST['mc_gross'] ) ? (float)$_POST['mc_gross'] : 0; |
|
| 141 | + $mc_gross = !empty($_POST['mc_gross']) ? (float)$_POST['mc_gross'] : 0; |
|
| 142 | 142 | |
| 143 | 143 | $params_array = array('method' => 'paypal', |
| 144 | 144 | 'waited_amount' => number_format((float)$order['order_amount_to_pay_now'], 2, '.', ''), |
| 145 | - 'status' => ( ( number_format((float)$order['order_amount_to_pay_now'], 2, '.', '') == number_format($mc_gross, 2, '.', '') ) ? 'payment_received' : 'incorrect_amount' ), |
|
| 145 | + 'status' => ((number_format((float)$order['order_amount_to_pay_now'], 2, '.', '') == number_format($mc_gross, 2, '.', '')) ? 'payment_received' : 'incorrect_amount'), |
|
| 146 | 146 | 'author' => $order['customer_id'], |
| 147 | 147 | 'payment_reference' => $txn_id, |
| 148 | 148 | 'date' => current_time('mysql', 0), |
| 149 | - 'received_amount' => number_format($mc_gross, 2, '.', '') ); |
|
| 149 | + 'received_amount' => number_format($mc_gross, 2, '.', '')); |
|
| 150 | 150 | wpshop_payment::check_order_payment_total_amount($order_id, $params_array, $payment_status); |
| 151 | 151 | |
| 152 | 152 | } |
@@ -162,25 +162,25 @@ discard block |
||
| 162 | 162 | $order = get_post_meta($oid, '_order_postmeta', true); |
| 163 | 163 | |
| 164 | 164 | // If the order exist |
| 165 | - if(!empty($order)) { |
|
| 165 | + if (!empty($order)) { |
|
| 166 | 166 | |
| 167 | 167 | $paypalBusinessEmail = get_option('wpshop_paypalEmail', null); |
| 168 | 168 | |
| 169 | 169 | // Si l'email Paypal n'est pas vide |
| 170 | - if(!empty($paypalBusinessEmail)) { |
|
| 170 | + if (!empty($paypalBusinessEmail)) { |
|
| 171 | 171 | |
| 172 | 172 | $paypalMode = get_option('wpshop_paypalMode', null); |
| 173 | - if($paypalMode == 'sandbox') $paypal = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 173 | + if ($paypalMode == 'sandbox') $paypal = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 174 | 174 | else $paypal = 'https://www.paypal.com/cgi-bin/webscr'; |
| 175 | 175 | |
| 176 | 176 | $current_currency = get_option('wpshop_shop_default_currency'); |
| 177 | - $query = $wpdb->prepare('SELECT code_iso FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency ); |
|
| 177 | + $query = $wpdb->prepare('SELECT code_iso FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency); |
|
| 178 | 178 | $currency = $wpdb->get_var($query); |
| 179 | 179 | |
| 180 | 180 | $output = '<script type="text/javascript">jQuery(document).ready(function(){ jQuery("#paypalForm").submit(); });</script>'; |
| 181 | 181 | $output .= '<div class="paypalPaymentLoading"><span>' . __('Redirecting to paypal. Please wait', 'wpshop') . '</span></div>'; |
| 182 | 182 | $output .= ' |
| 183 | - <form action="'.$paypal.'" id="paypalForm" method="post"> |
|
| 183 | + <form action="'.$paypal . '" id="paypalForm" method="post"> |
|
| 184 | 184 | <input id="cmd" name="cmd" type="hidden" value="_cart" /> |
| 185 | 185 | <input id="upload" name="upload" type="hidden" value="1" /> |
| 186 | 186 | <input id="charset" name="charset" type="hidden" value="utf-8" /> |
@@ -188,41 +188,41 @@ discard block |
||
| 188 | 188 | <input id="no_note" name="no_note" type="hidden" value="0" /> |
| 189 | 189 | <input id="rm" name="rm" type="hidden" value="0" /> |
| 190 | 190 | |
| 191 | - <input id="custom" name="custom" type="hidden" value="'.$order['customer_id'].'" /> |
|
| 192 | - <input id="invoice" name="invoice" type="hidden" value="'.$oid.'" /> <!-- Invoice number --> |
|
| 193 | - <input id="business" name="business" type="hidden" value="'.$paypalBusinessEmail.'" /> <!-- Paypal business account --> |
|
| 191 | + <input id="custom" name="custom" type="hidden" value="'.$order['customer_id'] . '" /> |
|
| 192 | + <input id="invoice" name="invoice" type="hidden" value="'.$oid . '" /> <!-- Invoice number --> |
|
| 193 | + <input id="business" name="business" type="hidden" value="'.$paypalBusinessEmail . '" /> <!-- Paypal business account --> |
|
| 194 | 194 | <input id="cbt" name="cbt" type="hidden" value="' . __('Back to shop', 'wpshop') . '" /> |
| 195 | 195 | <input id="lc" name="lc" type="hidden" value="FR" /> |
| 196 | - <input id="currency_code" name="currency_code" type="hidden" value="'.$currency.'" /> |
|
| 196 | + <input id="currency_code" name="currency_code" type="hidden" value="'.$currency . '" /> |
|
| 197 | 197 | |
| 198 | - <input id="return" name="return" type="hidden" value="'.wpshop_payment::get_success_payment_url().'" /> |
|
| 199 | - <input id="cancel_return" name="cancel_return" type="hidden" value="'.wpshop_payment::get_cancel_payment_url().'" /> |
|
| 200 | - <input id="notify_url" name="notify_url" type="hidden" value="'.wpshop_payment::construct_url_parameters(trailingslashit(home_url()), 'paymentListener', 'paypal').'" /> |
|
| 198 | + <input id="return" name="return" type="hidden" value="'.wpshop_payment::get_success_payment_url() . '" /> |
|
| 199 | + <input id="cancel_return" name="cancel_return" type="hidden" value="'.wpshop_payment::get_cancel_payment_url() . '" /> |
|
| 200 | + <input id="notify_url" name="notify_url" type="hidden" value="'.wpshop_payment::construct_url_parameters(trailingslashit(home_url()), 'paymentListener', 'paypal') . '" /> |
|
| 201 | 201 | '; |
| 202 | 202 | |
| 203 | - $i=1; |
|
| 204 | - if ( !empty( $order['order_partial_payment']) && !empty($order['order_partial_payment']['amount_of_partial_payment']) ) { |
|
| 205 | - $output .= ' |
|
| 206 | - <input id="item_number_'.$i.'" name="item_number_'.$i.'" type="hidden" value="' .$oid. '_partial_payment" /> |
|
| 207 | - <input id="item_name_'.$i.'" name="item_name_'.$i.'" type="hidden" value="'.__('Partial payment', 'wpshop').' (' .__('Order number', 'wpshop'). ' : ' .$order['order_key']. ')" /> |
|
| 208 | - <input id="quantity_'.$i.'" name="quantity_'.$i.'" type="hidden" value="1" /> |
|
| 209 | - <input id="amount_'.$i.'" name="amount_'.$i.'" type="hidden" value="'.number_format($order['order_amount_to_pay_now'], 2, '.', '').'" /> |
|
| 203 | + $i = 1; |
|
| 204 | + if (!empty($order['order_partial_payment']) && !empty($order['order_partial_payment']['amount_of_partial_payment'])) { |
|
| 205 | + $output .= ' |
|
| 206 | + <input id="item_number_'.$i . '" name="item_number_' . $i . '" type="hidden" value="' . $oid . '_partial_payment" /> |
|
| 207 | + <input id="item_name_'.$i . '" name="item_name_' . $i . '" type="hidden" value="' . __('Partial payment', 'wpshop') . ' (' . __('Order number', 'wpshop') . ' : ' . $order['order_key'] . ')" /> |
|
| 208 | + <input id="quantity_'.$i . '" name="quantity_' . $i . '" type="hidden" value="1" /> |
|
| 209 | + <input id="amount_'.$i . '" name="amount_' . $i . '" type="hidden" value="' . number_format($order['order_amount_to_pay_now'], 2, '.', '') . '" /> |
|
| 210 | 210 | '; |
| 211 | 211 | } |
| 212 | 212 | else { |
| 213 | 213 | |
| 214 | - $output .= ' |
|
| 215 | - <input id="item_number_'.$i.'" name="item_number_'.$i.'" type="hidden" value="' .$order['order_key']. '" /> |
|
| 216 | - <input id="item_name_'.$i.'" name="item_name_'.$i.'" type="hidden" value="' .__('Current order', 'wpshop'). ' : ' .$order['order_key']. '" /> |
|
| 217 | - <input id="quantity_'.$i.'" name="quantity_'.$i.'" type="hidden" value="1" /> |
|
| 218 | - <input id="amount_'.$i.'" name="amount_'.$i.'" type="hidden" value="'.number_format($order['order_amount_to_pay_now'], 2, '.', '').'" /> |
|
| 214 | + $output .= ' |
|
| 215 | + <input id="item_number_'.$i . '" name="item_number_' . $i . '" type="hidden" value="' . $order['order_key'] . '" /> |
|
| 216 | + <input id="item_name_'.$i . '" name="item_name_' . $i . '" type="hidden" value="' . __('Current order', 'wpshop') . ' : ' . $order['order_key'] . '" /> |
|
| 217 | + <input id="quantity_'.$i . '" name="quantity_' . $i . '" type="hidden" value="1" /> |
|
| 218 | + <input id="amount_'.$i . '" name="amount_' . $i . '" type="hidden" value="' . number_format($order['order_amount_to_pay_now'], 2, '.', '') . '" /> |
|
| 219 | 219 | '; |
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
| 224 | 224 | |
| 225 | - $output .= '<noscript><input type="submit" value="' . __('Checkout', 'wpshop') . '" /></noscript></form>'; |
|
| 225 | + $output .= '<noscript><input type="submit" value="' . __('Checkout', 'wpshop') . '" /></noscript></form>'; |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
@@ -232,16 +232,16 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | function display_admin_part() { |
| 234 | 234 | $paypalEmail = get_option('wpshop_paypalEmail'); |
| 235 | - $paypalMode = get_option('wpshop_paypalMode',0); |
|
| 235 | + $paypalMode = get_option('wpshop_paypalMode', 0); |
|
| 236 | 236 | $output = '<div class="wps-boxed">'; |
| 237 | - $output .= '<div class="wps-form-group"><label>'.__('Business email','wpshop').'</label><div class="wps-form"><input name="wpshop_paypalEmail" type="text" value="'.$paypalEmail.'" /></div></div>'; |
|
| 238 | - $output .= '<label class="simple_right">'.__('Mode','wpshop').'</label>'; |
|
| 237 | + $output .= '<div class="wps-form-group"><label>' . __('Business email', 'wpshop') . '</label><div class="wps-form"><input name="wpshop_paypalEmail" type="text" value="' . $paypalEmail . '" /></div></div>'; |
|
| 238 | + $output .= '<label class="simple_right">' . __('Mode', 'wpshop') . '</label>'; |
|
| 239 | 239 | $output .= '<div class="wps-form"><select name="wpshop_paypalMode">'; |
| 240 | - $output .= '<option value="normal"'.(($paypalMode=='sandbox') ? null : ' selected="selected"').'>'.__('Production mode','wpshop').'</option>'; |
|
| 241 | - $output .= '<option value="sandbox"'.(($paypalMode=='sandbox') ? ' selected="selected"' : null).'>'.__('Sandbox mode','wpshop').'</option>'; |
|
| 240 | + $output .= '<option value="normal"' . (($paypalMode == 'sandbox') ? null : ' selected="selected"') . '>' . __('Production mode', 'wpshop') . '</option>'; |
|
| 241 | + $output .= '<option value="sandbox"' . (($paypalMode == 'sandbox') ? ' selected="selected"' : null) . '>' . __('Sandbox mode', 'wpshop') . '</option>'; |
|
| 242 | 242 | $output .= '</select>'; |
| 243 | 243 | $output .= '</div>'; |
| 244 | - $output .= '<a href="#" title="'.__('This checkbox allow to use Paypal in Sandbox mode (test) or production mode (real money)','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 244 | + $output .= '<a href="#" title="' . __('This checkbox allow to use Paypal in Sandbox mode (test) or production mode (real money)', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 245 | 245 | $output .= '</div>'; |
| 246 | 246 | return $output; |
| 247 | 247 | } |