Code formatting for PSR1 & PSR2 - Part 1
This commit is contained in:
parent
ec514f310f
commit
4e3450e39f
@ -267,4 +267,4 @@ class PHPWord
|
||||
trigger_error('Template file ' . $strFilename . ' not found.', E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,4 +82,4 @@ class PHPWord_Autoloader
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,4 +343,4 @@ class PHPWord_DocumentProperties
|
||||
$this->_company = $pValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,4 +46,4 @@ class PHPWord_Exception extends Exception
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,4 +12,4 @@ use InvalidArgumentException;
|
||||
*/
|
||||
class InvalidStyleException extends InvalidArgumentException
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,93 +33,99 @@
|
||||
* @package PHPWord
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
*/
|
||||
class PHPWord_Footnote {
|
||||
class PHPWord_Footnote
|
||||
{
|
||||
|
||||
/**
|
||||
* Footnote Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_footnoteCollection = array();
|
||||
/**
|
||||
* Footnote Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_footnoteCollection = array();
|
||||
|
||||
/**
|
||||
* Footnote Link Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_footnoteLink = array();
|
||||
/**
|
||||
* Footnote Link Elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_footnoteLink = array();
|
||||
|
||||
/**
|
||||
* Add new Footnote Element
|
||||
*
|
||||
* @param string $linkSrc
|
||||
* @param string $linkName
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addFootnoteElement(PHPWord_Section_Footnote $footnote) {
|
||||
$refID = self::countFootnoteElements() + 2;
|
||||
/**
|
||||
* Add new Footnote Element
|
||||
*
|
||||
* @param string $linkSrc
|
||||
* @param string $linkName
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addFootnoteElement(PHPWord_Section_Footnote $footnote)
|
||||
{
|
||||
$refID = self::countFootnoteElements() + 2;
|
||||
|
||||
self::$_footnoteCollection[] = $footnote;
|
||||
self::$_footnoteCollection[] = $footnote;
|
||||
|
||||
return $refID;
|
||||
}
|
||||
return $refID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footnote Elements
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFootnoteElements() {
|
||||
return self::$_footnoteCollection;
|
||||
}
|
||||
/**
|
||||
* Get Footnote Elements
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFootnoteElements()
|
||||
{
|
||||
return self::$_footnoteCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footnote Elements Count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function countFootnoteElements() {
|
||||
return count(self::$_footnoteCollection);
|
||||
}
|
||||
/**
|
||||
* Get Footnote Elements Count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function countFootnoteElements()
|
||||
{
|
||||
return count(self::$_footnoteCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new Footnote Link Element
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $type
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addFootnoteLinkElement($linkSrc) {
|
||||
$rID = self::countFootnoteLinkElements() + 1;
|
||||
/**
|
||||
* Add new Footnote Link Element
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $type
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function addFootnoteLinkElement($linkSrc)
|
||||
{
|
||||
$rID = self::countFootnoteLinkElements() + 1;
|
||||
|
||||
$link = array();
|
||||
$link['target'] = $linkSrc;
|
||||
$link['rID'] = $rID;
|
||||
$link['type'] = 'hyperlink';
|
||||
$link = array();
|
||||
$link['target'] = $linkSrc;
|
||||
$link['rID'] = $rID;
|
||||
$link['type'] = 'hyperlink';
|
||||
|
||||
self::$_footnoteLink[] = $link;
|
||||
self::$_footnoteLink[] = $link;
|
||||
|
||||
return $rID;
|
||||
}
|
||||
return $rID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footnote Link Elements
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFootnoteLinkElements() {
|
||||
return self::$_footnoteLink;
|
||||
}
|
||||
/**
|
||||
* Get Footnote Link Elements
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFootnoteLinkElements()
|
||||
{
|
||||
return self::$_footnoteLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footnote Link Elements Count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function countFootnoteLinkElements() {
|
||||
return count(self::$_footnoteLink);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Get Footnote Link Elements Count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function countFootnoteLinkElements()
|
||||
{
|
||||
return count(self::$_footnoteLink);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,7 +126,8 @@ class PHPWord_IOFactory
|
||||
* @param string $readerType Example: Word2007
|
||||
* @return PHPWord_Reader_IReader
|
||||
*/
|
||||
public static function createReader($readerType = '') {
|
||||
public static function createReader($readerType = '')
|
||||
{
|
||||
$searchType = 'IReader';
|
||||
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
@ -134,7 +135,7 @@ class PHPWord_IOFactory
|
||||
$className = str_replace('{0}', $readerType, $searchLocation['class']);
|
||||
|
||||
$instance = new $className();
|
||||
if ($instance !== NULL) {
|
||||
if ($instance !== null) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
@ -149,9 +150,9 @@ class PHPWord_IOFactory
|
||||
* @param string $pFilename The name of the file
|
||||
* @return PHPWord
|
||||
*/
|
||||
public static function load($pFilename, $readerType = 'Word2007') {
|
||||
public static function load($pFilename, $readerType = 'Word2007')
|
||||
{
|
||||
$reader = self::createReader($readerType);
|
||||
return $reader->load($pFilename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -330,4 +330,3 @@ class PHPWord_Media
|
||||
return self::$_footerMedia;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -36,9 +36,9 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $readDataOnly = TRUE;
|
||||
protected $readDataOnly = true;
|
||||
|
||||
protected $fileHandle = NULL;
|
||||
protected $fileHandle = true;
|
||||
|
||||
|
||||
/**
|
||||
@ -46,9 +46,10 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getReadDataOnly() {
|
||||
public function getReadDataOnly()
|
||||
{
|
||||
// return $this->readDataOnly;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,7 +58,8 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
|
||||
* @param boolean $pValue
|
||||
* @return PHPWord_Reader_IReader
|
||||
*/
|
||||
public function setReadDataOnly($pValue = TRUE) {
|
||||
public function setReadDataOnly($pValue = true)
|
||||
{
|
||||
$this->readDataOnly = $pValue;
|
||||
return $this;
|
||||
}
|
||||
@ -78,7 +80,7 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
|
||||
|
||||
// Open file
|
||||
$this->fileHandle = fopen($pFilename, 'r');
|
||||
if ($this->fileHandle === FALSE) {
|
||||
if ($this->fileHandle === false) {
|
||||
throw new PHPWord_Exception("Could not open file " . $pFilename . " for reading.");
|
||||
}
|
||||
}
|
||||
@ -96,10 +98,9 @@ abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
|
||||
try {
|
||||
$this->openFile($pFilename);
|
||||
} catch (Exception $e) {
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
fclose ($this->fileHandle);
|
||||
fclose($this->fileHandle);
|
||||
return $readable;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -42,7 +42,8 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements
|
||||
/**
|
||||
* Create a new PHPWord_Reader_Word2007 instance
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,8 +56,10 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPWord_Exception("Could not open " . $pFilename .
|
||||
" for reading! File does not exist.");
|
||||
throw new PHPWord_Exception(
|
||||
"Could not open " . $pFilename .
|
||||
" for reading! File does not exist."
|
||||
);
|
||||
}
|
||||
|
||||
$return = false;
|
||||
@ -96,16 +99,14 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements
|
||||
$removeNamespace = false
|
||||
) {
|
||||
// Root-relative paths
|
||||
if (strpos($fileName, '//') !== false)
|
||||
{
|
||||
if (strpos($fileName, '//') !== false) {
|
||||
$fileName = substr($fileName, strpos($fileName, '//') + 1);
|
||||
}
|
||||
$fileName = PHPWord_Shared_File::realpath($fileName);
|
||||
|
||||
// Apache POI fixes
|
||||
$contents = $archive->getFromName($fileName);
|
||||
if ($contents === false)
|
||||
{
|
||||
if ($contents === false) {
|
||||
$contents = $archive->getFromName(substr($fileName, 1));
|
||||
}
|
||||
|
||||
@ -128,8 +129,10 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new PHPWord_Exception("Could not open " . $pFilename .
|
||||
" for reading! File does not exist.");
|
||||
throw new PHPWord_Exception(
|
||||
"Could not open " . $pFilename .
|
||||
" for reading! File does not exist."
|
||||
);
|
||||
}
|
||||
|
||||
// Initialisations
|
||||
@ -149,15 +152,15 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements
|
||||
$xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/");
|
||||
$xmlCore->registerXPathNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
|
||||
$docProps = $word->getProperties();
|
||||
$docProps->setCreator((string) self::array_item($xmlCore->xpath("dc:creator")));
|
||||
$docProps->setLastModifiedBy((string) self::array_item($xmlCore->xpath("cp:lastModifiedBy")));
|
||||
$docProps->setCreated(strtotime(self::array_item($xmlCore->xpath("dcterms:created"))));
|
||||
$docProps->setModified(strtotime(self::array_item($xmlCore->xpath("dcterms:modified"))));
|
||||
$docProps->setTitle((string) self::array_item($xmlCore->xpath("dc:title")));
|
||||
$docProps->setDescription((string) self::array_item($xmlCore->xpath("dc:description")));
|
||||
$docProps->setSubject((string) self::array_item($xmlCore->xpath("dc:subject")));
|
||||
$docProps->setKeywords((string) self::array_item($xmlCore->xpath("cp:keywords")));
|
||||
$docProps->setCategory((string) self::array_item($xmlCore->xpath("cp:category")));
|
||||
$docProps->setCreator((string) self::arrayItem($xmlCore->xpath("dc:creator")));
|
||||
$docProps->setLastModifiedBy((string) self::arrayItem($xmlCore->xpath("cp:lastModifiedBy")));
|
||||
$docProps->setCreated(strtotime(self::arrayItem($xmlCore->xpath("dcterms:created"))));
|
||||
$docProps->setModified(strtotime(self::arrayItem($xmlCore->xpath("dcterms:modified"))));
|
||||
$docProps->setTitle((string) self::arrayItem($xmlCore->xpath("dc:title")));
|
||||
$docProps->setDescription((string) self::arrayItem($xmlCore->xpath("dc:description")));
|
||||
$docProps->setSubject((string) self::arrayItem($xmlCore->xpath("dc:subject")));
|
||||
$docProps->setKeywords((string) self::arrayItem($xmlCore->xpath("cp:keywords")));
|
||||
$docProps->setCategory((string) self::arrayItem($xmlCore->xpath("cp:category")));
|
||||
}
|
||||
break;
|
||||
// Extended properties
|
||||
@ -165,10 +168,12 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements
|
||||
$xmlCore = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}"));
|
||||
if (is_object($xmlCore)) {
|
||||
$docProps = $word->getProperties();
|
||||
if (isset($xmlCore->Company))
|
||||
if (isset($xmlCore->Company)) {
|
||||
$docProps->setCompany((string) $xmlCore->Company);
|
||||
if (isset($xmlCore->Manager))
|
||||
}
|
||||
if (isset($xmlCore->Manager)) {
|
||||
$docProps->setManager((string) $xmlCore->Manager);
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Custom properties
|
||||
@ -183,9 +188,9 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements
|
||||
$cellDataOfficeChildren = $xmlProperty->children("http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes");
|
||||
$attributeType = $cellDataOfficeChildren->getName();
|
||||
$attributeValue = (string) $cellDataOfficeChildren->{$attributeType};
|
||||
$attributeValue = PHPWord_DocumentProperties::convertProperty($attributeValue,$attributeType);
|
||||
$attributeValue = PHPWord_DocumentProperties::convertProperty($attributeValue, $attributeType);
|
||||
$attributeType = PHPWord_DocumentProperties::convertPropertyType($attributeType);
|
||||
$docProps->setCustomProperty($propertyName,$attributeValue,$attributeType);
|
||||
$docProps->setCustomProperty($propertyName, $attributeValue, $attributeType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,8 +201,9 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements
|
||||
$archive = "$dir/_rels/" . basename($rel["Target"]) . ".rels";
|
||||
$relsDoc = simplexml_load_string($this->getFromZipArchive($zip, $archive));
|
||||
$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::arrayItem(
|
||||
$relsDoc->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']")
|
||||
);
|
||||
$xmlDoc = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}", true));
|
||||
if (is_object($xmlDoc)) {
|
||||
$section = $word->createSection();
|
||||
@ -215,14 +221,18 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements
|
||||
if ($elm->r) {
|
||||
// w:r = 1? It's a plain paragraph
|
||||
if (count($elm->r) == 1) {
|
||||
$section->addText($elm->r->t,
|
||||
$this->loadFontStyle($elm->r));
|
||||
$section->addText(
|
||||
$elm->r->t,
|
||||
$this->loadFontStyle($elm->r)
|
||||
);
|
||||
// w:r more than 1? It's a textrun
|
||||
} else {
|
||||
$textRun = $section->createTextRun();
|
||||
foreach ($elm->r as $r) {
|
||||
$textRun->addText($r->t,
|
||||
$this->loadFontStyle($r));
|
||||
$textRun->addText(
|
||||
$r->t,
|
||||
$this->loadFontStyle($r)
|
||||
);
|
||||
}
|
||||
}
|
||||
// No, it's a textbreak
|
||||
@ -457,8 +467,8 @@ class PHPWord_Reader_Word2007 extends PHPWord_Reader_Abstract implements
|
||||
* @param mixed $key
|
||||
* @return mixed|null
|
||||
*/
|
||||
private static function array_item($array, $key = 0) {
|
||||
private static function arrayItem($array, $key = 0)
|
||||
{
|
||||
return (isset($array[$key]) ? $array[$key] : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -425,11 +425,12 @@ class PHPWord_Section
|
||||
* @param string $text
|
||||
* @return PHPWord_Section_Footnote
|
||||
*/
|
||||
public function createFootnote($styleParagraph = null) {
|
||||
$footnote = new PHPWord_Section_Footnote($styleParagraph);
|
||||
$refID = PHPWord_Footnote::addFootnoteElement($footnote);
|
||||
$footnote->setReferenceId($refID);
|
||||
$this->_elementCollection[] = $footnote;
|
||||
return $footnote;
|
||||
public function createFootnote($styleParagraph = null)
|
||||
{
|
||||
$footnote = new PHPWord_Section_Footnote($styleParagraph);
|
||||
$refID = PHPWord_Footnote::addFootnoteElement($footnote);
|
||||
$footnote->setReferenceId($refID);
|
||||
$this->_elementCollection[] = $footnote;
|
||||
return $footnote;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,4 +210,4 @@ class PHPWord_Section_Footer
|
||||
{
|
||||
return $this->_footerCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,116 +33,124 @@
|
||||
* @package PHPWord_Section
|
||||
* @copyright Copyright (c) 2011 PHPWord
|
||||
*/
|
||||
class PHPWord_Section_Footnote {
|
||||
class PHPWord_Section_Footnote
|
||||
{
|
||||
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
/**
|
||||
* Paragraph style
|
||||
*
|
||||
* @var PHPWord_Style_Font
|
||||
*/
|
||||
private $_styleParagraph;
|
||||
|
||||
/**
|
||||
* Footnote Reference ID
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_refId;
|
||||
/**
|
||||
* Footnote Reference ID
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_refId;
|
||||
|
||||
/**
|
||||
* Text collection
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_elementCollection;
|
||||
/**
|
||||
* Text collection
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_elementCollection;
|
||||
|
||||
/**
|
||||
* Create a new Footnote Element
|
||||
*/
|
||||
public function __construct($styleParagraph = null) {
|
||||
$this->_elementCollection = array();
|
||||
/**
|
||||
* Create a new Footnote Element
|
||||
*/
|
||||
public function __construct($styleParagraph = null)
|
||||
{
|
||||
$this->_elementCollection = array();
|
||||
|
||||
// Set paragraph style
|
||||
if(is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
// Set paragraph style
|
||||
if (is_array($styleParagraph)) {
|
||||
$this->_styleParagraph = new PHPWord_Style_Paragraph();
|
||||
|
||||
foreach($styleParagraph as $key => $value) {
|
||||
if(substr($key, 0, 1) != '_') {
|
||||
$key = '_'.$key;
|
||||
foreach ($styleParagraph as $key => $value) {
|
||||
if (substr($key, 0, 1) != '_') {
|
||||
$key = '_' . $key;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleParagraph = $styleParagraph;
|
||||
}
|
||||
$this->_styleParagraph->setStyleValue($key, $value);
|
||||
}
|
||||
} else {
|
||||
$this->_styleParagraph = $styleParagraph;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a Text Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var mixed $styleFont
|
||||
* @return PHPWord_Section_Text
|
||||
*/
|
||||
public function addText($text = null, $styleFont = null) {
|
||||
$givenText = $text;
|
||||
$text = new PHPWord_Section_Text($givenText, $styleFont);
|
||||
$this->_elementCollection[] = $text;
|
||||
return $text;
|
||||
}
|
||||
/**
|
||||
* Add a Text Element
|
||||
*
|
||||
* @var string $text
|
||||
* @var mixed $styleFont
|
||||
* @return PHPWord_Section_Text
|
||||
*/
|
||||
public function addText($text = null, $styleFont = null)
|
||||
{
|
||||
$givenText = $text;
|
||||
$text = new PHPWord_Section_Text($givenText, $styleFont);
|
||||
$this->_elementCollection[] = $text;
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Link Element
|
||||
*
|
||||
* @param string $linkSrc
|
||||
* @param string $linkName
|
||||
* @param mixed $styleFont
|
||||
* @return PHPWord_Section_Link
|
||||
*/
|
||||
public function addLink($linkSrc, $linkName = null, $styleFont = null) {
|
||||
/**
|
||||
* Add a Link Element
|
||||
*
|
||||
* @param string $linkSrc
|
||||
* @param string $linkName
|
||||
* @param mixed $styleFont
|
||||
* @return PHPWord_Section_Link
|
||||
*/
|
||||
public function addLink($linkSrc, $linkName = null, $styleFont = null)
|
||||
{
|
||||
|
||||
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont);
|
||||
$rID = PHPWord_Footnote::addFootnoteLinkElement($linkSrc);
|
||||
$link->setRelationId($rID);
|
||||
$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont);
|
||||
$rID = PHPWord_Footnote::addFootnoteLinkElement($linkSrc);
|
||||
$link->setRelationId($rID);
|
||||
|
||||
$this->_elementCollection[] = $link;
|
||||
return $link;
|
||||
}
|
||||
$this->_elementCollection[] = $link;
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footnote content
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getElements() {
|
||||
return $this->_elementCollection;
|
||||
}
|
||||
/**
|
||||
* Get Footnote content
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getElements()
|
||||
{
|
||||
return $this->_elementCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle() {
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
/**
|
||||
* Get Paragraph style
|
||||
*
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function getParagraphStyle()
|
||||
{
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Footnote Reference ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getReferenceId() {
|
||||
return $this->_refId;
|
||||
}
|
||||
/**
|
||||
* Get Footnote Reference ID
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getReferenceId()
|
||||
{
|
||||
return $this->_refId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Footnote Reference ID
|
||||
*
|
||||
* @param int $refId
|
||||
*/
|
||||
public function setReferenceId($refId) {
|
||||
$this->_refId = $refId;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set Footnote Reference ID
|
||||
*
|
||||
* @param int $refId
|
||||
*/
|
||||
public function setReferenceId($refId)
|
||||
{
|
||||
$this->_refId = $refId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,5 +292,4 @@ class PHPWord_Section_Header
|
||||
{
|
||||
return $this->_type = PHPWord_Section_Header::EVEN;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,4 +172,4 @@ class PHPWord_Section_Image
|
||||
{
|
||||
$this->_isWatermark = $pValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -616,7 +616,8 @@ class PHPWord_Section_Settings
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeaderHeight() {
|
||||
public function getHeaderHeight()
|
||||
{
|
||||
return $this->headerHeight;
|
||||
}
|
||||
|
||||
@ -625,7 +626,8 @@ class PHPWord_Section_Settings
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setHeaderHeight($pValue = '') {
|
||||
public function setHeaderHeight($pValue = '')
|
||||
{
|
||||
if (!is_numeric($pValue)) {
|
||||
$pValue = 720;
|
||||
}
|
||||
@ -638,7 +640,8 @@ class PHPWord_Section_Settings
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFooterHeight() {
|
||||
public function getFooterHeight()
|
||||
{
|
||||
return $this->footerHeight;
|
||||
}
|
||||
|
||||
@ -647,7 +650,8 @@ class PHPWord_Section_Settings
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setFooterHeight($pValue = '') {
|
||||
public function setFooterHeight($pValue = '')
|
||||
{
|
||||
if (!is_numeric($pValue)) {
|
||||
$pValue = 720;
|
||||
}
|
||||
@ -660,7 +664,8 @@ class PHPWord_Section_Settings
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setColsNum($pValue = '') {
|
||||
public function setColsNum($pValue = '')
|
||||
{
|
||||
if (!is_numeric($pValue)) {
|
||||
$pValue = 1;
|
||||
}
|
||||
@ -673,7 +678,8 @@ class PHPWord_Section_Settings
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColsNum() {
|
||||
public function getColsNum()
|
||||
{
|
||||
return $this->_colsNum;
|
||||
}
|
||||
|
||||
@ -682,7 +688,8 @@ class PHPWord_Section_Settings
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setColsSpace($pValue = '') {
|
||||
public function setColsSpace($pValue = '')
|
||||
{
|
||||
if (!is_numeric($pValue)) {
|
||||
$pValue = 720;
|
||||
}
|
||||
@ -695,7 +702,8 @@ class PHPWord_Section_Settings
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColsSpace() {
|
||||
public function getColsSpace()
|
||||
{
|
||||
return $this->_colsSpace;
|
||||
}
|
||||
|
||||
@ -704,7 +712,8 @@ class PHPWord_Section_Settings
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public function setBreakType($pValue = null) {
|
||||
public function setBreakType($pValue = null)
|
||||
{
|
||||
$this->_breakType = $pValue;
|
||||
return $this;
|
||||
}
|
||||
@ -714,8 +723,8 @@ class PHPWord_Section_Settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBreakType() {
|
||||
public function getBreakType()
|
||||
{
|
||||
return $this->_breakType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -160,5 +160,4 @@ class PHPWord_Section_Table
|
||||
{
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -333,4 +333,4 @@ class PHPWord_Section_Table_Cell
|
||||
{
|
||||
return $this->_width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,4 +138,4 @@ class PHPWord_Section_Table_Row
|
||||
{
|
||||
return $this->_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,4 +149,4 @@ class PHPWord_Section_Text
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +116,8 @@ class PHPWord_Section_TextRun
|
||||
* @param mixed $styleFont
|
||||
* @return PHPWord_Section_Image
|
||||
*/
|
||||
public function addImage($imageSrc, $style = null) {
|
||||
public function addImage($imageSrc, $style = null)
|
||||
{
|
||||
$image = new PHPWord_Section_Image($imageSrc, $style);
|
||||
|
||||
if (!is_null($image->getSource())) {
|
||||
@ -136,7 +137,8 @@ class PHPWord_Section_TextRun
|
||||
* @param string $text
|
||||
* @return PHPWord_Section_Footnote
|
||||
*/
|
||||
public function createFootnote($styleParagraph = null) {
|
||||
public function createFootnote($styleParagraph = null)
|
||||
{
|
||||
$footnote = new PHPWord_Section_Footnote($styleParagraph);
|
||||
$refID = PHPWord_Footnote::addFootnoteElement($footnote);
|
||||
$footnote->setReferenceId($refID);
|
||||
@ -163,4 +165,4 @@ class PHPWord_Section_TextRun
|
||||
{
|
||||
return $this->_styleParagraph;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,5 +88,4 @@ class PHPWord_Shared_Font
|
||||
{
|
||||
return ($sizeInPoint * 20);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -266,5 +266,4 @@ class PHPWord_Shared_String
|
||||
$count = strlen($value);
|
||||
return $count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -150,4 +150,4 @@ class PHPWord_Shared_XMLWriter
|
||||
|
||||
return $this->text($text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ class PHPWord_Shared_ZipStreamWrapper
|
||||
/**
|
||||
* Read stream
|
||||
*/
|
||||
function stream_read($count)
|
||||
public function stream_read($count)
|
||||
{
|
||||
$ret = substr($this->_data, $this->_position, $count);
|
||||
$this->_position += strlen($ret);
|
||||
|
||||
@ -175,4 +175,3 @@ class PHPWord_Style
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ class PHPWord_Style_Cell
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_gridSpan = NULL;
|
||||
private $_gridSpan = null;
|
||||
|
||||
/**
|
||||
* rowspan (restart, continue)
|
||||
@ -133,7 +133,7 @@ class PHPWord_Style_Cell
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_vMerge = NULL;
|
||||
private $_vMerge = null;
|
||||
|
||||
/**
|
||||
* Create a new Cell Style
|
||||
@ -342,4 +342,4 @@ class PHPWord_Style_Cell
|
||||
{
|
||||
return $this->_vMerge;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,4 +173,4 @@ class PHPWord_Style_Image
|
||||
{
|
||||
return $this->wrappingStyle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,5 +81,4 @@ class PHPWord_Style_Row
|
||||
{
|
||||
return $this->_cantSplit ? 1 : 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ class PHPWord_Style_Tab
|
||||
* @param int $position Must be an integer; otherwise defaults to 0.
|
||||
* @param string $leader Defaults to NULL if value is not possible.
|
||||
*/
|
||||
public function __construct($val = NULL, $position = 0, $leader = NULL)
|
||||
public function __construct($val = null, $position = 0, $leader = null)
|
||||
{
|
||||
// Default to clear if the stop type is not matched
|
||||
$this->_val = (self::isStopType($val)) ? $val : 'clear';
|
||||
@ -101,7 +101,7 @@ class PHPWord_Style_Tab
|
||||
$this->_position = (is_numeric($position)) ? intval($position) : 0;
|
||||
|
||||
// Default to NULL if no tab leader
|
||||
$this->_leader = (self::isLeaderType($leader)) ? $leader : NULL;
|
||||
$this->_leader = (self::isLeaderType($leader)) ? $leader : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,7 +109,7 @@ class PHPWord_Style_Tab
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
*/
|
||||
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL)
|
||||
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = null)
|
||||
{
|
||||
if (isset($objWriter)) {
|
||||
$objWriter->startElement("w:tab");
|
||||
@ -143,4 +143,4 @@ class PHPWord_Style_Tab
|
||||
{
|
||||
return in_array($attribute, self::$_possibleLeaders);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ class PHPWord_Style_Tabs
|
||||
*
|
||||
* @param PHPWord_Shared_XMLWriter $objWriter
|
||||
*/
|
||||
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = NULL)
|
||||
public function toXml(PHPWord_Shared_XMLWriter &$objWriter = null)
|
||||
{
|
||||
if (isset($objWriter)) {
|
||||
$objWriter->startElement("w:tabs");
|
||||
@ -61,4 +61,4 @@ class PHPWord_Style_Tabs
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,4 +152,4 @@ class PHPWord_TOC
|
||||
{
|
||||
return self::$_styleFont;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ class PHPWord_Template
|
||||
throw new PHPWord_Exception('Could not create temporary file with unique name in the default temporary directory.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Applies XSL style sheet to template's parts
|
||||
*
|
||||
@ -133,10 +133,10 @@ class PHPWord_Template
|
||||
}
|
||||
$replace = htmlspecialchars($replace);
|
||||
} else {
|
||||
foreach($replace as $key=>$value) {
|
||||
foreach ($replace as $key => $value) {
|
||||
$replace[$key] = htmlspecialchars($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$regExpDelim = '/';
|
||||
$escapedSearch = preg_quote($search, $regExpDelim);
|
||||
@ -154,37 +154,40 @@ class PHPWord_Template
|
||||
|
||||
/**
|
||||
* Find the start position of the nearest table row before $offset
|
||||
*
|
||||
*
|
||||
* @param mixed $offset
|
||||
*/
|
||||
private function _findRowStart($offset) {
|
||||
$rowStart = strrpos($this->_documentXML, "<w:tr ", ((strlen($this->_documentXML) - $offset) * -1));
|
||||
if (!$rowStart) {
|
||||
$rowStart = strrpos($this->_documentXML, "<w:tr>", ((strlen($this->_documentXML) - $offset) * -1));
|
||||
}
|
||||
if (!$rowStart) {
|
||||
trigger_error("Can not find the start position of the row to clone.");
|
||||
return false;
|
||||
}
|
||||
private function _findRowStart($offset)
|
||||
{
|
||||
$rowStart = strrpos($this->_documentXML, "<w:tr ", ((strlen($this->_documentXML) - $offset) * -1));
|
||||
if (!$rowStart) {
|
||||
$rowStart = strrpos($this->_documentXML, "<w:tr>", ((strlen($this->_documentXML) - $offset) * -1));
|
||||
}
|
||||
if (!$rowStart) {
|
||||
trigger_error("Can not find the start position of the row to clone.");
|
||||
return false;
|
||||
}
|
||||
return $rowStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the end position of the nearest table row after $offset
|
||||
*
|
||||
*
|
||||
* @param mixed $offset
|
||||
*/
|
||||
private function _findRowEnd($offset) {
|
||||
$rowEnd = strpos($this->_documentXML, "</w:tr>", $offset) + 7;
|
||||
private function _findRowEnd($offset)
|
||||
{
|
||||
$rowEnd = strpos($this->_documentXML, "</w:tr>", $offset) + 7;
|
||||
return $rowEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a slice of a string
|
||||
*
|
||||
*
|
||||
* @param mixed $offset
|
||||
*/
|
||||
private function _getSlice($startPosition, $endPosition = 0) {
|
||||
private function _getSlice($startPosition, $endPosition = 0)
|
||||
{
|
||||
if (!$endPosition) {
|
||||
$endPosition = strlen($this->_documentXML);
|
||||
}
|
||||
@ -193,38 +196,39 @@ class PHPWord_Template
|
||||
|
||||
/**
|
||||
* Clone a table row in a template document
|
||||
*
|
||||
*
|
||||
* @param mixed $search
|
||||
* @param mixed $numberOfClones
|
||||
*/
|
||||
public function cloneRow($search, $numberOfClones) {
|
||||
if(substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
|
||||
public function cloneRow($search, $numberOfClones)
|
||||
{
|
||||
if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
|
||||
$search = '${'.$search.'}';
|
||||
}
|
||||
|
||||
|
||||
$tagPos = strpos($this->_documentXML, $search);
|
||||
if (!$tagPos) {
|
||||
trigger_error("Can not clone row, template variable not found or variable contains markup.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$tagPos) {
|
||||
trigger_error("Can not clone row, template variable not found or variable contains markup.");
|
||||
return false;
|
||||
}
|
||||
|
||||
$rowStart = $this->_findRowStart($tagPos);
|
||||
$rowEnd = $this->_findRowEnd($tagPos);
|
||||
$xmlRow = $this->_getSlice($rowStart, $rowEnd);
|
||||
|
||||
|
||||
// Check if there's a cell spanning multiple rows.
|
||||
if (preg_match('#<w:vMerge w:val="restart"/>#', $xmlRow)) {
|
||||
$extraRowStart = $rowEnd;
|
||||
$extraRowEnd = $rowEnd;
|
||||
while(true) {
|
||||
while (true) {
|
||||
$extraRowStart = $this->_findRowStart($extraRowEnd + 1);
|
||||
$extraRowEnd = $this->_findRowEnd($extraRowEnd + 1);
|
||||
|
||||
|
||||
// If extraRowEnd is lower then 7, there was no next row found.
|
||||
if ($extraRowEnd < 7) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// If tmpXmlRow doesn't contain continue, this row is no longer part of the spanned row.
|
||||
$tmpXmlRow = $this->_getSlice($extraRowStart, $extraRowEnd);
|
||||
if (!preg_match('#<w:vMerge/>#', $tmpXmlRow) && !preg_match('#<w:vMerge w:val="continue" />#', $tmpXmlRow)) {
|
||||
@ -232,17 +236,17 @@ class PHPWord_Template
|
||||
}
|
||||
// This row was a spanned row, update $rowEnd and search for the next row.
|
||||
$rowEnd = $extraRowEnd;
|
||||
}
|
||||
}
|
||||
$xmlRow = $this->_getSlice($rowStart, $rowEnd);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->_getSlice(0, $rowStart);
|
||||
for ($i = 1; $i <= $numberOfClones; $i++) {
|
||||
$result .= preg_replace('/\$\{(.*?)\}/','\${\\1#'.$i.'}', $xmlRow);
|
||||
}
|
||||
$result .= $this->_getSlice($rowEnd);
|
||||
|
||||
$this->_documentXML = $result;
|
||||
for ($i = 1; $i <= $numberOfClones; $i++) {
|
||||
$result .= preg_replace('/\$\{(.*?)\}/', '\${\\1#'.$i.'}', $xmlRow);
|
||||
}
|
||||
$result .= $this->_getSlice($rowEnd);
|
||||
|
||||
$this->_documentXML = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,7 +254,8 @@ class PHPWord_Template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function save() {
|
||||
public function save()
|
||||
{
|
||||
$this->_objZip->addFromString('word/document.xml', $this->_documentXML);
|
||||
|
||||
// Close zip file
|
||||
@ -266,7 +271,8 @@ class PHPWord_Template
|
||||
*
|
||||
* @param string $strFilename
|
||||
*/
|
||||
public function saveAs($strFilename) {
|
||||
public function saveAs($strFilename)
|
||||
{
|
||||
$tempFilename = $this->save();
|
||||
|
||||
if (file_exists($strFilename)) {
|
||||
|
||||
@ -236,7 +236,7 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
||||
* @param string $pPartName Writer part name
|
||||
* @return PHPWord_Writer_ODText_WriterPart
|
||||
*/
|
||||
function getWriterPart($pPartName = '')
|
||||
public function getWriterPart($pPartName = '')
|
||||
{
|
||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||
return $this->_writerParts[strtolower($pPartName)];
|
||||
@ -287,4 +287,4 @@ class PHPWord_Writer_ODText implements PHPWord_Writer_IWriter
|
||||
{
|
||||
return $this->_diskCachingDirectory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,27 +249,27 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_TextRun) {
|
||||
} elseif ($element instanceof PHPWord_Section_TextRun) {
|
||||
$this->_writeTextRun($objWriter, $element);
|
||||
} elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$this->_writeTextBreak($objWriter);
|
||||
/*
|
||||
} elseif($element instanceof PHPWord_Section_Link) {
|
||||
} elseif ($element instanceof PHPWord_Section_Link) {
|
||||
$this->_writeLink($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Title) {
|
||||
} elseif ($element instanceof PHPWord_Section_Title) {
|
||||
$this->_writeTitle($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_PageBreak) {
|
||||
} elseif ($element instanceof PHPWord_Section_PageBreak) {
|
||||
$this->_writePageBreak($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_Table) {
|
||||
} elseif ($element instanceof PHPWord_Section_Table) {
|
||||
$this->_writeTable($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_ListItem) {
|
||||
} elseif ($element instanceof PHPWord_Section_ListItem) {
|
||||
$this->_writeListItem($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Image ||
|
||||
} elseif ($element instanceof PHPWord_Section_Image ||
|
||||
$element instanceof PHPWord_Section_MemoryImage) {
|
||||
$this->_writeImage($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_Section_Object) {
|
||||
} elseif ($element instanceof PHPWord_Section_Object) {
|
||||
$this->_writeObject($objWriter, $element);
|
||||
} elseif($element instanceof PHPWord_TOC) {
|
||||
} elseif ($element instanceof PHPWord_TOC) {
|
||||
$this->_writeTOC($objWriter);
|
||||
*/
|
||||
} else {
|
||||
@ -303,8 +303,8 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
||||
protected function _writeText(
|
||||
PHPWord_Shared_XMLWriter $objWriter = null,
|
||||
PHPWord_Section_Text $text,
|
||||
$withoutP = false)
|
||||
{
|
||||
$withoutP = false
|
||||
) {
|
||||
$styleFont = $text->getFontStyle();
|
||||
$styleParagraph = $text->getParagraphStyle();
|
||||
|
||||
@ -351,9 +351,7 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
||||
* @param PHPWord_Section_TextRun $textrun
|
||||
* @todo Enable all other section types
|
||||
*/
|
||||
protected function _writeTextRun(
|
||||
PHPWord_Shared_XMLWriter $objWriter = null,
|
||||
PHPWord_Section_TextRun $textrun)
|
||||
protected function _writeTextRun(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_TextRun $textrun)
|
||||
{
|
||||
$elements = $textrun->getElements();
|
||||
$objWriter->startElement('text:p');
|
||||
@ -377,7 +375,7 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section)
|
||||
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null)
|
||||
{
|
||||
}
|
||||
|
||||
@ -386,9 +384,7 @@ class PHPWord_Writer_ODText_Content extends PHPWord_Writer_ODText_WriterPart
|
||||
*
|
||||
* @todo Create the real function
|
||||
*/
|
||||
private function _writeSection(
|
||||
PHPWord_Shared_XMLWriter $objWriter = null,
|
||||
PHPWord_Section $section)
|
||||
private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,5 +42,4 @@ class PHPWord_Writer_ODText_Mimetype extends PHPWord_Writer_ODText_WriterPart
|
||||
|
||||
return 'application/vnd.oasis.opendocument.text';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -182,8 +182,8 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
|
||||
}
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
} // PHPWord_Style_Paragraph
|
||||
elseif ($style instanceof PHPWord_Style_Paragraph) {
|
||||
} elseif ($style instanceof PHPWord_Style_Paragraph) {
|
||||
// PHPWord_Style_Paragraph
|
||||
// style:style
|
||||
$objWriter->startElement('style:style');
|
||||
$objWriter->writeAttribute('style:name', $styleName);
|
||||
@ -197,9 +197,8 @@ class PHPWord_Writer_ODText_Styles extends PHPWord_Writer_ODText_WriterPart
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
} // PHPWord_Style_TableFull
|
||||
elseif ($style instanceof PHPWord_Style_TableFull) {
|
||||
} elseif ($style instanceof PHPWord_Style_TableFull) {
|
||||
// PHPWord_Style_TableFull
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
}
|
||||
|
||||
$hFile = fopen($pFilename, 'w') or die("can't open file");
|
||||
fwrite($hFile, $this->_getData());
|
||||
fwrite($hFile, $this->getData());
|
||||
fclose($hFile);
|
||||
|
||||
// If a temporary file was used, copy it to the correct file stream
|
||||
@ -135,11 +135,11 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
private function _getData()
|
||||
private function getData()
|
||||
{
|
||||
// PHPWord object : $this->_document
|
||||
$this->_fontTable = $this->_getDataFont();
|
||||
$this->_colorTable = $this->_getDataColor();
|
||||
$this->_fontTable = $this->getDataFont();
|
||||
$this->_colorTable = $this->getDataColor();
|
||||
|
||||
$sRTFContent = '{\rtf1';
|
||||
// Set the default character set
|
||||
@ -180,7 +180,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
$sRTFContent .= '\fs' . (PHPWord::DEFAULT_FONT_SIZE * 2);
|
||||
$sRTFContent .= PHP_EOL;
|
||||
// Body
|
||||
$sRTFContent .= $this->_getDataContent();
|
||||
$sRTFContent .= $this->getDataContent();
|
||||
|
||||
|
||||
$sRTFContent .= '}';
|
||||
@ -188,7 +188,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
return $sRTFContent;
|
||||
}
|
||||
|
||||
private function _getDataFont()
|
||||
private function getDataFont()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
|
||||
@ -204,7 +204,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
foreach ($styles as $styleName => $style) {
|
||||
// PHPWord_Style_Font
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
if (in_array($style->getName(), $arrFonts) == FALSE) {
|
||||
if (in_array($style->getName(), $arrFonts) == false) {
|
||||
$arrFonts[] = $style->getName();
|
||||
}
|
||||
}
|
||||
@ -226,7 +226,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
$fStyle = $element->getFontStyle();
|
||||
|
||||
if ($fStyle instanceof PHPWord_Style_Font) {
|
||||
if (in_array($fStyle->getName(), $arrFonts) == FALSE) {
|
||||
if (in_array($fStyle->getName(), $arrFonts) == false) {
|
||||
$arrFonts[] = $fStyle->getName();
|
||||
}
|
||||
}
|
||||
@ -238,7 +238,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
return $arrFonts;
|
||||
}
|
||||
|
||||
private function _getDataColor()
|
||||
private function getDataColor()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
|
||||
@ -254,10 +254,10 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
if ($style instanceof PHPWord_Style_Font) {
|
||||
$color = $style->getColor();
|
||||
$fgcolor = $style->getFgColor();
|
||||
if (in_array($color, $arrColors) == FALSE && $color != PHPWord::DEFAULT_FONT_COLOR && !empty($color)) {
|
||||
if (in_array($color, $arrColors) == false && $color != PHPWord::DEFAULT_FONT_COLOR && !empty($color)) {
|
||||
$arrColors[] = $color;
|
||||
}
|
||||
if (in_array($fgcolor, $arrColors) == FALSE && $fgcolor != PHPWord::DEFAULT_FONT_COLOR && !empty($fgcolor)) {
|
||||
if (in_array($fgcolor, $arrColors) == false && $fgcolor != PHPWord::DEFAULT_FONT_COLOR && !empty($fgcolor)) {
|
||||
$arrColors[] = $fgcolor;
|
||||
}
|
||||
}
|
||||
@ -279,10 +279,10 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
$fStyle = $element->getFontStyle();
|
||||
|
||||
if ($fStyle instanceof PHPWord_Style_Font) {
|
||||
if (in_array($fStyle->getColor(), $arrColors) == FALSE) {
|
||||
if (in_array($fStyle->getColor(), $arrColors) == false) {
|
||||
$arrColors[] = $fStyle->getColor();
|
||||
}
|
||||
if (in_array($fStyle->getFgColor(), $arrColors) == FALSE) {
|
||||
if (in_array($fStyle->getFgColor(), $arrColors) == false) {
|
||||
$arrColors[] = $fStyle->getFgColor();
|
||||
}
|
||||
}
|
||||
@ -294,7 +294,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
return $arrColors;
|
||||
}
|
||||
|
||||
private function _getDataContent()
|
||||
private function getDataContent()
|
||||
{
|
||||
$pPHPWord = $this->_document;
|
||||
$sRTFBody = '';
|
||||
@ -309,11 +309,11 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
$_elements = $section->getElements();
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$sRTFBody .= $this->_getDataContent_writeText($element);
|
||||
$sRTFBody .= $this->getDataContentText($element);
|
||||
} elseif ($element instanceof PHPWord_Section_TextBreak) {
|
||||
$sRTFBody .= $this->_getDataContent_writeTextBreak();
|
||||
$sRTFBody .= $this->getDataContentTextBreak();
|
||||
} elseif ($element instanceof PHPWord_Section_TextRun) {
|
||||
$sRTFBody .= $this->_getDataContent_writeTextRun($element);
|
||||
$sRTFBody .= $this->getDataContentTextRun($element);
|
||||
/*
|
||||
} elseif($element instanceof PHPWord_Section_Link) {
|
||||
$this->_writeLink($objWriter, $element);
|
||||
@ -346,7 +346,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
/**
|
||||
* Get text
|
||||
*/
|
||||
private function _getDataContent_writeText(PHPWord_Section_Text $text, $withoutP = false)
|
||||
private function getDataContentText(PHPWord_Section_Text $text, $withoutP = false)
|
||||
{
|
||||
$sRTFText = '';
|
||||
|
||||
@ -384,7 +384,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
if ($styleFont) {
|
||||
if ($styleFont->getColor() != null) {
|
||||
$idxColor = array_search($styleFont->getColor(), $this->_colorTable);
|
||||
if ($idxColor !== FALSE) {
|
||||
if ($idxColor !== false) {
|
||||
$sRTFText .= '\cf' . ($idxColor + 1);
|
||||
}
|
||||
} else {
|
||||
@ -392,7 +392,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
}
|
||||
if ($styleFont->getName() != null) {
|
||||
$idxFont = array_search($styleFont->getName(), $this->_fontTable);
|
||||
if ($idxFont !== FALSE) {
|
||||
if ($idxFont !== false) {
|
||||
$sRTFText .= '\f' . $idxFont;
|
||||
}
|
||||
} else {
|
||||
@ -411,7 +411,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
if ($this->_lastParagraphStyle != '' || $styleFont) {
|
||||
$sRTFText .= ' ';
|
||||
}
|
||||
$sRTFText .= $text->getText();
|
||||
$sRTFText .= $text->getDataContentText();
|
||||
|
||||
if ($styleFont) {
|
||||
$sRTFText .= '\cf0';
|
||||
@ -437,7 +437,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
/**
|
||||
* Get text run content
|
||||
*/
|
||||
private function _getDataContent_writeTextRun(PHPWord_Section_TextRun $textrun)
|
||||
private function getDataContentTextRun(PHPWord_Section_TextRun $textrun)
|
||||
{
|
||||
$sRTFText = '';
|
||||
$elements = $textrun->getElements();
|
||||
@ -446,7 +446,7 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$sRTFText .= '{';
|
||||
$sRTFText .= $this->_getDataContent_writeText($element, true);
|
||||
$sRTFText .= $this->getDataContentText($element, true);
|
||||
$sRTFText .= '}' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
@ -455,12 +455,10 @@ class PHPWord_Writer_RTF implements PHPWord_Writer_IWriter
|
||||
return $sRTFText;
|
||||
}
|
||||
|
||||
private function _getDataContent_writeTextBreak()
|
||||
private function getDataContentTextBreak()
|
||||
{
|
||||
$this->_lastParagraphStyle = '';
|
||||
|
||||
return '\par' . PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,8 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
||||
|
||||
$footnoteLinks = array();
|
||||
$_footnoteElements = PHPWord_Footnote::getFootnoteLinkElements();
|
||||
foreach($_footnoteElements as $element) { // loop through footnote link elements
|
||||
// loop through footnote link elements
|
||||
foreach ($_footnoteElements as $element) {
|
||||
$footnoteLinks[] = $element;
|
||||
}
|
||||
|
||||
@ -204,8 +205,9 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
||||
$imagetype = image_type_to_mime_type($imagedata[2]);
|
||||
$imageext = image_type_to_extension($imagedata[2]);
|
||||
$imageext = str_replace('.', '', $imageext);
|
||||
if ($imageext == 'jpeg') $imageext = 'jpg';
|
||||
|
||||
if ($imageext == 'jpeg') {
|
||||
$imageext = 'jpg';
|
||||
}
|
||||
if (!in_array($imagetype, $this->_imageTypes)) {
|
||||
$this->_imageTypes[$imageext] = $imagetype;
|
||||
}
|
||||
@ -262,4 +264,4 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
|
||||
$this->_chkContentTypes($element['source']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
||||
$this->_writeLink($objWriter, $element, true);
|
||||
} elseif ($element instanceof PHPWord_Section_Image) {
|
||||
$this->_writeImage($objWriter, $element, true);
|
||||
} elseif($element instanceof PHPWord_Section_Footnote) {
|
||||
} elseif ($element instanceof PHPWord_Section_Footnote) {
|
||||
$this->_writeFootnoteReference($objWriter, $element, true);
|
||||
}
|
||||
}
|
||||
@ -875,7 +875,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
protected function _writeFootnote(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote) {
|
||||
protected function _writeFootnote(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote)
|
||||
{
|
||||
$objWriter->startElement('w:footnote');
|
||||
$objWriter->writeAttribute('w:id', $footnote->getReferenceId());
|
||||
|
||||
@ -884,22 +885,22 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
||||
|
||||
$objWriter->startElement('w:p');
|
||||
|
||||
if($SpIsObject) {
|
||||
if ($SpIsObject) {
|
||||
$this->_writeParagraphStyle($objWriter, $styleParagraph);
|
||||
} elseif(!$SpIsObject && !is_null($styleParagraph)) {
|
||||
} elseif (!$SpIsObject && !is_null($styleParagraph)) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleParagraph);
|
||||
$objWriter->endElement();
|
||||
$objWriter->startElement('w:pStyle');
|
||||
$objWriter->writeAttribute('w:val', $styleParagraph);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$elements = $footnote->getElements();
|
||||
if(count($elements) > 0) {
|
||||
foreach($elements as $element) {
|
||||
if($element instanceof PHPWord_Section_Text) {
|
||||
if (count($elements) > 0) {
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof PHPWord_Section_Text) {
|
||||
$this->_writeText($objWriter, $element, true);
|
||||
} elseif($element instanceof PHPWord_Section_Link) {
|
||||
} elseif ($element instanceof PHPWord_Section_Link) {
|
||||
$this->_writeLink($objWriter, $element, true);
|
||||
}
|
||||
}
|
||||
@ -909,7 +910,8 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
||||
$objWriter->endElement(); // w:footnote
|
||||
}
|
||||
|
||||
protected function _writeFootnoteReference(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote, $withoutP = false) {
|
||||
protected function _writeFootnoteReference(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section_Footnote $footnote, $withoutP = false)
|
||||
{
|
||||
if (!$withoutP) {
|
||||
$objWriter->startElement('w:p');
|
||||
}
|
||||
|
||||
@ -50,12 +50,16 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
||||
|
||||
// Rels
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
|
||||
$objWriter,
|
||||
'rels',
|
||||
'application/vnd.openxmlformats-package.relationships+xml'
|
||||
);
|
||||
|
||||
// XML
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'xml', 'application/xml'
|
||||
$objWriter,
|
||||
'xml',
|
||||
'application/xml'
|
||||
);
|
||||
|
||||
// Add media content-types
|
||||
@ -65,62 +69,88 @@ class PHPWord_Writer_Word2007_ContentTypes extends PHPWord_Writer_Word2007_Write
|
||||
|
||||
// Add embedding content-types
|
||||
if (count($_objectTypes) > 0) {
|
||||
$this->_writeDefaultContentType($objWriter, 'bin', 'application/vnd.openxmlformats-officedocument.oleObject');
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter,
|
||||
'bin',
|
||||
'application/vnd.openxmlformats-officedocument.oleObject'
|
||||
);
|
||||
}
|
||||
|
||||
// DocProps
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
||||
$objWriter,
|
||||
'/docProps/app.xml',
|
||||
'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
||||
);
|
||||
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
|
||||
$objWriter,
|
||||
'/docProps/core.xml',
|
||||
'application/vnd.openxmlformats-package.core-properties+xml'
|
||||
);
|
||||
|
||||
// Document
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/document.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'
|
||||
$objWriter,
|
||||
'/word/document.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'
|
||||
);
|
||||
|
||||
// Styles
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/styles.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml'
|
||||
$objWriter,
|
||||
'/word/styles.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml'
|
||||
);
|
||||
|
||||
// Numbering
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/numbering.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml'
|
||||
$objWriter,
|
||||
'/word/numbering.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml'
|
||||
);
|
||||
|
||||
// Settings
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/settings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml'
|
||||
$objWriter,
|
||||
'/word/settings.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml'
|
||||
);
|
||||
|
||||
// Theme1
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
|
||||
$objWriter,
|
||||
'/word/theme/theme1.xml',
|
||||
'application/vnd.openxmlformats-officedocument.theme+xml'
|
||||
);
|
||||
|
||||
// WebSettings
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/webSettings.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml'
|
||||
$objWriter,
|
||||
'/word/webSettings.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml'
|
||||
);
|
||||
|
||||
// Font Table
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/fontTable.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml'
|
||||
$objWriter,
|
||||
'/word/fontTable.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml'
|
||||
);
|
||||
|
||||
for ($i = 1; $i <= $_cHdrs; $i++) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/header' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
|
||||
$objWriter,
|
||||
'/word/header' . $i . '.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
|
||||
);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $_cFtrs; $i++) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/word/footer' . $i . '.xml', 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
|
||||
$objWriter,
|
||||
'/word/footer' . $i . '.xml',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ class PHPWord_Writer_Word2007_Document extends PHPWord_Writer_Word2007_Base
|
||||
$this->_writeObject($objWriter, $element);
|
||||
} elseif ($element instanceof PHPWord_TOC) {
|
||||
$this->_writeTOC($objWriter);
|
||||
} elseif($element instanceof PHPWord_Section_Footnote) {
|
||||
} elseif ($element instanceof PHPWord_Section_Footnote) {
|
||||
$this->_writeFootnoteReference($objWriter, $element);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,8 +26,10 @@
|
||||
*/
|
||||
|
||||
|
||||
class PHPWord_Writer_Word2007_Footnotes extends PHPWord_Writer_Word2007_Base {
|
||||
public function writeFootnotes($allFootnotesCollection) {
|
||||
class PHPWord_Writer_Word2007_Footnotes extends PHPWord_Writer_Word2007_Base
|
||||
{
|
||||
public function writeFootnotes($allFootnotesCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
@ -40,8 +42,8 @@ class PHPWord_Writer_Word2007_Footnotes extends PHPWord_Writer_Word2007_Base {
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
$objWriter->startElement('w:footnotes');
|
||||
$objWriter->writeAttribute('xmlns:r','http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:w','http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||
|
||||
// write separator and continuation separator
|
||||
$objWriter->startElement('w:footnote');
|
||||
@ -67,8 +69,8 @@ class PHPWord_Writer_Word2007_Footnotes extends PHPWord_Writer_Word2007_Base {
|
||||
$objWriter->endElement(); // w:footnote
|
||||
|
||||
|
||||
foreach($allFootnotesCollection as $footnote) {
|
||||
if($footnote instanceof PHPWord_Section_Footnote) {
|
||||
foreach ($allFootnotesCollection as $footnote) {
|
||||
if ($footnote instanceof PHPWord_Section_Footnote) {
|
||||
$this->_writeFootnote($objWriter, $footnote);
|
||||
}
|
||||
}
|
||||
@ -78,4 +80,4 @@ class PHPWord_Writer_Word2007_Footnotes extends PHPWord_Writer_Word2007_Base {
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,64 +26,61 @@
|
||||
*/
|
||||
|
||||
|
||||
class PHPWord_Writer_Word2007_FootnotesRels extends PHPWord_Writer_Word2007_WriterPart {
|
||||
public function writeFootnotesRels($_relsCollection) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
class PHPWord_Writer_Word2007_FootnotesRels extends PHPWord_Writer_Word2007_WriterPart
|
||||
{
|
||||
public function writeFootnotesRels($_relsCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationships to Links
|
||||
foreach ($_relsCollection as $relation) {
|
||||
$relationType = $relation['type'];
|
||||
$relationName = $relation['target'];
|
||||
$relationId = $relation['rID'];
|
||||
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
|
||||
|
||||
$this->_writeRelationship($objWriter, $relationId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $relationType, $relationName, $targetMode);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||
{
|
||||
if ($pType != '' && $pTarget != '') {
|
||||
if (strpos($pId, 'rId') === false) {
|
||||
$pId = 'rId' . $pId;
|
||||
}
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
// Write relationship
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', $pId);
|
||||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
|
||||
// Relationships to Links
|
||||
foreach($_relsCollection as $relation) {
|
||||
$relationType = $relation['type'];
|
||||
$relationName = $relation['target'];
|
||||
$relationId = $relation['rID'];
|
||||
$targetMode = ($relationType == 'hyperlink') ? 'External' : '';
|
||||
if ($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$relationId,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/'.$relationType,
|
||||
$relationName,
|
||||
$targetMode
|
||||
);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
private function _writeRelationship(PHPWord_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') {
|
||||
if($pType != '' && $pTarget != '') {
|
||||
if(strpos($pId, 'rId') === false) {
|
||||
$pId = 'rId' . $pId;
|
||||
}
|
||||
|
||||
// Write relationship
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', $pId);
|
||||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
|
||||
if($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user