Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like TCPDF_STATIC often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use TCPDF_STATIC, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
52 | class TCPDF_STATIC { |
||
53 | |||
54 | /** |
||
55 | * Current TCPDF version. |
||
56 | * @private static |
||
57 | */ |
||
58 | private static $tcpdf_version = '6.0.078'; |
||
59 | |||
60 | /** |
||
61 | * String alias for total number of pages. |
||
62 | * @public static |
||
63 | */ |
||
64 | public static $alias_tot_pages = '{:ptp:}'; |
||
65 | |||
66 | /** |
||
67 | * String alias for page number. |
||
68 | * @public static |
||
69 | */ |
||
70 | public static $alias_num_page = '{:pnp:}'; |
||
71 | |||
72 | /** |
||
73 | * String alias for total number of pages in a single group. |
||
74 | * @public static |
||
75 | */ |
||
76 | public static $alias_group_tot_pages = '{:ptg:}'; |
||
77 | |||
78 | /** |
||
79 | * String alias for group page number. |
||
80 | * @public static |
||
81 | */ |
||
82 | public static $alias_group_num_page = '{:png:}'; |
||
83 | |||
84 | /** |
||
85 | * String alias for right shift compensation used to correctly align page numbers on the right. |
||
86 | * @public static |
||
87 | */ |
||
88 | public static $alias_right_shift = '{rsc:'; |
||
89 | |||
90 | /** |
||
91 | * Encryption padding string. |
||
92 | * @public static |
||
93 | */ |
||
94 | public static $enc_padding = "\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A"; |
||
95 | |||
96 | /** |
||
97 | * ByteRange placemark used during digital signature process. |
||
98 | * @since 4.6.028 (2009-08-25) |
||
99 | * @public static |
||
100 | */ |
||
101 | public static $byterange_string = '/ByteRange[0 ********** ********** **********]'; |
||
102 | |||
103 | /** |
||
104 | * Array page boxes names |
||
105 | * @public static |
||
106 | */ |
||
107 | public static $pageboxes = array('MediaBox', 'CropBox', 'BleedBox', 'TrimBox', 'ArtBox'); |
||
108 | |||
109 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
||
110 | |||
111 | /** |
||
112 | * Return the current TCPDF version. |
||
113 | * @return TCPDF version string |
||
114 | * @since 5.9.012 (2010-11-10) |
||
115 | * @public static |
||
116 | */ |
||
117 | public static function getTCPDFVersion() { |
||
120 | |||
121 | /** |
||
122 | * Return the current TCPDF producer. |
||
123 | * @return TCPDF producer string |
||
124 | * @since 6.0.000 (2013-03-16) |
||
125 | * @public static |
||
126 | */ |
||
127 | public static function getTCPDFProducer() { |
||
130 | |||
131 | /** |
||
132 | * Sets the current active configuration setting of magic_quotes_runtime (if the set_magic_quotes_runtime function exist) |
||
133 | * @param $mqr (boolean) FALSE for off, TRUE for on. |
||
134 | * @since 4.6.025 (2009-08-17) |
||
135 | * @public static |
||
136 | */ |
||
137 | View Code Duplication | public static function set_mqr($mqr) { |
|
146 | |||
147 | /** |
||
148 | * Gets the current active configuration setting of magic_quotes_runtime (if the get_magic_quotes_runtime function exist) |
||
149 | * @return Returns 0 if magic quotes runtime is off or get_magic_quotes_runtime doesn't exist, 1 otherwise. |
||
150 | * @since 4.6.025 (2009-08-17) |
||
151 | * @public static |
||
152 | */ |
||
153 | View Code Duplication | public static function get_mqr() { |
|
163 | |||
164 | /** |
||
165 | * Get page dimensions from format name. |
||
166 | * @param $format (mixed) The format name. It can be: <ul> |
||
167 | * <li><b>ISO 216 A Series + 2 SIS 014711 extensions</b></li> |
||
168 | * <li>A0 (841x1189 mm ; 33.11x46.81 in)</li> |
||
169 | * <li>A1 (594x841 mm ; 23.39x33.11 in)</li> |
||
170 | * <li>A2 (420x594 mm ; 16.54x23.39 in)</li> |
||
171 | * <li>A3 (297x420 mm ; 11.69x16.54 in)</li> |
||
172 | * <li>A4 (210x297 mm ; 8.27x11.69 in)</li> |
||
173 | * <li>A5 (148x210 mm ; 5.83x8.27 in)</li> |
||
174 | * <li>A6 (105x148 mm ; 4.13x5.83 in)</li> |
||
175 | * <li>A7 (74x105 mm ; 2.91x4.13 in)</li> |
||
176 | * <li>A8 (52x74 mm ; 2.05x2.91 in)</li> |
||
177 | * <li>A9 (37x52 mm ; 1.46x2.05 in)</li> |
||
178 | * <li>A10 (26x37 mm ; 1.02x1.46 in)</li> |
||
179 | * <li>A11 (18x26 mm ; 0.71x1.02 in)</li> |
||
180 | * <li>A12 (13x18 mm ; 0.51x0.71 in)</li> |
||
181 | * <li><b>ISO 216 B Series + 2 SIS 014711 extensions</b></li> |
||
182 | * <li>B0 (1000x1414 mm ; 39.37x55.67 in)</li> |
||
183 | * <li>B1 (707x1000 mm ; 27.83x39.37 in)</li> |
||
184 | * <li>B2 (500x707 mm ; 19.69x27.83 in)</li> |
||
185 | * <li>B3 (353x500 mm ; 13.90x19.69 in)</li> |
||
186 | * <li>B4 (250x353 mm ; 9.84x13.90 in)</li> |
||
187 | * <li>B5 (176x250 mm ; 6.93x9.84 in)</li> |
||
188 | * <li>B6 (125x176 mm ; 4.92x6.93 in)</li> |
||
189 | * <li>B7 (88x125 mm ; 3.46x4.92 in)</li> |
||
190 | * <li>B8 (62x88 mm ; 2.44x3.46 in)</li> |
||
191 | * <li>B9 (44x62 mm ; 1.73x2.44 in)</li> |
||
192 | * <li>B10 (31x44 mm ; 1.22x1.73 in)</li> |
||
193 | * <li>B11 (22x31 mm ; 0.87x1.22 in)</li> |
||
194 | * <li>B12 (15x22 mm ; 0.59x0.87 in)</li> |
||
195 | * <li><b>ISO 216 C Series + 2 SIS 014711 extensions + 2 EXTENSION</b></li> |
||
196 | * <li>C0 (917x1297 mm ; 36.10x51.06 in)</li> |
||
197 | * <li>C1 (648x917 mm ; 25.51x36.10 in)</li> |
||
198 | * <li>C2 (458x648 mm ; 18.03x25.51 in)</li> |
||
199 | * <li>C3 (324x458 mm ; 12.76x18.03 in)</li> |
||
200 | * <li>C4 (229x324 mm ; 9.02x12.76 in)</li> |
||
201 | * <li>C5 (162x229 mm ; 6.38x9.02 in)</li> |
||
202 | * <li>C6 (114x162 mm ; 4.49x6.38 in)</li> |
||
203 | * <li>C7 (81x114 mm ; 3.19x4.49 in)</li> |
||
204 | * <li>C8 (57x81 mm ; 2.24x3.19 in)</li> |
||
205 | * <li>C9 (40x57 mm ; 1.57x2.24 in)</li> |
||
206 | * <li>C10 (28x40 mm ; 1.10x1.57 in)</li> |
||
207 | * <li>C11 (20x28 mm ; 0.79x1.10 in)</li> |
||
208 | * <li>C12 (14x20 mm ; 0.55x0.79 in)</li> |
||
209 | * <li>C76 (81x162 mm ; 3.19x6.38 in)</li> |
||
210 | * <li>DL (110x220 mm ; 4.33x8.66 in)</li> |
||
211 | * <li><b>SIS 014711 E Series</b></li> |
||
212 | * <li>E0 (879x1241 mm ; 34.61x48.86 in)</li> |
||
213 | * <li>E1 (620x879 mm ; 24.41x34.61 in)</li> |
||
214 | * <li>E2 (440x620 mm ; 17.32x24.41 in)</li> |
||
215 | * <li>E3 (310x440 mm ; 12.20x17.32 in)</li> |
||
216 | * <li>E4 (220x310 mm ; 8.66x12.20 in)</li> |
||
217 | * <li>E5 (155x220 mm ; 6.10x8.66 in)</li> |
||
218 | * <li>E6 (110x155 mm ; 4.33x6.10 in)</li> |
||
219 | * <li>E7 (78x110 mm ; 3.07x4.33 in)</li> |
||
220 | * <li>E8 (55x78 mm ; 2.17x3.07 in)</li> |
||
221 | * <li>E9 (39x55 mm ; 1.54x2.17 in)</li> |
||
222 | * <li>E10 (27x39 mm ; 1.06x1.54 in)</li> |
||
223 | * <li>E11 (19x27 mm ; 0.75x1.06 in)</li> |
||
224 | * <li>E12 (13x19 mm ; 0.51x0.75 in)</li> |
||
225 | * <li><b>SIS 014711 G Series</b></li> |
||
226 | * <li>G0 (958x1354 mm ; 37.72x53.31 in)</li> |
||
227 | * <li>G1 (677x958 mm ; 26.65x37.72 in)</li> |
||
228 | * <li>G2 (479x677 mm ; 18.86x26.65 in)</li> |
||
229 | * <li>G3 (338x479 mm ; 13.31x18.86 in)</li> |
||
230 | * <li>G4 (239x338 mm ; 9.41x13.31 in)</li> |
||
231 | * <li>G5 (169x239 mm ; 6.65x9.41 in)</li> |
||
232 | * <li>G6 (119x169 mm ; 4.69x6.65 in)</li> |
||
233 | * <li>G7 (84x119 mm ; 3.31x4.69 in)</li> |
||
234 | * <li>G8 (59x84 mm ; 2.32x3.31 in)</li> |
||
235 | * <li>G9 (42x59 mm ; 1.65x2.32 in)</li> |
||
236 | * <li>G10 (29x42 mm ; 1.14x1.65 in)</li> |
||
237 | * <li>G11 (21x29 mm ; 0.83x1.14 in)</li> |
||
238 | * <li>G12 (14x21 mm ; 0.55x0.83 in)</li> |
||
239 | * <li><b>ISO Press</b></li> |
||
240 | * <li>RA0 (860x1220 mm ; 33.86x48.03 in)</li> |
||
241 | * <li>RA1 (610x860 mm ; 24.02x33.86 in)</li> |
||
242 | * <li>RA2 (430x610 mm ; 16.93x24.02 in)</li> |
||
243 | * <li>RA3 (305x430 mm ; 12.01x16.93 in)</li> |
||
244 | * <li>RA4 (215x305 mm ; 8.46x12.01 in)</li> |
||
245 | * <li>SRA0 (900x1280 mm ; 35.43x50.39 in)</li> |
||
246 | * <li>SRA1 (640x900 mm ; 25.20x35.43 in)</li> |
||
247 | * <li>SRA2 (450x640 mm ; 17.72x25.20 in)</li> |
||
248 | * <li>SRA3 (320x450 mm ; 12.60x17.72 in)</li> |
||
249 | * <li>SRA4 (225x320 mm ; 8.86x12.60 in)</li> |
||
250 | * <li><b>German DIN 476</b></li> |
||
251 | * <li>4A0 (1682x2378 mm ; 66.22x93.62 in)</li> |
||
252 | * <li>2A0 (1189x1682 mm ; 46.81x66.22 in)</li> |
||
253 | * <li><b>Variations on the ISO Standard</b></li> |
||
254 | * <li>A2_EXTRA (445x619 mm ; 17.52x24.37 in)</li> |
||
255 | * <li>A3+ (329x483 mm ; 12.95x19.02 in)</li> |
||
256 | * <li>A3_EXTRA (322x445 mm ; 12.68x17.52 in)</li> |
||
257 | * <li>A3_SUPER (305x508 mm ; 12.01x20.00 in)</li> |
||
258 | * <li>SUPER_A3 (305x487 mm ; 12.01x19.17 in)</li> |
||
259 | * <li>A4_EXTRA (235x322 mm ; 9.25x12.68 in)</li> |
||
260 | * <li>A4_SUPER (229x322 mm ; 9.02x12.68 in)</li> |
||
261 | * <li>SUPER_A4 (227x356 mm ; 8.94x14.02 in)</li> |
||
262 | * <li>A4_LONG (210x348 mm ; 8.27x13.70 in)</li> |
||
263 | * <li>F4 (210x330 mm ; 8.27x12.99 in)</li> |
||
264 | * <li>SO_B5_EXTRA (202x276 mm ; 7.95x10.87 in)</li> |
||
265 | * <li>A5_EXTRA (173x235 mm ; 6.81x9.25 in)</li> |
||
266 | * <li><b>ANSI Series</b></li> |
||
267 | * <li>ANSI_E (864x1118 mm ; 34.00x44.00 in)</li> |
||
268 | * <li>ANSI_D (559x864 mm ; 22.00x34.00 in)</li> |
||
269 | * <li>ANSI_C (432x559 mm ; 17.00x22.00 in)</li> |
||
270 | * <li>ANSI_B (279x432 mm ; 11.00x17.00 in)</li> |
||
271 | * <li>ANSI_A (216x279 mm ; 8.50x11.00 in)</li> |
||
272 | * <li><b>Traditional 'Loose' North American Paper Sizes</b></li> |
||
273 | * <li>LEDGER, USLEDGER (432x279 mm ; 17.00x11.00 in)</li> |
||
274 | * <li>TABLOID, USTABLOID, BIBLE, ORGANIZERK (279x432 mm ; 11.00x17.00 in)</li> |
||
275 | * <li>LETTER, USLETTER, ORGANIZERM (216x279 mm ; 8.50x11.00 in)</li> |
||
276 | * <li>LEGAL, USLEGAL (216x356 mm ; 8.50x14.00 in)</li> |
||
277 | * <li>GLETTER, GOVERNMENTLETTER (203x267 mm ; 8.00x10.50 in)</li> |
||
278 | * <li>JLEGAL, JUNIORLEGAL (203x127 mm ; 8.00x5.00 in)</li> |
||
279 | * <li><b>Other North American Paper Sizes</b></li> |
||
280 | * <li>QUADDEMY (889x1143 mm ; 35.00x45.00 in)</li> |
||
281 | * <li>SUPER_B (330x483 mm ; 13.00x19.00 in)</li> |
||
282 | * <li>QUARTO (229x279 mm ; 9.00x11.00 in)</li> |
||
283 | * <li>FOLIO, GOVERNMENTLEGAL (216x330 mm ; 8.50x13.00 in)</li> |
||
284 | * <li>EXECUTIVE, MONARCH (184x267 mm ; 7.25x10.50 in)</li> |
||
285 | * <li>MEMO, STATEMENT, ORGANIZERL (140x216 mm ; 5.50x8.50 in)</li> |
||
286 | * <li>FOOLSCAP (210x330 mm ; 8.27x13.00 in)</li> |
||
287 | * <li>COMPACT (108x171 mm ; 4.25x6.75 in)</li> |
||
288 | * <li>ORGANIZERJ (70x127 mm ; 2.75x5.00 in)</li> |
||
289 | * <li><b>Canadian standard CAN 2-9.60M</b></li> |
||
290 | * <li>P1 (560x860 mm ; 22.05x33.86 in)</li> |
||
291 | * <li>P2 (430x560 mm ; 16.93x22.05 in)</li> |
||
292 | * <li>P3 (280x430 mm ; 11.02x16.93 in)</li> |
||
293 | * <li>P4 (215x280 mm ; 8.46x11.02 in)</li> |
||
294 | * <li>P5 (140x215 mm ; 5.51x8.46 in)</li> |
||
295 | * <li>P6 (107x140 mm ; 4.21x5.51 in)</li> |
||
296 | * <li><b>North American Architectural Sizes</b></li> |
||
297 | * <li>ARCH_E (914x1219 mm ; 36.00x48.00 in)</li> |
||
298 | * <li>ARCH_E1 (762x1067 mm ; 30.00x42.00 in)</li> |
||
299 | * <li>ARCH_D (610x914 mm ; 24.00x36.00 in)</li> |
||
300 | * <li>ARCH_C, BROADSHEET (457x610 mm ; 18.00x24.00 in)</li> |
||
301 | * <li>ARCH_B (305x457 mm ; 12.00x18.00 in)</li> |
||
302 | * <li>ARCH_A (229x305 mm ; 9.00x12.00 in)</li> |
||
303 | * <li><b>Announcement Envelopes</b></li> |
||
304 | * <li>ANNENV_A2 (111x146 mm ; 4.37x5.75 in)</li> |
||
305 | * <li>ANNENV_A6 (121x165 mm ; 4.75x6.50 in)</li> |
||
306 | * <li>ANNENV_A7 (133x184 mm ; 5.25x7.25 in)</li> |
||
307 | * <li>ANNENV_A8 (140x206 mm ; 5.50x8.12 in)</li> |
||
308 | * <li>ANNENV_A10 (159x244 mm ; 6.25x9.62 in)</li> |
||
309 | * <li>ANNENV_SLIM (98x225 mm ; 3.87x8.87 in)</li> |
||
310 | * <li><b>Commercial Envelopes</b></li> |
||
311 | * <li>COMMENV_N6_1/4 (89x152 mm ; 3.50x6.00 in)</li> |
||
312 | * <li>COMMENV_N6_3/4 (92x165 mm ; 3.62x6.50 in)</li> |
||
313 | * <li>COMMENV_N8 (98x191 mm ; 3.87x7.50 in)</li> |
||
314 | * <li>COMMENV_N9 (98x225 mm ; 3.87x8.87 in)</li> |
||
315 | * <li>COMMENV_N10 (105x241 mm ; 4.12x9.50 in)</li> |
||
316 | * <li>COMMENV_N11 (114x263 mm ; 4.50x10.37 in)</li> |
||
317 | * <li>COMMENV_N12 (121x279 mm ; 4.75x11.00 in)</li> |
||
318 | * <li>COMMENV_N14 (127x292 mm ; 5.00x11.50 in)</li> |
||
319 | * <li><b>Catalogue Envelopes</b></li> |
||
320 | * <li>CATENV_N1 (152x229 mm ; 6.00x9.00 in)</li> |
||
321 | * <li>CATENV_N1_3/4 (165x241 mm ; 6.50x9.50 in)</li> |
||
322 | * <li>CATENV_N2 (165x254 mm ; 6.50x10.00 in)</li> |
||
323 | * <li>CATENV_N3 (178x254 mm ; 7.00x10.00 in)</li> |
||
324 | * <li>CATENV_N6 (191x267 mm ; 7.50x10.50 in)</li> |
||
325 | * <li>CATENV_N7 (203x279 mm ; 8.00x11.00 in)</li> |
||
326 | * <li>CATENV_N8 (210x286 mm ; 8.25x11.25 in)</li> |
||
327 | * <li>CATENV_N9_1/2 (216x267 mm ; 8.50x10.50 in)</li> |
||
328 | * <li>CATENV_N9_3/4 (222x286 mm ; 8.75x11.25 in)</li> |
||
329 | * <li>CATENV_N10_1/2 (229x305 mm ; 9.00x12.00 in)</li> |
||
330 | * <li>CATENV_N12_1/2 (241x318 mm ; 9.50x12.50 in)</li> |
||
331 | * <li>CATENV_N13_1/2 (254x330 mm ; 10.00x13.00 in)</li> |
||
332 | * <li>CATENV_N14_1/4 (286x311 mm ; 11.25x12.25 in)</li> |
||
333 | * <li>CATENV_N14_1/2 (292x368 mm ; 11.50x14.50 in)</li> |
||
334 | * <li><b>Japanese (JIS P 0138-61) Standard B-Series</b></li> |
||
335 | * <li>JIS_B0 (1030x1456 mm ; 40.55x57.32 in)</li> |
||
336 | * <li>JIS_B1 (728x1030 mm ; 28.66x40.55 in)</li> |
||
337 | * <li>JIS_B2 (515x728 mm ; 20.28x28.66 in)</li> |
||
338 | * <li>JIS_B3 (364x515 mm ; 14.33x20.28 in)</li> |
||
339 | * <li>JIS_B4 (257x364 mm ; 10.12x14.33 in)</li> |
||
340 | * <li>JIS_B5 (182x257 mm ; 7.17x10.12 in)</li> |
||
341 | * <li>JIS_B6 (128x182 mm ; 5.04x7.17 in)</li> |
||
342 | * <li>JIS_B7 (91x128 mm ; 3.58x5.04 in)</li> |
||
343 | * <li>JIS_B8 (64x91 mm ; 2.52x3.58 in)</li> |
||
344 | * <li>JIS_B9 (45x64 mm ; 1.77x2.52 in)</li> |
||
345 | * <li>JIS_B10 (32x45 mm ; 1.26x1.77 in)</li> |
||
346 | * <li>JIS_B11 (22x32 mm ; 0.87x1.26 in)</li> |
||
347 | * <li>JIS_B12 (16x22 mm ; 0.63x0.87 in)</li> |
||
348 | * <li><b>PA Series</b></li> |
||
349 | * <li>PA0 (840x1120 mm ; 33.07x44.09 in)</li> |
||
350 | * <li>PA1 (560x840 mm ; 22.05x33.07 in)</li> |
||
351 | * <li>PA2 (420x560 mm ; 16.54x22.05 in)</li> |
||
352 | * <li>PA3 (280x420 mm ; 11.02x16.54 in)</li> |
||
353 | * <li>PA4 (210x280 mm ; 8.27x11.02 in)</li> |
||
354 | * <li>PA5 (140x210 mm ; 5.51x8.27 in)</li> |
||
355 | * <li>PA6 (105x140 mm ; 4.13x5.51 in)</li> |
||
356 | * <li>PA7 (70x105 mm ; 2.76x4.13 in)</li> |
||
357 | * <li>PA8 (52x70 mm ; 2.05x2.76 in)</li> |
||
358 | * <li>PA9 (35x52 mm ; 1.38x2.05 in)</li> |
||
359 | * <li>PA10 (26x35 mm ; 1.02x1.38 in)</li> |
||
360 | * <li><b>Standard Photographic Print Sizes</b></li> |
||
361 | * <li>PASSPORT_PHOTO (35x45 mm ; 1.38x1.77 in)</li> |
||
362 | * <li>E (82x120 mm ; 3.25x4.72 in)</li> |
||
363 | * <li>3R, L (89x127 mm ; 3.50x5.00 in)</li> |
||
364 | * <li>4R, KG (102x152 mm ; 4.02x5.98 in)</li> |
||
365 | * <li>4D (120x152 mm ; 4.72x5.98 in)</li> |
||
366 | * <li>5R, 2L (127x178 mm ; 5.00x7.01 in)</li> |
||
367 | * <li>6R, 8P (152x203 mm ; 5.98x7.99 in)</li> |
||
368 | * <li>8R, 6P (203x254 mm ; 7.99x10.00 in)</li> |
||
369 | * <li>S8R, 6PW (203x305 mm ; 7.99x12.01 in)</li> |
||
370 | * <li>10R, 4P (254x305 mm ; 10.00x12.01 in)</li> |
||
371 | * <li>S10R, 4PW (254x381 mm ; 10.00x15.00 in)</li> |
||
372 | * <li>11R (279x356 mm ; 10.98x14.02 in)</li> |
||
373 | * <li>S11R (279x432 mm ; 10.98x17.01 in)</li> |
||
374 | * <li>12R (305x381 mm ; 12.01x15.00 in)</li> |
||
375 | * <li>S12R (305x456 mm ; 12.01x17.95 in)</li> |
||
376 | * <li><b>Common Newspaper Sizes</b></li> |
||
377 | * <li>NEWSPAPER_BROADSHEET (750x600 mm ; 29.53x23.62 in)</li> |
||
378 | * <li>NEWSPAPER_BERLINER (470x315 mm ; 18.50x12.40 in)</li> |
||
379 | * <li>NEWSPAPER_COMPACT, NEWSPAPER_TABLOID (430x280 mm ; 16.93x11.02 in)</li> |
||
380 | * <li><b>Business Cards</b></li> |
||
381 | * <li>CREDIT_CARD, BUSINESS_CARD, BUSINESS_CARD_ISO7810 (54x86 mm ; 2.13x3.37 in)</li> |
||
382 | * <li>BUSINESS_CARD_ISO216 (52x74 mm ; 2.05x2.91 in)</li> |
||
383 | * <li>BUSINESS_CARD_IT, BUSINESS_CARD_UK, BUSINESS_CARD_FR, BUSINESS_CARD_DE, BUSINESS_CARD_ES (55x85 mm ; 2.17x3.35 in)</li> |
||
384 | * <li>BUSINESS_CARD_US, BUSINESS_CARD_CA (51x89 mm ; 2.01x3.50 in)</li> |
||
385 | * <li>BUSINESS_CARD_JP (55x91 mm ; 2.17x3.58 in)</li> |
||
386 | * <li>BUSINESS_CARD_HK (54x90 mm ; 2.13x3.54 in)</li> |
||
387 | * <li>BUSINESS_CARD_AU, BUSINESS_CARD_DK, BUSINESS_CARD_SE (55x90 mm ; 2.17x3.54 in)</li> |
||
388 | * <li>BUSINESS_CARD_RU, BUSINESS_CARD_CZ, BUSINESS_CARD_FI, BUSINESS_CARD_HU, BUSINESS_CARD_IL (50x90 mm ; 1.97x3.54 in)</li> |
||
389 | * <li><b>Billboards</b></li> |
||
390 | * <li>4SHEET (1016x1524 mm ; 40.00x60.00 in)</li> |
||
391 | * <li>6SHEET (1200x1800 mm ; 47.24x70.87 in)</li> |
||
392 | * <li>12SHEET (3048x1524 mm ; 120.00x60.00 in)</li> |
||
393 | * <li>16SHEET (2032x3048 mm ; 80.00x120.00 in)</li> |
||
394 | * <li>32SHEET (4064x3048 mm ; 160.00x120.00 in)</li> |
||
395 | * <li>48SHEET (6096x3048 mm ; 240.00x120.00 in)</li> |
||
396 | * <li>64SHEET (8128x3048 mm ; 320.00x120.00 in)</li> |
||
397 | * <li>96SHEET (12192x3048 mm ; 480.00x120.00 in)</li> |
||
398 | * <li><b>Old Imperial English (some are still used in USA)</b></li> |
||
399 | * <li>EN_EMPEROR (1219x1829 mm ; 48.00x72.00 in)</li> |
||
400 | * <li>EN_ANTIQUARIAN (787x1346 mm ; 31.00x53.00 in)</li> |
||
401 | * <li>EN_GRAND_EAGLE (730x1067 mm ; 28.75x42.00 in)</li> |
||
402 | * <li>EN_DOUBLE_ELEPHANT (679x1016 mm ; 26.75x40.00 in)</li> |
||
403 | * <li>EN_ATLAS (660x864 mm ; 26.00x34.00 in)</li> |
||
404 | * <li>EN_COLOMBIER (597x876 mm ; 23.50x34.50 in)</li> |
||
405 | * <li>EN_ELEPHANT (584x711 mm ; 23.00x28.00 in)</li> |
||
406 | * <li>EN_DOUBLE_DEMY (572x902 mm ; 22.50x35.50 in)</li> |
||
407 | * <li>EN_IMPERIAL (559x762 mm ; 22.00x30.00 in)</li> |
||
408 | * <li>EN_PRINCESS (546x711 mm ; 21.50x28.00 in)</li> |
||
409 | * <li>EN_CARTRIDGE (533x660 mm ; 21.00x26.00 in)</li> |
||
410 | * <li>EN_DOUBLE_LARGE_POST (533x838 mm ; 21.00x33.00 in)</li> |
||
411 | * <li>EN_ROYAL (508x635 mm ; 20.00x25.00 in)</li> |
||
412 | * <li>EN_SHEET, EN_HALF_POST (495x597 mm ; 19.50x23.50 in)</li> |
||
413 | * <li>EN_SUPER_ROYAL (483x686 mm ; 19.00x27.00 in)</li> |
||
414 | * <li>EN_DOUBLE_POST (483x775 mm ; 19.00x30.50 in)</li> |
||
415 | * <li>EN_MEDIUM (445x584 mm ; 17.50x23.00 in)</li> |
||
416 | * <li>EN_DEMY (445x572 mm ; 17.50x22.50 in)</li> |
||
417 | * <li>EN_LARGE_POST (419x533 mm ; 16.50x21.00 in)</li> |
||
418 | * <li>EN_COPY_DRAUGHT (406x508 mm ; 16.00x20.00 in)</li> |
||
419 | * <li>EN_POST (394x489 mm ; 15.50x19.25 in)</li> |
||
420 | * <li>EN_CROWN (381x508 mm ; 15.00x20.00 in)</li> |
||
421 | * <li>EN_PINCHED_POST (375x470 mm ; 14.75x18.50 in)</li> |
||
422 | * <li>EN_BRIEF (343x406 mm ; 13.50x16.00 in)</li> |
||
423 | * <li>EN_FOOLSCAP (343x432 mm ; 13.50x17.00 in)</li> |
||
424 | * <li>EN_SMALL_FOOLSCAP (337x419 mm ; 13.25x16.50 in)</li> |
||
425 | * <li>EN_POTT (318x381 mm ; 12.50x15.00 in)</li> |
||
426 | * <li><b>Old Imperial Belgian</b></li> |
||
427 | * <li>BE_GRAND_AIGLE (700x1040 mm ; 27.56x40.94 in)</li> |
||
428 | * <li>BE_COLOMBIER (620x850 mm ; 24.41x33.46 in)</li> |
||
429 | * <li>BE_DOUBLE_CARRE (620x920 mm ; 24.41x36.22 in)</li> |
||
430 | * <li>BE_ELEPHANT (616x770 mm ; 24.25x30.31 in)</li> |
||
431 | * <li>BE_PETIT_AIGLE (600x840 mm ; 23.62x33.07 in)</li> |
||
432 | * <li>BE_GRAND_JESUS (550x730 mm ; 21.65x28.74 in)</li> |
||
433 | * <li>BE_JESUS (540x730 mm ; 21.26x28.74 in)</li> |
||
434 | * <li>BE_RAISIN (500x650 mm ; 19.69x25.59 in)</li> |
||
435 | * <li>BE_GRAND_MEDIAN (460x605 mm ; 18.11x23.82 in)</li> |
||
436 | * <li>BE_DOUBLE_POSTE (435x565 mm ; 17.13x22.24 in)</li> |
||
437 | * <li>BE_COQUILLE (430x560 mm ; 16.93x22.05 in)</li> |
||
438 | * <li>BE_PETIT_MEDIAN (415x530 mm ; 16.34x20.87 in)</li> |
||
439 | * <li>BE_RUCHE (360x460 mm ; 14.17x18.11 in)</li> |
||
440 | * <li>BE_PROPATRIA (345x430 mm ; 13.58x16.93 in)</li> |
||
441 | * <li>BE_LYS (317x397 mm ; 12.48x15.63 in)</li> |
||
442 | * <li>BE_POT (307x384 mm ; 12.09x15.12 in)</li> |
||
443 | * <li>BE_ROSETTE (270x347 mm ; 10.63x13.66 in)</li> |
||
444 | * <li><b>Old Imperial French</b></li> |
||
445 | * <li>FR_UNIVERS (1000x1300 mm ; 39.37x51.18 in)</li> |
||
446 | * <li>FR_DOUBLE_COLOMBIER (900x1260 mm ; 35.43x49.61 in)</li> |
||
447 | * <li>FR_GRANDE_MONDE (900x1260 mm ; 35.43x49.61 in)</li> |
||
448 | * <li>FR_DOUBLE_SOLEIL (800x1200 mm ; 31.50x47.24 in)</li> |
||
449 | * <li>FR_DOUBLE_JESUS (760x1120 mm ; 29.92x44.09 in)</li> |
||
450 | * <li>FR_GRAND_AIGLE (750x1060 mm ; 29.53x41.73 in)</li> |
||
451 | * <li>FR_PETIT_AIGLE (700x940 mm ; 27.56x37.01 in)</li> |
||
452 | * <li>FR_DOUBLE_RAISIN (650x1000 mm ; 25.59x39.37 in)</li> |
||
453 | * <li>FR_JOURNAL (650x940 mm ; 25.59x37.01 in)</li> |
||
454 | * <li>FR_COLOMBIER_AFFICHE (630x900 mm ; 24.80x35.43 in)</li> |
||
455 | * <li>FR_DOUBLE_CAVALIER (620x920 mm ; 24.41x36.22 in)</li> |
||
456 | * <li>FR_CLOCHE (600x800 mm ; 23.62x31.50 in)</li> |
||
457 | * <li>FR_SOLEIL (600x800 mm ; 23.62x31.50 in)</li> |
||
458 | * <li>FR_DOUBLE_CARRE (560x900 mm ; 22.05x35.43 in)</li> |
||
459 | * <li>FR_DOUBLE_COQUILLE (560x880 mm ; 22.05x34.65 in)</li> |
||
460 | * <li>FR_JESUS (560x760 mm ; 22.05x29.92 in)</li> |
||
461 | * <li>FR_RAISIN (500x650 mm ; 19.69x25.59 in)</li> |
||
462 | * <li>FR_CAVALIER (460x620 mm ; 18.11x24.41 in)</li> |
||
463 | * <li>FR_DOUBLE_COURONNE (460x720 mm ; 18.11x28.35 in)</li> |
||
464 | * <li>FR_CARRE (450x560 mm ; 17.72x22.05 in)</li> |
||
465 | * <li>FR_COQUILLE (440x560 mm ; 17.32x22.05 in)</li> |
||
466 | * <li>FR_DOUBLE_TELLIERE (440x680 mm ; 17.32x26.77 in)</li> |
||
467 | * <li>FR_DOUBLE_CLOCHE (400x600 mm ; 15.75x23.62 in)</li> |
||
468 | * <li>FR_DOUBLE_POT (400x620 mm ; 15.75x24.41 in)</li> |
||
469 | * <li>FR_ECU (400x520 mm ; 15.75x20.47 in)</li> |
||
470 | * <li>FR_COURONNE (360x460 mm ; 14.17x18.11 in)</li> |
||
471 | * <li>FR_TELLIERE (340x440 mm ; 13.39x17.32 in)</li> |
||
472 | * <li>FR_POT (310x400 mm ; 12.20x15.75 in)</li> |
||
473 | * </ul> |
||
474 | * @return array containing page width and height in points |
||
475 | * @since 5.0.010 (2010-05-17) |
||
476 | * @public static |
||
477 | */ |
||
478 | public static function getPageSizeFromFormat($format) { |
||
831 | |||
832 | /** |
||
833 | * Set page boundaries. |
||
834 | * @param $page (int) page number |
||
835 | * @param $type (string) valid values are: <ul><li>'MediaBox' : the boundaries of the physical medium on which the page shall be displayed or printed;</li><li>'CropBox' : the visible region of default user space;</li><li>'BleedBox' : the region to which the contents of the page shall be clipped when output in a production environment;</li><li>'TrimBox' : the intended dimensions of the finished page after trimming;</li><li>'ArtBox' : the page's meaningful content (including potential white space).</li></ul> |
||
836 | * @param $llx (float) lower-left x coordinate in user units. |
||
837 | * @param $lly (float) lower-left y coordinate in user units. |
||
838 | * @param $urx (float) upper-right x coordinate in user units. |
||
839 | * @param $ury (float) upper-right y coordinate in user units. |
||
840 | * @param $points (boolean) If true uses user units as unit of measure, otherwise uses PDF points. |
||
841 | * @param $k (float) Scale factor (number of points in user unit). |
||
842 | * @param $pagedim (array) Array of page dimensions. |
||
843 | * @return pagedim array of page dimensions. |
||
844 | * @since 5.0.010 (2010-05-17) |
||
845 | * @public static |
||
846 | */ |
||
847 | public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=false, $k, $pagedim=array()) { |
||
864 | |||
865 | /** |
||
866 | * Swap X and Y coordinates of page boxes (change page boxes orientation). |
||
867 | * @param $page (int) page number |
||
868 | * @param $pagedim (array) Array of page dimensions. |
||
869 | * @return pagedim array of page dimensions. |
||
870 | * @since 5.0.010 (2010-05-17) |
||
871 | * @public static |
||
872 | */ |
||
873 | public static function swapPageBoxCoordinates($page, $pagedim) { |
||
887 | |||
888 | /** |
||
889 | * Get the canonical page layout mode. |
||
890 | * @param $layout (string) The page layout. Possible values are:<ul><li>SinglePage Display one page at a time</li><li>OneColumn Display the pages in one column</li><li>TwoColumnLeft Display the pages in two columns, with odd-numbered pages on the left</li><li>TwoColumnRight Display the pages in two columns, with odd-numbered pages on the right</li><li>TwoPageLeft (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left</li><li>TwoPageRight (PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right</li></ul> |
||
891 | * @return (string) Canonical page layout name. |
||
892 | * @public static |
||
893 | */ |
||
894 | public static function getPageLayoutMode($layout='SinglePage') { |
||
930 | |||
931 | /** |
||
932 | * Get the canonical page layout mode. |
||
933 | * @param $mode (string) A name object specifying how the document should be displayed when opened:<ul><li>UseNone Neither document outline nor thumbnail images visible</li><li>UseOutlines Document outline visible</li><li>UseThumbs Thumbnail images visible</li><li>FullScreen Full-screen mode, with no menu bar, window controls, or any other window visible</li><li>UseOC (PDF 1.5) Optional content group panel visible</li><li>UseAttachments (PDF 1.6) Attachments panel visible</li></ul> |
||
934 | * @return (string) Canonical page mode name. |
||
935 | * @public static |
||
936 | */ |
||
937 | public static function getPageMode($mode='UseNone') { |
||
969 | |||
970 | /** |
||
971 | * Check if the URL exist. |
||
972 | * @param $url (string) URL to check. |
||
973 | * @return Boolean true if the URl exist, false otherwise. |
||
974 | * @since 5.9.204 (2013-01-28) |
||
975 | * @public static |
||
976 | */ |
||
977 | public static function isValidURL($url) { |
||
981 | |||
982 | /** |
||
983 | * Removes SHY characters from text. |
||
984 | * Unicode Data:<ul> |
||
985 | * <li>Name : SOFT HYPHEN, commonly abbreviated as SHY</li> |
||
986 | * <li>HTML Entity (decimal): "&#173;"</li> |
||
987 | * <li>HTML Entity (hex): "&#xad;"</li> |
||
988 | * <li>HTML Entity (named): "&shy;"</li> |
||
989 | * <li>How to type in Microsoft Windows: [Alt +00AD] or [Alt 0173]</li> |
||
990 | * <li>UTF-8 (hex): 0xC2 0xAD (c2ad)</li> |
||
991 | * <li>UTF-8 character: chr(194).chr(173)</li> |
||
992 | * </ul> |
||
993 | * @param $txt (string) input string |
||
994 | * @param $unicode (boolean) True if we are in unicode mode, false otherwise. |
||
995 | * @return string without SHY characters. |
||
996 | * @since (4.5.019) 2009-02-28 |
||
997 | * @public static |
||
998 | */ |
||
999 | public static function removeSHY($txt='', $unicode=true) { |
||
1006 | |||
1007 | |||
1008 | /** |
||
1009 | * Get the border mode accounting for multicell position (opens bottom side of multicell crossing pages) |
||
1010 | * @param $brd (mixed) Indicates if borders must be drawn around the cell block. The value can be a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul> or an array of line styles for each border group: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))) |
||
1011 | * @param $position (string) multicell position: 'start', 'middle', 'end' |
||
1012 | * @param $opencell (boolean) True when the cell is left open at the page bottom, false otherwise. |
||
1013 | * @return border mode array |
||
1014 | * @since 4.4.002 (2008-12-09) |
||
1015 | * @public static |
||
1016 | */ |
||
1017 | public static function getBorderMode($brd, $position='start', $opencell=true) { |
||
1081 | |||
1082 | /** |
||
1083 | * Determine whether a string is empty. |
||
1084 | * @param $str (string) string to be checked |
||
1085 | * @return boolean true if string is empty |
||
1086 | * @since 4.5.044 (2009-04-16) |
||
1087 | * @public static |
||
1088 | */ |
||
1089 | public static function empty_string($str) { |
||
1092 | |||
1093 | /** |
||
1094 | * Returns a temporary filename for caching object on filesystem. |
||
1095 | * @param $type (string) Type of file (name of the subdir on the tcpdf cache folder). |
||
1096 | * @return string filename. |
||
1097 | * @since 4.5.000 (2008-12-31) |
||
1098 | * @public static |
||
1099 | */ |
||
1100 | public static function getObjFilename($type='tmp') { |
||
1103 | |||
1104 | /** |
||
1105 | * Add "\" before "\", "(" and ")" |
||
1106 | * @param $s (string) string to escape. |
||
1107 | * @return string escaped string. |
||
1108 | * @public static |
||
1109 | */ |
||
1110 | public static function _escape($s) { |
||
1114 | |||
1115 | /** |
||
1116 | * Escape some special characters (< > &) for XML output. |
||
1117 | * @param $str (string) Input string to convert. |
||
1118 | * @return converted string |
||
1119 | * @since 5.9.121 (2011-09-28) |
||
1120 | * @public static |
||
1121 | */ |
||
1122 | public static function _escapeXML($str) { |
||
1127 | |||
1128 | /** |
||
1129 | * Creates a copy of a class object |
||
1130 | * @param $object (object) class object to be cloned |
||
1131 | * @return cloned object |
||
1132 | * @since 4.5.029 (2009-03-19) |
||
1133 | * @public static |
||
1134 | */ |
||
1135 | public static function objclone($object) { |
||
1142 | |||
1143 | /** |
||
1144 | * Ouput input data and compress it if possible. |
||
1145 | * @param $data (string) Data to output. |
||
1146 | * @param $length (int) Data length in bytes. |
||
1147 | * @since 5.9.086 |
||
1148 | * @public static |
||
1149 | */ |
||
1150 | public static function sendOutputData($data, $length) { |
||
1157 | |||
1158 | /** |
||
1159 | * Replace page number aliases with number. |
||
1160 | * @param $page (string) Page content. |
||
1161 | * @param $replace (array) Array of replacements (array keys are replacement strings, values are alias arrays). |
||
1162 | * @param $diff (int) If passed, this will be set to the total char number difference between alias and replacements. |
||
1163 | * @return replaced page content and updated $diff parameter as array. |
||
1164 | * @public static |
||
1165 | */ |
||
1166 | public static function replacePageNumAliases($page, $replace, $diff=0) { |
||
1177 | |||
1178 | /** |
||
1179 | * Returns timestamp in seconds from formatted date-time. |
||
1180 | * @param $date (string) Formatted date-time. |
||
1181 | * @return int seconds. |
||
1182 | * @since 5.9.152 (2012-03-23) |
||
1183 | * @public static |
||
1184 | */ |
||
1185 | public static function getTimestamp($date) { |
||
1192 | |||
1193 | /** |
||
1194 | * Returns a formatted date-time. |
||
1195 | * @param $time (int) Time in seconds. |
||
1196 | * @return string escaped date string. |
||
1197 | * @since 5.9.152 (2012-03-23) |
||
1198 | * @public static |
||
1199 | */ |
||
1200 | public static function getFormattedDate($time) { |
||
1203 | |||
1204 | /** |
||
1205 | * Get ULONG from string (Big Endian 32-bit unsigned integer). |
||
1206 | * @param $str (string) string from where to extract value |
||
1207 | * @param $offset (int) point from where to read the data |
||
1208 | * @return int 32 bit value |
||
1209 | * @author Nicola Asuni |
||
1210 | * @since 5.2.000 (2010-06-02) |
||
1211 | * @public static |
||
1212 | */ |
||
1213 | public static function _getULONG($str, $offset) { |
||
1217 | |||
1218 | /** |
||
1219 | * Get USHORT from string (Big Endian 16-bit unsigned integer). |
||
1220 | * @param $str (string) string from where to extract value |
||
1221 | * @param $offset (int) point from where to read the data |
||
1222 | * @return int 16 bit value |
||
1223 | * @author Nicola Asuni |
||
1224 | * @since 5.2.000 (2010-06-02) |
||
1225 | * @public static |
||
1226 | */ |
||
1227 | public static function _getUSHORT($str, $offset) { |
||
1231 | |||
1232 | /** |
||
1233 | * Get SHORT from string (Big Endian 16-bit signed integer). |
||
1234 | * @param $str (string) String from where to extract value. |
||
1235 | * @param $offset (int) Point from where to read the data. |
||
1236 | * @return int 16 bit value |
||
1237 | * @author Nicola Asuni |
||
1238 | * @since 5.2.000 (2010-06-02) |
||
1239 | * @public static |
||
1240 | */ |
||
1241 | public static function _getSHORT($str, $offset) { |
||
1245 | |||
1246 | /** |
||
1247 | * Get FWORD from string (Big Endian 16-bit signed integer). |
||
1248 | * @param $str (string) String from where to extract value. |
||
1249 | * @param $offset (int) Point from where to read the data. |
||
1250 | * @return int 16 bit value |
||
1251 | * @author Nicola Asuni |
||
1252 | * @since 5.9.123 (2011-09-30) |
||
1253 | * @public static |
||
1254 | */ |
||
1255 | public static function _getFWORD($str, $offset) { |
||
1262 | |||
1263 | /** |
||
1264 | * Get UFWORD from string (Big Endian 16-bit unsigned integer). |
||
1265 | * @param $str (string) string from where to extract value |
||
1266 | * @param $offset (int) point from where to read the data |
||
1267 | * @return int 16 bit value |
||
1268 | * @author Nicola Asuni |
||
1269 | * @since 5.9.123 (2011-09-30) |
||
1270 | * @public static |
||
1271 | */ |
||
1272 | public static function _getUFWORD($str, $offset) { |
||
1276 | |||
1277 | /** |
||
1278 | * Get FIXED from string (32-bit signed fixed-point number (16.16). |
||
1279 | * @param $str (string) string from where to extract value |
||
1280 | * @param $offset (int) point from where to read the data |
||
1281 | * @return int 16 bit value |
||
1282 | * @author Nicola Asuni |
||
1283 | * @since 5.9.123 (2011-09-30) |
||
1284 | * @public static |
||
1285 | */ |
||
1286 | public static function _getFIXED($str, $offset) { |
||
1294 | |||
1295 | /** |
||
1296 | * Get BYTE from string (8-bit unsigned integer). |
||
1297 | * @param $str (string) String from where to extract value. |
||
1298 | * @param $offset (int) Point from where to read the data. |
||
1299 | * @return int 8 bit value |
||
1300 | * @author Nicola Asuni |
||
1301 | * @since 5.2.000 (2010-06-02) |
||
1302 | * @public static |
||
1303 | */ |
||
1304 | public static function _getBYTE($str, $offset) { |
||
1308 | /** |
||
1309 | * Binary-safe and URL-safe file read. |
||
1310 | * Reads up to length bytes from the file pointer referenced by handle. Reading stops as soon as one of the following conditions is met: length bytes have been read; EOF (end of file) is reached. |
||
1311 | * @param $handle (resource) |
||
1312 | * @param $length (int) |
||
1313 | * @return Returns the read string or FALSE in case of error. |
||
1314 | * @author Nicola Asuni |
||
1315 | * @since 4.5.027 (2009-03-16) |
||
1316 | * @public static |
||
1317 | */ |
||
1318 | public static function rfread($handle, $length) { |
||
1329 | |||
1330 | /** |
||
1331 | * Read a 4-byte (32 bit) integer from file. |
||
1332 | * @param $f (string) file name. |
||
1333 | * @return 4-byte integer |
||
1334 | * @public static |
||
1335 | */ |
||
1336 | public static function _freadint($f) { |
||
1340 | |||
1341 | /** |
||
1342 | * Returns a string containing random data to be used as a seed for encryption methods. |
||
1343 | * @param $seed (string) starting seed value |
||
1344 | * @return string containing random data |
||
1345 | * @author Nicola Asuni |
||
1346 | * @since 5.9.006 (2010-10-19) |
||
1347 | * @public static |
||
1348 | */ |
||
1349 | public static function getRandomSeed($seed='') { |
||
1386 | |||
1387 | /** |
||
1388 | * Encrypts a string using MD5 and returns it's value as a binary string. |
||
1389 | * @param $str (string) input string |
||
1390 | * @return String MD5 encrypted binary string |
||
1391 | * @since 2.0.000 (2008-01-02) |
||
1392 | * @public static |
||
1393 | */ |
||
1394 | public static function _md5_16($str) { |
||
1397 | |||
1398 | /** |
||
1399 | * Returns the input text exrypted using AES algorithm and the specified key. |
||
1400 | * This method requires mcrypt. |
||
1401 | * @param $key (string) encryption key |
||
1402 | * @param $text (String) input text to be encrypted |
||
1403 | * @return String encrypted text |
||
1404 | * @author Nicola Asuni |
||
1405 | * @since 5.0.005 (2010-05-11) |
||
1406 | * @public static |
||
1407 | */ |
||
1408 | public static function _AES($key, $text) { |
||
1417 | |||
1418 | /** |
||
1419 | * Returns the input text encrypted using RC4 algorithm and the specified key. |
||
1420 | * RC4 is the standard encryption algorithm used in PDF format |
||
1421 | * @param $key (string) Encryption key. |
||
1422 | * @param $text (String) Input text to be encrypted. |
||
1423 | * @param $last_enc_key (String) Reference to last RC4 key encrypted. |
||
1424 | * @param $last_enc_key_c (String) Reference to last RC4 computed key. |
||
1425 | * @return String encrypted text |
||
1426 | * @since 2.0.000 (2008-01-02) |
||
1427 | * @author Klemen Vodopivec, Nicola Asuni |
||
1428 | * @public static |
||
1429 | */ |
||
1430 | public static function _RC4($key, $text, &$last_enc_key, &$last_enc_key_c) { |
||
1465 | |||
1466 | /** |
||
1467 | * Return the premission code used on encryption (P value). |
||
1468 | * @param $permissions (Array) the set of permissions (specify the ones you want to block). |
||
1469 | * @param $mode (int) encryption strength: 0 = RC4 40 bit; 1 = RC4 128 bit; 2 = AES 128 bit; 3 = AES 256 bit. |
||
1470 | * @since 5.0.005 (2010-05-12) |
||
1471 | * @author Nicola Asuni |
||
1472 | * @public static |
||
1473 | */ |
||
1474 | public static function getUserPermissionCode($permissions, $mode=0) { |
||
1502 | |||
1503 | /** |
||
1504 | * Convert hexadecimal string to string |
||
1505 | * @param $bs (string) byte-string to convert |
||
1506 | * @return String |
||
1507 | * @since 5.0.005 (2010-05-12) |
||
1508 | * @author Nicola Asuni |
||
1509 | * @public static |
||
1510 | */ |
||
1511 | public static function convertHexStringToString($bs) { |
||
1524 | |||
1525 | /** |
||
1526 | * Convert string to hexadecimal string (byte string) |
||
1527 | * @param $s (string) string to convert |
||
1528 | * @return byte string |
||
1529 | * @since 5.0.010 (2010-05-17) |
||
1530 | * @author Nicola Asuni |
||
1531 | * @public static |
||
1532 | */ |
||
1533 | public static function convertStringToHexString($s) { |
||
1541 | |||
1542 | /** |
||
1543 | * Convert encryption P value to a string of bytes, low-order byte first. |
||
1544 | * @param $protection (string) 32bit encryption permission value (P value) |
||
1545 | * @return String |
||
1546 | * @since 5.0.005 (2010-05-12) |
||
1547 | * @author Nicola Asuni |
||
1548 | * @public static |
||
1549 | */ |
||
1550 | public static function getEncPermissionsString($protection) { |
||
1558 | |||
1559 | /** |
||
1560 | * Encode a name object. |
||
1561 | * @param $name (string) Name object to encode. |
||
1562 | * @return (string) Encoded name object. |
||
1563 | * @author Nicola Asuni |
||
1564 | * @since 5.9.097 (2011-06-23) |
||
1565 | * @public static |
||
1566 | */ |
||
1567 | View Code Duplication | public static function encodeNameObject($name) { |
|
1580 | |||
1581 | /** |
||
1582 | * Convert JavaScript form fields properties array to Annotation Properties array. |
||
1583 | * @param $prop (array) javascript field properties. Possible values are described on official Javascript for Acrobat API reference. |
||
1584 | * @param $spot_colors (array) Reference to spot colors array. |
||
1585 | * @param $rtl (boolean) True if in Right-To-Left text direction mode, false otherwise. |
||
1586 | * @return array of annotation properties |
||
1587 | * @author Nicola Asuni |
||
1588 | * @since 4.8.000 (2009-09-06) |
||
1589 | * @public static |
||
1590 | */ |
||
1591 | public static function getAnnotOptFromJSProp($prop, &$spot_colors, $rtl=false) { |
||
1949 | |||
1950 | /** |
||
1951 | * Format the page numbers. |
||
1952 | * This method can be overriden for custom formats. |
||
1953 | * @param $num (int) page number |
||
1954 | * @since 4.2.005 (2008-11-06) |
||
1955 | * @public static |
||
1956 | */ |
||
1957 | public static function formatPageNumber($num) { |
||
1960 | |||
1961 | /** |
||
1962 | * Format the page numbers on the Table Of Content. |
||
1963 | * This method can be overriden for custom formats. |
||
1964 | * @param $num (int) page number |
||
1965 | * @since 4.5.001 (2009-01-04) |
||
1966 | * @see addTOC(), addHTMLTOC() |
||
1967 | * @public static |
||
1968 | */ |
||
1969 | public static function formatTOCPageNumber($num) { |
||
1972 | |||
1973 | /** |
||
1974 | * Extracts the CSS properties from a CSS string. |
||
1975 | * @param $cssdata (string) string containing CSS definitions. |
||
1976 | * @return An array where the keys are the CSS selectors and the values are the CSS properties. |
||
1977 | * @author Nicola Asuni |
||
1978 | * @since 5.1.000 (2010-05-25) |
||
1979 | * @public static |
||
1980 | */ |
||
1981 | public static function extractCSSproperties($cssdata) { |
||
2063 | |||
2064 | /** |
||
2065 | * Cleanup HTML code (requires HTML Tidy library). |
||
2066 | * @param $html (string) htmlcode to fix |
||
2067 | * @param $default_css (string) CSS commands to add |
||
2068 | * @param $tagvs (array) parameters for setHtmlVSpace method |
||
2069 | * @param $tidy_options (array) options for tidy_parse_string function |
||
2070 | * @param $tagvspaces (array) Array of vertical spaces for tags. |
||
2071 | * @return string XHTML code cleaned up |
||
2072 | * @author Nicola Asuni |
||
2073 | * @since 5.9.017 (2010-11-16) |
||
2074 | * @see setHtmlVSpace() |
||
2075 | * @public static |
||
2076 | */ |
||
2077 | public static function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='', &$tagvspaces) { |
||
2133 | |||
2134 | /** |
||
2135 | * Returns true if the CSS selector is valid for the selected HTML tag |
||
2136 | * @param $dom (array) array of HTML tags and properties |
||
2137 | * @param $key (int) key of the current HTML tag |
||
2138 | * @param $selector (string) CSS selector string |
||
2139 | * @return true if the selector is valid, false otherwise |
||
2140 | * @since 5.1.000 (2010-05-25) |
||
2141 | * @public static |
||
2142 | */ |
||
2143 | public static function isValidCSSSelectorForTag($dom, $key, $selector) { |
||
2293 | |||
2294 | /** |
||
2295 | * Returns the styles array that apply for the selected HTML tag. |
||
2296 | * @param $dom (array) array of HTML tags and properties |
||
2297 | * @param $key (int) key of the current HTML tag |
||
2298 | * @param $css (array) array of CSS properties |
||
2299 | * @return array containing CSS properties |
||
2300 | * @since 5.1.000 (2010-05-25) |
||
2301 | * @public static |
||
2302 | */ |
||
2303 | public static function getCSSdataArray($dom, $key, $css) { |
||
2340 | |||
2341 | /** |
||
2342 | * Compact CSS data array into single string. |
||
2343 | * @param $css (array) array of CSS properties |
||
2344 | * @return string containing merged CSS properties |
||
2345 | * @since 5.9.070 (2011-04-19) |
||
2346 | * @public static |
||
2347 | */ |
||
2348 | public static function getTagStyleFromCSSarray($css) { |
||
2371 | |||
2372 | /** |
||
2373 | * Returns the Roman representation of an integer number |
||
2374 | * @param $number (int) number to convert |
||
2375 | * @return string roman representation of the specified number |
||
2376 | * @since 4.4.004 (2008-12-10) |
||
2377 | * @public static |
||
2378 | */ |
||
2379 | public static function intToRoman($number) { |
||
2435 | |||
2436 | /** |
||
2437 | * Find position of last occurrence of a substring in a string |
||
2438 | * @param $haystack (string) The string to search in. |
||
2439 | * @param $needle (string) substring to search. |
||
2440 | * @param $offset (int) May be specified to begin searching an arbitrary number of characters into the string. |
||
2441 | * @return Returns the position where the needle exists. Returns FALSE if the needle was not found. |
||
2442 | * @since 4.8.038 (2010-03-13) |
||
2443 | * @public static |
||
2444 | */ |
||
2445 | public static function revstrpos($haystack, $needle, $offset = 0) { |
||
2451 | |||
2452 | /** |
||
2453 | * Serialize an array of parameters to be used with TCPDF tag in HTML code. |
||
2454 | * @param $pararray (array) parameters array |
||
2455 | * @return sting containing serialized data |
||
2456 | * @since 4.9.006 (2010-04-02) |
||
2457 | * @public static |
||
2458 | */ |
||
2459 | public static function serializeTCPDFtagParameters($pararray) { |
||
2462 | |||
2463 | /** |
||
2464 | * Returns an array of hyphenation patterns. |
||
2465 | * @param $file (string) TEX file containing hypenation patterns. TEX pattrns can be downloaded from http://www.ctan.org/tex-archive/language/hyph-utf8/tex/generic/hyph-utf8/patterns/ |
||
2466 | * @return array of hyphenation patterns |
||
2467 | * @author Nicola Asuni |
||
2468 | * @since 4.9.012 (2010-04-12) |
||
2469 | * @public static |
||
2470 | */ |
||
2471 | public static function getHyphenPatternsFromTEX($file) { |
||
2495 | |||
2496 | /** |
||
2497 | * Get the Path-Painting Operators. |
||
2498 | * @param $style (string) Style of rendering. Possible values are: |
||
2499 | * <ul> |
||
2500 | * <li>S or D: Stroke the path.</li> |
||
2501 | * <li>s or d: Close and stroke the path.</li> |
||
2502 | * <li>f or F: Fill the path, using the nonzero winding number rule to determine the region to fill.</li> |
||
2503 | * <li>f* or F*: Fill the path, using the even-odd rule to determine the region to fill.</li> |
||
2504 | * <li>B or FD or DF: Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill.</li> |
||
2505 | * <li>B* or F*D or DF*: Fill and then stroke the path, using the even-odd rule to determine the region to fill.</li> |
||
2506 | * <li>b or fd or df: Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill.</li> |
||
2507 | * <li>b or f*d or df*: Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill.</li> |
||
2508 | * <li>CNZ: Clipping mode using the even-odd rule to determine which regions lie inside the clipping path.</li> |
||
2509 | * <li>CEO: Clipping mode using the nonzero winding number rule to determine which regions lie inside the clipping path</li> |
||
2510 | * <li>n: End the path object without filling or stroking it.</li> |
||
2511 | * </ul> |
||
2512 | * @param $default (string) default style |
||
2513 | * @author Nicola Asuni |
||
2514 | * @since 5.0.000 (2010-04-30) |
||
2515 | * @public static |
||
2516 | */ |
||
2517 | public static function getPathPaintOperator($style, $default='S') { |
||
2586 | |||
2587 | /** |
||
2588 | * Get the product of two SVG tranformation matrices |
||
2589 | * @param $ta (array) first SVG tranformation matrix |
||
2590 | * @param $tb (array) second SVG tranformation matrix |
||
2591 | * @return transformation array |
||
2592 | * @author Nicola Asuni |
||
2593 | * @since 5.0.000 (2010-05-02) |
||
2594 | * @public static |
||
2595 | */ |
||
2596 | public static function getTransformationMatrixProduct($ta, $tb) { |
||
2606 | |||
2607 | /** |
||
2608 | * Get the tranformation matrix from SVG transform attribute |
||
2609 | * @param $attribute (string) transformation |
||
2610 | * @return array of transformations |
||
2611 | * @author Nicola Asuni |
||
2612 | * @since 5.0.000 (2010-05-02) |
||
2613 | * @public static |
||
2614 | */ |
||
2615 | public static function getSVGTransformMatrix($attribute) { |
||
2701 | |||
2702 | /** |
||
2703 | * Returns the angle in radiants between two vectors |
||
2704 | * @param $x1 (int) X coordinate of first vector point |
||
2705 | * @param $y1 (int) Y coordinate of first vector point |
||
2706 | * @param $x2 (int) X coordinate of second vector point |
||
2707 | * @param $y2 (int) Y coordinate of second vector point |
||
2708 | * @author Nicola Asuni |
||
2709 | * @since 5.0.000 (2010-05-04) |
||
2710 | * @public static |
||
2711 | */ |
||
2712 | public static function getVectorsAngle($x1, $y1, $x2, $y2) { |
||
2725 | |||
2726 | /** |
||
2727 | * Split string by a regular expression. |
||
2728 | * This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850 |
||
2729 | * @param $pattern (string) The regular expression pattern to search for without the modifiers, as a string. |
||
2730 | * @param $modifiers (string) The modifiers part of the pattern, |
||
2731 | * @param $subject (string) The input string. |
||
2732 | * @param $limit (int) If specified, then only substrings up to limit are returned with the rest of the string being placed in the last substring. A limit of -1, 0 or NULL means "no limit" and, as is standard across PHP, you can use NULL to skip to the flags parameter. |
||
2733 | * @param $flags (int) The flags as specified on the preg_split PHP function. |
||
2734 | * @return Returns an array containing substrings of subject split along boundaries matched by pattern.modifier |
||
2735 | * @author Nicola Asuni |
||
2736 | * @since 6.0.023 |
||
2737 | * @public static |
||
2738 | */ |
||
2739 | public static function pregSplit($pattern, $modifiers, $subject, $limit=NULL, $flags=NULL) { |
||
2756 | |||
2757 | /** |
||
2758 | * Reads entire file into a string. |
||
2759 | * The file can be also an URL. |
||
2760 | * @param $file (string) Name of the file or URL to read. |
||
2761 | * @return The function returns the read data or FALSE on failure. |
||
2762 | * @author Nicola Asuni |
||
2763 | * @since 6.0.025 |
||
2764 | * @public static |
||
2765 | */ |
||
2766 | public static function fileGetContents($file) { |
||
2837 | |||
2838 | } // END OF TCPDF_STATIC CLASS |
||
2839 | |||
2843 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.