@@ -46,17 +46,17 @@ |
||
46 | 46 | continue; |
47 | 47 | } |
48 | 48 | switch ($line[0]) { |
49 | - case ' ': |
|
50 | - $edits[] = &new Text_Diff_Op_copy(array(substr($line, 1))); |
|
51 | - break; |
|
49 | + case ' ': |
|
50 | + $edits[] = &new Text_Diff_Op_copy(array(substr($line, 1))); |
|
51 | + break; |
|
52 | 52 | |
53 | - case '+': |
|
54 | - $edits[] = &new Text_Diff_Op_add(array(substr($line, 1))); |
|
55 | - break; |
|
53 | + case '+': |
|
54 | + $edits[] = &new Text_Diff_Op_add(array(substr($line, 1))); |
|
55 | + break; |
|
56 | 56 | |
57 | - case '-': |
|
58 | - $edits[] = &new Text_Diff_Op_delete(array(substr($line, 1))); |
|
59 | - break; |
|
57 | + case '-': |
|
58 | + $edits[] = &new Text_Diff_Op_delete(array(substr($line, 1))); |
|
59 | + break; |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 |
@@ -93,29 +93,29 @@ |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | switch ($match[3]) { |
96 | - case 'd': |
|
97 | - // deleted lines |
|
98 | - array_push($edits, |
|
99 | - new Text_Diff_Op_delete( |
|
100 | - $this->_getLines($from_lines, $from_line_no, $match[2]))); |
|
101 | - $to_line_no++; |
|
102 | - break; |
|
103 | - |
|
104 | - case 'c': |
|
105 | - // changed lines |
|
106 | - array_push($edits, |
|
107 | - new Text_Diff_Op_change( |
|
108 | - $this->_getLines($from_lines, $from_line_no, $match[2]), |
|
109 | - $this->_getLines($to_lines, $to_line_no, $match[5]))); |
|
110 | - break; |
|
111 | - |
|
112 | - case 'a': |
|
113 | - // added lines |
|
114 | - array_push($edits, |
|
115 | - new Text_Diff_Op_add( |
|
116 | - $this->_getLines($to_lines, $to_line_no, $match[5]))); |
|
117 | - $from_line_no++; |
|
118 | - break; |
|
96 | + case 'd': |
|
97 | + // deleted lines |
|
98 | + array_push($edits, |
|
99 | + new Text_Diff_Op_delete( |
|
100 | + $this->_getLines($from_lines, $from_line_no, $match[2]))); |
|
101 | + $to_line_no++; |
|
102 | + break; |
|
103 | + |
|
104 | + case 'c': |
|
105 | + // changed lines |
|
106 | + array_push($edits, |
|
107 | + new Text_Diff_Op_change( |
|
108 | + $this->_getLines($from_lines, $from_line_no, $match[2]), |
|
109 | + $this->_getLines($to_lines, $to_line_no, $match[5]))); |
|
110 | + break; |
|
111 | + |
|
112 | + case 'a': |
|
113 | + // added lines |
|
114 | + array_push($edits, |
|
115 | + new Text_Diff_Op_add( |
|
116 | + $this->_getLines($to_lines, $to_line_no, $match[5]))); |
|
117 | + $from_line_no++; |
|
118 | + break; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 |
@@ -346,19 +346,19 @@ discard block |
||
346 | 346 | } |
347 | 347 | foreach ($option as $opt => $val) { |
348 | 348 | switch ($opt) { |
349 | - case 'color': |
|
350 | - $this->setColors($val); |
|
351 | - break; |
|
352 | - case 'text': |
|
353 | - if (is_array($val)) { |
|
354 | - $this->_text = implode('\n', $val); |
|
355 | - } else { |
|
356 | - $this->_text = $val; |
|
357 | - } |
|
358 | - break; |
|
359 | - default: |
|
360 | - $this->_options[$opt] = $val; |
|
361 | - break; |
|
349 | + case 'color': |
|
350 | + $this->setColors($val); |
|
351 | + break; |
|
352 | + case 'text': |
|
353 | + if (is_array($val)) { |
|
354 | + $this->_text = implode('\n', $val); |
|
355 | + } else { |
|
356 | + $this->_text = $val; |
|
357 | + } |
|
358 | + break; |
|
359 | + default: |
|
360 | + $this->_options[$opt] = $val; |
|
361 | + break; |
|
362 | 362 | } |
363 | 363 | if (isset($reInits[$opt])) { |
364 | 364 | $this->_init = false; |
@@ -511,45 +511,45 @@ discard block |
||
511 | 511 | $image_canvas = false; |
512 | 512 | switch (true) { |
513 | 513 | |
514 | - case (empty($this->_options['canvas'])): |
|
515 | - // Create new image from width && height of the clipping |
|
516 | - $this->_img = imagecreatetruecolor( |
|
517 | - $this->_options['width'], $this->_options['height'] |
|
518 | - ); |
|
519 | - if (!$this->_img) { |
|
520 | - throw new Image_Text_Exception('Could not create image canvas.'); |
|
521 | - } |
|
522 | - break; |
|
514 | + case (empty($this->_options['canvas'])): |
|
515 | + // Create new image from width && height of the clipping |
|
516 | + $this->_img = imagecreatetruecolor( |
|
517 | + $this->_options['width'], $this->_options['height'] |
|
518 | + ); |
|
519 | + if (!$this->_img) { |
|
520 | + throw new Image_Text_Exception('Could not create image canvas.'); |
|
521 | + } |
|
522 | + break; |
|
523 | 523 | |
524 | - case (is_resource($this->_options['canvas']) && |
|
525 | - get_resource_type($this->_options['canvas']) == 'gd'): |
|
526 | - // The canvas is an image resource |
|
527 | - $image_canvas = true; |
|
528 | - $this->_img = $this->_options['canvas']; |
|
529 | - break; |
|
524 | + case (is_resource($this->_options['canvas']) && |
|
525 | + get_resource_type($this->_options['canvas']) == 'gd'): |
|
526 | + // The canvas is an image resource |
|
527 | + $image_canvas = true; |
|
528 | + $this->_img = $this->_options['canvas']; |
|
529 | + break; |
|
530 | 530 | |
531 | - case (is_array($this->_options['canvas']) && |
|
532 | - isset($this->_options['canvas']['width']) && |
|
533 | - isset($this->_options['canvas']['height'])): |
|
531 | + case (is_array($this->_options['canvas']) && |
|
532 | + isset($this->_options['canvas']['width']) && |
|
533 | + isset($this->_options['canvas']['height'])): |
|
534 | 534 | |
535 | - // Canvas must be a width and height measure |
|
536 | - $this->_img = imagecreatetruecolor( |
|
537 | - $this->_options['canvas']['width'], |
|
538 | - $this->_options['canvas']['height'] |
|
539 | - ); |
|
540 | - break; |
|
535 | + // Canvas must be a width and height measure |
|
536 | + $this->_img = imagecreatetruecolor( |
|
537 | + $this->_options['canvas']['width'], |
|
538 | + $this->_options['canvas']['height'] |
|
539 | + ); |
|
540 | + break; |
|
541 | 541 | |
542 | - case (is_array($this->_options['canvas']) && |
|
543 | - isset($this->_options['canvas']['size']) && |
|
544 | - ($this->_options['canvas']['size'] = 'auto')): |
|
542 | + case (is_array($this->_options['canvas']) && |
|
543 | + isset($this->_options['canvas']['size']) && |
|
544 | + ($this->_options['canvas']['size'] = 'auto')): |
|
545 | 545 | |
546 | - case (is_string($this->_options['canvas']) && |
|
547 | - ($this->_options['canvas'] = 'auto')): |
|
548 | - $this->_mode = 'auto'; |
|
549 | - break; |
|
546 | + case (is_string($this->_options['canvas']) && |
|
547 | + ($this->_options['canvas'] = 'auto')): |
|
548 | + $this->_mode = 'auto'; |
|
549 | + break; |
|
550 | 550 | |
551 | - default: |
|
552 | - throw new Image_Text_Exception('Could not create image canvas.'); |
|
551 | + default: |
|
552 | + throw new Image_Text_Exception('Could not create image canvas.'); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | if ($this->_img) { |
@@ -889,19 +889,19 @@ discard block |
||
889 | 889 | $cosR = cos($radians); |
890 | 890 | |
891 | 891 | switch ($this->_options['valign']) { |
892 | - case self::IMAGE_TEXT_ALIGN_TOP: |
|
893 | - $valign_space = 0; |
|
894 | - break; |
|
895 | - case self::IMAGE_TEXT_ALIGN_MIDDLE: |
|
896 | - $valign_space = ($this->_options['height'] |
|
897 | - - $this->_realTextSize['height']) / 2; |
|
898 | - break; |
|
899 | - case self::IMAGE_TEXT_ALIGN_BOTTOM: |
|
900 | - $valign_space = $this->_options['height'] |
|
901 | - - $this->_realTextSize['height']; |
|
902 | - break; |
|
903 | - default: |
|
904 | - $valign_space = 0; |
|
892 | + case self::IMAGE_TEXT_ALIGN_TOP: |
|
893 | + $valign_space = 0; |
|
894 | + break; |
|
895 | + case self::IMAGE_TEXT_ALIGN_MIDDLE: |
|
896 | + $valign_space = ($this->_options['height'] |
|
897 | + - $this->_realTextSize['height']) / 2; |
|
898 | + break; |
|
899 | + case self::IMAGE_TEXT_ALIGN_BOTTOM: |
|
900 | + $valign_space = $this->_options['height'] |
|
901 | + - $this->_realTextSize['height']; |
|
902 | + break; |
|
903 | + default: |
|
904 | + $valign_space = 0; |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | $space = (1 + $line_spacing) * $size; |
@@ -932,18 +932,18 @@ discard block |
||
932 | 932 | // Calc the position using the block width, the current line width and |
933 | 933 | // obviously the angle. That gives us the offset to slide the line. |
934 | 934 | switch ($align) { |
935 | - case self::IMAGE_TEXT_ALIGN_LEFT: |
|
936 | - $hyp = 0; |
|
937 | - break; |
|
938 | - case self::IMAGE_TEXT_ALIGN_RIGHT: |
|
939 | - $hyp = $block_width - $line_width - $left_margin; |
|
940 | - break; |
|
941 | - case self::IMAGE_TEXT_ALIGN_CENTER: |
|
942 | - $hyp = ($block_width - $line_width) / 2 - $left_margin; |
|
943 | - break; |
|
944 | - default: |
|
945 | - $hyp = 0; |
|
946 | - break; |
|
935 | + case self::IMAGE_TEXT_ALIGN_LEFT: |
|
936 | + $hyp = 0; |
|
937 | + break; |
|
938 | + case self::IMAGE_TEXT_ALIGN_RIGHT: |
|
939 | + $hyp = $block_width - $line_width - $left_margin; |
|
940 | + break; |
|
941 | + case self::IMAGE_TEXT_ALIGN_CENTER: |
|
942 | + $hyp = ($block_width - $line_width) / 2 - $left_margin; |
|
943 | + break; |
|
944 | + default: |
|
945 | + $hyp = 0; |
|
946 | + break; |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | $posx = $new_posx + $cosR * $hyp; |
@@ -997,17 +997,17 @@ discard block |
||
997 | 997 | throw new Image_Text_Exception('Header already sent.'); |
998 | 998 | } |
999 | 999 | switch ($this->_options['image_type']) { |
1000 | - case IMAGETYPE_PNG: |
|
1001 | - $imgout = 'imagepng'; |
|
1002 | - break; |
|
1003 | - case IMAGETYPE_JPEG: |
|
1004 | - $imgout = 'imagejpeg'; |
|
1005 | - break; |
|
1006 | - case IMAGETYPE_BMP: |
|
1007 | - $imgout = 'imagebmp'; |
|
1008 | - break; |
|
1009 | - default: |
|
1010 | - throw new Image_Text_Exception('Unsupported image type.'); |
|
1000 | + case IMAGETYPE_PNG: |
|
1001 | + $imgout = 'imagepng'; |
|
1002 | + break; |
|
1003 | + case IMAGETYPE_JPEG: |
|
1004 | + $imgout = 'imagejpeg'; |
|
1005 | + break; |
|
1006 | + case IMAGETYPE_BMP: |
|
1007 | + $imgout = 'imagebmp'; |
|
1008 | + break; |
|
1009 | + default: |
|
1010 | + throw new Image_Text_Exception('Unsupported image type.'); |
|
1011 | 1011 | } |
1012 | 1012 | if ($save) { |
1013 | 1013 | $imgout($this->_img); |
@@ -1048,18 +1048,18 @@ discard block |
||
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | switch ($this->_options['image_type']) { |
1051 | - case IMAGETYPE_PNG: |
|
1052 | - $imgout = 'imagepng'; |
|
1053 | - break; |
|
1054 | - case IMAGETYPE_JPEG: |
|
1055 | - $imgout = 'imagejpeg'; |
|
1056 | - break; |
|
1057 | - case IMAGETYPE_BMP: |
|
1058 | - $imgout = 'imagebmp'; |
|
1059 | - break; |
|
1060 | - default: |
|
1061 | - throw new Image_Text_Exception('Unsupported image type.'); |
|
1062 | - break; |
|
1051 | + case IMAGETYPE_PNG: |
|
1052 | + $imgout = 'imagepng'; |
|
1053 | + break; |
|
1054 | + case IMAGETYPE_JPEG: |
|
1055 | + $imgout = 'imagejpeg'; |
|
1056 | + break; |
|
1057 | + case IMAGETYPE_BMP: |
|
1058 | + $imgout = 'imagebmp'; |
|
1059 | + break; |
|
1060 | + default: |
|
1061 | + throw new Image_Text_Exception('Unsupported image type.'); |
|
1062 | + break; |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | $res = $imgout($this->_img, $destFile); |
@@ -104,61 +104,61 @@ |
||
104 | 104 | |
105 | 105 | switch ($_SERVER["argv"][$i]) { |
106 | 106 | |
107 | - case "--help": |
|
108 | - case "-h": |
|
109 | - $opts["h"] = true; |
|
110 | - $i++; |
|
111 | - break; |
|
112 | - |
|
113 | - case "-l": |
|
114 | - $opts["l"] = true; |
|
115 | - $i++; |
|
116 | - break; |
|
117 | - |
|
118 | - case "-p": |
|
119 | - if ( !isset($_SERVER["argv"][$i+1]) ) |
|
120 | - die("-p switch requires a size parameter\n"); |
|
121 | - $opts["p"] = $_SERVER["argv"][$i+1]; |
|
122 | - $i += 2; |
|
123 | - break; |
|
124 | - |
|
125 | - case "-o": |
|
126 | - if ( !isset($_SERVER["argv"][$i+1]) ) |
|
127 | - die("-o switch requires an orientation parameter\n"); |
|
128 | - $opts["o"] = $_SERVER["argv"][$i+1]; |
|
129 | - $i += 2; |
|
130 | - break; |
|
131 | - |
|
132 | - case "-b": |
|
133 | - if ( !isset($_SERVER["argv"][$i+1]) ) |
|
134 | - die("-b switch requires a path parameter\n"); |
|
135 | - $opts["b"] = $_SERVER["argv"][$i+1]; |
|
136 | - $i += 2; |
|
137 | - break; |
|
138 | - |
|
139 | - case "-f": |
|
140 | - if ( !isset($_SERVER["argv"][$i+1]) ) |
|
141 | - die("-f switch requires a filename parameter\n"); |
|
142 | - $opts["f"] = $_SERVER["argv"][$i+1]; |
|
143 | - $i += 2; |
|
144 | - break; |
|
145 | - |
|
146 | - case "-v": |
|
147 | - $opts["v"] = true; |
|
148 | - $i++; |
|
149 | - break; |
|
150 | - |
|
151 | - case "-d": |
|
152 | - $opts["d"] = true; |
|
153 | - $i++; |
|
154 | - break; |
|
155 | - |
|
156 | - case "-t": |
|
157 | - if ( !isset($_SERVER['argv'][$i + 1]) ) |
|
158 | - die("-t switch requires a comma separated list of types\n"); |
|
159 | - $opts["t"] = $_SERVER['argv'][$i+1]; |
|
160 | - $i += 2; |
|
161 | - break; |
|
107 | + case "--help": |
|
108 | + case "-h": |
|
109 | + $opts["h"] = true; |
|
110 | + $i++; |
|
111 | + break; |
|
112 | + |
|
113 | + case "-l": |
|
114 | + $opts["l"] = true; |
|
115 | + $i++; |
|
116 | + break; |
|
117 | + |
|
118 | + case "-p": |
|
119 | + if ( !isset($_SERVER["argv"][$i+1]) ) |
|
120 | + die("-p switch requires a size parameter\n"); |
|
121 | + $opts["p"] = $_SERVER["argv"][$i+1]; |
|
122 | + $i += 2; |
|
123 | + break; |
|
124 | + |
|
125 | + case "-o": |
|
126 | + if ( !isset($_SERVER["argv"][$i+1]) ) |
|
127 | + die("-o switch requires an orientation parameter\n"); |
|
128 | + $opts["o"] = $_SERVER["argv"][$i+1]; |
|
129 | + $i += 2; |
|
130 | + break; |
|
131 | + |
|
132 | + case "-b": |
|
133 | + if ( !isset($_SERVER["argv"][$i+1]) ) |
|
134 | + die("-b switch requires a path parameter\n"); |
|
135 | + $opts["b"] = $_SERVER["argv"][$i+1]; |
|
136 | + $i += 2; |
|
137 | + break; |
|
138 | + |
|
139 | + case "-f": |
|
140 | + if ( !isset($_SERVER["argv"][$i+1]) ) |
|
141 | + die("-f switch requires a filename parameter\n"); |
|
142 | + $opts["f"] = $_SERVER["argv"][$i+1]; |
|
143 | + $i += 2; |
|
144 | + break; |
|
145 | + |
|
146 | + case "-v": |
|
147 | + $opts["v"] = true; |
|
148 | + $i++; |
|
149 | + break; |
|
150 | + |
|
151 | + case "-d": |
|
152 | + $opts["d"] = true; |
|
153 | + $i++; |
|
154 | + break; |
|
155 | + |
|
156 | + case "-t": |
|
157 | + if ( !isset($_SERVER['argv'][$i + 1]) ) |
|
158 | + die("-t switch requires a comma separated list of types\n"); |
|
159 | + $opts["t"] = $_SERVER['argv'][$i+1]; |
|
160 | + $i += 2; |
|
161 | + break; |
|
162 | 162 | |
163 | 163 | default: |
164 | 164 | $opts["filename"] = $_SERVER["argv"][$i]; |
@@ -489,21 +489,21 @@ discard block |
||
489 | 489 | function image($img_url, $img_type, $x, $y, $w, $h) { |
490 | 490 | |
491 | 491 | switch ($img_type) { |
492 | - case "png": |
|
493 | - $src = @imagecreatefrompng($img_url); |
|
494 | - break; |
|
492 | + case "png": |
|
493 | + $src = @imagecreatefrompng($img_url); |
|
494 | + break; |
|
495 | 495 | |
496 | - case "gif": |
|
497 | - $src = @imagecreatefromgif($img_url); |
|
498 | - break; |
|
496 | + case "gif": |
|
497 | + $src = @imagecreatefromgif($img_url); |
|
498 | + break; |
|
499 | 499 | |
500 | - case "jpg": |
|
501 | - case "jpeg": |
|
502 | - $src = @imagecreatefromjpeg($img_url); |
|
503 | - break; |
|
500 | + case "jpg": |
|
501 | + case "jpeg": |
|
502 | + $src = @imagecreatefromjpeg($img_url); |
|
503 | + break; |
|
504 | 504 | |
505 | - default: |
|
506 | - break; |
|
505 | + default: |
|
506 | + break; |
|
507 | 507 | |
508 | 508 | } |
509 | 509 | |
@@ -658,20 +658,20 @@ discard block |
||
658 | 658 | |
659 | 659 | switch ($type) { |
660 | 660 | |
661 | - case "jpg": |
|
662 | - case "jpeg": |
|
663 | - if ( !isset($options["quality"]) ) |
|
664 | - $options["quality"] = 75; |
|
661 | + case "jpg": |
|
662 | + case "jpeg": |
|
663 | + if ( !isset($options["quality"]) ) |
|
664 | + $options["quality"] = 75; |
|
665 | 665 | |
666 | - header("Content-type: image/jpeg"); |
|
667 | - imagejpeg($dst, '', $options["quality"]); |
|
668 | - break; |
|
669 | - |
|
670 | - case "png": |
|
671 | - default: |
|
672 | - header("Content-type: image/png"); |
|
673 | - imagepng($dst); |
|
674 | - break; |
|
666 | + header("Content-type: image/jpeg"); |
|
667 | + imagejpeg($dst, '', $options["quality"]); |
|
668 | + break; |
|
669 | + |
|
670 | + case "png": |
|
671 | + default: |
|
672 | + header("Content-type: image/png"); |
|
673 | + imagepng($dst); |
|
674 | + break; |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | if ( $this->_aa_factor != 1 ) |
@@ -706,18 +706,18 @@ discard block |
||
706 | 706 | |
707 | 707 | switch ($type) { |
708 | 708 | |
709 | - case "jpg": |
|
710 | - case "jpeg": |
|
711 | - if ( !isset($options["quality"]) ) |
|
712 | - $options["quality"] = 75; |
|
709 | + case "jpg": |
|
710 | + case "jpeg": |
|
711 | + if ( !isset($options["quality"]) ) |
|
712 | + $options["quality"] = 75; |
|
713 | 713 | |
714 | - imagejpeg($dst, '', $options["quality"]); |
|
715 | - break; |
|
714 | + imagejpeg($dst, '', $options["quality"]); |
|
715 | + break; |
|
716 | 716 | |
717 | - case "png": |
|
718 | - default: |
|
719 | - imagepng($dst); |
|
720 | - break; |
|
717 | + case "png": |
|
718 | + default: |
|
719 | + imagepng($dst); |
|
720 | + break; |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | $image = ob_get_contents(); |
@@ -345,29 +345,29 @@ discard block |
||
345 | 345 | static protected function _set_table_rules($node, $value) { |
346 | 346 | $new_style = "; border-collapse: collapse;"; |
347 | 347 | switch ($value) { |
348 | - case "none": |
|
349 | - $new_style .= "border-style: none;"; |
|
350 | - break; |
|
348 | + case "none": |
|
349 | + $new_style .= "border-style: none;"; |
|
350 | + break; |
|
351 | 351 | |
352 | - case "groups": |
|
353 | - // FIXME: unsupported |
|
354 | - return; |
|
352 | + case "groups": |
|
353 | + // FIXME: unsupported |
|
354 | + return; |
|
355 | 355 | |
356 | - case "rows": |
|
357 | - $new_style .= "border-style: solid none solid none; border-width: 1px; "; |
|
358 | - break; |
|
356 | + case "rows": |
|
357 | + $new_style .= "border-style: solid none solid none; border-width: 1px; "; |
|
358 | + break; |
|
359 | 359 | |
360 | - case "cols": |
|
361 | - $new_style .= "border-style: none solid none solid; border-width: 1px; "; |
|
362 | - break; |
|
360 | + case "cols": |
|
361 | + $new_style .= "border-style: none solid none solid; border-width: 1px; "; |
|
362 | + break; |
|
363 | 363 | |
364 | - case "all": |
|
365 | - $new_style .= "border-style: solid; border-width: 1px; "; |
|
366 | - break; |
|
364 | + case "all": |
|
365 | + $new_style .= "border-style: solid; border-width: 1px; "; |
|
366 | + break; |
|
367 | 367 | |
368 | - default: |
|
369 | - // Invalid value |
|
370 | - return null; |
|
368 | + default: |
|
369 | + // Invalid value |
|
370 | + return null; |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | $td_list = $node->getElementsByTagName("td"); |
@@ -390,20 +390,20 @@ discard block |
||
390 | 390 | $remainder = 100 - (double)rtrim($width, "% "); |
391 | 391 | |
392 | 392 | switch ($value) { |
393 | - case "left": |
|
394 | - $style .= "; margin-right: $remainder %;"; |
|
395 | - break; |
|
393 | + case "left": |
|
394 | + $style .= "; margin-right: $remainder %;"; |
|
395 | + break; |
|
396 | 396 | |
397 | - case "right": |
|
398 | - $style .= "; margin-left: $remainder %;"; |
|
399 | - break; |
|
397 | + case "right": |
|
398 | + $style .= "; margin-left: $remainder %;"; |
|
399 | + break; |
|
400 | 400 | |
401 | - case "center": |
|
402 | - $style .= "; margin-left: auto; margin-right: auto;"; |
|
403 | - break; |
|
401 | + case "center": |
|
402 | + $style .= "; margin-left: auto; margin-right: auto;"; |
|
403 | + break; |
|
404 | 404 | |
405 | - default: |
|
406 | - return null; |
|
405 | + default: |
|
406 | + return null; |
|
407 | 407 | } |
408 | 408 | return ltrim($style, "; "); |
409 | 409 |
@@ -384,117 +384,117 @@ discard block |
||
384 | 384 | |
385 | 385 | switch ($s) { |
386 | 386 | |
387 | - case " ": |
|
388 | - case ">": |
|
389 | - // All elements matching the next token that are direct children of |
|
390 | - // the current token |
|
391 | - $expr = $s === " " ? "descendant" : "child"; |
|
387 | + case " ": |
|
388 | + case ">": |
|
389 | + // All elements matching the next token that are direct children of |
|
390 | + // the current token |
|
391 | + $expr = $s === " " ? "descendant" : "child"; |
|
392 | 392 | |
393 | - if ( mb_substr($query, -1, 1) !== "/" ) |
|
394 | - $query .= "/"; |
|
393 | + if ( mb_substr($query, -1, 1) !== "/" ) |
|
394 | + $query .= "/"; |
|
395 | 395 | |
396 | - if ( !$tok ) |
|
397 | - $tok = "*"; |
|
396 | + if ( !$tok ) |
|
397 | + $tok = "*"; |
|
398 | 398 | |
399 | - $query .= "$expr::$tok"; |
|
400 | - $tok = ""; |
|
401 | - break; |
|
399 | + $query .= "$expr::$tok"; |
|
400 | + $tok = ""; |
|
401 | + break; |
|
402 | 402 | |
403 | - case ".": |
|
404 | - case "#": |
|
405 | - // All elements matching the current token with a class/id equal to |
|
406 | - // the _next_ token. |
|
403 | + case ".": |
|
404 | + case "#": |
|
405 | + // All elements matching the current token with a class/id equal to |
|
406 | + // the _next_ token. |
|
407 | 407 | |
408 | - $attr = $s === "." ? "class" : "id"; |
|
408 | + $attr = $s === "." ? "class" : "id"; |
|
409 | 409 | |
410 | - // empty class/id == * |
|
411 | - if ( mb_substr($query, -1, 1) === "/" ) |
|
412 | - $query .= "*"; |
|
410 | + // empty class/id == * |
|
411 | + if ( mb_substr($query, -1, 1) === "/" ) |
|
412 | + $query .= "*"; |
|
413 | 413 | |
414 | - // Match multiple classes: $tok contains the current selected |
|
415 | - // class. Search for class attributes with class="$tok", |
|
416 | - // class=".* $tok .*" and class=".* $tok" |
|
414 | + // Match multiple classes: $tok contains the current selected |
|
415 | + // class. Search for class attributes with class="$tok", |
|
416 | + // class=".* $tok .*" and class=".* $tok" |
|
417 | 417 | |
418 | - // This doesn't work because libxml only supports XPath 1.0... |
|
419 | - //$query .= "[matches(@$attr,\"^${tok}\$|^${tok}[ ]+|[ ]+${tok}\$|[ ]+${tok}[ ]+\")]"; |
|
418 | + // This doesn't work because libxml only supports XPath 1.0... |
|
419 | + //$query .= "[matches(@$attr,\"^${tok}\$|^${tok}[ ]+|[ ]+${tok}\$|[ ]+${tok}[ ]+\")]"; |
|
420 | 420 | |
421 | - // Query improvement by Michael Sheakoski <[email protected]>: |
|
422 | - $query .= "[contains(concat(' ', @$attr, ' '), concat(' ', '$tok', ' '))]"; |
|
423 | - $tok = ""; |
|
424 | - break; |
|
421 | + // Query improvement by Michael Sheakoski <[email protected]>: |
|
422 | + $query .= "[contains(concat(' ', @$attr, ' '), concat(' ', '$tok', ' '))]"; |
|
423 | + $tok = ""; |
|
424 | + break; |
|
425 | 425 | |
426 | - case "+": |
|
427 | - // All sibling elements that folow the current token |
|
428 | - if ( mb_substr($query, -1, 1) !== "/" ) |
|
429 | - $query .= "/"; |
|
426 | + case "+": |
|
427 | + // All sibling elements that folow the current token |
|
428 | + if ( mb_substr($query, -1, 1) !== "/" ) |
|
429 | + $query .= "/"; |
|
430 | 430 | |
431 | - $query .= "following-sibling::$tok"; |
|
432 | - $tok = ""; |
|
433 | - break; |
|
431 | + $query .= "following-sibling::$tok"; |
|
432 | + $tok = ""; |
|
433 | + break; |
|
434 | 434 | |
435 | - case ":": |
|
436 | - // Pseudo-classes |
|
437 | - switch ($tok) { |
|
435 | + case ":": |
|
436 | + // Pseudo-classes |
|
437 | + switch ($tok) { |
|
438 | 438 | |
439 | - case "first-child": |
|
440 | - $query .= "[1]"; |
|
441 | - $tok = ""; |
|
442 | - break; |
|
439 | + case "first-child": |
|
440 | + $query .= "[1]"; |
|
441 | + $tok = ""; |
|
442 | + break; |
|
443 | 443 | |
444 | - case "link": |
|
445 | - $query .= "[@href]"; |
|
446 | - $tok = ""; |
|
447 | - break; |
|
444 | + case "link": |
|
445 | + $query .= "[@href]"; |
|
446 | + $tok = ""; |
|
447 | + break; |
|
448 | 448 | |
449 | - case "first-line": |
|
450 | - break; |
|
449 | + case "first-line": |
|
450 | + break; |
|
451 | 451 | |
452 | - case "first-letter": |
|
453 | - break; |
|
452 | + case "first-letter": |
|
453 | + break; |
|
454 | 454 | |
455 | - case "before": |
|
456 | - break; |
|
455 | + case "before": |
|
456 | + break; |
|
457 | 457 | |
458 | - case "after": |
|
459 | - break; |
|
458 | + case "after": |
|
459 | + break; |
|
460 | 460 | |
461 | - } |
|
461 | + } |
|
462 | 462 | |
463 | 463 | break; |
464 | 464 | |
465 | - case "[": |
|
466 | - // Attribute selectors. All with an attribute matching the following token(s) |
|
467 | - $attr_delimiters = array("=", "]", "~", "|"); |
|
468 | - $tok_len = mb_strlen($tok); |
|
469 | - $j = 0; |
|
465 | + case "[": |
|
466 | + // Attribute selectors. All with an attribute matching the following token(s) |
|
467 | + $attr_delimiters = array("=", "]", "~", "|"); |
|
468 | + $tok_len = mb_strlen($tok); |
|
469 | + $j = 0; |
|
470 | 470 | |
471 | - $attr = ""; |
|
472 | - $op = ""; |
|
473 | - $value = ""; |
|
471 | + $attr = ""; |
|
472 | + $op = ""; |
|
473 | + $value = ""; |
|
474 | 474 | |
475 | - while ( $j < $tok_len ) { |
|
476 | - if ( in_array($tok[$j], $attr_delimiters) ) |
|
477 | - break; |
|
478 | - $attr .= $tok[$j++]; |
|
479 | - } |
|
475 | + while ( $j < $tok_len ) { |
|
476 | + if ( in_array($tok[$j], $attr_delimiters) ) |
|
477 | + break; |
|
478 | + $attr .= $tok[$j++]; |
|
479 | + } |
|
480 | 480 | |
481 | - switch ( $tok[$j] ) { |
|
481 | + switch ( $tok[$j] ) { |
|
482 | 482 | |
483 | - case "~": |
|
484 | - case "|": |
|
485 | - $op .= $tok[$j++]; |
|
483 | + case "~": |
|
484 | + case "|": |
|
485 | + $op .= $tok[$j++]; |
|
486 | 486 | |
487 | - if ( $tok[$j] !== "=" ) |
|
488 | - throw new DOMPDF_Exception("Invalid CSS selector syntax: invalid attribute selector: $selector"); |
|
487 | + if ( $tok[$j] !== "=" ) |
|
488 | + throw new DOMPDF_Exception("Invalid CSS selector syntax: invalid attribute selector: $selector"); |
|
489 | 489 | |
490 | - $op .= $tok[$j]; |
|
491 | - break; |
|
490 | + $op .= $tok[$j]; |
|
491 | + break; |
|
492 | 492 | |
493 | - case "=": |
|
494 | - $op = "="; |
|
495 | - break; |
|
493 | + case "=": |
|
494 | + $op = "="; |
|
495 | + break; |
|
496 | 496 | |
497 | - } |
|
497 | + } |
|
498 | 498 | |
499 | 499 | // Read the attribute value, if required |
500 | 500 | if ( $op != "" ) { |
@@ -511,35 +511,35 @@ discard block |
||
511 | 511 | |
512 | 512 | switch ( $op ) { |
513 | 513 | |
514 | - case "": |
|
515 | - $query .= "[@$attr]"; |
|
516 | - break; |
|
514 | + case "": |
|
515 | + $query .= "[@$attr]"; |
|
516 | + break; |
|
517 | 517 | |
518 | - case "=": |
|
519 | - $query .= "[@$attr$op\"$value\"]"; |
|
520 | - break; |
|
518 | + case "=": |
|
519 | + $query .= "[@$attr$op\"$value\"]"; |
|
520 | + break; |
|
521 | 521 | |
522 | - case "~=": |
|
523 | - // FIXME: this will break if $value contains quoted strings |
|
524 | - // (e.g. [type~="a b c" "d e f"]) |
|
525 | - $values = explode(" ", $value); |
|
526 | - $query .= "["; |
|
522 | + case "~=": |
|
523 | + // FIXME: this will break if $value contains quoted strings |
|
524 | + // (e.g. [type~="a b c" "d e f"]) |
|
525 | + $values = explode(" ", $value); |
|
526 | + $query .= "["; |
|
527 | 527 | |
528 | - foreach ( $values as $val ) |
|
529 | - $query .= "@$attr=\"$val\" or "; |
|
528 | + foreach ( $values as $val ) |
|
529 | + $query .= "@$attr=\"$val\" or "; |
|
530 | 530 | |
531 | - $query = rtrim($query, " or ") . "]"; |
|
532 | - break; |
|
531 | + $query = rtrim($query, " or ") . "]"; |
|
532 | + break; |
|
533 | 533 | |
534 | - case "|=": |
|
535 | - $values = explode("-", $value); |
|
536 | - $query .= "["; |
|
534 | + case "|=": |
|
535 | + $values = explode("-", $value); |
|
536 | + $query .= "["; |
|
537 | 537 | |
538 | - foreach ($values as $val) |
|
539 | - $query .= "starts-with(@$attr, \"$val\") or "; |
|
538 | + foreach ($values as $val) |
|
539 | + $query .= "starts-with(@$attr, \"$val\") or "; |
|
540 | 540 | |
541 | - $query = rtrim($query, " or ") . "]"; |
|
542 | - break; |
|
541 | + $query = rtrim($query, " or ") . "]"; |
|
542 | + break; |
|
543 | 543 | |
544 | 544 | } |
545 | 545 | |
@@ -788,52 +788,52 @@ discard block |
||
788 | 788 | // Handle @rules |
789 | 789 | switch ($match[2]) { |
790 | 790 | |
791 | - case "import": |
|
792 | - $this->_parse_import($match[3]); |
|
793 | - break; |
|
791 | + case "import": |
|
792 | + $this->_parse_import($match[3]); |
|
793 | + break; |
|
794 | 794 | |
795 | - case "media": |
|
796 | - $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES; |
|
797 | - if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
798 | - $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
|
799 | - } else { |
|
800 | - $acceptedmedia[] = self::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
|
801 | - } |
|
802 | - if ( in_array(mb_strtolower(trim($match[3])), $acceptedmedia ) ) { |
|
803 | - $this->_parse_sections($match[5]); |
|
804 | - } |
|
805 | - break; |
|
795 | + case "media": |
|
796 | + $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES; |
|
797 | + if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
798 | + $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
|
799 | + } else { |
|
800 | + $acceptedmedia[] = self::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
|
801 | + } |
|
802 | + if ( in_array(mb_strtolower(trim($match[3])), $acceptedmedia ) ) { |
|
803 | + $this->_parse_sections($match[5]); |
|
804 | + } |
|
805 | + break; |
|
806 | 806 | |
807 | - case "page": |
|
808 | - //This handles @page to be applied to page oriented media |
|
809 | - //Note: This has a reduced syntax: |
|
810 | - //@page { margin:1cm; color:blue; } |
|
811 | - //Not a sequence of styles like a full.css, but only the properties |
|
812 | - //of a single style, which is applied to the very first "root" frame before |
|
813 | - //processing other styles of the frame. |
|
814 | - //Working properties: |
|
815 | - // margin (for margin around edge of paper) |
|
816 | - // font-family (default font of pages) |
|
817 | - // color (default text color of pages) |
|
818 | - //Non working properties: |
|
819 | - // border |
|
820 | - // padding |
|
821 | - // background-color |
|
822 | - //Todo:Reason is unknown |
|
823 | - //Other properties (like further font or border attributes) not tested. |
|
824 | - //If a border or background color around each paper sheet is desired, |
|
825 | - //assign it to the <body> tag, possibly only for the css of the correct media type. |
|
826 | - |
|
827 | - // Store the style for later... |
|
828 | - if ( is_null($this->_page_style) ) |
|
829 | - $this->_page_style = $this->_parse_properties($match[5]); |
|
830 | - else |
|
831 | - $this->_page_style->merge($this->_parse_properties($match[5])); |
|
832 | - break; |
|
807 | + case "page": |
|
808 | + //This handles @page to be applied to page oriented media |
|
809 | + //Note: This has a reduced syntax: |
|
810 | + //@page { margin:1cm; color:blue; } |
|
811 | + //Not a sequence of styles like a full.css, but only the properties |
|
812 | + //of a single style, which is applied to the very first "root" frame before |
|
813 | + //processing other styles of the frame. |
|
814 | + //Working properties: |
|
815 | + // margin (for margin around edge of paper) |
|
816 | + // font-family (default font of pages) |
|
817 | + // color (default text color of pages) |
|
818 | + //Non working properties: |
|
819 | + // border |
|
820 | + // padding |
|
821 | + // background-color |
|
822 | + //Todo:Reason is unknown |
|
823 | + //Other properties (like further font or border attributes) not tested. |
|
824 | + //If a border or background color around each paper sheet is desired, |
|
825 | + //assign it to the <body> tag, possibly only for the css of the correct media type. |
|
826 | + |
|
827 | + // Store the style for later... |
|
828 | + if ( is_null($this->_page_style) ) |
|
829 | + $this->_page_style = $this->_parse_properties($match[5]); |
|
830 | + else |
|
831 | + $this->_page_style->merge($this->_parse_properties($match[5])); |
|
832 | + break; |
|
833 | 833 | |
834 | - default: |
|
835 | - // ignore everything else |
|
836 | - break; |
|
834 | + default: |
|
835 | + // ignore everything else |
|
836 | + break; |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | continue; |
@@ -94,21 +94,21 @@ |
||
94 | 94 | |
95 | 95 | switch ($valign) { |
96 | 96 | |
97 | - default: |
|
98 | - case "baseline": |
|
99 | - // FIXME: this isn't right |
|
97 | + default: |
|
98 | + case "baseline": |
|
99 | + // FIXME: this isn't right |
|
100 | 100 | |
101 | - case "top": |
|
102 | - // Don't need to do anything |
|
103 | - return; |
|
101 | + case "top": |
|
102 | + // Don't need to do anything |
|
103 | + return; |
|
104 | 104 | |
105 | - case "middle": |
|
106 | - $delta = ($new_height - $this->_content_height) / 2; |
|
107 | - break; |
|
105 | + case "middle": |
|
106 | + $delta = ($new_height - $this->_content_height) / 2; |
|
107 | + break; |
|
108 | 108 | |
109 | - case "bottom": |
|
110 | - $delta = $new_height - $this->_content_height; |
|
111 | - break; |
|
109 | + case "bottom": |
|
110 | + $delta = $new_height - $this->_content_height; |
|
111 | + break; |
|
112 | 112 | |
113 | 113 | } |
114 | 114 |
@@ -56,21 +56,21 @@ discard block |
||
56 | 56 | // Handle text transform |
57 | 57 | $transform = $this->_frame->get_style()->text_transform; |
58 | 58 | switch ( strtolower($transform) ) { |
59 | - case "capitalize": |
|
60 | - $this->_frame->set_text( ucwords($this->_frame->get_text()) ); |
|
61 | - break; |
|
59 | + case "capitalize": |
|
60 | + $this->_frame->set_text( ucwords($this->_frame->get_text()) ); |
|
61 | + break; |
|
62 | 62 | |
63 | - case "uppercase": |
|
64 | - $this->_frame->set_text( strtoupper($this->_frame->get_text()) ); |
|
65 | - break; |
|
63 | + case "uppercase": |
|
64 | + $this->_frame->set_text( strtoupper($this->_frame->get_text()) ); |
|
65 | + break; |
|
66 | 66 | |
67 | - case "lowercase": |
|
68 | - $this->_frame->set_text( strtolower($this->_frame->get_text()) ); |
|
69 | - break; |
|
67 | + case "lowercase": |
|
68 | + $this->_frame->set_text( strtolower($this->_frame->get_text()) ); |
|
69 | + break; |
|
70 | 70 | |
71 | - default: |
|
72 | - // Do nothing |
|
73 | - break; |
|
71 | + default: |
|
72 | + // Do nothing |
|
73 | + break; |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -192,20 +192,20 @@ discard block |
||
192 | 192 | |
193 | 193 | switch ($style->text_transform) { |
194 | 194 | |
195 | - default: |
|
196 | - break; |
|
195 | + default: |
|
196 | + break; |
|
197 | 197 | |
198 | - case "capitalize": |
|
199 | - $text = mb_convert_case($text, MB_CASE_TITLE, 'UTF-8'); |
|
200 | - break; |
|
198 | + case "capitalize": |
|
199 | + $text = mb_convert_case($text, MB_CASE_TITLE, 'UTF-8'); |
|
200 | + break; |
|
201 | 201 | |
202 | - case "uppercase": |
|
203 | - $text = mb_convert_case($text, MB_CASE_UPPER, 'UTF-8'); |
|
204 | - break; |
|
202 | + case "uppercase": |
|
203 | + $text = mb_convert_case($text, MB_CASE_UPPER, 'UTF-8'); |
|
204 | + break; |
|
205 | 205 | |
206 | - case "lowercase": |
|
207 | - $text = mb_convert_case($text, MB_CASE_LOWER, 'UTF-8'); |
|
208 | - break; |
|
206 | + case "lowercase": |
|
207 | + $text = mb_convert_case($text, MB_CASE_LOWER, 'UTF-8'); |
|
208 | + break; |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | |
@@ -214,51 +214,51 @@ discard block |
||
214 | 214 | |
215 | 215 | switch ($style->white_space) { |
216 | 216 | |
217 | - default: |
|
218 | - case "normal": |
|
219 | - $this->_frame->set_text( $text = $this->_collapse_white_space($text) ); |
|
220 | - if ( $text == "" ) |
|
221 | - break; |
|
217 | + default: |
|
218 | + case "normal": |
|
219 | + $this->_frame->set_text( $text = $this->_collapse_white_space($text) ); |
|
220 | + if ( $text == "" ) |
|
221 | + break; |
|
222 | 222 | |
223 | - $split = $this->_line_break($text); |
|
224 | - break; |
|
223 | + $split = $this->_line_break($text); |
|
224 | + break; |
|
225 | 225 | |
226 | - case "pre": |
|
227 | - $split = $this->_newline_break($text); |
|
228 | - $add_line = $split !== false; |
|
229 | - break; |
|
226 | + case "pre": |
|
227 | + $split = $this->_newline_break($text); |
|
228 | + $add_line = $split !== false; |
|
229 | + break; |
|
230 | 230 | |
231 | - case "nowrap": |
|
232 | - $this->_frame->set_text( $text = $this->_collapse_white_space($text) ); |
|
233 | - break; |
|
231 | + case "nowrap": |
|
232 | + $this->_frame->set_text( $text = $this->_collapse_white_space($text) ); |
|
233 | + break; |
|
234 | 234 | |
235 | - case "pre-wrap": |
|
236 | - $split = $this->_newline_break($text); |
|
235 | + case "pre-wrap": |
|
236 | + $split = $this->_newline_break($text); |
|
237 | 237 | |
238 | - if ( ($tmp = $this->_line_break($text)) !== false ) { |
|
239 | - $add_line = $split < $tmp; |
|
240 | - $split = min($tmp, $split); |
|
241 | - } else |
|
242 | - $add_line = true; |
|
238 | + if ( ($tmp = $this->_line_break($text)) !== false ) { |
|
239 | + $add_line = $split < $tmp; |
|
240 | + $split = min($tmp, $split); |
|
241 | + } else |
|
242 | + $add_line = true; |
|
243 | 243 | |
244 | - break; |
|
244 | + break; |
|
245 | 245 | |
246 | - case "pre-line": |
|
247 | - // Collapse white-space except for \n |
|
248 | - $this->_frame->set_text( $text = preg_replace( "/[ \t]+/u", " ", $text ) ); |
|
246 | + case "pre-line": |
|
247 | + // Collapse white-space except for \n |
|
248 | + $this->_frame->set_text( $text = preg_replace( "/[ \t]+/u", " ", $text ) ); |
|
249 | 249 | |
250 | - if ( $text == "" ) |
|
251 | - break; |
|
250 | + if ( $text == "" ) |
|
251 | + break; |
|
252 | 252 | |
253 | - $split = $this->_newline_break($text); |
|
253 | + $split = $this->_newline_break($text); |
|
254 | 254 | |
255 | - if ( ($tmp = $this->_line_break($text)) !== false ) { |
|
256 | - $add_line = $split < $tmp; |
|
257 | - $split = min($tmp, $split); |
|
258 | - } else |
|
259 | - $add_line = true; |
|
255 | + if ( ($tmp = $this->_line_break($text)) !== false ) { |
|
256 | + $add_line = $split < $tmp; |
|
257 | + $split = min($tmp, $split); |
|
258 | + } else |
|
259 | + $add_line = true; |
|
260 | 260 | |
261 | - break; |
|
261 | + break; |
|
262 | 262 | |
263 | 263 | } |
264 | 264 | |
@@ -351,59 +351,59 @@ discard block |
||
351 | 351 | |
352 | 352 | switch($style->white_space) { |
353 | 353 | |
354 | - default: |
|
355 | - case "normal": |
|
356 | - $str = preg_replace("/[\s\n]+/u"," ", $str); |
|
357 | - case "pre-wrap": |
|
358 | - case "pre-line": |
|
359 | - |
|
360 | - // Find the longest word (i.e. minimum length) |
|
361 | - |
|
362 | - // This technique (using arrays & an anonymous function) is actually |
|
363 | - // faster than doing a single-pass character by character scan. Heh, |
|
364 | - // yes I took the time to bench it ;) |
|
365 | - $words = array_flip(preg_split("/[\s-]+/u",$str, -1, PREG_SPLIT_DELIM_CAPTURE)); |
|
366 | - array_walk($words, create_function('&$val,$str', |
|
367 | - '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
368 | - arsort($words); |
|
369 | - $min = reset($words); |
|
370 | - break; |
|
371 | - |
|
372 | - case "pre": |
|
373 | - $lines = array_flip(preg_split("/\n/u", $str)); |
|
374 | - array_walk($lines, create_function('&$val,$str', |
|
375 | - '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
376 | - |
|
377 | - arsort($lines); |
|
378 | - $min = reset($lines); |
|
379 | - break; |
|
380 | - |
|
381 | - case "nowrap": |
|
382 | - $min = Font_Metrics::get_text_width($this->_collapse_white_space($str), $font, $size, $spacing); |
|
383 | - break; |
|
354 | + default: |
|
355 | + case "normal": |
|
356 | + $str = preg_replace("/[\s\n]+/u"," ", $str); |
|
357 | + case "pre-wrap": |
|
358 | + case "pre-line": |
|
359 | + |
|
360 | + // Find the longest word (i.e. minimum length) |
|
361 | + |
|
362 | + // This technique (using arrays & an anonymous function) is actually |
|
363 | + // faster than doing a single-pass character by character scan. Heh, |
|
364 | + // yes I took the time to bench it ;) |
|
365 | + $words = array_flip(preg_split("/[\s-]+/u",$str, -1, PREG_SPLIT_DELIM_CAPTURE)); |
|
366 | + array_walk($words, create_function('&$val,$str', |
|
367 | + '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
368 | + arsort($words); |
|
369 | + $min = reset($words); |
|
370 | + break; |
|
371 | + |
|
372 | + case "pre": |
|
373 | + $lines = array_flip(preg_split("/\n/u", $str)); |
|
374 | + array_walk($lines, create_function('&$val,$str', |
|
375 | + '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
376 | + |
|
377 | + arsort($lines); |
|
378 | + $min = reset($lines); |
|
379 | + break; |
|
380 | + |
|
381 | + case "nowrap": |
|
382 | + $min = Font_Metrics::get_text_width($this->_collapse_white_space($str), $font, $size, $spacing); |
|
383 | + break; |
|
384 | 384 | |
385 | 385 | } |
386 | 386 | |
387 | 387 | switch ($style->white_space) { |
388 | 388 | |
389 | - default: |
|
390 | - case "normal": |
|
391 | - case "nowrap": |
|
392 | - $str = preg_replace("/[\s\n]+/u"," ", $text); |
|
393 | - break; |
|
394 | - |
|
395 | - case "pre-line": |
|
396 | - $str = preg_replace( "/[ \t]+/u", " ", $text); |
|
397 | - |
|
398 | - case "pre-wrap": |
|
399 | - // Find the longest word (i.e. minimum length) |
|
400 | - $lines = array_flip(preg_split("/\n/", $text)); |
|
401 | - array_walk($lines, create_function('&$val,$str', |
|
402 | - '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
403 | - arsort($lines); |
|
404 | - reset($lines); |
|
405 | - $str = key($lines); |
|
406 | - break; |
|
389 | + default: |
|
390 | + case "normal": |
|
391 | + case "nowrap": |
|
392 | + $str = preg_replace("/[\s\n]+/u"," ", $text); |
|
393 | + break; |
|
394 | + |
|
395 | + case "pre-line": |
|
396 | + $str = preg_replace( "/[ \t]+/u", " ", $text); |
|
397 | + |
|
398 | + case "pre-wrap": |
|
399 | + // Find the longest word (i.e. minimum length) |
|
400 | + $lines = array_flip(preg_split("/\n/", $text)); |
|
401 | + array_walk($lines, create_function('&$val,$str', |
|
402 | + '$val = Font_Metrics::get_text_width($str, "'.$font.'", '.$size.', '.$spacing.');')); |
|
403 | + arsort($lines); |
|
404 | + reset($lines); |
|
405 | + $str = key($lines); |
|
406 | + break; |
|
407 | 407 | |
408 | 408 | } |
409 | 409 |