Skip to content

Commit cf790b9

Browse files
committed
Minimum working sample for text, textrun, and textbreak
1 parent c1b4b2e commit cf790b9

File tree

4 files changed

+167
-1912
lines changed

4 files changed

+167
-1912
lines changed

Classes/PHPWord/IOFactory.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,15 @@ public static function createReader($readerType = '') {
143143
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
144144
}
145145

146+
/**
147+
* Loads PHPWord from file
148+
*
149+
* @param string $pFilename The name of the file
150+
* @return PHPWord
151+
*/
152+
public static function load($pFilename, $readerType = 'Word2007') {
153+
$reader = self::createReader($readerType);
154+
return $reader->load($pFilename);
155+
}
156+
146157
}

Classes/PHPWord/Reader/Abstract.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
3636
*
3737
* @var boolean
3838
*/
39-
protected $_readDataOnly = FALSE;
39+
protected $readDataOnly = TRUE;
4040

41-
protected $_fileHandle = NULL;
41+
protected $fileHandle = NULL;
4242

4343

4444
/**
@@ -47,7 +47,8 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
4747
* @return boolean
4848
*/
4949
public function getReadDataOnly() {
50-
return $this->_readDataOnly;
50+
// return $this->readDataOnly;
51+
return TRUE;
5152
}
5253

5354
/**
@@ -56,29 +57,29 @@ public function getReadDataOnly() {
5657
* @param boolean $pValue
5758
* @return PHPWord_Reader_IReader
5859
*/
59-
public function setReadDataOnly($pValue = FALSE) {
60-
$this->_readDataOnly = $pValue;
60+
public function setReadDataOnly($pValue = TRUE) {
61+
$this->readDataOnly = $pValue;
6162
return $this;
6263
}
6364

6465
/**
6566
* Open file for reading
6667
*
6768
* @param string $pFilename
68-
* @throws PHPWord_Reader_Exception
69+
* @throws PHPWord_Exception
6970
* @return resource
7071
*/
71-
protected function _openFile($pFilename)
72+
protected function openFile($pFilename)
7273
{
7374
// Check if file exists
7475
if (!file_exists($pFilename) || !is_readable($pFilename)) {
75-
throw new PHPWord_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
76+
throw new PHPWord_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
7677
}
7778

7879
// Open file
79-
$this->_fileHandle = fopen($pFilename, 'r');
80-
if ($this->_fileHandle === FALSE) {
81-
throw new PHPWord_Reader_Exception("Could not open file " . $pFilename . " for reading.");
80+
$this->fileHandle = fopen($pFilename, 'r');
81+
if ($this->fileHandle === FALSE) {
82+
throw new PHPWord_Exception("Could not open file " . $pFilename . " for reading.");
8283
}
8384
}
8485

@@ -87,19 +88,17 @@ protected function _openFile($pFilename)
8788
*
8889
* @param string $pFilename
8990
* @return boolean
90-
* @throws PHPWord_Reader_Exception
91+
* @throws PHPWord_Exception
9192
*/
9293
public function canRead($pFilename)
9394
{
9495
// Check if file exists
9596
try {
96-
$this->_openFile($pFilename);
97+
$this->openFile($pFilename);
9798
} catch (Exception $e) {
9899
return FALSE;
99100
}
100-
101-
$readable = $this->_isValidFormat();
102-
fclose ($this->_fileHandle);
101+
fclose ($this->fileHandle);
103102
return $readable;
104103
}
105104

0 commit comments

Comments
 (0)