More psr-2 changes

This commit is contained in:
MarkBaker 2015-05-17 00:16:41 +01:00
parent 61e81377cb
commit 1663ef141c
2 changed files with 1875 additions and 1526 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,15 @@
<?php <?php
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel * PHPExcel_Reader_HTML
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -26,21 +34,6 @@
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** PHPExcel root directory */ /** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_HTML
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{ {
@ -120,12 +113,12 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
{ {
// Reading 2048 bytes should be enough to validate that the format is HTML // Reading 2048 bytes should be enough to validate that the format is HTML
$data = fread($this->_fileHandle, 2048); $data = fread($this->_fileHandle, 2048);
if ((strpos($data, '<') !== FALSE) && if ((strpos($data, '<') !== false) &&
(strlen($data) !== strlen(strip_tags($data)))) { (strlen($data) !== strlen(strip_tags($data)))) {
return TRUE; return true;
} }
return FALSE; return false;
} }
/** /**
@ -173,8 +166,9 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
protected function _setTableStartColumn($column) protected function _setTableStartColumn($column)
{ {
if ($this->_tableLevel == 0) if ($this->_tableLevel == 0) {
$column = 'A'; $column = 'A';
}
++$this->_tableLevel; ++$this->_tableLevel;
$this->_nestedColumn[$this->_tableLevel] = $column; $this->_nestedColumn[$this->_tableLevel] = $column;
@ -235,7 +229,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
switch ($child->nodeName) { switch ($child->nodeName) {
case 'meta' : case 'meta':
foreach ($attributeArray as $attributeName => $attributeValue) { foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) { switch ($attributeName) {
case 'content': case 'content':
@ -246,27 +240,29 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->_processDomElement($child, $sheet, $row, $column, $cellContent);
break; break;
case 'title' : case 'title':
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->_processDomElement($child, $sheet, $row, $column, $cellContent);
$sheet->setTitle($cellContent); $sheet->setTitle($cellContent);
$cellContent = ''; $cellContent = '';
break; break;
case 'span' : case 'span':
case 'div' : case 'div':
case 'font' : case 'font':
case 'i' : case 'i':
case 'em' : case 'em':
case 'strong': case 'strong':
case 'b' : case 'b':
// echo 'STYLING, SPAN OR DIV<br />'; // echo 'STYLING, SPAN OR DIV<br />';
if ($cellContent > '') if ($cellContent > '') {
$cellContent .= ' '; $cellContent .= ' ';
}
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->_processDomElement($child, $sheet, $row, $column, $cellContent);
if ($cellContent > '') if ($cellContent > '') {
$cellContent .= ' '; $cellContent .= ' ';
}
// echo 'END OF STYLING, SPAN OR DIV<br />'; // echo 'END OF STYLING, SPAN OR DIV<br />';
break; break;
case 'hr' : case 'hr':
$this->_flushCell($sheet, $column, $row, $cellContent); $this->_flushCell($sheet, $column, $row, $cellContent);
++$row; ++$row;
if (isset($this->_formats[$child->nodeName])) { if (isset($this->_formats[$child->nodeName])) {
@ -276,7 +272,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$this->_flushCell($sheet, $column, $row, $cellContent); $this->_flushCell($sheet, $column, $row, $cellContent);
} }
++$row; ++$row;
case 'br' : case 'br':
if ($this->_tableLevel > 0) { if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n // If we're inside a table, replace with a \n
$cellContent .= "\n"; $cellContent .= "\n";
@ -287,7 +283,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
// echo 'HARD LINE BREAK: ' , '<br />'; // echo 'HARD LINE BREAK: ' , '<br />';
break; break;
case 'a' : case 'a':
// echo 'START OF HYPERLINK: ' , '<br />'; // echo 'START OF HYPERLINK: ' , '<br />';
foreach ($attributeArray as $attributeName => $attributeValue) { foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) { switch ($attributeName) {
@ -304,15 +300,15 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF HYPERLINK:' , '<br />'; // echo 'END OF HYPERLINK:' , '<br />';
break; break;
case 'h1' : case 'h1':
case 'h2' : case 'h2':
case 'h3' : case 'h3':
case 'h4' : case 'h4':
case 'h5' : case 'h5':
case 'h6' : case 'h6':
case 'ol' : case 'ol':
case 'ul' : case 'ul':
case 'p' : case 'p':
if ($this->_tableLevel > 0) { if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n // If we're inside a table, replace with a \n
$cellContent .= "\n"; $cellContent .= "\n";
@ -337,7 +333,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$column = 'A'; $column = 'A';
} }
break; break;
case 'li' : case 'li':
if ($this->_tableLevel > 0) { if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n // If we're inside a table, replace with a \n
$cellContent .= "\n"; $cellContent .= "\n";
@ -356,12 +352,13 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$column = 'A'; $column = 'A';
} }
break; break;
case 'table' : case 'table':
$this->_flushCell($sheet, $column, $row, $cellContent); $this->_flushCell($sheet, $column, $row, $cellContent);
$column = $this->_setTableStartColumn($column); $column = $this->_setTableStartColumn($column);
// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />'; // echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
if ($this->_tableLevel > 1) if ($this->_tableLevel > 1) {
--$row; --$row;
}
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />'; // echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
$column = $this->_releaseTableStartColumn(); $column = $this->_releaseTableStartColumn();
@ -371,11 +368,11 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
++$row; ++$row;
} }
break; break;
case 'thead' : case 'thead':
case 'tbody' : case 'tbody':
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->_processDomElement($child, $sheet, $row, $column, $cellContent);
break; break;
case 'tr' : case 'tr':
$column = $this->_getTableStartColumn(); $column = $this->_getTableStartColumn();
$cellContent = ''; $cellContent = '';
// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />'; // echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
@ -383,8 +380,8 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
++$row; ++$row;
// echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />'; // echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />';
break; break;
case 'th' : case 'th':
case 'td' : case 'td':
// echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />'; // echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />'; // echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />';
@ -433,7 +430,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
++$column; ++$column;
break; break;
case 'body' : case 'body':
$row = 1; $row = 1;
$column = 'A'; $column = 'A';
$content = ''; $content = '';
@ -476,7 +473,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$dom = new domDocument; $dom = new domDocument;
// Reload the HTML file into the DOM object // Reload the HTML file into the DOM object
$loaded = $dom->loadHTML($this->securityScanFile($pFilename)); $loaded = $dom->loadHTML($this->securityScanFile($pFilename));
if ($loaded === FALSE) { if ($loaded === false) {
throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document'); throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
} }
@ -529,6 +526,4 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
return $xml; return $xml;
} }
} }