@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | /** |
| 347 | 347 | * Constructor - starts a new document |
| 348 | 348 | * |
| 349 | - * @param array $pageSize Array of 4 numbers, defining the bottom left and upper right corner of the page. first two are normally zero. |
|
| 349 | + * @param integer[] $pageSize Array of 4 numbers, defining the bottom left and upper right corner of the page. first two are normally zero. |
|
| 350 | 350 | * |
| 351 | 351 | * @return void |
| 352 | 352 | */ |
@@ -384,6 +384,8 @@ discard block |
||
| 384 | 384 | /** |
| 385 | 385 | * destination object, used to specify the location for the user to jump to, presently on opening |
| 386 | 386 | * @access private |
| 387 | + * @param integer $id |
|
| 388 | + * @param string $action |
|
| 387 | 389 | */ |
| 388 | 390 | private function o_destination($id, $action, $options = '') |
| 389 | 391 | { |
@@ -421,6 +423,7 @@ discard block |
||
| 421 | 423 | /** |
| 422 | 424 | * sets the viewer preferences |
| 423 | 425 | * @access private |
| 426 | + * @param string $action |
|
| 424 | 427 | */ |
| 425 | 428 | private function o_viewerPreferences($id, $action, $options = '') |
| 426 | 429 | { |
@@ -461,6 +464,8 @@ discard block |
||
| 461 | 464 | /** |
| 462 | 465 | * define the document catalog, the overall controller for the document |
| 463 | 466 | * @access private |
| 467 | + * @param integer $id |
|
| 468 | + * @param string $action |
|
| 464 | 469 | */ |
| 465 | 470 | private function o_catalog($id, $action, $options = '') |
| 466 | 471 | { |
@@ -513,6 +518,8 @@ discard block |
||
| 513 | 518 | /** |
| 514 | 519 | * object which is a parent to the pages in the document |
| 515 | 520 | * @access private |
| 521 | + * @param integer $id |
|
| 522 | + * @param string $action |
|
| 516 | 523 | */ |
| 517 | 524 | private function o_pages($id, $action, $options = '') |
| 518 | 525 | { |
@@ -633,6 +640,8 @@ discard block |
||
| 633 | 640 | /** |
| 634 | 641 | * defines the outlines in the doc, empty for now |
| 635 | 642 | * @access private |
| 643 | + * @param integer $id |
|
| 644 | + * @param string $action |
|
| 636 | 645 | */ |
| 637 | 646 | private function o_outlines($id, $action, $options = '') |
| 638 | 647 | { |
@@ -665,6 +674,8 @@ discard block |
||
| 665 | 674 | /** |
| 666 | 675 | * an object to hold the font description |
| 667 | 676 | * @access private |
| 677 | + * @param integer $id |
|
| 678 | + * @param string $action |
|
| 668 | 679 | */ |
| 669 | 680 | private function o_font($id, $action, $options = '') |
| 670 | 681 | { |
@@ -851,6 +862,8 @@ discard block |
||
| 851 | 862 | /** |
| 852 | 863 | * a font descriptor, needed for including additional fonts |
| 853 | 864 | * @access private |
| 865 | + * @param integer $id |
|
| 866 | + * @param string $action |
|
| 854 | 867 | */ |
| 855 | 868 | private function o_fontDescriptor($id, $action, $options = '') |
| 856 | 869 | { |
@@ -904,6 +917,8 @@ discard block |
||
| 904 | 917 | /** |
| 905 | 918 | * the font encoding |
| 906 | 919 | * @access private |
| 920 | + * @param integer $id |
|
| 921 | + * @param string $action |
|
| 907 | 922 | */ |
| 908 | 923 | private function o_fontEncoding($id, $action, $options = '') |
| 909 | 924 | { |
@@ -943,6 +958,7 @@ discard block |
||
| 943 | 958 | /** |
| 944 | 959 | * a descendent cid font, needed for unicode fonts |
| 945 | 960 | * @access private |
| 961 | + * @param string $action |
|
| 946 | 962 | */ |
| 947 | 963 | private function o_fontDescendentCID($id, $action, $options = '') |
| 948 | 964 | { |
@@ -1018,6 +1034,7 @@ discard block |
||
| 1018 | 1034 | /** |
| 1019 | 1035 | * a font glyph to character map, needed for unicode fonts |
| 1020 | 1036 | * @access private |
| 1037 | + * @param string $action |
|
| 1021 | 1038 | */ |
| 1022 | 1039 | private function o_fontGIDtoCIDMap($id, $action, $options = '') |
| 1023 | 1040 | { |
@@ -1056,6 +1073,7 @@ discard block |
||
| 1056 | 1073 | /** |
| 1057 | 1074 | * define the document information |
| 1058 | 1075 | * @access private |
| 1076 | + * @param integer $id |
|
| 1059 | 1077 | */ |
| 1060 | 1078 | private function o_info($id, $action, $options = '') |
| 1061 | 1079 | { |
@@ -1102,6 +1120,8 @@ discard block |
||
| 1102 | 1120 | /** |
| 1103 | 1121 | * an action object, used to link to URLS initially |
| 1104 | 1122 | * @access private |
| 1123 | + * @param integer $id |
|
| 1124 | + * @param string $action |
|
| 1105 | 1125 | */ |
| 1106 | 1126 | private function o_action($id, $action, $options = '') |
| 1107 | 1127 | { |
@@ -1147,6 +1167,8 @@ discard block |
||
| 1147 | 1167 | * an annotation object, this will add an annotation to the current page. |
| 1148 | 1168 | * initially will support just link annotations |
| 1149 | 1169 | * @access private |
| 1170 | + * @param integer $id |
|
| 1171 | + * @param string $action |
|
| 1150 | 1172 | */ |
| 1151 | 1173 | private function o_annotation($id, $action, $options = '') |
| 1152 | 1174 | { |
@@ -1201,6 +1223,7 @@ discard block |
||
| 1201 | 1223 | /** |
| 1202 | 1224 | * a page object, it also creates a contents object to hold its contents |
| 1203 | 1225 | * @access private |
| 1226 | + * @param string $action |
|
| 1204 | 1227 | */ |
| 1205 | 1228 | private function o_page($id, $action, $options = '') |
| 1206 | 1229 | { |
@@ -1272,6 +1295,7 @@ discard block |
||
| 1272 | 1295 | /** |
| 1273 | 1296 | * the contents objects hold all of the content which appears on pages |
| 1274 | 1297 | * @access private |
| 1298 | + * @param string $action |
|
| 1275 | 1299 | */ |
| 1276 | 1300 | private function o_contents($id, $action, $options = '') |
| 1277 | 1301 | { |
@@ -1324,6 +1348,8 @@ discard block |
||
| 1324 | 1348 | /** |
| 1325 | 1349 | * an image object, will be an XObject in the document, includes description and data |
| 1326 | 1350 | * @access private |
| 1351 | + * @param integer $id |
|
| 1352 | + * @param string $action |
|
| 1327 | 1353 | */ |
| 1328 | 1354 | private function o_image($id, $action, $options = '') |
| 1329 | 1355 | { |
@@ -1402,6 +1428,8 @@ discard block |
||
| 1402 | 1428 | /** |
| 1403 | 1429 | * encryption object. |
| 1404 | 1430 | * @access private |
| 1431 | + * @param integer $id |
|
| 1432 | + * @param string $action |
|
| 1405 | 1433 | */ |
| 1406 | 1434 | private function o_encryption($id, $action, $options = '') |
| 1407 | 1435 | { |
@@ -1458,8 +1486,8 @@ discard block |
||
| 1458 | 1486 | |
| 1459 | 1487 | /** |
| 1460 | 1488 | * owner part of the encryption |
| 1461 | - * @param $owner - owner password plus padding |
|
| 1462 | - * @param $user - user password plus padding |
|
| 1489 | + * @param string $owner - owner password plus padding |
|
| 1490 | + * @param string $user - user password plus padding |
|
| 1463 | 1491 | * @access private |
| 1464 | 1492 | */ |
| 1465 | 1493 | private function encryptOwner($owner, $user) |
@@ -1498,9 +1526,9 @@ discard block |
||
| 1498 | 1526 | /** |
| 1499 | 1527 | * |
| 1500 | 1528 | * user part of the encryption |
| 1501 | - * @param $user - user password plus padding |
|
| 1502 | - * @param $ownerDict - encrypted owner entry |
|
| 1503 | - * @param $permissions - permission set (print, copy, modify, ...) |
|
| 1529 | + * @param string $user - user password plus padding |
|
| 1530 | + * @param string $ownerDict - encrypted owner entry |
|
| 1531 | + * @param string $permissions - permission set (print, copy, modify, ...) |
|
| 1504 | 1532 | */ |
| 1505 | 1533 | function encryptUser($user, $ownerDict, $permissions) |
| 1506 | 1534 | { |
@@ -1563,6 +1591,9 @@ discard block |
||
| 1563 | 1591 | return $hex; |
| 1564 | 1592 | } |
| 1565 | 1593 | |
| 1594 | + /** |
|
| 1595 | + * @param string $hex |
|
| 1596 | + */ |
|
| 1566 | 1597 | protected function hexToStr($hex) |
| 1567 | 1598 | { |
| 1568 | 1599 | $str = ''; |
@@ -2005,7 +2036,7 @@ discard block |
||
| 2005 | 2036 | * @param string $encoding Which encoding to use |
| 2006 | 2037 | * @param integer $set What is this |
| 2007 | 2038 | * |
| 2008 | - * @return void |
|
| 2039 | + * @return integer |
|
| 2009 | 2040 | * @access public |
| 2010 | 2041 | */ |
| 2011 | 2042 | public function selectFont($fontName, $encoding = '', $set = 1, $subsetFont = false) |
@@ -2331,6 +2362,11 @@ discard block |
||
| 2331 | 2362 | /** |
| 2332 | 2363 | * draw a part of an ellipse |
| 2333 | 2364 | * @access public |
| 2365 | + * @param integer $x0 |
|
| 2366 | + * @param integer $y0 |
|
| 2367 | + * @param integer $astart |
|
| 2368 | + * @param integer $afinish |
|
| 2369 | + * @param integer $r1 |
|
| 2334 | 2370 | */ |
| 2335 | 2371 | public function partEllipse($x0, $y0, $astart, $afinish, $r1, $r2 = 0, $angle = 0, $nSeg = 8) |
| 2336 | 2372 | { |
@@ -2494,6 +2530,7 @@ discard block |
||
| 2494 | 2530 | * draw a rectangle, note that it is the width and height of the rectangle which are the secondary paramaters, not |
| 2495 | 2531 | * the coordinates of the upper-right corner |
| 2496 | 2532 | * @access public |
| 2533 | + * @param integer $height |
|
| 2497 | 2534 | */ |
| 2498 | 2535 | public function rectangle($x1, $y1, $width, $height) |
| 2499 | 2536 | { |
@@ -2593,6 +2630,7 @@ discard block |
||
| 2593 | 2630 | /** |
| 2594 | 2631 | * return the height in units of the current font in the given size |
| 2595 | 2632 | * @access public |
| 2633 | + * @param integer $size |
|
| 2596 | 2634 | */ |
| 2597 | 2635 | public function getFontHeight($size) |
| 2598 | 2636 | { |
@@ -2611,6 +2649,7 @@ discard block |
||
| 2611 | 2649 | * if you add this number to the baseline, you get the level of the bottom of the font |
| 2612 | 2650 | * it is in the pdf user units |
| 2613 | 2651 | * @access public |
| 2652 | + * @param integer $size |
|
| 2614 | 2653 | */ |
| 2615 | 2654 | public function getFontDecender($size) |
| 2616 | 2655 | { |
@@ -2775,6 +2814,8 @@ discard block |
||
| 2775 | 2814 | * on the page the text will end |
| 2776 | 2815 | * |
| 2777 | 2816 | * @access protected |
| 2817 | + * @param integer $angle |
|
| 2818 | + * @param integer $wa |
|
| 2778 | 2819 | */ |
| 2779 | 2820 | protected function getTextPosition($x, $y, $angle, $size, $wa, $text) |
| 2780 | 2821 | { |
@@ -2792,6 +2833,7 @@ discard block |
||
| 2792 | 2833 | * wrapper function for checkTextDirective1 |
| 2793 | 2834 | * |
| 2794 | 2835 | * @access private |
| 2836 | + * @param integer $f |
|
| 2795 | 2837 | */ |
| 2796 | 2838 | private function checkTextDirective(&$text, $i, &$f) |
| 2797 | 2839 | { |
@@ -2808,6 +2850,7 @@ discard block |
||
| 2808 | 2850 | * if the directive does not require a font change, then $f should be set to 0 |
| 2809 | 2851 | * |
| 2810 | 2852 | * @access private |
| 2853 | + * @param integer $final |
|
| 2811 | 2854 | */ |
| 2812 | 2855 | private function checkTextDirective1(&$text, $i, &$f, $final, &$x, &$y, $size = 0, $angle = 0, $wordSpaceAdjust = 0) |
| 2813 | 2856 | { |
@@ -3132,6 +3175,8 @@ discard block |
||
| 3132 | 3175 | * do a part of the calculation for sorting out the justification of the text |
| 3133 | 3176 | * |
| 3134 | 3177 | * @access private |
| 3178 | + * @param integer $adjust |
|
| 3179 | + * @param string $justification |
|
| 3135 | 3180 | */ |
| 3136 | 3181 | private function adjustWrapText($text, $actual, $width, &$x, &$adjust, $justification) |
| 3137 | 3182 | { |
@@ -3393,6 +3438,7 @@ discard block |
||
| 3393 | 3438 | /** |
| 3394 | 3439 | * after an object has been created, it wil only show if it has been added, using this function. |
| 3395 | 3440 | * @access public |
| 3441 | + * @param integer $id |
|
| 3396 | 3442 | */ |
| 3397 | 3443 | public function addObject($id, $options = 'add') |
| 3398 | 3444 | { |
@@ -3477,6 +3523,8 @@ discard block |
||
| 3477 | 3523 | * extract an integer from a position in a byte stream |
| 3478 | 3524 | * |
| 3479 | 3525 | * @access private |
| 3526 | + * @param integer $pos |
|
| 3527 | + * @param integer $num |
|
| 3480 | 3528 | */ |
| 3481 | 3529 | private function getBytes(&$data, $pos, $num) |
| 3482 | 3530 | { |
@@ -3491,7 +3539,7 @@ discard block |
||
| 3491 | 3539 | |
| 3492 | 3540 | /** |
| 3493 | 3541 | * reads the PNG chunk |
| 3494 | - * @param $data - binary part of the png image |
|
| 3542 | + * @param string $data - binary part of the png image |
|
| 3495 | 3543 | * @access private |
| 3496 | 3544 | */ |
| 3497 | 3545 | private function readPngChunks(&$data) |
@@ -3738,6 +3786,7 @@ discard block |
||
| 3738 | 3786 | /** |
| 3739 | 3787 | * add a JPEG image into the document, from a file |
| 3740 | 3788 | * @access public |
| 3789 | + * @param string $img |
|
| 3741 | 3790 | */ |
| 3742 | 3791 | public function addJpegFromFile($img, $x, $y, $w = 0, $h = 0) |
| 3743 | 3792 | { |
@@ -3870,6 +3919,7 @@ discard block |
||
| 3870 | 3919 | /** |
| 3871 | 3920 | * common code used by the two JPEG adding functions |
| 3872 | 3921 | * @access private |
| 3922 | + * @param string $data |
|
| 3873 | 3923 | */ |
| 3874 | 3924 | private function addJpegImage_common(&$data, $x, $y, $w = 0, $h = 0, $imageWidth, $imageHeight, $channels = 3) |
| 3875 | 3925 | { |
@@ -3955,6 +4005,7 @@ discard block |
||
| 3955 | 4005 | /** |
| 3956 | 4006 | * used to add messages for use in debugging |
| 3957 | 4007 | * @access protected |
| 4008 | + * @param integer $error_type |
|
| 3958 | 4009 | */ |
| 3959 | 4010 | protected function debug($message, $error_type = E_USER_NOTICE) |
| 3960 | 4011 | { |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | private $numObj=0; |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * this array contains all of the pdf objects, ready for final assembly |
|
| 64 | - * |
|
| 65 | - * @var array |
|
| 66 | - */ |
|
| 63 | + * this array contains all of the pdf objects, ready for final assembly |
|
| 64 | + * |
|
| 65 | + * @var array |
|
| 66 | + */ |
|
| 67 | 67 | private $objects = array(); |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -76,10 +76,10 @@ discard block |
||
| 76 | 76 | private $objectHashes = array(); |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * the objectId (number within the objects array) of the document catalog |
|
| 80 | - * |
|
| 81 | - * @var integer |
|
| 82 | - */ |
|
| 79 | + * the objectId (number within the objects array) of the document catalog |
|
| 80 | + * |
|
| 81 | + * @var integer |
|
| 82 | + */ |
|
| 83 | 83 | private $catalogId; |
| 84 | 84 | |
| 85 | 85 | |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | private $fonts = array(); |
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | - * a record of the current font |
|
| 143 | - * |
|
| 144 | - * @var string |
|
| 145 | - */ |
|
| 142 | + * a record of the current font |
|
| 143 | + * |
|
| 144 | + * @var string |
|
| 145 | + */ |
|
| 146 | 146 | private $currentFont=''; |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | private $currentBaseFont=''; |
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | - * the number of the current font within the font array |
|
| 157 | - * |
|
| 158 | - * @var integer |
|
| 159 | - */ |
|
| 156 | + * the number of the current font within the font array |
|
| 157 | + * |
|
| 158 | + * @var integer |
|
| 159 | + */ |
|
| 160 | 160 | private $currentFontNum=0; |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -165,20 +165,20 @@ discard block |
||
| 165 | 165 | private $currentNode; |
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | - * object number of the current page |
|
| 169 | - * |
|
| 170 | - * @var integer |
|
| 171 | - */ |
|
| 168 | + * object number of the current page |
|
| 169 | + * |
|
| 170 | + * @var integer |
|
| 171 | + */ |
|
| 172 | 172 | private $currentPage; |
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | - * object number of the currently active contents block |
|
| 176 | - */ |
|
| 175 | + * object number of the currently active contents block |
|
| 176 | + */ |
|
| 177 | 177 | private $currentContents; |
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | - * number of fonts within the system |
|
| 181 | - */ |
|
| 180 | + * number of fonts within the system |
|
| 181 | + */ |
|
| 182 | 182 | private $numFonts = 0; |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -192,14 +192,14 @@ discard block |
||
| 192 | 192 | private $currentStrokeColour = array('r' => -1, 'g' => -1, 'b' => -1); |
| 193 | 193 | |
| 194 | 194 | /** |
| 195 | - * current style that lines are drawn in |
|
| 196 | - */ |
|
| 195 | + * current style that lines are drawn in |
|
| 196 | + */ |
|
| 197 | 197 | private $currentLineStyle=''; |
| 198 | 198 | |
| 199 | 199 | /** |
| 200 | - * an array which is used to save the state of the document, mainly the colours and styles |
|
| 201 | - * it is used to temporarily change to another state, the change back to what it was before |
|
| 202 | - */ |
|
| 200 | + * an array which is used to save the state of the document, mainly the colours and styles |
|
| 201 | + * it is used to temporarily change to another state, the change back to what it was before |
|
| 202 | + */ |
|
| 203 | 203 | private $stateStack = array(); |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -234,37 +234,37 @@ discard block |
||
| 234 | 234 | private $addLooseObjects=array(); |
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | - * the objectId of the information object for the document |
|
| 238 | - * this contains authorship, title etc. |
|
| 239 | - */ |
|
| 237 | + * the objectId of the information object for the document |
|
| 238 | + * this contains authorship, title etc. |
|
| 239 | + */ |
|
| 240 | 240 | private $infoObject=0; |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | - * number of images being tracked within the document |
|
| 244 | - */ |
|
| 243 | + * number of images being tracked within the document |
|
| 244 | + */ |
|
| 245 | 245 | private $numImages=0; |
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | - * some additional options while generation |
|
| 249 | - * currently used for compression only |
|
| 250 | - * Default: 'compression' => -1 which will set gzcompress to the default level of 6 |
|
| 251 | - */ |
|
| 248 | + * some additional options while generation |
|
| 249 | + * currently used for compression only |
|
| 250 | + * Default: 'compression' => -1 which will set gzcompress to the default level of 6 |
|
| 251 | + */ |
|
| 252 | 252 | public $options=array('compression'=>-1); |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | - * the objectId of the first page of the document |
|
| 256 | - */ |
|
| 255 | + * the objectId of the first page of the document |
|
| 256 | + */ |
|
| 257 | 257 | private $firstPageId; |
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | - * used to track the last used value of the inter-word spacing, this is so that it is known |
|
| 261 | - * when the spacing is changed. |
|
| 262 | - */ |
|
| 260 | + * used to track the last used value of the inter-word spacing, this is so that it is known |
|
| 261 | + * when the spacing is changed. |
|
| 262 | + */ |
|
| 263 | 263 | private $wordSpaceAdjust=0; |
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | - * track if the current font is bolded or italicised |
|
| 267 | - */ |
|
| 266 | + * track if the current font is bolded or italicised |
|
| 267 | + */ |
|
| 268 | 268 | private $currentTextState = ''; |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | $this->newDocument($pageSize); |
| 360 | 360 | |
| 361 | 361 | if (in_array('Windows-1252', mb_list_encodings())) { |
| 362 | - $this->targetEncoding = 'Windows-1252'; |
|
| 362 | + $this->targetEncoding = 'Windows-1252'; |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // font familys are already known in $this->fontFamilies |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | switch ($action) { |
| 394 | 394 | case 'new': |
| 395 | 395 | $this->objects[$id]=array('t'=>'destination','info'=>array()); |
| 396 | - $tmp = ''; |
|
| 396 | + $tmp = ''; |
|
| 397 | 397 | switch ($options['type']) { |
| 398 | 398 | case 'XYZ': |
| 399 | 399 | case 'FitR': |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | $res = "\n$id 0 obj\n<</Type /Font /Subtype /Type0 /BaseFont /".$o['info']['name'].""; |
| 817 | 817 | // The horizontal identity mapping for 2-byte CIDs; may be used |
| 818 | 818 | // with CIDFonts using any Registry, Ordering, and Supplement values. |
| 819 | - $res.= " /Encoding /Identity-H /DescendantFonts [".$o['info']['cidFont']." 0 R] /ToUnicode ".$o['info']['toUnicode']." 0 R >>\n"; |
|
| 819 | + $res.= " /Encoding /Identity-H /DescendantFonts [".$o['info']['cidFont']." 0 R] /ToUnicode ".$o['info']['toUnicode']." 0 R >>\n"; |
|
| 820 | 820 | $res.= "endobj"; |
| 821 | 821 | } else { |
| 822 | 822 | $res="\n".$id." 0 obj\n<< /Type /Font /Subtype /".$o['info']['SubType']." "; |
@@ -953,7 +953,7 @@ discard block |
||
| 953 | 953 | switch ($action) { |
| 954 | 954 | case 'new': |
| 955 | 955 | $this->objects[$id] = array('t' => 'fontDescendentCID', 'info' => $options); |
| 956 | - // and a CID to GID map |
|
| 956 | + // and a CID to GID map |
|
| 957 | 957 | if ($this->embedFont) { |
| 958 | 958 | $cidToGidMapId = ++$this->numObj; |
| 959 | 959 | $this->o_fontGIDtoCIDMap($cidToGidMapId, 'new', $options); |
@@ -974,20 +974,20 @@ discard block |
||
| 974 | 974 | case 'FontDescriptor': |
| 975 | 975 | case 'SubType': |
| 976 | 976 | $this->debug("o_fontDescendentCID $k : $v", E_USER_NOTICE); |
| 977 | - $o['info'][$k] = $v; |
|
| 977 | + $o['info'][$k] = $v; |
|
| 978 | 978 | break; |
| 979 | 979 | } |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | - // pass values down to cid to gid map |
|
| 982 | + // pass values down to cid to gid map |
|
| 983 | 983 | if ($this->embedFont) { |
| 984 | - $this->o_fontGIDtoCIDMap($o['info']['cidToGidMap'], 'add', $options); |
|
| 984 | + $this->o_fontGIDtoCIDMap($o['info']['cidToGidMap'], 'add', $options); |
|
| 985 | 985 | } |
| 986 | 986 | break; |
| 987 | 987 | |
| 988 | 988 | case 'out': |
| 989 | 989 | $res = "\n$id 0 obj\n"; |
| 990 | - $res.= "<</Type /Font /Subtype /CIDFontType2 /BaseFont /".$o['info']['name']." /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>"; |
|
| 990 | + $res.= "<</Type /Font /Subtype /CIDFontType2 /BaseFont /".$o['info']['name']." /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>"; |
|
| 991 | 991 | if (isset($o['info']['FontDescriptor'])) { |
| 992 | 992 | $res.= " /FontDescriptor ".$o['info']['FontDescriptor']." 0 R"; |
| 993 | 993 | } |
@@ -1006,19 +1006,19 @@ discard block |
||
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | if ($this->embedFont) { |
| 1009 | - $res.= " /CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R"; |
|
| 1009 | + $res.= " /CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R"; |
|
| 1010 | 1010 | } |
| 1011 | - $res.= " >>\n"; |
|
| 1012 | - $res.= "endobj"; |
|
| 1011 | + $res.= " >>\n"; |
|
| 1012 | + $res.= "endobj"; |
|
| 1013 | 1013 | |
| 1014 | 1014 | return $res; |
| 1015 | 1015 | } |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | /** |
| 1019 | - * a font glyph to character map, needed for unicode fonts |
|
| 1020 | - * @access private |
|
| 1021 | - */ |
|
| 1019 | + * a font glyph to character map, needed for unicode fonts |
|
| 1020 | + * @access private |
|
| 1021 | + */ |
|
| 1022 | 1022 | private function o_fontGIDtoCIDMap($id, $action, $options = '') |
| 1023 | 1023 | { |
| 1024 | 1024 | if ($action !== 'new') { |
@@ -1032,8 +1032,8 @@ discard block |
||
| 1032 | 1032 | |
| 1033 | 1033 | case 'out': |
| 1034 | 1034 | $res = "\n$id 0 obj\n"; |
| 1035 | - $fontFileName = $o['info']['fontFileName']; |
|
| 1036 | - $tmp = $this->fonts[$fontFileName]['CIDtoGID'] = base64_decode($this->fonts[$fontFileName]['CIDtoGID']); |
|
| 1035 | + $fontFileName = $o['info']['fontFileName']; |
|
| 1036 | + $tmp = $this->fonts[$fontFileName]['CIDtoGID'] = base64_decode($this->fonts[$fontFileName]['CIDtoGID']); |
|
| 1037 | 1037 | |
| 1038 | 1038 | if (isset($o['raw'])) { |
| 1039 | 1039 | $res.= $tmp; |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | $res.= " /Length ".mb_strlen($tmp, '8bit') .">>\nstream\n$tmp\nendstream"; |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | - $res.= "\nendobj"; |
|
| 1051 | + $res.= "\nendobj"; |
|
| 1052 | 1052 | return $res; |
| 1053 | 1053 | } |
| 1054 | 1054 | } |
@@ -1936,7 +1936,7 @@ discard block |
||
| 1936 | 1936 | } |
| 1937 | 1937 | |
| 1938 | 1938 | if (!isset($data['MissingWidth']) && $c == -1 && $n === '.notdef') { |
| 1939 | - $data['MissingWidth'] = $width; |
|
| 1939 | + $data['MissingWidth'] = $width; |
|
| 1940 | 1940 | } |
| 1941 | 1941 | } |
| 1942 | 1942 | break; |
@@ -1957,7 +1957,7 @@ discard block |
||
| 1957 | 1957 | |
| 1958 | 1958 | if ($c >= 0) { |
| 1959 | 1959 | if ($c >= 0 && $c < 0xFFFF && $glyph) { |
| 1960 | - $cidtogid[$c*2] = chr($glyph >> 8); |
|
| 1960 | + $cidtogid[$c*2] = chr($glyph >> 8); |
|
| 1961 | 1961 | $cidtogid[$c*2 + 1] = chr($glyph & 0xFF); |
| 1962 | 1962 | } |
| 1963 | 1963 | if ($c != hexdec($n)) { |
@@ -1969,7 +1969,7 @@ discard block |
||
| 1969 | 1969 | } |
| 1970 | 1970 | |
| 1971 | 1971 | if (!isset($data['MissingWidth']) && $c == -1 && $n === '.notdef') { |
| 1972 | - $data['MissingWidth'] = $width; |
|
| 1972 | + $data['MissingWidth'] = $width; |
|
| 1973 | 1973 | } |
| 1974 | 1974 | } |
| 1975 | 1975 | break; |
@@ -2167,8 +2167,8 @@ discard block |
||
| 2167 | 2167 | |
| 2168 | 2168 | // setup the basic properties for o_font output |
| 2169 | 2169 | $tmp = array('BaseFont'=>$adobeFontName,'Widths'=>$widthid |
| 2170 | - ,'FirstChar'=>$firstChar,'LastChar'=>$lastChar |
|
| 2171 | - ,'FontDescriptor'=>$fontDescriptorId); |
|
| 2170 | + ,'FirstChar'=>$firstChar,'LastChar'=>$lastChar |
|
| 2171 | + ,'FontDescriptor'=>$fontDescriptorId); |
|
| 2172 | 2172 | |
| 2173 | 2173 | // binary content of pfb or ttf file |
| 2174 | 2174 | $pfbid = ++$this->numObj; |
@@ -2662,18 +2662,18 @@ discard block |
||
| 2662 | 2662 | } |
| 2663 | 2663 | |
| 2664 | 2664 | /** |
| 2665 | - * return array containing codepoints (UTF-8 character values) for the |
|
| 2666 | - * string passed in. |
|
| 2667 | - * |
|
| 2668 | - * based on the excellent TCPDF code by Nicola Asuni and the |
|
| 2669 | - * RFC for UTF-8 at http://www.faqs.org/rfcs/rfc3629.html |
|
| 2670 | - * |
|
| 2671 | - * @access private |
|
| 2672 | - * @author Orion Richardson |
|
| 2673 | - * @since January 5, 2008 |
|
| 2674 | - * @param string $text UTF-8 string to process |
|
| 2675 | - * @return array UTF-8 codepoints array for the string |
|
| 2676 | - */ |
|
| 2665 | + * return array containing codepoints (UTF-8 character values) for the |
|
| 2666 | + * string passed in. |
|
| 2667 | + * |
|
| 2668 | + * based on the excellent TCPDF code by Nicola Asuni and the |
|
| 2669 | + * RFC for UTF-8 at http://www.faqs.org/rfcs/rfc3629.html |
|
| 2670 | + * |
|
| 2671 | + * @access private |
|
| 2672 | + * @author Orion Richardson |
|
| 2673 | + * @since January 5, 2008 |
|
| 2674 | + * @param string $text UTF-8 string to process |
|
| 2675 | + * @return array UTF-8 codepoints array for the string |
|
| 2676 | + */ |
|
| 2677 | 2677 | private function utf8toCodePointsArray(&$text) |
| 2678 | 2678 | { |
| 2679 | 2679 | $length = mb_strlen($text, '8bit'); // http://www.php.net/manual/en/function.mb-strlen.php#77040 |
@@ -2733,20 +2733,20 @@ discard block |
||
| 2733 | 2733 | return $unicode; |
| 2734 | 2734 | } |
| 2735 | 2735 | |
| 2736 | - /** |
|
| 2737 | - * convert UTF-8 to UTF-16 with an additional byte order marker |
|
| 2738 | - * at the front if required. |
|
| 2739 | - * |
|
| 2740 | - * based on the excellent TCPDF code by Nicola Asuni and the |
|
| 2741 | - * RFC for UTF-8 at http://www.faqs.org/rfcs/rfc3629.html |
|
| 2742 | - * |
|
| 2743 | - * @access private |
|
| 2744 | - * @author Orion Richardson |
|
| 2745 | - * @since January 5, 2008 |
|
| 2746 | - * @param string $text UTF-8 string to process |
|
| 2747 | - * @param boolean $bom whether to add the byte order marker |
|
| 2748 | - * @return string UTF-16 result string |
|
| 2749 | - */ |
|
| 2736 | + /** |
|
| 2737 | + * convert UTF-8 to UTF-16 with an additional byte order marker |
|
| 2738 | + * at the front if required. |
|
| 2739 | + * |
|
| 2740 | + * based on the excellent TCPDF code by Nicola Asuni and the |
|
| 2741 | + * RFC for UTF-8 at http://www.faqs.org/rfcs/rfc3629.html |
|
| 2742 | + * |
|
| 2743 | + * @access private |
|
| 2744 | + * @author Orion Richardson |
|
| 2745 | + * @since January 5, 2008 |
|
| 2746 | + * @param string $text UTF-8 string to process |
|
| 2747 | + * @param boolean $bom whether to add the byte order marker |
|
| 2748 | + * @return string UTF-16 result string |
|
| 2749 | + */ |
|
| 2750 | 2750 | private function utf8toUtf16BE(&$text, $bom = true) |
| 2751 | 2751 | { |
| 2752 | 2752 | $cf = $this->currentFont; |
@@ -3031,7 +3031,7 @@ discard block |
||
| 3031 | 3031 | if ($start < $len) { |
| 3032 | 3032 | $part = substr($text, $start); |
| 3033 | 3033 | $place_text = $this->filterText($part, false); |
| 3034 | - // modify unicode text so that extra word spacing is manually implemented (bug #) |
|
| 3034 | + // modify unicode text so that extra word spacing is manually implemented (bug #) |
|
| 3035 | 3035 | $cf = $this->currentFont; |
| 3036 | 3036 | if ($this->fonts[$cf]['isUnicode'] && $wordSpaceAdjust != 0) { |
| 3037 | 3037 | $space_scale = 1000 / $size; |
@@ -3346,15 +3346,15 @@ discard block |
||
| 3346 | 3346 | } |
| 3347 | 3347 | |
| 3348 | 3348 | /** |
| 3349 | - * open an existing object for editing |
|
| 3350 | - * @access public |
|
| 3351 | - */ |
|
| 3349 | + * open an existing object for editing |
|
| 3350 | + * @access public |
|
| 3351 | + */ |
|
| 3352 | 3352 | public function reopenObject($id) |
| 3353 | 3353 | { |
| 3354 | 3354 | $this->nStack++; |
| 3355 | 3355 | $this->stack[$this->nStack]=array('c'=>$this->currentContents,'p'=>$this->currentPage); |
| 3356 | 3356 | $this->currentContents=$id; |
| 3357 | - // also if this object is the primary contents for a page, then set the current page to its parent |
|
| 3357 | + // also if this object is the primary contents for a page, then set the current page to its parent |
|
| 3358 | 3358 | if (isset($this->objects[$id]['onPage'])) { |
| 3359 | 3359 | $this->currentPage = $this->objects[$id]['onPage']; |
| 3360 | 3360 | } |
@@ -3723,7 +3723,7 @@ discard block |
||
| 3723 | 3723 | } |
| 3724 | 3724 | |
| 3725 | 3725 | $options = array('label'=>$label,'data'=>$iChunk['idata'],'bitsPerComponent'=>$iChunk['info']['bitDepth'],'pdata'=>$iChunk['pdata'] |
| 3726 | - ,'iw'=>$iChunk['info']['width'],'ih'=>$iChunk['info']['height'],'type'=>'png','color'=>$color,'ncolor'=>$ncolor); |
|
| 3726 | + ,'iw'=>$iChunk['info']['width'],'ih'=>$iChunk['info']['height'],'type'=>'png','color'=>$color,'ncolor'=>$ncolor); |
|
| 3727 | 3727 | if (isset($iChunk['transparency'])) { |
| 3728 | 3728 | $options['transparency']=$iChunk['transparency']; |
| 3729 | 3729 | } |
@@ -3815,18 +3815,18 @@ discard block |
||
| 3815 | 3815 | $this->addJpegFromFile($tmpName, $x, $y, $w, $h); |
| 3816 | 3816 | } |
| 3817 | 3817 | |
| 3818 | - /** |
|
| 3819 | - * add an image into the document, from a GD object |
|
| 3820 | - * this function is not all that reliable, and I would probably encourage people to use |
|
| 3821 | - * the file based functions |
|
| 3822 | - * @param $img - gd image resource |
|
| 3823 | - * @param $x coord x |
|
| 3824 | - * @param $y coord y |
|
| 3825 | - * @param $w width |
|
| 3826 | - * @param $h height |
|
| 3827 | - * @param $quality image quality |
|
| 3828 | - * @access protected |
|
| 3829 | - */ |
|
| 3818 | + /** |
|
| 3819 | + * add an image into the document, from a GD object |
|
| 3820 | + * this function is not all that reliable, and I would probably encourage people to use |
|
| 3821 | + * the file based functions |
|
| 3822 | + * @param $img - gd image resource |
|
| 3823 | + * @param $x coord x |
|
| 3824 | + * @param $y coord y |
|
| 3825 | + * @param $w width |
|
| 3826 | + * @param $h height |
|
| 3827 | + * @param $quality image quality |
|
| 3828 | + * @access protected |
|
| 3829 | + */ |
|
| 3830 | 3830 | protected function addImage(&$img, $x, $y, $w = 0, $h = 0, $quality = 75) |
| 3831 | 3831 | { |
| 3832 | 3832 | // add a new image into the current location, as an external object |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @var integer |
| 59 | 59 | */ |
| 60 | - private $numObj=0; |
|
| 60 | + private $numObj = 0; |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * this array contains all of the pdf objects, ready for final assembly |
@@ -143,21 +143,21 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @var string |
| 145 | 145 | */ |
| 146 | - private $currentFont=''; |
|
| 146 | + private $currentFont = ''; |
|
| 147 | 147 | |
| 148 | 148 | /** |
| 149 | 149 | * the current base font |
| 150 | 150 | * |
| 151 | 151 | * @var string |
| 152 | 152 | */ |
| 153 | - private $currentBaseFont=''; |
|
| 153 | + private $currentBaseFont = ''; |
|
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | 156 | * the number of the current font within the font array |
| 157 | 157 | * |
| 158 | 158 | * @var integer |
| 159 | 159 | */ |
| 160 | - private $currentFontNum=0; |
|
| 160 | + private $currentFontNum = 0; |
|
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * @var integer |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | /** |
| 195 | 195 | * current style that lines are drawn in |
| 196 | 196 | */ |
| 197 | - private $currentLineStyle=''; |
|
| 197 | + private $currentLineStyle = ''; |
|
| 198 | 198 | |
| 199 | 199 | /** |
| 200 | 200 | * an array which is used to save the state of the document, mainly the colours and styles |
@@ -210,46 +210,46 @@ discard block |
||
| 210 | 210 | /** |
| 211 | 211 | * number of page objects within the document |
| 212 | 212 | */ |
| 213 | - private $numPages=0; |
|
| 213 | + private $numPages = 0; |
|
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * object Id storage stack |
| 217 | 217 | */ |
| 218 | - private $stack=array(); |
|
| 218 | + private $stack = array(); |
|
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | 221 | * number of elements within the object Id storage stack |
| 222 | 222 | */ |
| 223 | - private $nStack=0; |
|
| 223 | + private $nStack = 0; |
|
| 224 | 224 | |
| 225 | 225 | /** |
| 226 | 226 | * an array which contains information about the objects which are not firmly attached to pages |
| 227 | 227 | * these have been added with the addObject function |
| 228 | 228 | */ |
| 229 | - private $looseObjects=array(); |
|
| 229 | + private $looseObjects = array(); |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * array contains infomation about how the loose objects are to be added to the document |
| 233 | 233 | */ |
| 234 | - private $addLooseObjects=array(); |
|
| 234 | + private $addLooseObjects = array(); |
|
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | 237 | * the objectId of the information object for the document |
| 238 | 238 | * this contains authorship, title etc. |
| 239 | 239 | */ |
| 240 | - private $infoObject=0; |
|
| 240 | + private $infoObject = 0; |
|
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | 243 | * number of images being tracked within the document |
| 244 | 244 | */ |
| 245 | - private $numImages=0; |
|
| 245 | + private $numImages = 0; |
|
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * some additional options while generation |
| 249 | 249 | * currently used for compression only |
| 250 | 250 | * Default: 'compression' => -1 which will set gzcompress to the default level of 6 |
| 251 | 251 | */ |
| 252 | - public $options=array('compression'=>-1); |
|
| 252 | + public $options = array('compression'=>-1); |
|
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | 255 | * the objectId of the first page of the document |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * used to track the last used value of the inter-word spacing, this is so that it is known |
| 261 | 261 | * when the spacing is changed. |
| 262 | 262 | */ |
| 263 | - private $wordSpaceAdjust=0; |
|
| 263 | + private $wordSpaceAdjust = 0; |
|
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | 266 | * track if the current font is bolded or italicised |
@@ -270,29 +270,29 @@ discard block |
||
| 270 | 270 | /** |
| 271 | 271 | * messages are stored here during processing, these can be selected afterwards to give some useful debug information |
| 272 | 272 | */ |
| 273 | - public $messages=''; |
|
| 273 | + public $messages = ''; |
|
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | 276 | * the ancryption array for the document encryption is stored here |
| 277 | 277 | */ |
| 278 | - private $arc4=''; |
|
| 278 | + private $arc4 = ''; |
|
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | * the object Id of the encryption information |
| 282 | 282 | */ |
| 283 | - private $arc4_objnum=0; |
|
| 283 | + private $arc4_objnum = 0; |
|
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | 286 | * the file identifier, used to uniquely identify a pdf document |
| 287 | 287 | */ |
| 288 | - public $fileIdentifier=''; |
|
| 288 | + public $fileIdentifier = ''; |
|
| 289 | 289 | |
| 290 | 290 | /** |
| 291 | 291 | * a flag to say if a document is to be encrypted or not |
| 292 | 292 | * |
| 293 | 293 | * @var boolean |
| 294 | 294 | */ |
| 295 | - private $encrypted=0; |
|
| 295 | + private $encrypted = 0; |
|
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | 298 | * Set the encryption mode |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * |
| 306 | 306 | * @var string |
| 307 | 307 | */ |
| 308 | - private $encryptionKey=''; |
|
| 308 | + private $encryptionKey = ''; |
|
| 309 | 309 | |
| 310 | 310 | /* |
| 311 | 311 | * encryption padding fetched from the Adobe PDF reference |
@@ -387,32 +387,32 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | private function o_destination($id, $action, $options = '') |
| 389 | 389 | { |
| 390 | - if ($action!='new') { |
|
| 391 | - $o =& $this->objects[$id]; |
|
| 390 | + if ($action != 'new') { |
|
| 391 | + $o = & $this->objects[$id]; |
|
| 392 | 392 | } |
| 393 | 393 | switch ($action) { |
| 394 | 394 | case 'new': |
| 395 | - $this->objects[$id]=array('t'=>'destination','info'=>array()); |
|
| 395 | + $this->objects[$id] = array('t'=>'destination', 'info'=>array()); |
|
| 396 | 396 | $tmp = ''; |
| 397 | 397 | switch ($options['type']) { |
| 398 | 398 | case 'XYZ': |
| 399 | 399 | case 'FitR': |
| 400 | - $tmp = ' '.$options['p3'].$tmp; |
|
| 400 | + $tmp = ' '.$options['p3'].$tmp; |
|
| 401 | 401 | case 'FitH': |
| 402 | 402 | case 'FitV': |
| 403 | 403 | case 'FitBH': |
| 404 | 404 | case 'FitBV': |
| 405 | - $tmp = ' '.$options['p1'].' '.$options['p2'].$tmp; |
|
| 405 | + $tmp = ' '.$options['p1'].' '.$options['p2'].$tmp; |
|
| 406 | 406 | case 'Fit': |
| 407 | 407 | case 'FitB': |
| 408 | - $tmp = $options['type'].$tmp; |
|
| 409 | - $this->objects[$id]['info']['string']=$tmp; |
|
| 410 | - $this->objects[$id]['info']['page']=$options['page']; |
|
| 408 | + $tmp = $options['type'].$tmp; |
|
| 409 | + $this->objects[$id]['info']['string'] = $tmp; |
|
| 410 | + $this->objects[$id]['info']['page'] = $options['page']; |
|
| 411 | 411 | } |
| 412 | 412 | break; |
| 413 | 413 | case 'out': |
| 414 | 414 | $tmp = $o['info']; |
| 415 | - $res="\n".$id." 0 obj\n".'['.$tmp['page'].' 0 R /'.$tmp['string']."]\nendobj"; |
|
| 415 | + $res = "\n".$id." 0 obj\n".'['.$tmp['page'].' 0 R /'.$tmp['string']."]\nendobj"; |
|
| 416 | 416 | return $res; |
| 417 | 417 | break; |
| 418 | 418 | } |
@@ -424,12 +424,12 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | private function o_viewerPreferences($id, $action, $options = '') |
| 426 | 426 | { |
| 427 | - if ($action!='new') { |
|
| 428 | - $o =& $this->objects[$id]; |
|
| 427 | + if ($action != 'new') { |
|
| 428 | + $o = & $this->objects[$id]; |
|
| 429 | 429 | } |
| 430 | 430 | switch ($action) { |
| 431 | 431 | case 'new': |
| 432 | - $this->objects[$id]=array('t'=>'viewerPreferences','info'=>array()); |
|
| 432 | + $this->objects[$id] = array('t'=>'viewerPreferences', 'info'=>array()); |
|
| 433 | 433 | break; |
| 434 | 434 | case 'add': |
| 435 | 435 | foreach ($options as $k => $v) { |
@@ -442,17 +442,17 @@ discard block |
||
| 442 | 442 | case 'DisplayDocTitle': |
| 443 | 443 | case 'NonFullScreenPageMode': |
| 444 | 444 | case 'Direction': |
| 445 | - $o['info'][$k]=$v; |
|
| 445 | + $o['info'][$k] = $v; |
|
| 446 | 446 | break; |
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | 449 | break; |
| 450 | 450 | case 'out': |
| 451 | - $res="\n".$id." 0 obj\n".'<< '; |
|
| 451 | + $res = "\n".$id." 0 obj\n".'<< '; |
|
| 452 | 452 | foreach ($o['info'] as $k => $v) { |
| 453 | - $res.="\n/".$k.' '.$v; |
|
| 453 | + $res .= "\n/".$k.' '.$v; |
|
| 454 | 454 | } |
| 455 | - $res.="\n>>\n"; |
|
| 455 | + $res .= "\n>>\n"; |
|
| 456 | 456 | return $res; |
| 457 | 457 | break; |
| 458 | 458 | } |
@@ -464,47 +464,47 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | private function o_catalog($id, $action, $options = '') |
| 466 | 466 | { |
| 467 | - if ($action!='new') { |
|
| 468 | - $o =& $this->objects[$id]; |
|
| 467 | + if ($action != 'new') { |
|
| 468 | + $o = & $this->objects[$id]; |
|
| 469 | 469 | } |
| 470 | 470 | switch ($action) { |
| 471 | 471 | case 'new': |
| 472 | - $this->objects[$id]=array('t'=>'catalog','info'=>array()); |
|
| 473 | - $this->catalogId=$id; |
|
| 472 | + $this->objects[$id] = array('t'=>'catalog', 'info'=>array()); |
|
| 473 | + $this->catalogId = $id; |
|
| 474 | 474 | break; |
| 475 | 475 | case 'outlines': |
| 476 | 476 | case 'pages': |
| 477 | 477 | case 'openHere': |
| 478 | - $o['info'][$action]=$options; |
|
| 478 | + $o['info'][$action] = $options; |
|
| 479 | 479 | break; |
| 480 | 480 | case 'viewerPreferences': |
| 481 | 481 | if (!isset($o['info']['viewerPreferences'])) { |
| 482 | 482 | $this->numObj++; |
| 483 | 483 | $this->o_viewerPreferences($this->numObj, 'new'); |
| 484 | - $o['info']['viewerPreferences']=$this->numObj; |
|
| 484 | + $o['info']['viewerPreferences'] = $this->numObj; |
|
| 485 | 485 | } |
| 486 | 486 | $vp = $o['info']['viewerPreferences']; |
| 487 | 487 | $this->o_viewerPreferences($vp, 'add', $options); |
| 488 | 488 | break; |
| 489 | 489 | case 'out': |
| 490 | - $res="\n".$id." 0 obj\n".'<< /Type /Catalog'; |
|
| 490 | + $res = "\n".$id." 0 obj\n".'<< /Type /Catalog'; |
|
| 491 | 491 | foreach ($o['info'] as $k => $v) { |
| 492 | 492 | switch ($k) { |
| 493 | 493 | case 'outlines': |
| 494 | - $res.=' /Outlines '.$v.' 0 R'; |
|
| 494 | + $res .= ' /Outlines '.$v.' 0 R'; |
|
| 495 | 495 | break; |
| 496 | 496 | case 'pages': |
| 497 | - $res.=' /Pages '.$v.' 0 R'; |
|
| 497 | + $res .= ' /Pages '.$v.' 0 R'; |
|
| 498 | 498 | break; |
| 499 | 499 | case 'viewerPreferences': |
| 500 | - $res.=' /ViewerPreferences '.$o['info']['viewerPreferences'].' 0 R'; |
|
| 500 | + $res .= ' /ViewerPreferences '.$o['info']['viewerPreferences'].' 0 R'; |
|
| 501 | 501 | break; |
| 502 | 502 | case 'openHere': |
| 503 | - $res.=' /OpenAction '.$o['info']['openHere'].' 0 R'; |
|
| 503 | + $res .= ' /OpenAction '.$o['info']['openHere'].' 0 R'; |
|
| 504 | 504 | break; |
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | - $res.=" >>\nendobj"; |
|
| 507 | + $res .= " >>\nendobj"; |
|
| 508 | 508 | return $res; |
| 509 | 509 | break; |
| 510 | 510 | } |
@@ -516,93 +516,93 @@ discard block |
||
| 516 | 516 | */ |
| 517 | 517 | private function o_pages($id, $action, $options = '') |
| 518 | 518 | { |
| 519 | - if ($action!='new') { |
|
| 520 | - $o =& $this->objects[$id]; |
|
| 519 | + if ($action != 'new') { |
|
| 520 | + $o = & $this->objects[$id]; |
|
| 521 | 521 | } |
| 522 | 522 | switch ($action) { |
| 523 | 523 | case 'new': |
| 524 | - $this->objects[$id]=array('t'=>'pages','info'=>array()); |
|
| 524 | + $this->objects[$id] = array('t'=>'pages', 'info'=>array()); |
|
| 525 | 525 | $this->o_catalog($this->catalogId, 'pages', $id); |
| 526 | 526 | break; |
| 527 | 527 | case 'page': |
| 528 | 528 | if (!is_array($options)) { |
| 529 | 529 | // then it will just be the id of the new page |
| 530 | - $o['info']['pages'][]=$options; |
|
| 530 | + $o['info']['pages'][] = $options; |
|
| 531 | 531 | } else { |
| 532 | 532 | // then it should be an array having 'id','rid','pos', where rid=the page to which this one will be placed relative |
| 533 | 533 | // and pos is either 'before' or 'after', saying where this page will fit. |
| 534 | 534 | if (isset($options['id']) && isset($options['rid']) && isset($options['pos'])) { |
| 535 | 535 | $i = array_search($options['rid'], $o['info']['pages']); |
| 536 | - if (isset($o['info']['pages'][$i]) && $o['info']['pages'][$i]==$options['rid']) { |
|
| 536 | + if (isset($o['info']['pages'][$i]) && $o['info']['pages'][$i] == $options['rid']) { |
|
| 537 | 537 | // then there is a match make a space |
| 538 | 538 | switch ($options['pos']) { |
| 539 | 539 | case 'before': |
| 540 | 540 | $k = $i; |
| 541 | 541 | break; |
| 542 | 542 | case 'after': |
| 543 | - $k=$i+1; |
|
| 543 | + $k = $i + 1; |
|
| 544 | 544 | break; |
| 545 | 545 | default: |
| 546 | - $k=-1; |
|
| 546 | + $k = -1; |
|
| 547 | 547 | break; |
| 548 | 548 | } |
| 549 | - if ($k>=0) { |
|
| 550 | - for ($j=count($o['info']['pages'])-1; $j>=$k; $j--) { |
|
| 551 | - $o['info']['pages'][$j+1]=$o['info']['pages'][$j]; |
|
| 549 | + if ($k >= 0) { |
|
| 550 | + for ($j = count($o['info']['pages']) - 1; $j >= $k; $j--) { |
|
| 551 | + $o['info']['pages'][$j + 1] = $o['info']['pages'][$j]; |
|
| 552 | 552 | } |
| 553 | - $o['info']['pages'][$k]=$options['id']; |
|
| 553 | + $o['info']['pages'][$k] = $options['id']; |
|
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | break; |
| 559 | 559 | case 'procset': |
| 560 | - $o['info']['procset']=$options; |
|
| 560 | + $o['info']['procset'] = $options; |
|
| 561 | 561 | break; |
| 562 | 562 | case 'mediaBox': |
| 563 | - $o['info']['mediaBox']=$options; // which should be an array of 4 numbers |
|
| 563 | + $o['info']['mediaBox'] = $options; // which should be an array of 4 numbers |
|
| 564 | 564 | break; |
| 565 | 565 | case 'font': |
| 566 | - $o['info']['fonts'][]=array('objNum'=>$options['objNum'],'fontNum'=>$options['fontNum']); |
|
| 566 | + $o['info']['fonts'][] = array('objNum'=>$options['objNum'], 'fontNum'=>$options['fontNum']); |
|
| 567 | 567 | break; |
| 568 | 568 | case 'xObject': |
| 569 | - $o['info']['xObjects'][]=array('objNum'=>$options['objNum'],'label'=>$options['label']); |
|
| 569 | + $o['info']['xObjects'][] = array('objNum'=>$options['objNum'], 'label'=>$options['label']); |
|
| 570 | 570 | break; |
| 571 | 571 | case 'out': |
| 572 | 572 | if (count($o['info']['pages'])) { |
| 573 | - $res="\n".$id." 0 obj\n<< /Type /Pages /Kids ["; |
|
| 573 | + $res = "\n".$id." 0 obj\n<< /Type /Pages /Kids ["; |
|
| 574 | 574 | foreach ($o['info']['pages'] as $k => $v) { |
| 575 | - $res.=$v." 0 R "; |
|
| 575 | + $res .= $v." 0 R "; |
|
| 576 | 576 | } |
| 577 | - $res.="] /Count ".count($this->objects[$id]['info']['pages']); |
|
| 577 | + $res .= "] /Count ".count($this->objects[$id]['info']['pages']); |
|
| 578 | 578 | if ((isset($o['info']['fonts']) && count($o['info']['fonts'])) || isset($o['info']['procset'])) { |
| 579 | - $res.=" /Resources <<"; |
|
| 579 | + $res .= " /Resources <<"; |
|
| 580 | 580 | if (isset($o['info']['procset'])) { |
| 581 | - $res.=" /ProcSet ".$o['info']['procset']; |
|
| 581 | + $res .= " /ProcSet ".$o['info']['procset']; |
|
| 582 | 582 | } |
| 583 | 583 | if (isset($o['info']['fonts']) && count($o['info']['fonts'])) { |
| 584 | - $res.=" /Font << "; |
|
| 584 | + $res .= " /Font << "; |
|
| 585 | 585 | foreach ($o['info']['fonts'] as $finfo) { |
| 586 | - $res.=" /F".$finfo['fontNum']." ".$finfo['objNum']." 0 R"; |
|
| 586 | + $res .= " /F".$finfo['fontNum']." ".$finfo['objNum']." 0 R"; |
|
| 587 | 587 | } |
| 588 | - $res.=" >>"; |
|
| 588 | + $res .= " >>"; |
|
| 589 | 589 | } |
| 590 | 590 | if (isset($o['info']['xObjects']) && count($o['info']['xObjects'])) { |
| 591 | - $res.=" /XObject << "; |
|
| 591 | + $res .= " /XObject << "; |
|
| 592 | 592 | foreach ($o['info']['xObjects'] as $finfo) { |
| 593 | - $res.=" /".$finfo['label']." ".$finfo['objNum']." 0 R"; |
|
| 593 | + $res .= " /".$finfo['label']." ".$finfo['objNum']." 0 R"; |
|
| 594 | 594 | } |
| 595 | - $res.=" >>"; |
|
| 595 | + $res .= " >>"; |
|
| 596 | 596 | } |
| 597 | - $res.=" >>"; |
|
| 597 | + $res .= " >>"; |
|
| 598 | 598 | if (isset($o['info']['mediaBox'])) { |
| 599 | - $tmp=$o['info']['mediaBox']; |
|
| 600 | - $res.=" /MediaBox [".sprintf('%.3F', $tmp[0]).' '.sprintf('%.3F', $tmp[1]).' '.sprintf('%.3F', $tmp[2]).' '.sprintf('%.3F', $tmp[3]).']'; |
|
| 599 | + $tmp = $o['info']['mediaBox']; |
|
| 600 | + $res .= " /MediaBox [".sprintf('%.3F', $tmp[0]).' '.sprintf('%.3F', $tmp[1]).' '.sprintf('%.3F', $tmp[2]).' '.sprintf('%.3F', $tmp[3]).']'; |
|
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | - $res.=" >>\nendobj"; |
|
| 603 | + $res .= " >>\nendobj"; |
|
| 604 | 604 | } else { |
| 605 | - $res="\n".$id." 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj"; |
|
| 605 | + $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj"; |
|
| 606 | 606 | } |
| 607 | 607 | return $res; |
| 608 | 608 | break; |
@@ -617,14 +617,14 @@ discard block |
||
| 617 | 617 | { |
| 618 | 618 | switch ($action) { |
| 619 | 619 | case 'new': |
| 620 | - $this->objects[$id]=array('t'=>'redirect','data'=>$options['data'],'info'=>array()); |
|
| 621 | - $this->o_pages($this->currentNode, 'xObject', array('label'=>$options['label'],'objNum'=>$id)); |
|
| 620 | + $this->objects[$id] = array('t'=>'redirect', 'data'=>$options['data'], 'info'=>array()); |
|
| 621 | + $this->o_pages($this->currentNode, 'xObject', array('label'=>$options['label'], 'objNum'=>$id)); |
|
| 622 | 622 | break; |
| 623 | 623 | case 'out': |
| 624 | - $o =& $this->objects[$id]; |
|
| 625 | - $tmp=$o['data']; |
|
| 626 | - $res= "\n".$id." 0 obj\n<<"; |
|
| 627 | - $res.="/R".$o['data']." ".$o['data']." 0 R>>\nendobj"; |
|
| 624 | + $o = & $this->objects[$id]; |
|
| 625 | + $tmp = $o['data']; |
|
| 626 | + $res = "\n".$id." 0 obj\n<<"; |
|
| 627 | + $res .= "/R".$o['data']." ".$o['data']." 0 R>>\nendobj"; |
|
| 628 | 628 | return $res; |
| 629 | 629 | break; |
| 630 | 630 | } |
@@ -636,26 +636,26 @@ discard block |
||
| 636 | 636 | */ |
| 637 | 637 | private function o_outlines($id, $action, $options = '') |
| 638 | 638 | { |
| 639 | - if ($action!='new') { |
|
| 640 | - $o =& $this->objects[$id]; |
|
| 639 | + if ($action != 'new') { |
|
| 640 | + $o = & $this->objects[$id]; |
|
| 641 | 641 | } |
| 642 | 642 | switch ($action) { |
| 643 | 643 | case 'new': |
| 644 | - $this->objects[$id]=array('t'=>'outlines','info'=>array('outlines'=>array())); |
|
| 644 | + $this->objects[$id] = array('t'=>'outlines', 'info'=>array('outlines'=>array())); |
|
| 645 | 645 | $this->o_catalog($this->catalogId, 'outlines', $id); |
| 646 | 646 | break; |
| 647 | 647 | case 'outline': |
| 648 | - $o['info']['outlines'][]=$options; |
|
| 648 | + $o['info']['outlines'][] = $options; |
|
| 649 | 649 | break; |
| 650 | 650 | case 'out': |
| 651 | 651 | if (count($o['info']['outlines'])) { |
| 652 | - $res="\n".$id." 0 obj\n<< /Type /Outlines /Kids ["; |
|
| 652 | + $res = "\n".$id." 0 obj\n<< /Type /Outlines /Kids ["; |
|
| 653 | 653 | foreach ($o['info']['outlines'] as $k => $v) { |
| 654 | - $res.=$v." 0 R "; |
|
| 654 | + $res .= $v." 0 R "; |
|
| 655 | 655 | } |
| 656 | - $res.="] /Count ".count($o['info']['outlines'])." >>\nendobj"; |
|
| 656 | + $res .= "] /Count ".count($o['info']['outlines'])." >>\nendobj"; |
|
| 657 | 657 | } else { |
| 658 | - $res="\n".$id." 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj"; |
|
| 658 | + $res = "\n".$id." 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj"; |
|
| 659 | 659 | } |
| 660 | 660 | return $res; |
| 661 | 661 | break; |
@@ -668,36 +668,36 @@ discard block |
||
| 668 | 668 | */ |
| 669 | 669 | private function o_font($id, $action, $options = '') |
| 670 | 670 | { |
| 671 | - if ($action!='new') { |
|
| 672 | - $o =& $this->objects[$id]; |
|
| 671 | + if ($action != 'new') { |
|
| 672 | + $o = & $this->objects[$id]; |
|
| 673 | 673 | } |
| 674 | 674 | switch ($action) { |
| 675 | 675 | case 'new': |
| 676 | - $this->objects[$id]=array('t'=>'font','info'=>array('name'=>$options['name'], 'fontFileName' => $options['fontFileName'],'SubType'=>'Type1')); |
|
| 677 | - $fontNum=$this->numFonts; |
|
| 678 | - $this->objects[$id]['info']['fontNum']=$fontNum; |
|
| 676 | + $this->objects[$id] = array('t'=>'font', 'info'=>array('name'=>$options['name'], 'fontFileName' => $options['fontFileName'], 'SubType'=>'Type1')); |
|
| 677 | + $fontNum = $this->numFonts; |
|
| 678 | + $this->objects[$id]['info']['fontNum'] = $fontNum; |
|
| 679 | 679 | // deal with the encoding and the differences |
| 680 | 680 | if (isset($options['differences'])) { |
| 681 | 681 | // then we'll need an encoding dictionary |
| 682 | 682 | $this->numObj++; |
| 683 | 683 | $this->o_fontEncoding($this->numObj, 'new', $options); |
| 684 | - $this->objects[$id]['info']['encodingDictionary']=$this->numObj; |
|
| 684 | + $this->objects[$id]['info']['encodingDictionary'] = $this->numObj; |
|
| 685 | 685 | } elseif (isset($options['encoding'])) { |
| 686 | 686 | // we can specify encoding here |
| 687 | 687 | switch ($options['encoding']) { |
| 688 | 688 | case 'WinAnsiEncoding': |
| 689 | 689 | case 'MacRomanEncoding': |
| 690 | 690 | case 'MacExpertEncoding': |
| 691 | - $this->objects[$id]['info']['encoding']=$options['encoding']; |
|
| 691 | + $this->objects[$id]['info']['encoding'] = $options['encoding']; |
|
| 692 | 692 | break; |
| 693 | 693 | case 'none': |
| 694 | 694 | break; |
| 695 | 695 | default: |
| 696 | - $this->objects[$id]['info']['encoding']='WinAnsiEncoding'; |
|
| 696 | + $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding'; |
|
| 697 | 697 | break; |
| 698 | 698 | } |
| 699 | 699 | } else { |
| 700 | - $this->objects[$id]['info']['encoding']='WinAnsiEncoding'; |
|
| 700 | + $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding'; |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | if ($this->fonts[$options['fontFileName']]['isUnicode']) { |
@@ -714,8 +714,8 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | $stream = "/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo <</Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000> <FFFF>\nendcodespacerange\n1 beginbfrange\n<0000> <FFFF> <0000>\nendbfrange\nendcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\n"; |
| 716 | 716 | |
| 717 | - $res = "<</Length " . mb_strlen($stream, '8bit') . " >>\n"; |
|
| 718 | - $res .= "stream\n" . $stream . "\nendstream"; |
|
| 717 | + $res = "<</Length ".mb_strlen($stream, '8bit')." >>\n"; |
|
| 718 | + $res .= "stream\n".$stream."\nendstream"; |
|
| 719 | 719 | |
| 720 | 720 | $this->objects[$toUnicodeId]['c'] = $res; |
| 721 | 721 | |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | $this->objects[$id]['info']['cidFont'] = $cidFontId; |
| 725 | 725 | } |
| 726 | 726 | // also tell the pages node about the new font |
| 727 | - $this->o_pages($this->currentNode, 'font', array('fontNum'=>$fontNum,'objNum'=>$id)); |
|
| 727 | + $this->o_pages($this->currentNode, 'font', array('fontNum'=>$fontNum, 'objNum'=>$id)); |
|
| 728 | 728 | break; |
| 729 | 729 | case 'add': |
| 730 | 730 | foreach ($options as $k => $v) { |
@@ -757,8 +757,8 @@ discard block |
||
| 757 | 757 | $pfbid = $this->objects[$o['info']['FontDescriptor']]['info']['FontFile2']; |
| 758 | 758 | // if subsetting is set |
| 759 | 759 | if ($this->fonts[$o['info']['fontFileName']]['isSubset'] && !empty($this->fonts[$o['info']['fontFileName']]['subset'])) { |
| 760 | - $this->debug('subset font for ' . $o['info']['fontFileName'], E_USER_NOTICE); |
|
| 761 | - $subsetFontName = "AAAAAD+" . $o['info']['name']; |
|
| 760 | + $this->debug('subset font for '.$o['info']['fontFileName'], E_USER_NOTICE); |
|
| 761 | + $subsetFontName = "AAAAAD+".$o['info']['name']; |
|
| 762 | 762 | $o['info']['name'] = $subsetFontName; |
| 763 | 763 | // find descendant font |
| 764 | 764 | $this->objects[$o['info']['cidFont']]['info']['name'] = $subsetFontName; |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | // combine all used characters as string |
| 771 | 771 | $s = implode('', array_keys($this->fonts[$o['info']['fontFileName']]['subset'])); |
| 772 | 772 | // submit the string to TTFsubset class to return the subset (as binary) |
| 773 | - $data = $t->doSubset($o['info']['fontFileName'] . '.ttf', $s, null); |
|
| 773 | + $data = $t->doSubset($o['info']['fontFileName'].'.ttf', $s, null); |
|
| 774 | 774 | // $data is the new (subset) of the font font |
| 775 | 775 | //file_put_contents($o['info']['name'] . '.ttf', $data); |
| 776 | 776 | |
@@ -783,22 +783,22 @@ discard block |
||
| 783 | 783 | } |
| 784 | 784 | $cidwidth = $newcidwidth; |
| 785 | 785 | } else { |
| 786 | - $data = file_get_contents($o['info']['fontFileName']. '.ttf'); |
|
| 786 | + $data = file_get_contents($o['info']['fontFileName'].'.ttf'); |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | // TODO: cache the subset |
| 790 | 790 | |
| 791 | 791 | $l1 = strlen($data); |
| 792 | - $this->objects[$pfbid]['c'].= $data; |
|
| 792 | + $this->objects[$pfbid]['c'] .= $data; |
|
| 793 | 793 | $this->o_contents($pfbid, 'add', array('Length1'=>$l1)); |
| 794 | 794 | } elseif (isset($this->objects[$o['info']['FontDescriptor']]['info']['FontFile'])) { |
| 795 | 795 | // find FontFile id - used for PFB fonts |
| 796 | 796 | $pfbid = $this->objects[$o['info']['FontDescriptor']]['info']['FontFile']; |
| 797 | - $data = file_get_contents($o['info']['fontFileName']. '.pfb'); |
|
| 798 | - $l1 = strpos($data, 'eexec')+6; |
|
| 799 | - $l2 = strpos($data, '00000000')-$l1; |
|
| 800 | - $l3 = strlen($data)-$l2-$l1; |
|
| 801 | - $this->o_contents($pfbid, 'add', array('Length1'=>$l1,'Length2'=>$l2,'Length3'=>$l3)); |
|
| 797 | + $data = file_get_contents($o['info']['fontFileName'].'.pfb'); |
|
| 798 | + $l1 = strpos($data, 'eexec') + 6; |
|
| 799 | + $l2 = strpos($data, '00000000') - $l1; |
|
| 800 | + $l3 = strlen($data) - $l2 - $l1; |
|
| 801 | + $this->o_contents($pfbid, 'add', array('Length1'=>$l1, 'Length2'=>$l2, 'Length3'=>$l3)); |
|
| 802 | 802 | } else { |
| 803 | 803 | $this->debug("Failed to select the correct font program", E_USER_WARNING); |
| 804 | 804 | } |
@@ -816,32 +816,32 @@ discard block |
||
| 816 | 816 | $res = "\n$id 0 obj\n<</Type /Font /Subtype /Type0 /BaseFont /".$o['info']['name'].""; |
| 817 | 817 | // The horizontal identity mapping for 2-byte CIDs; may be used |
| 818 | 818 | // with CIDFonts using any Registry, Ordering, and Supplement values. |
| 819 | - $res.= " /Encoding /Identity-H /DescendantFonts [".$o['info']['cidFont']." 0 R] /ToUnicode ".$o['info']['toUnicode']." 0 R >>\n"; |
|
| 820 | - $res.= "endobj"; |
|
| 819 | + $res .= " /Encoding /Identity-H /DescendantFonts [".$o['info']['cidFont']." 0 R] /ToUnicode ".$o['info']['toUnicode']." 0 R >>\n"; |
|
| 820 | + $res .= "endobj"; |
|
| 821 | 821 | } else { |
| 822 | - $res="\n".$id." 0 obj\n<< /Type /Font /Subtype /".$o['info']['SubType']." "; |
|
| 823 | - $res.="/Name /F".$o['info']['fontNum']." "; |
|
| 824 | - $res.="/BaseFont /".$o['info']['name']." "; |
|
| 822 | + $res = "\n".$id." 0 obj\n<< /Type /Font /Subtype /".$o['info']['SubType']." "; |
|
| 823 | + $res .= "/Name /F".$o['info']['fontNum']." "; |
|
| 824 | + $res .= "/BaseFont /".$o['info']['name']." "; |
|
| 825 | 825 | if (isset($o['info']['encodingDictionary'])) { |
| 826 | 826 | // then place a reference to the dictionary |
| 827 | - $res.="/Encoding ".$o['info']['encodingDictionary']." 0 R "; |
|
| 827 | + $res .= "/Encoding ".$o['info']['encodingDictionary']." 0 R "; |
|
| 828 | 828 | } elseif (isset($o['info']['encoding'])) { |
| 829 | 829 | // use the specified encoding |
| 830 | - $res.="/Encoding /".$o['info']['encoding']." "; |
|
| 830 | + $res .= "/Encoding /".$o['info']['encoding']." "; |
|
| 831 | 831 | } |
| 832 | 832 | if (isset($o['info']['FirstChar'])) { |
| 833 | - $res.="/FirstChar ".$o['info']['FirstChar']." "; |
|
| 833 | + $res .= "/FirstChar ".$o['info']['FirstChar']." "; |
|
| 834 | 834 | } |
| 835 | 835 | if (isset($o['info']['LastChar'])) { |
| 836 | - $res.="/LastChar ".$o['info']['LastChar']." "; |
|
| 836 | + $res .= "/LastChar ".$o['info']['LastChar']." "; |
|
| 837 | 837 | } |
| 838 | 838 | if (isset($o['info']['Widths'])) { |
| 839 | - $res.="/Widths ".$o['info']['Widths']." 0 R "; |
|
| 839 | + $res .= "/Widths ".$o['info']['Widths']." 0 R "; |
|
| 840 | 840 | } |
| 841 | 841 | if (isset($o['info']['FontDescriptor'])) { |
| 842 | - $res.="/FontDescriptor ".$o['info']['FontDescriptor']." 0 R "; |
|
| 842 | + $res .= "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R "; |
|
| 843 | 843 | } |
| 844 | - $res.=">>\nendobj"; |
|
| 844 | + $res .= ">>\nendobj"; |
|
| 845 | 845 | } |
| 846 | 846 | return $res; |
| 847 | 847 | break; |
@@ -854,15 +854,15 @@ discard block |
||
| 854 | 854 | */ |
| 855 | 855 | private function o_fontDescriptor($id, $action, $options = '') |
| 856 | 856 | { |
| 857 | - if ($action!='new') { |
|
| 858 | - $o =& $this->objects[$id]; |
|
| 857 | + if ($action != 'new') { |
|
| 858 | + $o = & $this->objects[$id]; |
|
| 859 | 859 | } |
| 860 | 860 | switch ($action) { |
| 861 | 861 | case 'new': |
| 862 | - $this->objects[$id]=array('t'=>'fontDescriptor','info'=>$options); |
|
| 862 | + $this->objects[$id] = array('t'=>'fontDescriptor', 'info'=>$options); |
|
| 863 | 863 | break; |
| 864 | 864 | case 'out': |
| 865 | - $res="\n".$id." 0 obj\n<< /Type /FontDescriptor "; |
|
| 865 | + $res = "\n".$id." 0 obj\n<< /Type /FontDescriptor "; |
|
| 866 | 866 | foreach ($o['info'] as $label => $value) { |
| 867 | 867 | switch ($label) { |
| 868 | 868 | case 'Ascent': |
@@ -879,23 +879,23 @@ discard block |
||
| 879 | 879 | case 'XHeight': |
| 880 | 880 | case 'CharSet': |
| 881 | 881 | if (strlen($value)) { |
| 882 | - $res.='/'.$label.' '.$value." "; |
|
| 882 | + $res .= '/'.$label.' '.$value." "; |
|
| 883 | 883 | } |
| 884 | 884 | break; |
| 885 | 885 | case 'FontFile': |
| 886 | 886 | case 'FontFile2': |
| 887 | 887 | case 'FontFile3': |
| 888 | - $res.='/'.$label.' '.$value." 0 R "; |
|
| 888 | + $res .= '/'.$label.' '.$value." 0 R "; |
|
| 889 | 889 | break; |
| 890 | 890 | case 'FontBBox': |
| 891 | - $res.='/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."] "; |
|
| 891 | + $res .= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."] "; |
|
| 892 | 892 | break; |
| 893 | 893 | case 'FontName': |
| 894 | - $res.='/'.$label.' /'.$value." "; |
|
| 894 | + $res .= '/'.$label.' /'.$value." "; |
|
| 895 | 895 | break; |
| 896 | 896 | } |
| 897 | 897 | } |
| 898 | - $res.=">>\nendobj"; |
|
| 898 | + $res .= ">>\nendobj"; |
|
| 899 | 899 | return $res; |
| 900 | 900 | break; |
| 901 | 901 | } |
@@ -907,34 +907,34 @@ discard block |
||
| 907 | 907 | */ |
| 908 | 908 | private function o_fontEncoding($id, $action, $options = '') |
| 909 | 909 | { |
| 910 | - if ($action!='new') { |
|
| 911 | - $o =& $this->objects[$id]; |
|
| 910 | + if ($action != 'new') { |
|
| 911 | + $o = & $this->objects[$id]; |
|
| 912 | 912 | } |
| 913 | 913 | switch ($action) { |
| 914 | 914 | case 'new': |
| 915 | 915 | // the options array should contain 'differences' and maybe 'encoding' |
| 916 | - $this->objects[$id]=array('t'=>'fontEncoding','info'=>$options); |
|
| 916 | + $this->objects[$id] = array('t'=>'fontEncoding', 'info'=>$options); |
|
| 917 | 917 | break; |
| 918 | 918 | case 'out': |
| 919 | - $res="\n".$id." 0 obj\n<< /Type /Encoding "; |
|
| 919 | + $res = "\n".$id." 0 obj\n<< /Type /Encoding "; |
|
| 920 | 920 | if (!isset($o['info']['encoding'])) { |
| 921 | - $o['info']['encoding']='WinAnsiEncoding'; |
|
| 921 | + $o['info']['encoding'] = 'WinAnsiEncoding'; |
|
| 922 | 922 | } |
| 923 | - if ($o['info']['encoding']!='none') { |
|
| 924 | - $res.="/BaseEncoding /".$o['info']['encoding']." "; |
|
| 923 | + if ($o['info']['encoding'] != 'none') { |
|
| 924 | + $res .= "/BaseEncoding /".$o['info']['encoding']." "; |
|
| 925 | 925 | } |
| 926 | - $res.="/Differences ["; |
|
| 927 | - $onum=-100; |
|
| 926 | + $res .= "/Differences ["; |
|
| 927 | + $onum = -100; |
|
| 928 | 928 | foreach ($o['info']['differences'] as $num => $label) { |
| 929 | - if ($num!=$onum+1) { |
|
| 929 | + if ($num != $onum + 1) { |
|
| 930 | 930 | // we cannot make use of consecutive numbering |
| 931 | - $res.= " ".$num." /".$label; |
|
| 931 | + $res .= " ".$num." /".$label; |
|
| 932 | 932 | } else { |
| 933 | - $res.= " /".$label; |
|
| 933 | + $res .= " /".$label; |
|
| 934 | 934 | } |
| 935 | - $onum=$num; |
|
| 935 | + $onum = $num; |
|
| 936 | 936 | } |
| 937 | - $res.="] >>\nendobj"; |
|
| 937 | + $res .= "] >>\nendobj"; |
|
| 938 | 938 | return $res; |
| 939 | 939 | break; |
| 940 | 940 | } |
@@ -987,13 +987,13 @@ discard block |
||
| 987 | 987 | |
| 988 | 988 | case 'out': |
| 989 | 989 | $res = "\n$id 0 obj\n"; |
| 990 | - $res.= "<</Type /Font /Subtype /CIDFontType2 /BaseFont /".$o['info']['name']." /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>"; |
|
| 990 | + $res .= "<</Type /Font /Subtype /CIDFontType2 /BaseFont /".$o['info']['name']." /CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>"; |
|
| 991 | 991 | if (isset($o['info']['FontDescriptor'])) { |
| 992 | - $res.= " /FontDescriptor ".$o['info']['FontDescriptor']." 0 R"; |
|
| 992 | + $res .= " /FontDescriptor ".$o['info']['FontDescriptor']." 0 R"; |
|
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | if (isset($o['info']['MissingWidth'])) { |
| 996 | - $res.= " /DW ".$o['info']['MissingWidth'].""; |
|
| 996 | + $res .= " /DW ".$o['info']['MissingWidth'].""; |
|
| 997 | 997 | } |
| 998 | 998 | |
| 999 | 999 | if (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) { |
@@ -1002,14 +1002,14 @@ discard block |
||
| 1002 | 1002 | foreach ($cid_widths as $cid => $width) { |
| 1003 | 1003 | $w .= "$cid [$width] "; |
| 1004 | 1004 | } |
| 1005 | - $res.= " /W [$w]"; |
|
| 1005 | + $res .= " /W [$w]"; |
|
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | if ($this->embedFont) { |
| 1009 | - $res.= " /CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R"; |
|
| 1009 | + $res .= " /CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R"; |
|
| 1010 | 1010 | } |
| 1011 | - $res.= " >>\n"; |
|
| 1012 | - $res.= "endobj"; |
|
| 1011 | + $res .= " >>\n"; |
|
| 1012 | + $res .= "endobj"; |
|
| 1013 | 1013 | |
| 1014 | 1014 | return $res; |
| 1015 | 1015 | } |
@@ -1036,19 +1036,19 @@ discard block |
||
| 1036 | 1036 | $tmp = $this->fonts[$fontFileName]['CIDtoGID'] = base64_decode($this->fonts[$fontFileName]['CIDtoGID']); |
| 1037 | 1037 | |
| 1038 | 1038 | if (isset($o['raw'])) { |
| 1039 | - $res.= $tmp; |
|
| 1039 | + $res .= $tmp; |
|
| 1040 | 1040 | } else { |
| 1041 | - $res.= "<<"; |
|
| 1041 | + $res .= "<<"; |
|
| 1042 | 1042 | if (function_exists('gzcompress') && $this->options['compression']) { |
| 1043 | 1043 | // then implement ZLIB based compression on this content stream |
| 1044 | 1044 | $tmp = gzcompress($tmp, $this->options['compression']); |
| 1045 | - $res.= " /Filter /FlateDecode"; |
|
| 1045 | + $res .= " /Filter /FlateDecode"; |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | - $res.= " /Length ".mb_strlen($tmp, '8bit') .">>\nstream\n$tmp\nendstream"; |
|
| 1048 | + $res .= " /Length ".mb_strlen($tmp, '8bit').">>\nstream\n$tmp\nendstream"; |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | - $res.= "\nendobj"; |
|
| 1051 | + $res .= "\nendobj"; |
|
| 1052 | 1052 | return $res; |
| 1053 | 1053 | } |
| 1054 | 1054 | } |
@@ -1059,14 +1059,14 @@ discard block |
||
| 1059 | 1059 | */ |
| 1060 | 1060 | private function o_info($id, $action, $options = '') |
| 1061 | 1061 | { |
| 1062 | - if ($action!='new') { |
|
| 1063 | - $o =& $this->objects[$id]; |
|
| 1062 | + if ($action != 'new') { |
|
| 1063 | + $o = & $this->objects[$id]; |
|
| 1064 | 1064 | } |
| 1065 | 1065 | switch ($action) { |
| 1066 | 1066 | case 'new': |
| 1067 | - $this->infoObject=$id; |
|
| 1068 | - $date='D:'.date('Ymd'); |
|
| 1069 | - $this->objects[$id]=array('t'=>'info','info'=>array('Creator'=>'R and OS php pdf writer, http://www.ros.co.nz','CreationDate'=>$date)); |
|
| 1067 | + $this->infoObject = $id; |
|
| 1068 | + $date = 'D:'.date('Ymd'); |
|
| 1069 | + $this->objects[$id] = array('t'=>'info', 'info'=>array('Creator'=>'R and OS php pdf writer, http://www.ros.co.nz', 'CreationDate'=>$date)); |
|
| 1070 | 1070 | break; |
| 1071 | 1071 | case 'Title': |
| 1072 | 1072 | case 'Author': |
@@ -1077,23 +1077,23 @@ discard block |
||
| 1077 | 1077 | case 'CreationDate': |
| 1078 | 1078 | case 'ModDate': |
| 1079 | 1079 | case 'Trapped': |
| 1080 | - $o['info'][$action]=$options; |
|
| 1080 | + $o['info'][$action] = $options; |
|
| 1081 | 1081 | break; |
| 1082 | 1082 | case 'out': |
| 1083 | 1083 | if ($this->encrypted) { |
| 1084 | 1084 | $this->encryptInit($id); |
| 1085 | 1085 | } |
| 1086 | - $res="\n".$id." 0 obj\n<< "; |
|
| 1086 | + $res = "\n".$id." 0 obj\n<< "; |
|
| 1087 | 1087 | foreach ($o['info'] as $k => $v) { |
| 1088 | - $res.='/'.$k.' ('; |
|
| 1088 | + $res .= '/'.$k.' ('; |
|
| 1089 | 1089 | if ($this->encrypted) { |
| 1090 | - $res.=$this->filterText($this->ARC4($v), true, false); |
|
| 1090 | + $res .= $this->filterText($this->ARC4($v), true, false); |
|
| 1091 | 1091 | } else { |
| 1092 | - $res.=$this->filterText($v, true, false); |
|
| 1092 | + $res .= $this->filterText($v, true, false); |
|
| 1093 | 1093 | } |
| 1094 | - $res.=") "; |
|
| 1094 | + $res .= ") "; |
|
| 1095 | 1095 | } |
| 1096 | - $res.=">>\nendobj"; |
|
| 1096 | + $res .= ">>\nendobj"; |
|
| 1097 | 1097 | return $res; |
| 1098 | 1098 | break; |
| 1099 | 1099 | } |
@@ -1105,39 +1105,39 @@ discard block |
||
| 1105 | 1105 | */ |
| 1106 | 1106 | private function o_action($id, $action, $options = '') |
| 1107 | 1107 | { |
| 1108 | - if ($action!='new') { |
|
| 1109 | - $o =& $this->objects[$id]; |
|
| 1108 | + if ($action != 'new') { |
|
| 1109 | + $o = & $this->objects[$id]; |
|
| 1110 | 1110 | } |
| 1111 | 1111 | switch ($action) { |
| 1112 | 1112 | case 'new': |
| 1113 | 1113 | if (is_array($options)) { |
| 1114 | - $this->objects[$id]=array('t'=>'action','info'=>$options,'type'=>$options['type']); |
|
| 1114 | + $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>$options['type']); |
|
| 1115 | 1115 | } else { |
| 1116 | 1116 | // then assume a URI action |
| 1117 | - $this->objects[$id]=array('t'=>'action','info'=>$options,'type'=>'URI'); |
|
| 1117 | + $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>'URI'); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | break; |
| 1120 | 1120 | case 'out': |
| 1121 | 1121 | if ($this->encrypted) { |
| 1122 | 1122 | $this->encryptInit($id); |
| 1123 | 1123 | } |
| 1124 | - $res="\n".$id." 0 obj\n<< /Type /Action"; |
|
| 1124 | + $res = "\n".$id." 0 obj\n<< /Type /Action"; |
|
| 1125 | 1125 | switch ($o['type']) { |
| 1126 | 1126 | case 'ilink': |
| 1127 | 1127 | // there will be an 'label' setting, this is the name of the destination |
| 1128 | - $res.=" /S /GoTo /D ".$this->destinations[(string)$o['info']['label']]." 0 R"; |
|
| 1128 | + $res .= " /S /GoTo /D ".$this->destinations[(string)$o['info']['label']]." 0 R"; |
|
| 1129 | 1129 | break; |
| 1130 | 1130 | case 'URI': |
| 1131 | - $res.=" /S /URI /URI ("; |
|
| 1131 | + $res .= " /S /URI /URI ("; |
|
| 1132 | 1132 | if ($this->encrypted) { |
| 1133 | - $res.=$this->filterText($this->ARC4($o['info']), true, false); |
|
| 1133 | + $res .= $this->filterText($this->ARC4($o['info']), true, false); |
|
| 1134 | 1134 | } else { |
| 1135 | - $res.=$this->filterText($o['info'], true, false); |
|
| 1135 | + $res .= $this->filterText($o['info'], true, false); |
|
| 1136 | 1136 | } |
| 1137 | - $res.=")"; |
|
| 1137 | + $res .= ")"; |
|
| 1138 | 1138 | break; |
| 1139 | 1139 | } |
| 1140 | - $res.=" >>\nendobj"; |
|
| 1140 | + $res .= " >>\nendobj"; |
|
| 1141 | 1141 | return $res; |
| 1142 | 1142 | break; |
| 1143 | 1143 | } |
@@ -1150,8 +1150,8 @@ discard block |
||
| 1150 | 1150 | */ |
| 1151 | 1151 | private function o_annotation($id, $action, $options = '') |
| 1152 | 1152 | { |
| 1153 | - if ($action!='new') { |
|
| 1154 | - $o =& $this->objects[$id]; |
|
| 1153 | + if ($action != 'new') { |
|
| 1154 | + $o = & $this->objects[$id]; |
|
| 1155 | 1155 | } |
| 1156 | 1156 | switch ($action) { |
| 1157 | 1157 | case 'new': |
@@ -1161,38 +1161,38 @@ discard block |
||
| 1161 | 1161 | // and add the action object which is going to be required |
| 1162 | 1162 | switch ($options['type']) { |
| 1163 | 1163 | case 'link': |
| 1164 | - $this->objects[$id]=array('t'=>'annotation','info'=>$options); |
|
| 1164 | + $this->objects[$id] = array('t'=>'annotation', 'info'=>$options); |
|
| 1165 | 1165 | $this->numObj++; |
| 1166 | 1166 | $this->o_action($this->numObj, 'new', $options['url']); |
| 1167 | - $this->objects[$id]['info']['actionId']=$this->numObj; |
|
| 1167 | + $this->objects[$id]['info']['actionId'] = $this->numObj; |
|
| 1168 | 1168 | break; |
| 1169 | 1169 | case 'ilink': |
| 1170 | 1170 | // this is to a named internal link |
| 1171 | 1171 | $label = $options['label']; |
| 1172 | - $this->objects[$id]=array('t'=>'annotation','info'=>$options); |
|
| 1172 | + $this->objects[$id] = array('t'=>'annotation', 'info'=>$options); |
|
| 1173 | 1173 | $this->numObj++; |
| 1174 | - $this->o_action($this->numObj, 'new', array('type'=>'ilink','label'=>$label)); |
|
| 1175 | - $this->objects[$id]['info']['actionId']=$this->numObj; |
|
| 1174 | + $this->o_action($this->numObj, 'new', array('type'=>'ilink', 'label'=>$label)); |
|
| 1175 | + $this->objects[$id]['info']['actionId'] = $this->numObj; |
|
| 1176 | 1176 | break; |
| 1177 | 1177 | } |
| 1178 | 1178 | break; |
| 1179 | 1179 | case 'out': |
| 1180 | - $res="\n".$id." 0 obj << /Type /Annot"; |
|
| 1180 | + $res = "\n".$id." 0 obj << /Type /Annot"; |
|
| 1181 | 1181 | switch ($o['info']['type']) { |
| 1182 | 1182 | case 'link': |
| 1183 | 1183 | case 'ilink': |
| 1184 | - $res.= " /Subtype /Link"; |
|
| 1184 | + $res .= " /Subtype /Link"; |
|
| 1185 | 1185 | break; |
| 1186 | 1186 | } |
| 1187 | - $res.=" /A ".$o['info']['actionId']." 0 R"; |
|
| 1188 | - $res.=" /Border [0 0 0]"; |
|
| 1189 | - $res.=" /H /I"; |
|
| 1190 | - $res.=" /Rect [ "; |
|
| 1187 | + $res .= " /A ".$o['info']['actionId']." 0 R"; |
|
| 1188 | + $res .= " /Border [0 0 0]"; |
|
| 1189 | + $res .= " /H /I"; |
|
| 1190 | + $res .= " /Rect [ "; |
|
| 1191 | 1191 | foreach ($o['info']['rect'] as $v) { |
| 1192 | - $res.= sprintf("%.4f ", $v); |
|
| 1192 | + $res .= sprintf("%.4f ", $v); |
|
| 1193 | 1193 | } |
| 1194 | - $res.="]"; |
|
| 1195 | - $res.=" >>\nendobj"; |
|
| 1194 | + $res .= "]"; |
|
| 1195 | + $res .= " >>\nendobj"; |
|
| 1196 | 1196 | return $res; |
| 1197 | 1197 | break; |
| 1198 | 1198 | } |
@@ -1204,66 +1204,66 @@ discard block |
||
| 1204 | 1204 | */ |
| 1205 | 1205 | private function o_page($id, $action, $options = '') |
| 1206 | 1206 | { |
| 1207 | - if ($action!='new') { |
|
| 1208 | - $o =& $this->objects[$id]; |
|
| 1207 | + if ($action != 'new') { |
|
| 1208 | + $o = & $this->objects[$id]; |
|
| 1209 | 1209 | } |
| 1210 | 1210 | switch ($action) { |
| 1211 | 1211 | case 'new': |
| 1212 | 1212 | $this->numPages++; |
| 1213 | - $this->objects[$id]=array('t'=>'page','info'=>array('parent'=>$this->currentNode,'pageNum'=>$this->numPages)); |
|
| 1213 | + $this->objects[$id] = array('t'=>'page', 'info'=>array('parent'=>$this->currentNode, 'pageNum'=>$this->numPages)); |
|
| 1214 | 1214 | if (is_array($options)) { |
| 1215 | 1215 | // then this must be a page insertion, array shoudl contain 'rid','pos'=[before|after] |
| 1216 | - $options['id']=$id; |
|
| 1216 | + $options['id'] = $id; |
|
| 1217 | 1217 | $this->o_pages($this->currentNode, 'page', $options); |
| 1218 | 1218 | } else { |
| 1219 | 1219 | $this->o_pages($this->currentNode, 'page', $id); |
| 1220 | 1220 | } |
| 1221 | - $this->currentPage=$id; |
|
| 1221 | + $this->currentPage = $id; |
|
| 1222 | 1222 | // make a contents object to go with this page |
| 1223 | 1223 | $this->numObj++; |
| 1224 | 1224 | $this->o_contents($this->numObj, 'new', $id); |
| 1225 | - $this->currentContents=$this->numObj; |
|
| 1226 | - $this->objects[$id]['info']['contents']=array(); |
|
| 1227 | - $this->objects[$id]['info']['contents'][]=$this->numObj; |
|
| 1225 | + $this->currentContents = $this->numObj; |
|
| 1226 | + $this->objects[$id]['info']['contents'] = array(); |
|
| 1227 | + $this->objects[$id]['info']['contents'][] = $this->numObj; |
|
| 1228 | 1228 | $match = ($this->numPages%2 ? 'odd' : 'even'); |
| 1229 | 1229 | foreach ($this->addLooseObjects as $oId => $target) { |
| 1230 | - if ($target=='all' || $match==$target) { |
|
| 1231 | - $this->objects[$id]['info']['contents'][]=$oId; |
|
| 1230 | + if ($target == 'all' || $match == $target) { |
|
| 1231 | + $this->objects[$id]['info']['contents'][] = $oId; |
|
| 1232 | 1232 | } |
| 1233 | 1233 | } |
| 1234 | 1234 | break; |
| 1235 | 1235 | case 'content': |
| 1236 | - $o['info']['contents'][]=$options; |
|
| 1236 | + $o['info']['contents'][] = $options; |
|
| 1237 | 1237 | break; |
| 1238 | 1238 | case 'annot': |
| 1239 | 1239 | // add an annotation to this page |
| 1240 | 1240 | if (!isset($o['info']['annot'])) { |
| 1241 | - $o['info']['annot']=array(); |
|
| 1241 | + $o['info']['annot'] = array(); |
|
| 1242 | 1242 | } |
| 1243 | 1243 | // $options should contain the id of the annotation dictionary |
| 1244 | - $o['info']['annot'][]=$options; |
|
| 1244 | + $o['info']['annot'][] = $options; |
|
| 1245 | 1245 | break; |
| 1246 | 1246 | case 'out': |
| 1247 | - $res="\n".$id." 0 obj\n<< /Type /Page"; |
|
| 1248 | - $res.=" /Parent ".$o['info']['parent']." 0 R"; |
|
| 1247 | + $res = "\n".$id." 0 obj\n<< /Type /Page"; |
|
| 1248 | + $res .= " /Parent ".$o['info']['parent']." 0 R"; |
|
| 1249 | 1249 | if (isset($o['info']['annot'])) { |
| 1250 | - $res.=" /Annots ["; |
|
| 1250 | + $res .= " /Annots ["; |
|
| 1251 | 1251 | foreach ($o['info']['annot'] as $aId) { |
| 1252 | - $res.=" ".$aId." 0 R"; |
|
| 1252 | + $res .= " ".$aId." 0 R"; |
|
| 1253 | 1253 | } |
| 1254 | - $res.=" ]"; |
|
| 1254 | + $res .= " ]"; |
|
| 1255 | 1255 | } |
| 1256 | 1256 | $count = count($o['info']['contents']); |
| 1257 | - if ($count==1) { |
|
| 1258 | - $res.=" /Contents ".$o['info']['contents'][0]." 0 R"; |
|
| 1259 | - } elseif ($count>1) { |
|
| 1260 | - $res.=" /Contents [ "; |
|
| 1257 | + if ($count == 1) { |
|
| 1258 | + $res .= " /Contents ".$o['info']['contents'][0]." 0 R"; |
|
| 1259 | + } elseif ($count > 1) { |
|
| 1260 | + $res .= " /Contents [ "; |
|
| 1261 | 1261 | foreach ($o['info']['contents'] as $cId) { |
| 1262 | - $res.=$cId." 0 R "; |
|
| 1262 | + $res .= $cId." 0 R "; |
|
| 1263 | 1263 | } |
| 1264 | - $res.="]"; |
|
| 1264 | + $res .= "]"; |
|
| 1265 | 1265 | } |
| 1266 | - $res.=" >>\nendobj"; |
|
| 1266 | + $res .= " >>\nendobj"; |
|
| 1267 | 1267 | return $res; |
| 1268 | 1268 | break; |
| 1269 | 1269 | } |
@@ -1275,35 +1275,35 @@ discard block |
||
| 1275 | 1275 | */ |
| 1276 | 1276 | private function o_contents($id, $action, $options = '') |
| 1277 | 1277 | { |
| 1278 | - if ($action!='new') { |
|
| 1279 | - $o =& $this->objects[$id]; |
|
| 1278 | + if ($action != 'new') { |
|
| 1279 | + $o = & $this->objects[$id]; |
|
| 1280 | 1280 | } |
| 1281 | 1281 | switch ($action) { |
| 1282 | 1282 | case 'new': |
| 1283 | - $this->objects[$id]=array('t'=>'contents','c'=>'','info'=>array()); |
|
| 1283 | + $this->objects[$id] = array('t'=>'contents', 'c'=>'', 'info'=>array()); |
|
| 1284 | 1284 | if (strlen($options) && intval($options)) { |
| 1285 | 1285 | // then this contents is the primary for a page |
| 1286 | - $this->objects[$id]['onPage']=$options; |
|
| 1287 | - } elseif ($options=='raw') { |
|
| 1286 | + $this->objects[$id]['onPage'] = $options; |
|
| 1287 | + } elseif ($options == 'raw') { |
|
| 1288 | 1288 | // then this page contains some other type of system object |
| 1289 | - $this->objects[$id]['raw']=1; |
|
| 1289 | + $this->objects[$id]['raw'] = 1; |
|
| 1290 | 1290 | } |
| 1291 | 1291 | break; |
| 1292 | 1292 | case 'add': |
| 1293 | 1293 | // add more options to the decleration |
| 1294 | 1294 | foreach ($options as $k => $v) { |
| 1295 | - $o['info'][$k]=$v; |
|
| 1295 | + $o['info'][$k] = $v; |
|
| 1296 | 1296 | } |
| 1297 | 1297 | case 'out': |
| 1298 | - $tmp=$o['c']; |
|
| 1299 | - $res= "\n".$id." 0 obj\n"; |
|
| 1298 | + $tmp = $o['c']; |
|
| 1299 | + $res = "\n".$id." 0 obj\n"; |
|
| 1300 | 1300 | if (isset($this->objects[$id]['raw'])) { |
| 1301 | - $res.=$tmp; |
|
| 1301 | + $res .= $tmp; |
|
| 1302 | 1302 | } else { |
| 1303 | - $res.= "<<"; |
|
| 1303 | + $res .= "<<"; |
|
| 1304 | 1304 | if (function_exists('gzcompress') && $this->options['compression']) { |
| 1305 | 1305 | // then implement ZLIB based compression on this content stream |
| 1306 | - $res.=" /Filter /FlateDecode"; |
|
| 1306 | + $res .= " /Filter /FlateDecode"; |
|
| 1307 | 1307 | $tmp = gzcompress($tmp, $this->options['compression']); |
| 1308 | 1308 | } |
| 1309 | 1309 | if ($this->encrypted) { |
@@ -1313,9 +1313,9 @@ discard block |
||
| 1313 | 1313 | foreach ($o['info'] as $k => $v) { |
| 1314 | 1314 | $res .= " /".$k.' '.$v; |
| 1315 | 1315 | } |
| 1316 | - $res.=" /Length ".strlen($tmp)." >> stream\n".$tmp."\nendstream"; |
|
| 1316 | + $res .= " /Length ".strlen($tmp)." >> stream\n".$tmp."\nendstream"; |
|
| 1317 | 1317 | } |
| 1318 | - $res.="\nendobj"; |
|
| 1318 | + $res .= "\nendobj"; |
|
| 1319 | 1319 | return $res; |
| 1320 | 1320 | break; |
| 1321 | 1321 | } |
@@ -1327,43 +1327,43 @@ discard block |
||
| 1327 | 1327 | */ |
| 1328 | 1328 | private function o_image($id, $action, $options = '') |
| 1329 | 1329 | { |
| 1330 | - if ($action!='new') { |
|
| 1331 | - $o =& $this->objects[$id]; |
|
| 1330 | + if ($action != 'new') { |
|
| 1331 | + $o = & $this->objects[$id]; |
|
| 1332 | 1332 | } |
| 1333 | 1333 | switch ($action) { |
| 1334 | 1334 | case 'new': |
| 1335 | 1335 | // make the new object |
| 1336 | - $this->objects[$id]=array('t'=>'image','data'=>$options['data'],'info'=>array()); |
|
| 1337 | - $this->objects[$id]['info']['Type']='/XObject'; |
|
| 1338 | - $this->objects[$id]['info']['Subtype']='/Image'; |
|
| 1339 | - $this->objects[$id]['info']['Width']=$options['iw']; |
|
| 1340 | - $this->objects[$id]['info']['Height']=$options['ih']; |
|
| 1341 | - if (!isset($options['type']) || $options['type']=='jpg') { |
|
| 1336 | + $this->objects[$id] = array('t'=>'image', 'data'=>$options['data'], 'info'=>array()); |
|
| 1337 | + $this->objects[$id]['info']['Type'] = '/XObject'; |
|
| 1338 | + $this->objects[$id]['info']['Subtype'] = '/Image'; |
|
| 1339 | + $this->objects[$id]['info']['Width'] = $options['iw']; |
|
| 1340 | + $this->objects[$id]['info']['Height'] = $options['ih']; |
|
| 1341 | + if (!isset($options['type']) || $options['type'] == 'jpg') { |
|
| 1342 | 1342 | if (!isset($options['channels'])) { |
| 1343 | - $options['channels']=3; |
|
| 1343 | + $options['channels'] = 3; |
|
| 1344 | 1344 | } |
| 1345 | 1345 | switch ($options['channels']) { |
| 1346 | 1346 | case 1: |
| 1347 | - $this->objects[$id]['info']['ColorSpace']='/DeviceGray'; |
|
| 1347 | + $this->objects[$id]['info']['ColorSpace'] = '/DeviceGray'; |
|
| 1348 | 1348 | break; |
| 1349 | 1349 | default: |
| 1350 | - $this->objects[$id]['info']['ColorSpace']='/DeviceRGB'; |
|
| 1350 | + $this->objects[$id]['info']['ColorSpace'] = '/DeviceRGB'; |
|
| 1351 | 1351 | break; |
| 1352 | 1352 | } |
| 1353 | - $this->objects[$id]['info']['Filter']='/DCTDecode'; |
|
| 1354 | - $this->objects[$id]['info']['BitsPerComponent']=8; |
|
| 1355 | - } elseif ($options['type']=='png') { |
|
| 1353 | + $this->objects[$id]['info']['Filter'] = '/DCTDecode'; |
|
| 1354 | + $this->objects[$id]['info']['BitsPerComponent'] = 8; |
|
| 1355 | + } elseif ($options['type'] == 'png') { |
|
| 1356 | 1356 | if (strlen($options['pdata'])) { |
| 1357 | 1357 | $this->numObj++; |
| 1358 | - $this->objects[$this->numObj]=array('t'=>'image','c'=>'','info'=>array()); |
|
| 1358 | + $this->objects[$this->numObj] = array('t'=>'image', 'c'=>'', 'info'=>array()); |
|
| 1359 | 1359 | $this->objects[$this->numObj]['info'] = array('Type'=>'/XObject', 'Subtype'=>'/Image', 'Width'=> $options['iw'], 'Height'=> $options['ih'], 'Filter'=>'/FlateDecode', 'ColorSpace'=>'/DeviceGray', 'BitsPerComponent'=>'8', 'DecodeParms'=>'<< /Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$options['iw'].' >>'); |
| 1360 | - $this->objects[$this->numObj]['data']=$options['pdata']; |
|
| 1360 | + $this->objects[$this->numObj]['data'] = $options['pdata']; |
|
| 1361 | 1361 | if (isset($options['transparency'])) { |
| 1362 | 1362 | switch ($options['transparency']['type']) { |
| 1363 | 1363 | case 'indexed': |
| 1364 | - $tmp=' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] '; |
|
| 1364 | + $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] '; |
|
| 1365 | 1365 | $this->objects[$id]['info']['Mask'] = $tmp; |
| 1366 | - $this->objects[$id]['info']['ColorSpace'] = ' [ /Indexed /DeviceRGB '.(strlen($options['pdata'])/3-1).' '.$this->numObj.' 0 R ]'; |
|
| 1366 | + $this->objects[$id]['info']['ColorSpace'] = ' [ /Indexed /DeviceRGB '.(strlen($options['pdata'])/3 - 1).' '.$this->numObj.' 0 R ]'; |
|
| 1367 | 1367 | break; |
| 1368 | 1368 | case 'alpha': |
| 1369 | 1369 | $this->objects[$id]['info']['SMask'] = $this->numObj.' 0 R'; |
@@ -1372,28 +1372,28 @@ discard block |
||
| 1372 | 1372 | } |
| 1373 | 1373 | } |
| 1374 | 1374 | } else { |
| 1375 | - $this->objects[$id]['info']['ColorSpace']='/'.$options['color']; |
|
| 1375 | + $this->objects[$id]['info']['ColorSpace'] = '/'.$options['color']; |
|
| 1376 | 1376 | } |
| 1377 | - $this->objects[$id]['info']['BitsPerComponent']=$options['bitsPerComponent']; |
|
| 1378 | - $this->objects[$id]['info']['Filter']='/FlateDecode'; |
|
| 1377 | + $this->objects[$id]['info']['BitsPerComponent'] = $options['bitsPerComponent']; |
|
| 1378 | + $this->objects[$id]['info']['Filter'] = '/FlateDecode'; |
|
| 1379 | 1379 | $this->objects[$id]['data'] = $options['data']; |
| 1380 | - $this->objects[$id]['info']['DecodeParms']='<< /Predictor 15 /Colors '.$options['ncolor'].' /Columns '.$options['iw'].' /BitsPerComponent '.$options['bitsPerComponent'].'>>'; |
|
| 1380 | + $this->objects[$id]['info']['DecodeParms'] = '<< /Predictor 15 /Colors '.$options['ncolor'].' /Columns '.$options['iw'].' /BitsPerComponent '.$options['bitsPerComponent'].'>>'; |
|
| 1381 | 1381 | } |
| 1382 | 1382 | // assign it a place in the named resource dictionary as an external object, according to |
| 1383 | 1383 | // the label passed in with it. |
| 1384 | - $this->o_pages($this->currentNode, 'xObject', array('label'=>$options['label'],'objNum'=>$id)); |
|
| 1384 | + $this->o_pages($this->currentNode, 'xObject', array('label'=>$options['label'], 'objNum'=>$id)); |
|
| 1385 | 1385 | break; |
| 1386 | 1386 | case 'out': |
| 1387 | - $tmp=$o['data']; |
|
| 1388 | - $res= "\n".$id." 0 obj\n<<"; |
|
| 1387 | + $tmp = $o['data']; |
|
| 1388 | + $res = "\n".$id." 0 obj\n<<"; |
|
| 1389 | 1389 | foreach ($o['info'] as $k => $v) { |
| 1390 | - $res.=" /".$k.' '.$v; |
|
| 1390 | + $res .= " /".$k.' '.$v; |
|
| 1391 | 1391 | } |
| 1392 | 1392 | if ($this->encrypted) { |
| 1393 | 1393 | $this->encryptInit($id); |
| 1394 | 1394 | $tmp = $this->ARC4($tmp); |
| 1395 | 1395 | } |
| 1396 | - $res.=" /Length ".strlen($tmp)." >> stream\n".$tmp."\nendstream\nendobj"; |
|
| 1396 | + $res .= " /Length ".strlen($tmp)." >> stream\n".$tmp."\nendstream\nendobj"; |
|
| 1397 | 1397 | return $res; |
| 1398 | 1398 | break; |
| 1399 | 1399 | } |
@@ -1405,14 +1405,14 @@ discard block |
||
| 1405 | 1405 | */ |
| 1406 | 1406 | private function o_encryption($id, $action, $options = '') |
| 1407 | 1407 | { |
| 1408 | - if ($action!='new') { |
|
| 1409 | - $o =& $this->objects[$id]; |
|
| 1408 | + if ($action != 'new') { |
|
| 1409 | + $o = & $this->objects[$id]; |
|
| 1410 | 1410 | } |
| 1411 | 1411 | switch ($action) { |
| 1412 | 1412 | case 'new': |
| 1413 | 1413 | // make the new object |
| 1414 | - $this->objects[$id]=array('t'=>'encryption','info'=>$options); |
|
| 1415 | - $this->arc4_objnum=$id; |
|
| 1414 | + $this->objects[$id] = array('t'=>'encryption', 'info'=>$options); |
|
| 1415 | + $this->arc4_objnum = $id; |
|
| 1416 | 1416 | |
| 1417 | 1417 | // Pad or truncate the owner password |
| 1418 | 1418 | $owner = substr($options['owner'].$this->encryptionPad, 0, 32); |
@@ -1431,26 +1431,26 @@ discard block |
||
| 1431 | 1431 | // encryption key is set in encryptUser function |
| 1432 | 1432 | //$this->encryptionKey = $encryptionKey; |
| 1433 | 1433 | |
| 1434 | - $this->encrypted=1; |
|
| 1434 | + $this->encrypted = 1; |
|
| 1435 | 1435 | break; |
| 1436 | 1436 | case 'out': |
| 1437 | - $res= "\n".$id." 0 obj\n<<"; |
|
| 1438 | - $res.=' /Filter /Standard'; |
|
| 1437 | + $res = "\n".$id." 0 obj\n<<"; |
|
| 1438 | + $res .= ' /Filter /Standard'; |
|
| 1439 | 1439 | if ($this->encryptionMode > 1) { // RC4 128bit encryption |
| 1440 | - $res.=' /V 2'; |
|
| 1441 | - $res.=' /R 3'; |
|
| 1442 | - $res.=' /Length 128'; |
|
| 1440 | + $res .= ' /V 2'; |
|
| 1441 | + $res .= ' /R 3'; |
|
| 1442 | + $res .= ' /Length 128'; |
|
| 1443 | 1443 | } else { // RC4 40bit encryption |
| 1444 | - $res.=' /V 1'; |
|
| 1445 | - $res.=' /R 2'; |
|
| 1444 | + $res .= ' /V 1'; |
|
| 1445 | + $res .= ' /R 2'; |
|
| 1446 | 1446 | } |
| 1447 | 1447 | // use hex string instead of char code - char codes can make troubles (E.g. CR or LF) |
| 1448 | - $res.=' /O <'.$this->strToHex($o['info']['O']).'>'; |
|
| 1449 | - $res.=' /U <'.$this->strToHex($o['info']['U']).'>'; |
|
| 1448 | + $res .= ' /O <'.$this->strToHex($o['info']['O']).'>'; |
|
| 1449 | + $res .= ' /U <'.$this->strToHex($o['info']['U']).'>'; |
|
| 1450 | 1450 | // and the p-value needs to be converted to account for the twos-complement approach |
| 1451 | 1451 | //$o['info']['p'] = (($o['info']['p'] ^ 0xFFFFFFFF)+1)*-1; |
| 1452 | - $res.=' /P '.($o['info']['p']); |
|
| 1453 | - $res.=" >>\nendobj"; |
|
| 1452 | + $res .= ' /P '.($o['info']['p']); |
|
| 1453 | + $res .= " >>\nendobj"; |
|
| 1454 | 1454 | return $res; |
| 1455 | 1455 | break; |
| 1456 | 1456 | } |
@@ -1479,13 +1479,13 @@ discard block |
||
| 1479 | 1479 | $ownerKey = substr($ownerHash, 0, $keylength); // PDF 1.4 - Create the encryption key (IMPORTANT: need to check Length) |
| 1480 | 1480 | |
| 1481 | 1481 | $this->ARC4_init($ownerKey); // 5 bytes of the encryption key (hashed 50 times) |
| 1482 | - $ovalue=$this->ARC4($user); // PDF 1.4 - Encrypt the padded user password using RC4 |
|
| 1482 | + $ovalue = $this->ARC4($user); // PDF 1.4 - Encrypt the padded user password using RC4 |
|
| 1483 | 1483 | |
| 1484 | 1484 | if ($this->encryptionMode > 1) { |
| 1485 | 1485 | $len = strlen($ownerKey); |
| 1486 | - for ($i = 1; $i<=19; ++$i) { |
|
| 1486 | + for ($i = 1; $i <= 19; ++$i) { |
|
| 1487 | 1487 | $ek = ''; |
| 1488 | - for ($j=0; $j < $len; $j++) { |
|
| 1488 | + for ($j = 0; $j < $len; $j++) { |
|
| 1489 | 1489 | $ek .= chr(ord($ownerKey[$j]) ^ $i); |
| 1490 | 1490 | } |
| 1491 | 1491 | $this->ARC4_init($ek); |
@@ -1526,12 +1526,12 @@ discard block |
||
| 1526 | 1526 | |
| 1527 | 1527 | // encrypt the hash from the previous method by using the encryptionKey |
| 1528 | 1528 | $this->ARC4_init($this->encryptionKey); |
| 1529 | - $uvalue=$this->ARC4($userHash); |
|
| 1529 | + $uvalue = $this->ARC4($userHash); |
|
| 1530 | 1530 | |
| 1531 | 1531 | $len = strlen($this->encryptionKey); |
| 1532 | - for ($i = 1; $i<=19; ++$i) { |
|
| 1532 | + for ($i = 1; $i <= 19; ++$i) { |
|
| 1533 | 1533 | $ek = ''; |
| 1534 | - for ($j=0; $j< $len; $j++) { |
|
| 1534 | + for ($j = 0; $j < $len; $j++) { |
|
| 1535 | 1535 | $ek .= chr(ord($this->encryptionKey[$j]) ^ $i); |
| 1536 | 1536 | } |
| 1537 | 1537 | $this->ARC4_init($ek); |
@@ -1544,7 +1544,7 @@ discard block |
||
| 1544 | 1544 | $this->ARC4_init($this->encryptionKey); |
| 1545 | 1545 | //$this->encryptionKey = $encryptionKey; |
| 1546 | 1546 | //$this->encrypted=1; |
| 1547 | - $uvalue=$this->ARC4($this->encryptionPad); |
|
| 1547 | + $uvalue = $this->ARC4($this->encryptionPad); |
|
| 1548 | 1548 | } |
| 1549 | 1549 | return $uvalue; |
| 1550 | 1550 | } |
@@ -1557,7 +1557,7 @@ discard block |
||
| 1557 | 1557 | protected function strToHex($string) |
| 1558 | 1558 | { |
| 1559 | 1559 | $hex = ''; |
| 1560 | - for ($i=0; $i < strlen($string); $i++) { |
|
| 1560 | + for ($i = 0; $i < strlen($string); $i++) { |
|
| 1561 | 1561 | $hex .= sprintf("%02x", ord($string[$i])); |
| 1562 | 1562 | } |
| 1563 | 1563 | return $hex; |
@@ -1566,7 +1566,7 @@ discard block |
||
| 1566 | 1566 | protected function hexToStr($hex) |
| 1567 | 1567 | { |
| 1568 | 1568 | $str = ''; |
| 1569 | - for ($i=0; $i<strlen($hex); $i+=2) { |
|
| 1569 | + for ($i = 0; $i < strlen($hex); $i += 2) { |
|
| 1570 | 1570 | $str .= chr(hexdec(substr($hex, $i, 2))); |
| 1571 | 1571 | } |
| 1572 | 1572 | return $str; |
@@ -1591,10 +1591,10 @@ discard block |
||
| 1591 | 1591 | { |
| 1592 | 1592 | $tmp = $this->encryptionKey; |
| 1593 | 1593 | $hex = dechex($id); |
| 1594 | - if (strlen($hex)<6) { |
|
| 1595 | - $hex = substr('000000', 0, 6-strlen($hex)).$hex; |
|
| 1594 | + if (strlen($hex) < 6) { |
|
| 1595 | + $hex = substr('000000', 0, 6 - strlen($hex)).$hex; |
|
| 1596 | 1596 | } |
| 1597 | - $tmp.= chr(hexdec(substr($hex, 4, 2))).chr(hexdec(substr($hex, 2, 2))).chr(hexdec(substr($hex, 0, 2))).chr(0).chr(0); |
|
| 1597 | + $tmp .= chr(hexdec(substr($hex, 4, 2))).chr(hexdec(substr($hex, 2, 2))).chr(hexdec(substr($hex, 0, 2))).chr(0).chr(0); |
|
| 1598 | 1598 | $key = $this->md5_16($tmp); |
| 1599 | 1599 | if ($this->encryptionMode > 1) { |
| 1600 | 1600 | $this->ARC4_init(substr($key, 0, 16)); // use max 16 bytes for RC4 128bit encryption key |
@@ -1611,23 +1611,23 @@ discard block |
||
| 1611 | 1611 | { |
| 1612 | 1612 | $this->arc4 = ''; |
| 1613 | 1613 | // setup the control array |
| 1614 | - if (strlen($key)==0) { |
|
| 1614 | + if (strlen($key) == 0) { |
|
| 1615 | 1615 | return; |
| 1616 | 1616 | } |
| 1617 | 1617 | $k = ''; |
| 1618 | - while (strlen($k)<256) { |
|
| 1619 | - $k.=$key; |
|
| 1618 | + while (strlen($k) < 256) { |
|
| 1619 | + $k .= $key; |
|
| 1620 | 1620 | } |
| 1621 | - $k=substr($k, 0, 256); |
|
| 1622 | - for ($i=0; $i<256; $i++) { |
|
| 1621 | + $k = substr($k, 0, 256); |
|
| 1622 | + for ($i = 0; $i < 256; $i++) { |
|
| 1623 | 1623 | $this->arc4 .= chr($i); |
| 1624 | 1624 | } |
| 1625 | - $j=0; |
|
| 1626 | - for ($i=0; $i<256; $i++) { |
|
| 1625 | + $j = 0; |
|
| 1626 | + for ($i = 0; $i < 256; $i++) { |
|
| 1627 | 1627 | $t = $this->arc4[$i]; |
| 1628 | 1628 | $j = ($j + ord($t) + ord($k[$i]))%256; |
| 1629 | - $this->arc4[$i]=$this->arc4[$j]; |
|
| 1630 | - $this->arc4[$j]=$t; |
|
| 1629 | + $this->arc4[$i] = $this->arc4[$j]; |
|
| 1630 | + $this->arc4[$j] = $t; |
|
| 1631 | 1631 | } |
| 1632 | 1632 | } |
| 1633 | 1633 | |
@@ -1637,19 +1637,19 @@ discard block |
||
| 1637 | 1637 | */ |
| 1638 | 1638 | private function ARC4($text) |
| 1639 | 1639 | { |
| 1640 | - $len=strlen($text); |
|
| 1641 | - $a=0; |
|
| 1642 | - $b=0; |
|
| 1640 | + $len = strlen($text); |
|
| 1641 | + $a = 0; |
|
| 1642 | + $b = 0; |
|
| 1643 | 1643 | $c = $this->arc4; |
| 1644 | - $out=''; |
|
| 1645 | - for ($i=0; $i<$len; $i++) { |
|
| 1646 | - $a = ($a+1)%256; |
|
| 1647 | - $t= $c[$a]; |
|
| 1648 | - $b = ($b+ord($t))%256; |
|
| 1649 | - $c[$a]=$c[$b]; |
|
| 1650 | - $c[$b]=$t; |
|
| 1651 | - $k = ord($c[(ord($c[$a])+ord($c[$b]))%256]); |
|
| 1652 | - $out.=chr(ord($text[$i]) ^ $k); |
|
| 1644 | + $out = ''; |
|
| 1645 | + for ($i = 0; $i < $len; $i++) { |
|
| 1646 | + $a = ($a + 1)%256; |
|
| 1647 | + $t = $c[$a]; |
|
| 1648 | + $b = ($b + ord($t))%256; |
|
| 1649 | + $c[$a] = $c[$b]; |
|
| 1650 | + $c[$b] = $t; |
|
| 1651 | + $k = ord($c[(ord($c[$a]) + ord($c[$b]))%256]); |
|
| 1652 | + $out .= chr(ord($text[$i]) ^ $k); |
|
| 1653 | 1653 | } |
| 1654 | 1654 | return $out; |
| 1655 | 1655 | } |
@@ -1661,7 +1661,7 @@ discard block |
||
| 1661 | 1661 | public function addLink($url, $x0, $y0, $x1, $y1) |
| 1662 | 1662 | { |
| 1663 | 1663 | $this->numObj++; |
| 1664 | - $info = array('type'=>'link','url'=>$url,'rect'=>array($x0,$y0,$x1,$y1)); |
|
| 1664 | + $info = array('type'=>'link', 'url'=>$url, 'rect'=>array($x0, $y0, $x1, $y1)); |
|
| 1665 | 1665 | $this->o_annotation($this->numObj, 'new', $info); |
| 1666 | 1666 | } |
| 1667 | 1667 | |
@@ -1672,7 +1672,7 @@ discard block |
||
| 1672 | 1672 | public function addInternalLink($label, $x0, $y0, $x1, $y1) |
| 1673 | 1673 | { |
| 1674 | 1674 | $this->numObj++; |
| 1675 | - $info = array('type'=>'ilink','label'=>$label,'rect'=>array($x0,$y0,$x1,$y1)); |
|
| 1675 | + $info = array('type'=>'ilink', 'label'=>$label, 'rect'=>array($x0, $y0, $x1, $y1)); |
|
| 1676 | 1676 | $this->o_annotation($this->numObj, 'new', $info); |
| 1677 | 1677 | } |
| 1678 | 1678 | |
@@ -1685,9 +1685,9 @@ discard block |
||
| 1685 | 1685 | public function setEncryption($userPass = '', $ownerPass = '', $pc = array(), $mode = 1) |
| 1686 | 1686 | { |
| 1687 | 1687 | if ($mode > 1) { |
| 1688 | - $p=bindec('01111111111111111111000011000000'); // revision 3 is using bit 3 - 6 AND 9 - 12 |
|
| 1688 | + $p = bindec('01111111111111111111000011000000'); // revision 3 is using bit 3 - 6 AND 9 - 12 |
|
| 1689 | 1689 | } else { |
| 1690 | - $p=bindec('01111111111111111111111111000000'); // while revision 2 is using bit 3 - 6 only |
|
| 1690 | + $p = bindec('01111111111111111111111111000000'); // while revision 2 is using bit 3 - 6 only |
|
| 1691 | 1691 | } |
| 1692 | 1692 | |
| 1693 | 1693 | $options = array( |
@@ -1702,9 +1702,9 @@ discard block |
||
| 1702 | 1702 | ); |
| 1703 | 1703 | foreach ($pc as $k => $v) { |
| 1704 | 1704 | if ($v && isset($options[$k])) { |
| 1705 | - $p+=$options[$k]; |
|
| 1705 | + $p += $options[$k]; |
|
| 1706 | 1706 | } elseif (isset($options[$v])) { |
| 1707 | - $p+=$options[$v]; |
|
| 1707 | + $p += $options[$v]; |
|
| 1708 | 1708 | } |
| 1709 | 1709 | } |
| 1710 | 1710 | |
@@ -1715,10 +1715,10 @@ discard block |
||
| 1715 | 1715 | if ($this->arc4_objnum == 0) { |
| 1716 | 1716 | // then the block does not exist already, add it. |
| 1717 | 1717 | $this->numObj++; |
| 1718 | - if (strlen($ownerPass)==0) { |
|
| 1719 | - $ownerPass=$userPass; |
|
| 1718 | + if (strlen($ownerPass) == 0) { |
|
| 1719 | + $ownerPass = $userPass; |
|
| 1720 | 1720 | } |
| 1721 | - $this->o_encryption($this->numObj, 'new', array('user'=>$userPass,'owner'=>$ownerPass,'p'=>$p)); |
|
| 1721 | + $this->o_encryption($this->numObj, 'new', array('user'=>$userPass, 'owner'=>$ownerPass, 'p'=>$p)); |
|
| 1722 | 1722 | } |
| 1723 | 1723 | } |
| 1724 | 1724 | |
@@ -1743,7 +1743,7 @@ discard block |
||
| 1743 | 1743 | |
| 1744 | 1744 | if ($debug) { |
| 1745 | 1745 | // turn compression off |
| 1746 | - $this->options['compression']=0; |
|
| 1746 | + $this->options['compression'] = 0; |
|
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | 1749 | if ($this->arc4_objnum) { |
@@ -1756,23 +1756,23 @@ discard block |
||
| 1756 | 1756 | |
| 1757 | 1757 | $this->checkAllHere(); |
| 1758 | 1758 | |
| 1759 | - $xref=array(); |
|
| 1760 | - $content="%PDF-1.4\n%����"; |
|
| 1759 | + $xref = array(); |
|
| 1760 | + $content = "%PDF-1.4\n%����"; |
|
| 1761 | 1761 | // $content="%PDF-1.3\n"; |
| 1762 | - $pos=strlen($content); |
|
| 1762 | + $pos = strlen($content); |
|
| 1763 | 1763 | foreach ($this->objects as $k => $v) { |
| 1764 | - $tmp='o_'.$v['t']; |
|
| 1765 | - $cont=$this->$tmp($k,'out'); |
|
| 1766 | - $content.=$cont; |
|
| 1767 | - $xref[]=$pos; |
|
| 1768 | - $pos+=strlen($cont); |
|
| 1764 | + $tmp = 'o_'.$v['t']; |
|
| 1765 | + $cont = $this->$tmp($k, 'out'); |
|
| 1766 | + $content .= $cont; |
|
| 1767 | + $xref[] = $pos; |
|
| 1768 | + $pos += strlen($cont); |
|
| 1769 | 1769 | } |
| 1770 | 1770 | ++$pos; |
| 1771 | - $content.="\nxref\n0 ".(count($xref)+1)."\n0000000000 65535 f \n"; |
|
| 1771 | + $content .= "\nxref\n0 ".(count($xref) + 1)."\n0000000000 65535 f \n"; |
|
| 1772 | 1772 | foreach ($xref as $p) { |
| 1773 | - $content.=substr('0000000000', 0, 10-strlen($p+1)).($p+1)." 00000 n \n"; |
|
| 1773 | + $content .= substr('0000000000', 0, 10 - strlen($p + 1)).($p + 1)." 00000 n \n"; |
|
| 1774 | 1774 | } |
| 1775 | - $content.="trailer\n<< /Size ".(count($xref)+1)." /Root 1 0 R /Info ".$this->infoObject." 0 R"; |
|
| 1775 | + $content .= "trailer\n<< /Size ".(count($xref) + 1)." /Root 1 0 R /Info ".$this->infoObject." 0 R"; |
|
| 1776 | 1776 | // if encryption has been applied to this document then add the marker for this dictionary |
| 1777 | 1777 | if ($this->arc4_objnum > 0) { |
| 1778 | 1778 | $content .= " /Encrypt ".$this->arc4_objnum." 0 R"; |
@@ -1791,9 +1791,9 @@ discard block |
||
| 1791 | 1791 | * |
| 1792 | 1792 | * @access protected |
| 1793 | 1793 | */ |
| 1794 | - protected function newDocument($pageSize = array(0,0,612,792)) |
|
| 1794 | + protected function newDocument($pageSize = array(0, 0, 612, 792)) |
|
| 1795 | 1795 | { |
| 1796 | - $this->numObj=0; |
|
| 1796 | + $this->numObj = 0; |
|
| 1797 | 1797 | $this->objects = array(); |
| 1798 | 1798 | |
| 1799 | 1799 | $this->numObj++; |
@@ -1838,7 +1838,7 @@ discard block |
||
| 1838 | 1838 | $pos = strrpos($font, '/'); |
| 1839 | 1839 | if ($pos === false) { |
| 1840 | 1840 | // $dir = './'; |
| 1841 | - $dir = dirname(__FILE__) . '/fonts/'; |
|
| 1841 | + $dir = dirname(__FILE__).'/fonts/'; |
|
| 1842 | 1842 | $name = $font; |
| 1843 | 1843 | } else { |
| 1844 | 1844 | $dir = substr($font, 0, $pos + 1); |
@@ -1864,7 +1864,7 @@ discard block |
||
| 1864 | 1864 | } else { |
| 1865 | 1865 | $this->debug('openFont: cached file found in '.$this->tempPath.'/'.$cachedFile); |
| 1866 | 1866 | $this->fonts[$font] = require($this->tempPath.'/'.$cachedFile); |
| 1867 | - if (!isset($this->fonts[$font]['_version_']) || $this->fonts[$font]['_version_']<2) { |
|
| 1867 | + if (!isset($this->fonts[$font]['_version_']) || $this->fonts[$font]['_version_'] < 2) { |
|
| 1868 | 1868 | // if the font file is old, then clear it out and prepare for re-creation |
| 1869 | 1869 | $this->debug('openFont: version conflict with cached font file. Force recreation'); |
| 1870 | 1870 | unset($this->fonts[$font]); |
@@ -1885,8 +1885,8 @@ discard block |
||
| 1885 | 1885 | |
| 1886 | 1886 | $file = file($dir.$metrics_name); |
| 1887 | 1887 | foreach ($file as $row) { |
| 1888 | - $row=trim($row); |
|
| 1889 | - $pos=strpos($row, ' '); |
|
| 1888 | + $row = trim($row); |
|
| 1889 | + $pos = strpos($row, ' '); |
|
| 1890 | 1890 | if ($pos) { |
| 1891 | 1891 | // then there must be some keyword |
| 1892 | 1892 | $key = substr($row, 0, $pos); |
@@ -1909,10 +1909,10 @@ discard block |
||
| 1909 | 1909 | case 'StdHW': |
| 1910 | 1910 | case 'StdVW': |
| 1911 | 1911 | case 'StartCharMetrics': |
| 1912 | - $data[$key]=trim(substr($row, $pos)); |
|
| 1912 | + $data[$key] = trim(substr($row, $pos)); |
|
| 1913 | 1913 | break; |
| 1914 | 1914 | case 'FontBBox': |
| 1915 | - $data[$key]=explode(' ', trim(substr($row, $pos))); |
|
| 1915 | + $data[$key] = explode(' ', trim(substr($row, $pos))); |
|
| 1916 | 1916 | break; |
| 1917 | 1917 | case 'C': |
| 1918 | 1918 | // C 39 ; WX 222 ; N quoteright ; B 53 463 157 718 ; |
@@ -1976,16 +1976,16 @@ discard block |
||
| 1976 | 1976 | case 'KPX': |
| 1977 | 1977 | break; |
| 1978 | 1978 | // KPX Adieresis yacute -40 |
| 1979 | - $bits=explode(' ', $row); |
|
| 1980 | - $data['KPX'][$bits[1]][$bits[2]]=$bits[3]; |
|
| 1979 | + $bits = explode(' ', $row); |
|
| 1980 | + $data['KPX'][$bits[1]][$bits[2]] = $bits[3]; |
|
| 1981 | 1981 | break; |
| 1982 | 1982 | } |
| 1983 | 1983 | } |
| 1984 | 1984 | } |
| 1985 | 1985 | $data['CIDtoGID'] = base64_encode($cidtogid); |
| 1986 | - $data['_version_']=2; |
|
| 1986 | + $data['_version_'] = 2; |
|
| 1987 | 1987 | |
| 1988 | - $this->fonts[$font]=$data; |
|
| 1988 | + $this->fonts[$font] = $data; |
|
| 1989 | 1989 | $fp = fopen($this->tempPath.'/'.$cachedFile, 'w'); // use the temp folder to write cached font data |
| 1990 | 1990 | fwrite($fp, '<?php /* R&OS php pdf class font cache file */ return '.var_export($data, true).'; ?>'); |
| 1991 | 1991 | fclose($fp); |
@@ -2017,7 +2017,7 @@ discard block |
||
| 2017 | 2017 | |
| 2018 | 2018 | $ext = substr($fontName, -4); |
| 2019 | 2019 | if ($ext === '.afm' || $ext === '.ufm') { |
| 2020 | - $fontName = substr($fontName, 0, strlen($fontName)-4); |
|
| 2020 | + $fontName = substr($fontName, 0, strlen($fontName) - 4); |
|
| 2021 | 2021 | } |
| 2022 | 2022 | |
| 2023 | 2023 | $pos = strrpos($fontName, '/'); |
@@ -2098,14 +2098,14 @@ discard block |
||
| 2098 | 2098 | // also need to adjust the widths for the differences array |
| 2099 | 2099 | if (isset($options['differences'])) { |
| 2100 | 2100 | foreach ($options['differences'] as $charNum => $charName) { |
| 2101 | - if ($charNum>$lastChar) { |
|
| 2101 | + if ($charNum > $lastChar) { |
|
| 2102 | 2102 | for ($i = $lastChar + 1; $i <= $charNum; $i++) { |
| 2103 | - $widths[]=0; |
|
| 2103 | + $widths[] = 0; |
|
| 2104 | 2104 | } |
| 2105 | 2105 | $lastChar = $charNum; |
| 2106 | 2106 | } |
| 2107 | 2107 | if (isset($font['C'][$charName])) { |
| 2108 | - $widths[$charNum-$firstChar]=$font['C'][$charName]; |
|
| 2108 | + $widths[$charNum - $firstChar] = $font['C'][$charName]; |
|
| 2109 | 2109 | if ($font['isUnicode']) { |
| 2110 | 2110 | $cid_widths[$charName] = $font['C'][$charName]; |
| 2111 | 2111 | } |
@@ -2124,7 +2124,7 @@ discard block |
||
| 2124 | 2124 | if (!$font['isUnicode']) { |
| 2125 | 2125 | $this->numObj++; |
| 2126 | 2126 | $this->o_contents($this->numObj, 'new', 'raw'); |
| 2127 | - $this->objects[$this->numObj]['c'].='['.implode(' ', $widths).']'; |
|
| 2127 | + $this->objects[$this->numObj]['c'] .= '['.implode(' ', $widths).']'; |
|
| 2128 | 2128 | $widthid = $this->numObj; |
| 2129 | 2129 | } |
| 2130 | 2130 | |
@@ -2144,16 +2144,16 @@ discard block |
||
| 2144 | 2144 | $fontDescriptorId = ++$this->numObj; |
| 2145 | 2145 | |
| 2146 | 2146 | // determine flags (more than a little flakey, hopefully will not matter much) |
| 2147 | - $flags=0; |
|
| 2148 | - if ($font['ItalicAngle']!=0) { |
|
| 2149 | - $flags+=pow(2, 6); |
|
| 2147 | + $flags = 0; |
|
| 2148 | + if ($font['ItalicAngle'] != 0) { |
|
| 2149 | + $flags += pow(2, 6); |
|
| 2150 | 2150 | } |
| 2151 | - if ($font['IsFixedPitch']=='true') { |
|
| 2152 | - $flags+=1; |
|
| 2151 | + if ($font['IsFixedPitch'] == 'true') { |
|
| 2152 | + $flags += 1; |
|
| 2153 | 2153 | } |
| 2154 | - $flags+=pow(2, 5); // assume non-sybolic |
|
| 2154 | + $flags += pow(2, 5); // assume non-sybolic |
|
| 2155 | 2155 | |
| 2156 | - $list = array('Ascent'=>'Ascender','CapHeight'=>'CapHeight','Descent'=>'Descender','FontBBox'=>'FontBBox','ItalicAngle'=>'ItalicAngle'); |
|
| 2156 | + $list = array('Ascent'=>'Ascender', 'CapHeight'=>'CapHeight', 'Descent'=>'Descender', 'FontBBox'=>'FontBBox', 'ItalicAngle'=>'ItalicAngle'); |
|
| 2157 | 2157 | $fdopt = array( |
| 2158 | 2158 | 'Flags' => $flags, |
| 2159 | 2159 | 'FontName' => $adobeFontName, |
@@ -2161,13 +2161,13 @@ discard block |
||
| 2161 | 2161 | ); |
| 2162 | 2162 | foreach ($list as $k => $v) { |
| 2163 | 2163 | if (isset($font[$v])) { |
| 2164 | - $fdopt[$k]=$font[$v]; |
|
| 2164 | + $fdopt[$k] = $font[$v]; |
|
| 2165 | 2165 | } |
| 2166 | 2166 | } |
| 2167 | 2167 | |
| 2168 | 2168 | // setup the basic properties for o_font output |
| 2169 | - $tmp = array('BaseFont'=>$adobeFontName,'Widths'=>$widthid |
|
| 2170 | - ,'FirstChar'=>$firstChar,'LastChar'=>$lastChar |
|
| 2169 | + $tmp = array('BaseFont'=>$adobeFontName, 'Widths'=>$widthid |
|
| 2170 | + ,'FirstChar'=>$firstChar, 'LastChar'=>$lastChar |
|
| 2171 | 2171 | ,'FontDescriptor'=>$fontDescriptorId); |
| 2172 | 2172 | |
| 2173 | 2173 | // binary content of pfb or ttf file |
@@ -2176,11 +2176,11 @@ discard block |
||
| 2176 | 2176 | // embed the font program |
| 2177 | 2177 | // to allow font subsets embedding fonts is proceed in o_font 'output' |
| 2178 | 2178 | if ($this->embedFont) { |
| 2179 | - if ($fbtype=='pfb') { |
|
| 2180 | - $fdopt['FontFile']=$pfbid; |
|
| 2181 | - } elseif ($fbtype=='ttf') { |
|
| 2182 | - $fdopt['FontFile2']=$pfbid; |
|
| 2183 | - $tmp['SubType']='TrueType'; // Declare basic font as TrueType |
|
| 2179 | + if ($fbtype == 'pfb') { |
|
| 2180 | + $fdopt['FontFile'] = $pfbid; |
|
| 2181 | + } elseif ($fbtype == 'ttf') { |
|
| 2182 | + $fdopt['FontFile2'] = $pfbid; |
|
| 2183 | + $tmp['SubType'] = 'TrueType'; // Declare basic font as TrueType |
|
| 2184 | 2184 | } |
| 2185 | 2185 | $this->o_fontDescriptor($fontDescriptorId, 'new', $fdopt); |
| 2186 | 2186 | $this->o_contents($pfbid, 'new'); |
@@ -2198,7 +2198,7 @@ discard block |
||
| 2198 | 2198 | // also set the differences here, note that this means that these will take effect only the |
| 2199 | 2199 | // first time that a font is selected, else they are ignored |
| 2200 | 2200 | if (isset($options['differences'])) { |
| 2201 | - $font['differences']=$options['differences']; |
|
| 2201 | + $font['differences'] = $options['differences']; |
|
| 2202 | 2202 | } |
| 2203 | 2203 | } |
| 2204 | 2204 | } |
@@ -2210,7 +2210,7 @@ discard block |
||
| 2210 | 2210 | |
| 2211 | 2211 | if ($set && isset($this->fonts[$fontName])) { |
| 2212 | 2212 | // so if for some reason the font was not set in the last one then it will not be selected |
| 2213 | - $this->currentBaseFont=$fontName; |
|
| 2213 | + $this->currentBaseFont = $fontName; |
|
| 2214 | 2214 | // the next line means that if a new font is selected, then the current text state will be |
| 2215 | 2215 | // applied to it as well. |
| 2216 | 2216 | $this->setCurrentFont(); |
@@ -2232,9 +2232,9 @@ discard block |
||
| 2232 | 2232 | */ |
| 2233 | 2233 | protected function setCurrentFont() |
| 2234 | 2234 | { |
| 2235 | - if (strlen($this->currentBaseFont)==0) { |
|
| 2235 | + if (strlen($this->currentBaseFont) == 0) { |
|
| 2236 | 2236 | // then assume an initial font |
| 2237 | - $this->selectFont(dirname(__FILE__) . '/fonts/Helvetica'); |
|
| 2237 | + $this->selectFont(dirname(__FILE__).'/fonts/Helvetica'); |
|
| 2238 | 2238 | } |
| 2239 | 2239 | $pos = strrpos($this->currentBaseFont, '/'); |
| 2240 | 2240 | if ($pos !== false) { |
@@ -2280,7 +2280,7 @@ discard block |
||
| 2280 | 2280 | */ |
| 2281 | 2281 | protected function addContent($content) |
| 2282 | 2282 | { |
| 2283 | - $this->objects[$this->currentContents]['c'].=$content; |
|
| 2283 | + $this->objects[$this->currentContents]['c'] .= $content; |
|
| 2284 | 2284 | } |
| 2285 | 2285 | |
| 2286 | 2286 | /** |
@@ -2289,9 +2289,9 @@ discard block |
||
| 2289 | 2289 | */ |
| 2290 | 2290 | public function setColor($r, $g, $b, $force = 0) |
| 2291 | 2291 | { |
| 2292 | - if ($r>=0 && ($force || $r!=$this->currentColour['r'] || $g!=$this->currentColour['g'] || $b!=$this->currentColour['b'])) { |
|
| 2293 | - $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F', $r).' '.sprintf('%.3F', $g).' '.sprintf('%.3F', $b).' rg'; |
|
| 2294 | - $this->currentColour=array('r'=>$r,'g'=>$g,'b'=>$b); |
|
| 2292 | + if ($r >= 0 && ($force || $r != $this->currentColour['r'] || $g != $this->currentColour['g'] || $b != $this->currentColour['b'])) { |
|
| 2293 | + $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $r).' '.sprintf('%.3F', $g).' '.sprintf('%.3F', $b).' rg'; |
|
| 2294 | + $this->currentColour = array('r'=>$r, 'g'=>$g, 'b'=>$b); |
|
| 2295 | 2295 | } |
| 2296 | 2296 | } |
| 2297 | 2297 | |
@@ -2301,9 +2301,9 @@ discard block |
||
| 2301 | 2301 | */ |
| 2302 | 2302 | public function setStrokeColor($r, $g, $b, $force = 0) |
| 2303 | 2303 | { |
| 2304 | - if ($r>=0 && ($force || $r!=$this->currentStrokeColour['r'] || $g!=$this->currentStrokeColour['g'] || $b!=$this->currentStrokeColour['b'])) { |
|
| 2305 | - $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F', $r).' '.sprintf('%.3F', $g).' '.sprintf('%.3F', $b).' RG'; |
|
| 2306 | - $this->currentStrokeColour=array('r'=>$r,'g'=>$g,'b'=>$b); |
|
| 2304 | + if ($r >= 0 && ($force || $r != $this->currentStrokeColour['r'] || $g != $this->currentStrokeColour['g'] || $b != $this->currentStrokeColour['b'])) { |
|
| 2305 | + $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $r).' '.sprintf('%.3F', $g).' '.sprintf('%.3F', $b).' RG'; |
|
| 2306 | + $this->currentStrokeColour = array('r'=>$r, 'g'=>$g, 'b'=>$b); |
|
| 2307 | 2307 | } |
| 2308 | 2308 | } |
| 2309 | 2309 | |
@@ -2313,7 +2313,7 @@ discard block |
||
| 2313 | 2313 | */ |
| 2314 | 2314 | public function line($x1, $y1, $x2, $y2) |
| 2315 | 2315 | { |
| 2316 | - $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' m '.sprintf('%.3F', $x2).' '.sprintf('%.3F', $y2).' l S'; |
|
| 2316 | + $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' m '.sprintf('%.3F', $x2).' '.sprintf('%.3F', $y2).' l S'; |
|
| 2317 | 2317 | } |
| 2318 | 2318 | |
| 2319 | 2319 | /** |
@@ -2324,8 +2324,8 @@ discard block |
||
| 2324 | 2324 | { |
| 2325 | 2325 | // in the current line style, draw a bezier curve from (x0,y0) to (x3,y3) using the other two points |
| 2326 | 2326 | // as the control points for the curve. |
| 2327 | - $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F', $x0).' '.sprintf('%.3F', $y0).' m '.sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1); |
|
| 2328 | - $this->objects[$this->currentContents]['c'].= ' '.sprintf('%.3F', $x2).' '.sprintf('%.3F', $y2).' '.sprintf('%.3F', $x3).' '.sprintf('%.3F', $y3).' c S'; |
|
| 2327 | + $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $x0).' '.sprintf('%.3F', $y0).' m '.sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1); |
|
| 2328 | + $this->objects[$this->currentContents]['c'] .= ' '.sprintf('%.3F', $x2).' '.sprintf('%.3F', $y2).' '.sprintf('%.3F', $x3).' '.sprintf('%.3F', $y3).' c S'; |
|
| 2329 | 2329 | } |
| 2330 | 2330 | |
| 2331 | 2331 | /** |
@@ -2359,19 +2359,19 @@ discard block |
||
| 2359 | 2359 | */ |
| 2360 | 2360 | public function ellipse($x0, $y0, $r1, $r2 = 0, $angle = 0, $nSeg = 8, $astart = 0, $afinish = 360, $close = 1, $fill = 0) |
| 2361 | 2361 | { |
| 2362 | - if ($r1==0) { |
|
| 2362 | + if ($r1 == 0) { |
|
| 2363 | 2363 | return; |
| 2364 | 2364 | } |
| 2365 | - if ($r2==0) { |
|
| 2366 | - $r2=$r1; |
|
| 2365 | + if ($r2 == 0) { |
|
| 2366 | + $r2 = $r1; |
|
| 2367 | 2367 | } |
| 2368 | - if ($nSeg<2) { |
|
| 2369 | - $nSeg=2; |
|
| 2368 | + if ($nSeg < 2) { |
|
| 2369 | + $nSeg = 2; |
|
| 2370 | 2370 | } |
| 2371 | 2371 | |
| 2372 | 2372 | $astart = deg2rad((float)$astart); |
| 2373 | 2373 | $afinish = deg2rad((float)$afinish); |
| 2374 | - $totalAngle =$afinish-$astart; |
|
| 2374 | + $totalAngle = $afinish - $astart; |
|
| 2375 | 2375 | |
| 2376 | 2376 | $dt = $totalAngle/$nSeg; |
| 2377 | 2377 | $dtm = $dt/3; |
@@ -2381,43 +2381,43 @@ discard block |
||
| 2381 | 2381 | $tmp = "\n q "; |
| 2382 | 2382 | $tmp .= sprintf('%.3F', cos($a)).' '.sprintf('%.3F', (-1.0*sin($a))).' '.sprintf('%.3F', sin($a)).' '.sprintf('%.3F', cos($a)).' '; |
| 2383 | 2383 | $tmp .= sprintf('%.3F', $x0).' '.sprintf('%.3F', $y0).' cm'; |
| 2384 | - $this->objects[$this->currentContents]['c'].= $tmp; |
|
| 2385 | - $x0=0; |
|
| 2386 | - $y0=0; |
|
| 2384 | + $this->objects[$this->currentContents]['c'] .= $tmp; |
|
| 2385 | + $x0 = 0; |
|
| 2386 | + $y0 = 0; |
|
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | 2389 | $t1 = $astart; |
| 2390 | - $a0 = $x0+$r1*cos($t1); |
|
| 2391 | - $b0 = $y0+$r2*sin($t1); |
|
| 2390 | + $a0 = $x0 + $r1*cos($t1); |
|
| 2391 | + $b0 = $y0 + $r2*sin($t1); |
|
| 2392 | 2392 | $c0 = -$r1*sin($t1); |
| 2393 | 2393 | $d0 = $r2*cos($t1); |
| 2394 | 2394 | |
| 2395 | - $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F', $a0).' '.sprintf('%.3F', $b0).' m '; |
|
| 2396 | - for ($i=1; $i<=$nSeg; $i++) { |
|
| 2395 | + $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $a0).' '.sprintf('%.3F', $b0).' m '; |
|
| 2396 | + for ($i = 1; $i <= $nSeg; $i++) { |
|
| 2397 | 2397 | // draw this bit of the total curve |
| 2398 | - $t1 = $i*$dt+$astart; |
|
| 2399 | - $a1 = $x0+$r1*cos($t1); |
|
| 2400 | - $b1 = $y0+$r2*sin($t1); |
|
| 2398 | + $t1 = $i*$dt + $astart; |
|
| 2399 | + $a1 = $x0 + $r1*cos($t1); |
|
| 2400 | + $b1 = $y0 + $r2*sin($t1); |
|
| 2401 | 2401 | $c1 = -$r1*sin($t1); |
| 2402 | 2402 | $d1 = $r2*cos($t1); |
| 2403 | - $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F', ($a0+$c0*$dtm)).' '.sprintf('%.3F', ($b0+$d0*$dtm)); |
|
| 2404 | - $this->objects[$this->currentContents]['c'].= ' '.sprintf('%.3F', ($a1-$c1*$dtm)).' '.sprintf('%.3F', ($b1-$d1*$dtm)).' '.sprintf('%.3F', $a1).' '.sprintf('%.3F', $b1).' c'; |
|
| 2405 | - $a0=$a1; |
|
| 2406 | - $b0=$b1; |
|
| 2407 | - $c0=$c1; |
|
| 2408 | - $d0=$d1; |
|
| 2403 | + $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', ($a0 + $c0*$dtm)).' '.sprintf('%.3F', ($b0 + $d0*$dtm)); |
|
| 2404 | + $this->objects[$this->currentContents]['c'] .= ' '.sprintf('%.3F', ($a1 - $c1*$dtm)).' '.sprintf('%.3F', ($b1 - $d1*$dtm)).' '.sprintf('%.3F', $a1).' '.sprintf('%.3F', $b1).' c'; |
|
| 2405 | + $a0 = $a1; |
|
| 2406 | + $b0 = $b1; |
|
| 2407 | + $c0 = $c1; |
|
| 2408 | + $d0 = $d1; |
|
| 2409 | 2409 | } |
| 2410 | 2410 | if ($fill) { |
| 2411 | - $this->objects[$this->currentContents]['c'].=' f'; |
|
| 2411 | + $this->objects[$this->currentContents]['c'] .= ' f'; |
|
| 2412 | 2412 | } else { |
| 2413 | 2413 | if ($close) { |
| 2414 | - $this->objects[$this->currentContents]['c'].=' s'; // small 's' signifies closing the path as well |
|
| 2414 | + $this->objects[$this->currentContents]['c'] .= ' s'; // small 's' signifies closing the path as well |
|
| 2415 | 2415 | } else { |
| 2416 | - $this->objects[$this->currentContents]['c'].=' S'; |
|
| 2416 | + $this->objects[$this->currentContents]['c'] .= ' S'; |
|
| 2417 | 2417 | } |
| 2418 | 2418 | } |
| 2419 | - if ($angle !=0) { |
|
| 2420 | - $this->objects[$this->currentContents]['c'].=' Q'; |
|
| 2419 | + if ($angle != 0) { |
|
| 2420 | + $this->objects[$this->currentContents]['c'] .= ' Q'; |
|
| 2421 | 2421 | } |
| 2422 | 2422 | } |
| 2423 | 2423 | |
@@ -2440,26 +2440,26 @@ discard block |
||
| 2440 | 2440 | |
| 2441 | 2441 | // this is quite inefficient in that it sets all the parameters whenever 1 is changed, but will fix another day |
| 2442 | 2442 | $string = ''; |
| 2443 | - if ($width>0) { |
|
| 2444 | - $string.= $width.' w'; |
|
| 2443 | + if ($width > 0) { |
|
| 2444 | + $string .= $width.' w'; |
|
| 2445 | 2445 | } |
| 2446 | - $ca = array('butt'=>0,'round'=>1,'square'=>2); |
|
| 2446 | + $ca = array('butt'=>0, 'round'=>1, 'square'=>2); |
|
| 2447 | 2447 | if (isset($ca[$cap])) { |
| 2448 | - $string.= ' '.$ca[$cap].' J'; |
|
| 2448 | + $string .= ' '.$ca[$cap].' J'; |
|
| 2449 | 2449 | } |
| 2450 | - $ja = array('miter'=>0,'round'=>1,'bevel'=>2); |
|
| 2450 | + $ja = array('miter'=>0, 'round'=>1, 'bevel'=>2); |
|
| 2451 | 2451 | if (isset($ja[$join])) { |
| 2452 | - $string.= ' '.$ja[$join].' j'; |
|
| 2452 | + $string .= ' '.$ja[$join].' j'; |
|
| 2453 | 2453 | } |
| 2454 | 2454 | if (is_array($dash)) { |
| 2455 | - $string.= ' ['; |
|
| 2455 | + $string .= ' ['; |
|
| 2456 | 2456 | foreach ($dash as $len) { |
| 2457 | - $string.=' '.$len; |
|
| 2457 | + $string .= ' '.$len; |
|
| 2458 | 2458 | } |
| 2459 | - $string.= ' ] '.$phase.' d'; |
|
| 2459 | + $string .= ' ] '.$phase.' d'; |
|
| 2460 | 2460 | } |
| 2461 | 2461 | $this->currentLineStyle = $string; |
| 2462 | - $this->objects[$this->currentContents]['c'].="\n".$string; |
|
| 2462 | + $this->objects[$this->currentContents]['c'] .= "\n".$string; |
|
| 2463 | 2463 | } |
| 2464 | 2464 | |
| 2465 | 2465 | /** |
@@ -2468,15 +2468,15 @@ discard block |
||
| 2468 | 2468 | */ |
| 2469 | 2469 | public function polygon($p, $np, $f = 0) |
| 2470 | 2470 | { |
| 2471 | - $this->objects[$this->currentContents]['c'].="\n"; |
|
| 2472 | - $this->objects[$this->currentContents]['c'].=sprintf('%.3F', $p[0]).' '.sprintf('%.3F', $p[1]).' m '; |
|
| 2473 | - for ($i=2; $i<$np*2; $i=$i+2) { |
|
| 2474 | - $this->objects[$this->currentContents]['c'].= sprintf('%.3F', $p[$i]).' '.sprintf('%.3F', $p[$i+1]).' l '; |
|
| 2471 | + $this->objects[$this->currentContents]['c'] .= "\n"; |
|
| 2472 | + $this->objects[$this->currentContents]['c'] .= sprintf('%.3F', $p[0]).' '.sprintf('%.3F', $p[1]).' m '; |
|
| 2473 | + for ($i = 2; $i < $np*2; $i = $i + 2) { |
|
| 2474 | + $this->objects[$this->currentContents]['c'] .= sprintf('%.3F', $p[$i]).' '.sprintf('%.3F', $p[$i + 1]).' l '; |
|
| 2475 | 2475 | } |
| 2476 | - if ($f==1) { |
|
| 2477 | - $this->objects[$this->currentContents]['c'].=' f'; |
|
| 2476 | + if ($f == 1) { |
|
| 2477 | + $this->objects[$this->currentContents]['c'] .= ' f'; |
|
| 2478 | 2478 | } else { |
| 2479 | - $this->objects[$this->currentContents]['c'].=' S'; |
|
| 2479 | + $this->objects[$this->currentContents]['c'] .= ' S'; |
|
| 2480 | 2480 | } |
| 2481 | 2481 | } |
| 2482 | 2482 | |
@@ -2487,7 +2487,7 @@ discard block |
||
| 2487 | 2487 | */ |
| 2488 | 2488 | public function filledRectangle($x1, $y1, $width, $height) |
| 2489 | 2489 | { |
| 2490 | - $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' '.sprintf('%.3F', $width).' '.sprintf('%.3F', $height).' re f'; |
|
| 2490 | + $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' '.sprintf('%.3F', $width).' '.sprintf('%.3F', $height).' re f'; |
|
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | /** |
@@ -2497,7 +2497,7 @@ discard block |
||
| 2497 | 2497 | */ |
| 2498 | 2498 | public function rectangle($x1, $y1, $width, $height) |
| 2499 | 2499 | { |
| 2500 | - $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' '.sprintf('%.3F', $width).' '.sprintf('%.3F', $height).' re S'; |
|
| 2500 | + $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' '.sprintf('%.3F', $width).' '.sprintf('%.3F', $height).' re S'; |
|
| 2501 | 2501 | } |
| 2502 | 2502 | |
| 2503 | 2503 | /** |
@@ -2512,7 +2512,7 @@ discard block |
||
| 2512 | 2512 | // then on the new page, re-open them with the right setings |
| 2513 | 2513 | |
| 2514 | 2514 | if ($this->nStateStack) { |
| 2515 | - for ($i=$this->nStateStack; $i>=1; $i--) { |
|
| 2515 | + for ($i = $this->nStateStack; $i >= 1; $i--) { |
|
| 2516 | 2516 | $this->restoreState($i); |
| 2517 | 2517 | } |
| 2518 | 2518 | } |
@@ -2522,28 +2522,28 @@ discard block |
||
| 2522 | 2522 | // the id from the ezPdf class is the od of the contents of the page, not the page object itself |
| 2523 | 2523 | // query that object to find the parent |
| 2524 | 2524 | $rid = $this->objects[$id]['onPage']; |
| 2525 | - $opt= array('rid'=>$rid,'pos'=>$pos); |
|
| 2525 | + $opt = array('rid'=>$rid, 'pos'=>$pos); |
|
| 2526 | 2526 | $this->o_page($this->numObj, 'new', $opt); |
| 2527 | 2527 | } else { |
| 2528 | 2528 | $this->o_page($this->numObj, 'new'); |
| 2529 | 2529 | } |
| 2530 | 2530 | // if there is a stack saved, then put that onto the page |
| 2531 | 2531 | if ($this->nStateStack) { |
| 2532 | - for ($i=1; $i<=$this->nStateStack; $i++) { |
|
| 2532 | + for ($i = 1; $i <= $this->nStateStack; $i++) { |
|
| 2533 | 2533 | $this->saveState($i); |
| 2534 | 2534 | } |
| 2535 | 2535 | } |
| 2536 | 2536 | // and if there has been a stroke or fill colour set, then transfer them |
| 2537 | - if ($this->currentColour['r']>=0) { |
|
| 2537 | + if ($this->currentColour['r'] >= 0) { |
|
| 2538 | 2538 | $this->setColor($this->currentColour['r'], $this->currentColour['g'], $this->currentColour['b'], 1); |
| 2539 | 2539 | } |
| 2540 | - if ($this->currentStrokeColour['r']>=0) { |
|
| 2540 | + if ($this->currentStrokeColour['r'] >= 0) { |
|
| 2541 | 2541 | $this->setStrokeColor($this->currentStrokeColour['r'], $this->currentStrokeColour['g'], $this->currentStrokeColour['b'], 1); |
| 2542 | 2542 | } |
| 2543 | 2543 | |
| 2544 | 2544 | // if there is a line style set, then put this in too |
| 2545 | 2545 | if (strlen($this->currentLineStyle)) { |
| 2546 | - $this->objects[$this->currentContents]['c'].="\n".$this->currentLineStyle; |
|
| 2546 | + $this->objects[$this->currentContents]['c'] .= "\n".$this->currentLineStyle; |
|
| 2547 | 2547 | } |
| 2548 | 2548 | |
| 2549 | 2549 | // the call to the o_page object set currentContents to the present page, so this can be returned as the page id |
@@ -2568,23 +2568,23 @@ discard block |
||
| 2568 | 2568 | // 'compress'=> 1 or 0 - apply content stream compression, this is on (1) by default |
| 2569 | 2569 | // 'download'=> 1 or 0 - provide download dialog |
| 2570 | 2570 | if (!is_array($options)) { |
| 2571 | - $options=array(); |
|
| 2571 | + $options = array(); |
|
| 2572 | 2572 | } |
| 2573 | - if (isset($options['compress']) && $options['compress']==0) { |
|
| 2573 | + if (isset($options['compress']) && $options['compress'] == 0) { |
|
| 2574 | 2574 | $tmp = $this->output(1); |
| 2575 | 2575 | } else { |
| 2576 | 2576 | $tmp = $this->output(); |
| 2577 | 2577 | } |
| 2578 | 2578 | header("Content-Type: application/pdf"); |
| 2579 | 2579 | header("Content-Length: ".strlen(ltrim($tmp))); |
| 2580 | - $fileName = (isset($options['Content-Disposition'])?$options['Content-Disposition']:'file.pdf'); |
|
| 2580 | + $fileName = (isset($options['Content-Disposition']) ? $options['Content-Disposition'] : 'file.pdf'); |
|
| 2581 | 2581 | if (isset($options['download']) && $options['download'] == 1) { |
| 2582 | 2582 | $attached = 'attachment'; |
| 2583 | 2583 | } else { |
| 2584 | 2584 | $attached = 'inline'; |
| 2585 | 2585 | } |
| 2586 | 2586 | header("Content-Disposition: $attached; filename=".$fileName); |
| 2587 | - if (isset($options['Accept-Ranges']) && $options['Accept-Ranges']==1) { |
|
| 2587 | + if (isset($options['Accept-Ranges']) && $options['Accept-Ranges'] == 1) { |
|
| 2588 | 2588 | header("Accept-Ranges: ".strlen(ltrim($tmp))); |
| 2589 | 2589 | } |
| 2590 | 2590 | echo ltrim($tmp); |
@@ -2646,13 +2646,13 @@ discard block |
||
| 2646 | 2646 | $hexStr = $this->strToHex($text); |
| 2647 | 2647 | // store all used characters if subset font is set to true |
| 2648 | 2648 | if ($this->fonts[$cf]['isSubset']) { |
| 2649 | - for ($i = 0; $i < (strlen($hexStr) / 2); $i++) { |
|
| 2650 | - array_push($this->fonts[$cf]['subset'], substr($hexStr, ($i * 2), 2)); |
|
| 2649 | + for ($i = 0; $i < (strlen($hexStr)/2); $i++) { |
|
| 2650 | + array_push($this->fonts[$cf]['subset'], substr($hexStr, ($i*2), 2)); |
|
| 2651 | 2651 | } |
| 2652 | 2652 | } |
| 2653 | 2653 | } |
| 2654 | 2654 | } |
| 2655 | - $text = strtr($text, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(8) => '\\b', chr(9) => '\\t', chr(10) => '\\n', chr(12) => '\\f' ,chr(13) => '\\r')); |
|
| 2655 | + $text = strtr($text, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(8) => '\\b', chr(9) => '\\t', chr(10) => '\\n', chr(12) => '\\f', chr(13) => '\\r')); |
|
| 2656 | 2656 | |
| 2657 | 2657 | if ($this->rtl) { |
| 2658 | 2658 | $text = strrev($text); |
@@ -2708,7 +2708,7 @@ discard block |
||
| 2708 | 2708 | // compose UTF-8 bytes to a single unicode value |
| 2709 | 2709 | $c = $bytes[0]; |
| 2710 | 2710 | for ($j = 1; $j < $numbytes; $j++) { |
| 2711 | - $c += ($bytes[$j] << (($numbytes - $j - 1) * 0x06)); |
|
| 2711 | + $c += ($bytes[$j] << (($numbytes - $j - 1)*0x06)); |
|
| 2712 | 2712 | } |
| 2713 | 2713 | if ((($c >= 0xD800) and ($c <= 0xDFFF)) or ($c >= 0x10FFFF)) { |
| 2714 | 2714 | // The definition of UTF-8 prohibits encoding character numbers between |
@@ -2759,12 +2759,12 @@ discard block |
||
| 2759 | 2759 | if ($c === 0xFFFD) { |
| 2760 | 2760 | $out .= "\xFF\xFD"; // replacement character |
| 2761 | 2761 | } elseif ($c < 0x10000) { |
| 2762 | - $out .= chr($c >> 0x08) . chr($c & 0xFF); |
|
| 2762 | + $out .= chr($c >> 0x08).chr($c & 0xFF); |
|
| 2763 | 2763 | } else { |
| 2764 | 2764 | $c -= 0x10000; |
| 2765 | 2765 | $w1 = 0xD800 | ($c >> 0x10); |
| 2766 | 2766 | $w2 = 0xDC00 | ($c & 0x3FF); |
| 2767 | - $out .= chr($w1 >> 0x08) . chr($w1 & 0xFF) . chr($w2 >> 0x08) . chr($w2 & 0xFF); |
|
| 2767 | + $out .= chr($w1 >> 0x08).chr($w1 & 0xFF).chr($w2 >> 0x08).chr($w2 & 0xFF); |
|
| 2768 | 2768 | } |
| 2769 | 2769 | } |
| 2770 | 2770 | return $out; |
@@ -2782,10 +2782,10 @@ discard block |
||
| 2782 | 2782 | $w = $this->getTextWidth($size, $text); |
| 2783 | 2783 | // need to adjust for the number of spaces in this text |
| 2784 | 2784 | $words = explode(' ', $text); |
| 2785 | - $nspaces=count($words)-1; |
|
| 2785 | + $nspaces = count($words) - 1; |
|
| 2786 | 2786 | $w += $wa*$nspaces; |
| 2787 | 2787 | $a = deg2rad((float)$angle); |
| 2788 | - return array(cos($a)*$w+$x,-sin($a)*$w+$y); |
|
| 2788 | + return array(cos($a)*$w + $x, -sin($a)*$w + $y); |
|
| 2789 | 2789 | } |
| 2790 | 2790 | |
| 2791 | 2791 | /** |
@@ -2795,8 +2795,8 @@ discard block |
||
| 2795 | 2795 | */ |
| 2796 | 2796 | private function checkTextDirective(&$text, $i, &$f) |
| 2797 | 2797 | { |
| 2798 | - $x=0; |
|
| 2799 | - $y=0; |
|
| 2798 | + $x = 0; |
|
| 2799 | + $y = 0; |
|
| 2800 | 2800 | return $this->checkTextDirective1($text, $i, $f, 0, $x, $y); |
| 2801 | 2801 | } |
| 2802 | 2802 | |
@@ -2812,8 +2812,8 @@ discard block |
||
| 2812 | 2812 | private function checkTextDirective1(&$text, $i, &$f, $final, &$x, &$y, $size = 0, $angle = 0, $wordSpaceAdjust = 0) |
| 2813 | 2813 | { |
| 2814 | 2814 | $directive = 0; |
| 2815 | - $j=$i; |
|
| 2816 | - if ($text[$j]=='<') { |
|
| 2815 | + $j = $i; |
|
| 2816 | + if ($text[$j] == '<') { |
|
| 2817 | 2817 | $j++; |
| 2818 | 2818 | switch ($text[$j]) { |
| 2819 | 2819 | case '/': |
@@ -2825,44 +2825,44 @@ discard block |
||
| 2825 | 2825 | case 'b': |
| 2826 | 2826 | case 'i': |
| 2827 | 2827 | $j++; |
| 2828 | - if ($text[$j]=='>') { |
|
| 2829 | - $p = strrpos($this->currentTextState, $text[$j-1]); |
|
| 2828 | + if ($text[$j] == '>') { |
|
| 2829 | + $p = strrpos($this->currentTextState, $text[$j - 1]); |
|
| 2830 | 2830 | if ($p !== false) { |
| 2831 | 2831 | // then there is one to remove |
| 2832 | - $this->currentTextState = substr($this->currentTextState, 0, $p).substr($this->currentTextState, $p+1); |
|
| 2832 | + $this->currentTextState = substr($this->currentTextState, 0, $p).substr($this->currentTextState, $p + 1); |
|
| 2833 | 2833 | } |
| 2834 | - $directive=$j-$i+1; |
|
| 2834 | + $directive = $j - $i + 1; |
|
| 2835 | 2835 | } |
| 2836 | 2836 | break; |
| 2837 | 2837 | case 'c': |
| 2838 | 2838 | // this this might be a callback function |
| 2839 | 2839 | $j++; |
| 2840 | 2840 | $k = strpos($text, '>', $j); |
| 2841 | - if ($k!==false && $text[$j]==':') { |
|
| 2841 | + if ($k !== false && $text[$j] == ':') { |
|
| 2842 | 2842 | // then this will be treated as a callback directive |
| 2843 | - $directive = $k-$i+1; |
|
| 2844 | - $f=0; |
|
| 2843 | + $directive = $k - $i + 1; |
|
| 2844 | + $f = 0; |
|
| 2845 | 2845 | // split the remainder on colons to get the function name and the paramater |
| 2846 | - $tmp = substr($text, $j+1, $k-$j-1); |
|
| 2846 | + $tmp = substr($text, $j + 1, $k - $j - 1); |
|
| 2847 | 2847 | $b1 = strpos($tmp, ':'); |
| 2848 | - if ($b1!==false) { |
|
| 2848 | + if ($b1 !== false) { |
|
| 2849 | 2849 | $func = substr($tmp, 0, $b1); |
| 2850 | - $parm = substr($tmp, $b1+1); |
|
| 2850 | + $parm = substr($tmp, $b1 + 1); |
|
| 2851 | 2851 | } else { |
| 2852 | - $func=$tmp; |
|
| 2853 | - $parm=''; |
|
| 2852 | + $func = $tmp; |
|
| 2853 | + $parm = ''; |
|
| 2854 | 2854 | } |
| 2855 | 2855 | if (!isset($func) || !strlen(trim($func))) { |
| 2856 | - $directive=0; |
|
| 2856 | + $directive = 0; |
|
| 2857 | 2857 | } else { |
| 2858 | 2858 | // only call the function if this is the final call |
| 2859 | 2859 | if ($final) { |
| 2860 | 2860 | // need to assess the text position, calculate the text width to this point |
| 2861 | 2861 | // can use getTextWidth to find the text width I think |
| 2862 | 2862 | $tmp = $this->getTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, substr($text, 0, $i)); |
| 2863 | - $info = array('x'=>$tmp[0],'y'=>$tmp[1],'angle'=>$angle,'status'=>'end','p'=>$parm,'nCallback'=>$this->nCallback); |
|
| 2864 | - $x=$tmp[0]; |
|
| 2865 | - $y=$tmp[1]; |
|
| 2863 | + $info = array('x'=>$tmp[0], 'y'=>$tmp[1], 'angle'=>$angle, 'status'=>'end', 'p'=>$parm, 'nCallback'=>$this->nCallback); |
|
| 2864 | + $x = $tmp[0]; |
|
| 2865 | + $y = $tmp[1]; |
|
| 2866 | 2866 | $ret = $this->$func($info); |
| 2867 | 2867 | if (is_array($ret)) { |
| 2868 | 2868 | // then the return from the callback function could set the position, to start with, later will do font colour, and font |
@@ -2870,7 +2870,7 @@ discard block |
||
| 2870 | 2870 | switch ($rk) { |
| 2871 | 2871 | case 'x': |
| 2872 | 2872 | case 'y': |
| 2873 | - $$rk=$rv; |
|
| 2873 | + $$rk = $rv; |
|
| 2874 | 2874 | break; |
| 2875 | 2875 | } |
| 2876 | 2876 | } |
@@ -2878,8 +2878,8 @@ discard block |
||
| 2878 | 2878 | // also remove from to the stack |
| 2879 | 2879 | // for simplicity, just take from the end, fix this another day |
| 2880 | 2880 | $this->nCallback--; |
| 2881 | - if ($this->nCallback<0) { |
|
| 2882 | - $this->nCallBack=0; |
|
| 2881 | + if ($this->nCallback < 0) { |
|
| 2882 | + $this->nCallBack = 0; |
|
| 2883 | 2883 | } |
| 2884 | 2884 | } |
| 2885 | 2885 | } |
@@ -2890,34 +2890,34 @@ discard block |
||
| 2890 | 2890 | case 'b': |
| 2891 | 2891 | case 'i': |
| 2892 | 2892 | $j++; |
| 2893 | - if ($text[$j]=='>') { |
|
| 2894 | - $this->currentTextState.=$text[$j-1]; |
|
| 2895 | - $directive=$j-$i+1; |
|
| 2893 | + if ($text[$j] == '>') { |
|
| 2894 | + $this->currentTextState .= $text[$j - 1]; |
|
| 2895 | + $directive = $j - $i + 1; |
|
| 2896 | 2896 | } |
| 2897 | 2897 | break; |
| 2898 | 2898 | case 'C': |
| 2899 | - $noClose=1; |
|
| 2899 | + $noClose = 1; |
|
| 2900 | 2900 | case 'c': |
| 2901 | 2901 | // this this might be a callback function |
| 2902 | 2902 | $j++; |
| 2903 | 2903 | $k = strpos($text, '>', $j); |
| 2904 | - if ($k!==false && $text[$j]==':') { |
|
| 2904 | + if ($k !== false && $text[$j] == ':') { |
|
| 2905 | 2905 | // then this will be treated as a callback directive |
| 2906 | - $directive = $k-$i+1; |
|
| 2907 | - $f=0; |
|
| 2906 | + $directive = $k - $i + 1; |
|
| 2907 | + $f = 0; |
|
| 2908 | 2908 | // split the remainder on colons to get the function name and the paramater |
| 2909 | 2909 | // $bits = explode(':',substr($text,$j+1,$k-$j-1)); |
| 2910 | - $tmp = substr($text, $j+1, $k-$j-1); |
|
| 2910 | + $tmp = substr($text, $j + 1, $k - $j - 1); |
|
| 2911 | 2911 | $b1 = strpos($tmp, ':'); |
| 2912 | - if ($b1!==false) { |
|
| 2912 | + if ($b1 !== false) { |
|
| 2913 | 2913 | $func = substr($tmp, 0, $b1); |
| 2914 | - $parm = substr($tmp, $b1+1); |
|
| 2914 | + $parm = substr($tmp, $b1 + 1); |
|
| 2915 | 2915 | } else { |
| 2916 | - $func=$tmp; |
|
| 2917 | - $parm=''; |
|
| 2916 | + $func = $tmp; |
|
| 2917 | + $parm = ''; |
|
| 2918 | 2918 | } |
| 2919 | 2919 | if (!isset($func) || !strlen(trim($func))) { |
| 2920 | - $directive=0; |
|
| 2920 | + $directive = 0; |
|
| 2921 | 2921 | } else { |
| 2922 | 2922 | // only call the function if this is the final call, ie, the one actually doing printing, not measurement |
| 2923 | 2923 | if ($final) { |
@@ -2925,14 +2925,14 @@ discard block |
||
| 2925 | 2925 | // can use getTextWidth to find the text width I think |
| 2926 | 2926 | // also add the text height and decender |
| 2927 | 2927 | $tmp = $this->getTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, substr($text, 0, $i)); |
| 2928 | - $info = array('x'=>$tmp[0],'y'=>$tmp[1],'angle'=>$angle,'status'=>'start','p'=>$parm,'f'=>$func,'height'=>$this->getFontHeight($size),'decender'=>$this->getFontDecender($size)); |
|
| 2929 | - $x=$tmp[0]; |
|
| 2930 | - $y=$tmp[1]; |
|
| 2928 | + $info = array('x'=>$tmp[0], 'y'=>$tmp[1], 'angle'=>$angle, 'status'=>'start', 'p'=>$parm, 'f'=>$func, 'height'=>$this->getFontHeight($size), 'decender'=>$this->getFontDecender($size)); |
|
| 2929 | + $x = $tmp[0]; |
|
| 2930 | + $y = $tmp[1]; |
|
| 2931 | 2931 | if (!isset($noClose) || !$noClose) { |
| 2932 | 2932 | // only add to the stack if this is a small 'c', therefore is a start-stop pair |
| 2933 | 2933 | $this->nCallback++; |
| 2934 | - $info['nCallback']=$this->nCallback; |
|
| 2935 | - $this->callback[$this->nCallback]=$info; |
|
| 2934 | + $info['nCallback'] = $this->nCallback; |
|
| 2935 | + $this->callback[$this->nCallback] = $info; |
|
| 2936 | 2936 | } |
| 2937 | 2937 | $ret = $this->$func($info); |
| 2938 | 2938 | if (is_array($ret)) { |
@@ -2941,7 +2941,7 @@ discard block |
||
| 2941 | 2941 | switch ($rk) { |
| 2942 | 2942 | case 'x': |
| 2943 | 2943 | case 'y': |
| 2944 | - $$rk=$rv; |
|
| 2944 | + $$rk = $rv; |
|
| 2945 | 2945 | break; |
| 2946 | 2946 | } |
| 2947 | 2947 | } |
@@ -2962,13 +2962,13 @@ discard block |
||
| 2962 | 2962 | public function addText($x, $y, $size, $text, $angle = 0, $wordSpaceAdjust = 0) |
| 2963 | 2963 | { |
| 2964 | 2964 | if (!$this->numFonts) { |
| 2965 | - $this->selectFont(dirname(__FILE__) . '/fonts/Helvetica'); |
|
| 2965 | + $this->selectFont(dirname(__FILE__).'/fonts/Helvetica'); |
|
| 2966 | 2966 | } |
| 2967 | 2967 | // if there are any open callbacks, then they should be called, to show the start of the line |
| 2968 | 2968 | if ($this->nCallback > 0) { |
| 2969 | 2969 | for ($i = $this->nCallback; $i > 0; $i--) { |
| 2970 | 2970 | // call each function |
| 2971 | - $info = array('x'=>$x,'y'=>$y,'angle'=>$angle,'status'=>'sol','p'=>$this->callback[$i]['p'],'nCallback'=>$this->callback[$i]['nCallback'],'height'=>$this->callback[$i]['height'],'decender'=>$this->callback[$i]['decender']); |
|
| 2971 | + $info = array('x'=>$x, 'y'=>$y, 'angle'=>$angle, 'status'=>'sol', 'p'=>$this->callback[$i]['p'], 'nCallback'=>$this->callback[$i]['nCallback'], 'height'=>$this->callback[$i]['height'], 'decender'=>$this->callback[$i]['decender']); |
|
| 2972 | 2972 | $func = $this->callback[$i]['f']; |
| 2973 | 2973 | $this->$func($info); |
| 2974 | 2974 | } |
@@ -2986,14 +2986,14 @@ discard block |
||
| 2986 | 2986 | } |
| 2987 | 2987 | |
| 2988 | 2988 | $len = strlen($text); |
| 2989 | - $start=0; |
|
| 2990 | - for ($i=0; $i<$len; $i++) { |
|
| 2991 | - $f=1; |
|
| 2989 | + $start = 0; |
|
| 2990 | + for ($i = 0; $i < $len; $i++) { |
|
| 2991 | + $f = 1; |
|
| 2992 | 2992 | $directive = $this->checkTextDirective($text, $i, $f); |
| 2993 | 2993 | if ($directive) { |
| 2994 | 2994 | // then we should write what we need to |
| 2995 | - if ($i>$start) { |
|
| 2996 | - $part = substr($text, $start, $i-$start); |
|
| 2995 | + if ($i > $start) { |
|
| 2996 | + $part = substr($text, $start, $i - $start); |
|
| 2997 | 2997 | $this->addContent(' /F'.$this->currentFontNum.' '.sprintf('%.1f', $size).' Tf '); |
| 2998 | 2998 | $this->addContent(' ('.$this->filterText($part, false).') Tj'); |
| 2999 | 2999 | } |
@@ -3002,13 +3002,13 @@ discard block |
||
| 3002 | 3002 | $this->setCurrentFont(); |
| 3003 | 3003 | } else { |
| 3004 | 3004 | $this->addContent(' ET'); |
| 3005 | - $f=1; |
|
| 3006 | - $xp=$x; |
|
| 3007 | - $yp=$y; |
|
| 3005 | + $f = 1; |
|
| 3006 | + $xp = $x; |
|
| 3007 | + $yp = $y; |
|
| 3008 | 3008 | $directive = $this->checkTextDirective1($text, $i, $f, 1, $xp, $yp, $size, $angle, $wordSpaceAdjust); |
| 3009 | 3009 | |
| 3010 | 3010 | // restart the text object |
| 3011 | - if ($angle==0) { |
|
| 3011 | + if ($angle == 0) { |
|
| 3012 | 3012 | $this->addContent("\n".'BT '.sprintf('%.3F', $xp).' '.sprintf('%.3F', $yp).' Td'); |
| 3013 | 3013 | } else { |
| 3014 | 3014 | $a = deg2rad((float)$angle); |
@@ -3017,14 +3017,14 @@ discard block |
||
| 3017 | 3017 | $tmp .= sprintf('%.3F', $xp).' '.sprintf('%.3F', $yp).' Tm'; |
| 3018 | 3018 | $this->addContent($tmp); |
| 3019 | 3019 | } |
| 3020 | - if ($wordSpaceAdjust!=0 || $wordSpaceAdjust != $this->wordSpaceAdjust) { |
|
| 3021 | - $this->wordSpaceAdjust=$wordSpaceAdjust; |
|
| 3020 | + if ($wordSpaceAdjust != 0 || $wordSpaceAdjust != $this->wordSpaceAdjust) { |
|
| 3021 | + $this->wordSpaceAdjust = $wordSpaceAdjust; |
|
| 3022 | 3022 | $this->addContent(' '.sprintf('%.3F', $wordSpaceAdjust).' Tw'); |
| 3023 | 3023 | } |
| 3024 | 3024 | } |
| 3025 | 3025 | // and move the writing point to the next piece of text |
| 3026 | - $i=$i+$directive-1; |
|
| 3027 | - $start=$i+1; |
|
| 3026 | + $i = $i + $directive - 1; |
|
| 3027 | + $start = $i + 1; |
|
| 3028 | 3028 | } |
| 3029 | 3029 | } |
| 3030 | 3030 | |
@@ -3034,7 +3034,7 @@ discard block |
||
| 3034 | 3034 | // modify unicode text so that extra word spacing is manually implemented (bug #) |
| 3035 | 3035 | $cf = $this->currentFont; |
| 3036 | 3036 | if ($this->fonts[$cf]['isUnicode'] && $wordSpaceAdjust != 0) { |
| 3037 | - $space_scale = 1000 / $size; |
|
| 3037 | + $space_scale = 1000/$size; |
|
| 3038 | 3038 | $place_text = str_replace(' ', ' ) '.(-round($space_scale*$wordSpaceAdjust)).' (', $place_text); |
| 3039 | 3039 | } |
| 3040 | 3040 | $this->addContent(" /F$this->currentFontNum ".sprintf('%.1F Tf ', $size)); |
@@ -3085,7 +3085,7 @@ discard block |
||
| 3085 | 3085 | |
| 3086 | 3086 | // hmm, this is where it all starts to get tricky - use the font information to |
| 3087 | 3087 | // calculate the width of each character, add them up and convert to user units |
| 3088 | - $w=0; |
|
| 3088 | + $w = 0; |
|
| 3089 | 3089 | $len = strlen($text); |
| 3090 | 3090 | $cf = $this->currentFont; |
| 3091 | 3091 | // font is set to unicode mode |
@@ -3095,15 +3095,15 @@ discard block |
||
| 3095 | 3095 | $out = $this->utf8toUtf16BE($text); |
| 3096 | 3096 | } |
| 3097 | 3097 | |
| 3098 | - for ($i=0; $i< strlen($text); $i++) { |
|
| 3099 | - $f=1; |
|
| 3098 | + for ($i = 0; $i < strlen($text); $i++) { |
|
| 3099 | + $f = 1; |
|
| 3100 | 3100 | $directive = $this->checkTextDirective($text, $i, $f); |
| 3101 | 3101 | if ($directive) { |
| 3102 | 3102 | if ($f) { |
| 3103 | 3103 | $this->setCurrentFont(); |
| 3104 | 3104 | $cf = $this->currentFont; |
| 3105 | 3105 | } |
| 3106 | - $i=$i+$directive-1; |
|
| 3106 | + $i = $i + $directive - 1; |
|
| 3107 | 3107 | } else { |
| 3108 | 3108 | if ($unicode) { |
| 3109 | 3109 | // use the previous converted text (utf8toUtf16BE) and get the correct character index by using below workaround |
@@ -3116,10 +3116,10 @@ discard block |
||
| 3116 | 3116 | // then this character is being replaced by another |
| 3117 | 3117 | $name = $this->fonts[$cf]['differences'][$char]; |
| 3118 | 3118 | if (isset($this->fonts[$cf]['C'][$name])) { |
| 3119 | - $w+=$this->fonts[$cf]['C'][$name]; |
|
| 3119 | + $w += $this->fonts[$cf]['C'][$name]; |
|
| 3120 | 3120 | } |
| 3121 | 3121 | } elseif (isset($this->fonts[$cf]['C'][$char])) { |
| 3122 | - $w+=$this->fonts[$cf]['C'][$char]; |
|
| 3122 | + $w += $this->fonts[$cf]['C'][$char]; |
|
| 3123 | 3123 | } |
| 3124 | 3124 | } |
| 3125 | 3125 | } |
@@ -3140,20 +3140,20 @@ discard block |
||
| 3140 | 3140 | return; |
| 3141 | 3141 | break; |
| 3142 | 3142 | case 'right': |
| 3143 | - $x+=$width-$actual; |
|
| 3143 | + $x += $width - $actual; |
|
| 3144 | 3144 | break; |
| 3145 | 3145 | case 'center': |
| 3146 | 3146 | case 'centre': |
| 3147 | - $x+=($width-$actual)/2; |
|
| 3147 | + $x += ($width - $actual)/2; |
|
| 3148 | 3148 | break; |
| 3149 | 3149 | case 'full': |
| 3150 | 3150 | // count the number of words |
| 3151 | 3151 | $words = explode(' ', $text); |
| 3152 | - $nspaces=count($words)-1; |
|
| 3153 | - if ($nspaces>0) { |
|
| 3154 | - $adjust = ($width-$actual)/$nspaces; |
|
| 3152 | + $nspaces = count($words) - 1; |
|
| 3153 | + if ($nspaces > 0) { |
|
| 3154 | + $adjust = ($width - $actual)/$nspaces; |
|
| 3155 | 3155 | } else { |
| 3156 | - $adjust=0; |
|
| 3156 | + $adjust = 0; |
|
| 3157 | 3157 | } |
| 3158 | 3158 | break; |
| 3159 | 3159 | } |
@@ -3178,27 +3178,27 @@ discard block |
||
| 3178 | 3178 | $store_currentTextState = $this->currentTextState; |
| 3179 | 3179 | |
| 3180 | 3180 | if (!$this->numFonts) { |
| 3181 | - $this->selectFont(dirname(__FILE__) . '/fonts/Helvetica'); |
|
| 3181 | + $this->selectFont(dirname(__FILE__).'/fonts/Helvetica'); |
|
| 3182 | 3182 | } |
| 3183 | - if ($width<=0) { |
|
| 3183 | + if ($width <= 0) { |
|
| 3184 | 3184 | // error, pretend it printed ok, otherwise risking a loop |
| 3185 | 3185 | return ''; |
| 3186 | 3186 | } |
| 3187 | - $w=0; |
|
| 3188 | - $break=0; |
|
| 3189 | - $breakWidth=0; |
|
| 3190 | - $len=strlen($text); |
|
| 3187 | + $w = 0; |
|
| 3188 | + $break = 0; |
|
| 3189 | + $breakWidth = 0; |
|
| 3190 | + $len = strlen($text); |
|
| 3191 | 3191 | $cf = $this->currentFont; |
| 3192 | 3192 | $tw = $width/$size*1000; |
| 3193 | - for ($i=0; $i<$len; $i++) { |
|
| 3194 | - $f=1; |
|
| 3193 | + for ($i = 0; $i < $len; $i++) { |
|
| 3194 | + $f = 1; |
|
| 3195 | 3195 | $directive = $this->checkTextDirective($text, $i, $f); |
| 3196 | 3196 | if ($directive) { |
| 3197 | 3197 | if ($f) { |
| 3198 | 3198 | $this->setCurrentFont(); |
| 3199 | 3199 | $cf = $this->currentFont; |
| 3200 | 3200 | } |
| 3201 | - $i=$i+$directive-1; |
|
| 3201 | + $i = $i + $directive - 1; |
|
| 3202 | 3202 | } else { |
| 3203 | 3203 | $cOrd = ord($text[$i]); |
| 3204 | 3204 | if (isset($this->fonts[$cf]['differences'][$cOrd])) { |
@@ -3209,18 +3209,18 @@ discard block |
||
| 3209 | 3209 | } |
| 3210 | 3210 | |
| 3211 | 3211 | if (isset($this->fonts[$cf]['C'][$cOrd2])) { |
| 3212 | - $w+=$this->fonts[$cf]['C'][$cOrd2]; |
|
| 3212 | + $w += $this->fonts[$cf]['C'][$cOrd2]; |
|
| 3213 | 3213 | } |
| 3214 | - if ($w>$tw) { |
|
| 3214 | + if ($w > $tw) { |
|
| 3215 | 3215 | // then we need to truncate this line |
| 3216 | - if ($break>0) { |
|
| 3216 | + if ($break > 0) { |
|
| 3217 | 3217 | // then we have somewhere that we can split :) |
| 3218 | - if ($text[$break]==' ') { |
|
| 3218 | + if ($text[$break] == ' ') { |
|
| 3219 | 3219 | $tmp = substr($text, 0, $break); |
| 3220 | 3220 | } else { |
| 3221 | - $tmp = substr($text, 0, $break+1); |
|
| 3221 | + $tmp = substr($text, 0, $break + 1); |
|
| 3222 | 3222 | } |
| 3223 | - $adjust=0; |
|
| 3223 | + $adjust = 0; |
|
| 3224 | 3224 | $this->adjustWrapText($tmp, $breakWidth, $width, $x, $adjust, $justification); |
| 3225 | 3225 | |
| 3226 | 3226 | // reset the text state |
@@ -3229,16 +3229,16 @@ discard block |
||
| 3229 | 3229 | if (!$test) { |
| 3230 | 3230 | $this->addText($x, $y, $size, $tmp, $angle, $adjust); |
| 3231 | 3231 | } |
| 3232 | - return substr($text, $break+1); |
|
| 3232 | + return substr($text, $break + 1); |
|
| 3233 | 3233 | } else { |
| 3234 | 3234 | // just split before the current character |
| 3235 | 3235 | $tmp = substr($text, 0, $i); |
| 3236 | - $adjust=0; |
|
| 3237 | - $ctmp=ord($text[$i]); |
|
| 3236 | + $adjust = 0; |
|
| 3237 | + $ctmp = ord($text[$i]); |
|
| 3238 | 3238 | if (isset($this->fonts[$cf]['differences'][$ctmp])) { |
| 3239 | - $ctmp=$this->fonts[$cf]['differences'][$ctmp]; |
|
| 3239 | + $ctmp = $this->fonts[$cf]['differences'][$ctmp]; |
|
| 3240 | 3240 | } |
| 3241 | - $tmpw=($w-$this->fonts[$cf]['C'][$ctmp])*$size/1000; |
|
| 3241 | + $tmpw = ($w - $this->fonts[$cf]['C'][$ctmp])*$size/1000; |
|
| 3242 | 3242 | $this->adjustWrapText($tmp, $tmpw, $width, $x, $adjust, $justification); |
| 3243 | 3243 | // reset the text state |
| 3244 | 3244 | $this->currentTextState = $store_currentTextState; |
@@ -3249,26 +3249,26 @@ discard block |
||
| 3249 | 3249 | return substr($text, $i); |
| 3250 | 3250 | } |
| 3251 | 3251 | } |
| 3252 | - if ($text[$i]=='-') { |
|
| 3253 | - $break=$i; |
|
| 3252 | + if ($text[$i] == '-') { |
|
| 3253 | + $break = $i; |
|
| 3254 | 3254 | $breakWidth = $w*$size/1000; |
| 3255 | 3255 | } |
| 3256 | - if ($text[$i]==' ') { |
|
| 3257 | - $break=$i; |
|
| 3258 | - $ctmp=ord($text[$i]); |
|
| 3256 | + if ($text[$i] == ' ') { |
|
| 3257 | + $break = $i; |
|
| 3258 | + $ctmp = ord($text[$i]); |
|
| 3259 | 3259 | if (isset($this->fonts[$cf]['differences'][$ctmp])) { |
| 3260 | - $ctmp=$this->fonts[$cf]['differences'][$ctmp]; |
|
| 3260 | + $ctmp = $this->fonts[$cf]['differences'][$ctmp]; |
|
| 3261 | 3261 | } |
| 3262 | - $breakWidth = ($w-$this->fonts[$cf]['C'][$ctmp])*$size/1000; |
|
| 3262 | + $breakWidth = ($w - $this->fonts[$cf]['C'][$ctmp])*$size/1000; |
|
| 3263 | 3263 | } |
| 3264 | 3264 | } |
| 3265 | 3265 | } |
| 3266 | 3266 | // then there was no need to break this line |
| 3267 | - if ($justification=='full') { |
|
| 3268 | - $justification='left'; |
|
| 3267 | + if ($justification == 'full') { |
|
| 3268 | + $justification = 'left'; |
|
| 3269 | 3269 | } |
| 3270 | - $adjust=0; |
|
| 3271 | - $tmpw=$w*$size/1000; |
|
| 3270 | + $adjust = 0; |
|
| 3271 | + $tmpw = $w*$size/1000; |
|
| 3272 | 3272 | $this->adjustWrapText($text, $tmpw, $width, $x, $adjust, $justification); |
| 3273 | 3273 | // reset the text state |
| 3274 | 3274 | $this->currentTextState = $store_currentTextState; |
@@ -3294,17 +3294,17 @@ discard block |
||
| 3294 | 3294 | $opt = $this->stateStack[$pageEnd]; // ok to use this as stack starts numbering at 1 |
| 3295 | 3295 | $this->setColor($opt['col']['r'], $opt['col']['g'], $opt['col']['b'], 1); |
| 3296 | 3296 | $this->setStrokeColor($opt['str']['r'], $opt['str']['g'], $opt['str']['b'], 1); |
| 3297 | - $this->objects[$this->currentContents]['c'].="\n".$opt['lin']; |
|
| 3297 | + $this->objects[$this->currentContents]['c'] .= "\n".$opt['lin']; |
|
| 3298 | 3298 | // $this->currentLineStyle = $opt['lin']; |
| 3299 | 3299 | } else { |
| 3300 | 3300 | $this->nStateStack++; |
| 3301 | - $this->stateStack[$this->nStateStack]=array( |
|
| 3301 | + $this->stateStack[$this->nStateStack] = array( |
|
| 3302 | 3302 | 'col'=>$this->currentColour |
| 3303 | 3303 | ,'str'=>$this->currentStrokeColour |
| 3304 | 3304 | ,'lin'=>$this->currentLineStyle |
| 3305 | 3305 | ); |
| 3306 | 3306 | } |
| 3307 | - $this->objects[$this->currentContents]['c'].="\nq"; |
|
| 3307 | + $this->objects[$this->currentContents]['c'] .= "\nq"; |
|
| 3308 | 3308 | } |
| 3309 | 3309 | |
| 3310 | 3310 | /** |
@@ -3317,12 +3317,12 @@ discard block |
||
| 3317 | 3317 | $n = $this->nStateStack; |
| 3318 | 3318 | $this->currentColour = $this->stateStack[$n]['col']; |
| 3319 | 3319 | $this->currentStrokeColour = $this->stateStack[$n]['str']; |
| 3320 | - $this->objects[$this->currentContents]['c'].="\n".$this->stateStack[$n]['lin']; |
|
| 3320 | + $this->objects[$this->currentContents]['c'] .= "\n".$this->stateStack[$n]['lin']; |
|
| 3321 | 3321 | $this->currentLineStyle = $this->stateStack[$n]['lin']; |
| 3322 | 3322 | unset($this->stateStack[$n]); |
| 3323 | 3323 | $this->nStateStack--; |
| 3324 | 3324 | } |
| 3325 | - $this->objects[$this->currentContents]['c'].="\nQ"; |
|
| 3325 | + $this->objects[$this->currentContents]['c'] .= "\nQ"; |
|
| 3326 | 3326 | } |
| 3327 | 3327 | |
| 3328 | 3328 | /** |
@@ -3335,12 +3335,12 @@ discard block |
||
| 3335 | 3335 | public function openObject() |
| 3336 | 3336 | { |
| 3337 | 3337 | $this->nStack++; |
| 3338 | - $this->stack[$this->nStack]=array('c'=>$this->currentContents,'p'=>$this->currentPage); |
|
| 3338 | + $this->stack[$this->nStack] = array('c'=>$this->currentContents, 'p'=>$this->currentPage); |
|
| 3339 | 3339 | // add a new object of the content type, to hold the data flow |
| 3340 | 3340 | $this->numObj++; |
| 3341 | 3341 | $this->o_contents($this->numObj, 'new'); |
| 3342 | - $this->currentContents=$this->numObj; |
|
| 3343 | - $this->looseObjects[$this->numObj]=1; |
|
| 3342 | + $this->currentContents = $this->numObj; |
|
| 3343 | + $this->looseObjects[$this->numObj] = 1; |
|
| 3344 | 3344 | |
| 3345 | 3345 | return $this->numObj; |
| 3346 | 3346 | } |
@@ -3352,8 +3352,8 @@ discard block |
||
| 3352 | 3352 | public function reopenObject($id) |
| 3353 | 3353 | { |
| 3354 | 3354 | $this->nStack++; |
| 3355 | - $this->stack[$this->nStack]=array('c'=>$this->currentContents,'p'=>$this->currentPage); |
|
| 3356 | - $this->currentContents=$id; |
|
| 3355 | + $this->stack[$this->nStack] = array('c'=>$this->currentContents, 'p'=>$this->currentPage); |
|
| 3356 | + $this->currentContents = $id; |
|
| 3357 | 3357 | // also if this object is the primary contents for a page, then set the current page to its parent |
| 3358 | 3358 | if (isset($this->objects[$id]['onPage'])) { |
| 3359 | 3359 | $this->currentPage = $this->objects[$id]['onPage']; |
@@ -3368,9 +3368,9 @@ discard block |
||
| 3368 | 3368 | { |
| 3369 | 3369 | // close the object, as long as there was one open in the first place, which will be indicated by |
| 3370 | 3370 | // an objectId on the stack. |
| 3371 | - if ($this->nStack>0) { |
|
| 3372 | - $this->currentContents=$this->stack[$this->nStack]['c']; |
|
| 3373 | - $this->currentPage=$this->stack[$this->nStack]['p']; |
|
| 3371 | + if ($this->nStack > 0) { |
|
| 3372 | + $this->currentContents = $this->stack[$this->nStack]['c']; |
|
| 3373 | + $this->currentPage = $this->stack[$this->nStack]['p']; |
|
| 3374 | 3374 | $this->nStack--; |
| 3375 | 3375 | // easier to probably not worry about removing the old entries, they will be overwritten |
| 3376 | 3376 | // if there are new ones. |
@@ -3386,7 +3386,7 @@ discard block |
||
| 3386 | 3386 | // if an object has been appearing on pages up to now, then stop it, this page will |
| 3387 | 3387 | // be the last one that could contian it. |
| 3388 | 3388 | if (isset($this->addLooseObjects[$id])) { |
| 3389 | - $this->addLooseObjects[$id]=''; |
|
| 3389 | + $this->addLooseObjects[$id] = ''; |
|
| 3390 | 3390 | } |
| 3391 | 3391 | } |
| 3392 | 3392 | |
@@ -3397,13 +3397,13 @@ discard block |
||
| 3397 | 3397 | public function addObject($id, $options = 'add') |
| 3398 | 3398 | { |
| 3399 | 3399 | // add the specified object to the page |
| 3400 | - if (isset($this->looseObjects[$id]) && $this->currentContents!=$id) { |
|
| 3400 | + if (isset($this->looseObjects[$id]) && $this->currentContents != $id) { |
|
| 3401 | 3401 | // then it is a valid object, and it is not being added to itself |
| 3402 | 3402 | switch ($options) { |
| 3403 | 3403 | case 'all': |
| 3404 | 3404 | // then this object is to be added to this page (done in the next block) and |
| 3405 | 3405 | // all future new pages. |
| 3406 | - $this->addLooseObjects[$id]='all'; |
|
| 3406 | + $this->addLooseObjects[$id] = 'all'; |
|
| 3407 | 3407 | case 'add': |
| 3408 | 3408 | if (isset($this->objects[$this->currentContents]['onPage'])) { |
| 3409 | 3409 | // then the destination contents is the primary for the page |
@@ -3412,27 +3412,27 @@ discard block |
||
| 3412 | 3412 | } |
| 3413 | 3413 | break; |
| 3414 | 3414 | case 'even': |
| 3415 | - $this->addLooseObjects[$id]='even'; |
|
| 3416 | - $pageObjectId=$this->objects[$this->currentContents]['onPage']; |
|
| 3417 | - if ($this->objects[$pageObjectId]['info']['pageNum']%2==0) { |
|
| 3415 | + $this->addLooseObjects[$id] = 'even'; |
|
| 3416 | + $pageObjectId = $this->objects[$this->currentContents]['onPage']; |
|
| 3417 | + if ($this->objects[$pageObjectId]['info']['pageNum']%2 == 0) { |
|
| 3418 | 3418 | $this->addObject($id); // hacky huh :) |
| 3419 | 3419 | } |
| 3420 | 3420 | break; |
| 3421 | 3421 | case 'odd': |
| 3422 | - $this->addLooseObjects[$id]='odd'; |
|
| 3423 | - $pageObjectId=$this->objects[$this->currentContents]['onPage']; |
|
| 3424 | - if ($this->objects[$pageObjectId]['info']['pageNum']%2==1) { |
|
| 3422 | + $this->addLooseObjects[$id] = 'odd'; |
|
| 3423 | + $pageObjectId = $this->objects[$this->currentContents]['onPage']; |
|
| 3424 | + if ($this->objects[$pageObjectId]['info']['pageNum']%2 == 1) { |
|
| 3425 | 3425 | $this->addObject($id); // hacky huh :) |
| 3426 | 3426 | } |
| 3427 | 3427 | break; |
| 3428 | 3428 | case 'next': |
| 3429 | - $this->addLooseObjects[$id]='all'; |
|
| 3429 | + $this->addLooseObjects[$id] = 'all'; |
|
| 3430 | 3430 | break; |
| 3431 | 3431 | case 'nexteven': |
| 3432 | - $this->addLooseObjects[$id]='even'; |
|
| 3432 | + $this->addLooseObjects[$id] = 'even'; |
|
| 3433 | 3433 | break; |
| 3434 | 3434 | case 'nextodd': |
| 3435 | - $this->addLooseObjects[$id]='odd'; |
|
| 3435 | + $this->addLooseObjects[$id] = 'odd'; |
|
| 3436 | 3436 | break; |
| 3437 | 3437 | } |
| 3438 | 3438 | } |
@@ -3481,10 +3481,10 @@ discard block |
||
| 3481 | 3481 | private function getBytes(&$data, $pos, $num) |
| 3482 | 3482 | { |
| 3483 | 3483 | // return the integer represented by $num bytes from $pos within $data |
| 3484 | - $ret=0; |
|
| 3485 | - for ($i=0; $i<$num; $i++) { |
|
| 3486 | - $ret=$ret*256; |
|
| 3487 | - $ret+=ord($data[$pos+$i]); |
|
| 3484 | + $ret = 0; |
|
| 3485 | + for ($i = 0; $i < $num; $i++) { |
|
| 3486 | + $ret = $ret*256; |
|
| 3487 | + $ret += ord($data[$pos + $i]); |
|
| 3488 | 3488 | } |
| 3489 | 3489 | return $ret; |
| 3490 | 3490 | } |
@@ -3501,30 +3501,30 @@ discard block |
||
| 3501 | 3501 | $p = 8; |
| 3502 | 3502 | $len = strlen($data); |
| 3503 | 3503 | // cycle through the file, identifying chunks |
| 3504 | - while ($p<$len) { |
|
| 3504 | + while ($p < $len) { |
|
| 3505 | 3505 | $chunkLen = $this->getBytes($data, $p, 4); |
| 3506 | - $chunkType = substr($data, $p+4, 4); |
|
| 3506 | + $chunkType = substr($data, $p + 4, 4); |
|
| 3507 | 3507 | //error_log($chunkType. ' - '.$chunkLen); |
| 3508 | 3508 | switch ($chunkType) { |
| 3509 | 3509 | case 'IHDR': |
| 3510 | 3510 | //this is where all the file information comes from |
| 3511 | - $default['info']['width']=$this->getBytes($data, $p+8, 4); |
|
| 3512 | - $default['info']['height']=$this->getBytes($data, $p+12, 4); |
|
| 3513 | - $default['info']['bitDepth']=ord($data[$p+16]); |
|
| 3514 | - $default['info']['colorType']=ord($data[$p+17]); |
|
| 3515 | - $default['info']['compressionMethod']=ord($data[$p+18]); |
|
| 3516 | - $default['info']['filterMethod']=ord($data[$p+19]); |
|
| 3517 | - $default['info']['interlaceMethod']=ord($data[$p+20]); |
|
| 3511 | + $default['info']['width'] = $this->getBytes($data, $p + 8, 4); |
|
| 3512 | + $default['info']['height'] = $this->getBytes($data, $p + 12, 4); |
|
| 3513 | + $default['info']['bitDepth'] = ord($data[$p + 16]); |
|
| 3514 | + $default['info']['colorType'] = ord($data[$p + 17]); |
|
| 3515 | + $default['info']['compressionMethod'] = ord($data[$p + 18]); |
|
| 3516 | + $default['info']['filterMethod'] = ord($data[$p + 19]); |
|
| 3517 | + $default['info']['interlaceMethod'] = ord($data[$p + 20]); |
|
| 3518 | 3518 | |
| 3519 | - $this->debug('readPngChunks: ColorType is' . $default['info']['colorType'], E_USER_NOTICE); |
|
| 3519 | + $this->debug('readPngChunks: ColorType is'.$default['info']['colorType'], E_USER_NOTICE); |
|
| 3520 | 3520 | |
| 3521 | 3521 | $default['haveHeader'] = true; |
| 3522 | 3522 | |
| 3523 | - if ($default['info']['compressionMethod']!=0) { |
|
| 3523 | + if ($default['info']['compressionMethod'] != 0) { |
|
| 3524 | 3524 | $error = true; |
| 3525 | 3525 | $errormsg = "unsupported compression method"; |
| 3526 | 3526 | } |
| 3527 | - if ($default['info']['filterMethod']!=0) { |
|
| 3527 | + if ($default['info']['filterMethod'] != 0) { |
|
| 3528 | 3528 | $error = true; |
| 3529 | 3529 | $errormsg = "unsupported filter method"; |
| 3530 | 3530 | } |
@@ -3539,12 +3539,12 @@ discard block |
||
| 3539 | 3539 | |
| 3540 | 3540 | // there will be one entry for each palette entry. up until the last non-opaque entry. |
| 3541 | 3541 | // set up an array, stretching over all palette entries which will be o (opaque) or 1 (transparent) |
| 3542 | - $default['transparency']['type']='indexed'; |
|
| 3542 | + $default['transparency']['type'] = 'indexed'; |
|
| 3543 | 3543 | //$numPalette = strlen($default['pdata'])/3; |
| 3544 | - $trans=0; |
|
| 3545 | - for ($i=$chunkLen; $i>=0; $i--) { |
|
| 3546 | - if (ord($data[$p+8+$i])==0) { |
|
| 3547 | - $trans=$i; |
|
| 3544 | + $trans = 0; |
|
| 3545 | + for ($i = $chunkLen; $i >= 0; $i--) { |
|
| 3546 | + if (ord($data[$p + 8 + $i]) == 0) { |
|
| 3547 | + $trans = $i; |
|
| 3548 | 3548 | } |
| 3549 | 3549 | } |
| 3550 | 3550 | $default['transparency']['data'] = $trans; |
@@ -3553,16 +3553,16 @@ discard block |
||
| 3553 | 3553 | // Gray: 2 bytes, range 0 .. (2^bitdepth)-1 |
| 3554 | 3554 | |
| 3555 | 3555 | // $transparency['grayscale']=$this->getBytes($data,$p+8,2); // g = grayscale |
| 3556 | - $default['transparency']['type']='indexed'; |
|
| 3557 | - $default['transparency']['data'] = ord($data[$p+8+1]); |
|
| 3556 | + $default['transparency']['type'] = 'indexed'; |
|
| 3557 | + $default['transparency']['data'] = ord($data[$p + 8 + 1]); |
|
| 3558 | 3558 | } elseif ($default['info']['colorType'] == 2) { // truecolor |
| 3559 | 3559 | // corresponding to entries in the plte chunk |
| 3560 | 3560 | // Red: 2 bytes, range 0 .. (2^bitdepth)-1 |
| 3561 | 3561 | // Green: 2 bytes, range 0 .. (2^bitdepth)-1 |
| 3562 | 3562 | // Blue: 2 bytes, range 0 .. (2^bitdepth)-1 |
| 3563 | - $default['transparency']['r']=$this->getBytes($data, $p+8, 2); // r from truecolor |
|
| 3564 | - $default['transparency']['g']=$this->getBytes($data, $p+10, 2); // g from truecolor |
|
| 3565 | - $default['transparency']['b']=$this->getBytes($data, $p+12, 2); // b from truecolor |
|
| 3563 | + $default['transparency']['r'] = $this->getBytes($data, $p + 8, 2); // r from truecolor |
|
| 3564 | + $default['transparency']['g'] = $this->getBytes($data, $p + 10, 2); // g from truecolor |
|
| 3565 | + $default['transparency']['b'] = $this->getBytes($data, $p + 12, 2); // b from truecolor |
|
| 3566 | 3566 | } elseif ($default['info']['colorType'] == 6 || $default['info']['colorType'] == 4) { |
| 3567 | 3567 | // set transparency type to "alpha" and proceed with it in $this->o_image later |
| 3568 | 3568 | $default['transparency']['type'] = 'alpha'; |
@@ -3579,11 +3579,11 @@ discard block |
||
| 3579 | 3579 | for ($ypx = 0; $ypx < $default['info']['height']; ++$ypx) { |
| 3580 | 3580 | $colorBits = imagecolorat($img, $xpx, $ypx); |
| 3581 | 3581 | $color = imagecolorsforindex($img, $colorBits); |
| 3582 | - $color['alpha'] = (((127 - $color['alpha']) / 127) * 255); |
|
| 3582 | + $color['alpha'] = (((127 - $color['alpha'])/127)*255); |
|
| 3583 | 3583 | imagesetpixel($imgalpha, $xpx, $ypx, $color['alpha']); |
| 3584 | 3584 | } |
| 3585 | 3585 | } |
| 3586 | - $tmpfile_alpha=tempnam($this->tempPath, 'ezImg'); |
|
| 3586 | + $tmpfile_alpha = tempnam($this->tempPath, 'ezImg'); |
|
| 3587 | 3587 | |
| 3588 | 3588 | imagepng($imgalpha, $tmpfile_alpha); |
| 3589 | 3589 | imagedestroy($imgalpha); |
@@ -3595,7 +3595,7 @@ discard block |
||
| 3595 | 3595 | $default['pdata'] = $alphaImg['idata']; |
| 3596 | 3596 | |
| 3597 | 3597 | // generate true color image with no alpha channel |
| 3598 | - $tmpfile_tt=tempnam($this->tempPath, 'ezImg'); |
|
| 3598 | + $tmpfile_tt = tempnam($this->tempPath, 'ezImg'); |
|
| 3599 | 3599 | |
| 3600 | 3600 | $imgplain = imagecreatetruecolor($default['info']['width'], $default['info']['height']); |
| 3601 | 3601 | imagecopy($imgplain, $img, 0, 0, 0, 0, $default['info']['width'], $default['info']['height']); |
@@ -3615,10 +3615,10 @@ discard block |
||
| 3615 | 3615 | } |
| 3616 | 3616 | break; |
| 3617 | 3617 | case 'PLTE': |
| 3618 | - $default['pdata'] = substr($data, $p+8, $chunkLen); |
|
| 3618 | + $default['pdata'] = substr($data, $p + 8, $chunkLen); |
|
| 3619 | 3619 | break; |
| 3620 | 3620 | case 'IDAT': |
| 3621 | - $default['idata'] .= substr($data, $p+8, $chunkLen); |
|
| 3621 | + $default['idata'] .= substr($data, $p + 8, $chunkLen); |
|
| 3622 | 3622 | break; |
| 3623 | 3623 | case 'tRNS': // this HEADER info is optional. More info: rfc2083 (http://tools.ietf.org/html/rfc2083) |
| 3624 | 3624 | // error_log('OPTIONAL HEADER -tRNS- exist:'); |
@@ -3628,7 +3628,7 @@ discard block |
||
| 3628 | 3628 | default: |
| 3629 | 3629 | break; |
| 3630 | 3630 | } |
| 3631 | - $p += $chunkLen+12; |
|
| 3631 | + $p += $chunkLen + 12; |
|
| 3632 | 3632 | } |
| 3633 | 3633 | return $default; |
| 3634 | 3634 | } |
@@ -3644,18 +3644,18 @@ discard block |
||
| 3644 | 3644 | $error = false; |
| 3645 | 3645 | $errormsg = ""; |
| 3646 | 3646 | |
| 3647 | - $this->debug('addPngFromFile: opening image ' . $file); |
|
| 3647 | + $this->debug('addPngFromFile: opening image '.$file); |
|
| 3648 | 3648 | |
| 3649 | 3649 | $data = file_get_contents($file); |
| 3650 | 3650 | |
| 3651 | 3651 | if ($data === false) { |
| 3652 | - $this->debug('addPngFromFile: trouble opening file ' . $file, E_USER_WARNING); |
|
| 3652 | + $this->debug('addPngFromFile: trouble opening file '.$file, E_USER_WARNING); |
|
| 3653 | 3653 | return; |
| 3654 | 3654 | } |
| 3655 | 3655 | |
| 3656 | 3656 | $header = chr(137).chr(80).chr(78).chr(71).chr(13).chr(10).chr(26).chr(10); |
| 3657 | - if (substr($data, 0, 8)!=$header) { |
|
| 3658 | - $this->debug('addPngFromFile: Invalid PNG header for file: ' . $file, E_USER_WARNING); |
|
| 3657 | + if (substr($data, 0, 8) != $header) { |
|
| 3658 | + $this->debug('addPngFromFile: Invalid PNG header for file: '.$file, E_USER_WARNING); |
|
| 3659 | 3659 | return; |
| 3660 | 3660 | } |
| 3661 | 3661 | |
@@ -3675,24 +3675,24 @@ discard block |
||
| 3675 | 3675 | $errormsg = "only bit depth of 8 or less is supported."; |
| 3676 | 3676 | } |
| 3677 | 3677 | |
| 3678 | - if ($iChunk['info']['colorType'] == 1 || $iChunk['info']['colorType'] == 5 || $iChunk['info']['colorType']== 7) { |
|
| 3678 | + if ($iChunk['info']['colorType'] == 1 || $iChunk['info']['colorType'] == 5 || $iChunk['info']['colorType'] == 7) { |
|
| 3679 | 3679 | $error = true; |
| 3680 | 3680 | $errormsg = 'Unsupported PNG color type: '.$iChunk['info']['colorType']; |
| 3681 | 3681 | } elseif (isset($iChunk['info'])) { |
| 3682 | 3682 | switch ($iChunk['info']['colorType']) { |
| 3683 | 3683 | case 3: |
| 3684 | 3684 | $color = 'DeviceRGB'; |
| 3685 | - $ncolor=1; |
|
| 3685 | + $ncolor = 1; |
|
| 3686 | 3686 | break; |
| 3687 | 3687 | case 6: |
| 3688 | 3688 | case 2: |
| 3689 | 3689 | $color = 'DeviceRGB'; |
| 3690 | - $ncolor=3; |
|
| 3690 | + $ncolor = 3; |
|
| 3691 | 3691 | break; |
| 3692 | 3692 | case 4: |
| 3693 | 3693 | case 0: |
| 3694 | 3694 | $color = 'DeviceGray'; |
| 3695 | - $ncolor=1; |
|
| 3695 | + $ncolor = 1; |
|
| 3696 | 3696 | break; |
| 3697 | 3697 | } |
| 3698 | 3698 | } |
@@ -3701,11 +3701,11 @@ discard block |
||
| 3701 | 3701 | $this->debug('addPngFromFile: '.$errormsg, E_USER_WARNING); |
| 3702 | 3702 | return; |
| 3703 | 3703 | } |
| 3704 | - if ($w==0) { |
|
| 3705 | - $w=$h/$iChunk['info']['height']*$iChunk['info']['width']; |
|
| 3704 | + if ($w == 0) { |
|
| 3705 | + $w = $h/$iChunk['info']['height']*$iChunk['info']['width']; |
|
| 3706 | 3706 | } |
| 3707 | - if ($h==0) { |
|
| 3708 | - $h=$w*$iChunk['info']['height']/$iChunk['info']['width']; |
|
| 3707 | + if ($h == 0) { |
|
| 3708 | + $h = $w*$iChunk['info']['height']/$iChunk['info']['width']; |
|
| 3709 | 3709 | } |
| 3710 | 3710 | |
| 3711 | 3711 | if ($this->hashed) { |
@@ -3715,24 +3715,24 @@ discard block |
||
| 3715 | 3715 | $label = $this->objectHash[$oHash]; |
| 3716 | 3716 | } else { |
| 3717 | 3717 | $this->numImages++; |
| 3718 | - $label='I'.$this->numImages; |
|
| 3718 | + $label = 'I'.$this->numImages; |
|
| 3719 | 3719 | $this->numObj++; |
| 3720 | 3720 | |
| 3721 | 3721 | if (isset($oHash)) { |
| 3722 | 3722 | $this->objectHash[$oHash] = $label; |
| 3723 | 3723 | } |
| 3724 | 3724 | |
| 3725 | - $options = array('label'=>$label,'data'=>$iChunk['idata'],'bitsPerComponent'=>$iChunk['info']['bitDepth'],'pdata'=>$iChunk['pdata'] |
|
| 3726 | - ,'iw'=>$iChunk['info']['width'],'ih'=>$iChunk['info']['height'],'type'=>'png','color'=>$color,'ncolor'=>$ncolor); |
|
| 3725 | + $options = array('label'=>$label, 'data'=>$iChunk['idata'], 'bitsPerComponent'=>$iChunk['info']['bitDepth'], 'pdata'=>$iChunk['pdata'] |
|
| 3726 | + ,'iw'=>$iChunk['info']['width'], 'ih'=>$iChunk['info']['height'], 'type'=>'png', 'color'=>$color, 'ncolor'=>$ncolor); |
|
| 3727 | 3727 | if (isset($iChunk['transparency'])) { |
| 3728 | - $options['transparency']=$iChunk['transparency']; |
|
| 3728 | + $options['transparency'] = $iChunk['transparency']; |
|
| 3729 | 3729 | } |
| 3730 | 3730 | $this->o_image($this->numObj, 'new', $options); |
| 3731 | 3731 | } |
| 3732 | 3732 | |
| 3733 | - $this->objects[$this->currentContents]['c'].="\nq ".sprintf('%.3F', $w)." 0 0 ".sprintf('%.3F', $h)." ".sprintf('%.3F', $x)." ".sprintf('%.3F', $y)." cm"; |
|
| 3734 | - $this->objects[$this->currentContents]['c'].=" /".$label.' Do'; |
|
| 3735 | - $this->objects[$this->currentContents]['c'].=" Q"; |
|
| 3733 | + $this->objects[$this->currentContents]['c'] .= "\nq ".sprintf('%.3F', $w)." 0 0 ".sprintf('%.3F', $h)." ".sprintf('%.3F', $x)." ".sprintf('%.3F', $y)." cm"; |
|
| 3734 | + $this->objects[$this->currentContents]['c'] .= " /".$label.' Do'; |
|
| 3735 | + $this->objects[$this->currentContents]['c'] .= " Q"; |
|
| 3736 | 3736 | } |
| 3737 | 3737 | |
| 3738 | 3738 | /** |
@@ -3748,9 +3748,9 @@ discard block |
||
| 3748 | 3748 | return; |
| 3749 | 3749 | } |
| 3750 | 3750 | |
| 3751 | - $tmp=getimagesize($img); |
|
| 3752 | - $imageWidth=$tmp[0]; |
|
| 3753 | - $imageHeight=$tmp[1]; |
|
| 3751 | + $tmp = getimagesize($img); |
|
| 3752 | + $imageWidth = $tmp[0]; |
|
| 3753 | + $imageHeight = $tmp[1]; |
|
| 3754 | 3754 | |
| 3755 | 3755 | if (isset($tmp['channels'])) { |
| 3756 | 3756 | $channels = $tmp['channels']; |
@@ -3758,14 +3758,14 @@ discard block |
||
| 3758 | 3758 | $channels = 3; |
| 3759 | 3759 | } |
| 3760 | 3760 | |
| 3761 | - if ($w<=0 && $h<=0) { |
|
| 3762 | - $w=$imageWidth; |
|
| 3761 | + if ($w <= 0 && $h <= 0) { |
|
| 3762 | + $w = $imageWidth; |
|
| 3763 | 3763 | } |
| 3764 | - if ($w==0) { |
|
| 3765 | - $w=$h/$imageHeight*$imageWidth; |
|
| 3764 | + if ($w == 0) { |
|
| 3765 | + $w = $h/$imageHeight*$imageWidth; |
|
| 3766 | 3766 | } |
| 3767 | - if ($h==0) { |
|
| 3768 | - $h=$w*$imageHeight/$imageWidth; |
|
| 3767 | + if ($h == 0) { |
|
| 3768 | + $h = $w*$imageHeight/$imageWidth; |
|
| 3769 | 3769 | } |
| 3770 | 3770 | |
| 3771 | 3771 | $data = file_get_contents($img); |
@@ -3793,23 +3793,23 @@ discard block |
||
| 3793 | 3793 | return; |
| 3794 | 3794 | } |
| 3795 | 3795 | |
| 3796 | - $tmp=getimagesize($img); |
|
| 3797 | - $imageWidth=$tmp[0]; |
|
| 3798 | - $imageHeight=$tmp[1]; |
|
| 3796 | + $tmp = getimagesize($img); |
|
| 3797 | + $imageWidth = $tmp[0]; |
|
| 3798 | + $imageHeight = $tmp[1]; |
|
| 3799 | 3799 | |
| 3800 | 3800 | |
| 3801 | - if ($w<=0 && $h<=0) { |
|
| 3802 | - $w=$imageWidth; |
|
| 3801 | + if ($w <= 0 && $h <= 0) { |
|
| 3802 | + $w = $imageWidth; |
|
| 3803 | 3803 | } |
| 3804 | - if ($w==0) { |
|
| 3805 | - $w=$h/$imageHeight*$imageWidth; |
|
| 3804 | + if ($w == 0) { |
|
| 3805 | + $w = $h/$imageHeight*$imageWidth; |
|
| 3806 | 3806 | } |
| 3807 | - if ($h==0) { |
|
| 3808 | - $h=$w*$imageHeight/$imageWidth; |
|
| 3807 | + if ($h == 0) { |
|
| 3808 | + $h = $w*$imageHeight/$imageWidth; |
|
| 3809 | 3809 | } |
| 3810 | 3810 | |
| 3811 | 3811 | $imgres = imagecreatefromgif($img); |
| 3812 | - $tmpName=tempnam($this->tempPath, 'img'); |
|
| 3812 | + $tmpName = tempnam($this->tempPath, 'img'); |
|
| 3813 | 3813 | imagejpeg($imgres, $tmpName, 90); |
| 3814 | 3814 | |
| 3815 | 3815 | $this->addJpegFromFile($tmpName, $x, $y, $w, $h); |
@@ -3837,26 +3837,26 @@ discard block |
||
| 3837 | 3837 | |
| 3838 | 3838 | // there seems to be some problem here in that images that have quality set above 75 do not appear |
| 3839 | 3839 | // not too sure why this is, but in the meantime I have restricted this to 75. |
| 3840 | - if ($quality>75) { |
|
| 3841 | - $quality=75; |
|
| 3840 | + if ($quality > 75) { |
|
| 3841 | + $quality = 75; |
|
| 3842 | 3842 | } |
| 3843 | 3843 | |
| 3844 | 3844 | // if the width or height are set to zero, then set the other one based on keeping the image |
| 3845 | 3845 | // height/width ratio the same, if they are both zero, then give up :) |
| 3846 | - $imageWidth=imagesx($img); |
|
| 3847 | - $imageHeight=imagesy($img); |
|
| 3846 | + $imageWidth = imagesx($img); |
|
| 3847 | + $imageHeight = imagesy($img); |
|
| 3848 | 3848 | |
| 3849 | - if ($w<=0 && $h<=0) { |
|
| 3849 | + if ($w <= 0 && $h <= 0) { |
|
| 3850 | 3850 | return; |
| 3851 | 3851 | } |
| 3852 | - if ($w==0) { |
|
| 3853 | - $w=$h/$imageHeight*$imageWidth; |
|
| 3852 | + if ($w == 0) { |
|
| 3853 | + $w = $h/$imageHeight*$imageWidth; |
|
| 3854 | 3854 | } |
| 3855 | - if ($h==0) { |
|
| 3856 | - $h=$w*$imageHeight/$imageWidth; |
|
| 3855 | + if ($h == 0) { |
|
| 3856 | + $h = $w*$imageHeight/$imageWidth; |
|
| 3857 | 3857 | } |
| 3858 | 3858 | |
| 3859 | - $tmpName=tempnam($this->tempPath, 'img'); |
|
| 3859 | + $tmpName = tempnam($this->tempPath, 'img'); |
|
| 3860 | 3860 | imagejpeg($img, $tmpName, $quality); |
| 3861 | 3861 | |
| 3862 | 3862 | $data = file_get_contents($tmpName); |
@@ -3882,19 +3882,19 @@ discard block |
||
| 3882 | 3882 | $label = $this->objectHash[$oHash]; |
| 3883 | 3883 | } else { |
| 3884 | 3884 | $this->numImages++; |
| 3885 | - $label='I'.$this->numImages; |
|
| 3885 | + $label = 'I'.$this->numImages; |
|
| 3886 | 3886 | $this->numObj++; |
| 3887 | 3887 | |
| 3888 | 3888 | if (isset($oHash)) { |
| 3889 | 3889 | $this->objectHash[$oHash] = $label; |
| 3890 | 3890 | } |
| 3891 | 3891 | |
| 3892 | - $this->o_image($this->numObj, 'new', array('label'=>$label,'data'=>$data,'iw'=>$imageWidth,'ih'=>$imageHeight,'channels'=>$channels)); |
|
| 3892 | + $this->o_image($this->numObj, 'new', array('label'=>$label, 'data'=>$data, 'iw'=>$imageWidth, 'ih'=>$imageHeight, 'channels'=>$channels)); |
|
| 3893 | 3893 | } |
| 3894 | 3894 | |
| 3895 | - $this->objects[$this->currentContents]['c'].="\nq ".sprintf('%.3F', $w)." 0 0 ".sprintf('%.3F', $h)." ".sprintf('%.3F', $x)." ".sprintf('%.3F', $y)." cm"; |
|
| 3896 | - $this->objects[$this->currentContents]['c'].=" /".$label.' Do'; |
|
| 3897 | - $this->objects[$this->currentContents]['c'].=" Q"; |
|
| 3895 | + $this->objects[$this->currentContents]['c'] .= "\nq ".sprintf('%.3F', $w)." 0 0 ".sprintf('%.3F', $h)." ".sprintf('%.3F', $x)." ".sprintf('%.3F', $y)." cm"; |
|
| 3896 | + $this->objects[$this->currentContents]['c'] .= " /".$label.' Do'; |
|
| 3897 | + $this->objects[$this->currentContents]['c'] .= " Q"; |
|
| 3898 | 3898 | } |
| 3899 | 3899 | |
| 3900 | 3900 | /** |
@@ -3914,7 +3914,7 @@ discard block |
||
| 3914 | 3914 | // 'FitBH' top |
| 3915 | 3915 | // 'FitBV' left |
| 3916 | 3916 | $this->numObj++; |
| 3917 | - $this->o_destination($this->numObj, 'new', array('page'=>$this->currentPage,'type'=>$style,'p1'=>$a,'p2'=>$b,'p3'=>$c)); |
|
| 3917 | + $this->o_destination($this->numObj, 'new', array('page'=>$this->currentPage, 'type'=>$style, 'p1'=>$a, 'p2'=>$b, 'p3'=>$c)); |
|
| 3918 | 3918 | $id = $this->catalogId; |
| 3919 | 3919 | $this->o_catalog($id, 'openHere', $this->numObj); |
| 3920 | 3920 | } |
@@ -3929,10 +3929,10 @@ discard block |
||
| 3929 | 3929 | // it has been linked to |
| 3930 | 3930 | // styles are the same as the 'openHere' function |
| 3931 | 3931 | $this->numObj++; |
| 3932 | - $this->o_destination($this->numObj, 'new', array('page'=>$this->currentPage,'type'=>$style,'p1'=>$a,'p2'=>$b,'p3'=>$c)); |
|
| 3932 | + $this->o_destination($this->numObj, 'new', array('page'=>$this->currentPage, 'type'=>$style, 'p1'=>$a, 'p2'=>$b, 'p3'=>$c)); |
|
| 3933 | 3933 | $id = $this->numObj; |
| 3934 | 3934 | // store the label->idf relationship, note that this means that labels can be used only once |
| 3935 | - $this->destinations["$label"]=$id; |
|
| 3935 | + $this->destinations["$label"] = $id; |
|
| 3936 | 3936 | } |
| 3937 | 3937 | |
| 3938 | 3938 | /** |
@@ -3967,7 +3967,7 @@ discard block |
||
| 3967 | 3967 | trigger_error($message, $error_type); |
| 3968 | 3968 | break; |
| 3969 | 3969 | case 'variable': |
| 3970 | - $this->messages.=$message."\n"; |
|
| 3970 | + $this->messages .= $message."\n"; |
|
| 3971 | 3971 | break; |
| 3972 | 3972 | } |
| 3973 | 3973 | } |
@@ -3995,7 +3995,7 @@ discard block |
||
| 3995 | 3995 | $this->checkpoint = $tmp; |
| 3996 | 3996 | unset($tmp); |
| 3997 | 3997 | } else { |
| 3998 | - $this->checkpoint=''; |
|
| 3998 | + $this->checkpoint = ''; |
|
| 3999 | 3999 | } |
| 4000 | 4000 | break; |
| 4001 | 4001 | case 'rewind': |
@@ -4005,7 +4005,7 @@ discard block |
||
| 4005 | 4005 | $tmp = $this->checkpoint; |
| 4006 | 4006 | foreach ($tmp as $k => $v) { |
| 4007 | 4007 | if ($k != 'checkpoint') { |
| 4008 | - $this->$k=$v; |
|
| 4008 | + $this->$k = $v; |
|
| 4009 | 4009 | } |
| 4010 | 4010 | } |
| 4011 | 4011 | unset($tmp); |
@@ -4016,7 +4016,7 @@ discard block |
||
| 4016 | 4016 | // can only abort if were inside a checkpoint |
| 4017 | 4017 | $tmp = $this->checkpoint; |
| 4018 | 4018 | foreach ($tmp as $k => $v) { |
| 4019 | - $this->$k=$v; |
|
| 4019 | + $this->$k = $v; |
|
| 4020 | 4020 | } |
| 4021 | 4021 | unset($tmp); |
| 4022 | 4022 | } |
@@ -39,6 +39,9 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | + /** |
|
| 43 | + * @param string $module_name |
|
| 44 | + */ |
|
| 42 | 45 | function setPrimaryModule($module_name) |
| 43 | 46 | { |
| 44 | 47 | if (!empty($this->primary_module_object) and is_object($this->primary_module_object)) { |
@@ -169,8 +172,8 @@ discard block |
||
| 169 | 172 | /** |
| 170 | 173 | * getModule() |
| 171 | 174 | * |
| 172 | - * @param string $module_name |
|
| 173 | 175 | * |
| 176 | + * @param string $name |
|
| 174 | 177 | * @return object |
| 175 | 178 | */ |
| 176 | 179 | function getModule($name) |
@@ -250,6 +253,9 @@ discard block |
||
| 250 | 253 | return false; |
| 251 | 254 | } |
| 252 | 255 | |
| 256 | + /** |
|
| 257 | + * @param string $name |
|
| 258 | + */ |
|
| 253 | 259 | private static function isValidModuleName($name) |
| 254 | 260 | { |
| 255 | 261 | return preg_match("/^[a-z0-9]+$/", $name); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function useModule($module_name, $ignore_user_access = false) |
| 79 | 79 | { |
| 80 | 80 | if (!self::isValidModuleName($module_name)) { |
| 81 | - throw new Exception($module_name . ' is not a valid module name'); |
|
| 81 | + throw new Exception($module_name.' is not a valid module name'); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | if (!empty($this->modules[$module_name]) and is_object($this->modules[$module_name])) { |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | if ($access !== true) { |
| 119 | - throw new Exception('You need access to a required module to see this page, maybe it is ' . $module_name); |
|
| 119 | + throw new Exception('You need access to a required module to see this page, maybe it is '.$module_name); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $main_class_name = "Main" . ucfirst($module_name); |
|
| 123 | - $main_class_path = PATH_INCLUDE_MODULE . $module_name . "/" . $main_class_name . ".php"; |
|
| 122 | + $main_class_name = "Main".ucfirst($module_name); |
|
| 123 | + $main_class_path = PATH_INCLUDE_MODULE.$module_name."/".$main_class_name.".php"; |
|
| 124 | 124 | |
| 125 | 125 | if (file_exists($main_class_path)) { |
| 126 | 126 | require_once($main_class_path); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | return $object; |
| 131 | 131 | } else { |
| 132 | 132 | // @TODO this should not fail as hard - but what should happen then? |
| 133 | - throw new Exception('ModuleHandler: ' . $main_class_path . ' does not exist'); |
|
| 133 | + throw new Exception('ModuleHandler: '.$main_class_path.' does not exist'); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | public function useShared($shared_name) |
| 145 | 145 | { |
| 146 | 146 | if (!self::isValidModuleName($shared_name)) { |
| 147 | - throw new Exception($shared_name. ' is not a valid shared module name'); |
|
| 147 | + throw new Exception($shared_name.' is not a valid shared module name'); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Tjekker om shared allerede er loaded |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | return $this->shared[$shared_name]; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - $main_shared_name = 'Shared' . ucfirst($shared_name); |
|
| 156 | - $main_shared_path = PATH_INCLUDE_SHARED . $shared_name . '/' . $main_shared_name . '.php'; |
|
| 155 | + $main_shared_name = 'Shared'.ucfirst($shared_name); |
|
| 156 | + $main_shared_path = PATH_INCLUDE_SHARED.$shared_name.'/'.$main_shared_name.'.php'; |
|
| 157 | 157 | |
| 158 | 158 | if (file_exists($main_shared_path)) { |
| 159 | 159 | require_once $main_shared_path; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $this->shared[$shared_name] = $object; |
| 163 | 163 | return $object; |
| 164 | 164 | } else { |
| 165 | - throw new Exception($shared_name . ' cannot be found on ' . $main_shared_path . ' with PATH_INCLUDE_SHARED: ' . PATH_INCLUDE_SHARED); |
|
| 165 | + throw new Exception($shared_name.' cannot be found on '.$main_shared_path.' with PATH_INCLUDE_SHARED: '.PATH_INCLUDE_SHARED); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | if (is_object($this->modules[$name])) { |
| 179 | 179 | return($this->modules[$name]); |
| 180 | 180 | } else { |
| 181 | - throw new Exception('getModule() module ' . $name . ' not loaded'); |
|
| 181 | + throw new Exception('getModule() module '.$name.' not loaded'); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -450,7 +450,7 @@ |
||
| 450 | 450 | * @param $date_from (date) yyyy-mm-dd Der s�ges jo kun i indev�rende �r |
| 451 | 451 | * @param $date_to (date) yyyy-mm-dd Der s�ges kun i indev�rende �r |
| 452 | 452 | * |
| 453 | - * @return (array) med debet, credit og total saldo |
|
| 453 | + * @return boolean med debet, credit og total saldo |
|
| 454 | 454 | * |
| 455 | 455 | * |
| 456 | 456 | * |
@@ -235,7 +235,7 @@ |
||
| 235 | 235 | $this->error->set('Ikke en tilladt type'); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $validator->isNumeric($var['use_key'], 'Det kan en konto ikke bruges til'); |
|
| 238 | + $validator->isNumeric($var['use_key'], 'Det kan en konto ikke bruges til'); |
|
| 239 | 239 | |
| 240 | 240 | if (!array_key_exists($var['use_key'], $this->use)) { |
| 241 | 241 | $this->error->set('Ikke en tilladt brug af kontoen'); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $this->db = new DB_Sql; |
| 95 | 95 | $this->mdb2 = MDB2::singleton(DB_DSN); |
| 96 | 96 | if (PEAR::isError($this->mdb2)) { |
| 97 | - throw new Exception($this->mdb2->getMessage() . $this->mdb2->getUserInfo()); |
|
| 97 | + throw new Exception($this->mdb2->getMessage().$this->mdb2->getUserInfo()); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $this->error = new Intraface_Error; |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | account.active |
| 151 | 151 | FROM |
| 152 | 152 | accounting_account account |
| 153 | - WHERE account.id = " . $this->id . " |
|
| 154 | - AND account.intranet_id = ".$this->year->kernel->intranet->get('id'). " |
|
| 153 | + WHERE account.id = " . $this->id." |
|
| 154 | + AND account.intranet_id = ".$this->year->kernel->intranet->get('id')." |
|
| 155 | 155 | AND year_id = ".$this->year->get('id')." |
| 156 | 156 | LIMIT 1"; |
| 157 | 157 | |
@@ -256,26 +256,26 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | if ($this->id > 0) { |
| 258 | 258 | $sql_type = "UPDATE accounting_account "; |
| 259 | - $sql_end = " WHERE id = " . $this->id; |
|
| 259 | + $sql_end = " WHERE id = ".$this->id; |
|
| 260 | 260 | } else { |
| 261 | 261 | $sql_type = "INSERT INTO accounting_account "; |
| 262 | 262 | $sql_end = ", date_created=NOW()"; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - $sql = $sql_type . "SET |
|
| 265 | + $sql = $sql_type."SET |
|
| 266 | 266 | number = '".(int)$var['number']."', |
| 267 | - intranet_id = " . $this->year->kernel->intranet->get('id') . ", |
|
| 268 | - user_id = " . $this->year->kernel->user->get("id") . ", |
|
| 267 | + intranet_id = " . $this->year->kernel->intranet->get('id').", |
|
| 268 | + user_id = " . $this->year->kernel->user->get("id").", |
|
| 269 | 269 | type_key='" . $var['type_key']."', |
| 270 | 270 | year_id = " . $this->year->get('id').", |
| 271 | 271 | use_key = '" . $var['use_key']."', |
| 272 | 272 | name = '" . $var['name']."', |
| 273 | 273 | comment = '" . $var['comment']."', |
| 274 | - vat_percent = '" . $var['vat_percent'] . "', |
|
| 275 | - sum_to_account_number = " . (int)$var['sum_to'] . ", |
|
| 276 | - sum_from_account_number = " . (int)$var['sum_from'] . ", |
|
| 274 | + vat_percent = '" . $var['vat_percent']."', |
|
| 275 | + sum_to_account_number = " . (int)$var['sum_to'].", |
|
| 276 | + sum_from_account_number = " . (int)$var['sum_from'].", |
|
| 277 | 277 | date_changed = NOW(), |
| 278 | - vat_key=" . (int)$var['vat_key'] . " " . $sql_end; |
|
| 278 | + vat_key=" . (int)$var['vat_key']." ".$sql_end; |
|
| 279 | 279 | |
| 280 | 280 | $this->db->query($sql); |
| 281 | 281 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | if (!empty($var['created_from_id']) and is_numeric($var['created_from_id'])) { |
| 287 | - $this->db->query("UPDATE accounting_account SET created_from_id = ".$var['created_from_id']." WHERE id = " . $this->id); |
|
| 287 | + $this->db->query("UPDATE accounting_account SET created_from_id = ".$var['created_from_id']." WHERE id = ".$this->id); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | $this->load(); |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | return false; |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - $this->db->query("UPDATE accounting_account SET active = 0, date_changed=NOW() WHERE intranet_id = " . $this->year->kernel->intranet->get('id') . " AND year_id = ".$this->year->get('id')." AND id = " . $this->id); |
|
| 352 | + $this->db->query("UPDATE accounting_account SET active = 0, date_changed=NOW() WHERE intranet_id = ".$this->year->kernel->intranet->get('id')." AND year_id = ".$this->year->get('id')." AND id = ".$this->id); |
|
| 353 | 353 | $this->value['active'] = 0; |
| 354 | 354 | return true; |
| 355 | 355 | } |
@@ -390,10 +390,10 @@ discard block |
||
| 390 | 390 | $sql = "SELECT |
| 391 | 391 | id |
| 392 | 392 | FROM accounting_account |
| 393 | - WHERE number = " . $account_number . " |
|
| 394 | - AND intranet_id = " . $this->year->kernel->intranet->get('id') . " |
|
| 395 | - AND year_id = " .$this->year->get('id'). " |
|
| 396 | - AND id <> " . $this->id . " AND active = 1"; |
|
| 393 | + WHERE number = " . $account_number." |
|
| 394 | + AND intranet_id = " . $this->year->kernel->intranet->get('id')." |
|
| 395 | + AND year_id = " .$this->year->get('id')." |
|
| 396 | + AND id <> " . $this->id." AND active = 1"; |
|
| 397 | 397 | $result = $this->mdb2->query($sql); |
| 398 | 398 | if (PEAR::isError($result)) { |
| 399 | 399 | throw new Exception('Error in query: '.$result->getUserInfo()); |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | { |
| 419 | 419 | $sql = "SELECT primosaldo_debet, primosaldo_credit |
| 420 | 420 | FROM accounting_account |
| 421 | - WHERE year_id = " . $this->year->get('id') . " |
|
| 422 | - AND id = ".$this->id . " |
|
| 421 | + WHERE year_id = " . $this->year->get('id')." |
|
| 422 | + AND id = ".$this->id." |
|
| 423 | 423 | AND active = 1 |
| 424 | 424 | AND intranet_id = ".$this->year->kernel->intranet->get('id'); |
| 425 | 425 | |
@@ -499,9 +499,9 @@ discard block |
||
| 499 | 499 | if ($this->get('type_key') == array_search('sum', $this->types)) { |
| 500 | 500 | $db2 = new DB_Sql; |
| 501 | 501 | $sql = "SELECT id FROM accounting_account |
| 502 | - WHERE number >= " . $this->get('sum_from') . " |
|
| 502 | + WHERE number >= " . $this->get('sum_from')." |
|
| 503 | 503 | AND type_key != ".array_search('sum', $this->types)." |
| 504 | - AND number <= " . $this->get('sum_to') . " |
|
| 504 | + AND number <= " . $this->get('sum_to')." |
|
| 505 | 505 | AND year_id = ".$this->year->get('id')." |
| 506 | 506 | AND intranet_id = " . $this->year->kernel->intranet->get('id'); |
| 507 | 507 | $db2->query($sql); |
@@ -567,9 +567,9 @@ discard block |
||
| 567 | 567 | $this->db->query("SELECT |
| 568 | 568 | id |
| 569 | 569 | FROM accounting_post post |
| 570 | - WHERE (post.account_id = ". $this->id . ") |
|
| 570 | + WHERE (post.account_id = ". $this->id.") |
|
| 571 | 571 | AND intranet_id = ".$this->year->kernel->intranet->get('id')." |
| 572 | - AND year_id = " . $this->year->get('id') . " |
|
| 572 | + AND year_id = " . $this->year->get('id')." |
|
| 573 | 573 | LIMIT 1"); |
| 574 | 574 | return $this->db->numRows(); |
| 575 | 575 | } |
@@ -590,9 +590,9 @@ discard block |
||
| 590 | 590 | debet, |
| 591 | 591 | credit |
| 592 | 592 | FROM accounting_post post |
| 593 | - WHERE (post.account_id = ". $this->get('id') . ") |
|
| 593 | + WHERE (post.account_id = ". $this->get('id').") |
|
| 594 | 594 | AND intranet_id = ".$this->year->kernel->intranet->get('id')." |
| 595 | - AND year_id = " . $this->year->get('id') . " |
|
| 595 | + AND year_id = " . $this->year->get('id')." |
|
| 596 | 596 | AND stated = 1 |
| 597 | 597 | ORDER BY date ASC, id ASC"); |
| 598 | 598 | $i = 1; |
@@ -626,9 +626,9 @@ discard block |
||
| 626 | 626 | public function calculateVat($amount, $vat_percent) |
| 627 | 627 | { |
| 628 | 628 | $amount = (float)$amount; |
| 629 | - $vat_percent = (float)$vat_percent / 100; |
|
| 629 | + $vat_percent = (float)$vat_percent/100; |
|
| 630 | 630 | |
| 631 | - return $amount * ($vat_percent / (1 + $vat_percent)); |
|
| 631 | + return $amount*($vat_percent/(1 + $vat_percent)); |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | public function getId() |
@@ -36,6 +36,9 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | + /** |
|
| 40 | + * @param integer $post_id |
|
| 41 | + */ |
|
| 39 | 42 | public function factory($year, $post_id) |
| 40 | 43 | { |
| 41 | 44 | return Intraface_modules_accounting_PostGateway::getFromYearAndPostId($year, $post_id); |
@@ -76,6 +79,13 @@ discard block |
||
| 76 | 79 | return 1; |
| 77 | 80 | } |
| 78 | 81 | |
| 82 | + /** |
|
| 83 | + * @param string $date |
|
| 84 | + * @param integer $account_id |
|
| 85 | + * @param string $text |
|
| 86 | + * @param double $debet |
|
| 87 | + * @param double $credit |
|
| 88 | + */ |
|
| 79 | 89 | private function validate($date, $account_id, $text, $debet, $credit) |
| 80 | 90 | { |
| 81 | 91 | $validator = new Intraface_Validator($this->error); |
@@ -99,9 +109,7 @@ discard block |
||
| 99 | 109 | /** |
| 100 | 110 | * States the posts |
| 101 | 111 | * |
| 102 | - * @param integer $year_id |
|
| 103 | 112 | * @param string $date |
| 104 | - * @param string $voucher_number |
|
| 105 | 113 | * @param string $text |
| 106 | 114 | * @param integer $account_id |
| 107 | 115 | * @param float $debet |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | private function load() |
| 45 | 45 | { |
| 46 | 46 | $db = new DB_Sql; |
| 47 | - $db->query("SELECT *, DATE_FORMAT(date, '%d-%m-%Y') AS date_dk FROM accounting_post WHERE id = " . $this->id . " AND intranet_id=" .$this->voucher->year->kernel->intranet->get('id')); |
|
| 47 | + $db->query("SELECT *, DATE_FORMAT(date, '%d-%m-%Y') AS date_dk FROM accounting_post WHERE id = ".$this->id." AND intranet_id=".$this->voucher->year->kernel->intranet->get('id')); |
|
| 48 | 48 | if (!$db->nextRecord()) { |
| 49 | 49 | return 0; |
| 50 | 50 | } |
@@ -125,14 +125,14 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | if ($this->id > 0) { |
| 127 | 127 | $sql_type = "UPDATE"; |
| 128 | - $sql_end = " WHERE id = " . $this->id; |
|
| 128 | + $sql_end = " WHERE id = ".$this->id; |
|
| 129 | 129 | } else { |
| 130 | 130 | $sql_type = "INSERT INTO"; |
| 131 | 131 | $sql_end = ""; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $db = new DB_Sql; |
| 135 | - $sql = $sql_type . " accounting_post |
|
| 135 | + $sql = $sql_type." accounting_post |
|
| 136 | 136 | SET |
| 137 | 137 | voucher_id = '".$this->voucher->get('id')."', |
| 138 | 138 | intranet_id = ".$this-> |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | account_id = '".(int)$account_id."', |
| 148 | 148 | text = '".(string)$text."', |
| 149 | 149 | debet = '".$debet."', |
| 150 | - credit = '".$credit."'" . $sql_end; |
|
| 150 | + credit = '".$credit."'".$sql_end; |
|
| 151 | 151 | $db->query($sql); |
| 152 | 152 | |
| 153 | 153 | $this->id = $db->insertedId(); |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $db = new DB_Sql; |
| 177 | - $db->query("UPDATE accounting_post SET stated = 1 WHERE id = " . $this->id . " AND intranet_id =" .$this->voucher->year->kernel->intranet->get('id')); |
|
| 177 | + $db->query("UPDATE accounting_post SET stated = 1 WHERE id = ".$this->id." AND intranet_id =".$this->voucher->year->kernel->intranet->get('id')); |
|
| 178 | 178 | |
| 179 | 179 | return true; |
| 180 | 180 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $db = new DB_Sql; |
| 189 | - $db->query("DELETE FROM accounting_post WHERE id = " . $this->id); |
|
| 189 | + $db->query("DELETE FROM accounting_post WHERE id = ".$this->id); |
|
| 190 | 190 | return true; |
| 191 | 191 | |
| 192 | 192 | } |
@@ -22,7 +22,6 @@ discard block |
||
| 22 | 22 | * Constructor |
| 23 | 23 | * |
| 24 | 24 | * @param object $year_object |
| 25 | - * @param integer $post_id (optional) |
|
| 26 | 25 | * |
| 27 | 26 | * @return void |
| 28 | 27 | */ |
@@ -45,7 +44,7 @@ discard block |
||
| 45 | 44 | * @param object $year |
| 46 | 45 | * @param string $voucher_number |
| 47 | 46 | * |
| 48 | - * @return void |
|
| 47 | + * @return Voucher |
|
| 49 | 48 | */ |
| 50 | 49 | function factory($year, $voucher_number) |
| 51 | 50 | { |
@@ -339,9 +338,7 @@ discard block |
||
| 339 | 338 | /** |
| 340 | 339 | * Prepares amounts for stating, e.g. whether the accounts needs vat calculations |
| 341 | 340 | * |
| 342 | - * @param integer $year_id |
|
| 343 | 341 | * @param string $date |
| 344 | - * @param string $voucher_number |
|
| 345 | 342 | * @param string $text |
| 346 | 343 | * @param integer $account_id |
| 347 | 344 | * @param float $debet |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | voucher.date, |
| 69 | 69 | voucher.reference |
| 70 | 70 | FROM accounting_voucher voucher |
| 71 | - WHERE voucher.id = " . $this->id. " AND intranet_id = ". $this->year->kernel->intranet->getId(); |
|
| 71 | + WHERE voucher.id = " . $this->id." AND intranet_id = ".$this->year->kernel->intranet->getId(); |
|
| 72 | 72 | |
| 73 | 73 | $db = new DB_Sql; |
| 74 | 74 | $db->query($sql); |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | $sql_end = ", date_created = NOW()"; |
| 144 | 144 | } else { |
| 145 | 145 | $sql_type = "UPDATE"; |
| 146 | - $sql_end = " WHERE id = " . (int)$this->id; |
|
| 146 | + $sql_end = " WHERE id = ".(int)$this->id; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $db = new DB_Sql; |
| 150 | - $sql = $sql_type . " accounting_voucher |
|
| 150 | + $sql = $sql_type." accounting_voucher |
|
| 151 | 151 | SET intranet_id = ".$this->year->kernel->intranet->get('id').", |
| 152 | 152 | year_id = ".$this->year->get('id').", |
| 153 | 153 | user_id = ".$this->year->kernel->user->get('id').", |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | number = '".$var['voucher_number']."', |
| 156 | 156 | date = '".$post_date->get()."', |
| 157 | 157 | reference = '".$var['reference']."', |
| 158 | - text = '".$var['text']."'" . $sql_end; |
|
| 158 | + text = '".$var['text']."'".$sql_end; |
|
| 159 | 159 | |
| 160 | 160 | $db->query($sql); |
| 161 | 161 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | $buy_all_abroad = $buy_abroad; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - $amount = $this->get('amount') * ($this->vatpercent / 100); |
|
| 312 | + $amount = $this->get('amount')*($this->vatpercent/100); |
|
| 313 | 313 | |
| 314 | 314 | // I det omfang du har fradragsret for momsen, kan du medregne det beregnede |
| 315 | 315 | // momsbeløb til konto for indgående moms. Det beregnede momsbeløb af EU-varekøb |
@@ -374,13 +374,13 @@ discard block |
||
| 374 | 374 | $debet = $debet - $vat_amount; |
| 375 | 375 | // bogfør momsen |
| 376 | 376 | $post = new Post($this); |
| 377 | - $post->save($date, $vat_account_id, $text . " - købsmoms", $vat_amount, 0, $skip_draft); |
|
| 377 | + $post->save($date, $vat_account_id, $text." - købsmoms", $vat_amount, 0, $skip_draft); |
|
| 378 | 378 | } else { |
| 379 | 379 | $vat_amount = $this->calculateVat($credit, $vat_percent); |
| 380 | 380 | $credit = $credit - $vat_amount; |
| 381 | 381 | // bogføre udgående moms |
| 382 | 382 | $post = new Post($this); |
| 383 | - $post->save($date, $vat_account_id, $text . " - tilbageført moms", 0, $vat_amount, $skip_draft); |
|
| 383 | + $post->save($date, $vat_account_id, $text." - tilbageført moms", 0, $vat_amount, $skip_draft); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | // bogføre selve posten |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | $credit = $credit - $vat_amount; |
| 397 | 397 | // bogføre udgående moms |
| 398 | 398 | $post = new Post($this); |
| 399 | - $post->save($date, $vat_account_id, $text . " - salgsmoms", 0, $vat_amount, $skip_draft); |
|
| 399 | + $post->save($date, $vat_account_id, $text." - salgsmoms", 0, $vat_amount, $skip_draft); |
|
| 400 | 400 | } else { |
| 401 | 401 | // tilbagefører momsen hvis det er et debet beløb |
| 402 | 402 | $vat_amount = $this->calculateVat($debet, $vat_percent); |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $post = new Post($this, $p['id']); |
| 456 | 456 | |
| 457 | 457 | if (!$post->setStated()) { |
| 458 | - $this->error->set('id#' .$p['id'] . ': Det lykkedes ikke at bogføre denne post.'); |
|
| 458 | + $this->error->set('id#'.$p['id'].': Det lykkedes ikke at bogføre denne post.'); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // tjekker om der har været nogle fejl i bogføringen |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | if ($this->get('saldo') <> 0) { |
| 482 | - $this->error->set('Du kan kun bogføre et bilag, hvis det stemmer. Saldoen på dette bilag er ' . $this->get('saldo') . '.'); |
|
| 482 | + $this->error->set('Du kan kun bogføre et bilag, hvis det stemmer. Saldoen på dette bilag er '.$this->get('saldo').'.'); |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | if ($this->error->isError()) { |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | if (!$post->setStated()) { |
| 498 | - $this->error->set('id#' .$p['id'] . ': Det lykkedes ikke at bogføre denne post.'); |
|
| 498 | + $this->error->set('id#'.$p['id'].': Det lykkedes ikke at bogføre denne post.'); |
|
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | // tjekker om der har været nogle fejl i bogføringen |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | function getPosts() |
| 510 | 510 | { |
| 511 | 511 | $db = new DB_Sql; |
| 512 | - $db->query("SELECT id, text, debet, credit, account_id, stated, date, DATE_FORMAT(date, '%d-%m-%Y') AS date_dk FROM accounting_post WHERE voucher_id = " . $this->id . " AND intranet_id=".$this->year->kernel->intranet->get('id')); |
|
| 512 | + $db->query("SELECT id, text, debet, credit, account_id, stated, date, DATE_FORMAT(date, '%d-%m-%Y') AS date_dk FROM accounting_post WHERE voucher_id = ".$this->id." AND intranet_id=".$this->year->kernel->intranet->get('id')); |
|
| 513 | 513 | $list = array(); |
| 514 | 514 | $i = 0; |
| 515 | 515 | $this->value['saldo'] = 0; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * Funktion til at sætte et regnskabsår, som brugeren redigerer i. |
| 45 | 45 | * |
| 46 | - * @return true |
|
| 46 | + * @return boolean |
|
| 47 | 47 | */ |
| 48 | 48 | function setYear() |
| 49 | 49 | { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param boolean $redirect Set to true if a redirect should occur if no year isset |
| 87 | 87 | * |
| 88 | - * @return boolean |
|
| 88 | + * @return null|boolean |
|
| 89 | 89 | */ |
| 90 | 90 | function checkYear($redirect = true) |
| 91 | 91 | { |
@@ -439,11 +439,17 @@ discard block |
||
| 439 | 439 | return $this->kernel->getSetting()->set('intranet', 'accounting.'.$setting, $value, $this->get('id')); |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | + /** |
|
| 443 | + * @param string $setting |
|
| 444 | + */ |
|
| 442 | 445 | function getSetting($setting) |
| 443 | 446 | { |
| 444 | 447 | return $this->kernel->getSetting()->get('intranet', 'accounting.' . $setting, $this->get('id')); |
| 445 | 448 | } |
| 446 | 449 | |
| 450 | + /** |
|
| 451 | + * @param string $type |
|
| 452 | + */ |
|
| 447 | 453 | function createAccounts($type, $last_year_id = 0) |
| 448 | 454 | { |
| 449 | 455 | if ($this->getId() == 0) { |
@@ -742,7 +748,8 @@ discard block |
||
| 742 | 748 | |
| 743 | 749 | /** |
| 744 | 750 | * @param $from->year (object) |
| 745 | - * @param $setting (string) |
|
| 751 | + * @param string $setting (string) |
|
| 752 | + * @param Year $from_year |
|
| 746 | 753 | */ |
| 747 | 754 | function transferAccountSetting($from_year, $setting) |
| 748 | 755 | { |
@@ -874,6 +881,9 @@ discard block |
||
| 874 | 881 | return true; |
| 875 | 882 | } |
| 876 | 883 | |
| 884 | + /** |
|
| 885 | + * @return string |
|
| 886 | + */ |
|
| 877 | 887 | public function getId() |
| 878 | 888 | { |
| 879 | 889 | return $this->get('id'); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | DATE_FORMAT(to_date, '%d-%m-%Y') AS to_date_dk, |
| 145 | 145 | last_year_id, from_date, to_date, locked, label, vat |
| 146 | 146 | FROM accounting_year |
| 147 | - WHERE id = '" . $this->id . "' |
|
| 147 | + WHERE id = '" . $this->id."' |
|
| 148 | 148 | AND intranet_id = ".$this->kernel->intranet->get('id')." |
| 149 | 149 | LIMIT 1"; |
| 150 | 150 | |
@@ -212,13 +212,13 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | if ($this->id > 0) { |
| 215 | - $sql="UPDATE accounting_year "; |
|
| 216 | - $sql_after=" WHERE id='".$this->id."' AND intranet_id = ".$this->kernel->intranet->get('id').""; |
|
| 215 | + $sql = "UPDATE accounting_year "; |
|
| 216 | + $sql_after = " WHERE id='".$this->id."' AND intranet_id = ".$this->kernel->intranet->get('id').""; |
|
| 217 | 217 | } else { |
| 218 | - $sql="INSERT INTO accounting_year "; |
|
| 218 | + $sql = "INSERT INTO accounting_year "; |
|
| 219 | 219 | $sql_after = ', date_created = NOW()'; |
| 220 | 220 | } |
| 221 | - $sql.=" SET |
|
| 221 | + $sql .= " SET |
|
| 222 | 222 | intranet_id='".$this->kernel->intranet->get('id')."', |
| 223 | 223 | user_id='".$this->kernel->user->get('id')."', |
| 224 | 224 | last_year_id='".$var['last_year_id']."', |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | { |
| 260 | 260 | $sql = "SELECT id FROM accounting_year |
| 261 | 261 | WHERE id = ".$this->id." |
| 262 | - AND intranet_id = ". $this->kernel->intranet->get('id') . " AND active = 1"; |
|
| 262 | + AND intranet_id = ". $this->kernel->intranet->get('id')." AND active = 1"; |
|
| 263 | 263 | |
| 264 | 264 | $db = new DB_Sql; |
| 265 | 265 | $db->query($sql); |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | public function isYearOpen() |
| 292 | 292 | { |
| 293 | 293 | $db = new Db_Sql; |
| 294 | - $db->query("SELECT locked FROM accounting_year WHERE id = " . $this->id . " AND intranet_id = ".$this->kernel->intranet->get('id')); |
|
| 294 | + $db->query("SELECT locked FROM accounting_year WHERE id = ".$this->id." AND intranet_id = ".$this->kernel->intranet->get('id')); |
|
| 295 | 295 | if ($db->nextRecord()) { |
| 296 | 296 | if ($db->f('locked') == 1) { |
| 297 | 297 | return false; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $date = safeToDb($date); |
| 317 | 317 | |
| 318 | 318 | $db = new Db_Sql; |
| 319 | - $db->query("SELECT from_date, to_date FROM accounting_year WHERE id= " . $this->id . " AND intranet_id = " . $this->kernel->intranet->get('id') . " LIMIT 1"); |
|
| 319 | + $db->query("SELECT from_date, to_date FROM accounting_year WHERE id= ".$this->id." AND intranet_id = ".$this->kernel->intranet->get('id')." LIMIT 1"); |
|
| 320 | 320 | if ($db->nextRecord()) { |
| 321 | 321 | if ($db->f('from_date') <= $date and $date <= $db->f('to_date')) { |
| 322 | 322 | return true; |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | if (!empty($balance_accounts) and count($balance_accounts) > 0) { |
| 405 | 405 | foreach ($balance_accounts as $account) { |
| 406 | - $sql_where .= "id = " . $account . " OR "; |
|
| 406 | + $sql_where .= "id = ".$account." OR "; |
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | // hvis der ikke er nogen balance_accounts skal den ikke v�lge nogen poster |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | $db = new DB_Sql; |
| 413 | 413 | $db->query("SELECT id FROM accounting_account |
| 414 | 414 | WHERE (".$sql_where.") |
| 415 | - AND intranet_id = " . $this->kernel->intranet->get('id') . " |
|
| 415 | + AND intranet_id = " . $this->kernel->intranet->get('id')." |
|
| 416 | 416 | AND year_id = " . $this->get('id')); |
| 417 | 417 | |
| 418 | 418 | $accounts = array(); // afstemningskonti |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | function getSetting($setting) |
| 443 | 443 | { |
| 444 | - return $this->kernel->getSetting()->get('intranet', 'accounting.' . $setting, $this->get('id')); |
|
| 444 | + return $this->kernel->getSetting()->get('intranet', 'accounting.'.$setting, $this->get('id')); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | function createAccounts($type, $last_year_id = 0) |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | // settings |
| 490 | 490 | if (!empty($input['setting'])) { |
| 491 | - $this->setSetting($input['setting'] . '_account_id', $id); |
|
| 491 | + $this->setSetting($input['setting'].'_account_id', $id); |
|
| 492 | 492 | } |
| 493 | 493 | if (!empty($input['balance_account']) and $input['balance_account'] == 1) { |
| 494 | 494 | $balance_accounts[] = $id; |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | |
| 570 | 570 | if (is_array($balance_accounts)) { |
| 571 | 571 | foreach ($balance_accounts as $key => $id) { |
| 572 | - $db->query("SELECT id FROM accounting_account WHERE year_id = ".$this->get('id')." AND intranet_id = ".$this->kernel->intranet->get('id')." AND created_from_id = " . (int)$id); |
|
| 572 | + $db->query("SELECT id FROM accounting_account WHERE year_id = ".$this->get('id')." AND intranet_id = ".$this->kernel->intranet->get('id')." AND created_from_id = ".(int)$id); |
|
| 573 | 573 | while ($db->nextRecord()) { |
| 574 | 574 | $new_balance_accounts[] = $db->f('id'); |
| 575 | 575 | } |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | |
| 585 | 585 | if (is_array($buy_eu_accounts)) { |
| 586 | 586 | foreach ($buy_eu_accounts as $key => $id) { |
| 587 | - $db->query("SELECT id FROM accounting_account WHERE year_id = ".$this->get('id')." AND intranet_id = ".$this->kernel->intranet->get('id')." AND created_from_id = " . (int)$id); |
|
| 587 | + $db->query("SELECT id FROM accounting_account WHERE year_id = ".$this->get('id')." AND intranet_id = ".$this->kernel->intranet->get('id')." AND created_from_id = ".(int)$id); |
|
| 588 | 588 | while ($db->nextRecord()) { |
| 589 | 589 | $new_buy_eu_accounts[] = $db->f('id'); |
| 590 | 590 | } |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | |
| 600 | 600 | if (is_array($buy_abroad_accounts)) { |
| 601 | 601 | foreach ($buy_abroad_accounts as $key => $id) { |
| 602 | - $db->query("SELECT id FROM accounting_account WHERE year_id = ".$this->get('id')." AND intranet_id = ".$this->kernel->intranet->get('id')." AND created_from_id = " . (int)$id); |
|
| 602 | + $db->query("SELECT id FROM accounting_account WHERE year_id = ".$this->get('id')." AND intranet_id = ".$this->kernel->intranet->get('id')." AND created_from_id = ".(int)$id); |
|
| 603 | 603 | while ($db->nextRecord()) { |
| 604 | 604 | $new_buy_abroad_accounts[] = $db->f('id'); |
| 605 | 605 | } |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | { |
| 749 | 749 | $account_id = $from_year->getSetting($setting); |
| 750 | 750 | $db = new DB_Sql; |
| 751 | - $db->query("SELECT id FROM accounting_account WHERE year_id = ".$this->get('id')." AND intranet_id = ".$this->kernel->intranet->get('id')." AND created_from_id = " . $account_id); |
|
| 751 | + $db->query("SELECT id FROM accounting_account WHERE year_id = ".$this->get('id')." AND intranet_id = ".$this->kernel->intranet->get('id')." AND created_from_id = ".$account_id); |
|
| 752 | 752 | if ($db->nextRecord()) { |
| 753 | 753 | $this->setSetting($setting, $db->f('id')); |
| 754 | 754 | } |
@@ -826,9 +826,9 @@ discard block |
||
| 826 | 826 | } |
| 827 | 827 | $db = new DB_Sql; |
| 828 | 828 | $sql = "SELECT id FROM debtor |
| 829 | - WHERE type= " . $type_key . " |
|
| 830 | - AND intranet_id = " .$this->kernel->intranet->get('id') . " |
|
| 831 | - AND (this_date BETWEEN '" . $date_start . "' AND '" .$date_end . "') |
|
| 829 | + WHERE type= " . $type_key." |
|
| 830 | + AND intranet_id = " .$this->kernel->intranet->get('id')." |
|
| 831 | + AND (this_date BETWEEN '" . $date_start."' AND '".$date_end."') |
|
| 832 | 832 | AND voucher_id = 0 |
| 833 | 833 | AND active = 1"; |
| 834 | 834 | $db->query($sql); |
@@ -842,8 +842,8 @@ discard block |
||
| 842 | 842 | { |
| 843 | 843 | $db = new DB_Sql; |
| 844 | 844 | $sql = "SELECT id FROM invoice_payment |
| 845 | - WHERE intranet_id = " .$this->kernel->intranet->get('id') . " |
|
| 846 | - AND (payment_date BETWEEN '" . $date_start . "' AND '" .$date_end . "') |
|
| 845 | + WHERE intranet_id = " .$this->kernel->intranet->get('id')." |
|
| 846 | + AND (payment_date BETWEEN '" . $date_start."' AND '".$date_end."') |
|
| 847 | 847 | AND voucher_id = 0"; |
| 848 | 848 | $db->query($sql); |
| 849 | 849 | if ($db->numRows() == 0) { |
@@ -856,8 +856,8 @@ discard block |
||
| 856 | 856 | { |
| 857 | 857 | $db = new DB_Sql; |
| 858 | 858 | $sql = "SELECT id FROM procurement |
| 859 | - WHERE intranet_id = " .$this->kernel->intranet->get('id') . " |
|
| 860 | - AND (invoice_date BETWEEN '" . $date_start . "' AND '" .$date_end . "') |
|
| 859 | + WHERE intranet_id = " .$this->kernel->intranet->get('id')." |
|
| 860 | + AND (invoice_date BETWEEN '" . $date_start."' AND '".$date_end."') |
|
| 861 | 861 | AND voucher_id = 0 |
| 862 | 862 | AND active = 1"; |
| 863 | 863 | $db->query($sql); |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | function lock() |
| 871 | 871 | { |
| 872 | 872 | $db = new DB_Sql; |
| 873 | - $db->query("UPDATE accounting_year SET locked = 1 WHERE id = " . $this->id); |
|
| 873 | + $db->query("UPDATE accounting_year SET locked = 1 WHERE id = ".$this->id); |
|
| 874 | 874 | return true; |
| 875 | 875 | } |
| 876 | 876 | |
@@ -8,6 +8,9 @@ |
||
| 8 | 8 | |
| 9 | 9 | class OnlinePaymentDefault extends OnlinePayment |
| 10 | 10 | {
|
| 11 | + /** |
|
| 12 | + * @param integer $id |
|
| 13 | + */ |
|
| 11 | 14 | function __construct($kernel, $id) {
|
| 12 | 15 | |
| 13 | 16 | parent::__construct($kernel, $id); |
@@ -468,6 +468,7 @@ |
||
| 468 | 468 | |
| 469 | 469 | /** |
| 470 | 470 | * Return path to ckeditor.js. |
| 471 | + * @return string |
|
| 471 | 472 | */ |
| 472 | 473 | private function ckeditorPath() |
| 473 | 474 | { |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * When %CKEditor is created with the editor() method, a HTML <textarea> element is created, |
| 74 | 74 | * it will be displayed to anyone with JavaScript disabled or with incompatible browser. |
| 75 | 75 | */ |
| 76 | - public $textareaAttributes = array( "rows" => 8, "cols" => 60 ); |
|
| 76 | + public $textareaAttributes = array("rows" => 8, "cols" => 60); |
|
| 77 | 77 | /** |
| 78 | 78 | * A string indicating the creation date of %CKEditor. |
| 79 | 79 | * Do not change it unless you want to force browsers to not use previously cached version of %CKEditor. |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | $attr = ""; |
| 135 | 135 | foreach ($this->textareaAttributes as $key => $val) { |
| 136 | - $attr.= " " . $key . '="' . str_replace('"', '"', $val) . '"'; |
|
| 136 | + $attr .= " ".$key.'="'.str_replace('"', '"', $val).'"'; |
|
| 137 | 137 | } |
| 138 | - $out = "<textarea name=\"" . $name . "\"" . $attr . ">" . htmlspecialchars($value) . "</textarea>\n"; |
|
| 138 | + $out = "<textarea name=\"".$name."\"".$attr.">".htmlspecialchars($value)."</textarea>\n"; |
|
| 139 | 139 | if (!$this->initialized) { |
| 140 | 140 | $out .= $this->init(); |
| 141 | 141 | } |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | $classDetection = ""; |
| 235 | 235 | $js .= "CKEDITOR.replaceAll( function(textarea, config) {\n"; |
| 236 | 236 | if (!empty($className)) { |
| 237 | - $js .= " var classRegex = new RegExp('(?:^| )' + '". $className ."' + '(?:$| )');\n"; |
|
| 237 | + $js .= " var classRegex = new RegExp('(?:^| )' + '".$className."' + '(?:$| )');\n"; |
|
| 238 | 238 | $js .= " if (!classRegex.test(textarea.className))\n"; |
| 239 | 239 | $js .= " return false;\n"; |
| 240 | 240 | } |
| 241 | - $js .= " CKEDITOR.tools.extend(config, ". $this->jsEncode($_config) .", true);"; |
|
| 241 | + $js .= " CKEDITOR.tools.extend(config, ".$this->jsEncode($_config).", true);"; |
|
| 242 | 242 | $js .= "} );"; |
| 243 | 243 | } |
| 244 | 244 | |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | } |
| 413 | 413 | // Return only new events |
| 414 | 414 | if (!in_array($code, $returnedEvents[$eventName])) { |
| 415 | - $out .= ($code ? "\n" : "") . "CKEDITOR.on('". $eventName ."', $code);"; |
|
| 415 | + $out .= ($code ? "\n" : "")."CKEDITOR.on('".$eventName."', $code);"; |
|
| 416 | 416 | $returnedEvents[$eventName][] = $code; |
| 417 | 417 | } |
| 418 | 418 | } |
@@ -443,19 +443,19 @@ discard block |
||
| 443 | 443 | $ckeditorPath = $this->ckeditorPath(); |
| 444 | 444 | |
| 445 | 445 | if (!empty($this->timestamp) && $this->timestamp != "%"."TIMESTAMP%") { |
| 446 | - $args = '?t=' . $this->timestamp; |
|
| 446 | + $args = '?t='.$this->timestamp; |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // Skip relative paths... |
| 450 | 450 | if (strpos($ckeditorPath, '..') !== 0) { |
| 451 | - $out .= $this->script("window.CKEDITOR_BASEPATH='". $ckeditorPath ."';"); |
|
| 451 | + $out .= $this->script("window.CKEDITOR_BASEPATH='".$ckeditorPath."';"); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - $out .= "<script type=\"text/javascript\" src=\"" . $ckeditorPath . 'ckeditor.js' . $args . "\"></script>\n"; |
|
| 454 | + $out .= "<script type=\"text/javascript\" src=\"".$ckeditorPath.'ckeditor.js'.$args."\"></script>\n"; |
|
| 455 | 455 | |
| 456 | 456 | $extraCode = ""; |
| 457 | 457 | if ($this->timestamp != self::timestamp) { |
| 458 | - $extraCode .= ($extraCode ? "\n" : "") . "CKEDITOR.timestamp = '". $this->timestamp ."';"; |
|
| 458 | + $extraCode .= ($extraCode ? "\n" : "")."CKEDITOR.timestamp = '".$this->timestamp."';"; |
|
| 459 | 459 | } |
| 460 | 460 | if ($extraCode) { |
| 461 | 461 | $out .= $this->script($extraCode); |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | /** |
| 487 | 487 | * realpath — Returns canonicalized absolute pathname |
| 488 | 488 | */ |
| 489 | - $realPath = realpath('./') ; |
|
| 489 | + $realPath = realpath('./'); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | |
| 547 | 547 | $val = str_replace($jsonReplaces[0], $jsonReplaces[1], $val); |
| 548 | 548 | |
| 549 | - return '"' . $val . '"'; |
|
| 549 | + return '"'.$val.'"'; |
|
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | 552 | $isList = true; |
@@ -561,12 +561,12 @@ discard block |
||
| 561 | 561 | foreach ($val as $v) { |
| 562 | 562 | $result[] = $this->jsEncode($v); |
| 563 | 563 | } |
| 564 | - return '[ ' . join(', ', $result) . ' ]'; |
|
| 564 | + return '[ '.join(', ', $result).' ]'; |
|
| 565 | 565 | } else { |
| 566 | 566 | foreach ($val as $k => $v) { |
| 567 | 567 | $result[] = $this->jsEncode($k).': '.$this->jsEncode($v); |
| 568 | 568 | } |
| 569 | - return '{ ' . join(', ', $result) . ' }'; |
|
| 569 | + return '{ '.join(', ', $result).' }'; |
|
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | } |
@@ -82,6 +82,9 @@ |
||
| 82 | 82 | return $this->context->getKernel(); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | + /** |
|
| 86 | + * @return integer |
|
| 87 | + */ |
|
| 85 | 88 | function getShopId() |
| 86 | 89 | { |
| 87 | 90 | if ($this->query('shop_id')) { |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | function getSiteId() |
| 21 | 21 | { |
| 22 | - return $this->context->name(); |
|
| 22 | + return $this->context->name(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | function renderHtml() |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | 'templates' => $templates |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | - $tpl = $this->template->create(dirname(__FILE__) . '/templates/templates'); |
|
| 40 | + $tpl = $this->template->create(dirname(__FILE__).'/templates/templates'); |
|
| 41 | 41 | return $tpl->render($this, $data); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | 'translation' => $this->getKernel()->getTranslation() |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | - $tpl = $this->template->create(dirname(__FILE__) . '/templates/template-edit'); |
|
| 57 | + $tpl = $this->template->create(dirname(__FILE__).'/templates/template-edit'); |
|
| 58 | 58 | return $tpl->render($this, $data); |
| 59 | 59 | } |
| 60 | 60 | |