Index: trunk/extensions/QPoll/Excel/patch.php |
— | — | @@ -1,308 +0,0 @@ |
2 | | -<?php |
3 | | - /** |
4 | | - * Calculate |
5 | | - * Handling of the SST continue blocks is complicated by the need to include an |
6 | | - * additional continuation byte depending on whether the string is split between |
7 | | - * blocks or whether it starts at the beginning of the block. (There are also |
8 | | - * additional complications that will arise later when/if Rich Strings are |
9 | | - * supported). |
10 | | - * |
11 | | - * @access private |
12 | | - */ |
13 | | - function _calculateSharedStringsSizes() |
14 | | - { |
15 | | - /* Iterate through the strings to calculate the CONTINUE block sizes. |
16 | | - For simplicity we use the same size for the SST and CONTINUE records: |
17 | | - 8228 : Maximum Excel97 block size |
18 | | - -4 : Length of block header |
19 | | - -8 : Length of additional SST header information |
20 | | - -8 : Arbitrary number to keep within _add_continue() limit |
21 | | - = 8208 |
22 | | - */ |
23 | | - $continue_limit = 8208; |
24 | | - $block_length = 0; |
25 | | - $written = 0; |
26 | | - $this->_block_sizes = array(); |
27 | | - $continue = 0; |
28 | | - |
29 | | - foreach (array_keys($this->_str_table) as $string) { |
30 | | - $string_length = strlen($string); |
31 | | - $headerinfo = unpack("vlength/Cencoding", $string); |
32 | | - $encoding = $headerinfo["encoding"]; |
33 | | - $split_string = 0; |
34 | | - |
35 | | - // Block length is the total length of the strings that will be |
36 | | - // written out in a single SST or CONTINUE block. |
37 | | - $block_length += $string_length; |
38 | | - |
39 | | - // We can write the string if it doesn't cross a CONTINUE boundary |
40 | | - if ($block_length < $continue_limit) { |
41 | | - $written += $string_length; |
42 | | - continue; |
43 | | - } |
44 | | - |
45 | | - // Deal with the cases where the next string to be written will exceed |
46 | | - // the CONTINUE boundary. If the string is very long it may need to be |
47 | | - // written in more than one CONTINUE record. |
48 | | - while ($block_length >= $continue_limit) { |
49 | | - |
50 | | - // We need to avoid the case where a string is continued in the first |
51 | | - // n bytes that contain the string header information. |
52 | | - $header_length = 3; // Min string + header size -1 |
53 | | - $space_remaining = $continue_limit - $written - $continue; |
54 | | - |
55 | | - |
56 | | - /* TODO: Unicode data should only be split on char (2 byte) |
57 | | - boundaries. Therefore, in some cases we need to reduce the |
58 | | - amount of available |
59 | | - */ |
60 | | - $align = 0; |
61 | | - |
62 | | - # Only applies to Unicode strings |
63 | | - if ($encoding == 1) { |
64 | | - # Min string + header size -1 |
65 | | - $header_length = 4; |
66 | | - |
67 | | - if ($space_remaining > $header_length) { |
68 | | - # String contains 3 byte header => split on odd boundary |
69 | | - if (!$split_string && $space_remaining % 2 != 1) { |
70 | | - $space_remaining--; |
71 | | - $align = 1; |
72 | | - } |
73 | | - # Split section without header => split on even boundary |
74 | | - else if ($split_string && $space_remaining % 2 == 1) { |
75 | | - $space_remaining--; |
76 | | - $align = 1; |
77 | | - } |
78 | | - |
79 | | - $split_string = 1; |
80 | | - } |
81 | | - } |
82 | | - |
83 | | - |
84 | | - if ($space_remaining > $header_length) { |
85 | | - // Write as much as possible of the string in the current block |
86 | | - $written += $space_remaining; |
87 | | - |
88 | | - // Reduce the current block length by the amount written |
89 | | - $block_length -= $continue_limit - $continue - $align; |
90 | | - |
91 | | - // Store the max size for this block |
92 | | - $this->_block_sizes[] = $continue_limit - $align; |
93 | | - |
94 | | - // If the current string was split then the next CONTINUE block |
95 | | - // should have the string continue flag (grbit) set unless the |
96 | | - // split string fits exactly into the remaining space. |
97 | | - if ($block_length > 0) { |
98 | | - $continue = 1; |
99 | | - } else { |
100 | | - $continue = 0; |
101 | | - } |
102 | | - } else { |
103 | | - // Store the max size for this block |
104 | | - $this->_block_sizes[] = $written + $continue; |
105 | | - |
106 | | - // Not enough space to start the string in the current block |
107 | | - $block_length -= $continue_limit - $space_remaining - $continue; |
108 | | - $continue = 0; |
109 | | - |
110 | | - } |
111 | | - |
112 | | - // If the string (or substr) is small enough we can write it in the |
113 | | - // new CONTINUE block. Else, go through the loop again to write it in |
114 | | - // one or more CONTINUE blocks |
115 | | - if ($block_length < $continue_limit) { |
116 | | - $written = $block_length; |
117 | | - } else { |
118 | | - $written = 0; |
119 | | - } |
120 | | - } |
121 | | - } |
122 | | - |
123 | | - // Store the max size for the last block unless it is empty |
124 | | - if ($written + $continue) { |
125 | | - $this->_block_sizes[] = $written + $continue; |
126 | | - } |
127 | | - |
128 | | - |
129 | | - /* Calculate the total length of the SST and associated CONTINUEs (if any). |
130 | | - The SST record will have a length even if it contains no strings. |
131 | | - This length is required to set the offsets in the BOUNDSHEET records since |
132 | | - they must be written before the SST records |
133 | | - */ |
134 | | - |
135 | | - $tmp_block_sizes = array(); |
136 | | - $tmp_block_sizes = $this->_block_sizes; |
137 | | - |
138 | | - $length = 12; |
139 | | - if (!empty($tmp_block_sizes)) { |
140 | | - $length += array_shift($tmp_block_sizes); # SST |
141 | | - } |
142 | | - while (!empty($tmp_block_sizes)) { |
143 | | - $length += 4 + array_shift($tmp_block_sizes); # CONTINUEs |
144 | | - } |
145 | | - |
146 | | - return $length; |
147 | | - } |
148 | | - |
149 | | - /** |
150 | | - * Write all of the workbooks strings into an indexed array. |
151 | | - * See the comments in _calculate_shared_string_sizes() for more information. |
152 | | - * |
153 | | - * The Excel documentation says that the SST record should be followed by an |
154 | | - * EXTSST record. The EXTSST record is a hash table that is used to optimise |
155 | | - * access to SST. However, despite the documentation it doesn't seem to be |
156 | | - * required so we will ignore it. |
157 | | - * |
158 | | - * @access private |
159 | | - */ |
160 | | - function _storeSharedStringsTable() |
161 | | - { |
162 | | - $record = 0x00fc; // Record identifier |
163 | | - $length = 0x0008; // Number of bytes to follow |
164 | | - $total = 0x0000; |
165 | | - |
166 | | - // Iterate through the strings to calculate the CONTINUE block sizes |
167 | | - $continue_limit = 8208; |
168 | | - $block_length = 0; |
169 | | - $written = 0; |
170 | | - $continue = 0; |
171 | | - |
172 | | - // sizes are upside down |
173 | | - $tmp_block_sizes = $this->_block_sizes; |
174 | | -// $tmp_block_sizes = array_reverse($this->_block_sizes); |
175 | | - |
176 | | - # The SST record is required even if it contains no strings. Thus we will |
177 | | - # always have a length |
178 | | - # |
179 | | - if (!empty($tmp_block_sizes)) { |
180 | | - $length = 8 + array_shift($tmp_block_sizes); |
181 | | - } |
182 | | - else { |
183 | | - # No strings |
184 | | - $length = 8; |
185 | | - } |
186 | | - |
187 | | - |
188 | | - |
189 | | - // Write the SST block header information |
190 | | - $header = pack("vv", $record, $length); |
191 | | - $data = pack("VV", $this->_str_total, $this->_str_unique); |
192 | | - $this->_append($header . $data); |
193 | | - |
194 | | - |
195 | | - |
196 | | - |
197 | | - /* TODO: not good for performance */ |
198 | | - foreach (array_keys($this->_str_table) as $string) { |
199 | | - |
200 | | - $string_length = strlen($string); |
201 | | - $headerinfo = unpack("vlength/Cencoding", $string); |
202 | | - $encoding = $headerinfo["encoding"]; |
203 | | - $split_string = 0; |
204 | | - |
205 | | - // Block length is the total length of the strings that will be |
206 | | - // written out in a single SST or CONTINUE block. |
207 | | - // |
208 | | - $block_length += $string_length; |
209 | | - |
210 | | - |
211 | | - // We can write the string if it doesn't cross a CONTINUE boundary |
212 | | - if ($block_length < $continue_limit) { |
213 | | - $this->_append($string); |
214 | | - $written += $string_length; |
215 | | - continue; |
216 | | - } |
217 | | - |
218 | | - // Deal with the cases where the next string to be written will exceed |
219 | | - // the CONTINUE boundary. If the string is very long it may need to be |
220 | | - // written in more than one CONTINUE record. |
221 | | - // |
222 | | - while ($block_length >= $continue_limit) { |
223 | | - |
224 | | - // We need to avoid the case where a string is continued in the first |
225 | | - // n bytes that contain the string header information. |
226 | | - // |
227 | | - $header_length = 3; // Min string + header size -1 |
228 | | - $space_remaining = $continue_limit - $written - $continue; |
229 | | - |
230 | | - |
231 | | - // Unicode data should only be split on char (2 byte) boundaries. |
232 | | - // Therefore, in some cases we need to reduce the amount of available |
233 | | - // space by 1 byte to ensure the correct alignment. |
234 | | - $align = 0; |
235 | | - |
236 | | - // Only applies to Unicode strings |
237 | | - if ($encoding == 1) { |
238 | | - // Min string + header size -1 |
239 | | - $header_length = 4; |
240 | | - |
241 | | - if ($space_remaining > $header_length) { |
242 | | - // String contains 3 byte header => split on odd boundary |
243 | | - if (!$split_string && $space_remaining % 2 != 1) { |
244 | | - $space_remaining--; |
245 | | - $align = 1; |
246 | | - } |
247 | | - // Split section without header => split on even boundary |
248 | | - else if ($split_string && $space_remaining % 2 == 1) { |
249 | | - $space_remaining--; |
250 | | - $align = 1; |
251 | | - } |
252 | | - |
253 | | - $split_string = 1; |
254 | | - } |
255 | | - } |
256 | | - |
257 | | - |
258 | | - if ($space_remaining > $header_length) { |
259 | | - // Write as much as possible of the string in the current block |
260 | | - $tmp = substr($string, 0, $space_remaining); |
261 | | - $this->_append($tmp); |
262 | | - |
263 | | - // The remainder will be written in the next block(s) |
264 | | - $string = substr($string, $space_remaining); |
265 | | - |
266 | | - // Reduce the current block length by the amount written |
267 | | - $block_length -= $continue_limit - $continue - $align; |
268 | | - |
269 | | - // If the current string was split then the next CONTINUE block |
270 | | - // should have the string continue flag (grbit) set unless the |
271 | | - // split string fits exactly into the remaining space. |
272 | | - // |
273 | | - if ($block_length > 0) { |
274 | | - $continue = 1; |
275 | | - } else { |
276 | | - $continue = 0; |
277 | | - } |
278 | | - } else { |
279 | | - // Not enough space to start the string in the current block |
280 | | - $block_length -= $continue_limit - $space_remaining - $continue; |
281 | | - $continue = 0; |
282 | | - } |
283 | | - |
284 | | - // Write the CONTINUE block header |
285 | | - if (!empty($this->_block_sizes)) { |
286 | | - $record = 0x003C; |
287 | | - $length = array_shift($tmp_block_sizes); |
288 | | - |
289 | | - $header = pack('vv', $record, $length); |
290 | | - if ($continue) { |
291 | | - $header .= pack('C', $encoding); |
292 | | - } |
293 | | - $this->_append($header); |
294 | | - } |
295 | | - |
296 | | - // If the string (or substr) is small enough we can write it in the |
297 | | - // new CONTINUE block. Else, go through the loop again to write it in |
298 | | - // one or more CONTINUE blocks |
299 | | - // |
300 | | - if ($block_length < $continue_limit) { |
301 | | - $this->_append($string); |
302 | | - $written = $block_length; |
303 | | - } else { |
304 | | - $written = 0; |
305 | | - } |
306 | | - } |
307 | | - } |
308 | | - } |
309 | | - |
\ No newline at end of file |
Index: trunk/extensions/QPoll/Excel/Excel_Worksheet.php |
— | — | @@ -364,13 +364,15 @@ |
365 | 365 | * @param mixed &$firstsheet The first worksheet in the workbook we belong to |
366 | 366 | * @param mixed &$url_format The default format for hyperlinks |
367 | 367 | * @param mixed &$parser The formula parser created for the Workbook |
| 368 | + * @param string $tmp_dir The path to the directory for temporary files |
368 | 369 | * @access private |
369 | 370 | */ |
370 | 371 | function __construct($BIFF_version, $name, |
371 | 372 | $index, &$activesheet, |
372 | 373 | &$firstsheet, &$str_total, |
373 | 374 | &$str_unique, &$str_table, |
374 | | - &$url_format, &$parser) |
| 375 | + &$url_format, &$parser, |
| 376 | + $tmp_dir) |
375 | 377 | { |
376 | 378 | // It needs to call its parent's constructor explicitly |
377 | 379 | parent::__construct(); |
— | — | @@ -461,6 +463,8 @@ |
462 | 464 | |
463 | 465 | $this->_dv = array(); |
464 | 466 | |
| 467 | + $this->_tmp_dir = $tmp_dir; |
| 468 | + |
465 | 469 | $this->_initialize(); |
466 | 470 | } |
467 | 471 | |
— | — | @@ -473,14 +477,32 @@ |
474 | 478 | */ |
475 | 479 | function _initialize() |
476 | 480 | { |
| 481 | + if ($this->_using_tmpfile == false) { |
| 482 | + return; |
| 483 | + } |
| 484 | + |
| 485 | + if ($this->_tmp_dir === '' && ini_get('open_basedir') === false) { |
| 486 | + // open_basedir restriction in effect - store data in memory |
| 487 | + // ToDo: Let the error actually have an effect somewhere |
| 488 | + $this->_using_tmpfile = false; |
| 489 | + return new PEAR_Error('Temp file could not be opened since open_basedir restriction in effect - please use setTmpDir() - using memory storage instead'); |
| 490 | + } |
| 491 | + |
477 | 492 | // Open tmp file for storing Worksheet data |
478 | | - $fh = tmpfile(); |
479 | | - if ($fh) { |
480 | | - // Store filehandle |
481 | | - $this->_filehandle = $fh; |
| 493 | + if ($this->_tmp_dir === '') { |
| 494 | + $fh = tmpfile(); |
482 | 495 | } else { |
| 496 | + // For people with open base dir restriction |
| 497 | + $tmpfilename = tempnam($this->_tmp_dir, "Spreadsheet_Excel_Writer"); |
| 498 | + $fh = @fopen($tmpfilename, "w+b"); |
| 499 | + } |
| 500 | + |
| 501 | + if ($fh === false) { |
483 | 502 | // If tmpfile() fails store data in memory |
484 | 503 | $this->_using_tmpfile = false; |
| 504 | + } else { |
| 505 | + // Store filehandle |
| 506 | + $this->_filehandle = $fh; |
485 | 507 | } |
486 | 508 | } |
487 | 509 | |
— | — | @@ -1155,9 +1177,6 @@ |
1156 | 1178 | } elseif (preg_match("/^=/", $token)) { |
1157 | 1179 | // Match formula |
1158 | 1180 | return $this->writeFormula($row, $col, $token, $format); |
1159 | | - } elseif (preg_match("/^@/", $token)) { |
1160 | | - // Match formula |
1161 | | - return $this->writeFormula($row, $col, $token, $format); |
1162 | 1181 | } elseif ($token == '') { |
1163 | 1182 | // Match blank |
1164 | 1183 | return $this->writeBlank($row, $col, $format); |
— | — | @@ -1319,15 +1338,17 @@ |
1320 | 1339 | $row = $match[2]; |
1321 | 1340 | |
1322 | 1341 | // Convert base26 column string to number |
1323 | | - $chars = split('', $col); |
| 1342 | + // empty split / explode always equals to false and produces a warning |
| 1343 | + //$chars = split('', $col); |
1324 | 1344 | $expn = 0; |
1325 | 1345 | $col = 0; |
1326 | 1346 | |
| 1347 | + /* equals to false |
1327 | 1348 | while ($chars) { |
1328 | 1349 | $char = array_pop($chars); // LS char first |
1329 | 1350 | $col += (ord($char) -ord('A') +1) * pow(26,$expn); |
1330 | 1351 | $expn++; |
1331 | | - } |
| 1352 | + } */ |
1332 | 1353 | |
1333 | 1354 | // Convert 1-index to zero-index |
1334 | 1355 | $row--; |
— | — | @@ -2879,7 +2900,7 @@ |
2880 | 2901 | $colcount = count($this->_colinfo); |
2881 | 2902 | for ($i = 0; $i < $colcount; $i++) { |
2882 | 2903 | // Skip cols without outline level info. |
2883 | | - if (count($col_level) >= 6) { |
| 2904 | + if (count($this->_colinfo[$i]) >= 6) { |
2884 | 2905 | $col_level = max($this->_colinfo[$i][5], $col_level); |
2885 | 2906 | } |
2886 | 2907 | } |
— | — | @@ -3499,4 +3520,3 @@ |
3500 | 3521 | } |
3501 | 3522 | } |
3502 | 3523 | } |
3503 | | -?> |
Index: trunk/extensions/QPoll/Excel/Excel_Writer.php |
— | — | @@ -101,4 +101,3 @@ |
102 | 102 | return $chr1 . $chr2 . $row; |
103 | 103 | } |
104 | 104 | } |
105 | | -?> |
Index: trunk/extensions/QPoll/Excel/OLE_PPS_File.php |
— | — | @@ -122,4 +122,3 @@ |
123 | 123 | $this->ole->getStream($this); |
124 | 124 | } |
125 | 125 | } |
126 | | -?> |
Index: trunk/extensions/QPoll/Excel/OLE_PPS.php |
— | — | @@ -219,4 +219,3 @@ |
220 | 220 | return $this->No; |
221 | 221 | } |
222 | 222 | } |
223 | | -?> |
Index: trunk/extensions/QPoll/Excel/OLE_PPS_Root.php |
— | — | @@ -483,4 +483,3 @@ |
484 | 484 | } |
485 | 485 | } |
486 | 486 | } |
487 | | -?> |
Index: trunk/extensions/QPoll/Excel/Excel_Validator.php |
— | — | @@ -226,5 +226,3 @@ |
227 | 227 | //$this->_formula1 = ...; |
228 | 228 | } |
229 | 229 | }*/ |
230 | | - |
231 | | -?> |
Index: trunk/extensions/QPoll/Excel/Excel_Format.php |
— | — | @@ -429,7 +429,7 @@ |
430 | 430 | |
431 | 431 | $header = pack("vv", $record, $length); |
432 | 432 | |
433 | | - $rotation = 0x00; |
| 433 | + $rotation = $this->_rotation; |
434 | 434 | $biff8_options = 0x00; |
435 | 435 | $data = pack("vvvC", $ifnt, $ifmt, $style, $align); |
436 | 436 | $data .= pack("CCC", $rotation, $biff8_options, $used_attrib); |
— | — | @@ -996,20 +996,32 @@ |
997 | 997 | $this->_rotation = 0; |
998 | 998 | break; |
999 | 999 | case 90: |
| 1000 | + if ($this->_BIFF_version == 0x0500) { |
1000 | 1001 | $this->_rotation = 3; |
| 1002 | + } elseif ($this->_BIFF_version == 0x0600) { |
| 1003 | + $this->_rotation = 180; |
| 1004 | + } |
1001 | 1005 | break; |
1002 | 1006 | case 270: |
| 1007 | + if ($this->_BIFF_version == 0x0500) { |
1003 | 1008 | $this->_rotation = 2; |
| 1009 | + } elseif ($this->_BIFF_version == 0x0600) { |
| 1010 | + $this->_rotation = 90; |
| 1011 | + } |
1004 | 1012 | break; |
1005 | 1013 | case -1: |
| 1014 | + if ($this->_BIFF_version == 0x0500) { |
1006 | 1015 | $this->_rotation = 1; |
| 1016 | + } elseif ($this->_BIFF_version == 0x0600) { |
| 1017 | + $this->_rotation = 255; |
| 1018 | + } |
1007 | 1019 | break; |
1008 | 1020 | default : |
1009 | 1021 | return $this->raiseError("Invalid value for angle.". |
1010 | 1022 | " Possible values are: 0, 90, 270 and -1 ". |
1011 | 1023 | "for stacking top-to-bottom."); |
1012 | | - //$this->_rotation = 0; |
1013 | | - //break; |
| 1024 | + $this->_rotation = 0; |
| 1025 | + break; |
1014 | 1026 | } |
1015 | 1027 | } |
1016 | 1028 | |
— | — | @@ -1099,4 +1111,3 @@ |
1100 | 1112 | $this->_font_name = $font_family; |
1101 | 1113 | } |
1102 | 1114 | } |
1103 | | -?> |
Index: trunk/extensions/QPoll/Excel/Excel_Parser.php |
— | — | @@ -92,6 +92,10 @@ |
93 | 93 | */ |
94 | 94 | define('SPREADSHEET_EXCEL_WRITER_NE', "<>"); |
95 | 95 | |
| 96 | +/** |
| 97 | +* * @const SPREADSHEET_EXCEL_WRITER_CONCAT token identifier for character "&" |
| 98 | +*/ |
| 99 | +define('SPREADSHEET_EXCEL_WRITER_CONCAT', "&"); |
96 | 100 | |
97 | 101 | require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
98 | 102 | |
— | — | @@ -663,15 +667,15 @@ |
664 | 668 | * @access private |
665 | 669 | * @param string $range An Excel range in the A1:A2 or A1..A2 format. |
666 | 670 | */ |
667 | | - function _convertRange2d($range) |
| 671 | + function _convertRange2d($range, $class=0) |
668 | 672 | { |
669 | | - $class = 2; // as far as I know, this is magick. |
670 | 673 | |
| 674 | + // TODO: possible class value 0,1,2 check Formula.pm |
671 | 675 | // Split the range into 2 cell refs |
672 | 676 | if (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\:([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) { |
673 | | - list($cell1, $cell2) = split(':', $range); |
| 677 | + list($cell1, $cell2) = explode(':', $range); |
674 | 678 | } elseif (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\.\.([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) { |
675 | | - list($cell1, $cell2) = split('\.\.', $range); |
| 679 | + list($cell1, $cell2) = explode('..', $range); |
676 | 680 | |
677 | 681 | } else { |
678 | 682 | // TODO: use real error codes |
— | — | @@ -717,7 +721,7 @@ |
718 | 722 | $class = 2; // as far as I know, this is magick. |
719 | 723 | |
720 | 724 | // Split the ref at the ! symbol |
721 | | - list($ext_ref, $range) = split('!', $token); |
| 725 | + list($ext_ref, $range) = explode('!', $token); |
722 | 726 | |
723 | 727 | // Convert the external reference part (different for BIFF8) |
724 | 728 | if ($this->_BIFF_version == 0x0500) { |
— | — | @@ -733,7 +737,7 @@ |
734 | 738 | } |
735 | 739 | |
736 | 740 | // Split the range into 2 cell refs |
737 | | - list($cell1, $cell2) = split(':', $range); |
| 741 | + list($cell1, $cell2) = explode(':', $range); |
738 | 742 | |
739 | 743 | // Convert the cell references |
740 | 744 | if (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/", $cell1)) { |
— | — | @@ -814,7 +818,7 @@ |
815 | 819 | $class = 2; // as far as I know, this is magick. |
816 | 820 | |
817 | 821 | // Split the ref at the ! symbol |
818 | | - list($ext_ref, $cell) = split('!', $cell); |
| 822 | + list($ext_ref, $cell) = explode('!', $cell); |
819 | 823 | |
820 | 824 | // Convert the external reference part (different for BIFF8) |
821 | 825 | if ($this->_BIFF_version == 0x0500) { |
— | — | @@ -861,7 +865,7 @@ |
862 | 866 | |
863 | 867 | // Check if there is a sheet range eg., Sheet1:Sheet2. |
864 | 868 | if (preg_match("/:/", $ext_ref)) { |
865 | | - list($sheet_name1, $sheet_name2) = split(':', $ext_ref); |
| 869 | + list($sheet_name1, $sheet_name2) = explode(':', $ext_ref); |
866 | 870 | |
867 | 871 | $sheet1 = $this->_getSheetIndex($sheet_name1); |
868 | 872 | if ($sheet1 == -1) { |
— | — | @@ -907,7 +911,7 @@ |
908 | 912 | |
909 | 913 | // Check if there is a sheet range eg., Sheet1:Sheet2. |
910 | 914 | if (preg_match("/:/", $ext_ref)) { |
911 | | - list($sheet_name1, $sheet_name2) = split(':', $ext_ref); |
| 915 | + list($sheet_name1, $sheet_name2) = explode(':', $ext_ref); |
912 | 916 | |
913 | 917 | $sheet1 = $this->_getSheetIndex($sheet_name1); |
914 | 918 | if ($sheet1 == -1) { |
— | — | @@ -1203,10 +1207,13 @@ |
1204 | 1208 | case SPREADSHEET_EXCEL_WRITER_NE: |
1205 | 1209 | return $token; |
1206 | 1210 | break; |
| 1211 | + case SPREADSHEET_EXCEL_WRITER_CONCAT: |
| 1212 | + return $token; |
| 1213 | + break; |
1207 | 1214 | default: |
1208 | 1215 | // if it's a reference |
1209 | 1216 | if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and |
1210 | | - !ereg("[0-9]",$this->_lookahead) and |
| 1217 | + !preg_match("/[0-9]/",$this->_lookahead) and |
1211 | 1218 | ($this->_lookahead != ':') and ($this->_lookahead != '.') and |
1212 | 1219 | ($this->_lookahead != '!')) |
1213 | 1220 | { |
— | — | @@ -1214,39 +1221,39 @@ |
1215 | 1222 | } |
1216 | 1223 | // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1) |
1217 | 1224 | elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and |
1218 | | - !ereg("[0-9]",$this->_lookahead) and |
| 1225 | + !preg_match("/[0-9]/",$this->_lookahead) and |
1219 | 1226 | ($this->_lookahead != ':') and ($this->_lookahead != '.')) |
1220 | 1227 | { |
1221 | 1228 | return $token; |
1222 | 1229 | } |
1223 | 1230 | // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1) |
1224 | 1231 | elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and |
1225 | | - !ereg("[0-9]",$this->_lookahead) and |
| 1232 | + !preg_match("/[0-9]/",$this->_lookahead) and |
1226 | 1233 | ($this->_lookahead != ':') and ($this->_lookahead != '.')) |
1227 | 1234 | { |
1228 | 1235 | return $token; |
1229 | 1236 | } |
1230 | 1237 | // if it's a range (A1:A2) |
1231 | 1238 | elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and |
1232 | | - !ereg("[0-9]",$this->_lookahead)) |
| 1239 | + !preg_match("/[0-9]/",$this->_lookahead)) |
1233 | 1240 | { |
1234 | 1241 | return $token; |
1235 | 1242 | } |
1236 | 1243 | // if it's a range (A1..A2) |
1237 | 1244 | elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and |
1238 | | - !ereg("[0-9]",$this->_lookahead)) |
| 1245 | + !preg_match("/[0-9]/",$this->_lookahead)) |
1239 | 1246 | { |
1240 | 1247 | return $token; |
1241 | 1248 | } |
1242 | 1249 | // If it's an external range like Sheet1!A1 or Sheet1:Sheet2!A1:B2 |
1243 | 1250 | elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and |
1244 | | - !ereg("[0-9]",$this->_lookahead)) |
| 1251 | + !preg_match("/[0-9]/",$this->_lookahead)) |
1245 | 1252 | { |
1246 | 1253 | return $token; |
1247 | 1254 | } |
1248 | 1255 | // If it's an external range like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2 |
1249 | 1256 | elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and |
1250 | | - !ereg("[0-9]",$this->_lookahead)) |
| 1257 | + !preg_match("/[0-9]/",$this->_lookahead)) |
1251 | 1258 | { |
1252 | 1259 | return $token; |
1253 | 1260 | } |
— | — | @@ -1258,12 +1265,12 @@ |
1259 | 1266 | return $token; |
1260 | 1267 | } |
1261 | 1268 | // If it's a string (of maximum 255 characters) |
1262 | | - elseif (ereg("^\"[^\"]{0,255}\"$",$token)) |
| 1269 | + elseif (preg_match("/^\"[^\"]{0,255}\"$/",$token)) |
1263 | 1270 | { |
1264 | 1271 | return $token; |
1265 | 1272 | } |
1266 | 1273 | // if it's a function call |
1267 | | - elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "(")) |
| 1274 | + elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "(")) |
1268 | 1275 | { |
1269 | 1276 | return $token; |
1270 | 1277 | } |
— | — | @@ -1347,7 +1354,14 @@ |
1348 | 1355 | return $result2; |
1349 | 1356 | } |
1350 | 1357 | $result = $this->_createTree('ptgNE', $result, $result2); |
| 1358 | + } elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_CONCAT) { |
| 1359 | + $this->_advance(); |
| 1360 | + $result2 = $this->_expression(); |
| 1361 | + if (PEAR::isError($result2)) { |
| 1362 | + return $result2; |
1351 | 1363 | } |
| 1364 | + $result = $this->_createTree('ptgConcat', $result, $result2); |
| 1365 | + } |
1352 | 1366 | return $result; |
1353 | 1367 | } |
1354 | 1368 | |
— | — | @@ -1363,7 +1377,7 @@ |
1364 | 1378 | function _expression() |
1365 | 1379 | { |
1366 | 1380 | // If it's a string return a string node |
1367 | | - if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token)) { |
| 1381 | + if (preg_match("/^\"[^\"]{0,255}\"$/", $this->_current_token)) { |
1368 | 1382 | $result = $this->_createTree($this->_current_token, '', ''); |
1369 | 1383 | $this->_advance(); |
1370 | 1384 | return $result; |
— | — | @@ -1521,7 +1535,7 @@ |
1522 | 1536 | return $result; |
1523 | 1537 | } |
1524 | 1538 | // if it's a function call |
1525 | | - elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token)) |
| 1539 | + elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token)) |
1526 | 1540 | { |
1527 | 1541 | $result = $this->_func(); |
1528 | 1542 | return $result; |
— | — | @@ -1686,4 +1700,3 @@ |
1687 | 1701 | return $polish; |
1688 | 1702 | } |
1689 | 1703 | } |
1690 | | -?> |
Index: trunk/extensions/QPoll/Excel/Excel_Workbook.php |
— | — | @@ -160,12 +160,6 @@ |
161 | 161 | var $_country_code; |
162 | 162 | |
163 | 163 | /** |
164 | | - * The temporary dir for storing the OLE file |
165 | | - * @var string |
166 | | - */ |
167 | | - var $_tmp_dir; |
168 | | - |
169 | | - /** |
170 | 164 | * number of bytes for sizeinfo of strings |
171 | 165 | * @var integer |
172 | 166 | */ |
— | — | @@ -207,7 +201,6 @@ |
208 | 202 | $this->_str_unique = 0; |
209 | 203 | $this->_str_table = array(); |
210 | 204 | $this->_setPaletteXl97(); |
211 | | - $this->_tmp_dir = ''; |
212 | 205 | } |
213 | 206 | |
214 | 207 | /** |
— | — | @@ -276,6 +269,7 @@ |
277 | 270 | $this->_tmp_format->_BIFF_version = $version; |
278 | 271 | $this->_url_format->_BIFF_version = $version; |
279 | 272 | $this->_parser->_BIFF_version = $version; |
| 273 | + $this->_codepage = 0x04B0; |
280 | 274 | |
281 | 275 | $total_worksheets = count($this->_worksheets); |
282 | 276 | // change version for all worksheets too |
— | — | @@ -343,7 +337,7 @@ |
344 | 338 | $this->_activesheet, $this->_firstsheet, |
345 | 339 | $this->_str_total, $this->_str_unique, |
346 | 340 | $this->_str_table, $this->_url_format, |
347 | | - $this->_parser); |
| 341 | + $this->_parser, $this->_tmp_dir); |
348 | 342 | |
349 | 343 | $this->_worksheets[$index] = &$worksheet; // Store ref for iterator |
350 | 344 | $this->_sheetnames[$index] = $name; // Store EXTERNSHEET names |
— | — | @@ -495,6 +489,10 @@ |
496 | 490 | */ |
497 | 491 | function _storeWorkbook() |
498 | 492 | { |
| 493 | + if (count($this->_worksheets) == 0) { |
| 494 | + return true; |
| 495 | + } |
| 496 | + |
499 | 497 | // Ensure that at least one worksheet has been selected. |
500 | 498 | if ($this->_activesheet == 0) { |
501 | 499 | $this->_worksheets[0]->selected = 1; |
— | — | @@ -560,22 +558,6 @@ |
561 | 559 | } |
562 | 560 | |
563 | 561 | /** |
564 | | - * Sets the temp dir used for storing the OLE file |
565 | | - * |
566 | | - * @access public |
567 | | - * @param string $dir The dir to be used as temp dir |
568 | | - * @return true if given dir is valid, false otherwise |
569 | | - */ |
570 | | - function setTempDir($dir) |
571 | | - { |
572 | | - if (is_dir($dir)) { |
573 | | - $this->_tmp_dir = $dir; |
574 | | - return true; |
575 | | - } |
576 | | - return false; |
577 | | - } |
578 | | - |
579 | | - /** |
580 | 562 | * Store the workbook in an OLE container |
581 | 563 | * |
582 | 564 | * @access private |
— | — | @@ -583,7 +565,11 @@ |
584 | 566 | */ |
585 | 567 | function _storeOLEFile() |
586 | 568 | { |
587 | | - $OLE = new OLE_PPS_File(OLE::Asc2Ucs('Book')); |
| 569 | + if($this->_BIFF_version == 0x0600) { |
| 570 | + $OLE = new OLE_PPS_File(OLE::Asc2Ucs('Workbook')); |
| 571 | + } else { |
| 572 | + $OLE = new OLE_PPS_File(OLE::Asc2Ucs('Book')); |
| 573 | + } |
588 | 574 | if ($this->_tmp_dir != '') { |
589 | 575 | $OLE->setTempDir($this->_tmp_dir); |
590 | 576 | } |
— | — | @@ -1311,8 +1297,7 @@ |
1312 | 1298 | 8228 : Maximum Excel97 block size |
1313 | 1299 | -4 : Length of block header |
1314 | 1300 | -8 : Length of additional SST header information |
1315 | | - -8 : Arbitrary number to keep within _add_continue() limit |
1316 | | - = 8208 |
| 1301 | + -8 : Arbitrary number to keep within _add_continue() limit = 8208 |
1317 | 1302 | */ |
1318 | 1303 | $continue_limit = 8208; |
1319 | 1304 | $block_length = 0; |
— | — | @@ -1601,4 +1586,3 @@ |
1602 | 1587 | } |
1603 | 1588 | } |
1604 | 1589 | } |
1605 | | -?> |
Index: trunk/extensions/QPoll/Excel/OLE.php |
— | — | @@ -567,4 +567,3 @@ |
568 | 568 | return floor($big_date); |
569 | 569 | } |
570 | 570 | } |
571 | | -?> |
Index: trunk/extensions/QPoll/Excel/OLE_ChainedBlockStream.php |
— | — | @@ -225,5 +225,3 @@ |
226 | 226 | // bool dir_rewinddir ( void ) |
227 | 227 | // bool dir_closedir ( void ) |
228 | 228 | } |
229 | | - |
230 | | -?> |
Index: trunk/extensions/QPoll/Excel/Excel_BIFFwriter.php |
— | — | @@ -85,6 +85,12 @@ |
86 | 86 | var $_limit; |
87 | 87 | |
88 | 88 | /** |
| 89 | + * The temporary dir for storing the OLE file |
| 90 | + * @var string |
| 91 | + */ |
| 92 | + var $_tmp_dir; |
| 93 | + |
| 94 | + /** |
89 | 95 | * Constructor |
90 | 96 | * |
91 | 97 | * @access public |
— | — | @@ -95,6 +101,7 @@ |
96 | 102 | $this->_data = ''; |
97 | 103 | $this->_datasize = 0; |
98 | 104 | $this->_limit = 2080; |
| 105 | + $this->_tmp_dir = ''; |
99 | 106 | // Set the byte order |
100 | 107 | $this->_setByteOrder(); |
101 | 108 | } |
— | — | @@ -234,5 +241,21 @@ |
235 | 242 | |
236 | 243 | return $tmp; |
237 | 244 | } |
| 245 | + |
| 246 | + /** |
| 247 | + * Sets the temp dir used for storing the OLE file |
| 248 | + * |
| 249 | + * @access public |
| 250 | + * @param string $dir The dir to be used as temp dir |
| 251 | + * @return true if given dir is valid, false otherwise |
| 252 | + */ |
| 253 | + function setTempDir($dir) |
| 254 | + { |
| 255 | + if (is_dir($dir)) { |
| 256 | + $this->_tmp_dir = $dir; |
| 257 | + return true; |
| 258 | + } |
| 259 | + return false; |
| 260 | + } |
| 261 | + |
238 | 262 | } |
239 | | -?> |
Index: trunk/extensions/QPoll/Excel/Console_Getopt.php |
— | — | @@ -1,32 +1,40 @@ |
2 | 2 | <?php |
3 | 3 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
4 | | -// +----------------------------------------------------------------------+ |
5 | | -// | PHP Version 5 | |
6 | | -// +----------------------------------------------------------------------+ |
7 | | -// | Copyright (c) 1997-2004 The PHP Group | |
8 | | -// +----------------------------------------------------------------------+ |
9 | | -// | This source file is subject to version 3.0 of the PHP license, | |
10 | | -// | that is bundled with this package in the file LICENSE, and is | |
11 | | -// | available through the world-wide-web at the following url: | |
12 | | -// | http://www.php.net/license/3_0.txt. | |
13 | | -// | If you did not receive a copy of the PHP license and are unable to | |
14 | | -// | obtain it through the world-wide-web, please send a note to | |
15 | | -// | license@php.net so we can mail you a copy immediately. | |
16 | | -// +----------------------------------------------------------------------+ |
17 | | -// | Author: Andrei Zmievski <andrei@php.net> | |
18 | | -// +----------------------------------------------------------------------+ |
19 | | -// |
20 | | -// $Id: Getopt.php,v 1.4 2007/06/12 14:58:56 cellog Exp $ |
| 4 | +/** |
| 5 | + * PHP Version 5 |
| 6 | + * |
| 7 | + * Copyright (c) 1997-2004 The PHP Group |
| 8 | + * |
| 9 | + * This source file is subject to version 3.0 of the PHP license, |
| 10 | + * that is bundled with this package in the file LICENSE, and is |
| 11 | + * available through the world-wide-web at the following url: |
| 12 | + * http://www.php.net/license/3_0.txt. |
| 13 | + * If you did not receive a copy of the PHP license and are unable to |
| 14 | + * obtain it through the world-wide-web, please send a note to |
| 15 | + * license@php.net so we can mail you a copy immediately. |
| 16 | + * |
| 17 | + * @category Console |
| 18 | + * @package Console_Getopt |
| 19 | + * @author Andrei Zmievski <andrei@php.net> |
| 20 | + * @license http://www.php.net/license/3_0.txt PHP 3.0 |
| 21 | + * @version CVS: $Id: Getopt.php 306067 2010-12-08 00:13:31Z dufuz $ |
| 22 | + * @link http://pear.php.net/package/Console_Getopt |
| 23 | + */ |
21 | 24 | |
22 | 25 | require_once( qp_Setup::$ExtDir . '/Excel/PEAR.php' ); |
23 | 26 | |
24 | 27 | /** |
25 | 28 | * Command-line options parsing class. |
26 | 29 | * |
27 | | - * @author Andrei Zmievski <andrei@php.net> |
28 | | - * |
| 30 | + * @category Console |
| 31 | + * @package Console_Getopt |
| 32 | + * @author Andrei Zmievski <andrei@php.net> |
| 33 | + * @license http://www.php.net/license/3_0.txt PHP 3.0 |
| 34 | + * @link http://pear.php.net/package/Console_Getopt |
29 | 35 | */ |
30 | | -class Console_Getopt { |
| 36 | +class Console_Getopt |
| 37 | +{ |
| 38 | + |
31 | 39 | /** |
32 | 40 | * Parses the command-line options. |
33 | 41 | * |
— | — | @@ -53,46 +61,61 @@ |
54 | 62 | * |
55 | 63 | * Most of the semantics of this function are based on GNU getopt_long(). |
56 | 64 | * |
57 | | - * @param array $args an array of command-line arguments |
58 | | - * @param string $short_options specifies the list of allowed short options |
59 | | - * @param array $long_options specifies the list of allowed long options |
| 65 | + * @param array $args an array of command-line arguments |
| 66 | + * @param string $short_options specifies the list of allowed short options |
| 67 | + * @param array $long_options specifies the list of allowed long options |
| 68 | + * @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option |
60 | 69 | * |
61 | 70 | * @return array two-element array containing the list of parsed options and |
62 | 71 | * the non-option arguments |
63 | | - * |
64 | 72 | * @access public |
65 | | - * |
66 | 73 | */ |
67 | | - function getopt2($args, $short_options, $long_options = null) |
| 74 | + function getopt2($args, $short_options, $long_options = null, $skip_unknown = false) |
68 | 75 | { |
69 | | - return Console_Getopt::doGetopt(2, $args, $short_options, $long_options); |
| 76 | + return Console_Getopt::doGetopt(2, $args, $short_options, $long_options, $skip_unknown); |
70 | 77 | } |
71 | 78 | |
72 | 79 | /** |
73 | 80 | * This function expects $args to start with the script name (POSIX-style). |
74 | 81 | * Preserved for backwards compatibility. |
| 82 | + * |
| 83 | + * @param array $args an array of command-line arguments |
| 84 | + * @param string $short_options specifies the list of allowed short options |
| 85 | + * @param array $long_options specifies the list of allowed long options |
| 86 | + * |
75 | 87 | * @see getopt2() |
76 | | - */ |
77 | | - function getopt($args, $short_options, $long_options = null) |
| 88 | + * @return array two-element array containing the list of parsed options and |
| 89 | + * the non-option arguments |
| 90 | + */ |
| 91 | + function getopt($args, $short_options, $long_options = null, $skip_unknown = false) |
78 | 92 | { |
79 | | - return Console_Getopt::doGetopt(1, $args, $short_options, $long_options); |
| 93 | + return Console_Getopt::doGetopt(1, $args, $short_options, $long_options, $skip_unknown); |
80 | 94 | } |
81 | 95 | |
82 | 96 | /** |
83 | 97 | * The actual implementation of the argument parsing code. |
| 98 | + * |
| 99 | + * @param int $version Version to use |
| 100 | + * @param array $args an array of command-line arguments |
| 101 | + * @param string $short_options specifies the list of allowed short options |
| 102 | + * @param array $long_options specifies the list of allowed long options |
| 103 | + * @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option |
| 104 | + * |
| 105 | + * @return array |
84 | 106 | */ |
85 | | - function doGetopt($version, $args, $short_options, $long_options = null) |
| 107 | + function doGetopt($version, $args, $short_options, $long_options = null, $skip_unknown = false) |
86 | 108 | { |
87 | 109 | // in case you pass directly readPHPArgv() as the first arg |
88 | 110 | if (PEAR::isError($args)) { |
89 | 111 | return $args; |
90 | 112 | } |
| 113 | + |
91 | 114 | if (empty($args)) { |
92 | 115 | return array(array(), array()); |
93 | 116 | } |
94 | | - $opts = array(); |
95 | | - $non_opts = array(); |
96 | 117 | |
| 118 | + $non_opts = $opts = array(); |
| 119 | + |
97 | 120 | settype($args, 'array'); |
98 | 121 | |
99 | 122 | if ($long_options) { |
— | — | @@ -111,7 +134,6 @@ |
112 | 135 | |
113 | 136 | reset($args); |
114 | 137 | while (list($i, $arg) = each($args)) { |
115 | | - |
116 | 138 | /* The special element '--' means explicit end of |
117 | 139 | options. Treat the rest of the arguments as non-options |
118 | 140 | and end the loop. */ |
— | — | @@ -124,17 +146,27 @@ |
125 | 147 | $non_opts = array_merge($non_opts, array_slice($args, $i)); |
126 | 148 | break; |
127 | 149 | } elseif (strlen($arg) > 1 && $arg{1} == '-') { |
128 | | - $error = Console_Getopt::_parseLongOption(substr($arg, 2), $long_options, $opts, $args); |
129 | | - if (PEAR::isError($error)) |
| 150 | + $error = Console_Getopt::_parseLongOption(substr($arg, 2), |
| 151 | + $long_options, |
| 152 | + $opts, |
| 153 | + $args, |
| 154 | + $skip_unknown); |
| 155 | + if (PEAR::isError($error)) { |
130 | 156 | return $error; |
| 157 | + } |
131 | 158 | } elseif ($arg == '-') { |
132 | 159 | // - is stdin |
133 | 160 | $non_opts = array_merge($non_opts, array_slice($args, $i)); |
134 | 161 | break; |
135 | 162 | } else { |
136 | | - $error = Console_Getopt::_parseShortOption(substr($arg, 1), $short_options, $opts, $args); |
137 | | - if (PEAR::isError($error)) |
| 163 | + $error = Console_Getopt::_parseShortOption(substr($arg, 1), |
| 164 | + $short_options, |
| 165 | + $opts, |
| 166 | + $args, |
| 167 | + $skip_unknown); |
| 168 | + if (PEAR::isError($error)) { |
138 | 169 | return $error; |
| 170 | + } |
139 | 171 | } |
140 | 172 | } |
141 | 173 | |
— | — | @@ -142,19 +174,31 @@ |
143 | 175 | } |
144 | 176 | |
145 | 177 | /** |
| 178 | + * Parse short option |
| 179 | + * |
| 180 | + * @param string $arg Argument |
| 181 | + * @param string[] $short_options Available short options |
| 182 | + * @param string[][] &$opts |
| 183 | + * @param string[] &$args |
| 184 | + * @param boolean $skip_unknown suppresses Console_Getopt: unrecognized option |
| 185 | + * |
146 | 186 | * @access private |
147 | | - * |
| 187 | + * @return void |
148 | 188 | */ |
149 | | - function _parseShortOption($arg, $short_options, &$opts, &$args) |
| 189 | + function _parseShortOption($arg, $short_options, &$opts, &$args, $skip_unknown) |
150 | 190 | { |
151 | 191 | for ($i = 0; $i < strlen($arg); $i++) { |
152 | | - $opt = $arg{$i}; |
| 192 | + $opt = $arg{$i}; |
153 | 193 | $opt_arg = null; |
154 | 194 | |
155 | 195 | /* Try to find the short option in the specifier string. */ |
156 | | - if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':') |
157 | | - { |
158 | | - return PEAR::raiseError("Console_Getopt: unrecognized option -- $opt"); |
| 196 | + if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':') { |
| 197 | + if ($skip_unknown === true) { |
| 198 | + break; |
| 199 | + } |
| 200 | + |
| 201 | + $msg = "Console_Getopt: unrecognized option -- $opt"; |
| 202 | + return PEAR::raiseError($msg); |
159 | 203 | } |
160 | 204 | |
161 | 205 | if (strlen($spec) > 1 && $spec{1} == ':') { |
— | — | @@ -173,11 +217,14 @@ |
174 | 218 | break; |
175 | 219 | } else if (list(, $opt_arg) = each($args)) { |
176 | 220 | /* Else use the next argument. */; |
177 | | - if (Console_Getopt::_isShortOpt($opt_arg) || Console_Getopt::_isLongOpt($opt_arg)) { |
178 | | - return PEAR::raiseError("Console_Getopt: option requires an argument -- $opt"); |
| 221 | + if (Console_Getopt::_isShortOpt($opt_arg) |
| 222 | + || Console_Getopt::_isLongOpt($opt_arg)) { |
| 223 | + $msg = "option requires an argument --$opt"; |
| 224 | + return PEAR::raiseError("Console_Getopt:" . $msg); |
179 | 225 | } |
180 | 226 | } else { |
181 | | - return PEAR::raiseError("Console_Getopt: option requires an argument -- $opt"); |
| 227 | + $msg = "option requires an argument --$opt"; |
| 228 | + return PEAR::raiseError("Console_Getopt:" . $msg); |
182 | 229 | } |
183 | 230 | } |
184 | 231 | } |
— | — | @@ -187,36 +234,54 @@ |
188 | 235 | } |
189 | 236 | |
190 | 237 | /** |
| 238 | + * Checks if an argument is a short option |
| 239 | + * |
| 240 | + * @param string $arg Argument to check |
| 241 | + * |
191 | 242 | * @access private |
192 | | - * |
| 243 | + * @return bool |
193 | 244 | */ |
194 | 245 | function _isShortOpt($arg) |
195 | 246 | { |
196 | | - return strlen($arg) == 2 && $arg[0] == '-' && preg_match('/[a-zA-Z]/', $arg[1]); |
| 247 | + return strlen($arg) == 2 && $arg[0] == '-' |
| 248 | + && preg_match('/[a-zA-Z]/', $arg[1]); |
197 | 249 | } |
198 | 250 | |
199 | 251 | /** |
| 252 | + * Checks if an argument is a long option |
| 253 | + * |
| 254 | + * @param string $arg Argument to check |
| 255 | + * |
200 | 256 | * @access private |
201 | | - * |
| 257 | + * @return bool |
202 | 258 | */ |
203 | 259 | function _isLongOpt($arg) |
204 | 260 | { |
205 | 261 | return strlen($arg) > 2 && $arg[0] == '-' && $arg[1] == '-' && |
206 | | - preg_match('/[a-zA-Z]+$/', substr($arg, 2)); |
| 262 | + preg_match('/[a-zA-Z]+$/', substr($arg, 2)); |
207 | 263 | } |
208 | 264 | |
209 | 265 | /** |
| 266 | + * Parse long option |
| 267 | + * |
| 268 | + * @param string $arg Argument |
| 269 | + * @param string[] $long_options Available long options |
| 270 | + * @param string[][] &$opts |
| 271 | + * @param string[] &$args |
| 272 | + * |
210 | 273 | * @access private |
211 | | - * |
| 274 | + * @return void|PEAR_Error |
212 | 275 | */ |
213 | | - function _parseLongOption($arg, $long_options, &$opts, &$args) |
| 276 | + function _parseLongOption($arg, $long_options, &$opts, &$args, $skip_unknown) |
214 | 277 | { |
215 | 278 | @list($opt, $opt_arg) = explode('=', $arg, 2); |
| 279 | + |
216 | 280 | $opt_len = strlen($opt); |
217 | 281 | |
218 | 282 | for ($i = 0; $i < count($long_options); $i++) { |
219 | 283 | $long_opt = $long_options[$i]; |
220 | 284 | $opt_start = substr($long_opt, 0, $opt_len); |
| 285 | + |
221 | 286 | $long_opt_name = str_replace('=', '', $long_opt); |
222 | 287 | |
223 | 288 | /* Option doesn't match. Go on to the next one. */ |
— | — | @@ -224,7 +289,7 @@ |
225 | 290 | continue; |
226 | 291 | } |
227 | 292 | |
228 | | - $opt_rest = substr($long_opt, $opt_len); |
| 293 | + $opt_rest = substr($long_opt, $opt_len); |
229 | 294 | |
230 | 295 | /* Check that the options uniquely matches one of the allowed |
231 | 296 | options. */ |
— | — | @@ -233,12 +298,15 @@ |
234 | 299 | } else { |
235 | 300 | $next_option_rest = ''; |
236 | 301 | } |
| 302 | + |
237 | 303 | if ($opt_rest != '' && $opt{0} != '=' && |
238 | 304 | $i + 1 < count($long_options) && |
239 | 305 | $opt == substr($long_options[$i+1], 0, $opt_len) && |
240 | 306 | $next_option_rest != '' && |
241 | 307 | $next_option_rest{0} != '=') { |
242 | | - return PEAR::raiseError("Console_Getopt: option --$opt is ambiguous"); |
| 308 | + |
| 309 | + $msg = "Console_Getopt: option --$opt is ambiguous"; |
| 310 | + return PEAR::raiseError($msg); |
243 | 311 | } |
244 | 312 | |
245 | 313 | if (substr($long_opt, -1) == '=') { |
— | — | @@ -246,37 +314,47 @@ |
247 | 315 | /* Long option requires an argument. |
248 | 316 | Take the next argument if one wasn't specified. */; |
249 | 317 | if (!strlen($opt_arg) && !(list(, $opt_arg) = each($args))) { |
250 | | - return PEAR::raiseError("Console_Getopt: option --$opt requires an argument"); |
| 318 | + $msg = "Console_Getopt: option requires an argument --$opt"; |
| 319 | + return PEAR::raiseError($msg); |
251 | 320 | } |
252 | | - if (Console_Getopt::_isShortOpt($opt_arg) || Console_Getopt::_isLongOpt($opt_arg)) { |
253 | | - return PEAR::raiseError("Console_Getopt: option requires an argument --$opt"); |
| 321 | + |
| 322 | + if (Console_Getopt::_isShortOpt($opt_arg) |
| 323 | + || Console_Getopt::_isLongOpt($opt_arg)) { |
| 324 | + $msg = "Console_Getopt: option requires an argument --$opt"; |
| 325 | + return PEAR::raiseError($msg); |
254 | 326 | } |
255 | 327 | } |
256 | 328 | } else if ($opt_arg) { |
257 | | - return PEAR::raiseError("Console_Getopt: option --$opt doesn't allow an argument"); |
| 329 | + $msg = "Console_Getopt: option --$opt doesn't allow an argument"; |
| 330 | + return PEAR::raiseError($msg); |
258 | 331 | } |
259 | 332 | |
260 | 333 | $opts[] = array('--' . $opt, $opt_arg); |
261 | 334 | return; |
262 | 335 | } |
263 | 336 | |
| 337 | + if ($skip_unknown === true) { |
| 338 | + return; |
| 339 | + } |
| 340 | + |
264 | 341 | return PEAR::raiseError("Console_Getopt: unrecognized option --$opt"); |
265 | 342 | } |
266 | 343 | |
267 | 344 | /** |
268 | | - * Safely read the $argv PHP array across different PHP configurations. |
269 | | - * Will take care on register_globals and register_argc_argv ini directives |
270 | | - * |
271 | | - * @access public |
272 | | - * @return mixed the $argv PHP array or PEAR error if not registered |
273 | | - */ |
| 345 | + * Safely read the $argv PHP array across different PHP configurations. |
| 346 | + * Will take care on register_globals and register_argc_argv ini directives |
| 347 | + * |
| 348 | + * @access public |
| 349 | + * @return mixed the $argv PHP array or PEAR error if not registered |
| 350 | + */ |
274 | 351 | function readPHPArgv() |
275 | 352 | { |
276 | 353 | global $argv; |
277 | 354 | if (!is_array($argv)) { |
278 | 355 | if (!@is_array($_SERVER['argv'])) { |
279 | 356 | if (!@is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) { |
280 | | - return PEAR::raiseError("Console_Getopt: Could not read cmd args (register_argc_argv=Off?)"); |
| 357 | + $msg = "Could not read cmd args (register_argc_argv=Off?)"; |
| 358 | + return PEAR::raiseError("Console_Getopt: " . $msg); |
281 | 359 | } |
282 | 360 | return $GLOBALS['HTTP_SERVER_VARS']['argv']; |
283 | 361 | } |
— | — | @@ -285,6 +363,4 @@ |
286 | 364 | return $argv; |
287 | 365 | } |
288 | 366 | |
289 | | -} |
290 | | - |
291 | | -?> |
| 367 | +} |
\ No newline at end of file |
Index: trunk/extensions/QPoll/Excel/System.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | * @author Tomas V.V.Cox <cox@idecnet.com> |
11 | 11 | * @copyright 1997-2009 The Authors |
12 | 12 | * @license http://opensource.org/licenses/bsd-license.php New BSD License |
13 | | - * @version CVS: $Id: System.php,v 1.66 2009/02/24 23:52:56 dufuz Exp $ |
| 13 | + * @version CVS: $Id: System.php 276386 2009-02-24 23:52:56Z dufuz $ |
14 | 14 | * @link http://pear.php.net/package/PEAR |
15 | 15 | * @since File available since Release 0.1 |
16 | 16 | */ |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | * @author Tomas V.V. Cox <cox@idecnet.com> |
53 | 53 | * @copyright 1997-2006 The PHP Group |
54 | 54 | * @license http://opensource.org/licenses/bsd-license.php New BSD License |
55 | | -* @version Release: 1.8.1 |
| 55 | +* @version Release: 1.9.1 |
56 | 56 | * @link http://pear.php.net/package/PEAR |
57 | 57 | * @since Class available since Release 0.1 |
58 | 58 | * @static |
Index: trunk/extensions/QPoll/Excel/readme.txt |
— | — | @@ -2,25 +2,17 @@ |
3 | 3 | |
4 | 4 | Uses the following PEAR classes: |
5 | 5 | |
6 | | -PEAR-1.8.1.tgz |
| 6 | +PEAR-1.9.1.tgz |
| 7 | +Console_Getopt-1.3.0.tgz |
7 | 8 | OLE-1.0.0RC1.tgz |
8 | | -Spreadsheet_Excel_Writer-0.9.1.tgz |
| 9 | +Spreadsheet_Excel_Writer-0.9.2.tgz |
9 | 10 | |
10 | 11 | Nested filename paths are replaced to longer filenames with underscores, because I find deep nesting unhandy. |
11 | 12 | require_once() and include_once() calls are made relative from qp_Setup::$ExtDir extension's property. |
12 | 13 | |
13 | | -Spreadsheet_Excel_Writer-0.9.1 has a bug related to UTF16-LE string cell data encoding. |
14 | | -This bug can cause corruption of exported XLS files when non-ASCII set of codes |
15 | | -(such as Cyrillic or Chinesse) are used in polls. |
| 14 | +2009-09-18: patch to Excel_Workbook.php |
| 15 | +Removed "& new" (create object by reference) because it is incompatible with future versions of PHP |
16 | 16 | |
17 | | -The following path has been applied to 'Excel_Workbook.php' to fix this problem: |
18 | | -http://blog.teatime.com.tw/post/1/111 |
| 17 | +2010-12-19: tweaked for PHP 5.3 in E_STRICT mode |
19 | 18 | |
20 | | -The patch still hasn't been merged into PEAR SVN (2009, april 27th ). |
21 | | -Watch these bugreports for further information: |
22 | | -http://pear.php.net/bugs/bug.php?id=1572 |
23 | | -http://pear.php.net/bugs/bug.php?id=2159 |
24 | | - |
25 | | -18.09.2009: patch to Excel_Workbook.php |
26 | | -Removed "& new" (create object by reference) because it is incompatible with future versions of PHP |
27 | | -19.12.2010: tweaked for PHP 5.3 in E_STRICT mode |
\ No newline at end of file |
| 19 | +2011-02-02: get rid of additional PHP 5.3 deprecations; upgrade classes to latest PEAR version |
Index: trunk/extensions/QPoll/Excel/PEAR.php |
— | — | @@ -12,9 +12,9 @@ |
13 | 13 | * @author Stig Bakken <ssb@php.net> |
14 | 14 | * @author Tomas V.V.Cox <cox@idecnet.com> |
15 | 15 | * @author Greg Beaver <cellog@php.net> |
16 | | - * @copyright 1997-2009 The Authors |
| 16 | + * @copyright 1997-2010 The Authors |
17 | 17 | * @license http://opensource.org/licenses/bsd-license.php New BSD License |
18 | | - * @version CVS: $Id: PEAR.php,v 1.112 2009/04/15 04:05:13 dufuz Exp $ |
| 18 | + * @version CVS: $Id: PEAR.php 299159 2010-05-08 22:32:52Z dufuz $ |
19 | 19 | * @link http://pear.php.net/package/PEAR |
20 | 20 | * @since File available since Release 0.1 |
21 | 21 | */ |
— | — | @@ -78,7 +78,7 @@ |
79 | 79 | * @author Greg Beaver <cellog@php.net> |
80 | 80 | * @copyright 1997-2006 The PHP Group |
81 | 81 | * @license http://opensource.org/licenses/bsd-license.php New BSD License |
82 | | - * @version Release: 1.8.1 |
| 82 | + * @version Release: 1.9.1 |
83 | 83 | * @link http://pear.php.net/package/PEAR |
84 | 84 | * @see PEAR_Error |
85 | 85 | * @since Class available since PHP 4.0.2 |
— | — | @@ -158,9 +158,11 @@ |
159 | 159 | if ($this->_debug) { |
160 | 160 | print "PEAR constructor called, class=$classname\n"; |
161 | 161 | } |
| 162 | + |
162 | 163 | if ($error_class !== null) { |
163 | 164 | $this->_error_class = $error_class; |
164 | 165 | } |
| 166 | + |
165 | 167 | while ($classname && strcasecmp($classname, "pear")) { |
166 | 168 | $destructor = "_$classname"; |
167 | 169 | if (method_exists($this, $destructor)) { |
— | — | @@ -319,7 +321,6 @@ |
320 | 322 | * |
321 | 323 | * @since PHP 4.0.5 |
322 | 324 | */ |
323 | | - |
324 | 325 | function setErrorHandling($mode = null, $options = null) |
325 | 326 | { |
326 | 327 | if (isset($this) && is_a($this, 'PEAR')) { |
— | — | @@ -382,7 +383,7 @@ |
383 | 384 | } else { |
384 | 385 | array_push($this->_expected_errors, array($code)); |
385 | 386 | } |
386 | | - return sizeof($this->_expected_errors); |
| 387 | + return count($this->_expected_errors); |
387 | 388 | } |
388 | 389 | |
389 | 390 | // }}} |
— | — | @@ -413,8 +414,7 @@ |
414 | 415 | function _checkDelExpect($error_code) |
415 | 416 | { |
416 | 417 | $deleted = false; |
417 | | - |
418 | | - foreach ($this->_expected_errors AS $key => $error_array) { |
| 418 | + foreach ($this->_expected_errors as $key => $error_array) { |
419 | 419 | if (in_array($error_code, $error_array)) { |
420 | 420 | unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); |
421 | 421 | $deleted = true; |
— | — | @@ -425,6 +425,7 @@ |
426 | 426 | unset($this->_expected_errors[$key]); |
427 | 427 | } |
428 | 428 | } |
| 429 | + |
429 | 430 | return $deleted; |
430 | 431 | } |
431 | 432 | |
— | — | @@ -444,24 +445,20 @@ |
445 | 446 | { |
446 | 447 | $deleted = false; |
447 | 448 | if ((is_array($error_code) && (0 != count($error_code)))) { |
448 | | - // $error_code is a non-empty array here; |
449 | | - // we walk through it trying to unset all |
450 | | - // values |
451 | | - foreach($error_code as $key => $error) { |
452 | | - if ($this->_checkDelExpect($error)) { |
453 | | - $deleted = true; |
454 | | - } else { |
455 | | - $deleted = false; |
456 | | - } |
| 449 | + // $error_code is a non-empty array here; we walk through it trying |
| 450 | + // to unset all values |
| 451 | + foreach ($error_code as $key => $error) { |
| 452 | + $deleted = $this->_checkDelExpect($error) ? true : false; |
457 | 453 | } |
| 454 | + |
458 | 455 | return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME |
459 | 456 | } elseif (!empty($error_code)) { |
460 | 457 | // $error_code comes alone, trying to unset it |
461 | 458 | if ($this->_checkDelExpect($error_code)) { |
462 | 459 | return true; |
463 | | - } else { |
464 | | - return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME |
465 | | - } |
| 460 | + } |
| 461 | + |
| 462 | + return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME |
466 | 463 | } |
467 | 464 | |
468 | 465 | // $error_code is empty |
— | — | @@ -525,10 +522,16 @@ |
526 | 523 | $message = $message->getMessage(); |
527 | 524 | } |
528 | 525 | |
529 | | - if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) { |
| 526 | + if ( |
| 527 | + isset($this) && |
| 528 | + isset($this->_expected_errors) && |
| 529 | + count($this->_expected_errors) > 0 && |
| 530 | + count($exp = end($this->_expected_errors)) |
| 531 | + ) { |
530 | 532 | if ($exp[0] == "*" || |
531 | 533 | (is_int(reset($exp)) && in_array($code, $exp)) || |
532 | | - (is_string(reset($exp)) && in_array($message, $exp))) { |
| 534 | + (is_string(reset($exp)) && in_array($message, $exp)) |
| 535 | + ) { |
533 | 536 | $mode = PEAR_ERROR_RETURN; |
534 | 537 | } |
535 | 538 | } |
— | — | @@ -576,12 +579,19 @@ |
577 | 580 | * Simpler form of raiseError with fewer options. In most cases |
578 | 581 | * message, code and userinfo are enough. |
579 | 582 | * |
580 | | - * @param string $message |
| 583 | + * @param mixed $message a text error message or a PEAR error object |
581 | 584 | * |
| 585 | + * @param int $code a numeric error code (it is up to your class |
| 586 | + * to define these if you want to use codes) |
| 587 | + * |
| 588 | + * @param string $userinfo If you need to pass along for example debug |
| 589 | + * information, this parameter is meant for that. |
| 590 | + * |
| 591 | + * @access public |
| 592 | + * @return object a PEAR error object |
| 593 | + * @see PEAR::raiseError |
582 | 594 | */ |
583 | | - function &throwError($message = null, |
584 | | - $code = null, |
585 | | - $userinfo = null) |
| 595 | + function &throwError($message = null, $code = null, $userinfo = null) |
586 | 596 | { |
587 | 597 | if (isset($this) && is_a($this, 'PEAR')) { |
588 | 598 | $a = &$this->raiseError($message, $code, null, null, $userinfo); |
— | — | @@ -735,28 +745,32 @@ |
736 | 746 | */ |
737 | 747 | function loadExtension($ext) |
738 | 748 | { |
739 | | - if (!extension_loaded($ext)) { |
740 | | - // if either returns true dl() will produce a FATAL error, stop that |
741 | | - if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { |
742 | | - return false; |
743 | | - } |
| 749 | + if (extension_loaded($ext)) { |
| 750 | + return true; |
| 751 | + } |
744 | 752 | |
745 | | - if (OS_WINDOWS) { |
746 | | - $suffix = '.dll'; |
747 | | - } elseif (PHP_OS == 'HP-UX') { |
748 | | - $suffix = '.sl'; |
749 | | - } elseif (PHP_OS == 'AIX') { |
750 | | - $suffix = '.a'; |
751 | | - } elseif (PHP_OS == 'OSX') { |
752 | | - $suffix = '.bundle'; |
753 | | - } else { |
754 | | - $suffix = '.so'; |
755 | | - } |
| 753 | + // if either returns true dl() will produce a FATAL error, stop that |
| 754 | + if ( |
| 755 | + function_exists('dl') === false || |
| 756 | + ini_get('enable_dl') != 1 || |
| 757 | + ini_get('safe_mode') == 1 |
| 758 | + ) { |
| 759 | + return false; |
| 760 | + } |
756 | 761 | |
757 | | - return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); |
| 762 | + if (OS_WINDOWS) { |
| 763 | + $suffix = '.dll'; |
| 764 | + } elseif (PHP_OS == 'HP-UX') { |
| 765 | + $suffix = '.sl'; |
| 766 | + } elseif (PHP_OS == 'AIX') { |
| 767 | + $suffix = '.a'; |
| 768 | + } elseif (PHP_OS == 'OSX') { |
| 769 | + $suffix = '.bundle'; |
| 770 | + } else { |
| 771 | + $suffix = '.so'; |
758 | 772 | } |
759 | 773 | |
760 | | - return true; |
| 774 | + return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); |
761 | 775 | } |
762 | 776 | |
763 | 777 | // }}} |
— | — | @@ -803,7 +817,11 @@ |
804 | 818 | } |
805 | 819 | |
806 | 820 | // Now call the shutdown functions |
807 | | - if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) { |
| 821 | + if ( |
| 822 | + isset($GLOBALS['_PEAR_shutdown_funcs']) && |
| 823 | + is_array($GLOBALS['_PEAR_shutdown_funcs']) && |
| 824 | + !empty($GLOBALS['_PEAR_shutdown_funcs']) |
| 825 | + ) { |
808 | 826 | foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { |
809 | 827 | call_user_func_array($value[0], $value[1]); |
810 | 828 | } |
— | — | @@ -823,7 +841,7 @@ |
824 | 842 | * @author Gregory Beaver <cellog@php.net> |
825 | 843 | * @copyright 1997-2006 The PHP Group |
826 | 844 | * @license http://opensource.org/licenses/bsd-license.php New BSD License |
827 | | - * @version Release: 1.8.1 |
| 845 | + * @version Release: 1.9.1 |
828 | 846 | * @link http://pear.php.net/manual/en/core.pear.pear-error.php |
829 | 847 | * @see PEAR::raiseError(), PEAR::throwError() |
830 | 848 | * @since Class available since PHP 4.0.2 |
— | — | @@ -886,6 +904,7 @@ |
887 | 905 | unset($this->backtrace[0]['object']); |
888 | 906 | } |
889 | 907 | } |
| 908 | + |
890 | 909 | if ($mode & PEAR_ERROR_CALLBACK) { |
891 | 910 | $this->level = E_USER_NOTICE; |
892 | 911 | $this->callback = $options; |
— | — | @@ -896,6 +915,7 @@ |
897 | 916 | $this->level = $options; |
898 | 917 | $this->callback = null; |
899 | 918 | } |
| 919 | + |
900 | 920 | if ($this->mode & PEAR_ERROR_PRINT) { |
901 | 921 | if (is_null($options) || is_int($options)) { |
902 | 922 | $format = "%s"; |
— | — | @@ -904,9 +924,11 @@ |
905 | 925 | } |
906 | 926 | printf($format, $this->getMessage()); |
907 | 927 | } |
| 928 | + |
908 | 929 | if ($this->mode & PEAR_ERROR_TRIGGER) { |
909 | 930 | trigger_error($this->getMessage(), $this->level); |
910 | 931 | } |
| 932 | + |
911 | 933 | if ($this->mode & PEAR_ERROR_DIE) { |
912 | 934 | $msg = $this->getMessage(); |
913 | 935 | if (is_null($options) || is_int($options)) { |
— | — | @@ -919,11 +941,11 @@ |
920 | 942 | } |
921 | 943 | die(sprintf($format, $msg)); |
922 | 944 | } |
923 | | - if ($this->mode & PEAR_ERROR_CALLBACK) { |
924 | | - if (is_callable($this->callback)) { |
925 | | - call_user_func($this->callback, $this); |
926 | | - } |
| 945 | + |
| 946 | + if ($this->mode & PEAR_ERROR_CALLBACK && is_callable($this->callback)) { |
| 947 | + call_user_func($this->callback, $this); |
927 | 948 | } |
| 949 | + |
928 | 950 | if ($this->mode & PEAR_ERROR_EXCEPTION) { |
929 | 951 | trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); |
930 | 952 | eval('$e = new Exception($this->message, $this->code);throw($e);'); |
— | — | @@ -939,7 +961,8 @@ |
940 | 962 | * @return int error mode |
941 | 963 | * @access public |
942 | 964 | */ |
943 | | - function getMode() { |
| 965 | + function getMode() |
| 966 | + { |
944 | 967 | return $this->mode; |
945 | 968 | } |
946 | 969 | |
— | — | @@ -952,7 +975,8 @@ |
953 | 976 | * @return mixed callback function or object/method array |
954 | 977 | * @access public |
955 | 978 | */ |
956 | | - function getCallback() { |
| 979 | + function getCallback() |
| 980 | + { |
957 | 981 | return $this->callback; |
958 | 982 | } |
959 | 983 | |
— | — | @@ -1077,7 +1101,8 @@ |
1078 | 1102 | * @return string a string with an object summary |
1079 | 1103 | * @access public |
1080 | 1104 | */ |
1081 | | - function toString() { |
| 1105 | + function toString() |
| 1106 | + { |
1082 | 1107 | $modes = array(); |
1083 | 1108 | $levels = array(E_USER_NOTICE => 'notice', |
1084 | 1109 | E_USER_WARNING => 'warning', |