@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | -$fpdf_charwidths['helveticaI']=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,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>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,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667, |
|
6 | - 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'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,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833, |
|
8 | - 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556, |
|
9 | - chr(132)=>333,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)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, |
|
10 | - chr(154)=>500,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)=>260,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)=>556,chr(182)=>537,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)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, |
|
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)=>500,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)=>556,chr(241)=>556, |
|
14 | - chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500); |
|
2 | +$fpdf_charwidths['helveticaI'] = 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, '!'=>278, '"'=>355, '#'=>556, '$'=>556, '%'=>889, '&'=>667, '\''=>191, '('=>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, ':'=>278, ';'=>278, '<'=>584, '='=>584, '>'=>584, '?'=>556, '@'=>1015, 'A'=>667, |
|
6 | + 'B'=>667, 'C'=>722, 'D'=>722, 'E'=>667, 'F'=>611, 'G'=>778, 'H'=>722, 'I'=>278, 'J'=>500, 'K'=>667, 'L'=>556, '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, '['=>278, '\\'=>278, ']'=>278, '^'=>469, '_'=>556, '`'=>333, 'a'=>556, 'b'=>556, 'c'=>500, 'd'=>556, 'e'=>556, 'f'=>278, 'g'=>556, 'h'=>556, 'i'=>222, 'j'=>222, 'k'=>500, 'l'=>222, 'm'=>833, |
|
8 | + 'n'=>556, 'o'=>556, 'p'=>556, 'q'=>556, 'r'=>333, 's'=>500, 't'=>278, 'u'=>556, 'v'=>500, 'w'=>722, 'x'=>500, 'y'=>500, 'z'=>500, '{'=>334, '|'=>260, '}'=>334, '~'=>584, chr(127)=>350, chr(128)=>556, chr(129)=>350, chr(130)=>222, chr(131)=>556, |
|
9 | + chr(132)=>333, 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)=>222, chr(146)=>222, chr(147)=>333, chr(148)=>333, chr(149)=>350, chr(150)=>556, chr(151)=>1000, chr(152)=>333, chr(153)=>1000, |
|
10 | + chr(154)=>500, 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)=>260, 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)=>556, chr(182)=>537, 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)=>667, chr(193)=>667, chr(194)=>667, chr(195)=>667, chr(196)=>667, chr(197)=>667, |
|
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)=>500, 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)=>556, chr(241)=>556, |
|
14 | + chr(242)=>556, chr(243)=>556, chr(244)=>556, chr(245)=>556, chr(246)=>556, chr(247)=>584, chr(248)=>611, chr(249)=>556, chr(250)=>556, chr(251)=>556, chr(252)=>556, chr(253)=>500, chr(254)=>556, chr(255)=>500); |
|
15 | 15 | ?> |
@@ -1,24 +1,24 @@ |
||
1 | 1 | <?php |
2 | -$type='TrueType'; |
|
3 | -$name='VNI-Times-Italic'; |
|
4 | -$desc=array('Ascent'=>1058,'Descent'=>-218,'CapHeight'=>654,'Flags'=>32,'FontBBox'=>'[-468 -218 1150 1058]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>790); |
|
5 | -$up=-100; |
|
6 | -$ut=50; |
|
7 | -$cw=array( |
|
8 | - chr(0)=>790,chr(1)=>790,chr(2)=>790,chr(3)=>790,chr(4)=>790,chr(5)=>790,chr(6)=>790,chr(7)=>790,chr(8)=>790,chr(9)=>790,chr(10)=>790,chr(11)=>790,chr(12)=>790,chr(13)=>790,chr(14)=>790,chr(15)=>790,chr(16)=>790,chr(17)=>790,chr(18)=>790,chr(19)=>790,chr(20)=>790,chr(21)=>790, |
|
9 | - chr(22)=>790,chr(23)=>790,chr(24)=>790,chr(25)=>790,chr(26)=>790,chr(27)=>790,chr(28)=>790,chr(29)=>790,chr(30)=>790,chr(31)=>790,' '=>250,'!'=>338,'"'=>430,'#'=>502,'$'=>502,'%'=>838,'&'=>788,'\''=>216,'('=>338,')'=>338,'*'=>502,'+'=>686, |
|
10 | - ','=>256,'-'=>338,'.'=>256,'/'=>288,'0'=>502,'1'=>502,'2'=>502,'3'=>502,'4'=>502,'5'=>502,'6'=>502,'7'=>502,'8'=>502,'9'=>502,':'=>338,';'=>338,'<'=>686,'='=>686,'>'=>686,'?'=>502,'@'=>930,'A'=>596, |
|
11 | - 'B'=>614,'C'=>676,'D'=>726,'E'=>614,'F'=>614,'G'=>726,'H'=>726,'I'=>338,'J'=>450,'K'=>676,'L'=>564,'M'=>838,'N'=>676,'O'=>716,'P'=>614,'Q'=>726,'R'=>614,'S'=>502,'T'=>564,'U'=>726,'V'=>614,'W'=>838, |
|
12 | - 'X'=>614,'Y'=>614,'Z'=>564,'['=>400,'\\'=>288,']'=>400,'^'=>430,'_'=>502,'`'=>338,'a'=>502,'b'=>502,'c'=>450,'d'=>502,'e'=>448,'f'=>288,'g'=>502,'h'=>502,'i'=>288,'j'=>288,'k'=>450,'l'=>288,'m'=>726, |
|
13 | - 'n'=>502,'o'=>502,'p'=>502,'q'=>502,'r'=>400,'s'=>400,'t'=>288,'u'=>502,'v'=>450,'w'=>676,'x'=>450,'y'=>450,'z'=>400,'{'=>410,'|'=>288,'}'=>410,'~'=>552,chr(127)=>790,chr(128)=>790,chr(129)=>790,chr(130)=>889,chr(131)=>508, |
|
14 | - chr(132)=>667,chr(133)=>676,chr(134)=>420,chr(135)=>420,chr(136)=>250,chr(137)=>1196,chr(138)=>40,chr(139)=>328,chr(140)=>40,chr(141)=>790,chr(142)=>790,chr(143)=>790,chr(144)=>790,chr(145)=>285,chr(146)=>330,chr(147)=>426,chr(148)=>537,chr(149)=>250,chr(150)=>564,chr(151)=>992,chr(152)=>40,chr(153)=>980, |
|
15 | - chr(154)=>40,chr(155)=>328,chr(156)=>40,chr(157)=>790,chr(158)=>790,chr(159)=>614,chr(160)=>250,chr(161)=>389,chr(162)=>502,chr(163)=>502,chr(164)=>502,chr(165)=>502,chr(166)=>288,chr(167)=>500,chr(168)=>40,chr(169)=>768,chr(170)=>624,chr(171)=>502,chr(172)=>944,chr(173)=>338,chr(174)=>768,chr(175)=>338, |
|
16 | - chr(176)=>882,chr(177)=>686,chr(178)=>308,chr(179)=>308,chr(180)=>40,chr(181)=>502,chr(182)=>558,chr(183)=>250,chr(184)=>40,chr(185)=>308,chr(186)=>664,chr(187)=>502,chr(188)=>758,chr(189)=>758,chr(190)=>758,chr(191)=>500,chr(192)=>40,chr(193)=>40,chr(194)=>40,chr(195)=>40,chr(196)=>40,chr(197)=>40, |
|
17 | - chr(198)=>338,chr(199)=>676,chr(200)=>40,chr(201)=>40,chr(202)=>40,chr(203)=>40,chr(204)=>338,chr(205)=>338,chr(206)=>614,chr(207)=>40,chr(208)=>338,chr(209)=>726,chr(210)=>338,chr(211)=>338,chr(212)=>720,chr(213)=>40,chr(214)=>726,chr(215)=>686,chr(216)=>40,chr(217)=>40,chr(218)=>40,chr(219)=>40, |
|
18 | - chr(220)=>40,chr(221)=>338,chr(222)=>722,chr(223)=>500,chr(224)=>40,chr(225)=>40,chr(226)=>40,chr(227)=>40,chr(228)=>40,chr(229)=>40,chr(230)=>288,chr(231)=>450,chr(232)=>40,chr(233)=>40,chr(234)=>40,chr(235)=>40,chr(236)=>288,chr(237)=>288,chr(238)=>450,chr(239)=>40,chr(240)=>288,chr(241)=>502, |
|
19 | - chr(242)=>288,chr(243)=>288,chr(244)=>502,chr(245)=>40,chr(246)=>502,chr(247)=>686,chr(248)=>40,chr(249)=>40,chr(250)=>40,chr(251)=>40,chr(252)=>40,chr(253)=>288,chr(254)=>500,chr(255)=>450); |
|
20 | -$enc='cp1252'; |
|
21 | -$diff=''; |
|
22 | -$file='vni_timesi.z'; |
|
23 | -$originalsize=53508; |
|
2 | +$type = 'TrueType'; |
|
3 | +$name = 'VNI-Times-Italic'; |
|
4 | +$desc = array('Ascent'=>1058, 'Descent'=>-218, 'CapHeight'=>654, 'Flags'=>32, 'FontBBox'=>'[-468 -218 1150 1058]', 'ItalicAngle'=>0, 'StemV'=>70, 'MissingWidth'=>790); |
|
5 | +$up = -100; |
|
6 | +$ut = 50; |
|
7 | +$cw = array( |
|
8 | + chr(0)=>790, chr(1)=>790, chr(2)=>790, chr(3)=>790, chr(4)=>790, chr(5)=>790, chr(6)=>790, chr(7)=>790, chr(8)=>790, chr(9)=>790, chr(10)=>790, chr(11)=>790, chr(12)=>790, chr(13)=>790, chr(14)=>790, chr(15)=>790, chr(16)=>790, chr(17)=>790, chr(18)=>790, chr(19)=>790, chr(20)=>790, chr(21)=>790, |
|
9 | + chr(22)=>790, chr(23)=>790, chr(24)=>790, chr(25)=>790, chr(26)=>790, chr(27)=>790, chr(28)=>790, chr(29)=>790, chr(30)=>790, chr(31)=>790, ' '=>250, '!'=>338, '"'=>430, '#'=>502, '$'=>502, '%'=>838, '&'=>788, '\''=>216, '('=>338, ')'=>338, '*'=>502, '+'=>686, |
|
10 | + ','=>256, '-'=>338, '.'=>256, '/'=>288, '0'=>502, '1'=>502, '2'=>502, '3'=>502, '4'=>502, '5'=>502, '6'=>502, '7'=>502, '8'=>502, '9'=>502, ':'=>338, ';'=>338, '<'=>686, '='=>686, '>'=>686, '?'=>502, '@'=>930, 'A'=>596, |
|
11 | + 'B'=>614, 'C'=>676, 'D'=>726, 'E'=>614, 'F'=>614, 'G'=>726, 'H'=>726, 'I'=>338, 'J'=>450, 'K'=>676, 'L'=>564, 'M'=>838, 'N'=>676, 'O'=>716, 'P'=>614, 'Q'=>726, 'R'=>614, 'S'=>502, 'T'=>564, 'U'=>726, 'V'=>614, 'W'=>838, |
|
12 | + 'X'=>614, 'Y'=>614, 'Z'=>564, '['=>400, '\\'=>288, ']'=>400, '^'=>430, '_'=>502, '`'=>338, 'a'=>502, 'b'=>502, 'c'=>450, 'd'=>502, 'e'=>448, 'f'=>288, 'g'=>502, 'h'=>502, 'i'=>288, 'j'=>288, 'k'=>450, 'l'=>288, 'm'=>726, |
|
13 | + 'n'=>502, 'o'=>502, 'p'=>502, 'q'=>502, 'r'=>400, 's'=>400, 't'=>288, 'u'=>502, 'v'=>450, 'w'=>676, 'x'=>450, 'y'=>450, 'z'=>400, '{'=>410, '|'=>288, '}'=>410, '~'=>552, chr(127)=>790, chr(128)=>790, chr(129)=>790, chr(130)=>889, chr(131)=>508, |
|
14 | + chr(132)=>667, chr(133)=>676, chr(134)=>420, chr(135)=>420, chr(136)=>250, chr(137)=>1196, chr(138)=>40, chr(139)=>328, chr(140)=>40, chr(141)=>790, chr(142)=>790, chr(143)=>790, chr(144)=>790, chr(145)=>285, chr(146)=>330, chr(147)=>426, chr(148)=>537, chr(149)=>250, chr(150)=>564, chr(151)=>992, chr(152)=>40, chr(153)=>980, |
|
15 | + chr(154)=>40, chr(155)=>328, chr(156)=>40, chr(157)=>790, chr(158)=>790, chr(159)=>614, chr(160)=>250, chr(161)=>389, chr(162)=>502, chr(163)=>502, chr(164)=>502, chr(165)=>502, chr(166)=>288, chr(167)=>500, chr(168)=>40, chr(169)=>768, chr(170)=>624, chr(171)=>502, chr(172)=>944, chr(173)=>338, chr(174)=>768, chr(175)=>338, |
|
16 | + chr(176)=>882, chr(177)=>686, chr(178)=>308, chr(179)=>308, chr(180)=>40, chr(181)=>502, chr(182)=>558, chr(183)=>250, chr(184)=>40, chr(185)=>308, chr(186)=>664, chr(187)=>502, chr(188)=>758, chr(189)=>758, chr(190)=>758, chr(191)=>500, chr(192)=>40, chr(193)=>40, chr(194)=>40, chr(195)=>40, chr(196)=>40, chr(197)=>40, |
|
17 | + chr(198)=>338, chr(199)=>676, chr(200)=>40, chr(201)=>40, chr(202)=>40, chr(203)=>40, chr(204)=>338, chr(205)=>338, chr(206)=>614, chr(207)=>40, chr(208)=>338, chr(209)=>726, chr(210)=>338, chr(211)=>338, chr(212)=>720, chr(213)=>40, chr(214)=>726, chr(215)=>686, chr(216)=>40, chr(217)=>40, chr(218)=>40, chr(219)=>40, |
|
18 | + chr(220)=>40, chr(221)=>338, chr(222)=>722, chr(223)=>500, chr(224)=>40, chr(225)=>40, chr(226)=>40, chr(227)=>40, chr(228)=>40, chr(229)=>40, chr(230)=>288, chr(231)=>450, chr(232)=>40, chr(233)=>40, chr(234)=>40, chr(235)=>40, chr(236)=>288, chr(237)=>288, chr(238)=>450, chr(239)=>40, chr(240)=>288, chr(241)=>502, |
|
19 | + chr(242)=>288, chr(243)=>288, chr(244)=>502, chr(245)=>40, chr(246)=>502, chr(247)=>686, chr(248)=>40, chr(249)=>40, chr(250)=>40, chr(251)=>40, chr(252)=>40, chr(253)=>288, chr(254)=>500, chr(255)=>450); |
|
20 | +$enc = 'cp1252'; |
|
21 | +$diff = ''; |
|
22 | +$file = 'vni_timesi.z'; |
|
23 | +$originalsize = 53508; |
|
24 | 24 | ?> |
@@ -397,10 +397,10 @@ |
||
397 | 397 | $f = fopen($path,'r'); |
398 | 398 | fseek($f,13,SEEK_SET); |
399 | 399 | $info = fread($f,3); |
400 | - fclose($f); |
|
401 | - $iUnit = ord($info{0}); |
|
402 | - $iX = ord($info{1}) * 256 + ord($info{2}); |
|
403 | - return array($iUnit, $iX); |
|
400 | + fclose($f); |
|
401 | + $iUnit = ord($info{0}); |
|
402 | + $iX = ord($info{1}) * 256 + ord($info{2}); |
|
403 | + return array($iUnit, $iX); |
|
404 | 404 | } |
405 | 405 | private function _html2text($text){ |
406 | 406 | $text = str_replace(' ',' ',$text); |
@@ -10,18 +10,18 @@ discard block |
||
10 | 10 | require_once('color.inc.php'); |
11 | 11 | require_once('htmlparser.inc.php'); |
12 | 12 | |
13 | -define('FHR',0.58); |
|
14 | -define('PDFTABLE_VERSION','1.95'); |
|
15 | -$PDF_ALIGN = array('left'=>'L','center'=>'C','right'=>'R','justify'=>'J'); |
|
16 | -$PDF_VALIGN = array('top'=>'T','middle'=>'M','bottom'=>'B'); |
|
17 | -class PDFTable extends FPDF{ |
|
18 | -var $left; //Toa do le trai cua trang |
|
19 | -var $right; //Toa do le phai cua trang |
|
20 | -var $top; //Toa do le tren cua trang |
|
21 | -var $bottom; //Toa do le duoi cua trang |
|
22 | -var $width; //Width of writable zone of page |
|
23 | -var $height; //Height of writable zone of page |
|
24 | -var $defaultFontFamily ; |
|
13 | +define('FHR', 0.58); |
|
14 | +define('PDFTABLE_VERSION', '1.95'); |
|
15 | +$PDF_ALIGN = array('left'=>'L', 'center'=>'C', 'right'=>'R', 'justify'=>'J'); |
|
16 | +$PDF_VALIGN = array('top'=>'T', 'middle'=>'M', 'bottom'=>'B'); |
|
17 | +class PDFTable extends FPDF { |
|
18 | +var $left; //Toa do le trai cua trang |
|
19 | +var $right; //Toa do le phai cua trang |
|
20 | +var $top; //Toa do le tren cua trang |
|
21 | +var $bottom; //Toa do le duoi cua trang |
|
22 | +var $width; //Width of writable zone of page |
|
23 | +var $height; //Height of writable zone of page |
|
24 | +var $defaultFontFamily; |
|
25 | 25 | var $defaultFontStyle; |
26 | 26 | var $defaultFontSize; |
27 | 27 | var $isNotYetSetFont; |
@@ -31,62 +31,62 @@ discard block |
||
31 | 31 | var $spacingLine = 0; //(mm) |
32 | 32 | var $spacingParagraph = 0; //(mm) |
33 | 33 | |
34 | -function PDFTable($orientation='P',$unit='mm',$format='A4'){ |
|
35 | - parent::FPDF($orientation,$unit,$format); |
|
36 | - $this->SetMargins(20,20,20); |
|
34 | +function PDFTable($orientation = 'P', $unit = 'mm', $format = 'A4') { |
|
35 | + parent::FPDF($orientation, $unit, $format); |
|
36 | + $this->SetMargins(20, 20, 20); |
|
37 | 37 | $this->SetAuthor('Pham Minh Dung'); |
38 | 38 | $this->_makePageSize(); |
39 | 39 | $this->isNotYetSetFont = true; |
40 | 40 | $this->headerTable = $this->footerTable = ''; |
41 | 41 | } |
42 | 42 | |
43 | -function SetPadding($s=1){ |
|
43 | +function SetPadding($s = 1) { |
|
44 | 44 | $this->paddingCell = $s; |
45 | - $this->paddingCell2 = 2*$s; |
|
45 | + $this->paddingCell2 = 2 * $s; |
|
46 | 46 | } |
47 | -function SetSpacing($linespacing=1,$paragraphspacing=2){ |
|
47 | +function SetSpacing($linespacing = 1, $paragraphspacing = 2) { |
|
48 | 48 | $this->spacingLine = $linespacing; |
49 | 49 | $this->spacingParagraph = $paragraphspacing; |
50 | 50 | } |
51 | -function SetMargins($left,$top,$right=null,$bottom=null){ |
|
51 | +function SetMargins($left, $top, $right = null, $bottom = null) { |
|
52 | 52 | parent::SetMargins($left, $top, $right); |
53 | - $this->bMargin = $bottom?$bottom:$top; |
|
53 | + $this->bMargin = $bottom ? $bottom : $top; |
|
54 | 54 | $this->_makePageSize(); |
55 | 55 | } |
56 | 56 | |
57 | -function SetLeftMargin($margin){ |
|
57 | +function SetLeftMargin($margin) { |
|
58 | 58 | parent::SetLeftMargin($margin); |
59 | 59 | $this->_makePageSize(); |
60 | 60 | } |
61 | 61 | |
62 | -function SetRightMargin($margin){ |
|
62 | +function SetRightMargin($margin) { |
|
63 | 63 | parent::SetRightMargin($margin); |
64 | 64 | $this->_makePageSize(); |
65 | 65 | } |
66 | 66 | |
67 | -function SetHeaderFooter($header='',$footer=''){ |
|
67 | +function SetHeaderFooter($header = '', $footer = '') { |
|
68 | 68 | if ($header) $this->headerTable = $header; |
69 | 69 | if ($footer) $this->footerTable = $footer; |
70 | 70 | } |
71 | -function Header(){ |
|
71 | +function Header() { |
|
72 | 72 | $this->_makePageSize(); |
73 | - if ($this->headerTable){ |
|
73 | + if ($this->headerTable) { |
|
74 | 74 | $this->x = $this->left; |
75 | 75 | $this->y = 0; |
76 | - $this->htmltable($this->headerTable,0); |
|
76 | + $this->htmltable($this->headerTable, 0); |
|
77 | 77 | } |
78 | 78 | } |
79 | -function Footer(){ |
|
80 | - if ($this->footerTable){ |
|
79 | +function Footer() { |
|
80 | + if ($this->footerTable) { |
|
81 | 81 | $this->x = $this->left; |
82 | 82 | $this->y = $this->bottom; |
83 | - $this->htmltable($this->footerTable,0); |
|
83 | + $this->htmltable($this->footerTable, 0); |
|
84 | 84 | } |
85 | 85 | } |
86 | -private function _makePageSize(){ |
|
86 | +private function _makePageSize() { |
|
87 | 87 | $this->left = $this->lMargin; |
88 | 88 | $this->right = $this->w - $this->rMargin; |
89 | - $this->top = $this->tMargin; |
|
89 | + $this->top = $this->tMargin; |
|
90 | 90 | $this->bottom = $this->h - $this->bMargin; |
91 | 91 | $this->width = $this->right - $this->left; |
92 | 92 | $this->height = $this->bottom - $this->tMargin; |
@@ -96,158 +96,158 @@ discard block |
||
96 | 96 | * @return int |
97 | 97 | * Tra ve chieu cao cua 1 dong theo font hien hanh |
98 | 98 | */ |
99 | -function getLineHeight($fontSize = 0){ |
|
99 | +function getLineHeight($fontSize = 0) { |
|
100 | 100 | if ($fontSize == 0) $fontSize = $this->FontSizePt; |
101 | - return $fontSize*2/$this->k; |
|
101 | + return $fontSize * 2 / $this->k; |
|
102 | 102 | } |
103 | 103 | |
104 | -private function _cellHeight(&$c){ |
|
105 | - $maxw = $c['w0']-$this->paddingCell; |
|
104 | +private function _cellHeight(&$c) { |
|
105 | + $maxw = $c['w0'] - $this->paddingCell; |
|
106 | 106 | $h = 0; |
107 | 107 | $x = $this->paddingCell; |
108 | 108 | $countline = 0; |
109 | 109 | $maxline = 0; |
110 | 110 | $c['hline'] = array(); |
111 | - $c['wlinet'] = array(array(0,0)); |
|
111 | + $c['wlinet'] = array(array(0, 0)); |
|
112 | 112 | $c['wlines'] = array(0); |
113 | 113 | $space = 0; |
114 | - foreach ($c['font'] as &$f){ |
|
114 | + foreach ($c['font'] as &$f) { |
|
115 | 115 | $this->_setFontText($f); |
116 | 116 | $hl = $this->getLineHeight(); |
117 | - if ($maxline<$hl || $x==$this->paddingCell) $maxline=$hl; |
|
117 | + if ($maxline < $hl || $x == $this->paddingCell) $maxline = $hl; |
|
118 | 118 | if (!isset($f['space'])) continue; |
119 | 119 | $space = $f['space']; |
120 | - foreach ($f['line'] as $i=>&$l){ |
|
121 | - if ($x!=$this->paddingCell) $x+=$space; |
|
122 | - if (isset($l['str'])&&is_array($l['str'])) |
|
123 | - foreach ($l['str'] as &$t){ |
|
120 | + foreach ($f['line'] as $i=>&$l) { |
|
121 | + if ($x != $this->paddingCell) $x += $space; |
|
122 | + if (isset($l['str']) && is_array($l['str'])) |
|
123 | + foreach ($l['str'] as &$t) { |
|
124 | 124 | if (!is_array($t)) continue; |
125 | - if ($x==$this->paddingCell||$x+$t[1]<=$maxw){ |
|
125 | + if ($x == $this->paddingCell || $x + $t[1] <= $maxw) { |
|
126 | 126 | $c['wlinet'][$countline][0] += $t[1]; |
127 | 127 | $c['wlinet'][$countline][1]++; |
128 | - $x += $t[1]+(($x>$this->paddingCell)?$space:0); |
|
129 | - }else{//auto break line |
|
130 | - $h+=$maxline*FHR + $this->spacingLine; |
|
131 | - $c['hline'][] = $maxline*FHR + $this->spacingLine; |
|
132 | - $c['wlines'][$countline] = $x-$this->paddingCell; |
|
128 | + $x += $t[1] + (($x > $this->paddingCell) ? $space : 0); |
|
129 | + }else {//auto break line |
|
130 | + $h += $maxline * FHR + $this->spacingLine; |
|
131 | + $c['hline'][] = $maxline * FHR + $this->spacingLine; |
|
132 | + $c['wlines'][$countline] = $x - $this->paddingCell; |
|
133 | 133 | $c['autobr'][$countline] = 1; |
134 | - $maxline=$hl;$countline++;$x = $t[1]+$space; |
|
135 | - $c['wlinet'][$countline] = array($t[1],1); |
|
134 | + $maxline = $hl; $countline++; $x = $t[1] + $space; |
|
135 | + $c['wlinet'][$countline] = array($t[1], 1); |
|
136 | 136 | } |
137 | 137 | $t[2] = $countline; |
138 | 138 | } |
139 | - if ($l=='br'){ |
|
140 | - $h+=$maxline*FHR + max($this->spacingLine,$this->spacingParagraph); |
|
141 | - $c['hline'][] = $maxline*FHR + $this->spacingLine; |
|
142 | - $c['wlines'][$countline] = $x-$this->paddingCell; |
|
143 | - $maxline=$hl;$countline++;$x = $this->paddingCell; |
|
144 | - $c['wlinet'][$countline] = array(0,0); |
|
139 | + if ($l == 'br') { |
|
140 | + $h += $maxline * FHR + max($this->spacingLine, $this->spacingParagraph); |
|
141 | + $c['hline'][] = $maxline * FHR + $this->spacingLine; |
|
142 | + $c['wlines'][$countline] = $x - $this->paddingCell; |
|
143 | + $maxline = $hl; $countline++; $x = $this->paddingCell; |
|
144 | + $c['wlinet'][$countline] = array(0, 0); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
148 | - $c['wlines'][$countline] = $x-$space-$this->paddingCell; |
|
149 | - if ($maxline){ |
|
150 | - $h+=$maxline; |
|
151 | - $c['hline'][] = $maxline*FHR; |
|
148 | + $c['wlines'][$countline] = $x - $space - $this->paddingCell; |
|
149 | + if ($maxline) { |
|
150 | + $h += $maxline; |
|
151 | + $c['hline'][] = $maxline * FHR; |
|
152 | 152 | } |
153 | 153 | $c['maxh'] = $h; |
154 | 154 | return $h; |
155 | 155 | } |
156 | -private function _drawCellAligned($x0,$y0,&$c){ |
|
156 | +private function _drawCellAligned($x0, $y0, &$c) { |
|
157 | 157 | $maxh = $c['h0']; |
158 | - $maxw = $c['w0']-$this->paddingCell2; |
|
158 | + $maxw = $c['w0'] - $this->paddingCell2; |
|
159 | 159 | $curh = $c['maxh']; |
160 | - $x=$y=0; //Top by default |
|
161 | - if ($c['va']=='M') $y = ($maxh-$curh)/2; //Middle |
|
162 | - elseif ($c['va']=='B') $y = $maxh-$curh; //Bottom |
|
160 | + $x = $y = 0; //Top by default |
|
161 | + if ($c['va'] == 'M') $y = ($maxh - $curh) / 2; //Middle |
|
162 | + elseif ($c['va'] == 'B') $y = $maxh - $curh; //Bottom |
|
163 | 163 | $curline = 0; |
164 | 164 | $morespace = 0; |
165 | 165 | $cl = $c['hline'][$curline]; |
166 | - $this->_cellHorzAlignLine($c,$curline,$maxw,$x,$morespace); |
|
167 | - foreach ($c['font'] as &$f){ |
|
166 | + $this->_cellHorzAlignLine($c, $curline, $maxw, $x, $morespace); |
|
167 | + foreach ($c['font'] as &$f) { |
|
168 | 168 | $this->_setFontText($f); |
169 | - if (isset($f['color'])){ |
|
169 | + if (isset($f['color'])) { |
|
170 | 170 | $color = Color::HEX2RGB($f['color']); |
171 | - $this->SetTextColor($color[0],$color[1],$color[2]); |
|
171 | + $this->SetTextColor($color[0], $color[1], $color[2]); |
|
172 | 172 | }else unset($color); |
173 | 173 | $hl = $this->getLineHeight(); |
174 | 174 | if (!isset($f['space'])) continue; |
175 | 175 | $space = $f['space']; |
176 | - foreach ($f['line'] as $i=>&$l){ |
|
177 | - if (isset($l['str'])&&is_array($l['str'])) |
|
178 | - foreach ($l['str'] as &$t){ |
|
179 | - if ($t[2]!=$curline){ |
|
180 | - $y += $cl;$curline++;$cl = $c['hline'][$curline]; |
|
181 | - $this->_cellHorzAlignLine($c,$curline,$maxw,$x,$morespace); |
|
176 | + foreach ($f['line'] as $i=>&$l) { |
|
177 | + if (isset($l['str']) && is_array($l['str'])) |
|
178 | + foreach ($l['str'] as &$t) { |
|
179 | + if ($t[2] != $curline) { |
|
180 | + $y += $cl; $curline++; $cl = $c['hline'][$curline]; |
|
181 | + $this->_cellHorzAlignLine($c, $curline, $maxw, $x, $morespace); |
|
182 | 182 | } |
183 | - $this->x = $x+$x0; |
|
184 | - $this->y = $y+$y0+$cl; |
|
185 | - $this->Cell($t[1],0,$t[0]); |
|
186 | - $x += $t[1]+$space+$morespace; |
|
183 | + $this->x = $x + $x0; |
|
184 | + $this->y = $y + $y0 + $cl; |
|
185 | + $this->Cell($t[1], 0, $t[0]); |
|
186 | + $x += $t[1] + $space + $morespace; |
|
187 | 187 | } |
188 | - if ($l=='br'){ |
|
189 | - $y += $cl;$curline++;$cl = $c['hline'][$curline]; |
|
190 | - $this->_cellHorzAlignLine($c,$curline,$maxw,$x,$morespace); |
|
188 | + if ($l == 'br') { |
|
189 | + $y += $cl; $curline++; $cl = $c['hline'][$curline]; |
|
190 | + $this->_cellHorzAlignLine($c, $curline, $maxw, $x, $morespace); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | if (isset($color)) |
194 | 194 | $this->SetTextColor(0); |
195 | 195 | } |
196 | 196 | } |
197 | -private function _cellHorzAlignLine(&$c,$line,$maxw,&$x,&$morespace){ |
|
197 | +private function _cellHorzAlignLine(&$c, $line, $maxw, &$x, &$morespace) { |
|
198 | 198 | $morespace = 0; |
199 | - $x = $this->paddingCell;//Left by default |
|
200 | - if (!isset($c['wlines'][$line])) return ; |
|
201 | - if ($c['a']=='C'){//Center |
|
202 | - $x = ($maxw-$c['wlines'][$line])/2; |
|
203 | - }elseif ($c['a']=='R'){ |
|
204 | - $x = $maxw-$c['wlines'][$line]; |
|
205 | - }elseif ($c['a']=='J' && $c['wlinet'][$line][1]>1 |
|
206 | - && isset($c['autobr'][$line])){//Justify |
|
207 | - $morespace = ($maxw-$c['wlines'][$line])/($c['wlinet'][$line][1]-1); |
|
199 | + $x = $this->paddingCell; //Left by default |
|
200 | + if (!isset($c['wlines'][$line])) return; |
|
201 | + if ($c['a'] == 'C') {//Center |
|
202 | + $x = ($maxw - $c['wlines'][$line]) / 2; |
|
203 | + }elseif ($c['a'] == 'R') { |
|
204 | + $x = $maxw - $c['wlines'][$line]; |
|
205 | + }elseif ($c['a'] == 'J' && $c['wlinet'][$line][1] > 1 |
|
206 | + && isset($c['autobr'][$line])) {//Justify |
|
207 | + $morespace = ($maxw - $c['wlines'][$line]) / ($c['wlinet'][$line][1] - 1); |
|
208 | 208 | } |
209 | 209 | if ($x < $this->paddingCell) $x = $this->paddingCell; |
210 | 210 | } |
211 | 211 | |
212 | -private function _calWidth($w){ |
|
213 | - $p = strpos($w,'%'); |
|
214 | - if ($p!==false){ |
|
215 | - return intval(substr($w,0,$p)*$this->width/100); |
|
212 | +private function _calWidth($w) { |
|
213 | + $p = strpos($w, '%'); |
|
214 | + if ($p !== false) { |
|
215 | + return intval(substr($w, 0, $p) * $this->width / 100); |
|
216 | 216 | }else return intval($w); |
217 | 217 | } |
218 | 218 | /** |
219 | 219 | * @return array |
220 | 220 | * @desc Parse a string in html and return array of attribute of table |
221 | 221 | */ |
222 | -private function _tableParser(&$html){ |
|
222 | +private function _tableParser(&$html) { |
|
223 | 223 | $t = new TreeHTML(new HTMLParser($html), 0); |
224 | - $row = $col = -1; |
|
224 | + $row = $col = -1; |
|
225 | 225 | $table['nc'] = $table['nr'] = 0; |
226 | 226 | $table['repeat'] = array(); |
227 | 227 | $cell = array(); |
228 | 228 | $fontopen = false; |
229 | 229 | $tdopen = false; |
230 | - foreach ($t->name as $i=>$element){ |
|
231 | - if ($fontopen && $t->type[$i]==NODE_TYPE_ENDELEMENT |
|
232 | - && (in_array($element,array('table','tr','td','font')))) |
|
230 | + foreach ($t->name as $i=>$element) { |
|
231 | + if ($fontopen && $t->type[$i] == NODE_TYPE_ENDELEMENT |
|
232 | + && (in_array($element, array('table', 'tr', 'td', 'font')))) |
|
233 | 233 | $fontopen = false; |
234 | - if ($tdopen && $t->type[$i]==NODE_TYPE_ENDELEMENT |
|
235 | - && (in_array($element,array('table','tr','td'))) |
|
236 | - && !isset($cell[$row][$col]['miw'])){ |
|
234 | + if ($tdopen && $t->type[$i] == NODE_TYPE_ENDELEMENT |
|
235 | + && (in_array($element, array('table', 'tr', 'td'))) |
|
236 | + && !isset($cell[$row][$col]['miw'])) { |
|
237 | 237 | $c = &$cell[$row][$col]; |
238 | 238 | $c['miw'] = $c['maw'] = 0; |
239 | 239 | $tdopen = false; |
240 | 240 | } |
241 | 241 | if ($t->type[$i] != NODE_TYPE_ELEMENT && $t->type[$i] != NODE_TYPE_TEXT) continue; |
242 | - switch ($element){ |
|
242 | + switch ($element) { |
|
243 | 243 | case 'table': |
244 | 244 | $tdopen = 0; |
245 | - $a = &$t->attribute[$i]; |
|
245 | + $a = &$t->attribute[$i]; |
|
246 | 246 | if (isset($a['width'])) $table['w'] = $this->_calWidth($a['width']); |
247 | 247 | if (isset($a['height'])) $table['h'] = intval($a['height']); |
248 | 248 | if (isset($a['align'])) $table['a'] = $this->getAlign(strtolower($a['align'])); |
249 | - $table['border'] = (isset($a['border']))? $a['border']: 0; |
|
250 | - if (isset($a['bgcolor'])) $table['bgcolor'][-1] = $a['bgcolor']; |
|
249 | + $table['border'] = (isset($a['border'])) ? $a['border'] : 0; |
|
250 | + if (isset($a['bgcolor'])) $table['bgcolor'][-1] = $a['bgcolor']; |
|
251 | 251 | $table['nobreak'] = isset($a['nobreak']); |
252 | 252 | break; |
253 | 253 | case 'tr': |
@@ -255,156 +255,156 @@ discard block |
||
255 | 255 | $row++; |
256 | 256 | $table['nr']++; |
257 | 257 | $col = -1; |
258 | - $a = &$t->attribute[$i]; |
|
259 | - if (isset($a['bgcolor'])) $table['bgcolor'][$row] = $a['bgcolor']; |
|
260 | - if (isset($a['repeat'])) $table['repeat'][] = $row; |
|
261 | - else{ |
|
262 | - if (isset($a['pbr'])) $table['pbr'][$row] = 1; |
|
263 | - if (isset($a['knext'])) $table['knext'][$row] = 1; |
|
258 | + $a = &$t->attribute[$i]; |
|
259 | + if (isset($a['bgcolor'])) $table['bgcolor'][$row] = $a['bgcolor']; |
|
260 | + if (isset($a['repeat'])) $table['repeat'][] = $row; |
|
261 | + else { |
|
262 | + if (isset($a['pbr'])) $table['pbr'][$row] = 1; |
|
263 | + if (isset($a['knext'])) $table['knext'][$row] = 1; |
|
264 | 264 | } |
265 | 265 | break; |
266 | 266 | case 'td': |
267 | 267 | $tdopen = 1; |
268 | - $col++;while (isset($cell[$row][$col])) $col++; |
|
268 | + $col++; while (isset($cell[$row][$col])) $col++; |
|
269 | 269 | //Update number column |
270 | - if ($table['nc'] < $col+1) $table['nc'] = $col+1; |
|
270 | + if ($table['nc'] < $col + 1) $table['nc'] = $col + 1; |
|
271 | 271 | $cell[$row][$col] = array(); |
272 | 272 | $c = &$cell[$row][$col]; |
273 | 273 | $a = &$t->attribute[$i]; |
274 | 274 | if (isset($a['width'])) $c['w'] = intval($a['width']); |
275 | 275 | if (isset($a['height'])) $c['h'] = intval($a['height']); |
276 | - $c['a'] = isset($a['align'])?$this->getAlign($a['align']):'L'; |
|
277 | - $c['va']= isset($a['valign'])?$this->getVAlign($a['valign']):'T'; |
|
278 | - if (isset($a['border'])) $c['border'] = $a['border']; |
|
279 | - else $c['border'] = $table['border']; |
|
280 | - if (isset($a['bgcolor'])) $c['bgcolor'] = $a['bgcolor']; |
|
276 | + $c['a'] = isset($a['align']) ? $this->getAlign($a['align']) : 'L'; |
|
277 | + $c['va'] = isset($a['valign']) ? $this->getVAlign($a['valign']) : 'T'; |
|
278 | + if (isset($a['border'])) $c['border'] = $a['border']; |
|
279 | + else $c['border'] = $table['border']; |
|
280 | + if (isset($a['bgcolor'])) $c['bgcolor'] = $a['bgcolor']; |
|
281 | 281 | $cs = $rs = 1; |
282 | - if (isset($a['colspan']) && $a['colspan']>1) $cs = $c['colspan'] = intval($a['colspan']); |
|
283 | - if (isset($a['rowspan']) && $a['rowspan']>1) $rs = $c['rowspan'] = intval($a['rowspan']); |
|
282 | + if (isset($a['colspan']) && $a['colspan'] > 1) $cs = $c['colspan'] = intval($a['colspan']); |
|
283 | + if (isset($a['rowspan']) && $a['rowspan'] > 1) $rs = $c['rowspan'] = intval($a['rowspan']); |
|
284 | 284 | if (isset($a['size'])) $c['font'][0]['size'] = $a['size']; |
285 | - if (isset($a['family'])) $c['font'][0]['family'] = $a['family']; |
|
286 | - if (isset($a['style'])){ |
|
285 | + if (isset($a['family'])) $c['font'][0]['family'] = $a['family']; |
|
286 | + if (isset($a['style'])) { |
|
287 | 287 | $STYLE = explode(",", strtoupper($a['style'])); |
288 | 288 | $fontStyle = ''; |
289 | - foreach($STYLE AS $style) $fontStyle .= substr(trim($style), 0, 1); |
|
289 | + foreach ($STYLE AS $style) $fontStyle .= substr(trim($style), 0, 1); |
|
290 | 290 | $c['font'][0]['style'] = $fontStyle; |
291 | 291 | } |
292 | - if (isset($a['color'])) $c['font'][0]['color'] = $a['color']; |
|
292 | + if (isset($a['color'])) $c['font'][0]['color'] = $a['color']; |
|
293 | 293 | //Chiem dung vi tri de danh cho cell span |
294 | - for ($k=$row;$k<$row+$rs;$k++) for($l=$col;$l<$col+$cs;$l++){ |
|
295 | - if ($k-$row || $l-$col) |
|
294 | + for ($k = $row; $k < $row + $rs; $k++) for ($l = $col; $l < $col + $cs; $l++) { |
|
295 | + if ($k - $row || $l - $col) |
|
296 | 296 | $cell[$k][$l] = 0; |
297 | 297 | } |
298 | - if (isset($a['nowrap'])) $c['nowrap']= 1; |
|
298 | + if (isset($a['nowrap'])) $c['nowrap'] = 1; |
|
299 | 299 | $fontopen = true; |
300 | 300 | if (!isset($c['font'])) $c['font'][] = array(); |
301 | 301 | break; |
302 | 302 | case 'Text': |
303 | 303 | $c = &$cell[$row][$col]; |
304 | 304 | if (!$fontopen || !isset($c['font'])) $c['font'][] = array(); |
305 | - $f = &$c['font'][count($c['font'])-1]; |
|
306 | - $this->_setTextAndSize($c,$f,$this->_html2text($t->value[$i])); |
|
305 | + $f = &$c['font'][count($c['font']) - 1]; |
|
306 | + $this->_setTextAndSize($c, $f, $this->_html2text($t->value[$i])); |
|
307 | 307 | break; |
308 | 308 | case 'font': |
309 | 309 | $a = &$t->attribute[$i]; |
310 | 310 | $c = &$cell[$row][$col]; |
311 | 311 | $c['font'][] = array(); |
312 | - $f = &$c['font'][count($c['font'])-1]; |
|
313 | - if (isset($a['size'])) $f['size'] = $a['size']; |
|
314 | - if (isset($a['family'])) $f['family'] = $a['family']; |
|
315 | - if (isset($a['style'])){ |
|
312 | + $f = &$c['font'][count($c['font']) - 1]; |
|
313 | + if (isset($a['size'])) $f['size'] = $a['size']; |
|
314 | + if (isset($a['family'])) $f['family'] = $a['family']; |
|
315 | + if (isset($a['style'])) { |
|
316 | 316 | $STYLE = explode(",", strtoupper($a['style'])); |
317 | 317 | $fontStyle = ''; |
318 | - foreach($STYLE AS $style) $fontStyle .= substr(trim($style), 0, 1); |
|
318 | + foreach ($STYLE AS $style) $fontStyle .= substr(trim($style), 0, 1); |
|
319 | 319 | $f['style'] = $fontStyle; |
320 | 320 | } |
321 | - if (isset($a['color'])) $f['color'] = $a['color']; |
|
321 | + if (isset($a['color'])) $f['color'] = $a['color']; |
|
322 | 322 | break; |
323 | 323 | case 'img': |
324 | - $a = &$t->attribute[$i]; |
|
325 | - if (isset($a['src'])){ |
|
326 | - $this->_setImage($c,$a); |
|
324 | + $a = &$t->attribute[$i]; |
|
325 | + if (isset($a['src'])) { |
|
326 | + $this->_setImage($c, $a); |
|
327 | 327 | } |
328 | 328 | break; |
329 | 329 | case 'br': |
330 | 330 | $c = &$cell[$row][$col]; |
331 | - $cn = isset($c['font'])?count($c['font'])-1:0; |
|
331 | + $cn = isset($c['font']) ?count($c['font']) - 1 : 0; |
|
332 | 332 | $c['font'][$cn]['line'][] = 'br'; |
333 | 333 | break; |
334 | 334 | } |
335 | 335 | } |
336 | 336 | $table['cells'] = $cell; |
337 | - $table['wc'] = array_pad(array(),$table['nc'],array('miw'=>0,'maw'=>0)); |
|
338 | - $table['hr'] = array_pad(array(),$table['nr'],0); |
|
337 | + $table['wc'] = array_pad(array(), $table['nc'], array('miw'=>0, 'maw'=>0)); |
|
338 | + $table['hr'] = array_pad(array(), $table['nr'], 0); |
|
339 | 339 | return $table; |
340 | 340 | } |
341 | 341 | |
342 | -private function _setTextAndSize(&$cell,&$f, $text){ |
|
343 | - if ($text=='') return; |
|
342 | +private function _setTextAndSize(&$cell, &$f, $text) { |
|
343 | + if ($text == '') return; |
|
344 | 344 | $this->_setFontText($f); |
345 | - if (!isset($f['line'][0])){ |
|
345 | + if (!isset($f['line'][0])) { |
|
346 | 346 | $f['line'][0]['min'] = $f['line'][0]['max'] = 0; |
347 | 347 | } |
348 | - $text = preg_split('/[\s]+/',$text,-1, PREG_SPLIT_NO_EMPTY); |
|
349 | - $l = &$f['line'][count($f['line'])-1]; |
|
350 | - if ($l=='br'){ |
|
351 | - $f['line'][] = array('min'=>0,'max'=>0,'str'=>array()); |
|
352 | - $l = &$f['line'][count($f['line'])-1]; |
|
348 | + $text = preg_split('/[\s]+/', $text, -1, PREG_SPLIT_NO_EMPTY); |
|
349 | + $l = &$f['line'][count($f['line']) - 1]; |
|
350 | + if ($l == 'br') { |
|
351 | + $f['line'][] = array('min'=>0, 'max'=>0, 'str'=>array()); |
|
352 | + $l = &$f['line'][count($f['line']) - 1]; |
|
353 | 353 | } |
354 | 354 | if (!isset($f['space'])) $f['space'] = $this->GetStringWidth(' '); |
355 | 355 | $ct = count($text); |
356 | - foreach ($text as $item){ |
|
356 | + foreach ($text as $item) { |
|
357 | 357 | $s = $this->GetStringWidth($item); |
358 | - if ($l['min']<$s) $l['min']=$s; |
|
358 | + if ($l['min'] < $s) $l['min'] = $s; |
|
359 | 359 | $l['max'] += $s; |
360 | - if ($ct>1) $l['max'] += $f['space']; |
|
361 | - $l['str'][] = array($item,$s); |
|
360 | + if ($ct > 1) $l['max'] += $f['space']; |
|
361 | + $l['str'][] = array($item, $s); |
|
362 | 362 | } |
363 | 363 | if (isset($cell['nowrap'])) $l['min'] = $l['max']; |
364 | - if (!isset($cell['miw']) || $cell['miw']-$this->paddingCell2<$l['min']) |
|
365 | - $cell['miw']=$l['min']+$this->paddingCell2; |
|
366 | - if (!isset($cell['maw']) || $cell['maw']-$this->paddingCell2<$l['max']) |
|
367 | - $cell['maw']=$l['max']+$this->paddingCell2; |
|
364 | + if (!isset($cell['miw']) || $cell['miw'] - $this->paddingCell2 < $l['min']) |
|
365 | + $cell['miw'] = $l['min'] + $this->paddingCell2; |
|
366 | + if (!isset($cell['maw']) || $cell['maw'] - $this->paddingCell2 < $l['max']) |
|
367 | + $cell['maw'] = $l['max'] + $this->paddingCell2; |
|
368 | 368 | } |
369 | 369 | |
370 | -private function _setImage(&$c, &$a){ |
|
370 | +private function _setImage(&$c, &$a) { |
|
371 | 371 | $path = $a['src']; |
372 | - if (!is_file($path)){ |
|
372 | + if (!is_file($path)) { |
|
373 | 373 | $this->Error('Image is not exists: '.$path); |
374 | - }else{ |
|
375 | - list($u,$d) = $this->_getResolution($path); |
|
374 | + }else { |
|
375 | + list($u, $d) = $this->_getResolution($path); |
|
376 | 376 | $c['img'] = $path; |
377 | - list($c['w'],$c['h'],) = getimagesize($path); |
|
377 | + list($c['w'], $c['h'],) = getimagesize($path); |
|
378 | 378 | if (isset($a['width'])) $c['w'] = $a['width']; |
379 | 379 | if (isset($a['height'])) $c['h'] = $a['height']; |
380 | 380 | $scale = 1; |
381 | - if ($u==1) $scale = 25.4/$d; |
|
382 | - elseif ($u==2) $scale = 10/$d; |
|
383 | - $c['w'] = intval($c['w']*$scale); |
|
384 | - $c['h'] = intval($c['h']*$scale); |
|
381 | + if ($u == 1) $scale = 25.4 / $d; |
|
382 | + elseif ($u == 2) $scale = 10 / $d; |
|
383 | + $c['w'] = intval($c['w'] * $scale); |
|
384 | + $c['h'] = intval($c['h'] * $scale); |
|
385 | 385 | } |
386 | 386 | } |
387 | -private function _getResolution($path){ |
|
388 | - $pos=strrpos($path,'.'); |
|
389 | - if(!$pos) |
|
387 | +private function _getResolution($path) { |
|
388 | + $pos = strrpos($path, '.'); |
|
389 | + if (!$pos) |
|
390 | 390 | $this->Error('Image file has no extension and no type was specified: '.$path); |
391 | - $type=substr($path,$pos+1); |
|
392 | - $type=strtolower($type); |
|
393 | - if($type=='jpeg') |
|
394 | - $type='jpg'; |
|
395 | - if ($type!='jpg') |
|
391 | + $type = substr($path, $pos + 1); |
|
392 | + $type = strtolower($type); |
|
393 | + if ($type == 'jpeg') |
|
394 | + $type = 'jpg'; |
|
395 | + if ($type != 'jpg') |
|
396 | 396 | $this->Error('Unsupported image type: '.$path); |
397 | - $f = fopen($path,'r'); |
|
398 | - fseek($f,13,SEEK_SET); |
|
399 | - $info = fread($f,3); |
|
397 | + $f = fopen($path, 'r'); |
|
398 | + fseek($f, 13, SEEK_SET); |
|
399 | + $info = fread($f, 3); |
|
400 | 400 | fclose($f); |
401 | 401 | $iUnit = ord($info{0}); |
402 | 402 | $iX = ord($info{1}) * 256 + ord($info{2}); |
403 | 403 | return array($iUnit, $iX); |
404 | 404 | } |
405 | -private function _html2text($text){ |
|
406 | - $text = str_replace(' ',' ',$text); |
|
407 | - $text = str_replace('<','<',$text); |
|
405 | +private function _html2text($text) { |
|
406 | + $text = str_replace(' ', ' ', $text); |
|
407 | + $text = str_replace('<', '<', $text); |
|
408 | 408 | return $text; |
409 | 409 | } |
410 | 410 | |
@@ -418,37 +418,37 @@ discard block |
||
418 | 418 | * wc List of width of each column |
419 | 419 | * cells List of cells of each rows, cells[i][j] is a cell in table |
420 | 420 | */ |
421 | -private function _tableColumnWidth(&$table){ |
|
421 | +private function _tableColumnWidth(&$table) { |
|
422 | 422 | $cs = &$table['cells']; |
423 | 423 | $nc = $table['nc']; |
424 | 424 | $nr = $table['nr']; |
425 | 425 | $listspan = array(); |
426 | 426 | //Xac dinh do rong cua cac cell va cac cot tuong ung |
427 | - for ($j=0;$j<$nc;$j++){ |
|
427 | + for ($j = 0; $j < $nc; $j++) { |
|
428 | 428 | $wc = &$table['wc'][$j]; |
429 | - for ($i=0;$i<$nr;$i++){ |
|
430 | - if (isset($cs[$i][$j]['miw'])){ |
|
429 | + for ($i = 0; $i < $nr; $i++) { |
|
430 | + if (isset($cs[$i][$j]['miw'])) { |
|
431 | 431 | $c = &$cs[$i][$j]; |
432 | 432 | if (isset($c['nowrap'])) $c['miw'] = $c['maw']; |
433 | - if (isset($c['w'])){ |
|
434 | - if ($c['miw']<$c['w']) $c['miw'] = $c['w']; |
|
435 | - elseif ($c['miw']>$c['w']) $c['w'] = $c['miw']+$this->paddingCell2; |
|
433 | + if (isset($c['w'])) { |
|
434 | + if ($c['miw'] < $c['w']) $c['miw'] = $c['w']; |
|
435 | + elseif ($c['miw'] > $c['w']) $c['w'] = $c['miw'] + $this->paddingCell2; |
|
436 | 436 | if (!isset($wc['w'])) $wc['w'] = 1; |
437 | 437 | } |
438 | - if ($c['maw']<$c['miw']) $c['maw'] = $c['miw']; |
|
439 | - if (!isset($c['colspan'])){ |
|
440 | - if ($wc['miw'] < $c['miw']) $wc['miw']=$c['miw']; |
|
441 | - if ($wc['maw'] < $c['maw']) $wc['maw']=$c['maw']; |
|
438 | + if ($c['maw'] < $c['miw']) $c['maw'] = $c['miw']; |
|
439 | + if (!isset($c['colspan'])) { |
|
440 | + if ($wc['miw'] < $c['miw']) $wc['miw'] = $c['miw']; |
|
441 | + if ($wc['maw'] < $c['maw']) $wc['maw'] = $c['maw']; |
|
442 | 442 | if (isset($wc['w']) && $wc['w'] < $wc['miw']) |
443 | - $wc['w']=$wc['miw']; |
|
444 | - }else $listspan[] = array($i,$j); |
|
443 | + $wc['w'] = $wc['miw']; |
|
444 | + }else $listspan[] = array($i, $j); |
|
445 | 445 | } |
446 | 446 | } |
447 | 447 | } |
448 | 448 | //Xac dinh su anh huong cua cac cell colspan len cac cot va nguoc lai |
449 | 449 | $wc = &$table['wc']; |
450 | - foreach ($listspan as $span){ |
|
451 | - list($i,$j) = $span; |
|
450 | + foreach ($listspan as $span) { |
|
451 | + list($i, $j) = $span; |
|
452 | 452 | $c = &$cs[$i][$j]; |
453 | 453 | $lc = $j + $c['colspan']; |
454 | 454 | if ($lc > $nc) $lc = $nc; |
@@ -456,39 +456,39 @@ discard block |
||
456 | 456 | $wis = $wisa = 0; |
457 | 457 | $was = $wasa = 0; |
458 | 458 | $list = array(); |
459 | - for($k=$j;$k<$lc;$k++){ |
|
459 | + for ($k = $j; $k < $lc; $k++) { |
|
460 | 460 | $wis += $wc[$k]['miw']; |
461 | 461 | $was += $wc[$k]['maw']; |
462 | - if (!isset($c['w'])){ |
|
462 | + if (!isset($c['w'])) { |
|
463 | 463 | $list[] = $k; |
464 | 464 | $wisa += $wc[$k]['miw']; |
465 | 465 | $wasa += $wc[$k]['maw']; |
466 | 466 | } |
467 | 467 | } |
468 | - if ($c['miw'] > $wis){ |
|
469 | - if (!$wis){//Cac cot chua co kich thuoc => chia deu |
|
470 | - for($k=$j;$k<$lc;$k++) $wc[$k]['miw'] = $c['miw']/$c['colspan']; |
|
471 | - }elseif (!count($list)){//Khong co cot nao co kich thuoc auto => chia deu phan du cho tat ca |
|
468 | + if ($c['miw'] > $wis) { |
|
469 | + if (!$wis) {//Cac cot chua co kich thuoc => chia deu |
|
470 | + for ($k = $j; $k < $lc; $k++) $wc[$k]['miw'] = $c['miw'] / $c['colspan']; |
|
471 | + }elseif (!count($list)) {//Khong co cot nao co kich thuoc auto => chia deu phan du cho tat ca |
|
472 | 472 | $wi = $c['miw'] - $wis; |
473 | - for($k=$j;$k<$lc;$k++) |
|
474 | - $wc[$k]['miw'] += ($wc[$k]['miw']/$wis)*$wi; |
|
475 | - }else{//Co mot so cot co kich thuoc auto => chia deu phan du cho cac cot auto |
|
473 | + for ($k = $j; $k < $lc; $k++) |
|
474 | + $wc[$k]['miw'] += ($wc[$k]['miw'] / $wis) * $wi; |
|
475 | + }else {//Co mot so cot co kich thuoc auto => chia deu phan du cho cac cot auto |
|
476 | 476 | $wi = $c['miw'] - $wis; |
477 | 477 | foreach ($list as $_z2=>$k) |
478 | - $wc[$k]['miw'] += ($wc[$k]['miw']/$wisa)*$wi; |
|
478 | + $wc[$k]['miw'] += ($wc[$k]['miw'] / $wisa) * $wi; |
|
479 | 479 | } |
480 | 480 | } |
481 | - if ($c['maw'] > $was){ |
|
482 | - if (!$wis){//Cac cot chua co kich thuoc => chia deu |
|
483 | - for($k=$j;$k<$lc;$k++) $wc[$k]['maw'] = $c['maw']/$c['colspan']; |
|
484 | - }elseif (!count($list)){//Khong co cot nao co kich thuoc auto => chia deu phan du cho tat ca |
|
481 | + if ($c['maw'] > $was) { |
|
482 | + if (!$wis) {//Cac cot chua co kich thuoc => chia deu |
|
483 | + for ($k = $j; $k < $lc; $k++) $wc[$k]['maw'] = $c['maw'] / $c['colspan']; |
|
484 | + }elseif (!count($list)) {//Khong co cot nao co kich thuoc auto => chia deu phan du cho tat ca |
|
485 | 485 | $wi = $c['maw'] - $was; |
486 | - for($k=$j;$k<$lc;$k++) |
|
487 | - $wc[$k]['maw'] += ($wc[$k]['maw']/$was)*$wi; |
|
488 | - }else{//Co mot so cot co kich thuoc auto => chia deu phan du cho cac cot auto |
|
486 | + for ($k = $j; $k < $lc; $k++) |
|
487 | + $wc[$k]['maw'] += ($wc[$k]['maw'] / $was) * $wi; |
|
488 | + }else {//Co mot so cot co kich thuoc auto => chia deu phan du cho cac cot auto |
|
489 | 489 | $wi = $c['maw'] - $was; |
490 | 490 | foreach ($list as $_z2=>$k) |
491 | - $wc[$k]['maw'] += ($wc[$k]['maw']/$wasa)*$wi; |
|
491 | + $wc[$k]['maw'] += ($wc[$k]['maw'] / $wasa) * $wi; |
|
492 | 492 | } |
493 | 493 | } |
494 | 494 | } |
@@ -497,43 +497,43 @@ discard block |
||
497 | 497 | /** |
498 | 498 | * @desc Xac dinh chieu rong cua table |
499 | 499 | */ |
500 | -private function _tableWidth(&$table){ |
|
500 | +private function _tableWidth(&$table) { |
|
501 | 501 | $wc = &$table['wc']; |
502 | 502 | $nc = $table['nc']; |
503 | 503 | $a = 0; |
504 | - for ($i=0;$i<$nc;$i++){ |
|
504 | + for ($i = 0; $i < $nc; $i++) { |
|
505 | 505 | $a += isset($wc[$i]['w']) ? $wc[$i]['miw'] : $wc[$i]['maw']; |
506 | 506 | } |
507 | 507 | if ($a > $this->width) $table['w'] = $this->width; |
508 | 508 | |
509 | - if (isset($table['w'])){ |
|
509 | + if (isset($table['w'])) { |
|
510 | 510 | $wis = $wisa = 0; |
511 | 511 | $list = array(); |
512 | - for ($i=0;$i<$nc;$i++){ |
|
512 | + for ($i = 0; $i < $nc; $i++) { |
|
513 | 513 | $wis += $wc[$i]['miw']; |
514 | - if (!isset($wc[$i]['w'])){ $list[] = $i;$wisa += $wc[$i]['miw'];} |
|
514 | + if (!isset($wc[$i]['w'])) { $list[] = $i; $wisa += $wc[$i]['miw']; } |
|
515 | 515 | } |
516 | - if ($table['w'] > $wis){ |
|
517 | - if (!count($list)){ |
|
516 | + if ($table['w'] > $wis) { |
|
517 | + if (!count($list)) { |
|
518 | 518 | //Khong co cot nao co kich thuoc auto => chia deu phan du cho tat ca |
519 | - $wi = ($table['w'] - $wis)/$nc; |
|
520 | - for($k=0;$k<$nc;$k++) |
|
519 | + $wi = ($table['w'] - $wis) / $nc; |
|
520 | + for ($k = 0; $k < $nc; $k++) |
|
521 | 521 | $wc[$k]['miw'] += $wi; |
522 | - }else{ |
|
522 | + }else { |
|
523 | 523 | //Co mot so cot co kich thuoc auto => chia deu phan du cho cac cot auto |
524 | - $wi = ($table['w'] - $wis)/count($list); |
|
524 | + $wi = ($table['w'] - $wis) / count($list); |
|
525 | 525 | foreach ($list as $k) |
526 | 526 | $wc[$k]['miw'] += $wi; |
527 | 527 | } |
528 | 528 | } |
529 | - for ($i=0;$i<$nc;$i++){ |
|
529 | + for ($i = 0; $i < $nc; $i++) { |
|
530 | 530 | $a = $wc[$i]['miw']; |
531 | 531 | unset($wc[$i]); |
532 | 532 | $wc[$i] = $a; |
533 | 533 | } |
534 | - }else{ |
|
534 | + }else { |
|
535 | 535 | $table['w'] = $a; |
536 | - for ($i=0;$i<$nc;$i++){ |
|
536 | + for ($i = 0; $i < $nc; $i++) { |
|
537 | 537 | $a = isset($wc[$i]['w']) ? $wc[$i]['miw'] : $wc[$i]['maw']; |
538 | 538 | unset($wc[$i]); |
539 | 539 | $wc[$i] = $a; |
@@ -542,99 +542,99 @@ discard block |
||
542 | 542 | $table['w'] = array_sum($wc); |
543 | 543 | } |
544 | 544 | |
545 | -private function _tableHeight(&$table){ |
|
545 | +private function _tableHeight(&$table) { |
|
546 | 546 | $cs = &$table['cells']; |
547 | 547 | $nc = $table['nc']; |
548 | 548 | $nr = $table['nr']; |
549 | 549 | $listspan = array(); |
550 | - for ($i=0;$i<$nr;$i++){ |
|
550 | + for ($i = 0; $i < $nr; $i++) { |
|
551 | 551 | $hr = &$table['hr'][$i]; |
552 | - for ($j=0;$j<$nc;$j++){ |
|
553 | - if (isset($cs[$i][$j]['miw'])){ |
|
552 | + for ($j = 0; $j < $nc; $j++) { |
|
553 | + if (isset($cs[$i][$j]['miw'])) { |
|
554 | 554 | $c = &$cs[$i][$j]; |
555 | - $this->_tableGetWCell($table, $i,$j); //create $c['x0'], $c['w0'] |
|
555 | + $this->_tableGetWCell($table, $i, $j); //create $c['x0'], $c['w0'] |
|
556 | 556 | |
557 | 557 | $ch = $this->_cellHeight($c); |
558 | 558 | $c['ch'] = $ch; |
559 | 559 | |
560 | 560 | if (isset($c['h']) && $c['h'] > $ch) $ch = $c['h']; |
561 | 561 | |
562 | - if (isset($c['rowspan'])) $listspan[] = array($i,$j); |
|
562 | + if (isset($c['rowspan'])) $listspan[] = array($i, $j); |
|
563 | 563 | elseif ($hr < $ch) $hr = $ch; |
564 | 564 | $c['mih'] = $ch; |
565 | 565 | } |
566 | 566 | } |
567 | 567 | } |
568 | 568 | $hr = &$table['hr']; |
569 | - foreach ($listspan as $span){ |
|
570 | - list($i,$j) = $span; |
|
569 | + foreach ($listspan as $span) { |
|
570 | + list($i, $j) = $span; |
|
571 | 571 | $c = &$cs[$i][$j]; |
572 | 572 | $lr = $i + $c['rowspan']; |
573 | 573 | if ($lr > $nr) $lr = $nr; |
574 | 574 | $hs = $hsa = 0; |
575 | 575 | $list = array(); |
576 | - for($k=$i;$k<$lr;$k++){ |
|
576 | + for ($k = $i; $k < $lr; $k++) { |
|
577 | 577 | $hs += $hr[$k]; |
578 | - if (!isset($c['h'])){ |
|
578 | + if (!isset($c['h'])) { |
|
579 | 579 | $list[] = $k; |
580 | 580 | $hsa += $hr[$k]; |
581 | 581 | } |
582 | 582 | } |
583 | - if ($c['mih'] > $hs){ |
|
584 | - if (!$hs){//Cac dong chua co kich thuoc => chia deu |
|
585 | - for($k=$i;$k<$lr;$k++) $hr[$k] = $c['mih']/$c['rowspan']; |
|
586 | - }elseif (!count($list)){ |
|
583 | + if ($c['mih'] > $hs) { |
|
584 | + if (!$hs) {//Cac dong chua co kich thuoc => chia deu |
|
585 | + for ($k = $i; $k < $lr; $k++) $hr[$k] = $c['mih'] / $c['rowspan']; |
|
586 | + }elseif (!count($list)) { |
|
587 | 587 | //Khong co dong nao co kich thuoc auto => chia deu phan du cho tat ca |
588 | 588 | $hi = $c['mih'] - $hs; |
589 | - for($k=$i;$k<$lr;$k++) |
|
590 | - $hr[$k] += ($hr[$k]/$hs)*$hi; |
|
591 | - }else{ |
|
589 | + for ($k = $i; $k < $lr; $k++) |
|
590 | + $hr[$k] += ($hr[$k] / $hs) * $hi; |
|
591 | + }else { |
|
592 | 592 | //Co mot so dong co kich thuoc auto => chia deu phan du cho cac dong auto |
593 | 593 | $hi = $c['mih'] - $hsa; |
594 | 594 | foreach ($list as $k) |
595 | - $hr[$k] += ($hr[$k]/$hsa)*$hi; |
|
595 | + $hr[$k] += ($hr[$k] / $hsa) * $hi; |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | } |
599 | 599 | $table['repeatH'] = 0; |
600 | - if (count($table['repeat'])){ |
|
600 | + if (count($table['repeat'])) { |
|
601 | 601 | foreach ($table['repeat'] as $i) $table['repeatH'] += $hr[$i]; |
602 | 602 | }else $table['repeat'] = 0; |
603 | 603 | $tth = 0; |
604 | - foreach ($hr as $v) $tth+=$v; |
|
604 | + foreach ($hr as $v) $tth += $v; |
|
605 | 605 | $table['tth'] = $tth; |
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
609 | 609 | * @desc Xac dinh toa do va do rong cua mot cell |
610 | 610 | */ |
611 | -private function _tableGetWCell(&$table, $i,$j){ |
|
611 | +private function _tableGetWCell(&$table, $i, $j) { |
|
612 | 612 | $c = &$table['cells'][$i][$j]; |
613 | - if ($c){ |
|
613 | + if ($c) { |
|
614 | 614 | if (isset($c['x0'])) return array($c['x0'], $c['w0']); |
615 | 615 | $x = 0; |
616 | 616 | $wc = &$table['wc']; |
617 | - for ($k=0;$k<$j;$k++) $x += $wc[$k]; |
|
617 | + for ($k = 0; $k < $j; $k++) $x += $wc[$k]; |
|
618 | 618 | $w = $wc[$j]; |
619 | - if (isset($c['colspan'])){ |
|
620 | - for ($k=$j+$c['colspan']-1;$k>$j;$k--) |
|
619 | + if (isset($c['colspan'])) { |
|
620 | + for ($k = $j + $c['colspan'] - 1; $k > $j; $k--) |
|
621 | 621 | $w += @$wc[$k]; |
622 | 622 | } |
623 | 623 | $c['x0'] = $x; |
624 | 624 | $c['w0'] = $w; |
625 | 625 | return array($x, $w); |
626 | 626 | } |
627 | - return array(0,0); |
|
627 | + return array(0, 0); |
|
628 | 628 | } |
629 | 629 | |
630 | -private function _tableGetHCell(&$table, $i,$j){ |
|
630 | +private function _tableGetHCell(&$table, $i, $j) { |
|
631 | 631 | $c = &$table['cells'][$i][$j]; |
632 | - if ($c){ |
|
632 | + if ($c) { |
|
633 | 633 | if (isset($c['h0'])) return $c['h0']; |
634 | 634 | $hr = &$table['hr']; |
635 | 635 | $h = $hr[$i]; |
636 | - if (isset($c['rowspan'])){ |
|
637 | - for ($k=$i+$c['rowspan']-1;$k>$i;$k--) |
|
636 | + if (isset($c['rowspan'])) { |
|
637 | + for ($k = $i + $c['rowspan'] - 1; $k > $i; $k--) |
|
638 | 638 | $h += $hr[$k]; |
639 | 639 | } |
640 | 640 | $c['h0'] = $h; |
@@ -643,18 +643,18 @@ discard block |
||
643 | 643 | return 0; |
644 | 644 | } |
645 | 645 | |
646 | -private function _tableRect($x, $y, $w, $h, $type=1){ |
|
647 | - if (strlen($type)==4) |
|
646 | +private function _tableRect($x, $y, $w, $h, $type = 1) { |
|
647 | + if (strlen($type) == 4) |
|
648 | 648 | { |
649 | 649 | $x2 = $x + $w; $y2 = $y + $h; |
650 | - if (intval($type{0})) $this->Line($x , $y , $x2, $y ); |
|
651 | - if (intval($type{1})) $this->Line($x2, $y , $x2, $y2); |
|
652 | - if (intval($type{2})) $this->Line($x , $y2, $x2, $y2); |
|
653 | - if (intval($type{3})) $this->Line($x , $y , $x , $y2); |
|
650 | + if (intval($type{0})) $this->Line($x, $y, $x2, $y); |
|
651 | + if (intval($type{1})) $this->Line($x2, $y, $x2, $y2); |
|
652 | + if (intval($type{2})) $this->Line($x, $y2, $x2, $y2); |
|
653 | + if (intval($type{3})) $this->Line($x, $y, $x, $y2); |
|
654 | 654 | } |
655 | - elseif ((int)$type===1) |
|
655 | + elseif ((int) $type === 1) |
|
656 | 656 | $this->Rect($x, $y, $w, $h); |
657 | - elseif ((int)$type>1 && (int)$type<11) |
|
657 | + elseif ((int) $type > 1 && (int) $type < 11) |
|
658 | 658 | { |
659 | 659 | $width = $this->LineWidth; |
660 | 660 | $this->SetLineWidth($type * $this->LineWidth); |
@@ -663,73 +663,73 @@ discard block |
||
663 | 663 | } |
664 | 664 | } |
665 | 665 | |
666 | -private function _tableDrawBorder(&$table){ |
|
666 | +private function _tableDrawBorder(&$table) { |
|
667 | 667 | //When fill a cell, it overwrite the border of prevous cell, then I have to draw border at the end |
668 | - foreach ($table['listborder'] as $c){ |
|
669 | - list($x,$y,$w,$h,$s) = $c; |
|
670 | - $this->_tableRect($x,$y,$w,$h,$s); |
|
668 | + foreach ($table['listborder'] as $c) { |
|
669 | + list($x, $y, $w, $h, $s) = $c; |
|
670 | + $this->_tableRect($x, $y, $w, $h, $s); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | $table['listborder'] = array(); |
674 | 674 | } |
675 | -private function _getRowHeight(&$table,$i){ |
|
675 | +private function _getRowHeight(&$table, $i) { |
|
676 | 676 | $maxh = 0; |
677 | - for ($j=0;$j<$table['nc'];$j++){ |
|
677 | + for ($j = 0; $j < $table['nc']; $j++) { |
|
678 | 678 | $h = $this->_tableGetHCell($table, $i, $j); |
679 | 679 | if ($maxh < $h) $maxh = $h; |
680 | 680 | } |
681 | 681 | return $maxh; |
682 | 682 | } |
683 | -private function _checkLimitHeight(&$table,$maxh){ |
|
684 | - if ($maxh+$table['repeatH'] > $this->height){ |
|
683 | +private function _checkLimitHeight(&$table, $maxh) { |
|
684 | + if ($maxh + $table['repeatH'] > $this->height) { |
|
685 | 685 | $msg = 'Height of this row is greater than page height!'; |
686 | - $this->SetFillColor(255,0,0); |
|
687 | - $h=$this->bottom-$table['lasty']; |
|
688 | - $this->Rect($this->x, $this->y=$table['lasty'], $table['w'], $h, 'F'); |
|
689 | - $this->MultiCell($table['w'],$h,$msg); |
|
686 | + $this->SetFillColor(255, 0, 0); |
|
687 | + $h = $this->bottom - $table['lasty']; |
|
688 | + $this->Rect($this->x, $this->y = $table['lasty'], $table['w'], $h, 'F'); |
|
689 | + $this->MultiCell($table['w'], $h, $msg); |
|
690 | 690 | $table['lasty'] += $h; |
691 | 691 | return 1; |
692 | 692 | } |
693 | 693 | return 0; |
694 | 694 | } |
695 | -private function _tableWriteRow(&$table,$i,$x0){ |
|
695 | +private function _tableWriteRow(&$table, $i, $x0) { |
|
696 | 696 | $maxh = $this->_getRowHeight($table, $i); |
697 | - if ($table['multipage']){ |
|
697 | + if ($table['multipage']) { |
|
698 | 698 | $newpage = 0; |
699 | - if ($table['lasty']+$maxh>$this->bottom){ |
|
699 | + if ($table['lasty'] + $maxh > $this->bottom) { |
|
700 | 700 | if ($this->_checkLimitHeight($table, $maxh)) return; |
701 | 701 | $newpage = 1; |
702 | - }elseif (isset($table['pbr'][$i])){ |
|
702 | + }elseif (isset($table['pbr'][$i])) { |
|
703 | 703 | $newpage = 1; |
704 | 704 | unset($table['pbr'][$i]); |
705 | - }elseif (isset($table['knext'][$i])&&$i<$table['nr']-1){ |
|
705 | + }elseif (isset($table['knext'][$i]) && $i < $table['nr'] - 1) { |
|
706 | 706 | $mrowh = $maxh; |
707 | - for($j=$i+1;$j<$table['nr'];$j++){ |
|
707 | + for ($j = $i + 1; $j < $table['nr']; $j++) { |
|
708 | 708 | $mrowh += $this->_getRowHeight($table, $j); |
709 | 709 | if (!isset($table['knext'][$j])) break; |
710 | 710 | unset($table['knext'][$j]); |
711 | 711 | } |
712 | 712 | if ($this->_checkLimitHeight($table, $mrowh)) return; |
713 | - $newpage = $table['lasty']+$mrowh>$this->bottom; |
|
713 | + $newpage = $table['lasty'] + $mrowh > $this->bottom; |
|
714 | 714 | } |
715 | - if ($newpage){ |
|
715 | + if ($newpage) { |
|
716 | 716 | $this->_tableDrawBorder($table); |
717 | 717 | $this->AddPage($this->CurOrientation); |
718 | 718 | |
719 | 719 | $table['lasty'] = $this->y; |
720 | - if ($table['repeat']){ |
|
721 | - foreach ($table['repeat'] as $r){ |
|
722 | - if ($r==$i) continue; |
|
723 | - $this->_tableWriteRow($table,$r,$x0); |
|
720 | + if ($table['repeat']) { |
|
721 | + foreach ($table['repeat'] as $r) { |
|
722 | + if ($r == $i) continue; |
|
723 | + $this->_tableWriteRow($table, $r, $x0); |
|
724 | 724 | } |
725 | 725 | } |
726 | 726 | } |
727 | 727 | } |
728 | 728 | $y = $table['lasty']; |
729 | - for ($j=0;$j<$table['nc'];$j++){ |
|
730 | - if (isset($table['cells'][$i][$j]['miw'])){ |
|
729 | + for ($j = 0; $j < $table['nc']; $j++) { |
|
730 | + if (isset($table['cells'][$i][$j]['miw'])) { |
|
731 | 731 | $c = &$table['cells'][$i][$j]; |
732 | - list($x,$w) = $this->_tableGetWCell($table, $i, $j); |
|
732 | + list($x, $w) = $this->_tableGetWCell($table, $i, $j); |
|
733 | 733 | $h = $this->_tableGetHCell($table, $i, $j); |
734 | 734 | $x += $x0; |
735 | 735 | |
@@ -737,41 +737,41 @@ discard block |
||
737 | 737 | $fill = isset($c['bgcolor']) ? $c['bgcolor'] |
738 | 738 | : (isset($table['bgcolor'][$i]) ? $table['bgcolor'][$i] |
739 | 739 | : (isset($table['bgcolor'][-1]) ? $table['bgcolor'][-1] : 0)); |
740 | - if ($fill){ |
|
740 | + if ($fill) { |
|
741 | 741 | $color = Color::HEX2RGB($fill); |
742 | - $this->SetFillColor($color[0],$color[1],$color[2]); |
|
742 | + $this->SetFillColor($color[0], $color[1], $color[2]); |
|
743 | 743 | $this->Rect($x, $y, $w, $h, 'F'); |
744 | 744 | }; |
745 | 745 | //Content |
746 | - if (isset($c['img'])){ |
|
747 | - $this->Image($c['img'],$x,$y,$c['w'],$c['h']); |
|
748 | - }else{ |
|
749 | - $this->_drawCellAligned($x,$y,$c); |
|
746 | + if (isset($c['img'])) { |
|
747 | + $this->Image($c['img'], $x, $y, $c['w'], $c['h']); |
|
748 | + }else { |
|
749 | + $this->_drawCellAligned($x, $y, $c); |
|
750 | 750 | } |
751 | 751 | //Border |
752 | - if (isset($c['border'])){ |
|
753 | - $table['listborder'][] = array($x,$y,$w,$h,$c['border']); |
|
752 | + if (isset($c['border'])) { |
|
753 | + $table['listborder'][] = array($x, $y, $w, $h, $c['border']); |
|
754 | 754 | }elseif (isset($table['border']) && $table['border']) |
755 | - $table['listborder'][] = array($x,$y,$w,$h,$table['border']); |
|
755 | + $table['listborder'][] = array($x, $y, $w, $h, $table['border']); |
|
756 | 756 | } |
757 | 757 | } |
758 | 758 | $table['lasty'] += $table['hr'][$i]; |
759 | 759 | $this->y = $table['lasty']; |
760 | 760 | } |
761 | -function SetFont($family, $style='', $size=0, $default=false){ |
|
761 | +function SetFont($family, $style = '', $size = 0, $default = false) { |
|
762 | 762 | parent::SetFont($family, $style, $size); |
763 | - if ($default||$this->isNotYetSetFont){ |
|
763 | + if ($default || $this->isNotYetSetFont) { |
|
764 | 764 | $this->defaultFontFamily = $family; |
765 | 765 | $this->defaultFontSize = $size; |
766 | 766 | $this->defaultFontStyle = $style; |
767 | 767 | $this->isNotYetSetFont = false; |
768 | 768 | } |
769 | 769 | } |
770 | -private function _setFontText(&$f){ |
|
771 | - if (isset($f['size']) && ($f['size'] >0)){ |
|
770 | +private function _setFontText(&$f) { |
|
771 | + if (isset($f['size']) && ($f['size'] > 0)) { |
|
772 | 772 | $fontSize = $f['size']; |
773 | 773 | }else $fontSize = $this->defaultFontSize; |
774 | - if (isset($f['family'])){ |
|
774 | + if (isset($f['family'])) { |
|
775 | 775 | $fontFamily = $f['family']; |
776 | 776 | }else $fontFamily = $this->defaultFontFamily; |
777 | 777 | if (isset($f['style'])) |
@@ -780,45 +780,45 @@ discard block |
||
780 | 780 | $this->SetFont($fontFamily, $fontStyle, $fontSize); |
781 | 781 | return $fontSize; |
782 | 782 | } |
783 | -private function _tableWrite(&$table){ |
|
784 | - if ($this->CurOrientation == 'P' && $table['w']>$this->width+5){ |
|
783 | +private function _tableWrite(&$table) { |
|
784 | + if ($this->CurOrientation == 'P' && $table['w'] > $this->width + 5) { |
|
785 | 785 | $this->AddPage('L'); |
786 | 786 | } |
787 | - if ($this->x==null)$this->x = $this->lMargin; |
|
788 | - if ($this->y==null)$this->y = $this->tMargin; |
|
787 | + if ($this->x == null)$this->x = $this->lMargin; |
|
788 | + if ($this->y == null)$this->y = $this->tMargin; |
|
789 | 789 | $x0 = $this->x; |
790 | 790 | $y0 = $this->y; |
791 | - if (isset($table['a'])){ |
|
792 | - if ($table['a']=='C'){ |
|
793 | - $x0 += (($this->right-$x0) - $table['w'])/2; |
|
794 | - }elseif ($table['a']=='R'){ |
|
791 | + if (isset($table['a'])) { |
|
792 | + if ($table['a'] == 'C') { |
|
793 | + $x0 += (($this->right - $x0) - $table['w']) / 2; |
|
794 | + }elseif ($table['a'] == 'R') { |
|
795 | 795 | $x0 = $this->right - $table['w']; |
796 | 796 | } |
797 | 797 | } |
798 | - if (isset($table['nobreak'])&&$table['nobreak'] |
|
799 | - && $table['tth']+$y0>$this->bottom && $table['multipage']){ |
|
798 | + if (isset($table['nobreak']) && $table['nobreak'] |
|
799 | + && $table['tth'] + $y0 > $this->bottom && $table['multipage']) { |
|
800 | 800 | $this->AddPage($this->CurOrientation); |
801 | 801 | $table['lasty'] = $this->y; |
802 | 802 | }else |
803 | 803 | $table['lasty'] = $y0; |
804 | 804 | |
805 | 805 | $table['listborder'] = array(); |
806 | - for ($i=0;$i<$table['nr'];$i++) $this->_tableWriteRow($table, $i, $x0); |
|
806 | + for ($i = 0; $i < $table['nr']; $i++) $this->_tableWriteRow($table, $i, $x0); |
|
807 | 807 | $this->_tableDrawBorder($table); |
808 | 808 | $this->x = $x0; |
809 | 809 | } |
810 | 810 | |
811 | -function htmltable(&$html,$multipage=1){ |
|
811 | +function htmltable(&$html, $multipage = 1) { |
|
812 | 812 | $a = $this->AutoPageBreak; |
813 | - $this->SetAutoPageBreak(0,$this->bMargin); |
|
813 | + $this->SetAutoPageBreak(0, $this->bMargin); |
|
814 | 814 | $HTML = explode("<table", $html); |
815 | 815 | $oldMargin = $this->cMargin; |
816 | 816 | $this->cMargin = 0; |
817 | 817 | $x = $this->x; |
818 | - foreach ($HTML as $i=>$table){ |
|
818 | + foreach ($HTML as $i=>$table) { |
|
819 | 819 | $this->x = $x; |
820 | - if (strlen($table)<6) continue; |
|
821 | - $table = '<table' . $table; |
|
820 | + if (strlen($table) < 6) continue; |
|
821 | + $table = '<table'.$table; |
|
822 | 822 | $table = $this->_tableParser($table); |
823 | 823 | $table['multipage'] = $multipage; |
824 | 824 | $this->_tableColumnWidth($table); |
@@ -827,32 +827,32 @@ discard block |
||
827 | 827 | $this->_tableWrite($table); |
828 | 828 | } |
829 | 829 | $this->cMargin = $oldMargin; |
830 | - $this->SetAutoPageBreak($a,$this->bMargin); |
|
830 | + $this->SetAutoPageBreak($a, $this->bMargin); |
|
831 | 831 | } |
832 | -function _putinfo(){ |
|
832 | +function _putinfo() { |
|
833 | 833 | $this->_out('/Producer '.$this->_textstring('PDFTable '. |
834 | 834 | PDFTABLE_VERSION.' based on FPDF '.FPDF_VERSION)); |
835 | - if(!empty($this->title)) |
|
835 | + if (!empty($this->title)) |
|
836 | 836 | $this->_out('/Title '.$this->_textstring($this->title)); |
837 | - if(!empty($this->subject)) |
|
837 | + if (!empty($this->subject)) |
|
838 | 838 | $this->_out('/Subject '.$this->_textstring($this->subject)); |
839 | - if(!empty($this->author)) |
|
839 | + if (!empty($this->author)) |
|
840 | 840 | $this->_out('/Author '.$this->_textstring($this->author)); |
841 | - if(!empty($this->keywords)) |
|
841 | + if (!empty($this->keywords)) |
|
842 | 842 | $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
843 | - if(!empty($this->creator)) |
|
843 | + if (!empty($this->creator)) |
|
844 | 844 | $this->_out('/Creator '.$this->_textstring($this->creator)); |
845 | 845 | $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); |
846 | 846 | } |
847 | -private function getAlign($v){ |
|
847 | +private function getAlign($v) { |
|
848 | 848 | global $PDF_ALIGN; |
849 | 849 | $v = strtolower($v); |
850 | - return isset($PDF_ALIGN[$v])?$PDF_ALIGN[$v]:'L'; |
|
850 | + return isset($PDF_ALIGN[$v]) ? $PDF_ALIGN[$v] : 'L'; |
|
851 | 851 | } |
852 | -private function getVAlign($v){ |
|
852 | +private function getVAlign($v) { |
|
853 | 853 | global $PDF_VALIGN; |
854 | 854 | $v = strtolower($v); |
855 | - return isset($PDF_VALIGN[$v])?$PDF_VALIGN[$v]:'T'; |
|
855 | + return isset($PDF_VALIGN[$v]) ? $PDF_VALIGN[$v] : 'T'; |
|
856 | 856 | } |
857 | 857 | }//PDFTable |
858 | 858 | ?> |
859 | 859 | \ No newline at end of file |
@@ -65,9 +65,13 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | function SetHeaderFooter($header='',$footer=''){ |
68 | - if ($header) $this->headerTable = $header; |
|
69 | - if ($footer) $this->footerTable = $footer; |
|
70 | -} |
|
68 | + if ($header) { |
|
69 | + $this->headerTable = $header; |
|
70 | + } |
|
71 | + if ($footer) { |
|
72 | + $this->footerTable = $footer; |
|
73 | + } |
|
74 | + } |
|
71 | 75 | function Header(){ |
72 | 76 | $this->_makePageSize(); |
73 | 77 | if ($this->headerTable){ |
@@ -97,7 +101,9 @@ discard block |
||
97 | 101 | * Tra ve chieu cao cua 1 dong theo font hien hanh |
98 | 102 | */ |
99 | 103 | function getLineHeight($fontSize = 0){ |
100 | - if ($fontSize == 0) $fontSize = $this->FontSizePt; |
|
104 | + if ($fontSize == 0) { |
|
105 | + $fontSize = $this->FontSizePt; |
|
106 | + } |
|
101 | 107 | return $fontSize*2/$this->k; |
102 | 108 | } |
103 | 109 | |
@@ -114,19 +120,26 @@ discard block |
||
114 | 120 | foreach ($c['font'] as &$f){ |
115 | 121 | $this->_setFontText($f); |
116 | 122 | $hl = $this->getLineHeight(); |
117 | - if ($maxline<$hl || $x==$this->paddingCell) $maxline=$hl; |
|
118 | - if (!isset($f['space'])) continue; |
|
123 | + if ($maxline<$hl || $x==$this->paddingCell) { |
|
124 | + $maxline=$hl; |
|
125 | + } |
|
126 | + if (!isset($f['space'])) { |
|
127 | + continue; |
|
128 | + } |
|
119 | 129 | $space = $f['space']; |
120 | 130 | foreach ($f['line'] as $i=>&$l){ |
121 | - if ($x!=$this->paddingCell) $x+=$space; |
|
122 | - if (isset($l['str'])&&is_array($l['str'])) |
|
123 | - foreach ($l['str'] as &$t){ |
|
131 | + if ($x!=$this->paddingCell) { |
|
132 | + $x+=$space; |
|
133 | + } |
|
134 | + if (isset($l['str'])&&is_array($l['str'])) { |
|
135 | + foreach ($l['str'] as &$t){ |
|
124 | 136 | if (!is_array($t)) continue; |
137 | + } |
|
125 | 138 | if ($x==$this->paddingCell||$x+$t[1]<=$maxw){ |
126 | 139 | $c['wlinet'][$countline][0] += $t[1]; |
127 | 140 | $c['wlinet'][$countline][1]++; |
128 | 141 | $x += $t[1]+(($x>$this->paddingCell)?$space:0); |
129 | - }else{//auto break line |
|
142 | + } else{//auto break line |
|
130 | 143 | $h+=$maxline*FHR + $this->spacingLine; |
131 | 144 | $c['hline'][] = $maxline*FHR + $this->spacingLine; |
132 | 145 | $c['wlines'][$countline] = $x-$this->paddingCell; |
@@ -158,8 +171,14 @@ discard block |
||
158 | 171 | $maxw = $c['w0']-$this->paddingCell2; |
159 | 172 | $curh = $c['maxh']; |
160 | 173 | $x=$y=0; //Top by default |
161 | - if ($c['va']=='M') $y = ($maxh-$curh)/2; //Middle |
|
162 | - elseif ($c['va']=='B') $y = $maxh-$curh; //Bottom |
|
174 | + if ($c['va']=='M') { |
|
175 | + $y = ($maxh-$curh)/2; |
|
176 | + } |
|
177 | + //Middle |
|
178 | + elseif ($c['va']=='B') { |
|
179 | + $y = $maxh-$curh; |
|
180 | + } |
|
181 | + //Bottom |
|
163 | 182 | $curline = 0; |
164 | 183 | $morespace = 0; |
165 | 184 | $cl = $c['hline'][$curline]; |
@@ -169,15 +188,21 @@ discard block |
||
169 | 188 | if (isset($f['color'])){ |
170 | 189 | $color = Color::HEX2RGB($f['color']); |
171 | 190 | $this->SetTextColor($color[0],$color[1],$color[2]); |
172 | - }else unset($color); |
|
191 | + } else { |
|
192 | + unset($color); |
|
193 | + } |
|
173 | 194 | $hl = $this->getLineHeight(); |
174 | - if (!isset($f['space'])) continue; |
|
195 | + if (!isset($f['space'])) { |
|
196 | + continue; |
|
197 | + } |
|
175 | 198 | $space = $f['space']; |
176 | 199 | foreach ($f['line'] as $i=>&$l){ |
177 | - if (isset($l['str'])&&is_array($l['str'])) |
|
178 | - foreach ($l['str'] as &$t){ |
|
200 | + if (isset($l['str'])&&is_array($l['str'])) { |
|
201 | + foreach ($l['str'] as &$t){ |
|
179 | 202 | if ($t[2]!=$curline){ |
180 | - $y += $cl;$curline++;$cl = $c['hline'][$curline]; |
|
203 | + $y += $cl; |
|
204 | + } |
|
205 | + $curline++;$cl = $c['hline'][$curline]; |
|
181 | 206 | $this->_cellHorzAlignLine($c,$curline,$maxw,$x,$morespace); |
182 | 207 | } |
183 | 208 | $this->x = $x+$x0; |
@@ -190,31 +215,38 @@ discard block |
||
190 | 215 | $this->_cellHorzAlignLine($c,$curline,$maxw,$x,$morespace); |
191 | 216 | } |
192 | 217 | } |
193 | - if (isset($color)) |
|
194 | - $this->SetTextColor(0); |
|
218 | + if (isset($color)) { |
|
219 | + $this->SetTextColor(0); |
|
220 | + } |
|
195 | 221 | } |
196 | 222 | } |
197 | 223 | private function _cellHorzAlignLine(&$c,$line,$maxw,&$x,&$morespace){ |
198 | 224 | $morespace = 0; |
199 | 225 | $x = $this->paddingCell;//Left by default |
200 | - if (!isset($c['wlines'][$line])) return ; |
|
226 | + if (!isset($c['wlines'][$line])) { |
|
227 | + return ; |
|
228 | + } |
|
201 | 229 | if ($c['a']=='C'){//Center |
202 | 230 | $x = ($maxw-$c['wlines'][$line])/2; |
203 | - }elseif ($c['a']=='R'){ |
|
231 | + } elseif ($c['a']=='R'){ |
|
204 | 232 | $x = $maxw-$c['wlines'][$line]; |
205 | - }elseif ($c['a']=='J' && $c['wlinet'][$line][1]>1 |
|
233 | + } elseif ($c['a']=='J' && $c['wlinet'][$line][1]>1 |
|
206 | 234 | && isset($c['autobr'][$line])){//Justify |
207 | 235 | $morespace = ($maxw-$c['wlines'][$line])/($c['wlinet'][$line][1]-1); |
208 | 236 | } |
209 | - if ($x < $this->paddingCell) $x = $this->paddingCell; |
|
210 | -} |
|
237 | + if ($x < $this->paddingCell) { |
|
238 | + $x = $this->paddingCell; |
|
239 | + } |
|
240 | + } |
|
211 | 241 | |
212 | 242 | private function _calWidth($w){ |
213 | 243 | $p = strpos($w,'%'); |
214 | 244 | if ($p!==false){ |
215 | 245 | return intval(substr($w,0,$p)*$this->width/100); |
216 | - }else return intval($w); |
|
217 | -} |
|
246 | + } else { |
|
247 | + return intval($w); |
|
248 | + } |
|
249 | + } |
|
218 | 250 | /** |
219 | 251 | * @return array |
220 | 252 | * @desc Parse a string in html and return array of attribute of table |
@@ -229,8 +261,9 @@ discard block |
||
229 | 261 | $tdopen = false; |
230 | 262 | foreach ($t->name as $i=>$element){ |
231 | 263 | if ($fontopen && $t->type[$i]==NODE_TYPE_ENDELEMENT |
232 | - && (in_array($element,array('table','tr','td','font')))) |
|
233 | - $fontopen = false; |
|
264 | + && (in_array($element,array('table','tr','td','font')))) { |
|
265 | + $fontopen = false; |
|
266 | + } |
|
234 | 267 | if ($tdopen && $t->type[$i]==NODE_TYPE_ENDELEMENT |
235 | 268 | && (in_array($element,array('table','tr','td'))) |
236 | 269 | && !isset($cell[$row][$col]['miw'])){ |
@@ -238,16 +271,26 @@ discard block |
||
238 | 271 | $c['miw'] = $c['maw'] = 0; |
239 | 272 | $tdopen = false; |
240 | 273 | } |
241 | - if ($t->type[$i] != NODE_TYPE_ELEMENT && $t->type[$i] != NODE_TYPE_TEXT) continue; |
|
274 | + if ($t->type[$i] != NODE_TYPE_ELEMENT && $t->type[$i] != NODE_TYPE_TEXT) { |
|
275 | + continue; |
|
276 | + } |
|
242 | 277 | switch ($element){ |
243 | 278 | case 'table': |
244 | 279 | $tdopen = 0; |
245 | 280 | $a = &$t->attribute[$i]; |
246 | - if (isset($a['width'])) $table['w'] = $this->_calWidth($a['width']); |
|
247 | - if (isset($a['height'])) $table['h'] = intval($a['height']); |
|
248 | - if (isset($a['align'])) $table['a'] = $this->getAlign(strtolower($a['align'])); |
|
281 | + if (isset($a['width'])) { |
|
282 | + $table['w'] = $this->_calWidth($a['width']); |
|
283 | + } |
|
284 | + if (isset($a['height'])) { |
|
285 | + $table['h'] = intval($a['height']); |
|
286 | + } |
|
287 | + if (isset($a['align'])) { |
|
288 | + $table['a'] = $this->getAlign(strtolower($a['align'])); |
|
289 | + } |
|
249 | 290 | $table['border'] = (isset($a['border']))? $a['border']: 0; |
250 | - if (isset($a['bgcolor'])) $table['bgcolor'][-1] = $a['bgcolor']; |
|
291 | + if (isset($a['bgcolor'])) { |
|
292 | + $table['bgcolor'][-1] = $a['bgcolor']; |
|
293 | + } |
|
251 | 294 | $table['nobreak'] = isset($a['nobreak']); |
252 | 295 | break; |
253 | 296 | case 'tr': |
@@ -256,52 +299,94 @@ discard block |
||
256 | 299 | $table['nr']++; |
257 | 300 | $col = -1; |
258 | 301 | $a = &$t->attribute[$i]; |
259 | - if (isset($a['bgcolor'])) $table['bgcolor'][$row] = $a['bgcolor']; |
|
260 | - if (isset($a['repeat'])) $table['repeat'][] = $row; |
|
261 | - else{ |
|
262 | - if (isset($a['pbr'])) $table['pbr'][$row] = 1; |
|
263 | - if (isset($a['knext'])) $table['knext'][$row] = 1; |
|
302 | + if (isset($a['bgcolor'])) { |
|
303 | + $table['bgcolor'][$row] = $a['bgcolor']; |
|
304 | + } |
|
305 | + if (isset($a['repeat'])) { |
|
306 | + $table['repeat'][] = $row; |
|
307 | + } else{ |
|
308 | + if (isset($a['pbr'])) { |
|
309 | + $table['pbr'][$row] = 1; |
|
310 | + } |
|
311 | + if (isset($a['knext'])) { |
|
312 | + $table['knext'][$row] = 1; |
|
313 | + } |
|
264 | 314 | } |
265 | 315 | break; |
266 | 316 | case 'td': |
267 | 317 | $tdopen = 1; |
268 | - $col++;while (isset($cell[$row][$col])) $col++; |
|
318 | + $col++;while (isset($cell[$row][$col])) { |
|
319 | + $col++; |
|
320 | + } |
|
269 | 321 | //Update number column |
270 | - if ($table['nc'] < $col+1) $table['nc'] = $col+1; |
|
322 | + if ($table['nc'] < $col+1) { |
|
323 | + $table['nc'] = $col+1; |
|
324 | + } |
|
271 | 325 | $cell[$row][$col] = array(); |
272 | 326 | $c = &$cell[$row][$col]; |
273 | 327 | $a = &$t->attribute[$i]; |
274 | - if (isset($a['width'])) $c['w'] = intval($a['width']); |
|
275 | - if (isset($a['height'])) $c['h'] = intval($a['height']); |
|
328 | + if (isset($a['width'])) { |
|
329 | + $c['w'] = intval($a['width']); |
|
330 | + } |
|
331 | + if (isset($a['height'])) { |
|
332 | + $c['h'] = intval($a['height']); |
|
333 | + } |
|
276 | 334 | $c['a'] = isset($a['align'])?$this->getAlign($a['align']):'L'; |
277 | 335 | $c['va']= isset($a['valign'])?$this->getVAlign($a['valign']):'T'; |
278 | - if (isset($a['border'])) $c['border'] = $a['border']; |
|
279 | - else $c['border'] = $table['border']; |
|
280 | - if (isset($a['bgcolor'])) $c['bgcolor'] = $a['bgcolor']; |
|
336 | + if (isset($a['border'])) { |
|
337 | + $c['border'] = $a['border']; |
|
338 | + } else { |
|
339 | + $c['border'] = $table['border']; |
|
340 | + } |
|
341 | + if (isset($a['bgcolor'])) { |
|
342 | + $c['bgcolor'] = $a['bgcolor']; |
|
343 | + } |
|
281 | 344 | $cs = $rs = 1; |
282 | - if (isset($a['colspan']) && $a['colspan']>1) $cs = $c['colspan'] = intval($a['colspan']); |
|
283 | - if (isset($a['rowspan']) && $a['rowspan']>1) $rs = $c['rowspan'] = intval($a['rowspan']); |
|
284 | - if (isset($a['size'])) $c['font'][0]['size'] = $a['size']; |
|
285 | - if (isset($a['family'])) $c['font'][0]['family'] = $a['family']; |
|
345 | + if (isset($a['colspan']) && $a['colspan']>1) { |
|
346 | + $cs = $c['colspan'] = intval($a['colspan']); |
|
347 | + } |
|
348 | + if (isset($a['rowspan']) && $a['rowspan']>1) { |
|
349 | + $rs = $c['rowspan'] = intval($a['rowspan']); |
|
350 | + } |
|
351 | + if (isset($a['size'])) { |
|
352 | + $c['font'][0]['size'] = $a['size']; |
|
353 | + } |
|
354 | + if (isset($a['family'])) { |
|
355 | + $c['font'][0]['family'] = $a['family']; |
|
356 | + } |
|
286 | 357 | if (isset($a['style'])){ |
287 | 358 | $STYLE = explode(",", strtoupper($a['style'])); |
288 | 359 | $fontStyle = ''; |
289 | - foreach($STYLE AS $style) $fontStyle .= substr(trim($style), 0, 1); |
|
360 | + foreach($STYLE AS $style) { |
|
361 | + $fontStyle .= substr(trim($style), 0, 1); |
|
362 | + } |
|
290 | 363 | $c['font'][0]['style'] = $fontStyle; |
291 | 364 | } |
292 | - if (isset($a['color'])) $c['font'][0]['color'] = $a['color']; |
|
365 | + if (isset($a['color'])) { |
|
366 | + $c['font'][0]['color'] = $a['color']; |
|
367 | + } |
|
293 | 368 | //Chiem dung vi tri de danh cho cell span |
294 | - for ($k=$row;$k<$row+$rs;$k++) for($l=$col;$l<$col+$cs;$l++){ |
|
295 | - if ($k-$row || $l-$col) |
|
296 | - $cell[$k][$l] = 0; |
|
369 | + for ($k=$row;$k<$row+$rs;$k++) { |
|
370 | + for($l=$col; |
|
371 | + } |
|
372 | + $l<$col+$cs;$l++){ |
|
373 | + if ($k-$row || $l-$col) { |
|
374 | + $cell[$k][$l] = 0; |
|
375 | + } |
|
376 | + } |
|
377 | + if (isset($a['nowrap'])) { |
|
378 | + $c['nowrap']= 1; |
|
297 | 379 | } |
298 | - if (isset($a['nowrap'])) $c['nowrap']= 1; |
|
299 | 380 | $fontopen = true; |
300 | - if (!isset($c['font'])) $c['font'][] = array(); |
|
381 | + if (!isset($c['font'])) { |
|
382 | + $c['font'][] = array(); |
|
383 | + } |
|
301 | 384 | break; |
302 | 385 | case 'Text': |
303 | 386 | $c = &$cell[$row][$col]; |
304 | - if (!$fontopen || !isset($c['font'])) $c['font'][] = array(); |
|
387 | + if (!$fontopen || !isset($c['font'])) { |
|
388 | + $c['font'][] = array(); |
|
389 | + } |
|
305 | 390 | $f = &$c['font'][count($c['font'])-1]; |
306 | 391 | $this->_setTextAndSize($c,$f,$this->_html2text($t->value[$i])); |
307 | 392 | break; |
@@ -310,15 +395,23 @@ discard block |
||
310 | 395 | $c = &$cell[$row][$col]; |
311 | 396 | $c['font'][] = array(); |
312 | 397 | $f = &$c['font'][count($c['font'])-1]; |
313 | - if (isset($a['size'])) $f['size'] = $a['size']; |
|
314 | - if (isset($a['family'])) $f['family'] = $a['family']; |
|
398 | + if (isset($a['size'])) { |
|
399 | + $f['size'] = $a['size']; |
|
400 | + } |
|
401 | + if (isset($a['family'])) { |
|
402 | + $f['family'] = $a['family']; |
|
403 | + } |
|
315 | 404 | if (isset($a['style'])){ |
316 | 405 | $STYLE = explode(",", strtoupper($a['style'])); |
317 | 406 | $fontStyle = ''; |
318 | - foreach($STYLE AS $style) $fontStyle .= substr(trim($style), 0, 1); |
|
407 | + foreach($STYLE AS $style) { |
|
408 | + $fontStyle .= substr(trim($style), 0, 1); |
|
409 | + } |
|
319 | 410 | $f['style'] = $fontStyle; |
320 | 411 | } |
321 | - if (isset($a['color'])) $f['color'] = $a['color']; |
|
412 | + if (isset($a['color'])) { |
|
413 | + $f['color'] = $a['color']; |
|
414 | + } |
|
322 | 415 | break; |
323 | 416 | case 'img': |
324 | 417 | $a = &$t->attribute[$i]; |
@@ -340,7 +433,9 @@ discard block |
||
340 | 433 | } |
341 | 434 | |
342 | 435 | private function _setTextAndSize(&$cell,&$f, $text){ |
343 | - if ($text=='') return; |
|
436 | + if ($text=='') { |
|
437 | + return; |
|
438 | + } |
|
344 | 439 | $this->_setFontText($f); |
345 | 440 | if (!isset($f['line'][0])){ |
346 | 441 | $f['line'][0]['min'] = $f['line'][0]['max'] = 0; |
@@ -351,49 +446,69 @@ discard block |
||
351 | 446 | $f['line'][] = array('min'=>0,'max'=>0,'str'=>array()); |
352 | 447 | $l = &$f['line'][count($f['line'])-1]; |
353 | 448 | } |
354 | - if (!isset($f['space'])) $f['space'] = $this->GetStringWidth(' '); |
|
449 | + if (!isset($f['space'])) { |
|
450 | + $f['space'] = $this->GetStringWidth(' '); |
|
451 | + } |
|
355 | 452 | $ct = count($text); |
356 | 453 | foreach ($text as $item){ |
357 | 454 | $s = $this->GetStringWidth($item); |
358 | - if ($l['min']<$s) $l['min']=$s; |
|
455 | + if ($l['min']<$s) { |
|
456 | + $l['min']=$s; |
|
457 | + } |
|
359 | 458 | $l['max'] += $s; |
360 | - if ($ct>1) $l['max'] += $f['space']; |
|
459 | + if ($ct>1) { |
|
460 | + $l['max'] += $f['space']; |
|
461 | + } |
|
361 | 462 | $l['str'][] = array($item,$s); |
362 | 463 | } |
363 | - if (isset($cell['nowrap'])) $l['min'] = $l['max']; |
|
364 | - if (!isset($cell['miw']) || $cell['miw']-$this->paddingCell2<$l['min']) |
|
365 | - $cell['miw']=$l['min']+$this->paddingCell2; |
|
366 | - if (!isset($cell['maw']) || $cell['maw']-$this->paddingCell2<$l['max']) |
|
367 | - $cell['maw']=$l['max']+$this->paddingCell2; |
|
368 | -} |
|
464 | + if (isset($cell['nowrap'])) { |
|
465 | + $l['min'] = $l['max']; |
|
466 | + } |
|
467 | + if (!isset($cell['miw']) || $cell['miw']-$this->paddingCell2<$l['min']) { |
|
468 | + $cell['miw']=$l['min']+$this->paddingCell2; |
|
469 | + } |
|
470 | + if (!isset($cell['maw']) || $cell['maw']-$this->paddingCell2<$l['max']) { |
|
471 | + $cell['maw']=$l['max']+$this->paddingCell2; |
|
472 | + } |
|
473 | + } |
|
369 | 474 | |
370 | 475 | private function _setImage(&$c, &$a){ |
371 | 476 | $path = $a['src']; |
372 | 477 | if (!is_file($path)){ |
373 | 478 | $this->Error('Image is not exists: '.$path); |
374 | - }else{ |
|
479 | + } else{ |
|
375 | 480 | list($u,$d) = $this->_getResolution($path); |
376 | 481 | $c['img'] = $path; |
377 | 482 | list($c['w'],$c['h'],) = getimagesize($path); |
378 | - if (isset($a['width'])) $c['w'] = $a['width']; |
|
379 | - if (isset($a['height'])) $c['h'] = $a['height']; |
|
483 | + if (isset($a['width'])) { |
|
484 | + $c['w'] = $a['width']; |
|
485 | + } |
|
486 | + if (isset($a['height'])) { |
|
487 | + $c['h'] = $a['height']; |
|
488 | + } |
|
380 | 489 | $scale = 1; |
381 | - if ($u==1) $scale = 25.4/$d; |
|
382 | - elseif ($u==2) $scale = 10/$d; |
|
490 | + if ($u==1) { |
|
491 | + $scale = 25.4/$d; |
|
492 | + } elseif ($u==2) { |
|
493 | + $scale = 10/$d; |
|
494 | + } |
|
383 | 495 | $c['w'] = intval($c['w']*$scale); |
384 | 496 | $c['h'] = intval($c['h']*$scale); |
385 | 497 | } |
386 | 498 | } |
387 | 499 | private function _getResolution($path){ |
388 | 500 | $pos=strrpos($path,'.'); |
389 | - if(!$pos) |
|
390 | - $this->Error('Image file has no extension and no type was specified: '.$path); |
|
501 | + if(!$pos) { |
|
502 | + $this->Error('Image file has no extension and no type was specified: '.$path); |
|
503 | + } |
|
391 | 504 | $type=substr($path,$pos+1); |
392 | 505 | $type=strtolower($type); |
393 | - if($type=='jpeg') |
|
394 | - $type='jpg'; |
|
395 | - if ($type!='jpg') |
|
396 | - $this->Error('Unsupported image type: '.$path); |
|
506 | + if($type=='jpeg') { |
|
507 | + $type='jpg'; |
|
508 | + } |
|
509 | + if ($type!='jpg') { |
|
510 | + $this->Error('Unsupported image type: '.$path); |
|
511 | + } |
|
397 | 512 | $f = fopen($path,'r'); |
398 | 513 | fseek($f,13,SEEK_SET); |
399 | 514 | $info = fread($f,3); |
@@ -429,19 +544,35 @@ discard block |
||
429 | 544 | for ($i=0;$i<$nr;$i++){ |
430 | 545 | if (isset($cs[$i][$j]['miw'])){ |
431 | 546 | $c = &$cs[$i][$j]; |
432 | - if (isset($c['nowrap'])) $c['miw'] = $c['maw']; |
|
547 | + if (isset($c['nowrap'])) { |
|
548 | + $c['miw'] = $c['maw']; |
|
549 | + } |
|
433 | 550 | if (isset($c['w'])){ |
434 | - if ($c['miw']<$c['w']) $c['miw'] = $c['w']; |
|
435 | - elseif ($c['miw']>$c['w']) $c['w'] = $c['miw']+$this->paddingCell2; |
|
436 | - if (!isset($wc['w'])) $wc['w'] = 1; |
|
551 | + if ($c['miw']<$c['w']) { |
|
552 | + $c['miw'] = $c['w']; |
|
553 | + } elseif ($c['miw']>$c['w']) { |
|
554 | + $c['w'] = $c['miw']+$this->paddingCell2; |
|
555 | + } |
|
556 | + if (!isset($wc['w'])) { |
|
557 | + $wc['w'] = 1; |
|
558 | + } |
|
559 | + } |
|
560 | + if ($c['maw']<$c['miw']) { |
|
561 | + $c['maw'] = $c['miw']; |
|
437 | 562 | } |
438 | - if ($c['maw']<$c['miw']) $c['maw'] = $c['miw']; |
|
439 | 563 | if (!isset($c['colspan'])){ |
440 | - if ($wc['miw'] < $c['miw']) $wc['miw']=$c['miw']; |
|
441 | - if ($wc['maw'] < $c['maw']) $wc['maw']=$c['maw']; |
|
442 | - if (isset($wc['w']) && $wc['w'] < $wc['miw']) |
|
443 | - $wc['w']=$wc['miw']; |
|
444 | - }else $listspan[] = array($i,$j); |
|
564 | + if ($wc['miw'] < $c['miw']) { |
|
565 | + $wc['miw']=$c['miw']; |
|
566 | + } |
|
567 | + if ($wc['maw'] < $c['maw']) { |
|
568 | + $wc['maw']=$c['maw']; |
|
569 | + } |
|
570 | + if (isset($wc['w']) && $wc['w'] < $wc['miw']) { |
|
571 | + $wc['w']=$wc['miw']; |
|
572 | + } |
|
573 | + } else { |
|
574 | + $listspan[] = array($i,$j); |
|
575 | + } |
|
445 | 576 | } |
446 | 577 | } |
447 | 578 | } |
@@ -451,7 +582,9 @@ discard block |
||
451 | 582 | list($i,$j) = $span; |
452 | 583 | $c = &$cs[$i][$j]; |
453 | 584 | $lc = $j + $c['colspan']; |
454 | - if ($lc > $nc) $lc = $nc; |
|
585 | + if ($lc > $nc) { |
|
586 | + $lc = $nc; |
|
587 | + } |
|
455 | 588 | |
456 | 589 | $wis = $wisa = 0; |
457 | 590 | $was = $wasa = 0; |
@@ -467,28 +600,36 @@ discard block |
||
467 | 600 | } |
468 | 601 | if ($c['miw'] > $wis){ |
469 | 602 | if (!$wis){//Cac cot chua co kich thuoc => chia deu |
470 | - for($k=$j;$k<$lc;$k++) $wc[$k]['miw'] = $c['miw']/$c['colspan']; |
|
471 | - }elseif (!count($list)){//Khong co cot nao co kich thuoc auto => chia deu phan du cho tat ca |
|
603 | + for($k=$j;$k<$lc;$k++) { |
|
604 | + $wc[$k]['miw'] = $c['miw']/$c['colspan']; |
|
605 | + } |
|
606 | + } elseif (!count($list)){//Khong co cot nao co kich thuoc auto => chia deu phan du cho tat ca |
|
472 | 607 | $wi = $c['miw'] - $wis; |
473 | - for($k=$j;$k<$lc;$k++) |
|
474 | - $wc[$k]['miw'] += ($wc[$k]['miw']/$wis)*$wi; |
|
475 | - }else{//Co mot so cot co kich thuoc auto => chia deu phan du cho cac cot auto |
|
608 | + for($k=$j;$k<$lc;$k++) { |
|
609 | + $wc[$k]['miw'] += ($wc[$k]['miw']/$wis)*$wi; |
|
610 | + } |
|
611 | + } else{//Co mot so cot co kich thuoc auto => chia deu phan du cho cac cot auto |
|
476 | 612 | $wi = $c['miw'] - $wis; |
477 | - foreach ($list as $_z2=>$k) |
|
478 | - $wc[$k]['miw'] += ($wc[$k]['miw']/$wisa)*$wi; |
|
613 | + foreach ($list as $_z2=>$k) { |
|
614 | + $wc[$k]['miw'] += ($wc[$k]['miw']/$wisa)*$wi; |
|
615 | + } |
|
479 | 616 | } |
480 | 617 | } |
481 | 618 | if ($c['maw'] > $was){ |
482 | 619 | if (!$wis){//Cac cot chua co kich thuoc => chia deu |
483 | - for($k=$j;$k<$lc;$k++) $wc[$k]['maw'] = $c['maw']/$c['colspan']; |
|
484 | - }elseif (!count($list)){//Khong co cot nao co kich thuoc auto => chia deu phan du cho tat ca |
|
620 | + for($k=$j;$k<$lc;$k++) { |
|
621 | + $wc[$k]['maw'] = $c['maw']/$c['colspan']; |
|
622 | + } |
|
623 | + } elseif (!count($list)){//Khong co cot nao co kich thuoc auto => chia deu phan du cho tat ca |
|
485 | 624 | $wi = $c['maw'] - $was; |
486 | - for($k=$j;$k<$lc;$k++) |
|
487 | - $wc[$k]['maw'] += ($wc[$k]['maw']/$was)*$wi; |
|
488 | - }else{//Co mot so cot co kich thuoc auto => chia deu phan du cho cac cot auto |
|
625 | + for($k=$j;$k<$lc;$k++) { |
|
626 | + $wc[$k]['maw'] += ($wc[$k]['maw']/$was)*$wi; |
|
627 | + } |
|
628 | + } else{//Co mot so cot co kich thuoc auto => chia deu phan du cho cac cot auto |
|
489 | 629 | $wi = $c['maw'] - $was; |
490 | - foreach ($list as $_z2=>$k) |
|
491 | - $wc[$k]['maw'] += ($wc[$k]['maw']/$wasa)*$wi; |
|
630 | + foreach ($list as $_z2=>$k) { |
|
631 | + $wc[$k]['maw'] += ($wc[$k]['maw']/$wasa)*$wi; |
|
632 | + } |
|
492 | 633 | } |
493 | 634 | } |
494 | 635 | } |
@@ -504,7 +645,9 @@ discard block |
||
504 | 645 | for ($i=0;$i<$nc;$i++){ |
505 | 646 | $a += isset($wc[$i]['w']) ? $wc[$i]['miw'] : $wc[$i]['maw']; |
506 | 647 | } |
507 | - if ($a > $this->width) $table['w'] = $this->width; |
|
648 | + if ($a > $this->width) { |
|
649 | + $table['w'] = $this->width; |
|
650 | + } |
|
508 | 651 | |
509 | 652 | if (isset($table['w'])){ |
510 | 653 | $wis = $wisa = 0; |
@@ -517,13 +660,15 @@ discard block |
||
517 | 660 | if (!count($list)){ |
518 | 661 | //Khong co cot nao co kich thuoc auto => chia deu phan du cho tat ca |
519 | 662 | $wi = ($table['w'] - $wis)/$nc; |
520 | - for($k=0;$k<$nc;$k++) |
|
521 | - $wc[$k]['miw'] += $wi; |
|
522 | - }else{ |
|
663 | + for($k=0;$k<$nc;$k++) { |
|
664 | + $wc[$k]['miw'] += $wi; |
|
665 | + } |
|
666 | + } else{ |
|
523 | 667 | //Co mot so cot co kich thuoc auto => chia deu phan du cho cac cot auto |
524 | 668 | $wi = ($table['w'] - $wis)/count($list); |
525 | - foreach ($list as $k) |
|
526 | - $wc[$k]['miw'] += $wi; |
|
669 | + foreach ($list as $k) { |
|
670 | + $wc[$k]['miw'] += $wi; |
|
671 | + } |
|
527 | 672 | } |
528 | 673 | } |
529 | 674 | for ($i=0;$i<$nc;$i++){ |
@@ -531,7 +676,7 @@ discard block |
||
531 | 676 | unset($wc[$i]); |
532 | 677 | $wc[$i] = $a; |
533 | 678 | } |
534 | - }else{ |
|
679 | + } else{ |
|
535 | 680 | $table['w'] = $a; |
536 | 681 | for ($i=0;$i<$nc;$i++){ |
537 | 682 | $a = isset($wc[$i]['w']) ? $wc[$i]['miw'] : $wc[$i]['maw']; |
@@ -557,10 +702,15 @@ discard block |
||
557 | 702 | $ch = $this->_cellHeight($c); |
558 | 703 | $c['ch'] = $ch; |
559 | 704 | |
560 | - if (isset($c['h']) && $c['h'] > $ch) $ch = $c['h']; |
|
705 | + if (isset($c['h']) && $c['h'] > $ch) { |
|
706 | + $ch = $c['h']; |
|
707 | + } |
|
561 | 708 | |
562 | - if (isset($c['rowspan'])) $listspan[] = array($i,$j); |
|
563 | - elseif ($hr < $ch) $hr = $ch; |
|
709 | + if (isset($c['rowspan'])) { |
|
710 | + $listspan[] = array($i,$j); |
|
711 | + } elseif ($hr < $ch) { |
|
712 | + $hr = $ch; |
|
713 | + } |
|
564 | 714 | $c['mih'] = $ch; |
565 | 715 | } |
566 | 716 | } |
@@ -570,7 +720,9 @@ discard block |
||
570 | 720 | list($i,$j) = $span; |
571 | 721 | $c = &$cs[$i][$j]; |
572 | 722 | $lr = $i + $c['rowspan']; |
573 | - if ($lr > $nr) $lr = $nr; |
|
723 | + if ($lr > $nr) { |
|
724 | + $lr = $nr; |
|
725 | + } |
|
574 | 726 | $hs = $hsa = 0; |
575 | 727 | $list = array(); |
576 | 728 | for($k=$i;$k<$lr;$k++){ |
@@ -582,26 +734,36 @@ discard block |
||
582 | 734 | } |
583 | 735 | if ($c['mih'] > $hs){ |
584 | 736 | if (!$hs){//Cac dong chua co kich thuoc => chia deu |
585 | - for($k=$i;$k<$lr;$k++) $hr[$k] = $c['mih']/$c['rowspan']; |
|
586 | - }elseif (!count($list)){ |
|
737 | + for($k=$i;$k<$lr;$k++) { |
|
738 | + $hr[$k] = $c['mih']/$c['rowspan']; |
|
739 | + } |
|
740 | + } elseif (!count($list)){ |
|
587 | 741 | //Khong co dong nao co kich thuoc auto => chia deu phan du cho tat ca |
588 | 742 | $hi = $c['mih'] - $hs; |
589 | - for($k=$i;$k<$lr;$k++) |
|
590 | - $hr[$k] += ($hr[$k]/$hs)*$hi; |
|
591 | - }else{ |
|
743 | + for($k=$i;$k<$lr;$k++) { |
|
744 | + $hr[$k] += ($hr[$k]/$hs)*$hi; |
|
745 | + } |
|
746 | + } else{ |
|
592 | 747 | //Co mot so dong co kich thuoc auto => chia deu phan du cho cac dong auto |
593 | 748 | $hi = $c['mih'] - $hsa; |
594 | - foreach ($list as $k) |
|
595 | - $hr[$k] += ($hr[$k]/$hsa)*$hi; |
|
749 | + foreach ($list as $k) { |
|
750 | + $hr[$k] += ($hr[$k]/$hsa)*$hi; |
|
751 | + } |
|
596 | 752 | } |
597 | 753 | } |
598 | 754 | } |
599 | 755 | $table['repeatH'] = 0; |
600 | 756 | if (count($table['repeat'])){ |
601 | - foreach ($table['repeat'] as $i) $table['repeatH'] += $hr[$i]; |
|
602 | - }else $table['repeat'] = 0; |
|
757 | + foreach ($table['repeat'] as $i) { |
|
758 | + $table['repeatH'] += $hr[$i]; |
|
759 | + } |
|
760 | + } else { |
|
761 | + $table['repeat'] = 0; |
|
762 | + } |
|
603 | 763 | $tth = 0; |
604 | - foreach ($hr as $v) $tth+=$v; |
|
764 | + foreach ($hr as $v) { |
|
765 | + $tth+=$v; |
|
766 | + } |
|
605 | 767 | $table['tth'] = $tth; |
606 | 768 | } |
607 | 769 | |
@@ -611,14 +773,19 @@ discard block |
||
611 | 773 | private function _tableGetWCell(&$table, $i,$j){ |
612 | 774 | $c = &$table['cells'][$i][$j]; |
613 | 775 | if ($c){ |
614 | - if (isset($c['x0'])) return array($c['x0'], $c['w0']); |
|
776 | + if (isset($c['x0'])) { |
|
777 | + return array($c['x0'], $c['w0']); |
|
778 | + } |
|
615 | 779 | $x = 0; |
616 | 780 | $wc = &$table['wc']; |
617 | - for ($k=0;$k<$j;$k++) $x += $wc[$k]; |
|
781 | + for ($k=0;$k<$j;$k++) { |
|
782 | + $x += $wc[$k]; |
|
783 | + } |
|
618 | 784 | $w = $wc[$j]; |
619 | 785 | if (isset($c['colspan'])){ |
620 | - for ($k=$j+$c['colspan']-1;$k>$j;$k--) |
|
621 | - $w += @$wc[$k]; |
|
786 | + for ($k=$j+$c['colspan']-1;$k>$j;$k--) { |
|
787 | + $w += @$wc[$k]; |
|
788 | + } |
|
622 | 789 | } |
623 | 790 | $c['x0'] = $x; |
624 | 791 | $c['w0'] = $w; |
@@ -630,12 +797,15 @@ discard block |
||
630 | 797 | private function _tableGetHCell(&$table, $i,$j){ |
631 | 798 | $c = &$table['cells'][$i][$j]; |
632 | 799 | if ($c){ |
633 | - if (isset($c['h0'])) return $c['h0']; |
|
800 | + if (isset($c['h0'])) { |
|
801 | + return $c['h0']; |
|
802 | + } |
|
634 | 803 | $hr = &$table['hr']; |
635 | 804 | $h = $hr[$i]; |
636 | 805 | if (isset($c['rowspan'])){ |
637 | - for ($k=$i+$c['rowspan']-1;$k>$i;$k--) |
|
638 | - $h += $hr[$k]; |
|
806 | + for ($k=$i+$c['rowspan']-1;$k>$i;$k--) { |
|
807 | + $h += $hr[$k]; |
|
808 | + } |
|
639 | 809 | } |
640 | 810 | $c['h0'] = $h; |
641 | 811 | return $h; |
@@ -647,14 +817,21 @@ discard block |
||
647 | 817 | if (strlen($type)==4) |
648 | 818 | { |
649 | 819 | $x2 = $x + $w; $y2 = $y + $h; |
650 | - if (intval($type{0})) $this->Line($x , $y , $x2, $y ); |
|
651 | - if (intval($type{1})) $this->Line($x2, $y , $x2, $y2); |
|
652 | - if (intval($type{2})) $this->Line($x , $y2, $x2, $y2); |
|
653 | - if (intval($type{3})) $this->Line($x , $y , $x , $y2); |
|
654 | - } |
|
655 | - elseif ((int)$type===1) |
|
656 | - $this->Rect($x, $y, $w, $h); |
|
657 | - elseif ((int)$type>1 && (int)$type<11) |
|
820 | + if (intval($type{0})) { |
|
821 | + $this->Line($x , $y , $x2, $y ); |
|
822 | + } |
|
823 | + if (intval($type{1})) { |
|
824 | + $this->Line($x2, $y , $x2, $y2); |
|
825 | + } |
|
826 | + if (intval($type{2})) { |
|
827 | + $this->Line($x , $y2, $x2, $y2); |
|
828 | + } |
|
829 | + if (intval($type{3})) { |
|
830 | + $this->Line($x , $y , $x , $y2); |
|
831 | + } |
|
832 | + } elseif ((int)$type===1) { |
|
833 | + $this->Rect($x, $y, $w, $h); |
|
834 | + } elseif ((int)$type>1 && (int)$type<11) |
|
658 | 835 | { |
659 | 836 | $width = $this->LineWidth; |
660 | 837 | $this->SetLineWidth($type * $this->LineWidth); |
@@ -676,7 +853,9 @@ discard block |
||
676 | 853 | $maxh = 0; |
677 | 854 | for ($j=0;$j<$table['nc'];$j++){ |
678 | 855 | $h = $this->_tableGetHCell($table, $i, $j); |
679 | - if ($maxh < $h) $maxh = $h; |
|
856 | + if ($maxh < $h) { |
|
857 | + $maxh = $h; |
|
858 | + } |
|
680 | 859 | } |
681 | 860 | return $maxh; |
682 | 861 | } |
@@ -697,19 +876,25 @@ discard block |
||
697 | 876 | if ($table['multipage']){ |
698 | 877 | $newpage = 0; |
699 | 878 | if ($table['lasty']+$maxh>$this->bottom){ |
700 | - if ($this->_checkLimitHeight($table, $maxh)) return; |
|
879 | + if ($this->_checkLimitHeight($table, $maxh)) { |
|
880 | + return; |
|
881 | + } |
|
701 | 882 | $newpage = 1; |
702 | - }elseif (isset($table['pbr'][$i])){ |
|
883 | + } elseif (isset($table['pbr'][$i])){ |
|
703 | 884 | $newpage = 1; |
704 | 885 | unset($table['pbr'][$i]); |
705 | - }elseif (isset($table['knext'][$i])&&$i<$table['nr']-1){ |
|
886 | + } elseif (isset($table['knext'][$i])&&$i<$table['nr']-1){ |
|
706 | 887 | $mrowh = $maxh; |
707 | 888 | for($j=$i+1;$j<$table['nr'];$j++){ |
708 | 889 | $mrowh += $this->_getRowHeight($table, $j); |
709 | - if (!isset($table['knext'][$j])) break; |
|
890 | + if (!isset($table['knext'][$j])) { |
|
891 | + break; |
|
892 | + } |
|
710 | 893 | unset($table['knext'][$j]); |
711 | 894 | } |
712 | - if ($this->_checkLimitHeight($table, $mrowh)) return; |
|
895 | + if ($this->_checkLimitHeight($table, $mrowh)) { |
|
896 | + return; |
|
897 | + } |
|
713 | 898 | $newpage = $table['lasty']+$mrowh>$this->bottom; |
714 | 899 | } |
715 | 900 | if ($newpage){ |
@@ -719,7 +904,9 @@ discard block |
||
719 | 904 | $table['lasty'] = $this->y; |
720 | 905 | if ($table['repeat']){ |
721 | 906 | foreach ($table['repeat'] as $r){ |
722 | - if ($r==$i) continue; |
|
907 | + if ($r==$i) { |
|
908 | + continue; |
|
909 | + } |
|
723 | 910 | $this->_tableWriteRow($table,$r,$x0); |
724 | 911 | } |
725 | 912 | } |
@@ -745,14 +932,15 @@ discard block |
||
745 | 932 | //Content |
746 | 933 | if (isset($c['img'])){ |
747 | 934 | $this->Image($c['img'],$x,$y,$c['w'],$c['h']); |
748 | - }else{ |
|
935 | + } else{ |
|
749 | 936 | $this->_drawCellAligned($x,$y,$c); |
750 | 937 | } |
751 | 938 | //Border |
752 | 939 | if (isset($c['border'])){ |
753 | 940 | $table['listborder'][] = array($x,$y,$w,$h,$c['border']); |
754 | - }elseif (isset($table['border']) && $table['border']) |
|
755 | - $table['listborder'][] = array($x,$y,$w,$h,$table['border']); |
|
941 | + } elseif (isset($table['border']) && $table['border']) { |
|
942 | + $table['listborder'][] = array($x,$y,$w,$h,$table['border']); |
|
943 | + } |
|
756 | 944 | } |
757 | 945 | } |
758 | 946 | $table['lasty'] += $table['hr'][$i]; |
@@ -770,13 +958,19 @@ discard block |
||
770 | 958 | private function _setFontText(&$f){ |
771 | 959 | if (isset($f['size']) && ($f['size'] >0)){ |
772 | 960 | $fontSize = $f['size']; |
773 | - }else $fontSize = $this->defaultFontSize; |
|
961 | + } else { |
|
962 | + $fontSize = $this->defaultFontSize; |
|
963 | + } |
|
774 | 964 | if (isset($f['family'])){ |
775 | 965 | $fontFamily = $f['family']; |
776 | - }else $fontFamily = $this->defaultFontFamily; |
|
777 | - if (isset($f['style'])) |
|
778 | - $fontStyle = $f['style']; |
|
779 | - else $fontStyle = $this->defaultFontStyle; |
|
966 | + } else { |
|
967 | + $fontFamily = $this->defaultFontFamily; |
|
968 | + } |
|
969 | + if (isset($f['style'])) { |
|
970 | + $fontStyle = $f['style']; |
|
971 | + } else { |
|
972 | + $fontStyle = $this->defaultFontStyle; |
|
973 | + } |
|
780 | 974 | $this->SetFont($fontFamily, $fontStyle, $fontSize); |
781 | 975 | return $fontSize; |
782 | 976 | } |
@@ -784,14 +978,18 @@ discard block |
||
784 | 978 | if ($this->CurOrientation == 'P' && $table['w']>$this->width+5){ |
785 | 979 | $this->AddPage('L'); |
786 | 980 | } |
787 | - if ($this->x==null)$this->x = $this->lMargin; |
|
788 | - if ($this->y==null)$this->y = $this->tMargin; |
|
981 | + if ($this->x==null) { |
|
982 | + $this->x = $this->lMargin; |
|
983 | + } |
|
984 | + if ($this->y==null) { |
|
985 | + $this->y = $this->tMargin; |
|
986 | + } |
|
789 | 987 | $x0 = $this->x; |
790 | 988 | $y0 = $this->y; |
791 | 989 | if (isset($table['a'])){ |
792 | 990 | if ($table['a']=='C'){ |
793 | 991 | $x0 += (($this->right-$x0) - $table['w'])/2; |
794 | - }elseif ($table['a']=='R'){ |
|
992 | + } elseif ($table['a']=='R'){ |
|
795 | 993 | $x0 = $this->right - $table['w']; |
796 | 994 | } |
797 | 995 | } |
@@ -799,11 +997,14 @@ discard block |
||
799 | 997 | && $table['tth']+$y0>$this->bottom && $table['multipage']){ |
800 | 998 | $this->AddPage($this->CurOrientation); |
801 | 999 | $table['lasty'] = $this->y; |
802 | - }else |
|
803 | - $table['lasty'] = $y0; |
|
1000 | + } else { |
|
1001 | + $table['lasty'] = $y0; |
|
1002 | + } |
|
804 | 1003 | |
805 | 1004 | $table['listborder'] = array(); |
806 | - for ($i=0;$i<$table['nr'];$i++) $this->_tableWriteRow($table, $i, $x0); |
|
1005 | + for ($i=0;$i<$table['nr'];$i++) { |
|
1006 | + $this->_tableWriteRow($table, $i, $x0); |
|
1007 | + } |
|
807 | 1008 | $this->_tableDrawBorder($table); |
808 | 1009 | $this->x = $x0; |
809 | 1010 | } |
@@ -817,7 +1018,9 @@ discard block |
||
817 | 1018 | $x = $this->x; |
818 | 1019 | foreach ($HTML as $i=>$table){ |
819 | 1020 | $this->x = $x; |
820 | - if (strlen($table)<6) continue; |
|
1021 | + if (strlen($table)<6) { |
|
1022 | + continue; |
|
1023 | + } |
|
821 | 1024 | $table = '<table' . $table; |
822 | 1025 | $table = $this->_tableParser($table); |
823 | 1026 | $table['multipage'] = $multipage; |
@@ -832,16 +1035,21 @@ discard block |
||
832 | 1035 | function _putinfo(){ |
833 | 1036 | $this->_out('/Producer '.$this->_textstring('PDFTable '. |
834 | 1037 | PDFTABLE_VERSION.' based on FPDF '.FPDF_VERSION)); |
835 | - if(!empty($this->title)) |
|
836 | - $this->_out('/Title '.$this->_textstring($this->title)); |
|
837 | - if(!empty($this->subject)) |
|
838 | - $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
839 | - if(!empty($this->author)) |
|
840 | - $this->_out('/Author '.$this->_textstring($this->author)); |
|
841 | - if(!empty($this->keywords)) |
|
842 | - $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
843 | - if(!empty($this->creator)) |
|
844 | - $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
1038 | + if(!empty($this->title)) { |
|
1039 | + $this->_out('/Title '.$this->_textstring($this->title)); |
|
1040 | + } |
|
1041 | + if(!empty($this->subject)) { |
|
1042 | + $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
1043 | + } |
|
1044 | + if(!empty($this->author)) { |
|
1045 | + $this->_out('/Author '.$this->_textstring($this->author)); |
|
1046 | + } |
|
1047 | + if(!empty($this->keywords)) { |
|
1048 | + $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
1049 | + } |
|
1050 | + if(!empty($this->creator)) { |
|
1051 | + $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
1052 | + } |
|
845 | 1053 | $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); |
846 | 1054 | } |
847 | 1055 | private function getAlign($v){ |
@@ -33,297 +33,297 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class HTMLParser { |
35 | 35 | |
36 | - /** |
|
37 | - * Field iNodeType. |
|
38 | - * May be one of the NODE_TYPE_* constants above. |
|
39 | - */ |
|
40 | - var $iNodeType; |
|
41 | - |
|
42 | - /** |
|
43 | - * Field iNodeName. |
|
44 | - * For elements, it's the name of the element. |
|
45 | - */ |
|
46 | - var $iNodeName = ""; |
|
47 | - |
|
48 | - /** |
|
49 | - * Field iNodeValue. |
|
50 | - * For text nodes, it's the text. |
|
51 | - */ |
|
52 | - var $iNodeValue = ""; |
|
53 | - |
|
54 | - /** |
|
55 | - * Field iNodeAttributes. |
|
56 | - * A string-indexed array containing attribute values |
|
57 | - * of the current node. Indexes are always lowercase. |
|
58 | - */ |
|
59 | - var $iNodeAttributes; |
|
60 | - |
|
61 | - // The following fields should be |
|
62 | - // considered private: |
|
63 | - |
|
64 | - var $iHtmlText; |
|
65 | - var $iHtmlTextLength; |
|
66 | - var $iHtmlTextIndex = 0; |
|
67 | - var $iHtmlCurrentChar; |
|
68 | - |
|
69 | - /** |
|
70 | - * Constructor. |
|
71 | - * Constructs an HTMLParser instance with |
|
72 | - * the HTML text given. |
|
73 | - */ |
|
74 | - function HTMLParser ($aHtmlText) { |
|
75 | - $this->iHtmlText = $aHtmlText; |
|
76 | - $this->iHtmlTextLength = strlen($aHtmlText); |
|
77 | - $this->setTextIndex (0); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Method parse. |
|
82 | - * Parses the next node. Returns false only if |
|
83 | - * the end of the HTML text has been reached. |
|
84 | - * Updates values of iNode* fields. |
|
85 | - */ |
|
86 | - function parse() { |
|
87 | - $text = trim($this->skipToElement()); |
|
88 | - if ($text != "") { |
|
89 | - $this->iNodeType = NODE_TYPE_TEXT; |
|
90 | - $this->iNodeName = "Text"; |
|
91 | - $this->iNodeValue = $text; |
|
92 | - $this->iNodeAttributes = 0; |
|
93 | - return true; |
|
94 | - } |
|
95 | - return $this->readTag(); |
|
96 | - } |
|
97 | - |
|
98 | - function clearAttributes() { |
|
99 | - $this->iNodeAttributes = array(); |
|
100 | - } |
|
101 | - |
|
102 | - function readTag() { |
|
103 | - global $HTML_ATTRIBUTE_STAND_ALONE; |
|
104 | - if ($this->iCurrentChar != "<") { |
|
105 | - $this->iNodeType = NODE_TYPE_DONE; |
|
106 | - return false; |
|
107 | - } |
|
108 | - $this->skipInTag (array("<")); |
|
109 | - $this->clearAttributes(); |
|
110 | - $name = $this->skipToBlanksInTag(); |
|
111 | - $pos = strpos($name, "/"); |
|
112 | - if ($pos === 0) { |
|
113 | - $this->iNodeType = NODE_TYPE_ENDELEMENT; |
|
114 | - $this->iNodeName = substr ($name, 1); |
|
115 | - $this->iNodeValue = ""; |
|
116 | - } |
|
117 | - else { |
|
118 | - if (!$this->isValidTagIdentifier ($name)) { |
|
119 | - $comment = false; |
|
120 | - if ($name == "!--") { |
|
121 | - $rest = $this->skipToStringInTag ("-->"); |
|
122 | - if ($rest != "") { |
|
123 | - $this->iNodeType = NODE_TYPE_COMMENT; |
|
124 | - $this->iNodeName = "Comment"; |
|
125 | - $this->iNodeValue = "<" . $name . $rest; |
|
126 | - $comment = true; |
|
127 | - } |
|
128 | - } |
|
129 | - if (!$comment) { |
|
130 | - $this->iNodeType = NODE_TYPE_TEXT; |
|
131 | - $this->iNodeName = "Text"; |
|
132 | - $this->iNodeValue = "<" . $name; |
|
133 | - } |
|
134 | - return true; |
|
135 | - } |
|
136 | - else { |
|
137 | - $this->iNodeType = NODE_TYPE_ELEMENT; |
|
138 | - $this->iNodeValue = ""; |
|
139 | - $nameLength = strlen($name); |
|
140 | - if ($nameLength > 0 && substr($name, $nameLength - 1, 1) == "/") { |
|
141 | - $this->iNodeName = substr($name, 0, $nameLength - 1); |
|
142 | - }else { |
|
143 | - $this->iNodeName = $name; |
|
144 | - } |
|
145 | - $this->iNodeName = strtolower($this->iNodeName); |
|
146 | - } |
|
147 | - } |
|
148 | - while ($this->skipBlanksInTag()) { |
|
149 | - $attrName = $this->skipToBlanksOrEqualsInTag(); |
|
150 | - if ($attrName != "") { |
|
36 | + /** |
|
37 | + * Field iNodeType. |
|
38 | + * May be one of the NODE_TYPE_* constants above. |
|
39 | + */ |
|
40 | + var $iNodeType; |
|
41 | + |
|
42 | + /** |
|
43 | + * Field iNodeName. |
|
44 | + * For elements, it's the name of the element. |
|
45 | + */ |
|
46 | + var $iNodeName = ""; |
|
47 | + |
|
48 | + /** |
|
49 | + * Field iNodeValue. |
|
50 | + * For text nodes, it's the text. |
|
51 | + */ |
|
52 | + var $iNodeValue = ""; |
|
53 | + |
|
54 | + /** |
|
55 | + * Field iNodeAttributes. |
|
56 | + * A string-indexed array containing attribute values |
|
57 | + * of the current node. Indexes are always lowercase. |
|
58 | + */ |
|
59 | + var $iNodeAttributes; |
|
60 | + |
|
61 | + // The following fields should be |
|
62 | + // considered private: |
|
63 | + |
|
64 | + var $iHtmlText; |
|
65 | + var $iHtmlTextLength; |
|
66 | + var $iHtmlTextIndex = 0; |
|
67 | + var $iHtmlCurrentChar; |
|
68 | + |
|
69 | + /** |
|
70 | + * Constructor. |
|
71 | + * Constructs an HTMLParser instance with |
|
72 | + * the HTML text given. |
|
73 | + */ |
|
74 | + function HTMLParser ($aHtmlText) { |
|
75 | + $this->iHtmlText = $aHtmlText; |
|
76 | + $this->iHtmlTextLength = strlen($aHtmlText); |
|
77 | + $this->setTextIndex (0); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Method parse. |
|
82 | + * Parses the next node. Returns false only if |
|
83 | + * the end of the HTML text has been reached. |
|
84 | + * Updates values of iNode* fields. |
|
85 | + */ |
|
86 | + function parse() { |
|
87 | + $text = trim($this->skipToElement()); |
|
88 | + if ($text != "") { |
|
89 | + $this->iNodeType = NODE_TYPE_TEXT; |
|
90 | + $this->iNodeName = "Text"; |
|
91 | + $this->iNodeValue = $text; |
|
92 | + $this->iNodeAttributes = 0; |
|
93 | + return true; |
|
94 | + } |
|
95 | + return $this->readTag(); |
|
96 | + } |
|
97 | + |
|
98 | + function clearAttributes() { |
|
99 | + $this->iNodeAttributes = array(); |
|
100 | + } |
|
101 | + |
|
102 | + function readTag() { |
|
103 | + global $HTML_ATTRIBUTE_STAND_ALONE; |
|
104 | + if ($this->iCurrentChar != "<") { |
|
105 | + $this->iNodeType = NODE_TYPE_DONE; |
|
106 | + return false; |
|
107 | + } |
|
108 | + $this->skipInTag (array("<")); |
|
109 | + $this->clearAttributes(); |
|
110 | + $name = $this->skipToBlanksInTag(); |
|
111 | + $pos = strpos($name, "/"); |
|
112 | + if ($pos === 0) { |
|
113 | + $this->iNodeType = NODE_TYPE_ENDELEMENT; |
|
114 | + $this->iNodeName = substr ($name, 1); |
|
115 | + $this->iNodeValue = ""; |
|
116 | + } |
|
117 | + else { |
|
118 | + if (!$this->isValidTagIdentifier ($name)) { |
|
119 | + $comment = false; |
|
120 | + if ($name == "!--") { |
|
121 | + $rest = $this->skipToStringInTag ("-->"); |
|
122 | + if ($rest != "") { |
|
123 | + $this->iNodeType = NODE_TYPE_COMMENT; |
|
124 | + $this->iNodeName = "Comment"; |
|
125 | + $this->iNodeValue = "<" . $name . $rest; |
|
126 | + $comment = true; |
|
127 | + } |
|
128 | + } |
|
129 | + if (!$comment) { |
|
130 | + $this->iNodeType = NODE_TYPE_TEXT; |
|
131 | + $this->iNodeName = "Text"; |
|
132 | + $this->iNodeValue = "<" . $name; |
|
133 | + } |
|
134 | + return true; |
|
135 | + } |
|
136 | + else { |
|
137 | + $this->iNodeType = NODE_TYPE_ELEMENT; |
|
138 | + $this->iNodeValue = ""; |
|
139 | + $nameLength = strlen($name); |
|
140 | + if ($nameLength > 0 && substr($name, $nameLength - 1, 1) == "/") { |
|
141 | + $this->iNodeName = substr($name, 0, $nameLength - 1); |
|
142 | + }else { |
|
143 | + $this->iNodeName = $name; |
|
144 | + } |
|
145 | + $this->iNodeName = strtolower($this->iNodeName); |
|
146 | + } |
|
147 | + } |
|
148 | + while ($this->skipBlanksInTag()) { |
|
149 | + $attrName = $this->skipToBlanksOrEqualsInTag(); |
|
150 | + if ($attrName != "") { |
|
151 | 151 | $attrName = strtolower($attrName); |
152 | 152 | if (array_search($attrName, $HTML_ATTRIBUTE_STAND_ALONE)!==false){ |
153 | 153 | $this->iNodeAttributes[$attrName] = 1; |
154 | 154 | }else{ |
155 | - $this->skipBlanksInTag(); |
|
156 | - if ($this->iCurrentChar == "=") { |
|
157 | - $this->skipEqualsInTag(); |
|
158 | - $this->skipBlanksInTag(); |
|
159 | - $value = $this->readValueInTag(); |
|
160 | - $this->iNodeAttributes[$attrName] = $value; |
|
161 | - }else { |
|
162 | - $this->iNodeAttributes[$attrName] = ""; |
|
163 | - } |
|
155 | + $this->skipBlanksInTag(); |
|
156 | + if ($this->iCurrentChar == "=") { |
|
157 | + $this->skipEqualsInTag(); |
|
158 | + $this->skipBlanksInTag(); |
|
159 | + $value = $this->readValueInTag(); |
|
160 | + $this->iNodeAttributes[$attrName] = $value; |
|
161 | + }else { |
|
162 | + $this->iNodeAttributes[$attrName] = ""; |
|
163 | + } |
|
164 | 164 | } |
165 | - } |
|
166 | - } |
|
167 | - $this->skipEndOfTag(); |
|
168 | - return true; |
|
169 | - } |
|
170 | - |
|
171 | - function isValidTagIdentifier ($name) { |
|
172 | - return preg_match ("/[A-Za-z0-9]+/", $name); |
|
173 | - } |
|
165 | + } |
|
166 | + } |
|
167 | + $this->skipEndOfTag(); |
|
168 | + return true; |
|
169 | + } |
|
170 | + |
|
171 | + function isValidTagIdentifier ($name) { |
|
172 | + return preg_match ("/[A-Za-z0-9]+/", $name); |
|
173 | + } |
|
174 | 174 | |
175 | - function skipBlanksInTag() { |
|
176 | - return "" != ($this->skipInTag (array (" ", "\t", "\r", "\n" ))); |
|
177 | - } |
|
178 | - |
|
179 | - function skipToBlanksOrEqualsInTag() { |
|
180 | - return $this->skipToInTag (array (" ", "\t", "\r", "\n", "=" )); |
|
181 | - } |
|
182 | - |
|
183 | - function skipToBlanksInTag() { |
|
184 | - return $this->skipToInTag (array (" ", "\t", "\r", "\n" )); |
|
185 | - } |
|
186 | - |
|
187 | - function skipEqualsInTag() { |
|
188 | - return $this->skipInTag (array ( "=" )); |
|
189 | - } |
|
190 | - |
|
191 | - function readValueInTag() { |
|
192 | - $ch = $this->iCurrentChar; |
|
193 | - $value = ""; |
|
194 | - if ($ch == "\"") { |
|
195 | - $this->skipInTag (array ( "\"" )); |
|
196 | - $value = $this->skipToInTag (array ( "\"" )); |
|
197 | - $this->skipInTag (array ( "\"" )); |
|
198 | - } |
|
199 | - else if ($ch == "'") { |
|
200 | - $this->skipInTag (array ( "'" )); |
|
201 | - $value = $this->skipToInTag (array ( "'" )); |
|
202 | - $this->skipInTag (array ( "'" )); |
|
203 | - } |
|
204 | - else { |
|
205 | - $value = $this->skipToBlanksInTag(); |
|
206 | - } |
|
207 | - return $value; |
|
208 | - } |
|
209 | - |
|
210 | - function setTextIndex ($index) { |
|
211 | - $this->iHtmlTextIndex = $index; |
|
212 | - if ($index >= $this->iHtmlTextLength) { |
|
213 | - $this->iCurrentChar = -1; |
|
214 | - } |
|
215 | - else { |
|
216 | - $this->iCurrentChar = $this->iHtmlText{$index}; |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - function moveNext() { |
|
221 | - if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { |
|
222 | - $this->setTextIndex ($this->iHtmlTextIndex + 1); |
|
223 | - return true; |
|
224 | - } |
|
225 | - else { |
|
226 | - return false; |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - function skipEndOfTag() { |
|
231 | - $sb = ""; |
|
232 | - if (($ch = $this->iCurrentChar) !== -1) { |
|
233 | - $match = ($ch == ">"); |
|
234 | - if (!$match) { |
|
235 | - return $sb; |
|
236 | - } |
|
237 | - $sb .= $ch; |
|
238 | - $this->moveNext(); |
|
239 | - } |
|
240 | - return $sb; |
|
241 | - } |
|
242 | - |
|
243 | - function skipInTag ($chars) { |
|
244 | - $sb = ""; |
|
245 | - while (($ch = $this->iCurrentChar) !== -1) { |
|
246 | - if ($ch == ">") { |
|
247 | - return $sb; |
|
248 | - } else { |
|
249 | - if (array_search($ch,$chars) === false) |
|
250 | - return $sb; |
|
251 | - $sb .= $ch; |
|
252 | - $this->moveNext(); |
|
253 | - } |
|
254 | - } |
|
255 | - return $sb; |
|
256 | - } |
|
257 | - |
|
258 | - function skipToInTag ($chars) { |
|
259 | - $sb = ""; |
|
260 | - while (($ch = $this->iCurrentChar) !== -1) { |
|
261 | - if ($ch == '>' || array_search($ch,$chars) !== false) |
|
262 | - return $sb; |
|
263 | - $sb .= $ch; |
|
264 | - $this->moveNext(); |
|
265 | - } |
|
266 | - return $sb; |
|
267 | - } |
|
268 | - |
|
269 | - function skipToElement() { |
|
270 | - $sb = ""; |
|
271 | - while (($ch = $this->iCurrentChar) !== -1) { |
|
272 | - if ($ch == "<") { |
|
273 | - return $sb; |
|
274 | - } |
|
275 | - $sb .= $ch; |
|
276 | - $this->moveNext(); |
|
277 | - } |
|
278 | - return $sb; |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * Returns text between current position and $needle, |
|
283 | - * inclusive, or "" if not found. The current index is moved to a point |
|
284 | - * after the location of $needle, or not moved at all |
|
285 | - * if nothing is found. |
|
286 | - */ |
|
287 | - function skipToStringInTag ($needle) { |
|
288 | - $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
|
289 | - if ($pos === false) { |
|
290 | - return ""; |
|
291 | - } |
|
292 | - $top = $pos + strlen($needle); |
|
293 | - $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); |
|
294 | - $this->setTextIndex ($top); |
|
295 | - return $retvalue; |
|
296 | - } |
|
175 | + function skipBlanksInTag() { |
|
176 | + return "" != ($this->skipInTag (array (" ", "\t", "\r", "\n" ))); |
|
177 | + } |
|
178 | + |
|
179 | + function skipToBlanksOrEqualsInTag() { |
|
180 | + return $this->skipToInTag (array (" ", "\t", "\r", "\n", "=" )); |
|
181 | + } |
|
182 | + |
|
183 | + function skipToBlanksInTag() { |
|
184 | + return $this->skipToInTag (array (" ", "\t", "\r", "\n" )); |
|
185 | + } |
|
186 | + |
|
187 | + function skipEqualsInTag() { |
|
188 | + return $this->skipInTag (array ( "=" )); |
|
189 | + } |
|
190 | + |
|
191 | + function readValueInTag() { |
|
192 | + $ch = $this->iCurrentChar; |
|
193 | + $value = ""; |
|
194 | + if ($ch == "\"") { |
|
195 | + $this->skipInTag (array ( "\"" )); |
|
196 | + $value = $this->skipToInTag (array ( "\"" )); |
|
197 | + $this->skipInTag (array ( "\"" )); |
|
198 | + } |
|
199 | + else if ($ch == "'") { |
|
200 | + $this->skipInTag (array ( "'" )); |
|
201 | + $value = $this->skipToInTag (array ( "'" )); |
|
202 | + $this->skipInTag (array ( "'" )); |
|
203 | + } |
|
204 | + else { |
|
205 | + $value = $this->skipToBlanksInTag(); |
|
206 | + } |
|
207 | + return $value; |
|
208 | + } |
|
209 | + |
|
210 | + function setTextIndex ($index) { |
|
211 | + $this->iHtmlTextIndex = $index; |
|
212 | + if ($index >= $this->iHtmlTextLength) { |
|
213 | + $this->iCurrentChar = -1; |
|
214 | + } |
|
215 | + else { |
|
216 | + $this->iCurrentChar = $this->iHtmlText{$index}; |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + function moveNext() { |
|
221 | + if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { |
|
222 | + $this->setTextIndex ($this->iHtmlTextIndex + 1); |
|
223 | + return true; |
|
224 | + } |
|
225 | + else { |
|
226 | + return false; |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + function skipEndOfTag() { |
|
231 | + $sb = ""; |
|
232 | + if (($ch = $this->iCurrentChar) !== -1) { |
|
233 | + $match = ($ch == ">"); |
|
234 | + if (!$match) { |
|
235 | + return $sb; |
|
236 | + } |
|
237 | + $sb .= $ch; |
|
238 | + $this->moveNext(); |
|
239 | + } |
|
240 | + return $sb; |
|
241 | + } |
|
242 | + |
|
243 | + function skipInTag ($chars) { |
|
244 | + $sb = ""; |
|
245 | + while (($ch = $this->iCurrentChar) !== -1) { |
|
246 | + if ($ch == ">") { |
|
247 | + return $sb; |
|
248 | + } else { |
|
249 | + if (array_search($ch,$chars) === false) |
|
250 | + return $sb; |
|
251 | + $sb .= $ch; |
|
252 | + $this->moveNext(); |
|
253 | + } |
|
254 | + } |
|
255 | + return $sb; |
|
256 | + } |
|
257 | + |
|
258 | + function skipToInTag ($chars) { |
|
259 | + $sb = ""; |
|
260 | + while (($ch = $this->iCurrentChar) !== -1) { |
|
261 | + if ($ch == '>' || array_search($ch,$chars) !== false) |
|
262 | + return $sb; |
|
263 | + $sb .= $ch; |
|
264 | + $this->moveNext(); |
|
265 | + } |
|
266 | + return $sb; |
|
267 | + } |
|
268 | + |
|
269 | + function skipToElement() { |
|
270 | + $sb = ""; |
|
271 | + while (($ch = $this->iCurrentChar) !== -1) { |
|
272 | + if ($ch == "<") { |
|
273 | + return $sb; |
|
274 | + } |
|
275 | + $sb .= $ch; |
|
276 | + $this->moveNext(); |
|
277 | + } |
|
278 | + return $sb; |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * Returns text between current position and $needle, |
|
283 | + * inclusive, or "" if not found. The current index is moved to a point |
|
284 | + * after the location of $needle, or not moved at all |
|
285 | + * if nothing is found. |
|
286 | + */ |
|
287 | + function skipToStringInTag ($needle) { |
|
288 | + $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
|
289 | + if ($pos === false) { |
|
290 | + return ""; |
|
291 | + } |
|
292 | + $top = $pos + strlen($needle); |
|
293 | + $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); |
|
294 | + $this->setTextIndex ($top); |
|
295 | + return $retvalue; |
|
296 | + } |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | class HTMLFileParser extends HTMLParser { |
300 | 300 | function HTMLFileParser($fileName){ |
301 | - $fp = fopen ($fileName, "r"); |
|
302 | - $content = ""; |
|
303 | - while (true) { |
|
304 | - $data = fread ($fp, 8192); |
|
305 | - if (strlen($data) == 0) { |
|
306 | - break; |
|
307 | - } |
|
308 | - $content .= $data; |
|
309 | - } |
|
310 | - fclose ($fp); |
|
301 | + $fp = fopen ($fileName, "r"); |
|
302 | + $content = ""; |
|
303 | + while (true) { |
|
304 | + $data = fread ($fp, 8192); |
|
305 | + if (strlen($data) == 0) { |
|
306 | + break; |
|
307 | + } |
|
308 | + $content .= $data; |
|
309 | + } |
|
310 | + fclose ($fp); |
|
311 | 311 | $this->HTMLParser($content); |
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | 315 | class HTMLURLParser extends HTMLParser { |
316 | 316 | function HTMLURLParser($url){ |
317 | - $fp = fopen ($url, "r"); |
|
318 | - $content = ""; |
|
319 | - while (true) { |
|
320 | - $data = fread ($fp, 8192); |
|
321 | - if (strlen($data) == 0) { |
|
322 | - break; |
|
323 | - } |
|
324 | - $content .= $data; |
|
325 | - } |
|
326 | - fclose ($fp); |
|
317 | + $fp = fopen ($url, "r"); |
|
318 | + $content = ""; |
|
319 | + while (true) { |
|
320 | + $data = fread ($fp, 8192); |
|
321 | + if (strlen($data) == 0) { |
|
322 | + break; |
|
323 | + } |
|
324 | + $content .= $data; |
|
325 | + } |
|
326 | + fclose ($fp); |
|
327 | 327 | $this->HTMLParser(file_get_contents($content)); |
328 | 328 | } |
329 | 329 | } |
@@ -341,29 +341,29 @@ discard block |
||
341 | 341 | * @desc Tao mot tree node cac phan tu cua HTML |
342 | 342 | */ |
343 | 343 | function TreeHTML($parser, $file=true){ |
344 | - $i = 0; |
|
345 | - if ($file){ |
|
346 | - while ($parser->parse()) |
|
347 | - if (strtolower($parser->iNodeName)=='body') break; |
|
348 | - } |
|
349 | - while ($parser->parse()){ |
|
350 | - if ($parser->iNodeType == NODE_TYPE_ENDELEMENT && strtolower($parser->iNodeName)=='body' && $file) break; |
|
351 | - |
|
352 | - $this->type[$i] = $parser->iNodeType; |
|
353 | - $this->name[$i] = $parser->iNodeName; |
|
354 | - if ($parser->iNodeType == NODE_TYPE_TEXT) |
|
355 | - $this->value[$i] = $parser->iNodeValue; |
|
356 | - if ($parser->iNodeType == NODE_TYPE_ELEMENT){ |
|
357 | - $this->attribute[$i] = $parser->iNodeAttributes; |
|
358 | - if (isset($parser->iNodeAttributes['name'])){ |
|
359 | - $this->field[$i] = trim($parser->iNodeAttributes['name'],"\"' "); |
|
360 | - } |
|
361 | - if ( ($file && $parser->iNodeName == 'input' && isset($this->attribute[$i]['type']) && $this->attribute[$i]['type']=='text' && !isset($this->attribute[$i]['onkeydown'])) |
|
362 | - || ($file && $parser->iNodeName == 'textarea')) |
|
363 | - $this->attribute[$i]['onkeyup'] = 'initTyper(this)'; |
|
364 | - } |
|
365 | - $i++; |
|
366 | - } |
|
344 | + $i = 0; |
|
345 | + if ($file){ |
|
346 | + while ($parser->parse()) |
|
347 | + if (strtolower($parser->iNodeName)=='body') break; |
|
348 | + } |
|
349 | + while ($parser->parse()){ |
|
350 | + if ($parser->iNodeType == NODE_TYPE_ENDELEMENT && strtolower($parser->iNodeName)=='body' && $file) break; |
|
351 | + |
|
352 | + $this->type[$i] = $parser->iNodeType; |
|
353 | + $this->name[$i] = $parser->iNodeName; |
|
354 | + if ($parser->iNodeType == NODE_TYPE_TEXT) |
|
355 | + $this->value[$i] = $parser->iNodeValue; |
|
356 | + if ($parser->iNodeType == NODE_TYPE_ELEMENT){ |
|
357 | + $this->attribute[$i] = $parser->iNodeAttributes; |
|
358 | + if (isset($parser->iNodeAttributes['name'])){ |
|
359 | + $this->field[$i] = trim($parser->iNodeAttributes['name'],"\"' "); |
|
360 | + } |
|
361 | + if ( ($file && $parser->iNodeName == 'input' && isset($this->attribute[$i]['type']) && $this->attribute[$i]['type']=='text' && !isset($this->attribute[$i]['onkeydown'])) |
|
362 | + || ($file && $parser->iNodeName == 'textarea')) |
|
363 | + $this->attribute[$i]['onkeyup'] = 'initTyper(this)'; |
|
364 | + } |
|
365 | + $i++; |
|
366 | + } |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -513,14 +513,14 @@ |
||
513 | 513 | foreach ($this->name as $i => $name){ |
514 | 514 | if ($name == 'input' && isset($this->attribute[$i]['type'])){ |
515 | 515 | switch($this->attribute[$i]['type']){ |
516 | - case 'text': |
|
517 | - $this->attribute[$i]['readonly'] = 'true'; |
|
518 | - $this->attribute[$i]['style'] = 'border: 1 dotted #999999'; |
|
519 | - break; |
|
520 | - case 'select': |
|
521 | - case 'checkbox': |
|
522 | - $this->attribute[$i]['disabled'] = 1; |
|
523 | - break; |
|
516 | + case 'text': |
|
517 | + $this->attribute[$i]['readonly'] = 'true'; |
|
518 | + $this->attribute[$i]['style'] = 'border: 1 dotted #999999'; |
|
519 | + break; |
|
520 | + case 'select': |
|
521 | + case 'checkbox': |
|
522 | + $this->attribute[$i]['disabled'] = 1; |
|
523 | + break; |
|
524 | 524 | } |
525 | 525 | }elseif ($name == 'textarea'){ |
526 | 526 | $this->attribute[$i]['readonly'] = 'true'; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | global $HTML_ATTRIBUTE_STAND_ALONE; |
4 | -$HTML_ATTRIBUTE_STAND_ALONE = array('checked','compact','declare','defer','disabled','ismap','multiple','nohref','noresize','noshade','nowrap','readonly','selected'); |
|
4 | +$HTML_ATTRIBUTE_STAND_ALONE = array('checked', 'compact', 'declare', 'defer', 'disabled', 'ismap', 'multiple', 'nohref', 'noresize', 'noshade', 'nowrap', 'readonly', 'selected'); |
|
5 | 5 | |
6 | 6 | /* |
7 | 7 | * Copyright (c) 2003 Jose Solorzano. All rights reserved. |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | * - Leo West (performance improvements) |
14 | 14 | */ |
15 | 15 | |
16 | -define ("NODE_TYPE_START",0); |
|
17 | -define ("NODE_TYPE_ELEMENT",1); |
|
18 | -define ("NODE_TYPE_ENDELEMENT",2); |
|
19 | -define ("NODE_TYPE_TEXT",3); |
|
20 | -define ("NODE_TYPE_COMMENT",4); |
|
21 | -define ("NODE_TYPE_DONE",5); |
|
16 | +define("NODE_TYPE_START", 0); |
|
17 | +define("NODE_TYPE_ELEMENT", 1); |
|
18 | +define("NODE_TYPE_ENDELEMENT", 2); |
|
19 | +define("NODE_TYPE_TEXT", 3); |
|
20 | +define("NODE_TYPE_COMMENT", 4); |
|
21 | +define("NODE_TYPE_DONE", 5); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Class HTMLParser. |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | * Constructs an HTMLParser instance with |
72 | 72 | * the HTML text given. |
73 | 73 | */ |
74 | - function HTMLParser ($aHtmlText) { |
|
74 | + function HTMLParser($aHtmlText) { |
|
75 | 75 | $this->iHtmlText = $aHtmlText; |
76 | 76 | $this->iHtmlTextLength = strlen($aHtmlText); |
77 | - $this->setTextIndex (0); |
|
77 | + $this->setTextIndex(0); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -105,31 +105,31 @@ discard block |
||
105 | 105 | $this->iNodeType = NODE_TYPE_DONE; |
106 | 106 | return false; |
107 | 107 | } |
108 | - $this->skipInTag (array("<")); |
|
108 | + $this->skipInTag(array("<")); |
|
109 | 109 | $this->clearAttributes(); |
110 | 110 | $name = $this->skipToBlanksInTag(); |
111 | 111 | $pos = strpos($name, "/"); |
112 | 112 | if ($pos === 0) { |
113 | 113 | $this->iNodeType = NODE_TYPE_ENDELEMENT; |
114 | - $this->iNodeName = substr ($name, 1); |
|
114 | + $this->iNodeName = substr($name, 1); |
|
115 | 115 | $this->iNodeValue = ""; |
116 | 116 | } |
117 | 117 | else { |
118 | - if (!$this->isValidTagIdentifier ($name)) { |
|
118 | + if (!$this->isValidTagIdentifier($name)) { |
|
119 | 119 | $comment = false; |
120 | 120 | if ($name == "!--") { |
121 | - $rest = $this->skipToStringInTag ("-->"); |
|
121 | + $rest = $this->skipToStringInTag("-->"); |
|
122 | 122 | if ($rest != "") { |
123 | 123 | $this->iNodeType = NODE_TYPE_COMMENT; |
124 | 124 | $this->iNodeName = "Comment"; |
125 | - $this->iNodeValue = "<" . $name . $rest; |
|
125 | + $this->iNodeValue = "<".$name.$rest; |
|
126 | 126 | $comment = true; |
127 | 127 | } |
128 | 128 | } |
129 | 129 | if (!$comment) { |
130 | 130 | $this->iNodeType = NODE_TYPE_TEXT; |
131 | 131 | $this->iNodeName = "Text"; |
132 | - $this->iNodeValue = "<" . $name; |
|
132 | + $this->iNodeValue = "<".$name; |
|
133 | 133 | } |
134 | 134 | return true; |
135 | 135 | } |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | $attrName = $this->skipToBlanksOrEqualsInTag(); |
150 | 150 | if ($attrName != "") { |
151 | 151 | $attrName = strtolower($attrName); |
152 | - if (array_search($attrName, $HTML_ATTRIBUTE_STAND_ALONE)!==false){ |
|
152 | + if (array_search($attrName, $HTML_ATTRIBUTE_STAND_ALONE) !== false) { |
|
153 | 153 | $this->iNodeAttributes[$attrName] = 1; |
154 | - }else{ |
|
154 | + }else { |
|
155 | 155 | $this->skipBlanksInTag(); |
156 | 156 | if ($this->iCurrentChar == "=") { |
157 | 157 | $this->skipEqualsInTag(); |
@@ -168,38 +168,38 @@ discard block |
||
168 | 168 | return true; |
169 | 169 | } |
170 | 170 | |
171 | - function isValidTagIdentifier ($name) { |
|
172 | - return preg_match ("/[A-Za-z0-9]+/", $name); |
|
171 | + function isValidTagIdentifier($name) { |
|
172 | + return preg_match("/[A-Za-z0-9]+/", $name); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | function skipBlanksInTag() { |
176 | - return "" != ($this->skipInTag (array (" ", "\t", "\r", "\n" ))); |
|
176 | + return "" != ($this->skipInTag(array(" ", "\t", "\r", "\n"))); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | function skipToBlanksOrEqualsInTag() { |
180 | - return $this->skipToInTag (array (" ", "\t", "\r", "\n", "=" )); |
|
180 | + return $this->skipToInTag(array(" ", "\t", "\r", "\n", "=")); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | function skipToBlanksInTag() { |
184 | - return $this->skipToInTag (array (" ", "\t", "\r", "\n" )); |
|
184 | + return $this->skipToInTag(array(" ", "\t", "\r", "\n")); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | function skipEqualsInTag() { |
188 | - return $this->skipInTag (array ( "=" )); |
|
188 | + return $this->skipInTag(array("=")); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | function readValueInTag() { |
192 | 192 | $ch = $this->iCurrentChar; |
193 | 193 | $value = ""; |
194 | 194 | if ($ch == "\"") { |
195 | - $this->skipInTag (array ( "\"" )); |
|
196 | - $value = $this->skipToInTag (array ( "\"" )); |
|
197 | - $this->skipInTag (array ( "\"" )); |
|
195 | + $this->skipInTag(array("\"")); |
|
196 | + $value = $this->skipToInTag(array("\"")); |
|
197 | + $this->skipInTag(array("\"")); |
|
198 | 198 | } |
199 | 199 | else if ($ch == "'") { |
200 | - $this->skipInTag (array ( "'" )); |
|
201 | - $value = $this->skipToInTag (array ( "'" )); |
|
202 | - $this->skipInTag (array ( "'" )); |
|
200 | + $this->skipInTag(array("'")); |
|
201 | + $value = $this->skipToInTag(array("'")); |
|
202 | + $this->skipInTag(array("'")); |
|
203 | 203 | } |
204 | 204 | else { |
205 | 205 | $value = $this->skipToBlanksInTag(); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | return $value; |
208 | 208 | } |
209 | 209 | |
210 | - function setTextIndex ($index) { |
|
210 | + function setTextIndex($index) { |
|
211 | 211 | $this->iHtmlTextIndex = $index; |
212 | 212 | if ($index >= $this->iHtmlTextLength) { |
213 | 213 | $this->iCurrentChar = -1; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | function moveNext() { |
221 | 221 | if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { |
222 | - $this->setTextIndex ($this->iHtmlTextIndex + 1); |
|
222 | + $this->setTextIndex($this->iHtmlTextIndex + 1); |
|
223 | 223 | return true; |
224 | 224 | } |
225 | 225 | else { |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | return $sb; |
241 | 241 | } |
242 | 242 | |
243 | - function skipInTag ($chars) { |
|
243 | + function skipInTag($chars) { |
|
244 | 244 | $sb = ""; |
245 | 245 | while (($ch = $this->iCurrentChar) !== -1) { |
246 | 246 | if ($ch == ">") { |
247 | 247 | return $sb; |
248 | - } else { |
|
249 | - if (array_search($ch,$chars) === false) |
|
248 | + }else { |
|
249 | + if (array_search($ch, $chars) === false) |
|
250 | 250 | return $sb; |
251 | 251 | $sb .= $ch; |
252 | 252 | $this->moveNext(); |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | return $sb; |
256 | 256 | } |
257 | 257 | |
258 | - function skipToInTag ($chars) { |
|
258 | + function skipToInTag($chars) { |
|
259 | 259 | $sb = ""; |
260 | 260 | while (($ch = $this->iCurrentChar) !== -1) { |
261 | - if ($ch == '>' || array_search($ch,$chars) !== false) |
|
261 | + if ($ch == '>' || array_search($ch, $chars) !== false) |
|
262 | 262 | return $sb; |
263 | 263 | $sb .= $ch; |
264 | 264 | $this->moveNext(); |
@@ -284,81 +284,81 @@ discard block |
||
284 | 284 | * after the location of $needle, or not moved at all |
285 | 285 | * if nothing is found. |
286 | 286 | */ |
287 | - function skipToStringInTag ($needle) { |
|
288 | - $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
|
287 | + function skipToStringInTag($needle) { |
|
288 | + $pos = strpos($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
|
289 | 289 | if ($pos === false) { |
290 | 290 | return ""; |
291 | 291 | } |
292 | 292 | $top = $pos + strlen($needle); |
293 | - $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); |
|
294 | - $this->setTextIndex ($top); |
|
293 | + $retvalue = substr($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); |
|
294 | + $this->setTextIndex($top); |
|
295 | 295 | return $retvalue; |
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
299 | 299 | class HTMLFileParser extends HTMLParser { |
300 | - function HTMLFileParser($fileName){ |
|
301 | - $fp = fopen ($fileName, "r"); |
|
300 | + function HTMLFileParser($fileName) { |
|
301 | + $fp = fopen($fileName, "r"); |
|
302 | 302 | $content = ""; |
303 | 303 | while (true) { |
304 | - $data = fread ($fp, 8192); |
|
304 | + $data = fread($fp, 8192); |
|
305 | 305 | if (strlen($data) == 0) { |
306 | 306 | break; |
307 | 307 | } |
308 | 308 | $content .= $data; |
309 | 309 | } |
310 | - fclose ($fp); |
|
310 | + fclose($fp); |
|
311 | 311 | $this->HTMLParser($content); |
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | 315 | class HTMLURLParser extends HTMLParser { |
316 | - function HTMLURLParser($url){ |
|
317 | - $fp = fopen ($url, "r"); |
|
316 | + function HTMLURLParser($url) { |
|
317 | + $fp = fopen($url, "r"); |
|
318 | 318 | $content = ""; |
319 | 319 | while (true) { |
320 | - $data = fread ($fp, 8192); |
|
320 | + $data = fread($fp, 8192); |
|
321 | 321 | if (strlen($data) == 0) { |
322 | 322 | break; |
323 | 323 | } |
324 | 324 | $content .= $data; |
325 | 325 | } |
326 | - fclose ($fp); |
|
326 | + fclose($fp); |
|
327 | 327 | $this->HTMLParser(file_get_contents($content)); |
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | -class TreeHTML{ |
|
331 | +class TreeHTML { |
|
332 | 332 | var $type = array(); |
333 | 333 | var $name = array(); |
334 | 334 | var $value = array(); |
335 | 335 | var $attribute = array(); |
336 | 336 | var $field = array(); |
337 | - var $addText=''; |
|
337 | + var $addText = ''; |
|
338 | 338 | |
339 | 339 | /** |
340 | 340 | * @return array |
341 | 341 | * @desc Tao mot tree node cac phan tu cua HTML |
342 | 342 | */ |
343 | - function TreeHTML($parser, $file=true){ |
|
343 | + function TreeHTML($parser, $file = true) { |
|
344 | 344 | $i = 0; |
345 | - if ($file){ |
|
345 | + if ($file) { |
|
346 | 346 | while ($parser->parse()) |
347 | - if (strtolower($parser->iNodeName)=='body') break; |
|
347 | + if (strtolower($parser->iNodeName) == 'body') break; |
|
348 | 348 | } |
349 | - while ($parser->parse()){ |
|
350 | - if ($parser->iNodeType == NODE_TYPE_ENDELEMENT && strtolower($parser->iNodeName)=='body' && $file) break; |
|
349 | + while ($parser->parse()) { |
|
350 | + if ($parser->iNodeType == NODE_TYPE_ENDELEMENT && strtolower($parser->iNodeName) == 'body' && $file) break; |
|
351 | 351 | |
352 | 352 | $this->type[$i] = $parser->iNodeType; |
353 | 353 | $this->name[$i] = $parser->iNodeName; |
354 | 354 | if ($parser->iNodeType == NODE_TYPE_TEXT) |
355 | 355 | $this->value[$i] = $parser->iNodeValue; |
356 | - if ($parser->iNodeType == NODE_TYPE_ELEMENT){ |
|
356 | + if ($parser->iNodeType == NODE_TYPE_ELEMENT) { |
|
357 | 357 | $this->attribute[$i] = $parser->iNodeAttributes; |
358 | - if (isset($parser->iNodeAttributes['name'])){ |
|
359 | - $this->field[$i] = trim($parser->iNodeAttributes['name'],"\"' "); |
|
358 | + if (isset($parser->iNodeAttributes['name'])) { |
|
359 | + $this->field[$i] = trim($parser->iNodeAttributes['name'], "\"' "); |
|
360 | 360 | } |
361 | - if ( ($file && $parser->iNodeName == 'input' && isset($this->attribute[$i]['type']) && $this->attribute[$i]['type']=='text' && !isset($this->attribute[$i]['onkeydown'])) |
|
361 | + if (($file && $parser->iNodeName == 'input' && isset($this->attribute[$i]['type']) && $this->attribute[$i]['type'] == 'text' && !isset($this->attribute[$i]['onkeydown'])) |
|
362 | 362 | || ($file && $parser->iNodeName == 'textarea')) |
363 | 363 | $this->attribute[$i]['onkeyup'] = 'initTyper(this)'; |
364 | 364 | } |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | /** |
370 | 370 | * @desc Them hoac sua field co ten $name mot thuoc tinh $attr |
371 | 371 | */ |
372 | - function set($name,$attr, $value){ |
|
372 | + function set($name, $attr, $value) { |
|
373 | 373 | $index = array_search($name, $this->field); |
374 | 374 | if (!$index) return; |
375 | 375 | $this->attribute[$index][$attr] = $value; |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | /** |
379 | 379 | * @desc Tra ve thuoc tinh $attr cua field $name |
380 | 380 | */ |
381 | - function get($name,$attr){ |
|
381 | + function get($name, $attr) { |
|
382 | 382 | $index = array_search($name, $this->field); |
383 | 383 | if ($index && isset($this->attribute[$index][$attr])) |
384 | 384 | return $this->attribute[$index][$attr]; |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | /** |
389 | 389 | * @desc Tra ve ten cua tag HTML ung voi field $name |
390 | 390 | */ |
391 | - function getTag($name){ |
|
391 | + function getTag($name) { |
|
392 | 392 | $index = array_search($name, $this->field); |
393 | 393 | //if (!isset($this->name[$index])) {debug($name);debug($index);} |
394 | 394 | return $this->name[$index]; |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | /** |
398 | 398 | * @desc Tra ve cac thuoc tinh gom tabindex, size, maxlength |
399 | 399 | */ |
400 | - function getAll($name){ |
|
400 | + function getAll($name) { |
|
401 | 401 | $index = array_search($name, $this->field); |
402 | - if ($index){ |
|
402 | + if ($index) { |
|
403 | 403 | $t = ''; |
404 | 404 | if (isset($this->attribute[$index]['tabindex'])) |
405 | 405 | $t .= ' tabindex='.$this->attribute[$index]['tabindex']; |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | /** |
416 | 416 | * @desc Thay doi node ten $name thanh text voi noi dung $text |
417 | 417 | */ |
418 | - function replace($name,$text){ |
|
418 | + function replace($name, $text) { |
|
419 | 419 | $index = array_search($name, $this->field); |
420 | 420 | if (!$index) return; |
421 | 421 | $this->removeIndex($index); |
@@ -426,17 +426,17 @@ discard block |
||
426 | 426 | /** |
427 | 427 | * @desc Thay doi node ten $name thanh text voi noi dung $text |
428 | 428 | */ |
429 | - function remove($name){ |
|
429 | + function remove($name) { |
|
430 | 430 | $index = array_search($name, $this->field); |
431 | 431 | if (!$index) return; |
432 | - if (!isset($this->name[$index])) return;//echo "Remove: $name <br>"; |
|
432 | + if (!isset($this->name[$index])) return; //echo "Remove: $name <br>"; |
|
433 | 433 | $rname = $this->name[$index]; |
434 | 434 | $len = count($this->name); |
435 | - for ($end=$index+1;$end<$len;$end++){ |
|
435 | + for ($end = $index + 1; $end < $len; $end++) { |
|
436 | 436 | if (isset($this->name[$end]) && $this->name[$end] == $rname) break; |
437 | 437 | } |
438 | - if (isset($this->type[$end]) && $this->type[$end]==NODE_TYPE_ENDELEMENT){ |
|
439 | - for ($i=$index;$i<=$end;$i++) $this->removeIndex($i); |
|
438 | + if (isset($this->type[$end]) && $this->type[$end] == NODE_TYPE_ENDELEMENT) { |
|
439 | + for ($i = $index; $i <= $end; $i++) $this->removeIndex($i); |
|
440 | 440 | }else |
441 | 441 | $this->removeIndex($index); |
442 | 442 | } |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | /** |
445 | 445 | * @desc Private: Xoa 1 object trong tree |
446 | 446 | */ |
447 | - function removeIndex($index){ |
|
448 | - $this->type[$index]=-1; |
|
447 | + function removeIndex($index) { |
|
448 | + $this->type[$index] = -1; |
|
449 | 449 | unset($this->field[$index]); |
450 | 450 | unset($this->name[$index]); |
451 | 451 | unset($this->value[$index]); |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @desc Create a string HTML from a tree<br> |
458 | 458 | * An Item have format ($iNodeType, $iNodeName, $iNodeValue, $iNodeAttributes) |
459 | 459 | */ |
460 | - function toHTML(){ |
|
460 | + function toHTML() { |
|
461 | 461 | global $HTML_ATTRIBUTE_STAND_ALONE; |
462 | 462 | $result = ''; |
463 | 463 | $type = &$this->type; |
@@ -466,26 +466,26 @@ discard block |
||
466 | 466 | $attr = &$this->attribute; |
467 | 467 | |
468 | 468 | $len = count($type); |
469 | - for ($i=0; $i<$len;$i++){ |
|
469 | + for ($i = 0; $i < $len; $i++) { |
|
470 | 470 | $str = ''; |
471 | - switch($type[$i]){ |
|
471 | + switch ($type[$i]) { |
|
472 | 472 | case NODE_TYPE_ELEMENT: |
473 | - if ($name[$i] != 'textarea'){ |
|
473 | + if ($name[$i] != 'textarea') { |
|
474 | 474 | $str .= '<'.$name[$i]; |
475 | - if (isset($attr[$i])) foreach($attr[$i] as $key => $value){ |
|
476 | - if (array_search($value,$HTML_ATTRIBUTE_STAND_ALONE)!==false) |
|
475 | + if (isset($attr[$i])) foreach ($attr[$i] as $key => $value) { |
|
476 | + if (array_search($value, $HTML_ATTRIBUTE_STAND_ALONE) !== false) |
|
477 | 477 | $str .= " $key"; |
478 | 478 | else |
479 | 479 | $str .= " $key=\"$value\""; |
480 | 480 | } |
481 | 481 | $str .= '>'; |
482 | - }else{//is tag ATEXTAREA |
|
482 | + }else {//is tag ATEXTAREA |
|
483 | 483 | $content = ''; |
484 | 484 | $str .= '<'.$name[$i]; |
485 | - if (isset($attr[$i])) foreach($attr[$i] as $key => $value){ |
|
485 | + if (isset($attr[$i])) foreach ($attr[$i] as $key => $value) { |
|
486 | 486 | if ($key == 'value') |
487 | 487 | $content = $value; |
488 | - elseif (array_search($value,$HTML_ATTRIBUTE_STAND_ALONE)!==false) |
|
488 | + elseif (array_search($value, $HTML_ATTRIBUTE_STAND_ALONE) !== false) |
|
489 | 489 | $str .= " $key"; |
490 | 490 | else |
491 | 491 | $str .= " $key=\"$value\""; |
@@ -509,10 +509,10 @@ discard block |
||
509 | 509 | /** |
510 | 510 | * @desc Set all input text to readonly |
511 | 511 | */ |
512 | - function setReadonlyAll(){ |
|
513 | - foreach ($this->name as $i => $name){ |
|
514 | - if ($name == 'input' && isset($this->attribute[$i]['type'])){ |
|
515 | - switch($this->attribute[$i]['type']){ |
|
512 | + function setReadonlyAll() { |
|
513 | + foreach ($this->name as $i => $name) { |
|
514 | + if ($name == 'input' && isset($this->attribute[$i]['type'])) { |
|
515 | + switch ($this->attribute[$i]['type']) { |
|
516 | 516 | case 'text': |
517 | 517 | $this->attribute[$i]['readonly'] = 'true'; |
518 | 518 | $this->attribute[$i]['style'] = 'border: 1 dotted #999999'; |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | $this->attribute[$i]['disabled'] = 1; |
523 | 523 | break; |
524 | 524 | } |
525 | - }elseif ($name == 'textarea'){ |
|
525 | + }elseif ($name == 'textarea') { |
|
526 | 526 | $this->attribute[$i]['readonly'] = 'true'; |
527 | 527 | $this->attribute[$i]['style'] = 'border: 1 dotted #999999'; |
528 | 528 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | /** |
533 | 533 | * @desc Set an input text to readonly |
534 | 534 | */ |
535 | - function setReadonly($name){ |
|
535 | + function setReadonly($name) { |
|
536 | 536 | $index = array_search($name, $this->field); |
537 | 537 | if (!$index) return; |
538 | 538 | $this->attribute[$index]['readonly'] = true; |
@@ -113,8 +113,7 @@ discard block |
||
113 | 113 | $this->iNodeType = NODE_TYPE_ENDELEMENT; |
114 | 114 | $this->iNodeName = substr ($name, 1); |
115 | 115 | $this->iNodeValue = ""; |
116 | - } |
|
117 | - else { |
|
116 | + } else { |
|
118 | 117 | if (!$this->isValidTagIdentifier ($name)) { |
119 | 118 | $comment = false; |
120 | 119 | if ($name == "!--") { |
@@ -132,14 +131,13 @@ discard block |
||
132 | 131 | $this->iNodeValue = "<" . $name; |
133 | 132 | } |
134 | 133 | return true; |
135 | - } |
|
136 | - else { |
|
134 | + } else { |
|
137 | 135 | $this->iNodeType = NODE_TYPE_ELEMENT; |
138 | 136 | $this->iNodeValue = ""; |
139 | 137 | $nameLength = strlen($name); |
140 | 138 | if ($nameLength > 0 && substr($name, $nameLength - 1, 1) == "/") { |
141 | 139 | $this->iNodeName = substr($name, 0, $nameLength - 1); |
142 | - }else { |
|
140 | + } else { |
|
143 | 141 | $this->iNodeName = $name; |
144 | 142 | } |
145 | 143 | $this->iNodeName = strtolower($this->iNodeName); |
@@ -151,14 +149,14 @@ discard block |
||
151 | 149 | $attrName = strtolower($attrName); |
152 | 150 | if (array_search($attrName, $HTML_ATTRIBUTE_STAND_ALONE)!==false){ |
153 | 151 | $this->iNodeAttributes[$attrName] = 1; |
154 | - }else{ |
|
152 | + } else{ |
|
155 | 153 | $this->skipBlanksInTag(); |
156 | 154 | if ($this->iCurrentChar == "=") { |
157 | 155 | $this->skipEqualsInTag(); |
158 | 156 | $this->skipBlanksInTag(); |
159 | 157 | $value = $this->readValueInTag(); |
160 | 158 | $this->iNodeAttributes[$attrName] = $value; |
161 | - }else { |
|
159 | + } else { |
|
162 | 160 | $this->iNodeAttributes[$attrName] = ""; |
163 | 161 | } |
164 | 162 | } |
@@ -195,13 +193,11 @@ discard block |
||
195 | 193 | $this->skipInTag (array ( "\"" )); |
196 | 194 | $value = $this->skipToInTag (array ( "\"" )); |
197 | 195 | $this->skipInTag (array ( "\"" )); |
198 | - } |
|
199 | - else if ($ch == "'") { |
|
196 | + } else if ($ch == "'") { |
|
200 | 197 | $this->skipInTag (array ( "'" )); |
201 | 198 | $value = $this->skipToInTag (array ( "'" )); |
202 | 199 | $this->skipInTag (array ( "'" )); |
203 | - } |
|
204 | - else { |
|
200 | + } else { |
|
205 | 201 | $value = $this->skipToBlanksInTag(); |
206 | 202 | } |
207 | 203 | return $value; |
@@ -211,8 +207,7 @@ discard block |
||
211 | 207 | $this->iHtmlTextIndex = $index; |
212 | 208 | if ($index >= $this->iHtmlTextLength) { |
213 | 209 | $this->iCurrentChar = -1; |
214 | - } |
|
215 | - else { |
|
210 | + } else { |
|
216 | 211 | $this->iCurrentChar = $this->iHtmlText{$index}; |
217 | 212 | } |
218 | 213 | } |
@@ -221,8 +216,7 @@ discard block |
||
221 | 216 | if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { |
222 | 217 | $this->setTextIndex ($this->iHtmlTextIndex + 1); |
223 | 218 | return true; |
224 | - } |
|
225 | - else { |
|
219 | + } else { |
|
226 | 220 | return false; |
227 | 221 | } |
228 | 222 | } |
@@ -246,8 +240,9 @@ discard block |
||
246 | 240 | if ($ch == ">") { |
247 | 241 | return $sb; |
248 | 242 | } else { |
249 | - if (array_search($ch,$chars) === false) |
|
250 | - return $sb; |
|
243 | + if (array_search($ch,$chars) === false) { |
|
244 | + return $sb; |
|
245 | + } |
|
251 | 246 | $sb .= $ch; |
252 | 247 | $this->moveNext(); |
253 | 248 | } |
@@ -258,8 +253,9 @@ discard block |
||
258 | 253 | function skipToInTag ($chars) { |
259 | 254 | $sb = ""; |
260 | 255 | while (($ch = $this->iCurrentChar) !== -1) { |
261 | - if ($ch == '>' || array_search($ch,$chars) !== false) |
|
262 | - return $sb; |
|
256 | + if ($ch == '>' || array_search($ch,$chars) !== false) { |
|
257 | + return $sb; |
|
258 | + } |
|
263 | 259 | $sb .= $ch; |
264 | 260 | $this->moveNext(); |
265 | 261 | } |
@@ -343,24 +339,29 @@ discard block |
||
343 | 339 | function TreeHTML($parser, $file=true){ |
344 | 340 | $i = 0; |
345 | 341 | if ($file){ |
346 | - while ($parser->parse()) |
|
347 | - if (strtolower($parser->iNodeName)=='body') break; |
|
342 | + while ($parser->parse()) { |
|
343 | + if (strtolower($parser->iNodeName)=='body') break; |
|
344 | + } |
|
348 | 345 | } |
349 | 346 | while ($parser->parse()){ |
350 | - if ($parser->iNodeType == NODE_TYPE_ENDELEMENT && strtolower($parser->iNodeName)=='body' && $file) break; |
|
347 | + if ($parser->iNodeType == NODE_TYPE_ENDELEMENT && strtolower($parser->iNodeName)=='body' && $file) { |
|
348 | + break; |
|
349 | + } |
|
351 | 350 | |
352 | 351 | $this->type[$i] = $parser->iNodeType; |
353 | 352 | $this->name[$i] = $parser->iNodeName; |
354 | - if ($parser->iNodeType == NODE_TYPE_TEXT) |
|
355 | - $this->value[$i] = $parser->iNodeValue; |
|
353 | + if ($parser->iNodeType == NODE_TYPE_TEXT) { |
|
354 | + $this->value[$i] = $parser->iNodeValue; |
|
355 | + } |
|
356 | 356 | if ($parser->iNodeType == NODE_TYPE_ELEMENT){ |
357 | 357 | $this->attribute[$i] = $parser->iNodeAttributes; |
358 | 358 | if (isset($parser->iNodeAttributes['name'])){ |
359 | 359 | $this->field[$i] = trim($parser->iNodeAttributes['name'],"\"' "); |
360 | 360 | } |
361 | 361 | if ( ($file && $parser->iNodeName == 'input' && isset($this->attribute[$i]['type']) && $this->attribute[$i]['type']=='text' && !isset($this->attribute[$i]['onkeydown'])) |
362 | - || ($file && $parser->iNodeName == 'textarea')) |
|
363 | - $this->attribute[$i]['onkeyup'] = 'initTyper(this)'; |
|
362 | + || ($file && $parser->iNodeName == 'textarea')) { |
|
363 | + $this->attribute[$i]['onkeyup'] = 'initTyper(this)'; |
|
364 | + } |
|
364 | 365 | } |
365 | 366 | $i++; |
366 | 367 | } |
@@ -371,7 +372,9 @@ discard block |
||
371 | 372 | */ |
372 | 373 | function set($name,$attr, $value){ |
373 | 374 | $index = array_search($name, $this->field); |
374 | - if (!$index) return; |
|
375 | + if (!$index) { |
|
376 | + return; |
|
377 | + } |
|
375 | 378 | $this->attribute[$index][$attr] = $value; |
376 | 379 | } |
377 | 380 | |
@@ -380,8 +383,9 @@ discard block |
||
380 | 383 | */ |
381 | 384 | function get($name,$attr){ |
382 | 385 | $index = array_search($name, $this->field); |
383 | - if ($index && isset($this->attribute[$index][$attr])) |
|
384 | - return $this->attribute[$index][$attr]; |
|
386 | + if ($index && isset($this->attribute[$index][$attr])) { |
|
387 | + return $this->attribute[$index][$attr]; |
|
388 | + } |
|
385 | 389 | return ''; |
386 | 390 | } |
387 | 391 | |
@@ -401,12 +405,15 @@ discard block |
||
401 | 405 | $index = array_search($name, $this->field); |
402 | 406 | if ($index){ |
403 | 407 | $t = ''; |
404 | - if (isset($this->attribute[$index]['tabindex'])) |
|
405 | - $t .= ' tabindex='.$this->attribute[$index]['tabindex']; |
|
406 | - if (isset($this->attribute[$index]['size'])) |
|
407 | - $t .= ' size='.$this->attribute[$index]['size']; |
|
408 | - if (isset($this->attribute[$index]['maxlength'])) |
|
409 | - $t .= ' maxlength='.$this->attribute[$index]['maxlength']; |
|
408 | + if (isset($this->attribute[$index]['tabindex'])) { |
|
409 | + $t .= ' tabindex='.$this->attribute[$index]['tabindex']; |
|
410 | + } |
|
411 | + if (isset($this->attribute[$index]['size'])) { |
|
412 | + $t .= ' size='.$this->attribute[$index]['size']; |
|
413 | + } |
|
414 | + if (isset($this->attribute[$index]['maxlength'])) { |
|
415 | + $t .= ' maxlength='.$this->attribute[$index]['maxlength']; |
|
416 | + } |
|
410 | 417 | return $t; |
411 | 418 | } |
412 | 419 | return ''; |
@@ -417,7 +424,9 @@ discard block |
||
417 | 424 | */ |
418 | 425 | function replace($name,$text){ |
419 | 426 | $index = array_search($name, $this->field); |
420 | - if (!$index) return; |
|
427 | + if (!$index) { |
|
428 | + return; |
|
429 | + } |
|
421 | 430 | $this->removeIndex($index); |
422 | 431 | $this->type[$index] = NODE_TYPE_TEXT; |
423 | 432 | $this->value[$index] = $text; |
@@ -428,17 +437,27 @@ discard block |
||
428 | 437 | */ |
429 | 438 | function remove($name){ |
430 | 439 | $index = array_search($name, $this->field); |
431 | - if (!$index) return; |
|
432 | - if (!isset($this->name[$index])) return;//echo "Remove: $name <br>"; |
|
440 | + if (!$index) { |
|
441 | + return; |
|
442 | + } |
|
443 | + if (!isset($this->name[$index])) { |
|
444 | + return; |
|
445 | + } |
|
446 | + //echo "Remove: $name <br>"; |
|
433 | 447 | $rname = $this->name[$index]; |
434 | 448 | $len = count($this->name); |
435 | 449 | for ($end=$index+1;$end<$len;$end++){ |
436 | - if (isset($this->name[$end]) && $this->name[$end] == $rname) break; |
|
450 | + if (isset($this->name[$end]) && $this->name[$end] == $rname) { |
|
451 | + break; |
|
452 | + } |
|
437 | 453 | } |
438 | 454 | if (isset($this->type[$end]) && $this->type[$end]==NODE_TYPE_ENDELEMENT){ |
439 | - for ($i=$index;$i<=$end;$i++) $this->removeIndex($i); |
|
440 | - }else |
|
441 | - $this->removeIndex($index); |
|
455 | + for ($i=$index;$i<=$end;$i++) { |
|
456 | + $this->removeIndex($i); |
|
457 | + } |
|
458 | + } else { |
|
459 | + $this->removeIndex($index); |
|
460 | + } |
|
442 | 461 | } |
443 | 462 | |
444 | 463 | /** |
@@ -472,23 +491,27 @@ discard block |
||
472 | 491 | case NODE_TYPE_ELEMENT: |
473 | 492 | if ($name[$i] != 'textarea'){ |
474 | 493 | $str .= '<'.$name[$i]; |
475 | - if (isset($attr[$i])) foreach($attr[$i] as $key => $value){ |
|
494 | + if (isset($attr[$i])) { |
|
495 | + foreach($attr[$i] as $key => $value){ |
|
476 | 496 | if (array_search($value,$HTML_ATTRIBUTE_STAND_ALONE)!==false) |
477 | 497 | $str .= " $key"; |
478 | - else |
|
479 | - $str .= " $key=\"$value\""; |
|
498 | + } else { |
|
499 | + $str .= " $key=\"$value\""; |
|
500 | + } |
|
480 | 501 | } |
481 | 502 | $str .= '>'; |
482 | - }else{//is tag ATEXTAREA |
|
503 | + } else{//is tag ATEXTAREA |
|
483 | 504 | $content = ''; |
484 | 505 | $str .= '<'.$name[$i]; |
485 | - if (isset($attr[$i])) foreach($attr[$i] as $key => $value){ |
|
506 | + if (isset($attr[$i])) { |
|
507 | + foreach($attr[$i] as $key => $value){ |
|
486 | 508 | if ($key == 'value') |
487 | 509 | $content = $value; |
488 | - elseif (array_search($value,$HTML_ATTRIBUTE_STAND_ALONE)!==false) |
|
489 | - $str .= " $key"; |
|
490 | - else |
|
491 | - $str .= " $key=\"$value\""; |
|
510 | + } elseif (array_search($value,$HTML_ATTRIBUTE_STAND_ALONE)!==false) { |
|
511 | + $str .= " $key"; |
|
512 | + } else { |
|
513 | + $str .= " $key=\"$value\""; |
|
514 | + } |
|
492 | 515 | } |
493 | 516 | $str .= '>'.$content; |
494 | 517 | } |
@@ -522,7 +545,7 @@ discard block |
||
522 | 545 | $this->attribute[$i]['disabled'] = 1; |
523 | 546 | break; |
524 | 547 | } |
525 | - }elseif ($name == 'textarea'){ |
|
548 | + } elseif ($name == 'textarea'){ |
|
526 | 549 | $this->attribute[$i]['readonly'] = 'true'; |
527 | 550 | $this->attribute[$i]['style'] = 'border: 1 dotted #999999'; |
528 | 551 | } |
@@ -534,7 +557,9 @@ discard block |
||
534 | 557 | */ |
535 | 558 | function setReadonly($name){ |
536 | 559 | $index = array_search($name, $this->field); |
537 | - if (!$index) return; |
|
560 | + if (!$index) { |
|
561 | + return; |
|
562 | + } |
|
538 | 563 | $this->attribute[$index]['readonly'] = true; |
539 | 564 | $this->attribute[$index]['style'] = 'border: 1 dotted #999999'; |
540 | 565 | } |
@@ -5,17 +5,17 @@ discard block |
||
5 | 5 | * Author: vietcom (vncommando at yahoo dot com) |
6 | 6 | * Version: 1.0 |
7 | 7 | */ |
8 | -class Color{ |
|
8 | +class Color { |
|
9 | 9 | /** |
10 | 10 | * @desc Use only for function HSL2RGB() |
11 | 11 | */ |
12 | - function _HSL_2_RGB( $v1, $v2, $vH ){ |
|
13 | - if ( $vH < 0 ) $vH += 1; |
|
14 | - if ( $vH > 1 ) $vH -= 1; |
|
15 | - if ( ( 6 * $vH ) < 1 ) return ( $v1 + ( $v2 - $v1 ) * 6 * $vH ); |
|
16 | - if ( ( 2 * $vH ) < 1 ) return ( $v2 ); |
|
17 | - if ( ( 3 * $vH ) < 2 ) return ( $v1 + ( $v2 - $v1 ) * ( ( 2 / 3 ) - $vH ) * 6 ); |
|
18 | - return ( $v1 ); |
|
12 | + function _HSL_2_RGB($v1, $v2, $vH) { |
|
13 | + if ($vH < 0) $vH += 1; |
|
14 | + if ($vH > 1) $vH -= 1; |
|
15 | + if ((6 * $vH) < 1) return ($v1 + ($v2 - $v1) * 6 * $vH); |
|
16 | + if ((2 * $vH) < 1) return ($v2); |
|
17 | + if ((3 * $vH) < 2) return ($v1 + ($v2 - $v1) * ((2 / 3) - $vH) * 6); |
|
18 | + return ($v1); |
|
19 | 19 | } |
20 | 20 | /** |
21 | 21 | * @desc Convert HSL to RGB |
@@ -23,35 +23,35 @@ discard block |
||
23 | 23 | * RGB results = From 0 to 255 |
24 | 24 | * Code from http://www.easyrgb.com/math.php?MATH=M19#text19 |
25 | 25 | */ |
26 | - function HSL2RGB($H, $S, $L, &$R, &$G, &$B){ |
|
27 | - if ( $S == 0 ){ |
|
26 | + function HSL2RGB($H, $S, $L, &$R, &$G, &$B) { |
|
27 | + if ($S == 0) { |
|
28 | 28 | $R = $L * 255; |
29 | 29 | $G = $L * 255; |
30 | 30 | $B = $L * 255; |
31 | - }else{ |
|
32 | - $var_2 = ($L < 0.5)? ($L * ( 1 + $S )) : (( $L + $S ) - ( $S * $L )); |
|
31 | + }else { |
|
32 | + $var_2 = ($L < 0.5) ? ($L * (1 + $S)) : (($L + $S) - ($S * $L)); |
|
33 | 33 | $var_1 = 2 * $L - $var_2; |
34 | - $R = 255 * Color::_HSL_2_RGB( $var_1, $var_2, $H + ( 1 / 3 ) ) ; |
|
35 | - $G = 255 * Color::_HSL_2_RGB( $var_1, $var_2, $H ); |
|
36 | - $B = 255 * Color::_HSL_2_RGB( $var_1, $var_2, $H - ( 1 / 3 ) ); |
|
34 | + $R = 255 * Color::_HSL_2_RGB($var_1, $var_2, $H + (1 / 3)); |
|
35 | + $G = 255 * Color::_HSL_2_RGB($var_1, $var_2, $H); |
|
36 | + $B = 255 * Color::_HSL_2_RGB($var_1, $var_2, $H - (1 / 3)); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @desc Convert decimal color to #ffffff |
42 | 42 | */ |
43 | - function RGB2HEX($r, $g, $b){ |
|
44 | - $r = ($r<16)? '0'.dechex($r) : dechex($r); |
|
45 | - $g = ($g<16)? '0'.dechex($g) : dechex($g); |
|
46 | - $b = ($b<16)? '0'.dechex($b) : dechex($b); |
|
43 | + function RGB2HEX($r, $g, $b) { |
|
44 | + $r = ($r < 16) ? '0'.dechex($r) : dechex($r); |
|
45 | + $g = ($g < 16) ? '0'.dechex($g) : dechex($g); |
|
46 | + $b = ($b < 16) ? '0'.dechex($b) : dechex($b); |
|
47 | 47 | return "#$r$g$b"; |
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @desc Convert color #ffffff to RGB |
52 | 52 | */ |
53 | - function HEX2RGB($c){ |
|
54 | - if (strlen($c)!=7) return 0; |
|
53 | + function HEX2RGB($c) { |
|
54 | + if (strlen($c) != 7) return 0; |
|
55 | 55 | $r[] = hexdec($c{1}.$c{2}); |
56 | 56 | $r[] = hexdec($c{3}.$c{4}); |
57 | 57 | $r[] = hexdec($c{5}.$c{6}); |
@@ -61,21 +61,21 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * @desc Genereate an array of n colors differents |
63 | 63 | */ |
64 | - function getListColor($n){ |
|
64 | + function getListColor($n) { |
|
65 | 65 | $h = 0; |
66 | 66 | $s = 1; |
67 | 67 | $l = 0.6; |
68 | 68 | |
69 | - $d = 1/($n+1); |
|
70 | - $n2 = $n/2; |
|
71 | - $n3 = intval($n/3); |
|
69 | + $d = 1 / ($n + 1); |
|
70 | + $n2 = $n / 2; |
|
71 | + $n3 = intval($n / 3); |
|
72 | 72 | $c = 1; |
73 | - for ($i=0;$i<$n;$i++){ |
|
74 | - Color::HSL2RGB($h,$s,$l,$r,$g,$b); |
|
75 | - $color[] = Color::RGB2HEX($r,$g,$b); |
|
76 | - $h += 3*$d; |
|
77 | - if ($i % $n3==0){ |
|
78 | - $h = ($c++)*$d; |
|
73 | + for ($i = 0; $i < $n; $i++) { |
|
74 | + Color::HSL2RGB($h, $s, $l, $r, $g, $b); |
|
75 | + $color[] = Color::RGB2HEX($r, $g, $b); |
|
76 | + $h += 3 * $d; |
|
77 | + if ($i % $n3 == 0) { |
|
78 | + $h = ($c++) * $d; |
|
79 | 79 | $s -= 0.1; |
80 | 80 | $l -= 0.07; |
81 | 81 | } |
@@ -10,11 +10,21 @@ discard block |
||
10 | 10 | * @desc Use only for function HSL2RGB() |
11 | 11 | */ |
12 | 12 | function _HSL_2_RGB( $v1, $v2, $vH ){ |
13 | - if ( $vH < 0 ) $vH += 1; |
|
14 | - if ( $vH > 1 ) $vH -= 1; |
|
15 | - if ( ( 6 * $vH ) < 1 ) return ( $v1 + ( $v2 - $v1 ) * 6 * $vH ); |
|
16 | - if ( ( 2 * $vH ) < 1 ) return ( $v2 ); |
|
17 | - if ( ( 3 * $vH ) < 2 ) return ( $v1 + ( $v2 - $v1 ) * ( ( 2 / 3 ) - $vH ) * 6 ); |
|
13 | + if ( $vH < 0 ) { |
|
14 | + $vH += 1; |
|
15 | + } |
|
16 | + if ( $vH > 1 ) { |
|
17 | + $vH -= 1; |
|
18 | + } |
|
19 | + if ( ( 6 * $vH ) < 1 ) { |
|
20 | + return ( $v1 + ( $v2 - $v1 ) * 6 * $vH ); |
|
21 | + } |
|
22 | + if ( ( 2 * $vH ) < 1 ) { |
|
23 | + return ( $v2 ); |
|
24 | + } |
|
25 | + if ( ( 3 * $vH ) < 2 ) { |
|
26 | + return ( $v1 + ( $v2 - $v1 ) * ( ( 2 / 3 ) - $vH ) * 6 ); |
|
27 | + } |
|
18 | 28 | return ( $v1 ); |
19 | 29 | } |
20 | 30 | /** |
@@ -28,7 +38,7 @@ discard block |
||
28 | 38 | $R = $L * 255; |
29 | 39 | $G = $L * 255; |
30 | 40 | $B = $L * 255; |
31 | - }else{ |
|
41 | + } else{ |
|
32 | 42 | $var_2 = ($L < 0.5)? ($L * ( 1 + $S )) : (( $L + $S ) - ( $S * $L )); |
33 | 43 | $var_1 = 2 * $L - $var_2; |
34 | 44 | $R = 255 * Color::_HSL_2_RGB( $var_1, $var_2, $H + ( 1 / 3 ) ) ; |
@@ -51,7 +61,9 @@ discard block |
||
51 | 61 | * @desc Convert color #ffffff to RGB |
52 | 62 | */ |
53 | 63 | function HEX2RGB($c){ |
54 | - if (strlen($c)!=7) return 0; |
|
64 | + if (strlen($c)!=7) { |
|
65 | + return 0; |
|
66 | + } |
|
55 | 67 | $r[] = hexdec($c{1}.$c{2}); |
56 | 68 | $r[] = hexdec($c{3}.$c{4}); |
57 | 69 | $r[] = hexdec($c{5}.$c{6}); |
@@ -7,205 +7,205 @@ discard block |
||
7 | 7 | * Author: Olivier PLATHEY * |
8 | 8 | *******************************************************************************/ |
9 | 9 | |
10 | -define('FPDF_VERSION','1.6'); |
|
10 | +define('FPDF_VERSION', '1.6'); |
|
11 | 11 | |
12 | 12 | class FPDF |
13 | 13 | { |
14 | -var $page; //current page number |
|
15 | -var $n; //current object number |
|
16 | -var $offsets; //array of object offsets |
|
17 | -var $buffer; //buffer holding in-memory PDF |
|
18 | -var $pages; //array containing pages |
|
19 | -var $state; //current document state |
|
20 | -var $compress; //compression flag |
|
21 | -var $k; //scale factor (number of points in user unit) |
|
22 | -var $DefOrientation; //default orientation |
|
23 | -var $CurOrientation; //current orientation |
|
24 | -var $PageFormats; //available page formats |
|
25 | -var $DefPageFormat; //default page format |
|
26 | -var $CurPageFormat; //current page format |
|
27 | -var $PageSizes; //array storing non-default page sizes |
|
28 | -var $wPt,$hPt; //dimensions of current page in points |
|
29 | -var $w,$h; //dimensions of current page in user unit |
|
30 | -var $lMargin; //left margin |
|
31 | -var $tMargin; //top margin |
|
32 | -var $rMargin; //right margin |
|
33 | -var $bMargin; //page break margin |
|
34 | -var $cMargin; //cell margin |
|
35 | -var $x,$y; //current position in user unit |
|
36 | -var $lasth; //height of last printed cell |
|
37 | -var $LineWidth; //line width in user unit |
|
38 | -var $CoreFonts; //array of standard font names |
|
39 | -var $fonts; //array of used fonts |
|
40 | -var $FontFiles; //array of font files |
|
41 | -var $diffs; //array of encoding differences |
|
42 | -var $FontFamily; //current font family |
|
43 | -var $FontStyle; //current font style |
|
44 | -var $underline; //underlining flag |
|
45 | -var $CurrentFont; //current font info |
|
46 | -var $FontSizePt; //current font size in points |
|
47 | -var $FontSize; //current font size in user unit |
|
48 | -var $DrawColor; //commands for drawing color |
|
49 | -var $FillColor; //commands for filling color |
|
50 | -var $TextColor; //commands for text color |
|
51 | -var $ColorFlag; //indicates whether fill and text colors are different |
|
52 | -var $ws; //word spacing |
|
53 | -var $images; //array of used images |
|
54 | -var $PageLinks; //array of links in pages |
|
55 | -var $links; //array of internal links |
|
56 | -var $AutoPageBreak; //automatic page breaking |
|
57 | -var $PageBreakTrigger; //threshold used to trigger page breaks |
|
58 | -var $InHeader; //flag set when processing header |
|
59 | -var $InFooter; //flag set when processing footer |
|
60 | -var $ZoomMode; //zoom display mode |
|
61 | -var $LayoutMode; //layout display mode |
|
62 | -var $title; //title |
|
63 | -var $subject; //subject |
|
64 | -var $author; //author |
|
65 | -var $keywords; //keywords |
|
66 | -var $creator; //creator |
|
67 | -var $AliasNbPages; //alias for total number of pages |
|
68 | -var $PDFVersion; //PDF version number |
|
14 | +var $page; //current page number |
|
15 | +var $n; //current object number |
|
16 | +var $offsets; //array of object offsets |
|
17 | +var $buffer; //buffer holding in-memory PDF |
|
18 | +var $pages; //array containing pages |
|
19 | +var $state; //current document state |
|
20 | +var $compress; //compression flag |
|
21 | +var $k; //scale factor (number of points in user unit) |
|
22 | +var $DefOrientation; //default orientation |
|
23 | +var $CurOrientation; //current orientation |
|
24 | +var $PageFormats; //available page formats |
|
25 | +var $DefPageFormat; //default page format |
|
26 | +var $CurPageFormat; //current page format |
|
27 | +var $PageSizes; //array storing non-default page sizes |
|
28 | +var $wPt, $hPt; //dimensions of current page in points |
|
29 | +var $w, $h; //dimensions of current page in user unit |
|
30 | +var $lMargin; //left margin |
|
31 | +var $tMargin; //top margin |
|
32 | +var $rMargin; //right margin |
|
33 | +var $bMargin; //page break margin |
|
34 | +var $cMargin; //cell margin |
|
35 | +var $x, $y; //current position in user unit |
|
36 | +var $lasth; //height of last printed cell |
|
37 | +var $LineWidth; //line width in user unit |
|
38 | +var $CoreFonts; //array of standard font names |
|
39 | +var $fonts; //array of used fonts |
|
40 | +var $FontFiles; //array of font files |
|
41 | +var $diffs; //array of encoding differences |
|
42 | +var $FontFamily; //current font family |
|
43 | +var $FontStyle; //current font style |
|
44 | +var $underline; //underlining flag |
|
45 | +var $CurrentFont; //current font info |
|
46 | +var $FontSizePt; //current font size in points |
|
47 | +var $FontSize; //current font size in user unit |
|
48 | +var $DrawColor; //commands for drawing color |
|
49 | +var $FillColor; //commands for filling color |
|
50 | +var $TextColor; //commands for text color |
|
51 | +var $ColorFlag; //indicates whether fill and text colors are different |
|
52 | +var $ws; //word spacing |
|
53 | +var $images; //array of used images |
|
54 | +var $PageLinks; //array of links in pages |
|
55 | +var $links; //array of internal links |
|
56 | +var $AutoPageBreak; //automatic page breaking |
|
57 | +var $PageBreakTrigger; //threshold used to trigger page breaks |
|
58 | +var $InHeader; //flag set when processing header |
|
59 | +var $InFooter; //flag set when processing footer |
|
60 | +var $ZoomMode; //zoom display mode |
|
61 | +var $LayoutMode; //layout display mode |
|
62 | +var $title; //title |
|
63 | +var $subject; //subject |
|
64 | +var $author; //author |
|
65 | +var $keywords; //keywords |
|
66 | +var $creator; //creator |
|
67 | +var $AliasNbPages; //alias for total number of pages |
|
68 | +var $PDFVersion; //PDF version number |
|
69 | 69 | |
70 | 70 | /******************************************************************************* |
71 | 71 | * * |
72 | 72 | * Public methods * |
73 | 73 | * * |
74 | 74 | *******************************************************************************/ |
75 | -function FPDF($orientation='P', $unit='mm', $format='A4') |
|
75 | +function FPDF($orientation = 'P', $unit = 'mm', $format = 'A4') |
|
76 | 76 | { |
77 | 77 | //Some checks |
78 | 78 | $this->_dochecks(); |
79 | 79 | //Initialization of properties |
80 | - $this->page=0; |
|
81 | - $this->n=2; |
|
82 | - $this->buffer=''; |
|
83 | - $this->pages=array(); |
|
84 | - $this->PageSizes=array(); |
|
85 | - $this->state=0; |
|
86 | - $this->fonts=array(); |
|
87 | - $this->FontFiles=array(); |
|
88 | - $this->diffs=array(); |
|
89 | - $this->images=array(); |
|
90 | - $this->links=array(); |
|
91 | - $this->InHeader=false; |
|
92 | - $this->InFooter=false; |
|
93 | - $this->lasth=0; |
|
94 | - $this->FontFamily=''; |
|
95 | - $this->FontStyle=''; |
|
96 | - $this->FontSizePt=12; |
|
97 | - $this->underline=false; |
|
98 | - $this->DrawColor='0 G'; |
|
99 | - $this->FillColor='0 g'; |
|
100 | - $this->TextColor='0 g'; |
|
101 | - $this->ColorFlag=false; |
|
102 | - $this->ws=0; |
|
80 | + $this->page = 0; |
|
81 | + $this->n = 2; |
|
82 | + $this->buffer = ''; |
|
83 | + $this->pages = array(); |
|
84 | + $this->PageSizes = array(); |
|
85 | + $this->state = 0; |
|
86 | + $this->fonts = array(); |
|
87 | + $this->FontFiles = array(); |
|
88 | + $this->diffs = array(); |
|
89 | + $this->images = array(); |
|
90 | + $this->links = array(); |
|
91 | + $this->InHeader = false; |
|
92 | + $this->InFooter = false; |
|
93 | + $this->lasth = 0; |
|
94 | + $this->FontFamily = ''; |
|
95 | + $this->FontStyle = ''; |
|
96 | + $this->FontSizePt = 12; |
|
97 | + $this->underline = false; |
|
98 | + $this->DrawColor = '0 G'; |
|
99 | + $this->FillColor = '0 g'; |
|
100 | + $this->TextColor = '0 g'; |
|
101 | + $this->ColorFlag = false; |
|
102 | + $this->ws = 0; |
|
103 | 103 | //Standard fonts |
104 | - $this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique', |
|
104 | + $this->CoreFonts = array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique', |
|
105 | 105 | 'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique', |
106 | 106 | 'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic', |
107 | 107 | 'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats'); |
108 | 108 | //Scale factor |
109 | - if($unit=='pt') |
|
110 | - $this->k=1; |
|
111 | - elseif($unit=='mm') |
|
112 | - $this->k=72/25.4; |
|
113 | - elseif($unit=='cm') |
|
114 | - $this->k=72/2.54; |
|
115 | - elseif($unit=='in') |
|
116 | - $this->k=72; |
|
109 | + if ($unit == 'pt') |
|
110 | + $this->k = 1; |
|
111 | + elseif ($unit == 'mm') |
|
112 | + $this->k = 72 / 25.4; |
|
113 | + elseif ($unit == 'cm') |
|
114 | + $this->k = 72 / 2.54; |
|
115 | + elseif ($unit == 'in') |
|
116 | + $this->k = 72; |
|
117 | 117 | else |
118 | 118 | $this->Error('Incorrect unit: '.$unit); |
119 | 119 | //Page format |
120 | - $this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), |
|
121 | - 'letter'=>array(612,792), 'legal'=>array(612,1008)); |
|
122 | - if(is_string($format)) |
|
123 | - $format=$this->_getpageformat($format); |
|
124 | - $this->DefPageFormat=$format; |
|
125 | - $this->CurPageFormat=$format; |
|
120 | + $this->PageFormats = array('a3'=>array(841.89, 1190.55), 'a4'=>array(595.28, 841.89), 'a5'=>array(420.94, 595.28), |
|
121 | + 'letter'=>array(612, 792), 'legal'=>array(612, 1008)); |
|
122 | + if (is_string($format)) |
|
123 | + $format = $this->_getpageformat($format); |
|
124 | + $this->DefPageFormat = $format; |
|
125 | + $this->CurPageFormat = $format; |
|
126 | 126 | //Page orientation |
127 | - $orientation=strtolower($orientation); |
|
128 | - if($orientation=='p' || $orientation=='portrait') |
|
127 | + $orientation = strtolower($orientation); |
|
128 | + if ($orientation == 'p' || $orientation == 'portrait') |
|
129 | 129 | { |
130 | - $this->DefOrientation='P'; |
|
131 | - $this->w=$this->DefPageFormat[0]; |
|
132 | - $this->h=$this->DefPageFormat[1]; |
|
130 | + $this->DefOrientation = 'P'; |
|
131 | + $this->w = $this->DefPageFormat[0]; |
|
132 | + $this->h = $this->DefPageFormat[1]; |
|
133 | 133 | } |
134 | - elseif($orientation=='l' || $orientation=='landscape') |
|
134 | + elseif ($orientation == 'l' || $orientation == 'landscape') |
|
135 | 135 | { |
136 | - $this->DefOrientation='L'; |
|
137 | - $this->w=$this->DefPageFormat[1]; |
|
138 | - $this->h=$this->DefPageFormat[0]; |
|
136 | + $this->DefOrientation = 'L'; |
|
137 | + $this->w = $this->DefPageFormat[1]; |
|
138 | + $this->h = $this->DefPageFormat[0]; |
|
139 | 139 | } |
140 | 140 | else |
141 | 141 | $this->Error('Incorrect orientation: '.$orientation); |
142 | - $this->CurOrientation=$this->DefOrientation; |
|
143 | - $this->wPt=$this->w*$this->k; |
|
144 | - $this->hPt=$this->h*$this->k; |
|
142 | + $this->CurOrientation = $this->DefOrientation; |
|
143 | + $this->wPt = $this->w * $this->k; |
|
144 | + $this->hPt = $this->h * $this->k; |
|
145 | 145 | //Page margins (1 cm) |
146 | - $margin=28.35/$this->k; |
|
147 | - $this->SetMargins($margin,$margin); |
|
146 | + $margin = 28.35 / $this->k; |
|
147 | + $this->SetMargins($margin, $margin); |
|
148 | 148 | //Interior cell margin (1 mm) |
149 | - $this->cMargin=$margin/10; |
|
149 | + $this->cMargin = $margin / 10; |
|
150 | 150 | //Line width (0.2 mm) |
151 | - $this->LineWidth=.567/$this->k; |
|
151 | + $this->LineWidth = .567 / $this->k; |
|
152 | 152 | //Automatic page break |
153 | - $this->SetAutoPageBreak(true,2*$margin); |
|
153 | + $this->SetAutoPageBreak(true, 2 * $margin); |
|
154 | 154 | //Full width display mode |
155 | 155 | $this->SetDisplayMode('fullwidth'); |
156 | 156 | //Enable compression |
157 | 157 | $this->SetCompression(true); |
158 | 158 | //Set default PDF version number |
159 | - $this->PDFVersion='1.3'; |
|
159 | + $this->PDFVersion = '1.3'; |
|
160 | 160 | } |
161 | 161 | |
162 | -function SetMargins($left, $top, $right=null) |
|
162 | +function SetMargins($left, $top, $right = null) |
|
163 | 163 | { |
164 | 164 | //Set left, top and right margins |
165 | - $this->lMargin=$left; |
|
166 | - $this->tMargin=$top; |
|
167 | - if($right===null) |
|
168 | - $right=$left; |
|
169 | - $this->rMargin=$right; |
|
165 | + $this->lMargin = $left; |
|
166 | + $this->tMargin = $top; |
|
167 | + if ($right === null) |
|
168 | + $right = $left; |
|
169 | + $this->rMargin = $right; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | function SetLeftMargin($margin) |
173 | 173 | { |
174 | 174 | //Set left margin |
175 | - $this->lMargin=$margin; |
|
176 | - if($this->page>0 && $this->x<$margin) |
|
177 | - $this->x=$margin; |
|
175 | + $this->lMargin = $margin; |
|
176 | + if ($this->page > 0 && $this->x < $margin) |
|
177 | + $this->x = $margin; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | function SetTopMargin($margin) |
181 | 181 | { |
182 | 182 | //Set top margin |
183 | - $this->tMargin=$margin; |
|
183 | + $this->tMargin = $margin; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | function SetRightMargin($margin) |
187 | 187 | { |
188 | 188 | //Set right margin |
189 | - $this->rMargin=$margin; |
|
189 | + $this->rMargin = $margin; |
|
190 | 190 | } |
191 | 191 | |
192 | -function SetAutoPageBreak($auto, $margin=0) |
|
192 | +function SetAutoPageBreak($auto, $margin = 0) |
|
193 | 193 | { |
194 | 194 | //Set auto page break mode and triggering margin |
195 | - $this->AutoPageBreak=$auto; |
|
196 | - $this->bMargin=$margin; |
|
197 | - $this->PageBreakTrigger=$this->h-$margin; |
|
195 | + $this->AutoPageBreak = $auto; |
|
196 | + $this->bMargin = $margin; |
|
197 | + $this->PageBreakTrigger = $this->h - $margin; |
|
198 | 198 | } |
199 | 199 | |
200 | -function SetDisplayMode($zoom, $layout='continuous') |
|
200 | +function SetDisplayMode($zoom, $layout = 'continuous') |
|
201 | 201 | { |
202 | 202 | //Set display mode in viewer |
203 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
204 | - $this->ZoomMode=$zoom; |
|
203 | + if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom)) |
|
204 | + $this->ZoomMode = $zoom; |
|
205 | 205 | else |
206 | 206 | $this->Error('Incorrect zoom display mode: '.$zoom); |
207 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
208 | - $this->LayoutMode=$layout; |
|
207 | + if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default') |
|
208 | + $this->LayoutMode = $layout; |
|
209 | 209 | else |
210 | 210 | $this->Error('Incorrect layout display mode: '.$layout); |
211 | 211 | } |
@@ -213,56 +213,56 @@ discard block |
||
213 | 213 | function SetCompression($compress) |
214 | 214 | { |
215 | 215 | //Set page compression |
216 | - if(function_exists('gzcompress')) |
|
217 | - $this->compress=$compress; |
|
216 | + if (function_exists('gzcompress')) |
|
217 | + $this->compress = $compress; |
|
218 | 218 | else |
219 | - $this->compress=false; |
|
219 | + $this->compress = false; |
|
220 | 220 | } |
221 | 221 | |
222 | -function SetTitle($title, $isUTF8=false) |
|
222 | +function SetTitle($title, $isUTF8 = false) |
|
223 | 223 | { |
224 | 224 | //Title of document |
225 | - if($isUTF8) |
|
226 | - $title=$this->_UTF8toUTF16($title); |
|
227 | - $this->title=$title; |
|
225 | + if ($isUTF8) |
|
226 | + $title = $this->_UTF8toUTF16($title); |
|
227 | + $this->title = $title; |
|
228 | 228 | } |
229 | 229 | |
230 | -function SetSubject($subject, $isUTF8=false) |
|
230 | +function SetSubject($subject, $isUTF8 = false) |
|
231 | 231 | { |
232 | 232 | //Subject of document |
233 | - if($isUTF8) |
|
234 | - $subject=$this->_UTF8toUTF16($subject); |
|
235 | - $this->subject=$subject; |
|
233 | + if ($isUTF8) |
|
234 | + $subject = $this->_UTF8toUTF16($subject); |
|
235 | + $this->subject = $subject; |
|
236 | 236 | } |
237 | 237 | |
238 | -function SetAuthor($author, $isUTF8=false) |
|
238 | +function SetAuthor($author, $isUTF8 = false) |
|
239 | 239 | { |
240 | 240 | //Author of document |
241 | - if($isUTF8) |
|
242 | - $author=$this->_UTF8toUTF16($author); |
|
243 | - $this->author=$author; |
|
241 | + if ($isUTF8) |
|
242 | + $author = $this->_UTF8toUTF16($author); |
|
243 | + $this->author = $author; |
|
244 | 244 | } |
245 | 245 | |
246 | -function SetKeywords($keywords, $isUTF8=false) |
|
246 | +function SetKeywords($keywords, $isUTF8 = false) |
|
247 | 247 | { |
248 | 248 | //Keywords of document |
249 | - if($isUTF8) |
|
250 | - $keywords=$this->_UTF8toUTF16($keywords); |
|
251 | - $this->keywords=$keywords; |
|
249 | + if ($isUTF8) |
|
250 | + $keywords = $this->_UTF8toUTF16($keywords); |
|
251 | + $this->keywords = $keywords; |
|
252 | 252 | } |
253 | 253 | |
254 | -function SetCreator($creator, $isUTF8=false) |
|
254 | +function SetCreator($creator, $isUTF8 = false) |
|
255 | 255 | { |
256 | 256 | //Creator of document |
257 | - if($isUTF8) |
|
258 | - $creator=$this->_UTF8toUTF16($creator); |
|
259 | - $this->creator=$creator; |
|
257 | + if ($isUTF8) |
|
258 | + $creator = $this->_UTF8toUTF16($creator); |
|
259 | + $this->creator = $creator; |
|
260 | 260 | } |
261 | 261 | |
262 | -function AliasNbPages($alias='{nb}') |
|
262 | +function AliasNbPages($alias = '{nb}') |
|
263 | 263 | { |
264 | 264 | //Define an alias for total number of pages |
265 | - $this->AliasNbPages=$alias; |
|
265 | + $this->AliasNbPages = $alias; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | function Error($msg) |
@@ -274,93 +274,93 @@ discard block |
||
274 | 274 | function Open() |
275 | 275 | { |
276 | 276 | //Begin document |
277 | - $this->state=1; |
|
277 | + $this->state = 1; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | function Close() |
281 | 281 | { |
282 | 282 | //Terminate document |
283 | - if($this->state==3) |
|
283 | + if ($this->state == 3) |
|
284 | 284 | return; |
285 | - if($this->page==0) |
|
285 | + if ($this->page == 0) |
|
286 | 286 | $this->AddPage(); |
287 | 287 | //Page footer |
288 | - $this->InFooter=true; |
|
288 | + $this->InFooter = true; |
|
289 | 289 | $this->Footer(); |
290 | - $this->InFooter=false; |
|
290 | + $this->InFooter = false; |
|
291 | 291 | //Close page |
292 | 292 | $this->_endpage(); |
293 | 293 | //Close document |
294 | 294 | $this->_enddoc(); |
295 | 295 | } |
296 | 296 | |
297 | -function AddPage($orientation='', $format='') |
|
297 | +function AddPage($orientation = '', $format = '') |
|
298 | 298 | { |
299 | 299 | //Start a new page |
300 | - if($this->state==0) |
|
300 | + if ($this->state == 0) |
|
301 | 301 | $this->Open(); |
302 | - $family=$this->FontFamily; |
|
303 | - $style=$this->FontStyle.($this->underline ? 'U' : ''); |
|
304 | - $size=$this->FontSizePt; |
|
305 | - $lw=$this->LineWidth; |
|
306 | - $dc=$this->DrawColor; |
|
307 | - $fc=$this->FillColor; |
|
308 | - $tc=$this->TextColor; |
|
309 | - $cf=$this->ColorFlag; |
|
310 | - if($this->page>0) |
|
302 | + $family = $this->FontFamily; |
|
303 | + $style = $this->FontStyle.($this->underline ? 'U' : ''); |
|
304 | + $size = $this->FontSizePt; |
|
305 | + $lw = $this->LineWidth; |
|
306 | + $dc = $this->DrawColor; |
|
307 | + $fc = $this->FillColor; |
|
308 | + $tc = $this->TextColor; |
|
309 | + $cf = $this->ColorFlag; |
|
310 | + if ($this->page > 0) |
|
311 | 311 | { |
312 | 312 | //Page footer |
313 | - $this->InFooter=true; |
|
313 | + $this->InFooter = true; |
|
314 | 314 | $this->Footer(); |
315 | - $this->InFooter=false; |
|
315 | + $this->InFooter = false; |
|
316 | 316 | //Close page |
317 | 317 | $this->_endpage(); |
318 | 318 | } |
319 | 319 | //Start new page |
320 | - $this->_beginpage($orientation,$format); |
|
320 | + $this->_beginpage($orientation, $format); |
|
321 | 321 | //Set line cap style to square |
322 | 322 | $this->_out('2 J'); |
323 | 323 | //Set line width |
324 | - $this->LineWidth=$lw; |
|
325 | - $this->_out(sprintf('%.2F w',$lw*$this->k)); |
|
324 | + $this->LineWidth = $lw; |
|
325 | + $this->_out(sprintf('%.2F w', $lw * $this->k)); |
|
326 | 326 | //Set font |
327 | - if($family) |
|
328 | - $this->SetFont($family,$style,$size); |
|
327 | + if ($family) |
|
328 | + $this->SetFont($family, $style, $size); |
|
329 | 329 | //Set colors |
330 | - $this->DrawColor=$dc; |
|
331 | - if($dc!='0 G') |
|
330 | + $this->DrawColor = $dc; |
|
331 | + if ($dc != '0 G') |
|
332 | 332 | $this->_out($dc); |
333 | - $this->FillColor=$fc; |
|
334 | - if($fc!='0 g') |
|
333 | + $this->FillColor = $fc; |
|
334 | + if ($fc != '0 g') |
|
335 | 335 | $this->_out($fc); |
336 | - $this->TextColor=$tc; |
|
337 | - $this->ColorFlag=$cf; |
|
336 | + $this->TextColor = $tc; |
|
337 | + $this->ColorFlag = $cf; |
|
338 | 338 | //Page header |
339 | - $this->InHeader=true; |
|
339 | + $this->InHeader = true; |
|
340 | 340 | $this->Header(); |
341 | - $this->InHeader=false; |
|
341 | + $this->InHeader = false; |
|
342 | 342 | //Restore line width |
343 | - if($this->LineWidth!=$lw) |
|
343 | + if ($this->LineWidth != $lw) |
|
344 | 344 | { |
345 | - $this->LineWidth=$lw; |
|
346 | - $this->_out(sprintf('%.2F w',$lw*$this->k)); |
|
345 | + $this->LineWidth = $lw; |
|
346 | + $this->_out(sprintf('%.2F w', $lw * $this->k)); |
|
347 | 347 | } |
348 | 348 | //Restore font |
349 | - if($family) |
|
350 | - $this->SetFont($family,$style,$size); |
|
349 | + if ($family) |
|
350 | + $this->SetFont($family, $style, $size); |
|
351 | 351 | //Restore colors |
352 | - if($this->DrawColor!=$dc) |
|
352 | + if ($this->DrawColor != $dc) |
|
353 | 353 | { |
354 | - $this->DrawColor=$dc; |
|
354 | + $this->DrawColor = $dc; |
|
355 | 355 | $this->_out($dc); |
356 | 356 | } |
357 | - if($this->FillColor!=$fc) |
|
357 | + if ($this->FillColor != $fc) |
|
358 | 358 | { |
359 | - $this->FillColor=$fc; |
|
359 | + $this->FillColor = $fc; |
|
360 | 360 | $this->_out($fc); |
361 | 361 | } |
362 | - $this->TextColor=$tc; |
|
363 | - $this->ColorFlag=$cf; |
|
362 | + $this->TextColor = $tc; |
|
363 | + $this->ColorFlag = $cf; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | function Header() |
@@ -379,230 +379,230 @@ discard block |
||
379 | 379 | return $this->page; |
380 | 380 | } |
381 | 381 | |
382 | -function SetDrawColor($r, $g=null, $b=null) |
|
382 | +function SetDrawColor($r, $g = null, $b = null) |
|
383 | 383 | { |
384 | 384 | //Set color for all stroking operations |
385 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
386 | - $this->DrawColor=sprintf('%.3F G',$r/255); |
|
385 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
386 | + $this->DrawColor = sprintf('%.3F G', $r / 255); |
|
387 | 387 | else |
388 | - $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
389 | - if($this->page>0) |
|
388 | + $this->DrawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255); |
|
389 | + if ($this->page > 0) |
|
390 | 390 | $this->_out($this->DrawColor); |
391 | 391 | } |
392 | 392 | |
393 | -function SetFillColor($r, $g=null, $b=null) |
|
393 | +function SetFillColor($r, $g = null, $b = null) |
|
394 | 394 | { |
395 | 395 | //Set color for all filling operations |
396 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
397 | - $this->FillColor=sprintf('%.3F g',$r/255); |
|
396 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
397 | + $this->FillColor = sprintf('%.3F g', $r / 255); |
|
398 | 398 | else |
399 | - $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
400 | - $this->ColorFlag=($this->FillColor!=$this->TextColor); |
|
401 | - if($this->page>0) |
|
399 | + $this->FillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255); |
|
400 | + $this->ColorFlag = ($this->FillColor != $this->TextColor); |
|
401 | + if ($this->page > 0) |
|
402 | 402 | $this->_out($this->FillColor); |
403 | 403 | } |
404 | 404 | |
405 | -function SetTextColor($r, $g=null, $b=null) |
|
405 | +function SetTextColor($r, $g = null, $b = null) |
|
406 | 406 | { |
407 | 407 | //Set color for text |
408 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
409 | - $this->TextColor=sprintf('%.3F g',$r/255); |
|
408 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
409 | + $this->TextColor = sprintf('%.3F g', $r / 255); |
|
410 | 410 | else |
411 | - $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
412 | - $this->ColorFlag=($this->FillColor!=$this->TextColor); |
|
411 | + $this->TextColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255); |
|
412 | + $this->ColorFlag = ($this->FillColor != $this->TextColor); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | function GetStringWidth($s) |
416 | 416 | { |
417 | 417 | //Get width of a string in the current font |
418 | - $s=(string)$s; |
|
419 | - $cw=&$this->CurrentFont['cw']; |
|
420 | - $w=0; |
|
421 | - $l=strlen($s); |
|
422 | - for($i=0;$i<$l;$i++) |
|
423 | - $w+=$cw[$s[$i]]; |
|
424 | - return $w*$this->FontSize/1000; |
|
418 | + $s = (string) $s; |
|
419 | + $cw = &$this->CurrentFont['cw']; |
|
420 | + $w = 0; |
|
421 | + $l = strlen($s); |
|
422 | + for ($i = 0; $i < $l; $i++) |
|
423 | + $w += $cw[$s[$i]]; |
|
424 | + return $w * $this->FontSize / 1000; |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | function SetLineWidth($width) |
428 | 428 | { |
429 | 429 | //Set line width |
430 | - $this->LineWidth=$width; |
|
431 | - if($this->page>0) |
|
432 | - $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
430 | + $this->LineWidth = $width; |
|
431 | + if ($this->page > 0) |
|
432 | + $this->_out(sprintf('%.2F w', $width * $this->k)); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | function Line($x1, $y1, $x2, $y2) |
436 | 436 | { |
437 | 437 | //Draw a line |
438 | - $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)); |
|
438 | + $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)); |
|
439 | 439 | } |
440 | 440 | |
441 | -function Rect($x, $y, $w, $h, $style='') |
|
441 | +function Rect($x, $y, $w, $h, $style = '') |
|
442 | 442 | { |
443 | 443 | //Draw a rectangle |
444 | - if($style=='F') |
|
445 | - $op='f'; |
|
446 | - elseif($style=='FD' || $style=='DF') |
|
447 | - $op='B'; |
|
444 | + if ($style == 'F') |
|
445 | + $op = 'f'; |
|
446 | + elseif ($style == 'FD' || $style == 'DF') |
|
447 | + $op = 'B'; |
|
448 | 448 | else |
449 | - $op='S'; |
|
450 | - $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); |
|
449 | + $op = 'S'; |
|
450 | + $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s', $x * $this->k, ($this->h - $y) * $this->k, $w * $this->k, -$h * $this->k, $op)); |
|
451 | 451 | } |
452 | 452 | |
453 | -function AddFont($family, $style='', $file='') |
|
453 | +function AddFont($family, $style = '', $file = '') |
|
454 | 454 | { |
455 | 455 | //Add a TrueType or Type1 font |
456 | - $family=strtolower($family); |
|
457 | - if($file=='') |
|
458 | - $file=str_replace(' ','',$family).strtolower($style).'.php'; |
|
459 | - if($family=='arial') |
|
460 | - $family='helvetica'; |
|
461 | - $style=strtoupper($style); |
|
462 | - if($style=='IB') |
|
463 | - $style='BI'; |
|
464 | - $fontkey=$family.$style; |
|
465 | - if(isset($this->fonts[$fontkey])) |
|
456 | + $family = strtolower($family); |
|
457 | + if ($file == '') |
|
458 | + $file = str_replace(' ', '', $family).strtolower($style).'.php'; |
|
459 | + if ($family == 'arial') |
|
460 | + $family = 'helvetica'; |
|
461 | + $style = strtoupper($style); |
|
462 | + if ($style == 'IB') |
|
463 | + $style = 'BI'; |
|
464 | + $fontkey = $family.$style; |
|
465 | + if (isset($this->fonts[$fontkey])) |
|
466 | 466 | return; |
467 | 467 | include($this->_getfontpath().$file); |
468 | - if(!isset($name)) |
|
468 | + if (!isset($name)) |
|
469 | 469 | $this->Error('Could not include font definition file'); |
470 | - $i=count($this->fonts)+1; |
|
471 | - $this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file); |
|
472 | - if($diff) |
|
470 | + $i = count($this->fonts) + 1; |
|
471 | + $this->fonts[$fontkey] = array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file); |
|
472 | + if ($diff) |
|
473 | 473 | { |
474 | 474 | //Search existing encodings |
475 | - $d=0; |
|
476 | - $nb=count($this->diffs); |
|
477 | - for($i=1;$i<=$nb;$i++) |
|
475 | + $d = 0; |
|
476 | + $nb = count($this->diffs); |
|
477 | + for ($i = 1; $i <= $nb; $i++) |
|
478 | 478 | { |
479 | - if($this->diffs[$i]==$diff) |
|
479 | + if ($this->diffs[$i] == $diff) |
|
480 | 480 | { |
481 | - $d=$i; |
|
481 | + $d = $i; |
|
482 | 482 | break; |
483 | 483 | } |
484 | 484 | } |
485 | - if($d==0) |
|
485 | + if ($d == 0) |
|
486 | 486 | { |
487 | - $d=$nb+1; |
|
488 | - $this->diffs[$d]=$diff; |
|
487 | + $d = $nb + 1; |
|
488 | + $this->diffs[$d] = $diff; |
|
489 | 489 | } |
490 | - $this->fonts[$fontkey]['diff']=$d; |
|
490 | + $this->fonts[$fontkey]['diff'] = $d; |
|
491 | 491 | } |
492 | - if($file) |
|
492 | + if ($file) |
|
493 | 493 | { |
494 | - if($type=='TrueType') |
|
495 | - $this->FontFiles[$file]=array('length1'=>$originalsize); |
|
494 | + if ($type == 'TrueType') |
|
495 | + $this->FontFiles[$file] = array('length1'=>$originalsize); |
|
496 | 496 | else |
497 | - $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2); |
|
497 | + $this->FontFiles[$file] = array('length1'=>$size1, 'length2'=>$size2); |
|
498 | 498 | } |
499 | 499 | } |
500 | 500 | |
501 | -function SetFont($family, $style='', $size=0) |
|
501 | +function SetFont($family, $style = '', $size = 0) |
|
502 | 502 | { |
503 | 503 | //Select a font; size given in points |
504 | 504 | global $fpdf_charwidths; |
505 | 505 | |
506 | - $family=strtolower($family); |
|
507 | - if($family=='') |
|
508 | - $family=$this->FontFamily; |
|
509 | - if($family=='arial') |
|
510 | - $family='helvetica'; |
|
511 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
512 | - $style=''; |
|
513 | - $style=strtoupper($style); |
|
514 | - if(strpos($style,'U')!==false) |
|
506 | + $family = strtolower($family); |
|
507 | + if ($family == '') |
|
508 | + $family = $this->FontFamily; |
|
509 | + if ($family == 'arial') |
|
510 | + $family = 'helvetica'; |
|
511 | + elseif ($family == 'symbol' || $family == 'zapfdingbats') |
|
512 | + $style = ''; |
|
513 | + $style = strtoupper($style); |
|
514 | + if (strpos($style, 'U') !== false) |
|
515 | 515 | { |
516 | - $this->underline=true; |
|
517 | - $style=str_replace('U','',$style); |
|
516 | + $this->underline = true; |
|
517 | + $style = str_replace('U', '', $style); |
|
518 | 518 | } |
519 | 519 | else |
520 | - $this->underline=false; |
|
521 | - if($style=='IB') |
|
522 | - $style='BI'; |
|
523 | - if($size==0) |
|
524 | - $size=$this->FontSizePt; |
|
520 | + $this->underline = false; |
|
521 | + if ($style == 'IB') |
|
522 | + $style = 'BI'; |
|
523 | + if ($size == 0) |
|
524 | + $size = $this->FontSizePt; |
|
525 | 525 | //Test if font is already selected |
526 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
526 | + if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size) |
|
527 | 527 | return; |
528 | 528 | //Test if used for the first time |
529 | - $fontkey=$family.$style; |
|
530 | - if(!isset($this->fonts[$fontkey])) |
|
529 | + $fontkey = $family.$style; |
|
530 | + if (!isset($this->fonts[$fontkey])) |
|
531 | 531 | { |
532 | 532 | //Check if one of the standard fonts |
533 | - if(isset($this->CoreFonts[$fontkey])) |
|
533 | + if (isset($this->CoreFonts[$fontkey])) |
|
534 | 534 | { |
535 | - if(!isset($fpdf_charwidths[$fontkey])) |
|
535 | + if (!isset($fpdf_charwidths[$fontkey])) |
|
536 | 536 | { |
537 | 537 | //Load metric file |
538 | - $file=$family; |
|
539 | - if($family=='times' || $family=='helvetica') |
|
540 | - $file.=strtolower($style); |
|
538 | + $file = $family; |
|
539 | + if ($family == 'times' || $family == 'helvetica') |
|
540 | + $file .= strtolower($style); |
|
541 | 541 | include($this->_getfontpath().$file.'.php'); |
542 | - if(!isset($fpdf_charwidths[$fontkey])) |
|
542 | + if (!isset($fpdf_charwidths[$fontkey])) |
|
543 | 543 | $this->Error('Could not include font metric file'); |
544 | 544 | } |
545 | - $i=count($this->fonts)+1; |
|
546 | - $name=$this->CoreFonts[$fontkey]; |
|
547 | - $cw=$fpdf_charwidths[$fontkey]; |
|
548 | - $this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw); |
|
545 | + $i = count($this->fonts) + 1; |
|
546 | + $name = $this->CoreFonts[$fontkey]; |
|
547 | + $cw = $fpdf_charwidths[$fontkey]; |
|
548 | + $this->fonts[$fontkey] = array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw); |
|
549 | 549 | } |
550 | 550 | else |
551 | 551 | $this->Error('Undefined font: '.$family.' '.$style); |
552 | 552 | } |
553 | 553 | //Select it |
554 | - $this->FontFamily=$family; |
|
555 | - $this->FontStyle=$style; |
|
556 | - $this->FontSizePt=$size; |
|
557 | - $this->FontSize=$size/$this->k; |
|
558 | - $this->CurrentFont=&$this->fonts[$fontkey]; |
|
559 | - if($this->page>0) |
|
560 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
554 | + $this->FontFamily = $family; |
|
555 | + $this->FontStyle = $style; |
|
556 | + $this->FontSizePt = $size; |
|
557 | + $this->FontSize = $size / $this->k; |
|
558 | + $this->CurrentFont = &$this->fonts[$fontkey]; |
|
559 | + if ($this->page > 0) |
|
560 | + $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | function SetFontSize($size) |
564 | 564 | { |
565 | 565 | //Set font size in points |
566 | - if($this->FontSizePt==$size) |
|
566 | + if ($this->FontSizePt == $size) |
|
567 | 567 | return; |
568 | - $this->FontSizePt=$size; |
|
569 | - $this->FontSize=$size/$this->k; |
|
570 | - if($this->page>0) |
|
571 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
568 | + $this->FontSizePt = $size; |
|
569 | + $this->FontSize = $size / $this->k; |
|
570 | + if ($this->page > 0) |
|
571 | + $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | function AddLink() |
575 | 575 | { |
576 | 576 | //Create a new internal link |
577 | - $n=count($this->links)+1; |
|
578 | - $this->links[$n]=array(0, 0); |
|
577 | + $n = count($this->links) + 1; |
|
578 | + $this->links[$n] = array(0, 0); |
|
579 | 579 | return $n; |
580 | 580 | } |
581 | 581 | |
582 | -function SetLink($link, $y=0, $page=-1) |
|
582 | +function SetLink($link, $y = 0, $page = -1) |
|
583 | 583 | { |
584 | 584 | //Set destination of internal link |
585 | - if($y==-1) |
|
586 | - $y=$this->y; |
|
587 | - if($page==-1) |
|
588 | - $page=$this->page; |
|
589 | - $this->links[$link]=array($page, $y); |
|
585 | + if ($y == -1) |
|
586 | + $y = $this->y; |
|
587 | + if ($page == -1) |
|
588 | + $page = $this->page; |
|
589 | + $this->links[$link] = array($page, $y); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | function Link($x, $y, $w, $h, $link) |
593 | 593 | { |
594 | 594 | //Put a link on the page |
595 | - $this->PageLinks[$this->page][]=array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link); |
|
595 | + $this->PageLinks[$this->page][] = array($x * $this->k, $this->hPt - $y * $this->k, $w * $this->k, $h * $this->k, $link); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | function Text($x, $y, $txt) |
599 | 599 | { |
600 | 600 | //Output a string |
601 | - $s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); |
|
602 | - if($this->underline && $txt!='') |
|
603 | - $s.=' '.$this->_dounderline($x,$y,$txt); |
|
604 | - if($this->ColorFlag) |
|
605 | - $s='q '.$this->TextColor.' '.$s.' Q'; |
|
601 | + $s = sprintf('BT %.2F %.2F Td (%s) Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $this->_escape($txt)); |
|
602 | + if ($this->underline && $txt != '') |
|
603 | + $s .= ' '.$this->_dounderline($x, $y, $txt); |
|
604 | + if ($this->ColorFlag) |
|
605 | + $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
606 | 606 | $this->_out($s); |
607 | 607 | } |
608 | 608 | |
@@ -612,268 +612,268 @@ discard block |
||
612 | 612 | return $this->AutoPageBreak; |
613 | 613 | } |
614 | 614 | |
615 | -function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') |
|
615 | +function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '') |
|
616 | 616 | { |
617 | 617 | //Output a cell |
618 | - $k=$this->k; |
|
619 | - if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
618 | + $k = $this->k; |
|
619 | + if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
620 | 620 | { |
621 | 621 | //Automatic page break |
622 | - $x=$this->x; |
|
623 | - $ws=$this->ws; |
|
624 | - if($ws>0) |
|
622 | + $x = $this->x; |
|
623 | + $ws = $this->ws; |
|
624 | + if ($ws > 0) |
|
625 | 625 | { |
626 | - $this->ws=0; |
|
626 | + $this->ws = 0; |
|
627 | 627 | $this->_out('0 Tw'); |
628 | 628 | } |
629 | - $this->AddPage($this->CurOrientation,$this->CurPageFormat); |
|
630 | - $this->x=$x; |
|
631 | - if($ws>0) |
|
629 | + $this->AddPage($this->CurOrientation, $this->CurPageFormat); |
|
630 | + $this->x = $x; |
|
631 | + if ($ws > 0) |
|
632 | 632 | { |
633 | - $this->ws=$ws; |
|
634 | - $this->_out(sprintf('%.3F Tw',$ws*$k)); |
|
633 | + $this->ws = $ws; |
|
634 | + $this->_out(sprintf('%.3F Tw', $ws * $k)); |
|
635 | 635 | } |
636 | 636 | } |
637 | - if($w==0) |
|
638 | - $w=$this->w-$this->rMargin-$this->x; |
|
639 | - $s=''; |
|
640 | - if($fill || $border==1) |
|
637 | + if ($w == 0) |
|
638 | + $w = $this->w - $this->rMargin - $this->x; |
|
639 | + $s = ''; |
|
640 | + if ($fill || $border == 1) |
|
641 | 641 | { |
642 | - if($fill) |
|
643 | - $op=($border==1) ? 'B' : 'f'; |
|
642 | + if ($fill) |
|
643 | + $op = ($border == 1) ? 'B' : 'f'; |
|
644 | 644 | else |
645 | - $op='S'; |
|
646 | - $s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
|
645 | + $op = 'S'; |
|
646 | + $s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op); |
|
647 | 647 | } |
648 | - if(is_string($border)) |
|
648 | + if (is_string($border)) |
|
649 | 649 | { |
650 | - $x=$this->x; |
|
651 | - $y=$this->y; |
|
652 | - if(strpos($border,'L')!==false) |
|
653 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
654 | - if(strpos($border,'T')!==false) |
|
655 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
656 | - if(strpos($border,'R')!==false) |
|
657 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
658 | - if(strpos($border,'B')!==false) |
|
659 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
650 | + $x = $this->x; |
|
651 | + $y = $this->y; |
|
652 | + if (strpos($border, 'L') !== false) |
|
653 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k); |
|
654 | + if (strpos($border, 'T') !== false) |
|
655 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k); |
|
656 | + if (strpos($border, 'R') !== false) |
|
657 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); |
|
658 | + if (strpos($border, 'B') !== false) |
|
659 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); |
|
660 | 660 | } |
661 | - if($txt!=='') |
|
661 | + if ($txt !== '') |
|
662 | 662 | { |
663 | - if($align=='R') |
|
664 | - $dx=$w-$this->cMargin-$this->GetStringWidth($txt); |
|
665 | - elseif($align=='C') |
|
666 | - $dx=($w-$this->GetStringWidth($txt))/2; |
|
663 | + if ($align == 'R') |
|
664 | + $dx = $w - $this->cMargin - $this->GetStringWidth($txt); |
|
665 | + elseif ($align == 'C') |
|
666 | + $dx = ($w - $this->GetStringWidth($txt)) / 2; |
|
667 | 667 | else |
668 | - $dx=$this->cMargin; |
|
669 | - if($this->ColorFlag) |
|
670 | - $s.='q '.$this->TextColor.' '; |
|
671 | - $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); |
|
672 | - $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); |
|
673 | - if($this->underline) |
|
674 | - $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
675 | - if($this->ColorFlag) |
|
676 | - $s.=' Q'; |
|
677 | - if($link) |
|
678 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
668 | + $dx = $this->cMargin; |
|
669 | + if ($this->ColorFlag) |
|
670 | + $s .= 'q '.$this->TextColor.' '; |
|
671 | + $txt2 = str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt))); |
|
672 | + $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $txt2); |
|
673 | + if ($this->underline) |
|
674 | + $s .= ' '.$this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt); |
|
675 | + if ($this->ColorFlag) |
|
676 | + $s .= ' Q'; |
|
677 | + if ($link) |
|
678 | + $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link); |
|
679 | 679 | } |
680 | - if($s) |
|
680 | + if ($s) |
|
681 | 681 | $this->_out($s); |
682 | - $this->lasth=$h; |
|
683 | - if($ln>0) |
|
682 | + $this->lasth = $h; |
|
683 | + if ($ln > 0) |
|
684 | 684 | { |
685 | 685 | //Go to next line |
686 | - $this->y+=$h; |
|
687 | - if($ln==1) |
|
688 | - $this->x=$this->lMargin; |
|
686 | + $this->y += $h; |
|
687 | + if ($ln == 1) |
|
688 | + $this->x = $this->lMargin; |
|
689 | 689 | } |
690 | 690 | else |
691 | - $this->x+=$w; |
|
691 | + $this->x += $w; |
|
692 | 692 | } |
693 | 693 | |
694 | -function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) |
|
694 | +function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false) |
|
695 | 695 | { |
696 | 696 | //Output text with automatic or explicit line breaks |
697 | - $cw=&$this->CurrentFont['cw']; |
|
698 | - if($w==0) |
|
699 | - $w=$this->w-$this->rMargin-$this->x; |
|
700 | - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
701 | - $s=str_replace("\r",'',$txt); |
|
702 | - $nb=strlen($s); |
|
703 | - if($nb>0 && $s[$nb-1]=="\n") |
|
697 | + $cw = &$this->CurrentFont['cw']; |
|
698 | + if ($w == 0) |
|
699 | + $w = $this->w - $this->rMargin - $this->x; |
|
700 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
701 | + $s = str_replace("\r", '', $txt); |
|
702 | + $nb = strlen($s); |
|
703 | + if ($nb > 0 && $s[$nb - 1] == "\n") |
|
704 | 704 | $nb--; |
705 | - $b=0; |
|
706 | - if($border) |
|
705 | + $b = 0; |
|
706 | + if ($border) |
|
707 | 707 | { |
708 | - if($border==1) |
|
708 | + if ($border == 1) |
|
709 | 709 | { |
710 | - $border='LTRB'; |
|
711 | - $b='LRT'; |
|
712 | - $b2='LR'; |
|
710 | + $border = 'LTRB'; |
|
711 | + $b = 'LRT'; |
|
712 | + $b2 = 'LR'; |
|
713 | 713 | } |
714 | 714 | else |
715 | 715 | { |
716 | - $b2=''; |
|
717 | - if(strpos($border,'L')!==false) |
|
718 | - $b2.='L'; |
|
719 | - if(strpos($border,'R')!==false) |
|
720 | - $b2.='R'; |
|
721 | - $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2; |
|
716 | + $b2 = ''; |
|
717 | + if (strpos($border, 'L') !== false) |
|
718 | + $b2 .= 'L'; |
|
719 | + if (strpos($border, 'R') !== false) |
|
720 | + $b2 .= 'R'; |
|
721 | + $b = (strpos($border, 'T') !== false) ? $b2.'T' : $b2; |
|
722 | 722 | } |
723 | 723 | } |
724 | - $sep=-1; |
|
725 | - $i=0; |
|
726 | - $j=0; |
|
727 | - $l=0; |
|
728 | - $ns=0; |
|
729 | - $nl=1; |
|
730 | - while($i<$nb) |
|
724 | + $sep = -1; |
|
725 | + $i = 0; |
|
726 | + $j = 0; |
|
727 | + $l = 0; |
|
728 | + $ns = 0; |
|
729 | + $nl = 1; |
|
730 | + while ($i < $nb) |
|
731 | 731 | { |
732 | 732 | //Get next character |
733 | - $c=$s[$i]; |
|
734 | - if($c=="\n") |
|
733 | + $c = $s[$i]; |
|
734 | + if ($c == "\n") |
|
735 | 735 | { |
736 | 736 | //Explicit line break |
737 | - if($this->ws>0) |
|
737 | + if ($this->ws > 0) |
|
738 | 738 | { |
739 | - $this->ws=0; |
|
739 | + $this->ws = 0; |
|
740 | 740 | $this->_out('0 Tw'); |
741 | 741 | } |
742 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
742 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
743 | 743 | $i++; |
744 | - $sep=-1; |
|
745 | - $j=$i; |
|
746 | - $l=0; |
|
747 | - $ns=0; |
|
744 | + $sep = -1; |
|
745 | + $j = $i; |
|
746 | + $l = 0; |
|
747 | + $ns = 0; |
|
748 | 748 | $nl++; |
749 | - if($border && $nl==2) |
|
750 | - $b=$b2; |
|
749 | + if ($border && $nl == 2) |
|
750 | + $b = $b2; |
|
751 | 751 | continue; |
752 | 752 | } |
753 | - if($c==' ') |
|
753 | + if ($c == ' ') |
|
754 | 754 | { |
755 | - $sep=$i; |
|
756 | - $ls=$l; |
|
755 | + $sep = $i; |
|
756 | + $ls = $l; |
|
757 | 757 | $ns++; |
758 | 758 | } |
759 | - $l+=$cw[$c]; |
|
760 | - if($l>$wmax) |
|
759 | + $l += $cw[$c]; |
|
760 | + if ($l > $wmax) |
|
761 | 761 | { |
762 | 762 | //Automatic line break |
763 | - if($sep==-1) |
|
763 | + if ($sep == -1) |
|
764 | 764 | { |
765 | - if($i==$j) |
|
765 | + if ($i == $j) |
|
766 | 766 | $i++; |
767 | - if($this->ws>0) |
|
767 | + if ($this->ws > 0) |
|
768 | 768 | { |
769 | - $this->ws=0; |
|
769 | + $this->ws = 0; |
|
770 | 770 | $this->_out('0 Tw'); |
771 | 771 | } |
772 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
772 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
773 | 773 | } |
774 | 774 | else |
775 | 775 | { |
776 | - if($align=='J') |
|
776 | + if ($align == 'J') |
|
777 | 777 | { |
778 | - $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; |
|
779 | - $this->_out(sprintf('%.3F Tw',$this->ws*$this->k)); |
|
778 | + $this->ws = ($ns > 1) ? ($wmax - $ls) / 1000 * $this->FontSize / ($ns - 1) : 0; |
|
779 | + $this->_out(sprintf('%.3F Tw', $this->ws * $this->k)); |
|
780 | 780 | } |
781 | - $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); |
|
782 | - $i=$sep+1; |
|
781 | + $this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill); |
|
782 | + $i = $sep + 1; |
|
783 | 783 | } |
784 | - $sep=-1; |
|
785 | - $j=$i; |
|
786 | - $l=0; |
|
787 | - $ns=0; |
|
784 | + $sep = -1; |
|
785 | + $j = $i; |
|
786 | + $l = 0; |
|
787 | + $ns = 0; |
|
788 | 788 | $nl++; |
789 | - if($border && $nl==2) |
|
790 | - $b=$b2; |
|
789 | + if ($border && $nl == 2) |
|
790 | + $b = $b2; |
|
791 | 791 | } |
792 | 792 | else |
793 | 793 | $i++; |
794 | 794 | } |
795 | 795 | //Last chunk |
796 | - if($this->ws>0) |
|
796 | + if ($this->ws > 0) |
|
797 | 797 | { |
798 | - $this->ws=0; |
|
798 | + $this->ws = 0; |
|
799 | 799 | $this->_out('0 Tw'); |
800 | 800 | } |
801 | - if($border && strpos($border,'B')!==false) |
|
802 | - $b.='B'; |
|
803 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
804 | - $this->x=$this->lMargin; |
|
801 | + if ($border && strpos($border, 'B') !== false) |
|
802 | + $b .= 'B'; |
|
803 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
804 | + $this->x = $this->lMargin; |
|
805 | 805 | } |
806 | 806 | |
807 | -function Write($h, $txt, $link='') |
|
807 | +function Write($h, $txt, $link = '') |
|
808 | 808 | { |
809 | 809 | //Output text in flowing mode |
810 | - $cw=&$this->CurrentFont['cw']; |
|
811 | - $w=$this->w-$this->rMargin-$this->x; |
|
812 | - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
813 | - $s=str_replace("\r",'',$txt); |
|
814 | - $nb=strlen($s); |
|
815 | - $sep=-1; |
|
816 | - $i=0; |
|
817 | - $j=0; |
|
818 | - $l=0; |
|
819 | - $nl=1; |
|
820 | - while($i<$nb) |
|
810 | + $cw = &$this->CurrentFont['cw']; |
|
811 | + $w = $this->w - $this->rMargin - $this->x; |
|
812 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
813 | + $s = str_replace("\r", '', $txt); |
|
814 | + $nb = strlen($s); |
|
815 | + $sep = -1; |
|
816 | + $i = 0; |
|
817 | + $j = 0; |
|
818 | + $l = 0; |
|
819 | + $nl = 1; |
|
820 | + while ($i < $nb) |
|
821 | 821 | { |
822 | 822 | //Get next character |
823 | - $c=$s[$i]; |
|
824 | - if($c=="\n") |
|
823 | + $c = $s[$i]; |
|
824 | + if ($c == "\n") |
|
825 | 825 | { |
826 | 826 | //Explicit line break |
827 | - $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
|
827 | + $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link); |
|
828 | 828 | $i++; |
829 | - $sep=-1; |
|
830 | - $j=$i; |
|
831 | - $l=0; |
|
832 | - if($nl==1) |
|
829 | + $sep = -1; |
|
830 | + $j = $i; |
|
831 | + $l = 0; |
|
832 | + if ($nl == 1) |
|
833 | 833 | { |
834 | - $this->x=$this->lMargin; |
|
835 | - $w=$this->w-$this->rMargin-$this->x; |
|
836 | - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
834 | + $this->x = $this->lMargin; |
|
835 | + $w = $this->w - $this->rMargin - $this->x; |
|
836 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
837 | 837 | } |
838 | 838 | $nl++; |
839 | 839 | continue; |
840 | 840 | } |
841 | - if($c==' ') |
|
842 | - $sep=$i; |
|
843 | - $l+=$cw[$c]; |
|
844 | - if($l>$wmax) |
|
841 | + if ($c == ' ') |
|
842 | + $sep = $i; |
|
843 | + $l += $cw[$c]; |
|
844 | + if ($l > $wmax) |
|
845 | 845 | { |
846 | 846 | //Automatic line break |
847 | - if($sep==-1) |
|
847 | + if ($sep == -1) |
|
848 | 848 | { |
849 | - if($this->x>$this->lMargin) |
|
849 | + if ($this->x > $this->lMargin) |
|
850 | 850 | { |
851 | 851 | //Move to next line |
852 | - $this->x=$this->lMargin; |
|
853 | - $this->y+=$h; |
|
854 | - $w=$this->w-$this->rMargin-$this->x; |
|
855 | - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
852 | + $this->x = $this->lMargin; |
|
853 | + $this->y += $h; |
|
854 | + $w = $this->w - $this->rMargin - $this->x; |
|
855 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
856 | 856 | $i++; |
857 | 857 | $nl++; |
858 | 858 | continue; |
859 | 859 | } |
860 | - if($i==$j) |
|
860 | + if ($i == $j) |
|
861 | 861 | $i++; |
862 | - $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
|
862 | + $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link); |
|
863 | 863 | } |
864 | 864 | else |
865 | 865 | { |
866 | - $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); |
|
867 | - $i=$sep+1; |
|
866 | + $this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', 0, $link); |
|
867 | + $i = $sep + 1; |
|
868 | 868 | } |
869 | - $sep=-1; |
|
870 | - $j=$i; |
|
871 | - $l=0; |
|
872 | - if($nl==1) |
|
869 | + $sep = -1; |
|
870 | + $j = $i; |
|
871 | + $l = 0; |
|
872 | + if ($nl == 1) |
|
873 | 873 | { |
874 | - $this->x=$this->lMargin; |
|
875 | - $w=$this->w-$this->rMargin-$this->x; |
|
876 | - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
|
874 | + $this->x = $this->lMargin; |
|
875 | + $w = $this->w - $this->rMargin - $this->x; |
|
876 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
877 | 877 | } |
878 | 878 | $nl++; |
879 | 879 | } |
@@ -881,74 +881,74 @@ discard block |
||
881 | 881 | $i++; |
882 | 882 | } |
883 | 883 | //Last chunk |
884 | - if($i!=$j) |
|
885 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); |
|
884 | + if ($i != $j) |
|
885 | + $this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', 0, $link); |
|
886 | 886 | } |
887 | 887 | |
888 | -function Ln($h=null) |
|
888 | +function Ln($h = null) |
|
889 | 889 | { |
890 | 890 | //Line feed; default value is last cell height |
891 | - $this->x=$this->lMargin; |
|
892 | - if($h===null) |
|
893 | - $this->y+=$this->lasth; |
|
891 | + $this->x = $this->lMargin; |
|
892 | + if ($h === null) |
|
893 | + $this->y += $this->lasth; |
|
894 | 894 | else |
895 | - $this->y+=$h; |
|
895 | + $this->y += $h; |
|
896 | 896 | } |
897 | 897 | |
898 | -function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') |
|
898 | +function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '') |
|
899 | 899 | { |
900 | 900 | //Put an image on the page |
901 | - if(!isset($this->images[$file])) |
|
901 | + if (!isset($this->images[$file])) |
|
902 | 902 | { |
903 | 903 | //First use of this image, get info |
904 | - if($type=='') |
|
904 | + if ($type == '') |
|
905 | 905 | { |
906 | - $pos=strrpos($file,'.'); |
|
907 | - if(!$pos) |
|
906 | + $pos = strrpos($file, '.'); |
|
907 | + if (!$pos) |
|
908 | 908 | $this->Error('Image file has no extension and no type was specified: '.$file); |
909 | - $type=substr($file,$pos+1); |
|
909 | + $type = substr($file, $pos + 1); |
|
910 | 910 | } |
911 | - $type=strtolower($type); |
|
912 | - if($type=='jpeg') |
|
913 | - $type='jpg'; |
|
914 | - $mtd='_parse'.$type; |
|
915 | - if(!method_exists($this,$mtd)) |
|
911 | + $type = strtolower($type); |
|
912 | + if ($type == 'jpeg') |
|
913 | + $type = 'jpg'; |
|
914 | + $mtd = '_parse'.$type; |
|
915 | + if (!method_exists($this, $mtd)) |
|
916 | 916 | $this->Error('Unsupported image type: '.$type); |
917 | - $info=$this->$mtd($file); |
|
918 | - $info['i']=count($this->images)+1; |
|
919 | - $this->images[$file]=$info; |
|
917 | + $info = $this->$mtd($file); |
|
918 | + $info['i'] = count($this->images) + 1; |
|
919 | + $this->images[$file] = $info; |
|
920 | 920 | } |
921 | 921 | else |
922 | - $info=$this->images[$file]; |
|
922 | + $info = $this->images[$file]; |
|
923 | 923 | //Automatic width and height calculation if needed |
924 | - if($w==0 && $h==0) |
|
924 | + if ($w == 0 && $h == 0) |
|
925 | 925 | { |
926 | 926 | //Put image at 72 dpi |
927 | - $w=$info['w']/$this->k; |
|
928 | - $h=$info['h']/$this->k; |
|
927 | + $w = $info['w'] / $this->k; |
|
928 | + $h = $info['h'] / $this->k; |
|
929 | 929 | } |
930 | - elseif($w==0) |
|
931 | - $w=$h*$info['w']/$info['h']; |
|
932 | - elseif($h==0) |
|
933 | - $h=$w*$info['h']/$info['w']; |
|
930 | + elseif ($w == 0) |
|
931 | + $w = $h * $info['w'] / $info['h']; |
|
932 | + elseif ($h == 0) |
|
933 | + $h = $w * $info['h'] / $info['w']; |
|
934 | 934 | //Flowing mode |
935 | - if($y===null) |
|
935 | + if ($y === null) |
|
936 | 936 | { |
937 | - if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
937 | + if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
938 | 938 | { |
939 | 939 | //Automatic page break |
940 | - $x2=$this->x; |
|
941 | - $this->AddPage($this->CurOrientation,$this->CurPageFormat); |
|
942 | - $this->x=$x2; |
|
940 | + $x2 = $this->x; |
|
941 | + $this->AddPage($this->CurOrientation, $this->CurPageFormat); |
|
942 | + $this->x = $x2; |
|
943 | 943 | } |
944 | - $y=$this->y; |
|
945 | - $this->y+=$h; |
|
944 | + $y = $this->y; |
|
945 | + $this->y += $h; |
|
946 | 946 | } |
947 | - if($x===null) |
|
948 | - $x=$this->x; |
|
949 | - $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'])); |
|
950 | - if($link) |
|
951 | - $this->Link($x,$y,$w,$h,$link); |
|
947 | + if ($x === null) |
|
948 | + $x = $this->x; |
|
949 | + $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'])); |
|
950 | + if ($link) |
|
951 | + $this->Link($x, $y, $w, $h, $link); |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | function GetX() |
@@ -960,10 +960,10 @@ discard block |
||
960 | 960 | function SetX($x) |
961 | 961 | { |
962 | 962 | //Set x position |
963 | - if($x>=0) |
|
964 | - $this->x=$x; |
|
963 | + if ($x >= 0) |
|
964 | + $this->x = $x; |
|
965 | 965 | else |
966 | - $this->x=$this->w+$x; |
|
966 | + $this->x = $this->w + $x; |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | function GetY() |
@@ -975,11 +975,11 @@ discard block |
||
975 | 975 | function SetY($y) |
976 | 976 | { |
977 | 977 | //Set y position and reset x |
978 | - $this->x=$this->lMargin; |
|
979 | - if($y>=0) |
|
980 | - $this->y=$y; |
|
978 | + $this->x = $this->lMargin; |
|
979 | + if ($y >= 0) |
|
980 | + $this->y = $y; |
|
981 | 981 | else |
982 | - $this->y=$this->h+$y; |
|
982 | + $this->y = $this->h + $y; |
|
983 | 983 | } |
984 | 984 | |
985 | 985 | function SetXY($x, $y) |
@@ -989,62 +989,62 @@ discard block |
||
989 | 989 | $this->SetX($x); |
990 | 990 | } |
991 | 991 | |
992 | -function Output($name='', $dest='') |
|
992 | +function Output($name = '', $dest = '') |
|
993 | 993 | { |
994 | 994 | //Output PDF to some destination |
995 | - if($this->state<3) |
|
995 | + if ($this->state < 3) |
|
996 | 996 | $this->Close(); |
997 | - $dest=strtoupper($dest); |
|
998 | - if($dest=='') |
|
997 | + $dest = strtoupper($dest); |
|
998 | + if ($dest == '') |
|
999 | 999 | { |
1000 | - if($name=='') |
|
1000 | + if ($name == '') |
|
1001 | 1001 | { |
1002 | - $name='doc.pdf'; |
|
1003 | - $dest='I'; |
|
1002 | + $name = 'doc.pdf'; |
|
1003 | + $dest = 'I'; |
|
1004 | 1004 | } |
1005 | 1005 | else |
1006 | - $dest='F'; |
|
1006 | + $dest = 'F'; |
|
1007 | 1007 | } |
1008 | - switch($dest) |
|
1008 | + switch ($dest) |
|
1009 | 1009 | { |
1010 | 1010 | case 'I': |
1011 | 1011 | //Send to standard output |
1012 | - if(ob_get_length()) |
|
1012 | + if (ob_get_length()) |
|
1013 | 1013 | $this->Error('Some data has already been output, can\'t send PDF file'); |
1014 | - if(php_sapi_name()!='cli') |
|
1014 | + if (php_sapi_name() != 'cli') |
|
1015 | 1015 | { |
1016 | 1016 | //We send to a browser |
1017 | 1017 | header('Content-Type: application/pdf'); |
1018 | - if(headers_sent()) |
|
1018 | + if (headers_sent()) |
|
1019 | 1019 | $this->Error('Some data has already been output, can\'t send PDF file'); |
1020 | 1020 | header('Content-Length: '.strlen($this->buffer)); |
1021 | 1021 | header('Content-Disposition: inline; filename="'.$name.'"'); |
1022 | 1022 | header('Cache-Control: private, max-age=0, must-revalidate'); |
1023 | 1023 | header('Pragma: public'); |
1024 | - ini_set('zlib.output_compression','0'); |
|
1024 | + ini_set('zlib.output_compression', '0'); |
|
1025 | 1025 | } |
1026 | 1026 | echo $this->buffer; |
1027 | 1027 | break; |
1028 | 1028 | case 'D': |
1029 | 1029 | //Download file |
1030 | - if(ob_get_length()) |
|
1030 | + if (ob_get_length()) |
|
1031 | 1031 | $this->Error('Some data has already been output, can\'t send PDF file'); |
1032 | 1032 | header('Content-Type: application/x-download'); |
1033 | - if(headers_sent()) |
|
1033 | + if (headers_sent()) |
|
1034 | 1034 | $this->Error('Some data has already been output, can\'t send PDF file'); |
1035 | 1035 | header('Content-Length: '.strlen($this->buffer)); |
1036 | 1036 | header('Content-Disposition: attachment; filename="'.$name.'"'); |
1037 | 1037 | header('Cache-Control: private, max-age=0, must-revalidate'); |
1038 | 1038 | header('Pragma: public'); |
1039 | - ini_set('zlib.output_compression','0'); |
|
1039 | + ini_set('zlib.output_compression', '0'); |
|
1040 | 1040 | echo $this->buffer; |
1041 | 1041 | break; |
1042 | 1042 | case 'F': |
1043 | 1043 | //Save to local file |
1044 | - $f=fopen($name,'wb'); |
|
1045 | - if(!$f) |
|
1044 | + $f = fopen($name, 'wb'); |
|
1045 | + if (!$f) |
|
1046 | 1046 | $this->Error('Unable to create output file: '.$name); |
1047 | - fwrite($f,$this->buffer,strlen($this->buffer)); |
|
1047 | + fwrite($f, $this->buffer, strlen($this->buffer)); |
|
1048 | 1048 | fclose($f); |
1049 | 1049 | break; |
1050 | 1050 | case 'S': |
@@ -1064,87 +1064,87 @@ discard block |
||
1064 | 1064 | function _dochecks() |
1065 | 1065 | { |
1066 | 1066 | //Check availability of %F |
1067 | - if(sprintf('%.1F',1.0)!='1.0') |
|
1067 | + if (sprintf('%.1F', 1.0) != '1.0') |
|
1068 | 1068 | $this->Error('This version of PHP is not supported'); |
1069 | 1069 | //Check mbstring overloading |
1070 | - if(ini_get('mbstring.func_overload') & 2) |
|
1070 | + if (ini_get('mbstring.func_overload') & 2) |
|
1071 | 1071 | $this->Error('mbstring overloading must be disabled'); |
1072 | 1072 | //Disable runtime magic quotes |
1073 | - if(get_magic_quotes_runtime()) |
|
1073 | + if (get_magic_quotes_runtime()) |
|
1074 | 1074 | @set_magic_quotes_runtime(0); |
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | function _getpageformat($format) |
1078 | 1078 | { |
1079 | - $format=strtolower($format); |
|
1080 | - if(!isset($this->PageFormats[$format])) |
|
1079 | + $format = strtolower($format); |
|
1080 | + if (!isset($this->PageFormats[$format])) |
|
1081 | 1081 | $this->Error('Unknown page format: '.$format); |
1082 | - $a=$this->PageFormats[$format]; |
|
1083 | - return array($a[0]/$this->k, $a[1]/$this->k); |
|
1082 | + $a = $this->PageFormats[$format]; |
|
1083 | + return array($a[0] / $this->k, $a[1] / $this->k); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | function _getfontpath() |
1087 | 1087 | { |
1088 | - if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) |
|
1089 | - define('FPDF_FONTPATH',dirname(__FILE__).'/font/'); |
|
1088 | + if (!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) |
|
1089 | + define('FPDF_FONTPATH', dirname(__FILE__).'/font/'); |
|
1090 | 1090 | return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : ''; |
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | function _beginpage($orientation, $format) |
1094 | 1094 | { |
1095 | 1095 | $this->page++; |
1096 | - $this->pages[$this->page]=''; |
|
1097 | - $this->state=2; |
|
1098 | - $this->x=$this->lMargin; |
|
1099 | - $this->y=$this->tMargin; |
|
1100 | - $this->FontFamily=''; |
|
1096 | + $this->pages[$this->page] = ''; |
|
1097 | + $this->state = 2; |
|
1098 | + $this->x = $this->lMargin; |
|
1099 | + $this->y = $this->tMargin; |
|
1100 | + $this->FontFamily = ''; |
|
1101 | 1101 | //Check page size |
1102 | - if($orientation=='') |
|
1103 | - $orientation=$this->DefOrientation; |
|
1102 | + if ($orientation == '') |
|
1103 | + $orientation = $this->DefOrientation; |
|
1104 | 1104 | else |
1105 | - $orientation=strtoupper($orientation[0]); |
|
1106 | - if($format=='') |
|
1107 | - $format=$this->DefPageFormat; |
|
1105 | + $orientation = strtoupper($orientation[0]); |
|
1106 | + if ($format == '') |
|
1107 | + $format = $this->DefPageFormat; |
|
1108 | 1108 | else |
1109 | 1109 | { |
1110 | - if(is_string($format)) |
|
1111 | - $format=$this->_getpageformat($format); |
|
1110 | + if (is_string($format)) |
|
1111 | + $format = $this->_getpageformat($format); |
|
1112 | 1112 | } |
1113 | - if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) |
|
1113 | + if ($orientation != $this->CurOrientation || $format[0] != $this->CurPageFormat[0] || $format[1] != $this->CurPageFormat[1]) |
|
1114 | 1114 | { |
1115 | 1115 | //New size |
1116 | - if($orientation=='P') |
|
1116 | + if ($orientation == 'P') |
|
1117 | 1117 | { |
1118 | - $this->w=$format[0]; |
|
1119 | - $this->h=$format[1]; |
|
1118 | + $this->w = $format[0]; |
|
1119 | + $this->h = $format[1]; |
|
1120 | 1120 | } |
1121 | 1121 | else |
1122 | 1122 | { |
1123 | - $this->w=$format[1]; |
|
1124 | - $this->h=$format[0]; |
|
1123 | + $this->w = $format[1]; |
|
1124 | + $this->h = $format[0]; |
|
1125 | 1125 | } |
1126 | - $this->wPt=$this->w*$this->k; |
|
1127 | - $this->hPt=$this->h*$this->k; |
|
1128 | - $this->PageBreakTrigger=$this->h-$this->bMargin; |
|
1129 | - $this->CurOrientation=$orientation; |
|
1130 | - $this->CurPageFormat=$format; |
|
1126 | + $this->wPt = $this->w * $this->k; |
|
1127 | + $this->hPt = $this->h * $this->k; |
|
1128 | + $this->PageBreakTrigger = $this->h - $this->bMargin; |
|
1129 | + $this->CurOrientation = $orientation; |
|
1130 | + $this->CurPageFormat = $format; |
|
1131 | 1131 | } |
1132 | - if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) |
|
1133 | - $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); |
|
1132 | + if ($orientation != $this->DefOrientation || $format[0] != $this->DefPageFormat[0] || $format[1] != $this->DefPageFormat[1]) |
|
1133 | + $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | function _endpage() |
1137 | 1137 | { |
1138 | - $this->state=1; |
|
1138 | + $this->state = 1; |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | function _escape($s) |
1142 | 1142 | { |
1143 | 1143 | //Escape special characters in strings |
1144 | - $s=str_replace('\\','\\\\',$s); |
|
1145 | - $s=str_replace('(','\\(',$s); |
|
1146 | - $s=str_replace(')','\\)',$s); |
|
1147 | - $s=str_replace("\r",'\\r',$s); |
|
1144 | + $s = str_replace('\\', '\\\\', $s); |
|
1145 | + $s = str_replace('(', '\\(', $s); |
|
1146 | + $s = str_replace(')', '\\)', $s); |
|
1147 | + $s = str_replace("\r", '\\r', $s); |
|
1148 | 1148 | return $s; |
1149 | 1149 | } |
1150 | 1150 | |
@@ -1157,31 +1157,31 @@ discard block |
||
1157 | 1157 | function _UTF8toUTF16($s) |
1158 | 1158 | { |
1159 | 1159 | //Convert UTF-8 to UTF-16BE with BOM |
1160 | - $res="\xFE\xFF"; |
|
1161 | - $nb=strlen($s); |
|
1162 | - $i=0; |
|
1163 | - while($i<$nb) |
|
1160 | + $res = "\xFE\xFF"; |
|
1161 | + $nb = strlen($s); |
|
1162 | + $i = 0; |
|
1163 | + while ($i < $nb) |
|
1164 | 1164 | { |
1165 | - $c1=ord($s[$i++]); |
|
1166 | - if($c1>=224) |
|
1165 | + $c1 = ord($s[$i++]); |
|
1166 | + if ($c1 >= 224) |
|
1167 | 1167 | { |
1168 | 1168 | //3-byte character |
1169 | - $c2=ord($s[$i++]); |
|
1170 | - $c3=ord($s[$i++]); |
|
1171 | - $res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
|
1172 | - $res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
|
1169 | + $c2 = ord($s[$i++]); |
|
1170 | + $c3 = ord($s[$i++]); |
|
1171 | + $res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2)); |
|
1172 | + $res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F)); |
|
1173 | 1173 | } |
1174 | - elseif($c1>=192) |
|
1174 | + elseif ($c1 >= 192) |
|
1175 | 1175 | { |
1176 | 1176 | //2-byte character |
1177 | - $c2=ord($s[$i++]); |
|
1178 | - $res.=chr(($c1 & 0x1C)>>2); |
|
1179 | - $res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
|
1177 | + $c2 = ord($s[$i++]); |
|
1178 | + $res .= chr(($c1 & 0x1C) >> 2); |
|
1179 | + $res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F)); |
|
1180 | 1180 | } |
1181 | 1181 | else |
1182 | 1182 | { |
1183 | 1183 | //Single-byte character |
1184 | - $res.="\0".chr($c1); |
|
1184 | + $res .= "\0".chr($c1); |
|
1185 | 1185 | } |
1186 | 1186 | } |
1187 | 1187 | return $res; |
@@ -1190,32 +1190,32 @@ discard block |
||
1190 | 1190 | function _dounderline($x, $y, $txt) |
1191 | 1191 | { |
1192 | 1192 | //Underline text |
1193 | - $up=$this->CurrentFont['up']; |
|
1194 | - $ut=$this->CurrentFont['ut']; |
|
1195 | - $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); |
|
1196 | - 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); |
|
1193 | + $up = $this->CurrentFont['up']; |
|
1194 | + $ut = $this->CurrentFont['ut']; |
|
1195 | + $w = $this->GetStringWidth($txt) + $this->ws * substr_count($txt, ' '); |
|
1196 | + 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); |
|
1197 | 1197 | } |
1198 | 1198 | |
1199 | 1199 | function _parsejpg($file) |
1200 | 1200 | { |
1201 | 1201 | //Extract info from a JPEG file |
1202 | - $a=GetImageSize($file); |
|
1203 | - if(!$a) |
|
1202 | + $a = GetImageSize($file); |
|
1203 | + if (!$a) |
|
1204 | 1204 | $this->Error('Missing or incorrect image file: '.$file); |
1205 | - if($a[2]!=2) |
|
1205 | + if ($a[2] != 2) |
|
1206 | 1206 | $this->Error('Not a JPEG file: '.$file); |
1207 | - if(!isset($a['channels']) || $a['channels']==3) |
|
1208 | - $colspace='DeviceRGB'; |
|
1209 | - elseif($a['channels']==4) |
|
1210 | - $colspace='DeviceCMYK'; |
|
1207 | + if (!isset($a['channels']) || $a['channels'] == 3) |
|
1208 | + $colspace = 'DeviceRGB'; |
|
1209 | + elseif ($a['channels'] == 4) |
|
1210 | + $colspace = 'DeviceCMYK'; |
|
1211 | 1211 | else |
1212 | - $colspace='DeviceGray'; |
|
1213 | - $bpc=isset($a['bits']) ? $a['bits'] : 8; |
|
1212 | + $colspace = 'DeviceGray'; |
|
1213 | + $bpc = isset($a['bits']) ? $a['bits'] : 8; |
|
1214 | 1214 | //Read whole file |
1215 | - $f=fopen($file,'rb'); |
|
1216 | - $data=''; |
|
1217 | - while(!feof($f)) |
|
1218 | - $data.=fread($f,8192); |
|
1215 | + $f = fopen($file, 'rb'); |
|
1216 | + $data = ''; |
|
1217 | + while (!feof($f)) |
|
1218 | + $data .= fread($f, 8192); |
|
1219 | 1219 | fclose($f); |
1220 | 1220 | return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); |
1221 | 1221 | } |
@@ -1223,81 +1223,81 @@ discard block |
||
1223 | 1223 | function _parsepng($file) |
1224 | 1224 | { |
1225 | 1225 | //Extract info from a PNG file |
1226 | - $f=fopen($file,'rb'); |
|
1227 | - if(!$f) |
|
1226 | + $f = fopen($file, 'rb'); |
|
1227 | + if (!$f) |
|
1228 | 1228 | $this->Error('Can\'t open image file: '.$file); |
1229 | 1229 | //Check signature |
1230 | - if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
1230 | + if ($this->_readstream($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
1231 | 1231 | $this->Error('Not a PNG file: '.$file); |
1232 | 1232 | //Read header chunk |
1233 | - $this->_readstream($f,4); |
|
1234 | - if($this->_readstream($f,4)!='IHDR') |
|
1233 | + $this->_readstream($f, 4); |
|
1234 | + if ($this->_readstream($f, 4) != 'IHDR') |
|
1235 | 1235 | $this->Error('Incorrect PNG file: '.$file); |
1236 | - $w=$this->_readint($f); |
|
1237 | - $h=$this->_readint($f); |
|
1238 | - $bpc=ord($this->_readstream($f,1)); |
|
1239 | - if($bpc>8) |
|
1236 | + $w = $this->_readint($f); |
|
1237 | + $h = $this->_readint($f); |
|
1238 | + $bpc = ord($this->_readstream($f, 1)); |
|
1239 | + if ($bpc > 8) |
|
1240 | 1240 | $this->Error('16-bit depth not supported: '.$file); |
1241 | - $ct=ord($this->_readstream($f,1)); |
|
1242 | - if($ct==0) |
|
1243 | - $colspace='DeviceGray'; |
|
1244 | - elseif($ct==2) |
|
1245 | - $colspace='DeviceRGB'; |
|
1246 | - elseif($ct==3) |
|
1247 | - $colspace='Indexed'; |
|
1241 | + $ct = ord($this->_readstream($f, 1)); |
|
1242 | + if ($ct == 0) |
|
1243 | + $colspace = 'DeviceGray'; |
|
1244 | + elseif ($ct == 2) |
|
1245 | + $colspace = 'DeviceRGB'; |
|
1246 | + elseif ($ct == 3) |
|
1247 | + $colspace = 'Indexed'; |
|
1248 | 1248 | else |
1249 | 1249 | $this->Error('Alpha channel not supported: '.$file); |
1250 | - if(ord($this->_readstream($f,1))!=0) |
|
1250 | + if (ord($this->_readstream($f, 1)) != 0) |
|
1251 | 1251 | $this->Error('Unknown compression method: '.$file); |
1252 | - if(ord($this->_readstream($f,1))!=0) |
|
1252 | + if (ord($this->_readstream($f, 1)) != 0) |
|
1253 | 1253 | $this->Error('Unknown filter method: '.$file); |
1254 | - if(ord($this->_readstream($f,1))!=0) |
|
1254 | + if (ord($this->_readstream($f, 1)) != 0) |
|
1255 | 1255 | $this->Error('Interlacing not supported: '.$file); |
1256 | - $this->_readstream($f,4); |
|
1257 | - $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>'; |
|
1256 | + $this->_readstream($f, 4); |
|
1257 | + $parms = '/DecodeParms <</Predictor 15 /Colors '.($ct == 2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>'; |
|
1258 | 1258 | //Scan chunks looking for palette, transparency and image data |
1259 | - $pal=''; |
|
1260 | - $trns=''; |
|
1261 | - $data=''; |
|
1259 | + $pal = ''; |
|
1260 | + $trns = ''; |
|
1261 | + $data = ''; |
|
1262 | 1262 | do |
1263 | 1263 | { |
1264 | - $n=$this->_readint($f); |
|
1265 | - $type=$this->_readstream($f,4); |
|
1266 | - if($type=='PLTE') |
|
1264 | + $n = $this->_readint($f); |
|
1265 | + $type = $this->_readstream($f, 4); |
|
1266 | + if ($type == 'PLTE') |
|
1267 | 1267 | { |
1268 | 1268 | //Read palette |
1269 | - $pal=$this->_readstream($f,$n); |
|
1270 | - $this->_readstream($f,4); |
|
1269 | + $pal = $this->_readstream($f, $n); |
|
1270 | + $this->_readstream($f, 4); |
|
1271 | 1271 | } |
1272 | - elseif($type=='tRNS') |
|
1272 | + elseif ($type == 'tRNS') |
|
1273 | 1273 | { |
1274 | 1274 | //Read transparency info |
1275 | - $t=$this->_readstream($f,$n); |
|
1276 | - if($ct==0) |
|
1277 | - $trns=array(ord(substr($t,1,1))); |
|
1278 | - elseif($ct==2) |
|
1279 | - $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
1275 | + $t = $this->_readstream($f, $n); |
|
1276 | + if ($ct == 0) |
|
1277 | + $trns = array(ord(substr($t, 1, 1))); |
|
1278 | + elseif ($ct == 2) |
|
1279 | + $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1))); |
|
1280 | 1280 | else |
1281 | 1281 | { |
1282 | - $pos=strpos($t,chr(0)); |
|
1283 | - if($pos!==false) |
|
1284 | - $trns=array($pos); |
|
1282 | + $pos = strpos($t, chr(0)); |
|
1283 | + if ($pos !== false) |
|
1284 | + $trns = array($pos); |
|
1285 | 1285 | } |
1286 | - $this->_readstream($f,4); |
|
1286 | + $this->_readstream($f, 4); |
|
1287 | 1287 | } |
1288 | - elseif($type=='IDAT') |
|
1288 | + elseif ($type == 'IDAT') |
|
1289 | 1289 | { |
1290 | 1290 | //Read image data block |
1291 | - $data.=$this->_readstream($f,$n); |
|
1292 | - $this->_readstream($f,4); |
|
1291 | + $data .= $this->_readstream($f, $n); |
|
1292 | + $this->_readstream($f, 4); |
|
1293 | 1293 | } |
1294 | - elseif($type=='IEND') |
|
1294 | + elseif ($type == 'IEND') |
|
1295 | 1295 | break; |
1296 | 1296 | else |
1297 | - $this->_readstream($f,$n+4); |
|
1297 | + $this->_readstream($f, $n + 4); |
|
1298 | 1298 | } |
1299 | - while($n); |
|
1300 | - if($colspace=='Indexed' && empty($pal)) |
|
1299 | + while ($n); |
|
1300 | + if ($colspace == 'Indexed' && empty($pal)) |
|
1301 | 1301 | $this->Error('Missing palette in '.$file); |
1302 | 1302 | fclose($f); |
1303 | 1303 | return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data); |
@@ -1306,16 +1306,16 @@ discard block |
||
1306 | 1306 | function _readstream($f, $n) |
1307 | 1307 | { |
1308 | 1308 | //Read n bytes from stream |
1309 | - $res=''; |
|
1310 | - while($n>0 && !feof($f)) |
|
1309 | + $res = ''; |
|
1310 | + while ($n > 0 && !feof($f)) |
|
1311 | 1311 | { |
1312 | - $s=fread($f,$n); |
|
1313 | - if($s===false) |
|
1312 | + $s = fread($f, $n); |
|
1313 | + if ($s === false) |
|
1314 | 1314 | $this->Error('Error while reading stream'); |
1315 | - $n-=strlen($s); |
|
1316 | - $res.=$s; |
|
1315 | + $n -= strlen($s); |
|
1316 | + $res .= $s; |
|
1317 | 1317 | } |
1318 | - if($n>0) |
|
1318 | + if ($n > 0) |
|
1319 | 1319 | $this->Error('Unexpected end of stream'); |
1320 | 1320 | return $res; |
1321 | 1321 | } |
@@ -1323,28 +1323,28 @@ discard block |
||
1323 | 1323 | function _readint($f) |
1324 | 1324 | { |
1325 | 1325 | //Read a 4-byte integer from stream |
1326 | - $a=unpack('Ni',$this->_readstream($f,4)); |
|
1326 | + $a = unpack('Ni', $this->_readstream($f, 4)); |
|
1327 | 1327 | return $a['i']; |
1328 | 1328 | } |
1329 | 1329 | |
1330 | 1330 | function _parsegif($file) |
1331 | 1331 | { |
1332 | 1332 | //Extract info from a GIF file (via PNG conversion) |
1333 | - if(!function_exists('imagepng')) |
|
1333 | + if (!function_exists('imagepng')) |
|
1334 | 1334 | $this->Error('GD extension is required for GIF support'); |
1335 | - if(!function_exists('imagecreatefromgif')) |
|
1335 | + if (!function_exists('imagecreatefromgif')) |
|
1336 | 1336 | $this->Error('GD has no GIF read support'); |
1337 | - $im=imagecreatefromgif($file); |
|
1338 | - if(!$im) |
|
1337 | + $im = imagecreatefromgif($file); |
|
1338 | + if (!$im) |
|
1339 | 1339 | $this->Error('Missing or incorrect image file: '.$file); |
1340 | - imageinterlace($im,0); |
|
1341 | - $tmp=tempnam('.','gif'); |
|
1342 | - if(!$tmp) |
|
1340 | + imageinterlace($im, 0); |
|
1341 | + $tmp = tempnam('.', 'gif'); |
|
1342 | + if (!$tmp) |
|
1343 | 1343 | $this->Error('Unable to create a temporary file'); |
1344 | - if(!imagepng($im,$tmp)) |
|
1344 | + if (!imagepng($im, $tmp)) |
|
1345 | 1345 | $this->Error('Error while saving to temporary file'); |
1346 | 1346 | imagedestroy($im); |
1347 | - $info=$this->_parsepng($tmp); |
|
1347 | + $info = $this->_parsepng($tmp); |
|
1348 | 1348 | unlink($tmp); |
1349 | 1349 | return $info; |
1350 | 1350 | } |
@@ -1353,7 +1353,7 @@ discard block |
||
1353 | 1353 | { |
1354 | 1354 | //Begin a new object |
1355 | 1355 | $this->n++; |
1356 | - $this->offsets[$this->n]=strlen($this->buffer); |
|
1356 | + $this->offsets[$this->n] = strlen($this->buffer); |
|
1357 | 1357 | $this->_out($this->n.' 0 obj'); |
1358 | 1358 | } |
1359 | 1359 | |
@@ -1367,149 +1367,149 @@ discard block |
||
1367 | 1367 | function _out($s) |
1368 | 1368 | { |
1369 | 1369 | //Add a line to the document |
1370 | - if($this->state==2) |
|
1371 | - $this->pages[$this->page].=$s."\n"; |
|
1370 | + if ($this->state == 2) |
|
1371 | + $this->pages[$this->page] .= $s."\n"; |
|
1372 | 1372 | else |
1373 | - $this->buffer.=$s."\n"; |
|
1373 | + $this->buffer .= $s."\n"; |
|
1374 | 1374 | } |
1375 | 1375 | |
1376 | 1376 | function _putpages() |
1377 | 1377 | { |
1378 | - $nb=$this->page; |
|
1379 | - if(!empty($this->AliasNbPages)) |
|
1378 | + $nb = $this->page; |
|
1379 | + if (!empty($this->AliasNbPages)) |
|
1380 | 1380 | { |
1381 | 1381 | //Replace number of pages |
1382 | - for($n=1;$n<=$nb;$n++) |
|
1383 | - $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]); |
|
1382 | + for ($n = 1; $n <= $nb; $n++) |
|
1383 | + $this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]); |
|
1384 | 1384 | } |
1385 | - if($this->DefOrientation=='P') |
|
1385 | + if ($this->DefOrientation == 'P') |
|
1386 | 1386 | { |
1387 | - $wPt=$this->DefPageFormat[0]*$this->k; |
|
1388 | - $hPt=$this->DefPageFormat[1]*$this->k; |
|
1387 | + $wPt = $this->DefPageFormat[0] * $this->k; |
|
1388 | + $hPt = $this->DefPageFormat[1] * $this->k; |
|
1389 | 1389 | } |
1390 | 1390 | else |
1391 | 1391 | { |
1392 | - $wPt=$this->DefPageFormat[1]*$this->k; |
|
1393 | - $hPt=$this->DefPageFormat[0]*$this->k; |
|
1392 | + $wPt = $this->DefPageFormat[1] * $this->k; |
|
1393 | + $hPt = $this->DefPageFormat[0] * $this->k; |
|
1394 | 1394 | } |
1395 | - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; |
|
1396 | - for($n=1;$n<=$nb;$n++) |
|
1395 | + $filter = ($this->compress) ? '/Filter /FlateDecode ' : ''; |
|
1396 | + for ($n = 1; $n <= $nb; $n++) |
|
1397 | 1397 | { |
1398 | 1398 | //Page |
1399 | 1399 | $this->_newobj(); |
1400 | 1400 | $this->_out('<</Type /Page'); |
1401 | 1401 | $this->_out('/Parent 1 0 R'); |
1402 | - if(isset($this->PageSizes[$n])) |
|
1403 | - $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); |
|
1402 | + if (isset($this->PageSizes[$n])) |
|
1403 | + $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1])); |
|
1404 | 1404 | $this->_out('/Resources 2 0 R'); |
1405 | - if(isset($this->PageLinks[$n])) |
|
1405 | + if (isset($this->PageLinks[$n])) |
|
1406 | 1406 | { |
1407 | 1407 | //Links |
1408 | - $annots='/Annots ['; |
|
1409 | - foreach($this->PageLinks[$n] as $pl) |
|
1408 | + $annots = '/Annots ['; |
|
1409 | + foreach ($this->PageLinks[$n] as $pl) |
|
1410 | 1410 | { |
1411 | - $rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); |
|
1412 | - $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
|
1413 | - if(is_string($pl[4])) |
|
1414 | - $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
1411 | + $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]); |
|
1412 | + $annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
|
1413 | + if (is_string($pl[4])) |
|
1414 | + $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
1415 | 1415 | else |
1416 | 1416 | { |
1417 | - $l=$this->links[$pl[4]]; |
|
1418 | - $h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; |
|
1419 | - $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k); |
|
1417 | + $l = $this->links[$pl[4]]; |
|
1418 | + $h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; |
|
1419 | + $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', 1 + 2 * $l[0], $h - $l[1] * $this->k); |
|
1420 | 1420 | } |
1421 | 1421 | } |
1422 | 1422 | $this->_out($annots.']'); |
1423 | 1423 | } |
1424 | - $this->_out('/Contents '.($this->n+1).' 0 R>>'); |
|
1424 | + $this->_out('/Contents '.($this->n + 1).' 0 R>>'); |
|
1425 | 1425 | $this->_out('endobj'); |
1426 | 1426 | //Page content |
1427 | - $p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n]; |
|
1427 | + $p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n]; |
|
1428 | 1428 | $this->_newobj(); |
1429 | 1429 | $this->_out('<<'.$filter.'/Length '.strlen($p).'>>'); |
1430 | 1430 | $this->_putstream($p); |
1431 | 1431 | $this->_out('endobj'); |
1432 | 1432 | } |
1433 | 1433 | //Pages root |
1434 | - $this->offsets[1]=strlen($this->buffer); |
|
1434 | + $this->offsets[1] = strlen($this->buffer); |
|
1435 | 1435 | $this->_out('1 0 obj'); |
1436 | 1436 | $this->_out('<</Type /Pages'); |
1437 | - $kids='/Kids ['; |
|
1438 | - for($i=0;$i<$nb;$i++) |
|
1439 | - $kids.=(3+2*$i).' 0 R '; |
|
1437 | + $kids = '/Kids ['; |
|
1438 | + for ($i = 0; $i < $nb; $i++) |
|
1439 | + $kids .= (3 + 2 * $i).' 0 R '; |
|
1440 | 1440 | $this->_out($kids.']'); |
1441 | 1441 | $this->_out('/Count '.$nb); |
1442 | - $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt)); |
|
1442 | + $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $wPt, $hPt)); |
|
1443 | 1443 | $this->_out('>>'); |
1444 | 1444 | $this->_out('endobj'); |
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | function _putfonts() |
1448 | 1448 | { |
1449 | - $nf=$this->n; |
|
1450 | - foreach($this->diffs as $diff) |
|
1449 | + $nf = $this->n; |
|
1450 | + foreach ($this->diffs as $diff) |
|
1451 | 1451 | { |
1452 | 1452 | //Encodings |
1453 | 1453 | $this->_newobj(); |
1454 | 1454 | $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>'); |
1455 | 1455 | $this->_out('endobj'); |
1456 | 1456 | } |
1457 | - foreach($this->FontFiles as $file=>$info) |
|
1457 | + foreach ($this->FontFiles as $file=>$info) |
|
1458 | 1458 | { |
1459 | 1459 | //Font file embedding |
1460 | 1460 | $this->_newobj(); |
1461 | - $this->FontFiles[$file]['n']=$this->n; |
|
1462 | - $font=''; |
|
1463 | - $f=fopen($this->_getfontpath().$file,'rb',1); |
|
1464 | - if(!$f) |
|
1461 | + $this->FontFiles[$file]['n'] = $this->n; |
|
1462 | + $font = ''; |
|
1463 | + $f = fopen($this->_getfontpath().$file, 'rb', 1); |
|
1464 | + if (!$f) |
|
1465 | 1465 | $this->Error('Font file not found'); |
1466 | - while(!feof($f)) |
|
1467 | - $font.=fread($f,8192); |
|
1466 | + while (!feof($f)) |
|
1467 | + $font .= fread($f, 8192); |
|
1468 | 1468 | fclose($f); |
1469 | - $compressed=(substr($file,-2)=='.z'); |
|
1470 | - if(!$compressed && isset($info['length2'])) |
|
1469 | + $compressed = (substr($file, -2) == '.z'); |
|
1470 | + if (!$compressed && isset($info['length2'])) |
|
1471 | 1471 | { |
1472 | - $header=(ord($font[0])==128); |
|
1473 | - if($header) |
|
1472 | + $header = (ord($font[0]) == 128); |
|
1473 | + if ($header) |
|
1474 | 1474 | { |
1475 | 1475 | //Strip first binary header |
1476 | - $font=substr($font,6); |
|
1476 | + $font = substr($font, 6); |
|
1477 | 1477 | } |
1478 | - if($header && ord($font[$info['length1']])==128) |
|
1478 | + if ($header && ord($font[$info['length1']]) == 128) |
|
1479 | 1479 | { |
1480 | 1480 | //Strip second binary header |
1481 | - $font=substr($font,0,$info['length1']).substr($font,$info['length1']+6); |
|
1481 | + $font = substr($font, 0, $info['length1']).substr($font, $info['length1'] + 6); |
|
1482 | 1482 | } |
1483 | 1483 | } |
1484 | 1484 | $this->_out('<</Length '.strlen($font)); |
1485 | - if($compressed) |
|
1485 | + if ($compressed) |
|
1486 | 1486 | $this->_out('/Filter /FlateDecode'); |
1487 | 1487 | $this->_out('/Length1 '.$info['length1']); |
1488 | - if(isset($info['length2'])) |
|
1488 | + if (isset($info['length2'])) |
|
1489 | 1489 | $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
1490 | 1490 | $this->_out('>>'); |
1491 | 1491 | $this->_putstream($font); |
1492 | 1492 | $this->_out('endobj'); |
1493 | 1493 | } |
1494 | - foreach($this->fonts as $k=>$font) |
|
1494 | + foreach ($this->fonts as $k=>$font) |
|
1495 | 1495 | { |
1496 | 1496 | //Font objects |
1497 | - $this->fonts[$k]['n']=$this->n+1; |
|
1498 | - $type=$font['type']; |
|
1499 | - $name=$font['name']; |
|
1500 | - if($type=='core') |
|
1497 | + $this->fonts[$k]['n'] = $this->n + 1; |
|
1498 | + $type = $font['type']; |
|
1499 | + $name = $font['name']; |
|
1500 | + if ($type == 'core') |
|
1501 | 1501 | { |
1502 | 1502 | //Standard font |
1503 | 1503 | $this->_newobj(); |
1504 | 1504 | $this->_out('<</Type /Font'); |
1505 | 1505 | $this->_out('/BaseFont /'.$name); |
1506 | 1506 | $this->_out('/Subtype /Type1'); |
1507 | - if($name!='Symbol' && $name!='ZapfDingbats') |
|
1507 | + if ($name != 'Symbol' && $name != 'ZapfDingbats') |
|
1508 | 1508 | $this->_out('/Encoding /WinAnsiEncoding'); |
1509 | 1509 | $this->_out('>>'); |
1510 | 1510 | $this->_out('endobj'); |
1511 | 1511 | } |
1512 | - elseif($type=='Type1' || $type=='TrueType') |
|
1512 | + elseif ($type == 'Type1' || $type == 'TrueType') |
|
1513 | 1513 | { |
1514 | 1514 | //Additional Type1 or TrueType font |
1515 | 1515 | $this->_newobj(); |
@@ -1517,12 +1517,12 @@ discard block |
||
1517 | 1517 | $this->_out('/BaseFont /'.$name); |
1518 | 1518 | $this->_out('/Subtype /'.$type); |
1519 | 1519 | $this->_out('/FirstChar 32 /LastChar 255'); |
1520 | - $this->_out('/Widths '.($this->n+1).' 0 R'); |
|
1521 | - $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); |
|
1522 | - if($font['enc']) |
|
1520 | + $this->_out('/Widths '.($this->n + 1).' 0 R'); |
|
1521 | + $this->_out('/FontDescriptor '.($this->n + 2).' 0 R'); |
|
1522 | + if ($font['enc']) |
|
1523 | 1523 | { |
1524 | - if(isset($font['diff'])) |
|
1525 | - $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); |
|
1524 | + if (isset($font['diff'])) |
|
1525 | + $this->_out('/Encoding '.($nf + $font['diff']).' 0 R'); |
|
1526 | 1526 | else |
1527 | 1527 | $this->_out('/Encoding /WinAnsiEncoding'); |
1528 | 1528 | } |
@@ -1530,28 +1530,28 @@ discard block |
||
1530 | 1530 | $this->_out('endobj'); |
1531 | 1531 | //Widths |
1532 | 1532 | $this->_newobj(); |
1533 | - $cw=&$font['cw']; |
|
1534 | - $s='['; |
|
1535 | - for($i=32;$i<=255;$i++) |
|
1536 | - $s.=$cw[chr($i)].' '; |
|
1533 | + $cw = &$font['cw']; |
|
1534 | + $s = '['; |
|
1535 | + for ($i = 32; $i <= 255; $i++) |
|
1536 | + $s .= $cw[chr($i)].' '; |
|
1537 | 1537 | $this->_out($s.']'); |
1538 | 1538 | $this->_out('endobj'); |
1539 | 1539 | //Descriptor |
1540 | 1540 | $this->_newobj(); |
1541 | - $s='<</Type /FontDescriptor /FontName /'.$name; |
|
1542 | - foreach($font['desc'] as $k=>$v) |
|
1543 | - $s.=' /'.$k.' '.$v; |
|
1544 | - $file=$font['file']; |
|
1545 | - if($file) |
|
1546 | - $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
|
1541 | + $s = '<</Type /FontDescriptor /FontName /'.$name; |
|
1542 | + foreach ($font['desc'] as $k=>$v) |
|
1543 | + $s .= ' /'.$k.' '.$v; |
|
1544 | + $file = $font['file']; |
|
1545 | + if ($file) |
|
1546 | + $s .= ' /FontFile'.($type == 'Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
|
1547 | 1547 | $this->_out($s.'>>'); |
1548 | 1548 | $this->_out('endobj'); |
1549 | 1549 | } |
1550 | 1550 | else |
1551 | 1551 | { |
1552 | 1552 | //Allow for additional types |
1553 | - $mtd='_put'.strtolower($type); |
|
1554 | - if(!method_exists($this,$mtd)) |
|
1553 | + $mtd = '_put'.strtolower($type); |
|
1554 | + if (!method_exists($this, $mtd)) |
|
1555 | 1555 | $this->Error('Unsupported font type: '.$type); |
1556 | 1556 | $this->$mtd($font); |
1557 | 1557 | } |
@@ -1560,34 +1560,34 @@ discard block |
||
1560 | 1560 | |
1561 | 1561 | function _putimages() |
1562 | 1562 | { |
1563 | - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; |
|
1563 | + $filter = ($this->compress) ? '/Filter /FlateDecode ' : ''; |
|
1564 | 1564 | reset($this->images); |
1565 | - while(list($file,$info)=each($this->images)) |
|
1565 | + while (list($file, $info) = each($this->images)) |
|
1566 | 1566 | { |
1567 | 1567 | $this->_newobj(); |
1568 | - $this->images[$file]['n']=$this->n; |
|
1568 | + $this->images[$file]['n'] = $this->n; |
|
1569 | 1569 | $this->_out('<</Type /XObject'); |
1570 | 1570 | $this->_out('/Subtype /Image'); |
1571 | 1571 | $this->_out('/Width '.$info['w']); |
1572 | 1572 | $this->_out('/Height '.$info['h']); |
1573 | - if($info['cs']=='Indexed') |
|
1574 | - $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
1573 | + if ($info['cs'] == 'Indexed') |
|
1574 | + $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal']) / 3 - 1).' '.($this->n + 1).' 0 R]'); |
|
1575 | 1575 | else |
1576 | 1576 | { |
1577 | 1577 | $this->_out('/ColorSpace /'.$info['cs']); |
1578 | - if($info['cs']=='DeviceCMYK') |
|
1578 | + if ($info['cs'] == 'DeviceCMYK') |
|
1579 | 1579 | $this->_out('/Decode [1 0 1 0 1 0 1 0]'); |
1580 | 1580 | } |
1581 | 1581 | $this->_out('/BitsPerComponent '.$info['bpc']); |
1582 | - if(isset($info['f'])) |
|
1582 | + if (isset($info['f'])) |
|
1583 | 1583 | $this->_out('/Filter /'.$info['f']); |
1584 | - if(isset($info['parms'])) |
|
1584 | + if (isset($info['parms'])) |
|
1585 | 1585 | $this->_out($info['parms']); |
1586 | - if(isset($info['trns']) && is_array($info['trns'])) |
|
1586 | + if (isset($info['trns']) && is_array($info['trns'])) |
|
1587 | 1587 | { |
1588 | - $trns=''; |
|
1589 | - for($i=0;$i<count($info['trns']);$i++) |
|
1590 | - $trns.=$info['trns'][$i].' '.$info['trns'][$i].' '; |
|
1588 | + $trns = ''; |
|
1589 | + for ($i = 0; $i < count($info['trns']); $i++) |
|
1590 | + $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; |
|
1591 | 1591 | $this->_out('/Mask ['.$trns.']'); |
1592 | 1592 | } |
1593 | 1593 | $this->_out('/Length '.strlen($info['data']).'>>'); |
@@ -1595,10 +1595,10 @@ discard block |
||
1595 | 1595 | unset($this->images[$file]['data']); |
1596 | 1596 | $this->_out('endobj'); |
1597 | 1597 | //Palette |
1598 | - if($info['cs']=='Indexed') |
|
1598 | + if ($info['cs'] == 'Indexed') |
|
1599 | 1599 | { |
1600 | 1600 | $this->_newobj(); |
1601 | - $pal=($this->compress) ? gzcompress($info['pal']) : $info['pal']; |
|
1601 | + $pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal']; |
|
1602 | 1602 | $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>'); |
1603 | 1603 | $this->_putstream($pal); |
1604 | 1604 | $this->_out('endobj'); |
@@ -1608,7 +1608,7 @@ discard block |
||
1608 | 1608 | |
1609 | 1609 | function _putxobjectdict() |
1610 | 1610 | { |
1611 | - foreach($this->images as $image) |
|
1611 | + foreach ($this->images as $image) |
|
1612 | 1612 | $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); |
1613 | 1613 | } |
1614 | 1614 | |
@@ -1616,7 +1616,7 @@ discard block |
||
1616 | 1616 | { |
1617 | 1617 | $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
1618 | 1618 | $this->_out('/Font <<'); |
1619 | - foreach($this->fonts as $font) |
|
1619 | + foreach ($this->fonts as $font) |
|
1620 | 1620 | $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); |
1621 | 1621 | $this->_out('>>'); |
1622 | 1622 | $this->_out('/XObject <<'); |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | $this->_putfonts(); |
1630 | 1630 | $this->_putimages(); |
1631 | 1631 | //Resource dictionary |
1632 | - $this->offsets[2]=strlen($this->buffer); |
|
1632 | + $this->offsets[2] = strlen($this->buffer); |
|
1633 | 1633 | $this->_out('2 0 obj'); |
1634 | 1634 | $this->_out('<<'); |
1635 | 1635 | $this->_putresourcedict(); |
@@ -1640,15 +1640,15 @@ discard block |
||
1640 | 1640 | function _putinfo() |
1641 | 1641 | { |
1642 | 1642 | $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION)); |
1643 | - if(!empty($this->title)) |
|
1643 | + if (!empty($this->title)) |
|
1644 | 1644 | $this->_out('/Title '.$this->_textstring($this->title)); |
1645 | - if(!empty($this->subject)) |
|
1645 | + if (!empty($this->subject)) |
|
1646 | 1646 | $this->_out('/Subject '.$this->_textstring($this->subject)); |
1647 | - if(!empty($this->author)) |
|
1647 | + if (!empty($this->author)) |
|
1648 | 1648 | $this->_out('/Author '.$this->_textstring($this->author)); |
1649 | - if(!empty($this->keywords)) |
|
1649 | + if (!empty($this->keywords)) |
|
1650 | 1650 | $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
1651 | - if(!empty($this->creator)) |
|
1651 | + if (!empty($this->creator)) |
|
1652 | 1652 | $this->_out('/Creator '.$this->_textstring($this->creator)); |
1653 | 1653 | $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); |
1654 | 1654 | } |
@@ -1657,19 +1657,19 @@ discard block |
||
1657 | 1657 | { |
1658 | 1658 | $this->_out('/Type /Catalog'); |
1659 | 1659 | $this->_out('/Pages 1 0 R'); |
1660 | - if($this->ZoomMode=='fullpage') |
|
1660 | + if ($this->ZoomMode == 'fullpage') |
|
1661 | 1661 | $this->_out('/OpenAction [3 0 R /Fit]'); |
1662 | - elseif($this->ZoomMode=='fullwidth') |
|
1662 | + elseif ($this->ZoomMode == 'fullwidth') |
|
1663 | 1663 | $this->_out('/OpenAction [3 0 R /FitH null]'); |
1664 | - elseif($this->ZoomMode=='real') |
|
1664 | + elseif ($this->ZoomMode == 'real') |
|
1665 | 1665 | $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); |
1666 | - elseif(!is_string($this->ZoomMode)) |
|
1667 | - $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); |
|
1668 | - if($this->LayoutMode=='single') |
|
1666 | + elseif (!is_string($this->ZoomMode)) |
|
1667 | + $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode / 100).']'); |
|
1668 | + if ($this->LayoutMode == 'single') |
|
1669 | 1669 | $this->_out('/PageLayout /SinglePage'); |
1670 | - elseif($this->LayoutMode=='continuous') |
|
1670 | + elseif ($this->LayoutMode == 'continuous') |
|
1671 | 1671 | $this->_out('/PageLayout /OneColumn'); |
1672 | - elseif($this->LayoutMode=='two') |
|
1672 | + elseif ($this->LayoutMode == 'two') |
|
1673 | 1673 | $this->_out('/PageLayout /TwoColumnLeft'); |
1674 | 1674 | } |
1675 | 1675 | |
@@ -1680,9 +1680,9 @@ discard block |
||
1680 | 1680 | |
1681 | 1681 | function _puttrailer() |
1682 | 1682 | { |
1683 | - $this->_out('/Size '.($this->n+1)); |
|
1683 | + $this->_out('/Size '.($this->n + 1)); |
|
1684 | 1684 | $this->_out('/Root '.$this->n.' 0 R'); |
1685 | - $this->_out('/Info '.($this->n-1).' 0 R'); |
|
1685 | + $this->_out('/Info '.($this->n - 1).' 0 R'); |
|
1686 | 1686 | } |
1687 | 1687 | |
1688 | 1688 | function _enddoc() |
@@ -1703,12 +1703,12 @@ discard block |
||
1703 | 1703 | $this->_out('>>'); |
1704 | 1704 | $this->_out('endobj'); |
1705 | 1705 | //Cross-ref |
1706 | - $o=strlen($this->buffer); |
|
1706 | + $o = strlen($this->buffer); |
|
1707 | 1707 | $this->_out('xref'); |
1708 | - $this->_out('0 '.($this->n+1)); |
|
1708 | + $this->_out('0 '.($this->n + 1)); |
|
1709 | 1709 | $this->_out('0000000000 65535 f '); |
1710 | - for($i=1;$i<=$this->n;$i++) |
|
1711 | - $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
1710 | + for ($i = 1; $i <= $this->n; $i++) |
|
1711 | + $this->_out(sprintf('%010d 00000 n ', $this->offsets[$i])); |
|
1712 | 1712 | //Trailer |
1713 | 1713 | $this->_out('trailer'); |
1714 | 1714 | $this->_out('<<'); |
@@ -1717,13 +1717,13 @@ discard block |
||
1717 | 1717 | $this->_out('startxref'); |
1718 | 1718 | $this->_out($o); |
1719 | 1719 | $this->_out('%%EOF'); |
1720 | - $this->state=3; |
|
1720 | + $this->state = 3; |
|
1721 | 1721 | } |
1722 | 1722 | //End of class |
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | //Handle special IE contype request |
1726 | -if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype') |
|
1726 | +if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] == 'contype') |
|
1727 | 1727 | { |
1728 | 1728 | header('Content-Type: application/pdf'); |
1729 | 1729 | exit; |
@@ -106,21 +106,23 @@ discard block |
||
106 | 106 | 'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic', |
107 | 107 | 'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats'); |
108 | 108 | //Scale factor |
109 | - if($unit=='pt') |
|
110 | - $this->k=1; |
|
111 | - elseif($unit=='mm') |
|
112 | - $this->k=72/25.4; |
|
113 | - elseif($unit=='cm') |
|
114 | - $this->k=72/2.54; |
|
115 | - elseif($unit=='in') |
|
116 | - $this->k=72; |
|
117 | - else |
|
118 | - $this->Error('Incorrect unit: '.$unit); |
|
109 | + if($unit=='pt') { |
|
110 | + $this->k=1; |
|
111 | + } elseif($unit=='mm') { |
|
112 | + $this->k=72/25.4; |
|
113 | + } elseif($unit=='cm') { |
|
114 | + $this->k=72/2.54; |
|
115 | + } elseif($unit=='in') { |
|
116 | + $this->k=72; |
|
117 | + } else { |
|
118 | + $this->Error('Incorrect unit: '.$unit); |
|
119 | + } |
|
119 | 120 | //Page format |
120 | 121 | $this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), |
121 | 122 | 'letter'=>array(612,792), 'legal'=>array(612,1008)); |
122 | - if(is_string($format)) |
|
123 | - $format=$this->_getpageformat($format); |
|
123 | + if(is_string($format)) { |
|
124 | + $format=$this->_getpageformat($format); |
|
125 | + } |
|
124 | 126 | $this->DefPageFormat=$format; |
125 | 127 | $this->CurPageFormat=$format; |
126 | 128 | //Page orientation |
@@ -130,15 +132,14 @@ discard block |
||
130 | 132 | $this->DefOrientation='P'; |
131 | 133 | $this->w=$this->DefPageFormat[0]; |
132 | 134 | $this->h=$this->DefPageFormat[1]; |
133 | - } |
|
134 | - elseif($orientation=='l' || $orientation=='landscape') |
|
135 | + } elseif($orientation=='l' || $orientation=='landscape') |
|
135 | 136 | { |
136 | 137 | $this->DefOrientation='L'; |
137 | 138 | $this->w=$this->DefPageFormat[1]; |
138 | 139 | $this->h=$this->DefPageFormat[0]; |
140 | + } else { |
|
141 | + $this->Error('Incorrect orientation: '.$orientation); |
|
139 | 142 | } |
140 | - else |
|
141 | - $this->Error('Incorrect orientation: '.$orientation); |
|
142 | 143 | $this->CurOrientation=$this->DefOrientation; |
143 | 144 | $this->wPt=$this->w*$this->k; |
144 | 145 | $this->hPt=$this->h*$this->k; |
@@ -164,8 +165,9 @@ discard block |
||
164 | 165 | //Set left, top and right margins |
165 | 166 | $this->lMargin=$left; |
166 | 167 | $this->tMargin=$top; |
167 | - if($right===null) |
|
168 | - $right=$left; |
|
168 | + if($right===null) { |
|
169 | + $right=$left; |
|
170 | + } |
|
169 | 171 | $this->rMargin=$right; |
170 | 172 | } |
171 | 173 | |
@@ -173,9 +175,10 @@ discard block |
||
173 | 175 | { |
174 | 176 | //Set left margin |
175 | 177 | $this->lMargin=$margin; |
176 | - if($this->page>0 && $this->x<$margin) |
|
177 | - $this->x=$margin; |
|
178 | -} |
|
178 | + if($this->page>0 && $this->x<$margin) { |
|
179 | + $this->x=$margin; |
|
180 | + } |
|
181 | + } |
|
179 | 182 | |
180 | 183 | function SetTopMargin($margin) |
181 | 184 | { |
@@ -200,62 +203,70 @@ discard block |
||
200 | 203 | function SetDisplayMode($zoom, $layout='continuous') |
201 | 204 | { |
202 | 205 | //Set display mode in viewer |
203 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
204 | - $this->ZoomMode=$zoom; |
|
205 | - else |
|
206 | - $this->Error('Incorrect zoom display mode: '.$zoom); |
|
207 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
208 | - $this->LayoutMode=$layout; |
|
209 | - else |
|
210 | - $this->Error('Incorrect layout display mode: '.$layout); |
|
211 | -} |
|
206 | + if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) { |
|
207 | + $this->ZoomMode=$zoom; |
|
208 | + } else { |
|
209 | + $this->Error('Incorrect zoom display mode: '.$zoom); |
|
210 | + } |
|
211 | + if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') { |
|
212 | + $this->LayoutMode=$layout; |
|
213 | + } else { |
|
214 | + $this->Error('Incorrect layout display mode: '.$layout); |
|
215 | + } |
|
216 | + } |
|
212 | 217 | |
213 | 218 | function SetCompression($compress) |
214 | 219 | { |
215 | 220 | //Set page compression |
216 | - if(function_exists('gzcompress')) |
|
217 | - $this->compress=$compress; |
|
218 | - else |
|
219 | - $this->compress=false; |
|
220 | -} |
|
221 | + if(function_exists('gzcompress')) { |
|
222 | + $this->compress=$compress; |
|
223 | + } else { |
|
224 | + $this->compress=false; |
|
225 | + } |
|
226 | + } |
|
221 | 227 | |
222 | 228 | function SetTitle($title, $isUTF8=false) |
223 | 229 | { |
224 | 230 | //Title of document |
225 | - if($isUTF8) |
|
226 | - $title=$this->_UTF8toUTF16($title); |
|
231 | + if($isUTF8) { |
|
232 | + $title=$this->_UTF8toUTF16($title); |
|
233 | + } |
|
227 | 234 | $this->title=$title; |
228 | 235 | } |
229 | 236 | |
230 | 237 | function SetSubject($subject, $isUTF8=false) |
231 | 238 | { |
232 | 239 | //Subject of document |
233 | - if($isUTF8) |
|
234 | - $subject=$this->_UTF8toUTF16($subject); |
|
240 | + if($isUTF8) { |
|
241 | + $subject=$this->_UTF8toUTF16($subject); |
|
242 | + } |
|
235 | 243 | $this->subject=$subject; |
236 | 244 | } |
237 | 245 | |
238 | 246 | function SetAuthor($author, $isUTF8=false) |
239 | 247 | { |
240 | 248 | //Author of document |
241 | - if($isUTF8) |
|
242 | - $author=$this->_UTF8toUTF16($author); |
|
249 | + if($isUTF8) { |
|
250 | + $author=$this->_UTF8toUTF16($author); |
|
251 | + } |
|
243 | 252 | $this->author=$author; |
244 | 253 | } |
245 | 254 | |
246 | 255 | function SetKeywords($keywords, $isUTF8=false) |
247 | 256 | { |
248 | 257 | //Keywords of document |
249 | - if($isUTF8) |
|
250 | - $keywords=$this->_UTF8toUTF16($keywords); |
|
258 | + if($isUTF8) { |
|
259 | + $keywords=$this->_UTF8toUTF16($keywords); |
|
260 | + } |
|
251 | 261 | $this->keywords=$keywords; |
252 | 262 | } |
253 | 263 | |
254 | 264 | function SetCreator($creator, $isUTF8=false) |
255 | 265 | { |
256 | 266 | //Creator of document |
257 | - if($isUTF8) |
|
258 | - $creator=$this->_UTF8toUTF16($creator); |
|
267 | + if($isUTF8) { |
|
268 | + $creator=$this->_UTF8toUTF16($creator); |
|
269 | + } |
|
259 | 270 | $this->creator=$creator; |
260 | 271 | } |
261 | 272 | |
@@ -280,10 +291,12 @@ discard block |
||
280 | 291 | function Close() |
281 | 292 | { |
282 | 293 | //Terminate document |
283 | - if($this->state==3) |
|
284 | - return; |
|
285 | - if($this->page==0) |
|
286 | - $this->AddPage(); |
|
294 | + if($this->state==3) { |
|
295 | + return; |
|
296 | + } |
|
297 | + if($this->page==0) { |
|
298 | + $this->AddPage(); |
|
299 | + } |
|
287 | 300 | //Page footer |
288 | 301 | $this->InFooter=true; |
289 | 302 | $this->Footer(); |
@@ -297,8 +310,9 @@ discard block |
||
297 | 310 | function AddPage($orientation='', $format='') |
298 | 311 | { |
299 | 312 | //Start a new page |
300 | - if($this->state==0) |
|
301 | - $this->Open(); |
|
313 | + if($this->state==0) { |
|
314 | + $this->Open(); |
|
315 | + } |
|
302 | 316 | $family=$this->FontFamily; |
303 | 317 | $style=$this->FontStyle.($this->underline ? 'U' : ''); |
304 | 318 | $size=$this->FontSizePt; |
@@ -324,15 +338,18 @@ discard block |
||
324 | 338 | $this->LineWidth=$lw; |
325 | 339 | $this->_out(sprintf('%.2F w',$lw*$this->k)); |
326 | 340 | //Set font |
327 | - if($family) |
|
328 | - $this->SetFont($family,$style,$size); |
|
341 | + if($family) { |
|
342 | + $this->SetFont($family,$style,$size); |
|
343 | + } |
|
329 | 344 | //Set colors |
330 | 345 | $this->DrawColor=$dc; |
331 | - if($dc!='0 G') |
|
332 | - $this->_out($dc); |
|
346 | + if($dc!='0 G') { |
|
347 | + $this->_out($dc); |
|
348 | + } |
|
333 | 349 | $this->FillColor=$fc; |
334 | - if($fc!='0 g') |
|
335 | - $this->_out($fc); |
|
350 | + if($fc!='0 g') { |
|
351 | + $this->_out($fc); |
|
352 | + } |
|
336 | 353 | $this->TextColor=$tc; |
337 | 354 | $this->ColorFlag=$cf; |
338 | 355 | //Page header |
@@ -346,8 +363,9 @@ discard block |
||
346 | 363 | $this->_out(sprintf('%.2F w',$lw*$this->k)); |
347 | 364 | } |
348 | 365 | //Restore font |
349 | - if($family) |
|
350 | - $this->SetFont($family,$style,$size); |
|
366 | + if($family) { |
|
367 | + $this->SetFont($family,$style,$size); |
|
368 | + } |
|
351 | 369 | //Restore colors |
352 | 370 | if($this->DrawColor!=$dc) |
353 | 371 | { |
@@ -382,33 +400,38 @@ discard block |
||
382 | 400 | function SetDrawColor($r, $g=null, $b=null) |
383 | 401 | { |
384 | 402 | //Set color for all stroking operations |
385 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
386 | - $this->DrawColor=sprintf('%.3F G',$r/255); |
|
387 | - else |
|
388 | - $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
389 | - if($this->page>0) |
|
390 | - $this->_out($this->DrawColor); |
|
391 | -} |
|
403 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
404 | + $this->DrawColor=sprintf('%.3F G',$r/255); |
|
405 | + } else { |
|
406 | + $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
407 | + } |
|
408 | + if($this->page>0) { |
|
409 | + $this->_out($this->DrawColor); |
|
410 | + } |
|
411 | + } |
|
392 | 412 | |
393 | 413 | function SetFillColor($r, $g=null, $b=null) |
394 | 414 | { |
395 | 415 | //Set color for all filling operations |
396 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
397 | - $this->FillColor=sprintf('%.3F g',$r/255); |
|
398 | - else |
|
399 | - $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
416 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
417 | + $this->FillColor=sprintf('%.3F g',$r/255); |
|
418 | + } else { |
|
419 | + $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
420 | + } |
|
400 | 421 | $this->ColorFlag=($this->FillColor!=$this->TextColor); |
401 | - if($this->page>0) |
|
402 | - $this->_out($this->FillColor); |
|
403 | -} |
|
422 | + if($this->page>0) { |
|
423 | + $this->_out($this->FillColor); |
|
424 | + } |
|
425 | + } |
|
404 | 426 | |
405 | 427 | function SetTextColor($r, $g=null, $b=null) |
406 | 428 | { |
407 | 429 | //Set color for text |
408 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
409 | - $this->TextColor=sprintf('%.3F g',$r/255); |
|
410 | - else |
|
411 | - $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
430 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
431 | + $this->TextColor=sprintf('%.3F g',$r/255); |
|
432 | + } else { |
|
433 | + $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
434 | + } |
|
412 | 435 | $this->ColorFlag=($this->FillColor!=$this->TextColor); |
413 | 436 | } |
414 | 437 | |
@@ -419,8 +442,9 @@ discard block |
||
419 | 442 | $cw=&$this->CurrentFont['cw']; |
420 | 443 | $w=0; |
421 | 444 | $l=strlen($s); |
422 | - for($i=0;$i<$l;$i++) |
|
423 | - $w+=$cw[$s[$i]]; |
|
445 | + for($i=0;$i<$l;$i++) { |
|
446 | + $w+=$cw[$s[$i]]; |
|
447 | + } |
|
424 | 448 | return $w*$this->FontSize/1000; |
425 | 449 | } |
426 | 450 | |
@@ -428,9 +452,10 @@ discard block |
||
428 | 452 | { |
429 | 453 | //Set line width |
430 | 454 | $this->LineWidth=$width; |
431 | - if($this->page>0) |
|
432 | - $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
433 | -} |
|
455 | + if($this->page>0) { |
|
456 | + $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
457 | + } |
|
458 | + } |
|
434 | 459 | |
435 | 460 | function Line($x1, $y1, $x2, $y2) |
436 | 461 | { |
@@ -441,12 +466,13 @@ discard block |
||
441 | 466 | function Rect($x, $y, $w, $h, $style='') |
442 | 467 | { |
443 | 468 | //Draw a rectangle |
444 | - if($style=='F') |
|
445 | - $op='f'; |
|
446 | - elseif($style=='FD' || $style=='DF') |
|
447 | - $op='B'; |
|
448 | - else |
|
449 | - $op='S'; |
|
469 | + if($style=='F') { |
|
470 | + $op='f'; |
|
471 | + } elseif($style=='FD' || $style=='DF') { |
|
472 | + $op='B'; |
|
473 | + } else { |
|
474 | + $op='S'; |
|
475 | + } |
|
450 | 476 | $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); |
451 | 477 | } |
452 | 478 | |
@@ -454,19 +480,24 @@ discard block |
||
454 | 480 | { |
455 | 481 | //Add a TrueType or Type1 font |
456 | 482 | $family=strtolower($family); |
457 | - if($file=='') |
|
458 | - $file=str_replace(' ','',$family).strtolower($style).'.php'; |
|
459 | - if($family=='arial') |
|
460 | - $family='helvetica'; |
|
483 | + if($file=='') { |
|
484 | + $file=str_replace(' ','',$family).strtolower($style).'.php'; |
|
485 | + } |
|
486 | + if($family=='arial') { |
|
487 | + $family='helvetica'; |
|
488 | + } |
|
461 | 489 | $style=strtoupper($style); |
462 | - if($style=='IB') |
|
463 | - $style='BI'; |
|
490 | + if($style=='IB') { |
|
491 | + $style='BI'; |
|
492 | + } |
|
464 | 493 | $fontkey=$family.$style; |
465 | - if(isset($this->fonts[$fontkey])) |
|
466 | - return; |
|
494 | + if(isset($this->fonts[$fontkey])) { |
|
495 | + return; |
|
496 | + } |
|
467 | 497 | include($this->_getfontpath().$file); |
468 | - if(!isset($name)) |
|
469 | - $this->Error('Could not include font definition file'); |
|
498 | + if(!isset($name)) { |
|
499 | + $this->Error('Could not include font definition file'); |
|
500 | + } |
|
470 | 501 | $i=count($this->fonts)+1; |
471 | 502 | $this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file); |
472 | 503 | if($diff) |
@@ -491,10 +522,11 @@ discard block |
||
491 | 522 | } |
492 | 523 | if($file) |
493 | 524 | { |
494 | - if($type=='TrueType') |
|
495 | - $this->FontFiles[$file]=array('length1'=>$originalsize); |
|
496 | - else |
|
497 | - $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2); |
|
525 | + if($type=='TrueType') { |
|
526 | + $this->FontFiles[$file]=array('length1'=>$originalsize); |
|
527 | + } else { |
|
528 | + $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2); |
|
529 | + } |
|
498 | 530 | } |
499 | 531 | } |
500 | 532 | |
@@ -504,27 +536,32 @@ discard block |
||
504 | 536 | global $fpdf_charwidths; |
505 | 537 | |
506 | 538 | $family=strtolower($family); |
507 | - if($family=='') |
|
508 | - $family=$this->FontFamily; |
|
509 | - if($family=='arial') |
|
510 | - $family='helvetica'; |
|
511 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
512 | - $style=''; |
|
539 | + if($family=='') { |
|
540 | + $family=$this->FontFamily; |
|
541 | + } |
|
542 | + if($family=='arial') { |
|
543 | + $family='helvetica'; |
|
544 | + } elseif($family=='symbol' || $family=='zapfdingbats') { |
|
545 | + $style=''; |
|
546 | + } |
|
513 | 547 | $style=strtoupper($style); |
514 | 548 | if(strpos($style,'U')!==false) |
515 | 549 | { |
516 | 550 | $this->underline=true; |
517 | 551 | $style=str_replace('U','',$style); |
552 | + } else { |
|
553 | + $this->underline=false; |
|
554 | + } |
|
555 | + if($style=='IB') { |
|
556 | + $style='BI'; |
|
557 | + } |
|
558 | + if($size==0) { |
|
559 | + $size=$this->FontSizePt; |
|
518 | 560 | } |
519 | - else |
|
520 | - $this->underline=false; |
|
521 | - if($style=='IB') |
|
522 | - $style='BI'; |
|
523 | - if($size==0) |
|
524 | - $size=$this->FontSizePt; |
|
525 | 561 | //Test if font is already selected |
526 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
527 | - return; |
|
562 | + if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) { |
|
563 | + return; |
|
564 | + } |
|
528 | 565 | //Test if used for the first time |
529 | 566 | $fontkey=$family.$style; |
530 | 567 | if(!isset($this->fonts[$fontkey])) |
@@ -536,19 +573,21 @@ discard block |
||
536 | 573 | { |
537 | 574 | //Load metric file |
538 | 575 | $file=$family; |
539 | - if($family=='times' || $family=='helvetica') |
|
540 | - $file.=strtolower($style); |
|
576 | + if($family=='times' || $family=='helvetica') { |
|
577 | + $file.=strtolower($style); |
|
578 | + } |
|
541 | 579 | include($this->_getfontpath().$file.'.php'); |
542 | - if(!isset($fpdf_charwidths[$fontkey])) |
|
543 | - $this->Error('Could not include font metric file'); |
|
580 | + if(!isset($fpdf_charwidths[$fontkey])) { |
|
581 | + $this->Error('Could not include font metric file'); |
|
582 | + } |
|
544 | 583 | } |
545 | 584 | $i=count($this->fonts)+1; |
546 | 585 | $name=$this->CoreFonts[$fontkey]; |
547 | 586 | $cw=$fpdf_charwidths[$fontkey]; |
548 | 587 | $this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw); |
588 | + } else { |
|
589 | + $this->Error('Undefined font: '.$family.' '.$style); |
|
549 | 590 | } |
550 | - else |
|
551 | - $this->Error('Undefined font: '.$family.' '.$style); |
|
552 | 591 | } |
553 | 592 | //Select it |
554 | 593 | $this->FontFamily=$family; |
@@ -556,20 +595,23 @@ discard block |
||
556 | 595 | $this->FontSizePt=$size; |
557 | 596 | $this->FontSize=$size/$this->k; |
558 | 597 | $this->CurrentFont=&$this->fonts[$fontkey]; |
559 | - if($this->page>0) |
|
560 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
561 | -} |
|
598 | + if($this->page>0) { |
|
599 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
600 | + } |
|
601 | + } |
|
562 | 602 | |
563 | 603 | function SetFontSize($size) |
564 | 604 | { |
565 | 605 | //Set font size in points |
566 | - if($this->FontSizePt==$size) |
|
567 | - return; |
|
606 | + if($this->FontSizePt==$size) { |
|
607 | + return; |
|
608 | + } |
|
568 | 609 | $this->FontSizePt=$size; |
569 | 610 | $this->FontSize=$size/$this->k; |
570 | - if($this->page>0) |
|
571 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
572 | -} |
|
611 | + if($this->page>0) { |
|
612 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
613 | + } |
|
614 | + } |
|
573 | 615 | |
574 | 616 | function AddLink() |
575 | 617 | { |
@@ -582,10 +624,12 @@ discard block |
||
582 | 624 | function SetLink($link, $y=0, $page=-1) |
583 | 625 | { |
584 | 626 | //Set destination of internal link |
585 | - if($y==-1) |
|
586 | - $y=$this->y; |
|
587 | - if($page==-1) |
|
588 | - $page=$this->page; |
|
627 | + if($y==-1) { |
|
628 | + $y=$this->y; |
|
629 | + } |
|
630 | + if($page==-1) { |
|
631 | + $page=$this->page; |
|
632 | + } |
|
589 | 633 | $this->links[$link]=array($page, $y); |
590 | 634 | } |
591 | 635 | |
@@ -599,10 +643,12 @@ discard block |
||
599 | 643 | { |
600 | 644 | //Output a string |
601 | 645 | $s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); |
602 | - if($this->underline && $txt!='') |
|
603 | - $s.=' '.$this->_dounderline($x,$y,$txt); |
|
604 | - if($this->ColorFlag) |
|
605 | - $s='q '.$this->TextColor.' '.$s.' Q'; |
|
646 | + if($this->underline && $txt!='') { |
|
647 | + $s.=' '.$this->_dounderline($x,$y,$txt); |
|
648 | + } |
|
649 | + if($this->ColorFlag) { |
|
650 | + $s='q '.$this->TextColor.' '.$s.' Q'; |
|
651 | + } |
|
606 | 652 | $this->_out($s); |
607 | 653 | } |
608 | 654 | |
@@ -634,74 +680,89 @@ discard block |
||
634 | 680 | $this->_out(sprintf('%.3F Tw',$ws*$k)); |
635 | 681 | } |
636 | 682 | } |
637 | - if($w==0) |
|
638 | - $w=$this->w-$this->rMargin-$this->x; |
|
683 | + if($w==0) { |
|
684 | + $w=$this->w-$this->rMargin-$this->x; |
|
685 | + } |
|
639 | 686 | $s=''; |
640 | 687 | if($fill || $border==1) |
641 | 688 | { |
642 | - if($fill) |
|
643 | - $op=($border==1) ? 'B' : 'f'; |
|
644 | - else |
|
645 | - $op='S'; |
|
689 | + if($fill) { |
|
690 | + $op=($border==1) ? 'B' : 'f'; |
|
691 | + } else { |
|
692 | + $op='S'; |
|
693 | + } |
|
646 | 694 | $s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
647 | 695 | } |
648 | 696 | if(is_string($border)) |
649 | 697 | { |
650 | 698 | $x=$this->x; |
651 | 699 | $y=$this->y; |
652 | - if(strpos($border,'L')!==false) |
|
653 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
654 | - if(strpos($border,'T')!==false) |
|
655 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
656 | - if(strpos($border,'R')!==false) |
|
657 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
658 | - if(strpos($border,'B')!==false) |
|
659 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
700 | + if(strpos($border,'L')!==false) { |
|
701 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
702 | + } |
|
703 | + if(strpos($border,'T')!==false) { |
|
704 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
705 | + } |
|
706 | + if(strpos($border,'R')!==false) { |
|
707 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
708 | + } |
|
709 | + if(strpos($border,'B')!==false) { |
|
710 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
711 | + } |
|
660 | 712 | } |
661 | 713 | if($txt!=='') |
662 | 714 | { |
663 | - if($align=='R') |
|
664 | - $dx=$w-$this->cMargin-$this->GetStringWidth($txt); |
|
665 | - elseif($align=='C') |
|
666 | - $dx=($w-$this->GetStringWidth($txt))/2; |
|
667 | - else |
|
668 | - $dx=$this->cMargin; |
|
669 | - if($this->ColorFlag) |
|
670 | - $s.='q '.$this->TextColor.' '; |
|
715 | + if($align=='R') { |
|
716 | + $dx=$w-$this->cMargin-$this->GetStringWidth($txt); |
|
717 | + } elseif($align=='C') { |
|
718 | + $dx=($w-$this->GetStringWidth($txt))/2; |
|
719 | + } else { |
|
720 | + $dx=$this->cMargin; |
|
721 | + } |
|
722 | + if($this->ColorFlag) { |
|
723 | + $s.='q '.$this->TextColor.' '; |
|
724 | + } |
|
671 | 725 | $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); |
672 | 726 | $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); |
673 | - if($this->underline) |
|
674 | - $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
675 | - if($this->ColorFlag) |
|
676 | - $s.=' Q'; |
|
677 | - if($link) |
|
678 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
679 | - } |
|
680 | - if($s) |
|
681 | - $this->_out($s); |
|
727 | + if($this->underline) { |
|
728 | + $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
729 | + } |
|
730 | + if($this->ColorFlag) { |
|
731 | + $s.=' Q'; |
|
732 | + } |
|
733 | + if($link) { |
|
734 | + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
735 | + } |
|
736 | + } |
|
737 | + if($s) { |
|
738 | + $this->_out($s); |
|
739 | + } |
|
682 | 740 | $this->lasth=$h; |
683 | 741 | if($ln>0) |
684 | 742 | { |
685 | 743 | //Go to next line |
686 | 744 | $this->y+=$h; |
687 | - if($ln==1) |
|
688 | - $this->x=$this->lMargin; |
|
745 | + if($ln==1) { |
|
746 | + $this->x=$this->lMargin; |
|
747 | + } |
|
748 | + } else { |
|
749 | + $this->x+=$w; |
|
750 | + } |
|
689 | 751 | } |
690 | - else |
|
691 | - $this->x+=$w; |
|
692 | -} |
|
693 | 752 | |
694 | 753 | function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) |
695 | 754 | { |
696 | 755 | //Output text with automatic or explicit line breaks |
697 | 756 | $cw=&$this->CurrentFont['cw']; |
698 | - if($w==0) |
|
699 | - $w=$this->w-$this->rMargin-$this->x; |
|
757 | + if($w==0) { |
|
758 | + $w=$this->w-$this->rMargin-$this->x; |
|
759 | + } |
|
700 | 760 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
701 | 761 | $s=str_replace("\r",'',$txt); |
702 | 762 | $nb=strlen($s); |
703 | - if($nb>0 && $s[$nb-1]=="\n") |
|
704 | - $nb--; |
|
763 | + if($nb>0 && $s[$nb-1]=="\n") { |
|
764 | + $nb--; |
|
765 | + } |
|
705 | 766 | $b=0; |
706 | 767 | if($border) |
707 | 768 | { |
@@ -710,14 +771,15 @@ discard block |
||
710 | 771 | $border='LTRB'; |
711 | 772 | $b='LRT'; |
712 | 773 | $b2='LR'; |
713 | - } |
|
714 | - else |
|
774 | + } else |
|
715 | 775 | { |
716 | 776 | $b2=''; |
717 | - if(strpos($border,'L')!==false) |
|
718 | - $b2.='L'; |
|
719 | - if(strpos($border,'R')!==false) |
|
720 | - $b2.='R'; |
|
777 | + if(strpos($border,'L')!==false) { |
|
778 | + $b2.='L'; |
|
779 | + } |
|
780 | + if(strpos($border,'R')!==false) { |
|
781 | + $b2.='R'; |
|
782 | + } |
|
721 | 783 | $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2; |
722 | 784 | } |
723 | 785 | } |
@@ -746,8 +808,9 @@ discard block |
||
746 | 808 | $l=0; |
747 | 809 | $ns=0; |
748 | 810 | $nl++; |
749 | - if($border && $nl==2) |
|
750 | - $b=$b2; |
|
811 | + if($border && $nl==2) { |
|
812 | + $b=$b2; |
|
813 | + } |
|
751 | 814 | continue; |
752 | 815 | } |
753 | 816 | if($c==' ') |
@@ -762,16 +825,16 @@ discard block |
||
762 | 825 | //Automatic line break |
763 | 826 | if($sep==-1) |
764 | 827 | { |
765 | - if($i==$j) |
|
766 | - $i++; |
|
828 | + if($i==$j) { |
|
829 | + $i++; |
|
830 | + } |
|
767 | 831 | if($this->ws>0) |
768 | 832 | { |
769 | 833 | $this->ws=0; |
770 | 834 | $this->_out('0 Tw'); |
771 | 835 | } |
772 | 836 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
773 | - } |
|
774 | - else |
|
837 | + } else |
|
775 | 838 | { |
776 | 839 | if($align=='J') |
777 | 840 | { |
@@ -786,11 +849,12 @@ discard block |
||
786 | 849 | $l=0; |
787 | 850 | $ns=0; |
788 | 851 | $nl++; |
789 | - if($border && $nl==2) |
|
790 | - $b=$b2; |
|
852 | + if($border && $nl==2) { |
|
853 | + $b=$b2; |
|
854 | + } |
|
855 | + } else { |
|
856 | + $i++; |
|
791 | 857 | } |
792 | - else |
|
793 | - $i++; |
|
794 | 858 | } |
795 | 859 | //Last chunk |
796 | 860 | if($this->ws>0) |
@@ -798,8 +862,9 @@ discard block |
||
798 | 862 | $this->ws=0; |
799 | 863 | $this->_out('0 Tw'); |
800 | 864 | } |
801 | - if($border && strpos($border,'B')!==false) |
|
802 | - $b.='B'; |
|
865 | + if($border && strpos($border,'B')!==false) { |
|
866 | + $b.='B'; |
|
867 | + } |
|
803 | 868 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
804 | 869 | $this->x=$this->lMargin; |
805 | 870 | } |
@@ -838,8 +903,9 @@ discard block |
||
838 | 903 | $nl++; |
839 | 904 | continue; |
840 | 905 | } |
841 | - if($c==' ') |
|
842 | - $sep=$i; |
|
906 | + if($c==' ') { |
|
907 | + $sep=$i; |
|
908 | + } |
|
843 | 909 | $l+=$cw[$c]; |
844 | 910 | if($l>$wmax) |
845 | 911 | { |
@@ -857,11 +923,11 @@ discard block |
||
857 | 923 | $nl++; |
858 | 924 | continue; |
859 | 925 | } |
860 | - if($i==$j) |
|
861 | - $i++; |
|
926 | + if($i==$j) { |
|
927 | + $i++; |
|
928 | + } |
|
862 | 929 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
863 | - } |
|
864 | - else |
|
930 | + } else |
|
865 | 931 | { |
866 | 932 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); |
867 | 933 | $i=$sep+1; |
@@ -876,24 +942,26 @@ discard block |
||
876 | 942 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
877 | 943 | } |
878 | 944 | $nl++; |
945 | + } else { |
|
946 | + $i++; |
|
879 | 947 | } |
880 | - else |
|
881 | - $i++; |
|
882 | 948 | } |
883 | 949 | //Last chunk |
884 | - if($i!=$j) |
|
885 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); |
|
886 | -} |
|
950 | + if($i!=$j) { |
|
951 | + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); |
|
952 | + } |
|
953 | + } |
|
887 | 954 | |
888 | 955 | function Ln($h=null) |
889 | 956 | { |
890 | 957 | //Line feed; default value is last cell height |
891 | 958 | $this->x=$this->lMargin; |
892 | - if($h===null) |
|
893 | - $this->y+=$this->lasth; |
|
894 | - else |
|
895 | - $this->y+=$h; |
|
896 | -} |
|
959 | + if($h===null) { |
|
960 | + $this->y+=$this->lasth; |
|
961 | + } else { |
|
962 | + $this->y+=$h; |
|
963 | + } |
|
964 | + } |
|
897 | 965 | |
898 | 966 | function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') |
899 | 967 | { |
@@ -904,33 +972,36 @@ discard block |
||
904 | 972 | if($type=='') |
905 | 973 | { |
906 | 974 | $pos=strrpos($file,'.'); |
907 | - if(!$pos) |
|
908 | - $this->Error('Image file has no extension and no type was specified: '.$file); |
|
975 | + if(!$pos) { |
|
976 | + $this->Error('Image file has no extension and no type was specified: '.$file); |
|
977 | + } |
|
909 | 978 | $type=substr($file,$pos+1); |
910 | 979 | } |
911 | 980 | $type=strtolower($type); |
912 | - if($type=='jpeg') |
|
913 | - $type='jpg'; |
|
981 | + if($type=='jpeg') { |
|
982 | + $type='jpg'; |
|
983 | + } |
|
914 | 984 | $mtd='_parse'.$type; |
915 | - if(!method_exists($this,$mtd)) |
|
916 | - $this->Error('Unsupported image type: '.$type); |
|
985 | + if(!method_exists($this,$mtd)) { |
|
986 | + $this->Error('Unsupported image type: '.$type); |
|
987 | + } |
|
917 | 988 | $info=$this->$mtd($file); |
918 | 989 | $info['i']=count($this->images)+1; |
919 | 990 | $this->images[$file]=$info; |
991 | + } else { |
|
992 | + $info=$this->images[$file]; |
|
920 | 993 | } |
921 | - else |
|
922 | - $info=$this->images[$file]; |
|
923 | 994 | //Automatic width and height calculation if needed |
924 | 995 | if($w==0 && $h==0) |
925 | 996 | { |
926 | 997 | //Put image at 72 dpi |
927 | 998 | $w=$info['w']/$this->k; |
928 | 999 | $h=$info['h']/$this->k; |
1000 | + } elseif($w==0) { |
|
1001 | + $w=$h*$info['w']/$info['h']; |
|
1002 | + } elseif($h==0) { |
|
1003 | + $h=$w*$info['h']/$info['w']; |
|
929 | 1004 | } |
930 | - elseif($w==0) |
|
931 | - $w=$h*$info['w']/$info['h']; |
|
932 | - elseif($h==0) |
|
933 | - $h=$w*$info['h']/$info['w']; |
|
934 | 1005 | //Flowing mode |
935 | 1006 | if($y===null) |
936 | 1007 | { |
@@ -944,12 +1015,14 @@ discard block |
||
944 | 1015 | $y=$this->y; |
945 | 1016 | $this->y+=$h; |
946 | 1017 | } |
947 | - if($x===null) |
|
948 | - $x=$this->x; |
|
1018 | + if($x===null) { |
|
1019 | + $x=$this->x; |
|
1020 | + } |
|
949 | 1021 | $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'])); |
950 | - if($link) |
|
951 | - $this->Link($x,$y,$w,$h,$link); |
|
952 | -} |
|
1022 | + if($link) { |
|
1023 | + $this->Link($x,$y,$w,$h,$link); |
|
1024 | + } |
|
1025 | + } |
|
953 | 1026 | |
954 | 1027 | function GetX() |
955 | 1028 | { |
@@ -960,11 +1033,12 @@ discard block |
||
960 | 1033 | function SetX($x) |
961 | 1034 | { |
962 | 1035 | //Set x position |
963 | - if($x>=0) |
|
964 | - $this->x=$x; |
|
965 | - else |
|
966 | - $this->x=$this->w+$x; |
|
967 | -} |
|
1036 | + if($x>=0) { |
|
1037 | + $this->x=$x; |
|
1038 | + } else { |
|
1039 | + $this->x=$this->w+$x; |
|
1040 | + } |
|
1041 | + } |
|
968 | 1042 | |
969 | 1043 | function GetY() |
970 | 1044 | { |
@@ -976,11 +1050,12 @@ discard block |
||
976 | 1050 | { |
977 | 1051 | //Set y position and reset x |
978 | 1052 | $this->x=$this->lMargin; |
979 | - if($y>=0) |
|
980 | - $this->y=$y; |
|
981 | - else |
|
982 | - $this->y=$this->h+$y; |
|
983 | -} |
|
1053 | + if($y>=0) { |
|
1054 | + $this->y=$y; |
|
1055 | + } else { |
|
1056 | + $this->y=$this->h+$y; |
|
1057 | + } |
|
1058 | + } |
|
984 | 1059 | |
985 | 1060 | function SetXY($x, $y) |
986 | 1061 | { |
@@ -992,8 +1067,9 @@ discard block |
||
992 | 1067 | function Output($name='', $dest='') |
993 | 1068 | { |
994 | 1069 | //Output PDF to some destination |
995 | - if($this->state<3) |
|
996 | - $this->Close(); |
|
1070 | + if($this->state<3) { |
|
1071 | + $this->Close(); |
|
1072 | + } |
|
997 | 1073 | $dest=strtoupper($dest); |
998 | 1074 | if($dest=='') |
999 | 1075 | { |
@@ -1001,22 +1077,24 @@ discard block |
||
1001 | 1077 | { |
1002 | 1078 | $name='doc.pdf'; |
1003 | 1079 | $dest='I'; |
1080 | + } else { |
|
1081 | + $dest='F'; |
|
1004 | 1082 | } |
1005 | - else |
|
1006 | - $dest='F'; |
|
1007 | 1083 | } |
1008 | 1084 | switch($dest) |
1009 | 1085 | { |
1010 | 1086 | case 'I': |
1011 | 1087 | //Send to standard output |
1012 | - if(ob_get_length()) |
|
1013 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1088 | + if(ob_get_length()) { |
|
1089 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1090 | + } |
|
1014 | 1091 | if(php_sapi_name()!='cli') |
1015 | 1092 | { |
1016 | 1093 | //We send to a browser |
1017 | 1094 | header('Content-Type: application/pdf'); |
1018 | - if(headers_sent()) |
|
1019 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1095 | + if(headers_sent()) { |
|
1096 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1097 | + } |
|
1020 | 1098 | header('Content-Length: '.strlen($this->buffer)); |
1021 | 1099 | header('Content-Disposition: inline; filename="'.$name.'"'); |
1022 | 1100 | header('Cache-Control: private, max-age=0, must-revalidate'); |
@@ -1027,11 +1105,13 @@ discard block |
||
1027 | 1105 | break; |
1028 | 1106 | case 'D': |
1029 | 1107 | //Download file |
1030 | - if(ob_get_length()) |
|
1031 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1108 | + if(ob_get_length()) { |
|
1109 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1110 | + } |
|
1032 | 1111 | header('Content-Type: application/x-download'); |
1033 | - if(headers_sent()) |
|
1034 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1112 | + if(headers_sent()) { |
|
1113 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
1114 | + } |
|
1035 | 1115 | header('Content-Length: '.strlen($this->buffer)); |
1036 | 1116 | header('Content-Disposition: attachment; filename="'.$name.'"'); |
1037 | 1117 | header('Cache-Control: private, max-age=0, must-revalidate'); |
@@ -1042,8 +1122,9 @@ discard block |
||
1042 | 1122 | case 'F': |
1043 | 1123 | //Save to local file |
1044 | 1124 | $f=fopen($name,'wb'); |
1045 | - if(!$f) |
|
1046 | - $this->Error('Unable to create output file: '.$name); |
|
1125 | + if(!$f) { |
|
1126 | + $this->Error('Unable to create output file: '.$name); |
|
1127 | + } |
|
1047 | 1128 | fwrite($f,$this->buffer,strlen($this->buffer)); |
1048 | 1129 | fclose($f); |
1049 | 1130 | break; |
@@ -1064,29 +1145,34 @@ discard block |
||
1064 | 1145 | function _dochecks() |
1065 | 1146 | { |
1066 | 1147 | //Check availability of %F |
1067 | - if(sprintf('%.1F',1.0)!='1.0') |
|
1068 | - $this->Error('This version of PHP is not supported'); |
|
1148 | + if(sprintf('%.1F',1.0)!='1.0') { |
|
1149 | + $this->Error('This version of PHP is not supported'); |
|
1150 | + } |
|
1069 | 1151 | //Check mbstring overloading |
1070 | - if(ini_get('mbstring.func_overload') & 2) |
|
1071 | - $this->Error('mbstring overloading must be disabled'); |
|
1152 | + if(ini_get('mbstring.func_overload') & 2) { |
|
1153 | + $this->Error('mbstring overloading must be disabled'); |
|
1154 | + } |
|
1072 | 1155 | //Disable runtime magic quotes |
1073 | - if(get_magic_quotes_runtime()) |
|
1074 | - @set_magic_quotes_runtime(0); |
|
1075 | -} |
|
1156 | + if(get_magic_quotes_runtime()) { |
|
1157 | + @set_magic_quotes_runtime(0); |
|
1158 | + } |
|
1159 | + } |
|
1076 | 1160 | |
1077 | 1161 | function _getpageformat($format) |
1078 | 1162 | { |
1079 | 1163 | $format=strtolower($format); |
1080 | - if(!isset($this->PageFormats[$format])) |
|
1081 | - $this->Error('Unknown page format: '.$format); |
|
1164 | + if(!isset($this->PageFormats[$format])) { |
|
1165 | + $this->Error('Unknown page format: '.$format); |
|
1166 | + } |
|
1082 | 1167 | $a=$this->PageFormats[$format]; |
1083 | 1168 | return array($a[0]/$this->k, $a[1]/$this->k); |
1084 | 1169 | } |
1085 | 1170 | |
1086 | 1171 | function _getfontpath() |
1087 | 1172 | { |
1088 | - if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) |
|
1089 | - define('FPDF_FONTPATH',dirname(__FILE__).'/font/'); |
|
1173 | + if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) { |
|
1174 | + define('FPDF_FONTPATH',dirname(__FILE__).'/font/'); |
|
1175 | + } |
|
1090 | 1176 | return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : ''; |
1091 | 1177 | } |
1092 | 1178 | |
@@ -1099,16 +1185,18 @@ discard block |
||
1099 | 1185 | $this->y=$this->tMargin; |
1100 | 1186 | $this->FontFamily=''; |
1101 | 1187 | //Check page size |
1102 | - if($orientation=='') |
|
1103 | - $orientation=$this->DefOrientation; |
|
1104 | - else |
|
1105 | - $orientation=strtoupper($orientation[0]); |
|
1106 | - if($format=='') |
|
1107 | - $format=$this->DefPageFormat; |
|
1108 | - else |
|
1188 | + if($orientation=='') { |
|
1189 | + $orientation=$this->DefOrientation; |
|
1190 | + } else { |
|
1191 | + $orientation=strtoupper($orientation[0]); |
|
1192 | + } |
|
1193 | + if($format=='') { |
|
1194 | + $format=$this->DefPageFormat; |
|
1195 | + } else |
|
1109 | 1196 | { |
1110 | - if(is_string($format)) |
|
1111 | - $format=$this->_getpageformat($format); |
|
1197 | + if(is_string($format)) { |
|
1198 | + $format=$this->_getpageformat($format); |
|
1199 | + } |
|
1112 | 1200 | } |
1113 | 1201 | if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) |
1114 | 1202 | { |
@@ -1117,8 +1205,7 @@ discard block |
||
1117 | 1205 | { |
1118 | 1206 | $this->w=$format[0]; |
1119 | 1207 | $this->h=$format[1]; |
1120 | - } |
|
1121 | - else |
|
1208 | + } else |
|
1122 | 1209 | { |
1123 | 1210 | $this->w=$format[1]; |
1124 | 1211 | $this->h=$format[0]; |
@@ -1129,9 +1216,10 @@ discard block |
||
1129 | 1216 | $this->CurOrientation=$orientation; |
1130 | 1217 | $this->CurPageFormat=$format; |
1131 | 1218 | } |
1132 | - if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) |
|
1133 | - $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); |
|
1134 | -} |
|
1219 | + if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) { |
|
1220 | + $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); |
|
1221 | + } |
|
1222 | + } |
|
1135 | 1223 | |
1136 | 1224 | function _endpage() |
1137 | 1225 | { |
@@ -1170,15 +1258,13 @@ discard block |
||
1170 | 1258 | $c3=ord($s[$i++]); |
1171 | 1259 | $res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
1172 | 1260 | $res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
1173 | - } |
|
1174 | - elseif($c1>=192) |
|
1261 | + } elseif($c1>=192) |
|
1175 | 1262 | { |
1176 | 1263 | //2-byte character |
1177 | 1264 | $c2=ord($s[$i++]); |
1178 | 1265 | $res.=chr(($c1 & 0x1C)>>2); |
1179 | 1266 | $res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
1180 | - } |
|
1181 | - else |
|
1267 | + } else |
|
1182 | 1268 | { |
1183 | 1269 | //Single-byte character |
1184 | 1270 | $res.="\0".chr($c1); |
@@ -1200,22 +1286,26 @@ discard block |
||
1200 | 1286 | { |
1201 | 1287 | //Extract info from a JPEG file |
1202 | 1288 | $a=GetImageSize($file); |
1203 | - if(!$a) |
|
1204 | - $this->Error('Missing or incorrect image file: '.$file); |
|
1205 | - if($a[2]!=2) |
|
1206 | - $this->Error('Not a JPEG file: '.$file); |
|
1207 | - if(!isset($a['channels']) || $a['channels']==3) |
|
1208 | - $colspace='DeviceRGB'; |
|
1209 | - elseif($a['channels']==4) |
|
1210 | - $colspace='DeviceCMYK'; |
|
1211 | - else |
|
1212 | - $colspace='DeviceGray'; |
|
1289 | + if(!$a) { |
|
1290 | + $this->Error('Missing or incorrect image file: '.$file); |
|
1291 | + } |
|
1292 | + if($a[2]!=2) { |
|
1293 | + $this->Error('Not a JPEG file: '.$file); |
|
1294 | + } |
|
1295 | + if(!isset($a['channels']) || $a['channels']==3) { |
|
1296 | + $colspace='DeviceRGB'; |
|
1297 | + } elseif($a['channels']==4) { |
|
1298 | + $colspace='DeviceCMYK'; |
|
1299 | + } else { |
|
1300 | + $colspace='DeviceGray'; |
|
1301 | + } |
|
1213 | 1302 | $bpc=isset($a['bits']) ? $a['bits'] : 8; |
1214 | 1303 | //Read whole file |
1215 | 1304 | $f=fopen($file,'rb'); |
1216 | 1305 | $data=''; |
1217 | - while(!feof($f)) |
|
1218 | - $data.=fread($f,8192); |
|
1306 | + while(!feof($f)) { |
|
1307 | + $data.=fread($f,8192); |
|
1308 | + } |
|
1219 | 1309 | fclose($f); |
1220 | 1310 | return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); |
1221 | 1311 | } |
@@ -1224,35 +1314,43 @@ discard block |
||
1224 | 1314 | { |
1225 | 1315 | //Extract info from a PNG file |
1226 | 1316 | $f=fopen($file,'rb'); |
1227 | - if(!$f) |
|
1228 | - $this->Error('Can\'t open image file: '.$file); |
|
1317 | + if(!$f) { |
|
1318 | + $this->Error('Can\'t open image file: '.$file); |
|
1319 | + } |
|
1229 | 1320 | //Check signature |
1230 | - if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
1231 | - $this->Error('Not a PNG file: '.$file); |
|
1321 | + if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { |
|
1322 | + $this->Error('Not a PNG file: '.$file); |
|
1323 | + } |
|
1232 | 1324 | //Read header chunk |
1233 | 1325 | $this->_readstream($f,4); |
1234 | - if($this->_readstream($f,4)!='IHDR') |
|
1235 | - $this->Error('Incorrect PNG file: '.$file); |
|
1326 | + if($this->_readstream($f,4)!='IHDR') { |
|
1327 | + $this->Error('Incorrect PNG file: '.$file); |
|
1328 | + } |
|
1236 | 1329 | $w=$this->_readint($f); |
1237 | 1330 | $h=$this->_readint($f); |
1238 | 1331 | $bpc=ord($this->_readstream($f,1)); |
1239 | - if($bpc>8) |
|
1240 | - $this->Error('16-bit depth not supported: '.$file); |
|
1332 | + if($bpc>8) { |
|
1333 | + $this->Error('16-bit depth not supported: '.$file); |
|
1334 | + } |
|
1241 | 1335 | $ct=ord($this->_readstream($f,1)); |
1242 | - if($ct==0) |
|
1243 | - $colspace='DeviceGray'; |
|
1244 | - elseif($ct==2) |
|
1245 | - $colspace='DeviceRGB'; |
|
1246 | - elseif($ct==3) |
|
1247 | - $colspace='Indexed'; |
|
1248 | - else |
|
1249 | - $this->Error('Alpha channel not supported: '.$file); |
|
1250 | - if(ord($this->_readstream($f,1))!=0) |
|
1251 | - $this->Error('Unknown compression method: '.$file); |
|
1252 | - if(ord($this->_readstream($f,1))!=0) |
|
1253 | - $this->Error('Unknown filter method: '.$file); |
|
1254 | - if(ord($this->_readstream($f,1))!=0) |
|
1255 | - $this->Error('Interlacing not supported: '.$file); |
|
1336 | + if($ct==0) { |
|
1337 | + $colspace='DeviceGray'; |
|
1338 | + } elseif($ct==2) { |
|
1339 | + $colspace='DeviceRGB'; |
|
1340 | + } elseif($ct==3) { |
|
1341 | + $colspace='Indexed'; |
|
1342 | + } else { |
|
1343 | + $this->Error('Alpha channel not supported: '.$file); |
|
1344 | + } |
|
1345 | + if(ord($this->_readstream($f,1))!=0) { |
|
1346 | + $this->Error('Unknown compression method: '.$file); |
|
1347 | + } |
|
1348 | + if(ord($this->_readstream($f,1))!=0) { |
|
1349 | + $this->Error('Unknown filter method: '.$file); |
|
1350 | + } |
|
1351 | + if(ord($this->_readstream($f,1))!=0) { |
|
1352 | + $this->Error('Interlacing not supported: '.$file); |
|
1353 | + } |
|
1256 | 1354 | $this->_readstream($f,4); |
1257 | 1355 | $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>'; |
1258 | 1356 | //Scan chunks looking for palette, transparency and image data |
@@ -1268,37 +1366,37 @@ discard block |
||
1268 | 1366 | //Read palette |
1269 | 1367 | $pal=$this->_readstream($f,$n); |
1270 | 1368 | $this->_readstream($f,4); |
1271 | - } |
|
1272 | - elseif($type=='tRNS') |
|
1369 | + } elseif($type=='tRNS') |
|
1273 | 1370 | { |
1274 | 1371 | //Read transparency info |
1275 | 1372 | $t=$this->_readstream($f,$n); |
1276 | - if($ct==0) |
|
1277 | - $trns=array(ord(substr($t,1,1))); |
|
1278 | - elseif($ct==2) |
|
1279 | - $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
1280 | - else |
|
1373 | + if($ct==0) { |
|
1374 | + $trns=array(ord(substr($t,1,1))); |
|
1375 | + } elseif($ct==2) { |
|
1376 | + $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
1377 | + } else |
|
1281 | 1378 | { |
1282 | 1379 | $pos=strpos($t,chr(0)); |
1283 | - if($pos!==false) |
|
1284 | - $trns=array($pos); |
|
1380 | + if($pos!==false) { |
|
1381 | + $trns=array($pos); |
|
1382 | + } |
|
1285 | 1383 | } |
1286 | 1384 | $this->_readstream($f,4); |
1287 | - } |
|
1288 | - elseif($type=='IDAT') |
|
1385 | + } elseif($type=='IDAT') |
|
1289 | 1386 | { |
1290 | 1387 | //Read image data block |
1291 | 1388 | $data.=$this->_readstream($f,$n); |
1292 | 1389 | $this->_readstream($f,4); |
1390 | + } elseif($type=='IEND') { |
|
1391 | + break; |
|
1392 | + } else { |
|
1393 | + $this->_readstream($f,$n+4); |
|
1293 | 1394 | } |
1294 | - elseif($type=='IEND') |
|
1295 | - break; |
|
1296 | - else |
|
1297 | - $this->_readstream($f,$n+4); |
|
1298 | 1395 | } |
1299 | 1396 | while($n); |
1300 | - if($colspace=='Indexed' && empty($pal)) |
|
1301 | - $this->Error('Missing palette in '.$file); |
|
1397 | + if($colspace=='Indexed' && empty($pal)) { |
|
1398 | + $this->Error('Missing palette in '.$file); |
|
1399 | + } |
|
1302 | 1400 | fclose($f); |
1303 | 1401 | return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data); |
1304 | 1402 | } |
@@ -1310,13 +1408,15 @@ discard block |
||
1310 | 1408 | while($n>0 && !feof($f)) |
1311 | 1409 | { |
1312 | 1410 | $s=fread($f,$n); |
1313 | - if($s===false) |
|
1314 | - $this->Error('Error while reading stream'); |
|
1411 | + if($s===false) { |
|
1412 | + $this->Error('Error while reading stream'); |
|
1413 | + } |
|
1315 | 1414 | $n-=strlen($s); |
1316 | 1415 | $res.=$s; |
1317 | 1416 | } |
1318 | - if($n>0) |
|
1319 | - $this->Error('Unexpected end of stream'); |
|
1417 | + if($n>0) { |
|
1418 | + $this->Error('Unexpected end of stream'); |
|
1419 | + } |
|
1320 | 1420 | return $res; |
1321 | 1421 | } |
1322 | 1422 | |
@@ -1330,19 +1430,24 @@ discard block |
||
1330 | 1430 | function _parsegif($file) |
1331 | 1431 | { |
1332 | 1432 | //Extract info from a GIF file (via PNG conversion) |
1333 | - if(!function_exists('imagepng')) |
|
1334 | - $this->Error('GD extension is required for GIF support'); |
|
1335 | - if(!function_exists('imagecreatefromgif')) |
|
1336 | - $this->Error('GD has no GIF read support'); |
|
1433 | + if(!function_exists('imagepng')) { |
|
1434 | + $this->Error('GD extension is required for GIF support'); |
|
1435 | + } |
|
1436 | + if(!function_exists('imagecreatefromgif')) { |
|
1437 | + $this->Error('GD has no GIF read support'); |
|
1438 | + } |
|
1337 | 1439 | $im=imagecreatefromgif($file); |
1338 | - if(!$im) |
|
1339 | - $this->Error('Missing or incorrect image file: '.$file); |
|
1440 | + if(!$im) { |
|
1441 | + $this->Error('Missing or incorrect image file: '.$file); |
|
1442 | + } |
|
1340 | 1443 | imageinterlace($im,0); |
1341 | 1444 | $tmp=tempnam('.','gif'); |
1342 | - if(!$tmp) |
|
1343 | - $this->Error('Unable to create a temporary file'); |
|
1344 | - if(!imagepng($im,$tmp)) |
|
1345 | - $this->Error('Error while saving to temporary file'); |
|
1445 | + if(!$tmp) { |
|
1446 | + $this->Error('Unable to create a temporary file'); |
|
1447 | + } |
|
1448 | + if(!imagepng($im,$tmp)) { |
|
1449 | + $this->Error('Error while saving to temporary file'); |
|
1450 | + } |
|
1346 | 1451 | imagedestroy($im); |
1347 | 1452 | $info=$this->_parsepng($tmp); |
1348 | 1453 | unlink($tmp); |
@@ -1367,11 +1472,12 @@ discard block |
||
1367 | 1472 | function _out($s) |
1368 | 1473 | { |
1369 | 1474 | //Add a line to the document |
1370 | - if($this->state==2) |
|
1371 | - $this->pages[$this->page].=$s."\n"; |
|
1372 | - else |
|
1373 | - $this->buffer.=$s."\n"; |
|
1374 | -} |
|
1475 | + if($this->state==2) { |
|
1476 | + $this->pages[$this->page].=$s."\n"; |
|
1477 | + } else { |
|
1478 | + $this->buffer.=$s."\n"; |
|
1479 | + } |
|
1480 | + } |
|
1375 | 1481 | |
1376 | 1482 | function _putpages() |
1377 | 1483 | { |
@@ -1379,15 +1485,15 @@ discard block |
||
1379 | 1485 | if(!empty($this->AliasNbPages)) |
1380 | 1486 | { |
1381 | 1487 | //Replace number of pages |
1382 | - for($n=1;$n<=$nb;$n++) |
|
1383 | - $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]); |
|
1488 | + for($n=1;$n<=$nb;$n++) { |
|
1489 | + $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]); |
|
1490 | + } |
|
1384 | 1491 | } |
1385 | 1492 | if($this->DefOrientation=='P') |
1386 | 1493 | { |
1387 | 1494 | $wPt=$this->DefPageFormat[0]*$this->k; |
1388 | 1495 | $hPt=$this->DefPageFormat[1]*$this->k; |
1389 | - } |
|
1390 | - else |
|
1496 | + } else |
|
1391 | 1497 | { |
1392 | 1498 | $wPt=$this->DefPageFormat[1]*$this->k; |
1393 | 1499 | $hPt=$this->DefPageFormat[0]*$this->k; |
@@ -1399,8 +1505,9 @@ discard block |
||
1399 | 1505 | $this->_newobj(); |
1400 | 1506 | $this->_out('<</Type /Page'); |
1401 | 1507 | $this->_out('/Parent 1 0 R'); |
1402 | - if(isset($this->PageSizes[$n])) |
|
1403 | - $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); |
|
1508 | + if(isset($this->PageSizes[$n])) { |
|
1509 | + $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); |
|
1510 | + } |
|
1404 | 1511 | $this->_out('/Resources 2 0 R'); |
1405 | 1512 | if(isset($this->PageLinks[$n])) |
1406 | 1513 | { |
@@ -1410,9 +1517,9 @@ discard block |
||
1410 | 1517 | { |
1411 | 1518 | $rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); |
1412 | 1519 | $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
1413 | - if(is_string($pl[4])) |
|
1414 | - $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
1415 | - else |
|
1520 | + if(is_string($pl[4])) { |
|
1521 | + $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
1522 | + } else |
|
1416 | 1523 | { |
1417 | 1524 | $l=$this->links[$pl[4]]; |
1418 | 1525 | $h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; |
@@ -1435,8 +1542,9 @@ discard block |
||
1435 | 1542 | $this->_out('1 0 obj'); |
1436 | 1543 | $this->_out('<</Type /Pages'); |
1437 | 1544 | $kids='/Kids ['; |
1438 | - for($i=0;$i<$nb;$i++) |
|
1439 | - $kids.=(3+2*$i).' 0 R '; |
|
1545 | + for($i=0;$i<$nb;$i++) { |
|
1546 | + $kids.=(3+2*$i).' 0 R '; |
|
1547 | + } |
|
1440 | 1548 | $this->_out($kids.']'); |
1441 | 1549 | $this->_out('/Count '.$nb); |
1442 | 1550 | $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt)); |
@@ -1461,10 +1569,12 @@ discard block |
||
1461 | 1569 | $this->FontFiles[$file]['n']=$this->n; |
1462 | 1570 | $font=''; |
1463 | 1571 | $f=fopen($this->_getfontpath().$file,'rb',1); |
1464 | - if(!$f) |
|
1465 | - $this->Error('Font file not found'); |
|
1466 | - while(!feof($f)) |
|
1467 | - $font.=fread($f,8192); |
|
1572 | + if(!$f) { |
|
1573 | + $this->Error('Font file not found'); |
|
1574 | + } |
|
1575 | + while(!feof($f)) { |
|
1576 | + $font.=fread($f,8192); |
|
1577 | + } |
|
1468 | 1578 | fclose($f); |
1469 | 1579 | $compressed=(substr($file,-2)=='.z'); |
1470 | 1580 | if(!$compressed && isset($info['length2'])) |
@@ -1482,11 +1592,13 @@ discard block |
||
1482 | 1592 | } |
1483 | 1593 | } |
1484 | 1594 | $this->_out('<</Length '.strlen($font)); |
1485 | - if($compressed) |
|
1486 | - $this->_out('/Filter /FlateDecode'); |
|
1595 | + if($compressed) { |
|
1596 | + $this->_out('/Filter /FlateDecode'); |
|
1597 | + } |
|
1487 | 1598 | $this->_out('/Length1 '.$info['length1']); |
1488 | - if(isset($info['length2'])) |
|
1489 | - $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
|
1599 | + if(isset($info['length2'])) { |
|
1600 | + $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
|
1601 | + } |
|
1490 | 1602 | $this->_out('>>'); |
1491 | 1603 | $this->_putstream($font); |
1492 | 1604 | $this->_out('endobj'); |
@@ -1504,12 +1616,12 @@ discard block |
||
1504 | 1616 | $this->_out('<</Type /Font'); |
1505 | 1617 | $this->_out('/BaseFont /'.$name); |
1506 | 1618 | $this->_out('/Subtype /Type1'); |
1507 | - if($name!='Symbol' && $name!='ZapfDingbats') |
|
1508 | - $this->_out('/Encoding /WinAnsiEncoding'); |
|
1619 | + if($name!='Symbol' && $name!='ZapfDingbats') { |
|
1620 | + $this->_out('/Encoding /WinAnsiEncoding'); |
|
1621 | + } |
|
1509 | 1622 | $this->_out('>>'); |
1510 | 1623 | $this->_out('endobj'); |
1511 | - } |
|
1512 | - elseif($type=='Type1' || $type=='TrueType') |
|
1624 | + } elseif($type=='Type1' || $type=='TrueType') |
|
1513 | 1625 | { |
1514 | 1626 | //Additional Type1 or TrueType font |
1515 | 1627 | $this->_newobj(); |
@@ -1521,10 +1633,11 @@ discard block |
||
1521 | 1633 | $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); |
1522 | 1634 | if($font['enc']) |
1523 | 1635 | { |
1524 | - if(isset($font['diff'])) |
|
1525 | - $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); |
|
1526 | - else |
|
1527 | - $this->_out('/Encoding /WinAnsiEncoding'); |
|
1636 | + if(isset($font['diff'])) { |
|
1637 | + $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); |
|
1638 | + } else { |
|
1639 | + $this->_out('/Encoding /WinAnsiEncoding'); |
|
1640 | + } |
|
1528 | 1641 | } |
1529 | 1642 | $this->_out('>>'); |
1530 | 1643 | $this->_out('endobj'); |
@@ -1532,27 +1645,30 @@ discard block |
||
1532 | 1645 | $this->_newobj(); |
1533 | 1646 | $cw=&$font['cw']; |
1534 | 1647 | $s='['; |
1535 | - for($i=32;$i<=255;$i++) |
|
1536 | - $s.=$cw[chr($i)].' '; |
|
1648 | + for($i=32;$i<=255;$i++) { |
|
1649 | + $s.=$cw[chr($i)].' '; |
|
1650 | + } |
|
1537 | 1651 | $this->_out($s.']'); |
1538 | 1652 | $this->_out('endobj'); |
1539 | 1653 | //Descriptor |
1540 | 1654 | $this->_newobj(); |
1541 | 1655 | $s='<</Type /FontDescriptor /FontName /'.$name; |
1542 | - foreach($font['desc'] as $k=>$v) |
|
1543 | - $s.=' /'.$k.' '.$v; |
|
1656 | + foreach($font['desc'] as $k=>$v) { |
|
1657 | + $s.=' /'.$k.' '.$v; |
|
1658 | + } |
|
1544 | 1659 | $file=$font['file']; |
1545 | - if($file) |
|
1546 | - $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
|
1660 | + if($file) { |
|
1661 | + $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
|
1662 | + } |
|
1547 | 1663 | $this->_out($s.'>>'); |
1548 | 1664 | $this->_out('endobj'); |
1549 | - } |
|
1550 | - else |
|
1665 | + } else |
|
1551 | 1666 | { |
1552 | 1667 | //Allow for additional types |
1553 | 1668 | $mtd='_put'.strtolower($type); |
1554 | - if(!method_exists($this,$mtd)) |
|
1555 | - $this->Error('Unsupported font type: '.$type); |
|
1669 | + if(!method_exists($this,$mtd)) { |
|
1670 | + $this->Error('Unsupported font type: '.$type); |
|
1671 | + } |
|
1556 | 1672 | $this->$mtd($font); |
1557 | 1673 | } |
1558 | 1674 | } |
@@ -1570,24 +1686,28 @@ discard block |
||
1570 | 1686 | $this->_out('/Subtype /Image'); |
1571 | 1687 | $this->_out('/Width '.$info['w']); |
1572 | 1688 | $this->_out('/Height '.$info['h']); |
1573 | - if($info['cs']=='Indexed') |
|
1574 | - $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
1575 | - else |
|
1689 | + if($info['cs']=='Indexed') { |
|
1690 | + $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
1691 | + } else |
|
1576 | 1692 | { |
1577 | 1693 | $this->_out('/ColorSpace /'.$info['cs']); |
1578 | - if($info['cs']=='DeviceCMYK') |
|
1579 | - $this->_out('/Decode [1 0 1 0 1 0 1 0]'); |
|
1694 | + if($info['cs']=='DeviceCMYK') { |
|
1695 | + $this->_out('/Decode [1 0 1 0 1 0 1 0]'); |
|
1696 | + } |
|
1580 | 1697 | } |
1581 | 1698 | $this->_out('/BitsPerComponent '.$info['bpc']); |
1582 | - if(isset($info['f'])) |
|
1583 | - $this->_out('/Filter /'.$info['f']); |
|
1584 | - if(isset($info['parms'])) |
|
1585 | - $this->_out($info['parms']); |
|
1699 | + if(isset($info['f'])) { |
|
1700 | + $this->_out('/Filter /'.$info['f']); |
|
1701 | + } |
|
1702 | + if(isset($info['parms'])) { |
|
1703 | + $this->_out($info['parms']); |
|
1704 | + } |
|
1586 | 1705 | if(isset($info['trns']) && is_array($info['trns'])) |
1587 | 1706 | { |
1588 | 1707 | $trns=''; |
1589 | - for($i=0;$i<count($info['trns']);$i++) |
|
1590 | - $trns.=$info['trns'][$i].' '.$info['trns'][$i].' '; |
|
1708 | + for($i=0;$i<count($info['trns']);$i++) { |
|
1709 | + $trns.=$info['trns'][$i].' '.$info['trns'][$i].' '; |
|
1710 | + } |
|
1591 | 1711 | $this->_out('/Mask ['.$trns.']'); |
1592 | 1712 | } |
1593 | 1713 | $this->_out('/Length '.strlen($info['data']).'>>'); |
@@ -1608,16 +1728,18 @@ discard block |
||
1608 | 1728 | |
1609 | 1729 | function _putxobjectdict() |
1610 | 1730 | { |
1611 | - foreach($this->images as $image) |
|
1612 | - $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
1613 | -} |
|
1731 | + foreach($this->images as $image) { |
|
1732 | + $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
1733 | + } |
|
1734 | + } |
|
1614 | 1735 | |
1615 | 1736 | function _putresourcedict() |
1616 | 1737 | { |
1617 | 1738 | $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
1618 | 1739 | $this->_out('/Font <<'); |
1619 | - foreach($this->fonts as $font) |
|
1620 | - $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
1740 | + foreach($this->fonts as $font) { |
|
1741 | + $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
1742 | + } |
|
1621 | 1743 | $this->_out('>>'); |
1622 | 1744 | $this->_out('/XObject <<'); |
1623 | 1745 | $this->_putxobjectdict(); |
@@ -1640,16 +1762,21 @@ discard block |
||
1640 | 1762 | function _putinfo() |
1641 | 1763 | { |
1642 | 1764 | $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION)); |
1643 | - if(!empty($this->title)) |
|
1644 | - $this->_out('/Title '.$this->_textstring($this->title)); |
|
1645 | - if(!empty($this->subject)) |
|
1646 | - $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
1647 | - if(!empty($this->author)) |
|
1648 | - $this->_out('/Author '.$this->_textstring($this->author)); |
|
1649 | - if(!empty($this->keywords)) |
|
1650 | - $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
1651 | - if(!empty($this->creator)) |
|
1652 | - $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
1765 | + if(!empty($this->title)) { |
|
1766 | + $this->_out('/Title '.$this->_textstring($this->title)); |
|
1767 | + } |
|
1768 | + if(!empty($this->subject)) { |
|
1769 | + $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
1770 | + } |
|
1771 | + if(!empty($this->author)) { |
|
1772 | + $this->_out('/Author '.$this->_textstring($this->author)); |
|
1773 | + } |
|
1774 | + if(!empty($this->keywords)) { |
|
1775 | + $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
1776 | + } |
|
1777 | + if(!empty($this->creator)) { |
|
1778 | + $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
1779 | + } |
|
1653 | 1780 | $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); |
1654 | 1781 | } |
1655 | 1782 | |
@@ -1657,21 +1784,23 @@ discard block |
||
1657 | 1784 | { |
1658 | 1785 | $this->_out('/Type /Catalog'); |
1659 | 1786 | $this->_out('/Pages 1 0 R'); |
1660 | - if($this->ZoomMode=='fullpage') |
|
1661 | - $this->_out('/OpenAction [3 0 R /Fit]'); |
|
1662 | - elseif($this->ZoomMode=='fullwidth') |
|
1663 | - $this->_out('/OpenAction [3 0 R /FitH null]'); |
|
1664 | - elseif($this->ZoomMode=='real') |
|
1665 | - $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); |
|
1666 | - elseif(!is_string($this->ZoomMode)) |
|
1667 | - $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); |
|
1668 | - if($this->LayoutMode=='single') |
|
1669 | - $this->_out('/PageLayout /SinglePage'); |
|
1670 | - elseif($this->LayoutMode=='continuous') |
|
1671 | - $this->_out('/PageLayout /OneColumn'); |
|
1672 | - elseif($this->LayoutMode=='two') |
|
1673 | - $this->_out('/PageLayout /TwoColumnLeft'); |
|
1674 | -} |
|
1787 | + if($this->ZoomMode=='fullpage') { |
|
1788 | + $this->_out('/OpenAction [3 0 R /Fit]'); |
|
1789 | + } elseif($this->ZoomMode=='fullwidth') { |
|
1790 | + $this->_out('/OpenAction [3 0 R /FitH null]'); |
|
1791 | + } elseif($this->ZoomMode=='real') { |
|
1792 | + $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); |
|
1793 | + } elseif(!is_string($this->ZoomMode)) { |
|
1794 | + $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); |
|
1795 | + } |
|
1796 | + if($this->LayoutMode=='single') { |
|
1797 | + $this->_out('/PageLayout /SinglePage'); |
|
1798 | + } elseif($this->LayoutMode=='continuous') { |
|
1799 | + $this->_out('/PageLayout /OneColumn'); |
|
1800 | + } elseif($this->LayoutMode=='two') { |
|
1801 | + $this->_out('/PageLayout /TwoColumnLeft'); |
|
1802 | + } |
|
1803 | + } |
|
1675 | 1804 | |
1676 | 1805 | function _putheader() |
1677 | 1806 | { |
@@ -1707,8 +1836,9 @@ discard block |
||
1707 | 1836 | $this->_out('xref'); |
1708 | 1837 | $this->_out('0 '.($this->n+1)); |
1709 | 1838 | $this->_out('0000000000 65535 f '); |
1710 | - for($i=1;$i<=$this->n;$i++) |
|
1711 | - $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
1839 | + for($i=1;$i<=$this->n;$i++) { |
|
1840 | + $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
1841 | + } |
|
1712 | 1842 | //Trailer |
1713 | 1843 | $this->_out('trailer'); |
1714 | 1844 | $this->_out('<<'); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | //if($user['level'] != "Manager") |
6 | 6 | //{ exit("You don't have permission to access this page!"); } |
7 | 7 | $ticket_list = $tickets->count_tickets_by_customer(); |
8 | -$i=0;$color[0]='FF0000';$color[1]='00FF00';$color[2]='FFFF00';$color[3]='0000FF';$color[4]='FF00FF'; |
|
8 | +$i = 0; $color[0] = 'FF0000'; $color[1] = '00FF00'; $color[2] = 'FFFF00'; $color[3] = '0000FF'; $color[4] = 'FF00FF'; |
|
9 | 9 | foreach ($ticket_list as $ticket) |
10 | 10 | { $customer = $customers->customer_data($ticket['idcustomer']); |
11 | 11 | //$datachart .= "<set value='$ticket[total]' name='$customer[namacustomer]' color='$color[$i]' />"; |
@@ -31,15 +31,15 @@ discard block |
||
31 | 31 | $arr_value2 = explode("#", $value2); |
32 | 32 | $arr_name2 = explode("#", $name2); |
33 | 33 | |
34 | -$ResolvedBulan=Array(0,0,0,0,0,0,0,0,0,0,0,0,0); |
|
34 | +$ResolvedBulan = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); |
|
35 | 35 | $ticket_list3 = $tickets->count_resolved_tickets_by_month(); |
36 | 36 | foreach ($ticket_list3 as $ticket3) |
37 | -{ @$ResolvedBulan[$ticket3['Bulan']]=$ticket3['Total']; |
|
37 | +{ @$ResolvedBulan[$ticket3['Bulan']] = $ticket3['Total']; |
|
38 | 38 | } |
39 | -$InProgressBulan=Array(0,0,0,0,0,0,0,0,0,0,0,0,0); |
|
39 | +$InProgressBulan = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); |
|
40 | 40 | $ticket_list4 = $tickets->count_inprogress_tickets_by_month(); |
41 | 41 | foreach ($ticket_list4 as $ticket4) |
42 | -{ @$InProgressBulan[$ticket4['Bulan']]=$ticket4['Total']; |
|
42 | +{ @$InProgressBulan[$ticket4['Bulan']] = $ticket4['Total']; |
|
43 | 43 | } |
44 | 44 | ?> |
45 | 45 | <!DOCTYPE html> |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | type: "Pie2D", |
72 | 72 | data: "<graph caption='Top 5 Ticket Received By Company' subcaption='This Year' decimalPrecision='0'" + |
73 | 73 | "bgColor='b9c9fe' baseFontSize='12' Bold='1' showNames='1' showPercentageInLabel='1'>" + |
74 | - "<set value='<?php echo $arr_value[0];?>' name='<?php echo $arr_name[0];?>' color='FF00FF' />" + |
|
75 | - "<set value='<?php echo $arr_value[1];?>' name='<?php echo $arr_name[1];?>' color='00FFFF' />" + |
|
76 | - "<set value='<?php echo $arr_value[2];?>' name='<?php echo $arr_name[2];?>' color='990000' />" + |
|
77 | - "<set value='<?php echo $arr_value[3];?>' name='<?php echo $arr_name[3];?>' color='660099' />" + |
|
78 | - "<set value='<?php echo $arr_value[4];?>' name='<?php echo $arr_name[4];?>' color='FF9900' /> </graph>", |
|
74 | + "<set value='<?php echo $arr_value[0]; ?>' name='<?php echo $arr_name[0]; ?>' color='FF00FF' />" + |
|
75 | + "<set value='<?php echo $arr_value[1]; ?>' name='<?php echo $arr_name[1]; ?>' color='00FFFF' />" + |
|
76 | + "<set value='<?php echo $arr_value[2]; ?>' name='<?php echo $arr_name[2]; ?>' color='990000' />" + |
|
77 | + "<set value='<?php echo $arr_value[3]; ?>' name='<?php echo $arr_name[3]; ?>' color='660099' />" + |
|
78 | + "<set value='<?php echo $arr_value[4]; ?>' name='<?php echo $arr_name[4]; ?>' color='FF9900' /> </graph>", |
|
79 | 79 | dataFormat: "XMLData", |
80 | 80 | width: "520", |
81 | 81 | height: "300" |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | type: "Pie2D", |
86 | 86 | data: "<graph caption='Ticket Received By Status' subcaption='This Year' decimalPrecision='0'" + |
87 | 87 | "bgColor='b9c9fe' baseFontSize='12' Bold='1' showNames='1' showPercentageInLabel='1'>" + |
88 | - "<set value='<?php echo $arr_value2[0];?>' name='<?php echo $arr_name2[0];?>' color='<?php echo $color[0];?>' />" + |
|
89 | - "<set value='<?php echo $arr_value2[1];?>' name='<?php echo $arr_name2[1];?>' color='<?php echo $color[1];?>' />" + |
|
90 | - "<set value='<?php echo $arr_value2[2];?>' name='<?php echo $arr_name2[2];?>' color='<?php echo $color[2];?>' />" + |
|
91 | - "<set value='<?php echo $arr_value2[3];?>' name='<?php echo $arr_name2[3];?>' color='<?php echo $color[3];?>' /> </graph>", |
|
88 | + "<set value='<?php echo $arr_value2[0]; ?>' name='<?php echo $arr_name2[0]; ?>' color='<?php echo $color[0]; ?>' />" + |
|
89 | + "<set value='<?php echo $arr_value2[1]; ?>' name='<?php echo $arr_name2[1]; ?>' color='<?php echo $color[1]; ?>' />" + |
|
90 | + "<set value='<?php echo $arr_value2[2]; ?>' name='<?php echo $arr_name2[2]; ?>' color='<?php echo $color[2]; ?>' />" + |
|
91 | + "<set value='<?php echo $arr_value2[3]; ?>' name='<?php echo $arr_name2[3]; ?>' color='<?php echo $color[3]; ?>' /> </graph>", |
|
92 | 92 | dataFormat: "XMLData", |
93 | 93 | width: "520", |
94 | 94 | height: "300" |
@@ -1,1 +1,1 @@ |
||
1 | -<?php require 'core/init.php'; $general->logged_out_protect(); $user = $users->userdata($_SESSION['loginid']); $fullname = ucwords(strtolower($user['fullname'])); ?> <!DOCTYPE HTML> <html> <head> <title>Helpdesk System</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="css/style.css" /> <script type="text/javascript" src="js/time.js"></script> </head> <body bgcolor="#bb2a26" onload="startTime();"> <table class="header"> <tr> <td width="120px"><img src="images/company-logo.png" alt="Company-Logo" width="120px" height="30px" align="middle"></td> <td width="200px"><strong>HELPDESK SYSTEM</strong></td> <td align="right"><span id="clocktime"></span><span id="welcome"><?php echo " :: Welcome $fullname "; ?> </span></td> </tr> <tr><td colspan="3"> <div id='topmenu'> <ul> <li class='active'><a href='home.php' target="_parent"><span>Home</span></a></li> <li><a href='ticketnew.php' target="contentFrame"><span>New Ticket</span></a></li> <?php if ($user['level'] == "Admin") { echo "<li><a href='adminmenu.php' target='leftFrame'><span>Admin</span></a></li>"; } ?> <li><a href='changepwd.php' target="contentFrame"><span>Change Password</span></a></li> <li class='last'><a href='logout.php' target="_parent"><span>Logout</span></a></li> </ul> </div> </td></tr> </table> <div style="clear:both; margin: 0 0 0px 0;"> </div> </body> </html> |
|
2 | 1 | \ No newline at end of file |
2 | +<?php require 'core/init.php'; $general->logged_out_protect(); $user = $users->userdata($_SESSION['loginid']); $fullname = ucwords(strtolower($user['fullname'])); ?> <!DOCTYPE HTML> <html> <head> <title>Helpdesk System</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="css/style.css" /> <script type="text/javascript" src="js/time.js"></script> </head> <body bgcolor="#bb2a26" onload="startTime();"> <table class="header"> <tr> <td width="120px"><img src="images/company-logo.png" alt="Company-Logo" width="120px" height="30px" align="middle"></td> <td width="200px"><strong>HELPDESK SYSTEM</strong></td> <td align="right"><span id="clocktime"></span><span id="welcome"><?php echo " :: Welcome $fullname "; ?> </span></td> </tr> <tr><td colspan="3"> <div id='topmenu'> <ul> <li class='active'><a href='home.php' target="_parent"><span>Home</span></a></li> <li><a href='ticketnew.php' target="contentFrame"><span>New Ticket</span></a></li> <?php if ($user['level'] == "Admin") { echo "<li><a href='adminmenu.php' target='leftFrame'><span>Admin</span></a></li>"; } ?> <li><a href='changepwd.php' target="contentFrame"><span>Change Password</span></a></li> <li class='last'><a href='logout.php' target="_parent"><span>Logout</span></a></li> </ul> </div> </td></tr> </table> <div style="clear:both; margin: 0 0 0px 0;"> </div> </body> </html> |
|
3 | 3 | \ No newline at end of file |
@@ -7,18 +7,18 @@ discard block |
||
7 | 7 | $password = strip_tags(addslashes(trim($_POST['password']))); |
8 | 8 | if (empty($username) === true || empty($password) === true) { |
9 | 9 | $errors[] = 'Sorry, but we need your username and password.'; |
10 | - } else if ($users->user_exists($username) === false) { |
|
10 | + }else if ($users->user_exists($username) === false) { |
|
11 | 11 | $errors[] = 'Sorry, that username doesn\'t exists. Please try again.'; |
12 | 12 | } |
13 | 13 | else |
14 | 14 | { $login = $users->login($username, $password); |
15 | 15 | if ($login === false) { |
16 | 16 | $errors[] = 'Sorry, that username/password is invalid. Please try again.'; |
17 | - }else if (!$users->email_confirmed($username)){ |
|
17 | + }else if (!$users->email_confirmed($username)) { |
|
18 | 18 | $errors[] = 'Sorry, your account is locked. Please contact Administrator.'; |
19 | 19 | }else { |
20 | - $_SESSION['loginid'] = $login; |
|
21 | - $users->log_users($login,'Login to Helpdesk System'); |
|
20 | + $_SESSION['loginid'] = $login; |
|
21 | + $users->log_users($login, 'Login to Helpdesk System'); |
|
22 | 22 | echo $login; |
23 | 23 | header('location: home.php'); |
24 | 24 | exit(); |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | </table> |
58 | 58 | </div> |
59 | 59 | <?php |
60 | - if(empty($errors) === false){ |
|
61 | - echo '<p class="errormsg">' . implode('</p><p class="errormsg">', $errors) . '</p>'; |
|
60 | + if (empty($errors) === false) { |
|
61 | + echo '<p class="errormsg">'.implode('</p><p class="errormsg">', $errors).'</p>'; |
|
62 | 62 | } |
63 | 63 | ?> |
64 | 64 | <div class="footer"> |
@@ -9,14 +9,13 @@ |
||
9 | 9 | $errors[] = 'Sorry, but we need your username and password.'; |
10 | 10 | } else if ($users->user_exists($username) === false) { |
11 | 11 | $errors[] = 'Sorry, that username doesn\'t exists. Please try again.'; |
12 | - } |
|
13 | - else |
|
12 | + } else |
|
14 | 13 | { $login = $users->login($username, $password); |
15 | 14 | if ($login === false) { |
16 | 15 | $errors[] = 'Sorry, that username/password is invalid. Please try again.'; |
17 | - }else if (!$users->email_confirmed($username)){ |
|
16 | + } else if (!$users->email_confirmed($username)){ |
|
18 | 17 | $errors[] = 'Sorry, your account is locked. Please contact Administrator.'; |
19 | - }else { |
|
18 | + } else { |
|
20 | 19 | $_SESSION['loginid'] = $login; |
21 | 20 | $users->log_users($login,'Login to Helpdesk System'); |
22 | 21 | echo $login; |