@@ -91,7 +91,7 @@ |
||
91 | 91 | /** |
92 | 92 | * Can the current PHPExcel_Reader_IReader read the file? |
93 | 93 | * |
94 | - * @param string $pFileName |
|
94 | + * @param string $pFilename |
|
95 | 95 | * @return boolean |
96 | 96 | * @throws Exception |
97 | 97 | */ |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** PHPExcel root directory */ |
30 | -if (!defined('PHPEXCEL_ROOT')) { |
|
30 | +if ( ! defined('PHPEXCEL_ROOT')) { |
|
31 | 31 | /** |
32 | 32 | * @ignore |
33 | 33 | */ |
34 | - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); |
|
35 | - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); |
|
34 | + define('PHPEXCEL_ROOT', dirname(__FILE__).'/../../'); |
|
35 | + require(PHPEXCEL_ROOT.'PHPExcel/Autoloader.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @var string |
51 | 51 | */ |
52 | - private $_inputEncoding = 'ANSI'; |
|
52 | + private $_inputEncoding = 'ANSI'; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Sheet index to read |
56 | 56 | * |
57 | 57 | * @var int |
58 | 58 | */ |
59 | - private $_sheetIndex = 0; |
|
59 | + private $_sheetIndex = 0; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Formats |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * Create a new PHPExcel_Reader_SYLK |
85 | 85 | */ |
86 | 86 | public function __construct() { |
87 | - $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); |
|
87 | + $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | public function canRead($pFilename) |
99 | 99 | { |
100 | 100 | // Check if file exists |
101 | - if (!file_exists($pFilename)) { |
|
102 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
101 | + if ( ! file_exists($pFilename)) { |
|
102 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Read sample data (first 2 KB will do) |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | // Analyze first line looking for ID; signature |
117 | 117 | $lines = explode("\n", $data); |
118 | - if (substr($lines[0],0,4) != 'ID;P') { |
|
118 | + if (substr($lines[0], 0, 4) != 'ID;P') { |
|
119 | 119 | return false; |
120 | 120 | } |
121 | 121 | |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | public function listWorksheetInfo($pFilename) |
177 | 177 | { |
178 | 178 | // Check if file exists |
179 | - if (!file_exists($pFilename)) { |
|
180 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
179 | + if ( ! file_exists($pFilename)) { |
|
180 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // Open file |
184 | 184 | $fileHandle = fopen($pFilename, 'r'); |
185 | 185 | if ($fileHandle === false) { |
186 | - throw new Exception("Could not open file " . $pFilename . " for reading."); |
|
186 | + throw new Exception("Could not open file ".$pFilename." for reading."); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $worksheetInfo = array(); |
@@ -206,20 +206,20 @@ discard block |
||
206 | 206 | |
207 | 207 | // explode each row at semicolons while taking into account that literal semicolon (;) |
208 | 208 | // is escaped like this (;;) |
209 | - $rowData = explode("\t",str_replace('?',';',str_replace(';',"\t",str_replace(';;','?',rtrim($rowData))))); |
|
209 | + $rowData = explode("\t", str_replace('?', ';', str_replace(';', "\t", str_replace(';;', '?', rtrim($rowData))))); |
|
210 | 210 | |
211 | 211 | $dataType = array_shift($rowData); |
212 | 212 | if ($dataType == 'C') { |
213 | 213 | // Read cell value data |
214 | - foreach($rowData as $rowDatum) { |
|
215 | - switch($rowDatum{0}) { |
|
214 | + foreach ($rowData as $rowDatum) { |
|
215 | + switch ($rowDatum{0}) { |
|
216 | 216 | case 'C' : |
217 | 217 | case 'X' : |
218 | - $columnIndex = substr($rowDatum,1) - 1; |
|
218 | + $columnIndex = substr($rowDatum, 1) - 1; |
|
219 | 219 | break; |
220 | 220 | case 'R' : |
221 | 221 | case 'Y' : |
222 | - $rowIndex = substr($rowDatum,1); |
|
222 | + $rowIndex = substr($rowDatum, 1); |
|
223 | 223 | break; |
224 | 224 | } |
225 | 225 | |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) |
268 | 268 | { |
269 | 269 | // Check if file exists |
270 | - if (!file_exists($pFilename)) { |
|
271 | - throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); |
|
270 | + if ( ! file_exists($pFilename)) { |
|
271 | + throw new Exception("Could not open ".$pFilename." for reading! File does not exist."); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | // Create new PHPExcel |
275 | 275 | while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { |
276 | 276 | $objPHPExcel->createSheet(); |
277 | 277 | } |
278 | - $objPHPExcel->setActiveSheetIndex( $this->_sheetIndex ); |
|
278 | + $objPHPExcel->setActiveSheetIndex($this->_sheetIndex); |
|
279 | 279 | |
280 | - $fromFormats = array('\-', '\ '); |
|
281 | - $toFormats = array('-', ' '); |
|
280 | + $fromFormats = array('\-', '\ '); |
|
281 | + $toFormats = array('-', ' '); |
|
282 | 282 | |
283 | 283 | // Open file |
284 | 284 | $fileHandle = fopen($pFilename, 'r'); |
@@ -298,23 +298,23 @@ discard block |
||
298 | 298 | |
299 | 299 | // explode each row at semicolons while taking into account that literal semicolon (;) |
300 | 300 | // is escaped like this (;;) |
301 | - $rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData))))); |
|
301 | + $rowData = explode("\t", str_replace('¤', ';', str_replace(';', "\t", str_replace(';;', '¤', rtrim($rowData))))); |
|
302 | 302 | |
303 | 303 | $dataType = array_shift($rowData); |
304 | 304 | // Read shared styles |
305 | 305 | if ($dataType == 'P') { |
306 | 306 | $formatArray = array(); |
307 | - foreach($rowData as $rowDatum) { |
|
308 | - switch($rowDatum{0}) { |
|
309 | - case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1)); |
|
307 | + foreach ($rowData as $rowDatum) { |
|
308 | + switch ($rowDatum{0}) { |
|
309 | + case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats, substr($rowDatum, 1)); |
|
310 | 310 | break; |
311 | 311 | case 'E' : |
312 | - case 'F' : $formatArray['font']['name'] = substr($rowDatum,1); |
|
312 | + case 'F' : $formatArray['font']['name'] = substr($rowDatum, 1); |
|
313 | 313 | break; |
314 | - case 'L' : $formatArray['font']['size'] = substr($rowDatum,1); |
|
314 | + case 'L' : $formatArray['font']['size'] = substr($rowDatum, 1); |
|
315 | 315 | break; |
316 | - case 'S' : $styleSettings = substr($rowDatum,1); |
|
317 | - for ($i=0;$i<strlen($styleSettings);++$i) { |
|
316 | + case 'S' : $styleSettings = substr($rowDatum, 1); |
|
317 | + for ($i = 0; $i < strlen($styleSettings); ++$i) { |
|
318 | 318 | switch ($styleSettings{$i}) { |
319 | 319 | case 'I' : $formatArray['font']['italic'] = true; |
320 | 320 | break; |
@@ -338,55 +338,55 @@ discard block |
||
338 | 338 | } elseif ($dataType == 'C') { |
339 | 339 | $hasCalculatedValue = false; |
340 | 340 | $cellData = $cellDataFormula = ''; |
341 | - foreach($rowData as $rowDatum) { |
|
342 | - switch($rowDatum{0}) { |
|
341 | + foreach ($rowData as $rowDatum) { |
|
342 | + switch ($rowDatum{0}) { |
|
343 | 343 | case 'C' : |
344 | - case 'X' : $column = substr($rowDatum,1); |
|
344 | + case 'X' : $column = substr($rowDatum, 1); |
|
345 | 345 | break; |
346 | 346 | case 'R' : |
347 | - case 'Y' : $row = substr($rowDatum,1); |
|
347 | + case 'Y' : $row = substr($rowDatum, 1); |
|
348 | 348 | break; |
349 | - case 'K' : $cellData = substr($rowDatum,1); |
|
349 | + case 'K' : $cellData = substr($rowDatum, 1); |
|
350 | 350 | break; |
351 | - case 'E' : $cellDataFormula = '='.substr($rowDatum,1); |
|
351 | + case 'E' : $cellDataFormula = '='.substr($rowDatum, 1); |
|
352 | 352 | // Convert R1C1 style references to A1 style references (but only when not quoted) |
353 | - $temp = explode('"',$cellDataFormula); |
|
353 | + $temp = explode('"', $cellDataFormula); |
|
354 | 354 | $key = false; |
355 | - foreach($temp as &$value) { |
|
355 | + foreach ($temp as &$value) { |
|
356 | 356 | // Only count/replace in alternate array entries |
357 | - if ($key = !$key) { |
|
358 | - preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE); |
|
357 | + if ($key = ! $key) { |
|
358 | + preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); |
|
359 | 359 | // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way |
360 | 360 | // through the formula from left to right. Reversing means that we work right to left.through |
361 | 361 | // the formula |
362 | 362 | $cellReferences = array_reverse($cellReferences); |
363 | 363 | // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, |
364 | 364 | // then modify the formula to use that new reference |
365 | - foreach($cellReferences as $cellReference) { |
|
365 | + foreach ($cellReferences as $cellReference) { |
|
366 | 366 | $rowReference = $cellReference[2][0]; |
367 | 367 | // Empty R reference is the current row |
368 | 368 | if ($rowReference == '') $rowReference = $row; |
369 | 369 | // Bracketed R references are relative to the current row |
370 | - if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]'); |
|
370 | + if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference, '[]'); |
|
371 | 371 | $columnReference = $cellReference[4][0]; |
372 | 372 | // Empty C reference is the current column |
373 | 373 | if ($columnReference == '') $columnReference = $column; |
374 | 374 | // Bracketed C references are relative to the current column |
375 | - if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]'); |
|
376 | - $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; |
|
375 | + if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference, '[]'); |
|
376 | + $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference - 1).$rowReference; |
|
377 | 377 | |
378 | - $value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0])); |
|
378 | + $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0])); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | } |
382 | 382 | unset($value); |
383 | 383 | // Then rebuild the formula string |
384 | - $cellDataFormula = implode('"',$temp); |
|
384 | + $cellDataFormula = implode('"', $temp); |
|
385 | 385 | $hasCalculatedValue = true; |
386 | 386 | break; |
387 | 387 | } |
388 | 388 | } |
389 | - $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); |
|
389 | + $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column - 1); |
|
390 | 390 | $cellData = PHPExcel_Calculation::_unwrapResult($cellData); |
391 | 391 | |
392 | 392 | // Set cell value |
@@ -399,20 +399,20 @@ discard block |
||
399 | 399 | } elseif ($dataType == 'F') { |
400 | 400 | $formatStyle = $columnWidth = $styleSettings = ''; |
401 | 401 | $styleData = array(); |
402 | - foreach($rowData as $rowDatum) { |
|
403 | - switch($rowDatum{0}) { |
|
402 | + foreach ($rowData as $rowDatum) { |
|
403 | + switch ($rowDatum{0}) { |
|
404 | 404 | case 'C' : |
405 | - case 'X' : $column = substr($rowDatum,1); |
|
405 | + case 'X' : $column = substr($rowDatum, 1); |
|
406 | 406 | break; |
407 | 407 | case 'R' : |
408 | - case 'Y' : $row = substr($rowDatum,1); |
|
408 | + case 'Y' : $row = substr($rowDatum, 1); |
|
409 | 409 | break; |
410 | 410 | case 'P' : $formatStyle = $rowDatum; |
411 | 411 | break; |
412 | - case 'W' : list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1)); |
|
412 | + case 'W' : list($startCol, $endCol, $columnWidth) = explode(' ', substr($rowDatum, 1)); |
|
413 | 413 | break; |
414 | - case 'S' : $styleSettings = substr($rowDatum,1); |
|
415 | - for ($i=0;$i<strlen($styleSettings);++$i) { |
|
414 | + case 'S' : $styleSettings = substr($rowDatum, 1); |
|
415 | + for ($i = 0; $i < strlen($styleSettings); ++$i) { |
|
416 | 416 | switch ($styleSettings{$i}) { |
417 | 417 | case 'I' : $styleData['font']['italic'] = true; |
418 | 418 | break; |
@@ -432,20 +432,20 @@ discard block |
||
432 | 432 | } |
433 | 433 | } |
434 | 434 | if (($formatStyle > '') && ($column > '') && ($row > '')) { |
435 | - $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); |
|
435 | + $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column - 1); |
|
436 | 436 | $objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]); |
437 | 437 | } |
438 | - if ((!empty($styleData)) && ($column > '') && ($row > '')) { |
|
439 | - $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); |
|
438 | + if (( ! empty($styleData)) && ($column > '') && ($row > '')) { |
|
439 | + $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column - 1); |
|
440 | 440 | $objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData); |
441 | 441 | } |
442 | 442 | if ($columnWidth > '') { |
443 | 443 | if ($startCol == $endCol) { |
444 | - $startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1); |
|
444 | + $startCol = PHPExcel_Cell::stringFromColumnIndex($startCol - 1); |
|
445 | 445 | $objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); |
446 | 446 | } else { |
447 | - $startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1); |
|
448 | - $endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1); |
|
447 | + $startCol = PHPExcel_Cell::stringFromColumnIndex($startCol - 1); |
|
448 | + $endCol = PHPExcel_Cell::stringFromColumnIndex($endCol - 1); |
|
449 | 449 | $objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth); |
450 | 450 | do { |
451 | 451 | $objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth); |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | } |
454 | 454 | } |
455 | 455 | } else { |
456 | - foreach($rowData as $rowDatum) { |
|
457 | - switch($rowDatum{0}) { |
|
456 | + foreach ($rowData as $rowDatum) { |
|
457 | + switch ($rowDatum{0}) { |
|
458 | 458 | case 'C' : |
459 | - case 'X' : $column = substr($rowDatum,1); |
|
459 | + case 'X' : $column = substr($rowDatum, 1); |
|
460 | 460 | break; |
461 | 461 | case 'R' : |
462 | - case 'Y' : $row = substr($rowDatum,1); |
|
462 | + case 'Y' : $row = substr($rowDatum, 1); |
|
463 | 463 | break; |
464 | 464 | } |
465 | 465 | } |
@@ -365,14 +365,22 @@ |
||
365 | 365 | foreach($cellReferences as $cellReference) { |
366 | 366 | $rowReference = $cellReference[2][0]; |
367 | 367 | // Empty R reference is the current row |
368 | - if ($rowReference == '') $rowReference = $row; |
|
368 | + if ($rowReference == '') { |
|
369 | + $rowReference = $row; |
|
370 | + } |
|
369 | 371 | // Bracketed R references are relative to the current row |
370 | - if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]'); |
|
372 | + if ($rowReference{0} == '[') { |
|
373 | + $rowReference = $row + trim($rowReference,'[]'); |
|
374 | + } |
|
371 | 375 | $columnReference = $cellReference[4][0]; |
372 | 376 | // Empty C reference is the current column |
373 | - if ($columnReference == '') $columnReference = $column; |
|
377 | + if ($columnReference == '') { |
|
378 | + $columnReference = $column; |
|
379 | + } |
|
374 | 380 | // Bracketed C references are relative to the current column |
375 | - if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]'); |
|
381 | + if ($columnReference{0} == '[') { |
|
382 | + $columnReference = $column + trim($columnReference,'[]'); |
|
383 | + } |
|
376 | 384 | $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; |
377 | 385 | |
378 | 386 | $value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0])); |
@@ -45,7 +45,6 @@ |
||
45 | 45 | /** |
46 | 46 | * Create a new PHPExcel_RichText instance |
47 | 47 | * |
48 | - * @param PHPExcel_Cell $pParent |
|
49 | 48 | * @throws Exception |
50 | 49 | */ |
51 | 50 | public function __construct(PHPExcel_Cell $pCell = null) |
@@ -1,29 +1,29 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PHPExcel |
|
4 | - * |
|
5 | - * Copyright (c) 2006 - 2012 PHPExcel |
|
6 | - * |
|
7 | - * This library is free software; you can redistribute it and/or |
|
8 | - * modify it under the terms of the GNU Lesser General Public |
|
9 | - * License as published by the Free Software Foundation; either |
|
10 | - * version 2.1 of the License, or (at your option) any later version. |
|
11 | - * |
|
12 | - * This library is distributed in the hope that it will be useful, |
|
13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 | - * Lesser General Public License for more details. |
|
16 | - * |
|
17 | - * You should have received a copy of the GNU Lesser General Public |
|
18 | - * License along with this library; if not, write to the Free Software |
|
19 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
20 | - * |
|
21 | - * @category PHPExcel |
|
22 | - * @package PHPExcel_RichText |
|
23 | - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) |
|
24 | - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL |
|
25 | - * @version 1.7.7, 2012-05-19 |
|
26 | - */ |
|
3 | + * PHPExcel |
|
4 | + * |
|
5 | + * Copyright (c) 2006 - 2012 PHPExcel |
|
6 | + * |
|
7 | + * This library is free software; you can redistribute it and/or |
|
8 | + * modify it under the terms of the GNU Lesser General Public |
|
9 | + * License as published by the Free Software Foundation; either |
|
10 | + * version 2.1 of the License, or (at your option) any later version. |
|
11 | + * |
|
12 | + * This library is distributed in the hope that it will be useful, |
|
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 | + * Lesser General Public License for more details. |
|
16 | + * |
|
17 | + * You should have received a copy of the GNU Lesser General Public |
|
18 | + * License along with this library; if not, write to the Free Software |
|
19 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
20 | + * |
|
21 | + * @category PHPExcel |
|
22 | + * @package PHPExcel_RichText |
|
23 | + * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) |
|
24 | + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL |
|
25 | + * @version 1.7.7, 2012-05-19 |
|
26 | + */ |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -42,126 +42,126 @@ discard block |
||
42 | 42 | */ |
43 | 43 | private $_richTextElements; |
44 | 44 | |
45 | - /** |
|
46 | - * Create a new PHPExcel_RichText instance |
|
47 | - * |
|
48 | - * @param PHPExcel_Cell $pParent |
|
49 | - * @throws Exception |
|
50 | - */ |
|
51 | - public function __construct(PHPExcel_Cell $pCell = null) |
|
52 | - { |
|
53 | - // Initialise variables |
|
54 | - $this->_richTextElements = array(); |
|
55 | - |
|
56 | - // Rich-Text string attached to cell? |
|
57 | - if ($pCell !== NULL) { |
|
58 | - // Add cell text and style |
|
59 | - if ($pCell->getValue() != "") { |
|
60 | - $objRun = new PHPExcel_RichText_Run($pCell->getValue()); |
|
61 | - $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont()); |
|
62 | - $this->addText($objRun); |
|
63 | - } |
|
64 | - |
|
65 | - // Set parent value |
|
66 | - $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING); |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Add text |
|
72 | - * |
|
73 | - * @param PHPExcel_RichText_ITextElement $pText Rich text element |
|
74 | - * @throws Exception |
|
75 | - * @return PHPExcel_RichText |
|
76 | - */ |
|
77 | - public function addText(PHPExcel_RichText_ITextElement $pText = null) |
|
78 | - { |
|
79 | - $this->_richTextElements[] = $pText; |
|
80 | - return $this; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Create text |
|
85 | - * |
|
86 | - * @param string $pText Text |
|
87 | - * @return PHPExcel_RichText_TextElement |
|
88 | - * @throws Exception |
|
89 | - */ |
|
90 | - public function createText($pText = '') |
|
91 | - { |
|
92 | - $objText = new PHPExcel_RichText_TextElement($pText); |
|
93 | - $this->addText($objText); |
|
94 | - return $objText; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Create text run |
|
99 | - * |
|
100 | - * @param string $pText Text |
|
101 | - * @return PHPExcel_RichText_Run |
|
102 | - * @throws Exception |
|
103 | - */ |
|
104 | - public function createTextRun($pText = '') |
|
105 | - { |
|
106 | - $objText = new PHPExcel_RichText_Run($pText); |
|
107 | - $this->addText($objText); |
|
108 | - return $objText; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Get plain text |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - public function getPlainText() |
|
117 | - { |
|
118 | - // Return value |
|
119 | - $returnValue = ''; |
|
120 | - |
|
121 | - // Loop through all PHPExcel_RichText_ITextElement |
|
122 | - foreach ($this->_richTextElements as $text) { |
|
123 | - $returnValue .= $text->getText(); |
|
124 | - } |
|
125 | - |
|
126 | - // Return |
|
127 | - return $returnValue; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Convert to string |
|
132 | - * |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - public function __toString() { |
|
136 | - return $this->getPlainText(); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Get Rich Text elements |
|
141 | - * |
|
142 | - * @return PHPExcel_RichText_ITextElement[] |
|
143 | - */ |
|
144 | - public function getRichTextElements() |
|
145 | - { |
|
146 | - return $this->_richTextElements; |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * Set Rich Text elements |
|
151 | - * |
|
152 | - * @param PHPExcel_RichText_ITextElement[] $pElements Array of elements |
|
153 | - * @throws Exception |
|
154 | - * @return PHPExcel_RichText |
|
155 | - */ |
|
156 | - public function setRichTextElements($pElements = null) |
|
157 | - { |
|
158 | - if (is_array($pElements)) { |
|
159 | - $this->_richTextElements = $pElements; |
|
160 | - } else { |
|
161 | - throw new Exception("Invalid PHPExcel_RichText_ITextElement[] array passed."); |
|
162 | - } |
|
163 | - return $this; |
|
164 | - } |
|
45 | + /** |
|
46 | + * Create a new PHPExcel_RichText instance |
|
47 | + * |
|
48 | + * @param PHPExcel_Cell $pParent |
|
49 | + * @throws Exception |
|
50 | + */ |
|
51 | + public function __construct(PHPExcel_Cell $pCell = null) |
|
52 | + { |
|
53 | + // Initialise variables |
|
54 | + $this->_richTextElements = array(); |
|
55 | + |
|
56 | + // Rich-Text string attached to cell? |
|
57 | + if ($pCell !== NULL) { |
|
58 | + // Add cell text and style |
|
59 | + if ($pCell->getValue() != "") { |
|
60 | + $objRun = new PHPExcel_RichText_Run($pCell->getValue()); |
|
61 | + $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont()); |
|
62 | + $this->addText($objRun); |
|
63 | + } |
|
64 | + |
|
65 | + // Set parent value |
|
66 | + $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING); |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Add text |
|
72 | + * |
|
73 | + * @param PHPExcel_RichText_ITextElement $pText Rich text element |
|
74 | + * @throws Exception |
|
75 | + * @return PHPExcel_RichText |
|
76 | + */ |
|
77 | + public function addText(PHPExcel_RichText_ITextElement $pText = null) |
|
78 | + { |
|
79 | + $this->_richTextElements[] = $pText; |
|
80 | + return $this; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Create text |
|
85 | + * |
|
86 | + * @param string $pText Text |
|
87 | + * @return PHPExcel_RichText_TextElement |
|
88 | + * @throws Exception |
|
89 | + */ |
|
90 | + public function createText($pText = '') |
|
91 | + { |
|
92 | + $objText = new PHPExcel_RichText_TextElement($pText); |
|
93 | + $this->addText($objText); |
|
94 | + return $objText; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Create text run |
|
99 | + * |
|
100 | + * @param string $pText Text |
|
101 | + * @return PHPExcel_RichText_Run |
|
102 | + * @throws Exception |
|
103 | + */ |
|
104 | + public function createTextRun($pText = '') |
|
105 | + { |
|
106 | + $objText = new PHPExcel_RichText_Run($pText); |
|
107 | + $this->addText($objText); |
|
108 | + return $objText; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Get plain text |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + public function getPlainText() |
|
117 | + { |
|
118 | + // Return value |
|
119 | + $returnValue = ''; |
|
120 | + |
|
121 | + // Loop through all PHPExcel_RichText_ITextElement |
|
122 | + foreach ($this->_richTextElements as $text) { |
|
123 | + $returnValue .= $text->getText(); |
|
124 | + } |
|
125 | + |
|
126 | + // Return |
|
127 | + return $returnValue; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Convert to string |
|
132 | + * |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + public function __toString() { |
|
136 | + return $this->getPlainText(); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Get Rich Text elements |
|
141 | + * |
|
142 | + * @return PHPExcel_RichText_ITextElement[] |
|
143 | + */ |
|
144 | + public function getRichTextElements() |
|
145 | + { |
|
146 | + return $this->_richTextElements; |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * Set Rich Text elements |
|
151 | + * |
|
152 | + * @param PHPExcel_RichText_ITextElement[] $pElements Array of elements |
|
153 | + * @throws Exception |
|
154 | + * @return PHPExcel_RichText |
|
155 | + */ |
|
156 | + public function setRichTextElements($pElements = null) |
|
157 | + { |
|
158 | + if (is_array($pElements)) { |
|
159 | + $this->_richTextElements = $pElements; |
|
160 | + } else { |
|
161 | + throw new Exception("Invalid PHPExcel_RichText_ITextElement[] array passed."); |
|
162 | + } |
|
163 | + return $this; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | /** |
167 | 167 | * Get hash code |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | $hashElements .= $element->getHashCode(); |
175 | 175 | } |
176 | 176 | |
177 | - return md5( |
|
178 | - $hashElements |
|
179 | - . __CLASS__ |
|
180 | - ); |
|
181 | - } |
|
177 | + return md5( |
|
178 | + $hashElements |
|
179 | + . __CLASS__ |
|
180 | + ); |
|
181 | + } |
|
182 | 182 | |
183 | 183 | /** |
184 | 184 | * Implement PHP __clone to create a deep clone, not just a shallow copy. |
@@ -39,7 +39,6 @@ |
||
39 | 39 | * Convert Microsoft Code Page Identifier to Code Page Name which iconv |
40 | 40 | * and mbstring understands |
41 | 41 | * |
42 | - * @param int $number Microsoft Code Page Indentifier |
|
43 | 42 | * @return string Code Page Name |
44 | 43 | * @throws Exception |
45 | 44 | */ |
@@ -46,56 +46,56 @@ |
||
46 | 46 | public static function NumberToName($codePage = '1252') |
47 | 47 | { |
48 | 48 | switch ($codePage) { |
49 | - case 367: return 'ASCII'; break; // ASCII |
|
50 | - case 437: return 'CP437'; break; // OEM US |
|
49 | + case 367: return 'ASCII'; break; // ASCII |
|
50 | + case 437: return 'CP437'; break; // OEM US |
|
51 | 51 | case 720: throw new Exception('Code page 720 not supported.'); |
52 | - break; // OEM Arabic |
|
53 | - case 737: return 'CP737'; break; // OEM Greek |
|
54 | - case 775: return 'CP775'; break; // OEM Baltic |
|
55 | - case 850: return 'CP850'; break; // OEM Latin I |
|
56 | - case 852: return 'CP852'; break; // OEM Latin II (Central European) |
|
57 | - case 855: return 'CP855'; break; // OEM Cyrillic |
|
58 | - case 857: return 'CP857'; break; // OEM Turkish |
|
59 | - case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro |
|
60 | - case 860: return 'CP860'; break; // OEM Portugese |
|
61 | - case 861: return 'CP861'; break; // OEM Icelandic |
|
62 | - case 862: return 'CP862'; break; // OEM Hebrew |
|
63 | - case 863: return 'CP863'; break; // OEM Canadian (French) |
|
64 | - case 864: return 'CP864'; break; // OEM Arabic |
|
65 | - case 865: return 'CP865'; break; // OEM Nordic |
|
66 | - case 866: return 'CP866'; break; // OEM Cyrillic (Russian) |
|
67 | - case 869: return 'CP869'; break; // OEM Greek (Modern) |
|
68 | - case 874: return 'CP874'; break; // ANSI Thai |
|
69 | - case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS |
|
70 | - case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK |
|
71 | - case 949: return 'CP949'; break; // ANSI Korean (Wansung) |
|
72 | - case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5 |
|
73 | - case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8) |
|
74 | - case 1250: return 'CP1250'; break; // ANSI Latin II (Central European) |
|
75 | - case 1251: return 'CP1251'; break; // ANSI Cyrillic |
|
52 | + break; // OEM Arabic |
|
53 | + case 737: return 'CP737'; break; // OEM Greek |
|
54 | + case 775: return 'CP775'; break; // OEM Baltic |
|
55 | + case 850: return 'CP850'; break; // OEM Latin I |
|
56 | + case 852: return 'CP852'; break; // OEM Latin II (Central European) |
|
57 | + case 855: return 'CP855'; break; // OEM Cyrillic |
|
58 | + case 857: return 'CP857'; break; // OEM Turkish |
|
59 | + case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro |
|
60 | + case 860: return 'CP860'; break; // OEM Portugese |
|
61 | + case 861: return 'CP861'; break; // OEM Icelandic |
|
62 | + case 862: return 'CP862'; break; // OEM Hebrew |
|
63 | + case 863: return 'CP863'; break; // OEM Canadian (French) |
|
64 | + case 864: return 'CP864'; break; // OEM Arabic |
|
65 | + case 865: return 'CP865'; break; // OEM Nordic |
|
66 | + case 866: return 'CP866'; break; // OEM Cyrillic (Russian) |
|
67 | + case 869: return 'CP869'; break; // OEM Greek (Modern) |
|
68 | + case 874: return 'CP874'; break; // ANSI Thai |
|
69 | + case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS |
|
70 | + case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK |
|
71 | + case 949: return 'CP949'; break; // ANSI Korean (Wansung) |
|
72 | + case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5 |
|
73 | + case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8) |
|
74 | + case 1250: return 'CP1250'; break; // ANSI Latin II (Central European) |
|
75 | + case 1251: return 'CP1251'; break; // ANSI Cyrillic |
|
76 | 76 | case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program |
77 | - case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7) |
|
78 | - case 1253: return 'CP1253'; break; // ANSI Greek |
|
79 | - case 1254: return 'CP1254'; break; // ANSI Turkish |
|
80 | - case 1255: return 'CP1255'; break; // ANSI Hebrew |
|
81 | - case 1256: return 'CP1256'; break; // ANSI Arabic |
|
82 | - case 1257: return 'CP1257'; break; // ANSI Baltic |
|
83 | - case 1258: return 'CP1258'; break; // ANSI Vietnamese |
|
84 | - case 1361: return 'CP1361'; break; // ANSI Korean (Johab) |
|
85 | - case 10000: return 'MAC'; break; // Apple Roman |
|
86 | - case 10006: return 'MACGREEK'; break; // Macintosh Greek |
|
87 | - case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic |
|
88 | - case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe |
|
89 | - case 10079: return 'MACICELAND'; break; // Macintosh Icelandic |
|
90 | - case 10081: return 'MACTURKISH'; break; // Macintosh Turkish |
|
91 | - case 32768: return 'MAC'; break; // Apple Roman |
|
77 | + case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7) |
|
78 | + case 1253: return 'CP1253'; break; // ANSI Greek |
|
79 | + case 1254: return 'CP1254'; break; // ANSI Turkish |
|
80 | + case 1255: return 'CP1255'; break; // ANSI Hebrew |
|
81 | + case 1256: return 'CP1256'; break; // ANSI Arabic |
|
82 | + case 1257: return 'CP1257'; break; // ANSI Baltic |
|
83 | + case 1258: return 'CP1258'; break; // ANSI Vietnamese |
|
84 | + case 1361: return 'CP1361'; break; // ANSI Korean (Johab) |
|
85 | + case 10000: return 'MAC'; break; // Apple Roman |
|
86 | + case 10006: return 'MACGREEK'; break; // Macintosh Greek |
|
87 | + case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic |
|
88 | + case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe |
|
89 | + case 10079: return 'MACICELAND'; break; // Macintosh Icelandic |
|
90 | + case 10081: return 'MACTURKISH'; break; // Macintosh Turkish |
|
91 | + case 32768: return 'MAC'; break; // Apple Roman |
|
92 | 92 | case 32769: throw new Exception('Code page 32769 not supported.'); |
93 | - break; // ANSI Latin I (BIFF2-BIFF3) |
|
94 | - case 65000: return 'UTF-7'; break; // Unicode (UTF-7) |
|
95 | - case 65001: return 'UTF-8'; break; // Unicode (UTF-8) |
|
93 | + break; // ANSI Latin I (BIFF2-BIFF3) |
|
94 | + case 65000: return 'UTF-7'; break; // Unicode (UTF-7) |
|
95 | + case 65001: return 'UTF-8'; break; // Unicode (UTF-8) |
|
96 | 96 | } |
97 | 97 | |
98 | - throw new Exception('Unknown codepage: ' . $codePage); |
|
98 | + throw new Exception('Unknown codepage: '.$codePage); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | } |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | /** |
108 | 108 | * Convert a date from Excel to PHP |
109 | 109 | * |
110 | - * @param long $dateValue Excel date/time value |
|
111 | - * @return long PHP serialized date/time |
|
110 | + * @param integer $dateValue Excel date/time value |
|
111 | + * @return integer|null PHP serialized date/time |
|
112 | 112 | */ |
113 | 113 | public static function ExcelToPHP($dateValue = 0) { |
114 | 114 | if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | /** |
144 | 144 | * Convert a date from Excel to a PHP Date/Time object |
145 | 145 | * |
146 | - * @param long $dateValue Excel date/time value |
|
146 | + * @param integer $dateValue Excel date/time value |
|
147 | 147 | * @return long PHP date/time object |
148 | 148 | */ |
149 | 149 | public static function ExcelToPHPObject($dateValue = 0) { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | /** |
165 | 165 | * Convert a date from PHP to Excel |
166 | 166 | * |
167 | - * @param mixed $dateValue PHP serialized date/time or date object |
|
167 | + * @param integer $dateValue PHP serialized date/time or date object |
|
168 | 168 | * @return mixed Excel date/time value |
169 | 169 | * or boolean False on failure |
170 | 170 | */ |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | * @param long $year |
194 | 194 | * @param long $month |
195 | 195 | * @param long $day |
196 | - * @param long $hours |
|
197 | - * @param long $minutes |
|
198 | - * @param long $seconds |
|
199 | - * @return long Excel date/time value |
|
196 | + * @param integer $hours |
|
197 | + * @param integer $minutes |
|
198 | + * @param integer $seconds |
|
199 | + * @return double Excel date/time value |
|
200 | 200 | */ |
201 | 201 | public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) { |
202 | 202 | if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) { |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | class PHPExcel_Shared_Date |
38 | 38 | { |
39 | 39 | /** constants */ |
40 | - const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0 |
|
41 | - const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0 |
|
40 | + const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0 |
|
41 | + const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0 |
|
42 | 42 | |
43 | 43 | /* |
44 | 44 | * Names of the months of the year, indexed by shortname |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @public |
48 | 48 | * @var string[] |
49 | 49 | */ |
50 | - public static $_monthNames = array( 'Jan' => 'January', |
|
50 | + public static $_monthNames = array('Jan' => 'January', |
|
51 | 51 | 'Feb' => 'February', |
52 | 52 | 'Mar' => 'March', |
53 | 53 | 'Apr' => 'April', |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @private |
68 | 68 | * @var int |
69 | 69 | */ |
70 | - private static $ExcelBaseDate = self::CALENDAR_WINDOWS_1900; |
|
70 | + private static $ExcelBaseDate = self::CALENDAR_WINDOWS_1900; |
|
71 | 71 | |
72 | 72 | /* |
73 | 73 | * Object type for PHP Date/Time values |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @private |
76 | 76 | * @var string |
77 | 77 | */ |
78 | - public static $dateTimeObjectType = 'DateTime'; |
|
78 | + public static $dateTimeObjectType = 'DateTime'; |
|
79 | 79 | |
80 | 80 | |
81 | 81 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $seconds = round($time) - ($hours * 3600) - ($minutes * 60); |
156 | 156 | |
157 | 157 | $dateObj = date_create('1-Jan-1970+'.$days.' days'); |
158 | - $dateObj->setTime($hours,$minutes,$seconds); |
|
158 | + $dateObj->setTime($hours, $minutes, $seconds); |
|
159 | 159 | |
160 | 160 | return $dateObj; |
161 | 161 | } // function ExcelToPHPObject() |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | date_default_timezone_set('UTC'); |
174 | 174 | $retValue = False; |
175 | 175 | if ((is_object($dateValue)) && ($dateValue instanceof self::$dateTimeObjectType)) { |
176 | - $retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), |
|
176 | + $retValue = self::FormattedPHPToExcel($dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), |
|
177 | 177 | $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s') |
178 | 178 | ); |
179 | 179 | } elseif (is_numeric($dateValue)) { |
180 | - $retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue), |
|
181 | - date('H',$dateValue), date('i',$dateValue), date('s',$dateValue) |
|
180 | + $retValue = self::FormattedPHPToExcel(date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue), |
|
181 | + date('H', $dateValue), date('i', $dateValue), date('s', $dateValue) |
|
182 | 182 | ); |
183 | 183 | } |
184 | 184 | date_default_timezone_set($saveTimeZone); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param long $seconds |
199 | 199 | * @return long Excel date/time value |
200 | 200 | */ |
201 | - public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) { |
|
201 | + public static function FormattedPHPToExcel($year, $month, $day, $hours = 0, $minutes = 0, $seconds = 0) { |
|
202 | 202 | if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) { |
203 | 203 | // |
204 | 204 | // Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | // Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0) |
224 | - $century = substr($year,0,2); |
|
225 | - $decade = substr($year,2,2); |
|
224 | + $century = substr($year, 0, 2); |
|
225 | + $decade = substr($year, 2, 2); |
|
226 | 226 | $excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $myExcelBaseDate + $excel1900isLeapYear; |
227 | 227 | |
228 | 228 | $excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400; |
@@ -290,18 +290,18 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | // Typically number, currency or accounting (or occasionally fraction) formats |
293 | - if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) { |
|
293 | + if ((substr($pFormatCode, 0, 1) == '_') || (substr($pFormatCode, 0, 2) == '0 ')) { |
|
294 | 294 | return false; |
295 | 295 | } |
296 | 296 | // Try checking for any of the date formatting characters that don't appear within square braces |
297 | - if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) { |
|
297 | + if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $pFormatCode)) { |
|
298 | 298 | // We might also have a format mask containing quoted strings... |
299 | 299 | // we don't want to test for any of our characters within the quoted blocks |
300 | - if (strpos($pFormatCode,'"') !== false) { |
|
300 | + if (strpos($pFormatCode, '"') !== false) { |
|
301 | 301 | $i = false; |
302 | - foreach(explode('"',$pFormatCode) as $subVal) { |
|
302 | + foreach (explode('"', $pFormatCode) as $subVal) { |
|
303 | 303 | // Only test in alternate array entries (the non-quoted blocks) |
304 | - if (($i = !$i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) { |
|
304 | + if (($i = ! $i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $subVal))) { |
|
305 | 305 | return true; |
306 | 306 | } |
307 | 307 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | public static function stringToExcel($dateValue = '') { |
325 | 325 | if (strlen($dateValue) < 2) |
326 | 326 | return false; |
327 | - if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) |
|
327 | + if ( ! preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) |
|
328 | 328 | return false; |
329 | 329 | |
330 | 330 | $dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue); |
@@ -322,10 +322,12 @@ |
||
322 | 322 | * @return float|false Excel date/time serial value |
323 | 323 | */ |
324 | 324 | public static function stringToExcel($dateValue = '') { |
325 | - if (strlen($dateValue) < 2) |
|
326 | - return false; |
|
327 | - if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) |
|
328 | - return false; |
|
325 | + if (strlen($dateValue) < 2) { |
|
326 | + return false; |
|
327 | + } |
|
328 | + if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) { |
|
329 | + return false; |
|
330 | + } |
|
329 | 331 | |
330 | 332 | $dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue); |
331 | 333 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * Convert pixels to EMU |
40 | 40 | * |
41 | 41 | * @param int $pValue Value in pixels |
42 | - * @return int Value in EMU |
|
42 | + * @return double Value in EMU |
|
43 | 43 | */ |
44 | 44 | public static function pixelsToEMU($pValue = 0) { |
45 | 45 | return round($pValue * 9525); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * Convert column width from (intrinsic) Excel units to pixels |
94 | 94 | * |
95 | - * @param float $pValue Value in cell dimension |
|
95 | + * @param integer $pValue Value in cell dimension |
|
96 | 96 | * @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook |
97 | 97 | * @return int Value in pixels |
98 | 98 | */ |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * Convert pixels to points |
126 | 126 | * |
127 | 127 | * @param int $pValue Value in pixels |
128 | - * @return int Value in points |
|
128 | + * @return double Value in points |
|
129 | 129 | */ |
130 | 130 | public static function pixelsToPoints($pValue = 0) { |
131 | 131 | return $pValue * 0.67777777; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * Create a new image from file. By alexander at alexauto dot nl |
174 | 174 | * |
175 | 175 | * @link http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214 |
176 | - * @param string $filename Path to Windows DIB (BMP) image |
|
176 | + * @param string $p_sFile |
|
177 | 177 | * @return resource |
178 | 178 | */ |
179 | 179 | public static function imagecreatefrombmp($p_sFile) |
@@ -178,95 +178,95 @@ |
||
178 | 178 | */ |
179 | 179 | public static function imagecreatefrombmp($p_sFile) |
180 | 180 | { |
181 | - // Load the image into a string |
|
182 | - $file = fopen($p_sFile,"rb"); |
|
183 | - $read = fread($file,10); |
|
184 | - while(!feof($file)&&($read<>"")) |
|
185 | - $read .= fread($file,1024); |
|
186 | - |
|
187 | - $temp = unpack("H*",$read); |
|
188 | - $hex = $temp[1]; |
|
189 | - $header = substr($hex,0,108); |
|
190 | - |
|
191 | - // Process the header |
|
192 | - // Structure: http://www.fastgraph.com/help/bmp_header_format.html |
|
193 | - if (substr($header,0,4)=="424d") |
|
194 | - { |
|
195 | - // Cut it in parts of 2 bytes |
|
196 | - $header_parts = str_split($header,2); |
|
197 | - |
|
198 | - // Get the width 4 bytes |
|
199 | - $width = hexdec($header_parts[19].$header_parts[18]); |
|
200 | - |
|
201 | - // Get the height 4 bytes |
|
202 | - $height = hexdec($header_parts[23].$header_parts[22]); |
|
203 | - |
|
204 | - // Unset the header params |
|
205 | - unset($header_parts); |
|
206 | - } |
|
207 | - |
|
208 | - // Define starting X and Y |
|
209 | - $x = 0; |
|
210 | - $y = 1; |
|
211 | - |
|
212 | - // Create newimage |
|
213 | - $image = imagecreatetruecolor($width,$height); |
|
214 | - |
|
215 | - // Grab the body from the image |
|
216 | - $body = substr($hex,108); |
|
217 | - |
|
218 | - // Calculate if padding at the end-line is needed |
|
219 | - // Divided by two to keep overview. |
|
220 | - // 1 byte = 2 HEX-chars |
|
221 | - $body_size = (strlen($body)/2); |
|
222 | - $header_size = ($width*$height); |
|
223 | - |
|
224 | - // Use end-line padding? Only when needed |
|
225 | - $usePadding = ($body_size>($header_size*3)+4); |
|
226 | - |
|
227 | - // Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption |
|
228 | - // Calculate the next DWORD-position in the body |
|
229 | - for ($i=0;$i<$body_size;$i+=3) |
|
230 | - { |
|
231 | - // Calculate line-ending and padding |
|
232 | - if ($x>=$width) |
|
233 | - { |
|
234 | - // If padding needed, ignore image-padding |
|
235 | - // Shift i to the ending of the current 32-bit-block |
|
236 | - if ($usePadding) |
|
237 | - $i += $width%4; |
|
238 | - |
|
239 | - // Reset horizontal position |
|
240 | - $x = 0; |
|
241 | - |
|
242 | - // Raise the height-position (bottom-up) |
|
243 | - $y++; |
|
244 | - |
|
245 | - // Reached the image-height? Break the for-loop |
|
246 | - if ($y>$height) |
|
247 | - break; |
|
248 | - } |
|
249 | - |
|
250 | - // Calculation of the RGB-pixel (defined as BGR in image-data) |
|
251 | - // Define $i_pos as absolute position in the body |
|
252 | - $i_pos = $i*2; |
|
253 | - $r = hexdec($body[$i_pos+4].$body[$i_pos+5]); |
|
254 | - $g = hexdec($body[$i_pos+2].$body[$i_pos+3]); |
|
255 | - $b = hexdec($body[$i_pos].$body[$i_pos+1]); |
|
256 | - |
|
257 | - // Calculate and draw the pixel |
|
258 | - $color = imagecolorallocate($image,$r,$g,$b); |
|
259 | - imagesetpixel($image,$x,$height-$y,$color); |
|
260 | - |
|
261 | - // Raise the horizontal position |
|
262 | - $x++; |
|
263 | - } |
|
264 | - |
|
265 | - // Unset the body / free the memory |
|
266 | - unset($body); |
|
267 | - |
|
268 | - // Return image-object |
|
269 | - return $image; |
|
181 | + // Load the image into a string |
|
182 | + $file = fopen($p_sFile,"rb"); |
|
183 | + $read = fread($file,10); |
|
184 | + while(!feof($file)&&($read<>"")) |
|
185 | + $read .= fread($file,1024); |
|
186 | + |
|
187 | + $temp = unpack("H*",$read); |
|
188 | + $hex = $temp[1]; |
|
189 | + $header = substr($hex,0,108); |
|
190 | + |
|
191 | + // Process the header |
|
192 | + // Structure: http://www.fastgraph.com/help/bmp_header_format.html |
|
193 | + if (substr($header,0,4)=="424d") |
|
194 | + { |
|
195 | + // Cut it in parts of 2 bytes |
|
196 | + $header_parts = str_split($header,2); |
|
197 | + |
|
198 | + // Get the width 4 bytes |
|
199 | + $width = hexdec($header_parts[19].$header_parts[18]); |
|
200 | + |
|
201 | + // Get the height 4 bytes |
|
202 | + $height = hexdec($header_parts[23].$header_parts[22]); |
|
203 | + |
|
204 | + // Unset the header params |
|
205 | + unset($header_parts); |
|
206 | + } |
|
207 | + |
|
208 | + // Define starting X and Y |
|
209 | + $x = 0; |
|
210 | + $y = 1; |
|
211 | + |
|
212 | + // Create newimage |
|
213 | + $image = imagecreatetruecolor($width,$height); |
|
214 | + |
|
215 | + // Grab the body from the image |
|
216 | + $body = substr($hex,108); |
|
217 | + |
|
218 | + // Calculate if padding at the end-line is needed |
|
219 | + // Divided by two to keep overview. |
|
220 | + // 1 byte = 2 HEX-chars |
|
221 | + $body_size = (strlen($body)/2); |
|
222 | + $header_size = ($width*$height); |
|
223 | + |
|
224 | + // Use end-line padding? Only when needed |
|
225 | + $usePadding = ($body_size>($header_size*3)+4); |
|
226 | + |
|
227 | + // Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption |
|
228 | + // Calculate the next DWORD-position in the body |
|
229 | + for ($i=0;$i<$body_size;$i+=3) |
|
230 | + { |
|
231 | + // Calculate line-ending and padding |
|
232 | + if ($x>=$width) |
|
233 | + { |
|
234 | + // If padding needed, ignore image-padding |
|
235 | + // Shift i to the ending of the current 32-bit-block |
|
236 | + if ($usePadding) |
|
237 | + $i += $width%4; |
|
238 | + |
|
239 | + // Reset horizontal position |
|
240 | + $x = 0; |
|
241 | + |
|
242 | + // Raise the height-position (bottom-up) |
|
243 | + $y++; |
|
244 | + |
|
245 | + // Reached the image-height? Break the for-loop |
|
246 | + if ($y>$height) |
|
247 | + break; |
|
248 | + } |
|
249 | + |
|
250 | + // Calculation of the RGB-pixel (defined as BGR in image-data) |
|
251 | + // Define $i_pos as absolute position in the body |
|
252 | + $i_pos = $i*2; |
|
253 | + $r = hexdec($body[$i_pos+4].$body[$i_pos+5]); |
|
254 | + $g = hexdec($body[$i_pos+2].$body[$i_pos+3]); |
|
255 | + $b = hexdec($body[$i_pos].$body[$i_pos+1]); |
|
256 | + |
|
257 | + // Calculate and draw the pixel |
|
258 | + $color = imagecolorallocate($image,$r,$g,$b); |
|
259 | + imagesetpixel($image,$x,$height-$y,$color); |
|
260 | + |
|
261 | + // Raise the horizontal position |
|
262 | + $x++; |
|
263 | + } |
|
264 | + |
|
265 | + // Unset the body / free the memory |
|
266 | + unset($body); |
|
267 | + |
|
268 | + // Return image-object |
|
269 | + return $image; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @return int Angle |
153 | 153 | */ |
154 | 154 | public static function degreesToAngle($pValue = 0) { |
155 | - return (int)round($pValue * 60000); |
|
155 | + return (int) round($pValue * 60000); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -179,84 +179,84 @@ discard block |
||
179 | 179 | public static function imagecreatefrombmp($p_sFile) |
180 | 180 | { |
181 | 181 | // Load the image into a string |
182 | - $file = fopen($p_sFile,"rb"); |
|
183 | - $read = fread($file,10); |
|
184 | - while(!feof($file)&&($read<>"")) |
|
185 | - $read .= fread($file,1024); |
|
182 | + $file = fopen($p_sFile, "rb"); |
|
183 | + $read = fread($file, 10); |
|
184 | + while ( ! feof($file) && ($read <> "")) |
|
185 | + $read .= fread($file, 1024); |
|
186 | 186 | |
187 | - $temp = unpack("H*",$read); |
|
188 | - $hex = $temp[1]; |
|
189 | - $header = substr($hex,0,108); |
|
187 | + $temp = unpack("H*", $read); |
|
188 | + $hex = $temp[1]; |
|
189 | + $header = substr($hex, 0, 108); |
|
190 | 190 | |
191 | 191 | // Process the header |
192 | 192 | // Structure: http://www.fastgraph.com/help/bmp_header_format.html |
193 | - if (substr($header,0,4)=="424d") |
|
193 | + if (substr($header, 0, 4) == "424d") |
|
194 | 194 | { |
195 | 195 | // Cut it in parts of 2 bytes |
196 | - $header_parts = str_split($header,2); |
|
196 | + $header_parts = str_split($header, 2); |
|
197 | 197 | |
198 | 198 | // Get the width 4 bytes |
199 | - $width = hexdec($header_parts[19].$header_parts[18]); |
|
199 | + $width = hexdec($header_parts[19].$header_parts[18]); |
|
200 | 200 | |
201 | 201 | // Get the height 4 bytes |
202 | - $height = hexdec($header_parts[23].$header_parts[22]); |
|
202 | + $height = hexdec($header_parts[23].$header_parts[22]); |
|
203 | 203 | |
204 | 204 | // Unset the header params |
205 | 205 | unset($header_parts); |
206 | 206 | } |
207 | 207 | |
208 | 208 | // Define starting X and Y |
209 | - $x = 0; |
|
210 | - $y = 1; |
|
209 | + $x = 0; |
|
210 | + $y = 1; |
|
211 | 211 | |
212 | 212 | // Create newimage |
213 | - $image = imagecreatetruecolor($width,$height); |
|
213 | + $image = imagecreatetruecolor($width, $height); |
|
214 | 214 | |
215 | 215 | // Grab the body from the image |
216 | - $body = substr($hex,108); |
|
216 | + $body = substr($hex, 108); |
|
217 | 217 | |
218 | 218 | // Calculate if padding at the end-line is needed |
219 | 219 | // Divided by two to keep overview. |
220 | 220 | // 1 byte = 2 HEX-chars |
221 | - $body_size = (strlen($body)/2); |
|
222 | - $header_size = ($width*$height); |
|
221 | + $body_size = (strlen($body) / 2); |
|
222 | + $header_size = ($width * $height); |
|
223 | 223 | |
224 | 224 | // Use end-line padding? Only when needed |
225 | - $usePadding = ($body_size>($header_size*3)+4); |
|
225 | + $usePadding = ($body_size > ($header_size * 3) + 4); |
|
226 | 226 | |
227 | 227 | // Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption |
228 | 228 | // Calculate the next DWORD-position in the body |
229 | - for ($i=0;$i<$body_size;$i+=3) |
|
229 | + for ($i = 0; $i < $body_size; $i += 3) |
|
230 | 230 | { |
231 | 231 | // Calculate line-ending and padding |
232 | - if ($x>=$width) |
|
232 | + if ($x >= $width) |
|
233 | 233 | { |
234 | 234 | // If padding needed, ignore image-padding |
235 | 235 | // Shift i to the ending of the current 32-bit-block |
236 | 236 | if ($usePadding) |
237 | - $i += $width%4; |
|
237 | + $i += $width % 4; |
|
238 | 238 | |
239 | 239 | // Reset horizontal position |
240 | - $x = 0; |
|
240 | + $x = 0; |
|
241 | 241 | |
242 | 242 | // Raise the height-position (bottom-up) |
243 | 243 | $y++; |
244 | 244 | |
245 | 245 | // Reached the image-height? Break the for-loop |
246 | - if ($y>$height) |
|
246 | + if ($y > $height) |
|
247 | 247 | break; |
248 | 248 | } |
249 | 249 | |
250 | 250 | // Calculation of the RGB-pixel (defined as BGR in image-data) |
251 | 251 | // Define $i_pos as absolute position in the body |
252 | - $i_pos = $i*2; |
|
253 | - $r = hexdec($body[$i_pos+4].$body[$i_pos+5]); |
|
254 | - $g = hexdec($body[$i_pos+2].$body[$i_pos+3]); |
|
255 | - $b = hexdec($body[$i_pos].$body[$i_pos+1]); |
|
252 | + $i_pos = $i * 2; |
|
253 | + $r = hexdec($body[$i_pos + 4].$body[$i_pos + 5]); |
|
254 | + $g = hexdec($body[$i_pos + 2].$body[$i_pos + 3]); |
|
255 | + $b = hexdec($body[$i_pos].$body[$i_pos + 1]); |
|
256 | 256 | |
257 | 257 | // Calculate and draw the pixel |
258 | - $color = imagecolorallocate($image,$r,$g,$b); |
|
259 | - imagesetpixel($image,$x,$height-$y,$color); |
|
258 | + $color = imagecolorallocate($image, $r, $g, $b); |
|
259 | + imagesetpixel($image, $x, $height - $y, $color); |
|
260 | 260 | |
261 | 261 | // Raise the horizontal position |
262 | 262 | $x++; |
@@ -181,8 +181,9 @@ discard block |
||
181 | 181 | // Load the image into a string |
182 | 182 | $file = fopen($p_sFile,"rb"); |
183 | 183 | $read = fread($file,10); |
184 | - while(!feof($file)&&($read<>"")) |
|
185 | - $read .= fread($file,1024); |
|
184 | + while(!feof($file)&&($read<>"")) { |
|
185 | + $read .= fread($file,1024); |
|
186 | + } |
|
186 | 187 | |
187 | 188 | $temp = unpack("H*",$read); |
188 | 189 | $hex = $temp[1]; |
@@ -233,8 +234,9 @@ discard block |
||
233 | 234 | { |
234 | 235 | // If padding needed, ignore image-padding |
235 | 236 | // Shift i to the ending of the current 32-bit-block |
236 | - if ($usePadding) |
|
237 | - $i += $width%4; |
|
237 | + if ($usePadding) { |
|
238 | + $i += $width%4; |
|
239 | + } |
|
238 | 240 | |
239 | 241 | // Reset horizontal position |
240 | 242 | $x = 0; |
@@ -243,8 +245,9 @@ discard block |
||
243 | 245 | $y++; |
244 | 246 | |
245 | 247 | // Reached the image-height? Break the for-loop |
246 | - if ($y>$height) |
|
247 | - break; |
|
248 | + if ($y>$height) { |
|
249 | + break; |
|
250 | + } |
|
248 | 251 | } |
249 | 252 | |
250 | 253 | // Calculation of the RGB-pixel (defined as BGR in image-data) |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | /** |
185 | 185 | * Get the shape index |
186 | 186 | * |
187 | - * @return int |
|
187 | + * @return boolean |
|
188 | 188 | */ |
189 | 189 | public function getSpId() |
190 | 190 | { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * Set an option for the Shape Group Container |
196 | 196 | * |
197 | 197 | * @param int $property The number specifies the option |
198 | - * @param mixed $value |
|
198 | + * @param integer $value |
|
199 | 199 | */ |
200 | 200 | public function setOPT($property, $value) |
201 | 201 | { |
@@ -309,7 +309,6 @@ discard block |
||
309 | 309 | /** |
310 | 310 | * Set offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width |
311 | 311 | * |
312 | - * @param int $startOffsetX |
|
313 | 312 | */ |
314 | 313 | public function setEndOffsetX($endOffsetX = 0) |
315 | 314 | { |
@@ -1,29 +1,29 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PHPExcel |
|
4 | - * |
|
5 | - * Copyright (c) 2006 - 2012 PHPExcel |
|
6 | - * |
|
7 | - * This library is free software; you can redistribute it and/or |
|
8 | - * modify it under the terms of the GNU Lesser General Public |
|
9 | - * License as published by the Free Software Foundation; either |
|
10 | - * version 2.1 of the License, or (at your option) any later version. |
|
11 | - * |
|
12 | - * This library is distributed in the hope that it will be useful, |
|
13 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 | - * Lesser General Public License for more details. |
|
16 | - * |
|
17 | - * You should have received a copy of the GNU Lesser General Public |
|
18 | - * License along with this library; if not, write to the Free Software |
|
19 | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
20 | - * |
|
21 | - * @category PHPExcel |
|
22 | - * @package PHPExcel_Shared_Escher |
|
23 | - * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) |
|
24 | - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL |
|
25 | - * @version 1.7.7, 2012-05-19 |
|
26 | - */ |
|
3 | + * PHPExcel |
|
4 | + * |
|
5 | + * Copyright (c) 2006 - 2012 PHPExcel |
|
6 | + * |
|
7 | + * This library is free software; you can redistribute it and/or |
|
8 | + * modify it under the terms of the GNU Lesser General Public |
|
9 | + * License as published by the Free Software Foundation; either |
|
10 | + * version 2.1 of the License, or (at your option) any later version. |
|
11 | + * |
|
12 | + * This library is distributed in the hope that it will be useful, |
|
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 | + * Lesser General Public License for more details. |
|
16 | + * |
|
17 | + * You should have received a copy of the GNU Lesser General Public |
|
18 | + * License along with this library; if not, write to the Free Software |
|
19 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
20 | + * |
|
21 | + * @category PHPExcel |
|
22 | + * @package PHPExcel_Shared_Escher |
|
23 | + * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) |
|
24 | + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL |
|
25 | + * @version 1.7.7, 2012-05-19 |
|
26 | + */ |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @param PHPExcel_Worksheet $sheet |
138 | 138 | * @param string $startColumn |
139 | - * @param integer $startOffset Offset within start cell measured in 1/1024 of the cell width |
|
139 | + * @param integer $startOffsetX Offset within start cell measured in 1/1024 of the cell width |
|
140 | 140 | * @param string $endColumn |
141 | - * @param integer $endOffset Offset within end cell measured in 1/1024 of the cell width |
|
141 | + * @param integer $endOffsetX Offset within end cell measured in 1/1024 of the cell width |
|
142 | 142 | * @return integer Horizontal measured in pixels |
143 | 143 | */ |
144 | 144 | public static function getDistanceX(PHPExcel_Worksheet $sheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0) |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | * The distanceY is found as sum of all the spanning rows minus two offsets |
167 | 167 | * |
168 | 168 | * @param PHPExcel_Worksheet $sheet |
169 | - * @param string $startRow (1-based) |
|
170 | - * @param integer $startOffset Offset within start cell measured in 1/256 of the cell height |
|
171 | - * @param string $endRow (1-based) |
|
172 | - * @param integer $endOffset Offset within end cell measured in 1/256 of the cell height |
|
169 | + * @param integer $startRow (1-based) |
|
170 | + * @param integer $startOffsetY Offset within start cell measured in 1/256 of the cell height |
|
171 | + * @param integer $endRow (1-based) |
|
172 | + * @param integer $endOffsetY Offset within end cell measured in 1/256 of the cell height |
|
173 | 173 | * @return integer Vertical distance measured in pixels |
174 | 174 | */ |
175 | 175 | public static function getDistanceY(PHPExcel_Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0) |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param PHPExcel_Worksheet $sheet The sheet |
43 | 43 | * @param integer $col The column |
44 | 44 | * @return integer The width in pixels |
45 | - */ |
|
45 | + */ |
|
46 | 46 | public static function sizeCol($sheet, $col = 'A') |
47 | 47 | { |
48 | 48 | // default font of the workbook |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $columnDimensions = $sheet->getColumnDimensions(); |
52 | 52 | |
53 | 53 | // first find the true column width in pixels (uncollapsed and unhidden) |
54 | - if ( isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1 ) { |
|
54 | + if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) { |
|
55 | 55 | |
56 | 56 | // then we have column dimension with explicit width |
57 | 57 | $columnDimension = $columnDimensions[$col]; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // now find the effective column width in pixels |
75 | - if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) { |
|
75 | + if (isset($columnDimensions[$col]) and ! $columnDimensions[$col]->getVisible()) { |
|
76 | 76 | $effectivePixelWidth = 0; |
77 | 77 | } else { |
78 | 78 | $effectivePixelWidth = $pixelWidth; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $rowDimensions = $sheet->getRowDimensions(); |
99 | 99 | |
100 | 100 | // first find the true row height in pixels (uncollapsed and unhidden) |
101 | - if ( isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) { |
|
101 | + if (isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) { |
|
102 | 102 | |
103 | 103 | // then we have a row dimension |
104 | 104 | $rowDimension = $rowDimensions[$row]; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | // now find the effective row height in pixels |
124 | - if ( isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible() ) { |
|
124 | + if (isset($rowDimensions[$row]) and ! $rowDimensions[$row]->getVisible()) { |
|
125 | 125 | $effectivePixelRowHeight = 0; |
126 | 126 | } else { |
127 | 127 | $effectivePixelRowHeight = $pixelRowHeight; |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | $y1 = $offsetY; |
253 | 253 | |
254 | 254 | // Initialise end cell to the same as the start cell |
255 | - $col_end = $col_start; // Col containing lower right corner of object |
|
256 | - $row_end = $row_start; // Row containing bottom right corner of object |
|
255 | + $col_end = $col_start; // Col containing lower right corner of object |
|
256 | + $row_end = $row_start; // Row containing bottom right corner of object |
|
257 | 257 | |
258 | 258 | // Zero the specified offset if greater than the cell dimensions |
259 | 259 | if ($x1 >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start))) { |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | $y1 = 0; |
264 | 264 | } |
265 | 265 | |
266 | - $width = $width + $x1 -1; |
|
267 | - $height = $height + $y1 -1; |
|
266 | + $width = $width + $x1 - 1; |
|
267 | + $height = $height + $y1 - 1; |
|
268 | 268 | |
269 | 269 | // Subtract the underlying cell widths to find the end cell of the image |
270 | 270 | while ($width >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end))) { |
@@ -283,24 +283,24 @@ discard block |
||
283 | 283 | if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) == 0) { |
284 | 284 | return; |
285 | 285 | } |
286 | - if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) == 0) { |
|
286 | + if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) == 0) { |
|
287 | 287 | return; |
288 | 288 | } |
289 | 289 | if (self::sizeRow($sheet, $row_start + 1) == 0) { |
290 | 290 | return; |
291 | 291 | } |
292 | - if (self::sizeRow($sheet, $row_end + 1) == 0) { |
|
292 | + if (self::sizeRow($sheet, $row_end + 1) == 0) { |
|
293 | 293 | return; |
294 | 294 | } |
295 | 295 | |
296 | 296 | // Convert the pixel values to the percentage value expected by Excel |
297 | - $x1 = $x1 / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024; |
|
298 | - $y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256; |
|
299 | - $x2 = ($width + 1) / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object |
|
300 | - $y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object |
|
297 | + $x1 = $x1 / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024; |
|
298 | + $y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256; |
|
299 | + $x2 = ($width + 1) / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object |
|
300 | + $y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object |
|
301 | 301 | |
302 | - $startCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_start) . ($row_start + 1); |
|
303 | - $endCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_end) . ($row_end + 1); |
|
302 | + $startCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_start).($row_start + 1); |
|
303 | + $endCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_end).($row_end + 1); |
|
304 | 304 | |
305 | 305 | $twoAnchor = array( |
306 | 306 | 'startCoordinates' => $startCoordinates, |
@@ -232,8 +232,6 @@ discard block |
||
232 | 232 | /** |
233 | 233 | * Calculate an (approximate) OpenXML column width, based on font size and text contained |
234 | 234 | * |
235 | - * @param int $fontSize Font size (in pixels or points) |
|
236 | - * @param bool $fontSizeInPixels Is the font size specified in pixels (true) or in points (false) ? |
|
237 | 235 | * @param string $cellText Text to calculate width |
238 | 236 | * @param int $rotation Rotation angle |
239 | 237 | * @return int Column width |
@@ -399,7 +397,7 @@ discard block |
||
399 | 397 | * Calculate an (approximate) pixel size, based on centimeter size |
400 | 398 | * |
401 | 399 | * @param int $sizeInCm Font size (in centimeters) |
402 | - * @return int Size (in pixels) |
|
400 | + * @return double Size (in pixels) |
|
403 | 401 | */ |
404 | 402 | public static function centimeterSizeToPixels($sizeInCm = 1) { |
405 | 403 | return ($sizeInCm * 37.795275591); |
@@ -409,6 +407,7 @@ discard block |
||
409 | 407 | * Returns the font path given the font |
410 | 408 | * |
411 | 409 | * @param PHPExcel_Style_Font |
410 | + * @param PHPExcel_Style_Font $font |
|
412 | 411 | * @return string Path to TrueType font file |
413 | 412 | */ |
414 | 413 | public static function getTrueTypeFontFileFromFont($font) { |
@@ -40,87 +40,87 @@ discard block |
||
40 | 40 | const AUTOSIZE_METHOD_EXACT = 'exact'; |
41 | 41 | |
42 | 42 | /** Character set codes used by BIFF5-8 in Font records */ |
43 | - const CHARSET_ANSI_LATIN = 0x00; |
|
44 | - const CHARSET_SYSTEM_DEFAULT = 0x01; |
|
45 | - const CHARSET_SYMBOL = 0x02; |
|
46 | - const CHARSET_APPLE_ROMAN = 0x4D; |
|
47 | - const CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80; |
|
43 | + const CHARSET_ANSI_LATIN = 0x00; |
|
44 | + const CHARSET_SYSTEM_DEFAULT = 0x01; |
|
45 | + const CHARSET_SYMBOL = 0x02; |
|
46 | + const CHARSET_APPLE_ROMAN = 0x4D; |
|
47 | + const CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80; |
|
48 | 48 | const CHARSET_ANSI_KOREAN_HANGUL = 0x81; |
49 | 49 | const CHARSET_ANSI_KOREAN_JOHAB = 0x82; |
50 | - const CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86; // gb2312 |
|
51 | - const CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88; // big5 |
|
52 | - const CHARSET_ANSI_GREEK = 0xA1; |
|
53 | - const CHARSET_ANSI_TURKISH = 0xA2; |
|
54 | - const CHARSET_ANSI_VIETNAMESE = 0xA3; |
|
50 | + const CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86; // gb2312 |
|
51 | + const CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88; // big5 |
|
52 | + const CHARSET_ANSI_GREEK = 0xA1; |
|
53 | + const CHARSET_ANSI_TURKISH = 0xA2; |
|
54 | + const CHARSET_ANSI_VIETNAMESE = 0xA3; |
|
55 | 55 | const CHARSET_ANSI_HEBREW = 0xB1; |
56 | 56 | const CHARSET_ANSI_ARABIC = 0xB2; |
57 | 57 | const CHARSET_ANSI_BALTIC = 0xBA; |
58 | 58 | const CHARSET_ANSI_CYRILLIC = 0xCC; |
59 | - const CHARSET_ANSI_THAI = 0xDD; |
|
59 | + const CHARSET_ANSI_THAI = 0xDD; |
|
60 | 60 | const CHARSET_ANSI_LATIN_II = 0xEE; |
61 | - const CHARSET_OEM_LATIN_I = 0xFF; |
|
61 | + const CHARSET_OEM_LATIN_I = 0xFF; |
|
62 | 62 | |
63 | 63 | // XXX: Constants created! |
64 | 64 | /** Font filenames */ |
65 | - const ARIAL = 'arial.ttf'; |
|
66 | - const ARIAL_BOLD = 'arialbd.ttf'; |
|
67 | - const ARIAL_ITALIC = 'ariali.ttf'; |
|
68 | - const ARIAL_BOLD_ITALIC = 'arialbi.ttf'; |
|
65 | + const ARIAL = 'arial.ttf'; |
|
66 | + const ARIAL_BOLD = 'arialbd.ttf'; |
|
67 | + const ARIAL_ITALIC = 'ariali.ttf'; |
|
68 | + const ARIAL_BOLD_ITALIC = 'arialbi.ttf'; |
|
69 | 69 | |
70 | - const CALIBRI = 'CALIBRI.TTF'; |
|
71 | - const CALIBRI_BOLD = 'CALIBRIB.TTF'; |
|
70 | + const CALIBRI = 'CALIBRI.TTF'; |
|
71 | + const CALIBRI_BOLD = 'CALIBRIB.TTF'; |
|
72 | 72 | const CALIBRI_ITALIC = 'CALIBRII.TTF'; |
73 | - const CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF'; |
|
73 | + const CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF'; |
|
74 | 74 | |
75 | 75 | const COMIC_SANS_MS = 'comic.ttf'; |
76 | - const COMIC_SANS_MS_BOLD = 'comicbd.ttf'; |
|
76 | + const COMIC_SANS_MS_BOLD = 'comicbd.ttf'; |
|
77 | 77 | |
78 | - const COURIER_NEW = 'cour.ttf'; |
|
79 | - const COURIER_NEW_BOLD = 'courbd.ttf'; |
|
80 | - const COURIER_NEW_ITALIC = 'couri.ttf'; |
|
81 | - const COURIER_NEW_BOLD_ITALIC = 'courbi.ttf'; |
|
78 | + const COURIER_NEW = 'cour.ttf'; |
|
79 | + const COURIER_NEW_BOLD = 'courbd.ttf'; |
|
80 | + const COURIER_NEW_ITALIC = 'couri.ttf'; |
|
81 | + const COURIER_NEW_BOLD_ITALIC = 'courbi.ttf'; |
|
82 | 82 | |
83 | - const GEORGIA = 'georgia.ttf'; |
|
84 | - const GEORGIA_BOLD = 'georgiab.ttf'; |
|
85 | - const GEORGIA_ITALIC = 'georgiai.ttf'; |
|
86 | - const GEORGIA_BOLD_ITALIC = 'georgiaz.ttf'; |
|
83 | + const GEORGIA = 'georgia.ttf'; |
|
84 | + const GEORGIA_BOLD = 'georgiab.ttf'; |
|
85 | + const GEORGIA_ITALIC = 'georgiai.ttf'; |
|
86 | + const GEORGIA_BOLD_ITALIC = 'georgiaz.ttf'; |
|
87 | 87 | |
88 | - const IMPACT = 'impact.ttf'; |
|
88 | + const IMPACT = 'impact.ttf'; |
|
89 | 89 | |
90 | - const LIBERATION_SANS = 'LiberationSans-Regular.ttf'; |
|
91 | - const LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf'; |
|
92 | - const LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf'; |
|
93 | - const LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf'; |
|
90 | + const LIBERATION_SANS = 'LiberationSans-Regular.ttf'; |
|
91 | + const LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf'; |
|
92 | + const LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf'; |
|
93 | + const LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf'; |
|
94 | 94 | |
95 | - const LUCIDA_CONSOLE = 'lucon.ttf'; |
|
96 | - const LUCIDA_SANS_UNICODE = 'l_10646.ttf'; |
|
95 | + const LUCIDA_CONSOLE = 'lucon.ttf'; |
|
96 | + const LUCIDA_SANS_UNICODE = 'l_10646.ttf'; |
|
97 | 97 | |
98 | - const MICROSOFT_SANS_SERIF = 'micross.ttf'; |
|
98 | + const MICROSOFT_SANS_SERIF = 'micross.ttf'; |
|
99 | 99 | |
100 | - const PALATINO_LINOTYPE = 'pala.ttf'; |
|
101 | - const PALATINO_LINOTYPE_BOLD = 'palab.ttf'; |
|
102 | - const PALATINO_LINOTYPE_ITALIC = 'palai.ttf'; |
|
103 | - const PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf'; |
|
100 | + const PALATINO_LINOTYPE = 'pala.ttf'; |
|
101 | + const PALATINO_LINOTYPE_BOLD = 'palab.ttf'; |
|
102 | + const PALATINO_LINOTYPE_ITALIC = 'palai.ttf'; |
|
103 | + const PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf'; |
|
104 | 104 | |
105 | 105 | const SYMBOL = 'symbol.ttf'; |
106 | 106 | |
107 | 107 | const TAHOMA = 'tahoma.ttf'; |
108 | - const TAHOMA_BOLD = 'tahomabd.ttf'; |
|
108 | + const TAHOMA_BOLD = 'tahomabd.ttf'; |
|
109 | 109 | |
110 | - const TIMES_NEW_ROMAN = 'times.ttf'; |
|
111 | - const TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf'; |
|
112 | - const TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf'; |
|
113 | - const TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf'; |
|
110 | + const TIMES_NEW_ROMAN = 'times.ttf'; |
|
111 | + const TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf'; |
|
112 | + const TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf'; |
|
113 | + const TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf'; |
|
114 | 114 | |
115 | - const TREBUCHET_MS = 'trebuc.ttf'; |
|
116 | - const TREBUCHET_MS_BOLD = 'trebucbd.ttf'; |
|
117 | - const TREBUCHET_MS_ITALIC = 'trebucit.ttf'; |
|
118 | - const TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf'; |
|
115 | + const TREBUCHET_MS = 'trebuc.ttf'; |
|
116 | + const TREBUCHET_MS_BOLD = 'trebucbd.ttf'; |
|
117 | + const TREBUCHET_MS_ITALIC = 'trebucit.ttf'; |
|
118 | + const TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf'; |
|
119 | 119 | |
120 | - const VERDANA = 'verdana.ttf'; |
|
121 | - const VERDANA_BOLD = 'verdanab.ttf'; |
|
122 | - const VERDANA_ITALIC = 'verdanai.ttf'; |
|
123 | - const VERDANA_BOLD_ITALIC = 'verdanaz.ttf'; |
|
120 | + const VERDANA = 'verdana.ttf'; |
|
121 | + const VERDANA_BOLD = 'verdanab.ttf'; |
|
122 | + const VERDANA_ITALIC = 'verdanai.ttf'; |
|
123 | + const VERDANA_BOLD_ITALIC = 'verdanaz.ttf'; |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * AutoSize method |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @throws Exception |
294 | 294 | */ |
295 | 295 | public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0) { |
296 | - if (!function_exists('imagettfbbox')) { |
|
296 | + if ( ! function_exists('imagettfbbox')) { |
|
297 | 297 | throw new Exception('GD library needs to be enabled'); |
298 | 298 | } |
299 | 299 | |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | * @return string Path to TrueType font file |
413 | 413 | */ |
414 | 414 | public static function getTrueTypeFontFileFromFont($font) { |
415 | - if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) { |
|
415 | + if ( ! file_exists(self::$trueTypeFontPath) || ! is_dir(self::$trueTypeFontPath)) { |
|
416 | 416 | throw new Exception('Valid directory to TrueType Font files not specified'); |
417 | 417 | } |
418 | 418 | |
419 | 419 | $name = $font->getName(); |
420 | 420 | $bold = $font->getBold(); |
421 | - $italic = $font->getItalic(); |
|
421 | + $italic = $font->getItalic(); |
|
422 | 422 | |
423 | 423 | // Check if we can map font to true type font file |
424 | 424 | switch ($name) { |
@@ -518,14 +518,14 @@ discard block |
||
518 | 518 | break; |
519 | 519 | |
520 | 520 | default: |
521 | - throw new Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file'); |
|
521 | + throw new Exception('Unknown font name "'.$name.'". Cannot map to TrueType font file'); |
|
522 | 522 | break; |
523 | 523 | } |
524 | 524 | |
525 | - $fontFile = self::$trueTypeFontPath . $fontFile; |
|
525 | + $fontFile = self::$trueTypeFontPath.$fontFile; |
|
526 | 526 | |
527 | 527 | // Check if file actually exists |
528 | - if (!file_exists($fontFile)) { |
|
528 | + if ( ! file_exists($fontFile)) { |
|
529 | 529 | throw New Exception('TrueType Font file not found'); |
530 | 530 | } |
531 | 531 |
@@ -14,8 +14,6 @@ |
||
14 | 14 | * |
15 | 15 | * @param double[][] $x |
16 | 16 | * @param double[] $a |
17 | - * @param double[] $y, |
|
18 | - * @param double[] $s, |
|
19 | 17 | * @param object $f |
20 | 18 | */ |
21 | 19 | function chiSquared($x, $a, $y, $s, $f) { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | for ($i = 0; $i < $npts; ++$i) { |
26 | 26 | $d = $y[$i] - $f->val($x[$i], $a); |
27 | 27 | $d = $d / $s[$i]; |
28 | - $sum = $sum + ($d*$d); |
|
28 | + $sum = $sum + ($d * $d); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | return $sum; |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | |
79 | 79 | $oos2 = array(); |
80 | 80 | |
81 | - for($i = 0; $i < $npts; ++$i) { |
|
82 | - $oos2[$i] = 1./($s[$i]*$s[$i]); |
|
81 | + for ($i = 0; $i < $npts; ++$i) { |
|
82 | + $oos2[$i] = 1. / ($s[$i] * $s[$i]); |
|
83 | 83 | } |
84 | 84 | $iter = 0; |
85 | - $term = 0; // termination count test |
|
85 | + $term = 0; // termination count test |
|
86 | 86 | |
87 | 87 | do { |
88 | 88 | ++$iter; |
89 | 89 | |
90 | 90 | // hessian approximation |
91 | - for( $r = 0; $r < $nparm; ++$r) { |
|
92 | - for( $c = 0; $c < $nparm; ++$c) { |
|
93 | - for( $i = 0; $i < $npts; ++$i) { |
|
91 | + for ($r = 0; $r < $nparm; ++$r) { |
|
92 | + for ($c = 0; $c < $nparm; ++$c) { |
|
93 | + for ($i = 0; $i < $npts; ++$i) { |
|
94 | 94 | if ($i == 0) $H[$r][$c] = 0.; |
95 | 95 | $xi = $x[$i]; |
96 | 96 | $H[$r][$c] += ($oos2[$i] * $f->grad($xi, $a, $r) * $f->grad($xi, $a, $c)); |
@@ -99,23 +99,23 @@ discard block |
||
99 | 99 | } //r |
100 | 100 | |
101 | 101 | // boost diagonal towards gradient descent |
102 | - for( $r = 0; $r < $nparm; ++$r) |
|
102 | + for ($r = 0; $r < $nparm; ++$r) |
|
103 | 103 | $H[$r][$r] *= (1. + $lambda); |
104 | 104 | |
105 | 105 | // gradient |
106 | - for( $r = 0; $r < $nparm; ++$r) { |
|
107 | - for( $i = 0; $i < $npts; ++$i) { |
|
106 | + for ($r = 0; $r < $nparm; ++$r) { |
|
107 | + for ($i = 0; $i < $npts; ++$i) { |
|
108 | 108 | if ($i == 0) $g[$r] = 0.; |
109 | 109 | $xi = $x[$i]; |
110 | - $g[$r] += ($oos2[$i] * ($y[$i]-$f->val($xi,$a)) * $f->grad($xi, $a, $r)); |
|
110 | + $g[$r] += ($oos2[$i] * ($y[$i] - $f->val($xi, $a)) * $f->grad($xi, $a, $r)); |
|
111 | 111 | } |
112 | 112 | } //npts |
113 | 113 | |
114 | 114 | // scale (for consistency with NR, not necessary) |
115 | 115 | if ($false) { |
116 | - for( $r = 0; $r < $nparm; ++$r) { |
|
116 | + for ($r = 0; $r < $nparm; ++$r) { |
|
117 | 117 | $g[$r] = -0.5 * $g[$r]; |
118 | - for( $c = 0; $c < $nparm; ++$c) { |
|
118 | + for ($c = 0; $c < $nparm; ++$c) { |
|
119 | 119 | $H[$r][$c] *= 0.5; |
120 | 120 | } |
121 | 121 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | // if (vary[i]) a[i] = na[i]; |
178 | 178 | // } |
179 | 179 | // } |
180 | - } while(!$done); |
|
180 | + } while ( ! $done); |
|
181 | 181 | |
182 | 182 | return $lambda; |
183 | 183 | } // function solve() |
@@ -91,7 +91,9 @@ discard block |
||
91 | 91 | for( $r = 0; $r < $nparm; ++$r) { |
92 | 92 | for( $c = 0; $c < $nparm; ++$c) { |
93 | 93 | for( $i = 0; $i < $npts; ++$i) { |
94 | - if ($i == 0) $H[$r][$c] = 0.; |
|
94 | + if ($i == 0) { |
|
95 | + $H[$r][$c] = 0.; |
|
96 | + } |
|
95 | 97 | $xi = $x[$i]; |
96 | 98 | $H[$r][$c] += ($oos2[$i] * $f->grad($xi, $a, $r) * $f->grad($xi, $a, $c)); |
97 | 99 | } //npts |
@@ -99,13 +101,16 @@ discard block |
||
99 | 101 | } //r |
100 | 102 | |
101 | 103 | // boost diagonal towards gradient descent |
102 | - for( $r = 0; $r < $nparm; ++$r) |
|
103 | - $H[$r][$r] *= (1. + $lambda); |
|
104 | + for( $r = 0; $r < $nparm; ++$r) { |
|
105 | + $H[$r][$r] *= (1. + $lambda); |
|
106 | + } |
|
104 | 107 | |
105 | 108 | // gradient |
106 | 109 | for( $r = 0; $r < $nparm; ++$r) { |
107 | 110 | for( $i = 0; $i < $npts; ++$i) { |
108 | - if ($i == 0) $g[$r] = 0.; |
|
111 | + if ($i == 0) { |
|
112 | + $g[$r] = 0.; |
|
113 | + } |
|
109 | 114 | $xi = $x[$i]; |
110 | 115 | $g[$r] += ($oos2[$i] * ($y[$i]-$f->val($xi,$a)) * $f->grad($xi, $a, $r)); |
111 | 116 | } |