Cleaning up code
This commit is contained in:
parent
cf790b9f98
commit
fa2878e530
|
|
@ -38,7 +38,7 @@ class PHPWord_IOFactory
|
||||||
*/
|
*/
|
||||||
private static $_searchLocations = array(
|
private static $_searchLocations = array(
|
||||||
array('type' => 'IWriter', 'path' => 'PHPWord/Writer/{0}.php', 'class' => 'PHPWord_Writer_{0}'),
|
array('type' => 'IWriter', 'path' => 'PHPWord/Writer/{0}.php', 'class' => 'PHPWord_Writer_{0}'),
|
||||||
array( 'type' => 'IReader', 'path' => 'PHPWord/Reader/{0}.php', 'class' => 'PHPWord_Reader_{0}' ),
|
array('type' => 'IReader', 'path' => 'PHPWord/Reader/{0}.php', 'class' => 'PHPWord_Reader_{0}' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -140,7 +140,7 @@ class PHPWord_IOFactory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
|
throw new PHPWord_Exception("No $searchType found for type $readerType");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,7 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements PHPWord
|
||||||
* Can the current PHPWord_Reader_IReader read the file?
|
* Can the current PHPWord_Reader_IReader read the file?
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @return boolean
|
* @return bool
|
||||||
* @throws PHPWord_Exception
|
|
||||||
*/
|
*/
|
||||||
public function canRead($pFilename)
|
public function canRead($pFilename)
|
||||||
{
|
{
|
||||||
|
|
@ -117,6 +116,7 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements PHPWord
|
||||||
* Loads PHPWord from file
|
* Loads PHPWord from file
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
|
* @return PHPWord
|
||||||
*/
|
*/
|
||||||
public function load($pFilename)
|
public function load($pFilename)
|
||||||
{
|
{
|
||||||
|
|
@ -189,7 +189,8 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements PHPWord
|
||||||
$archive = "$dir/_rels/" . basename($rel["Target"]) . ".rels";
|
$archive = "$dir/_rels/" . basename($rel["Target"]) . ".rels";
|
||||||
$relsDoc = simplexml_load_string($this->getFromZipArchive($zip, $archive));
|
$relsDoc = simplexml_load_string($this->getFromZipArchive($zip, $archive));
|
||||||
$relsDoc->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006//relationships");
|
$relsDoc->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006//relationships");
|
||||||
$xpath = self::array_item($relsDoc->xpath("rel:Relationship[@Type='" . "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
|
$xpath = self::array_item($relsDoc->xpath("rel:Relationship[@Type='" .
|
||||||
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
|
||||||
$xmlDoc = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}"));
|
$xmlDoc = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}"));
|
||||||
if ($xmlDoc->body) {
|
if ($xmlDoc->body) {
|
||||||
$section = $word->createSection();
|
$section = $word->createSection();
|
||||||
|
|
@ -219,12 +220,18 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements PHPWord
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
|
||||||
return $word;
|
return $word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get array item
|
||||||
|
*
|
||||||
|
* @param array $array
|
||||||
|
* @param mixed $key
|
||||||
|
* @return mixed|null
|
||||||
|
*/
|
||||||
private static function array_item($array, $key = 0) {
|
private static function array_item($array, $key = 0) {
|
||||||
return (isset($array[$key]) ? $array[$key] : null);
|
return (isset($array[$key]) ? $array[$key] : null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue