|
@@ -120,16 +120,16 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|
|
$this->addHeaderFooterMedia($zip, 'footer');
|
|
$this->addHeaderFooterMedia($zip, 'footer');
|
|
|
|
|
|
|
|
// Add header/footer contents
|
|
// Add header/footer contents
|
|
|
- $rId = Media::countElements('section') + 6; // @see Rels::writeDocRels for 6 first elements
|
|
|
|
|
|
|
+ $rID = Media::countElements('section') + 6; // @see Rels::writeDocRels for 6 first elements
|
|
|
$sections = $phpWord->getSections();
|
|
$sections = $phpWord->getSections();
|
|
|
foreach ($sections as $section) {
|
|
foreach ($sections as $section) {
|
|
|
- $this->addHeaderFooterContent($section, $zip, 'header', $rId);
|
|
|
|
|
- $this->addHeaderFooterContent($section, $zip, 'footer', $rId);
|
|
|
|
|
|
|
+ $this->addHeaderFooterContent($section, $zip, 'header', $rID);
|
|
|
|
|
+ $this->addHeaderFooterContent($section, $zip, 'footer', $rID);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $this->addNotes($zip, $rId, 'footnote');
|
|
|
|
|
- $this->addNotes($zip, $rId, 'endnote');
|
|
|
|
|
- $this->addChart($zip, $rId);
|
|
|
|
|
|
|
+ $this->addNotes($zip, $rID, 'footnote');
|
|
|
|
|
+ $this->addNotes($zip, $rID, 'endnote');
|
|
|
|
|
+ $this->addChart($zip, $rID);
|
|
|
|
|
|
|
|
// Write parts
|
|
// Write parts
|
|
|
foreach ($this->parts as $partName => $fileName) {
|
|
foreach ($this->parts as $partName => $fileName) {
|
|
@@ -195,21 +195,21 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|
|
* @param \PhpOffice\PhpWord\Element\Section &$section
|
|
* @param \PhpOffice\PhpWord\Element\Section &$section
|
|
|
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
|
|
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
|
|
|
* @param string $elmType header|footer
|
|
* @param string $elmType header|footer
|
|
|
- * @param integer &$rId
|
|
|
|
|
|
|
+ * @param integer &$rID
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
- private function addHeaderFooterContent(Section &$section, ZipArchive $zip, $elmType, &$rId)
|
|
|
|
|
|
|
+ private function addHeaderFooterContent(Section &$section, ZipArchive $zip, $elmType, &$rID)
|
|
|
{
|
|
{
|
|
|
$getFunction = $elmType == 'header' ? 'getHeaders' : 'getFooters';
|
|
$getFunction = $elmType == 'header' ? 'getHeaders' : 'getFooters';
|
|
|
- $elmCount = ($section->getSectionId() - 1) * 3;
|
|
|
|
|
|
|
+ $elmCount = ($section->getSectionID() - 1) * 3;
|
|
|
$elements = $section->$getFunction();
|
|
$elements = $section->$getFunction();
|
|
|
foreach ($elements as &$element) {
|
|
foreach ($elements as &$element) {
|
|
|
/** @var \PhpOffice\PhpWord\Element\AbstractElement $element Type hint */
|
|
/** @var \PhpOffice\PhpWord\Element\AbstractElement $element Type hint */
|
|
|
$elmCount++;
|
|
$elmCount++;
|
|
|
- $element->setRelationId(++$rId);
|
|
|
|
|
|
|
+ $element->setRelationID(++$rID);
|
|
|
$elmFile = "{$elmType}{$elmCount}.xml"; // e.g. footer1.xml
|
|
$elmFile = "{$elmType}{$elmCount}.xml"; // e.g. footer1.xml
|
|
|
$this->contentTypes['override']["/word/$elmFile"] = $elmType;
|
|
$this->contentTypes['override']["/word/$elmFile"] = $elmType;
|
|
|
- $this->relationships[] = array('target' => $elmFile, 'type' => $elmType, 'rID' => $rId);
|
|
|
|
|
|
|
+ $this->relationships[] = array('target' => $elmFile, 'type' => $elmType, 'rID' => $rID);
|
|
|
|
|
|
|
|
/** @var \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart $writerPart Type hint */
|
|
/** @var \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart $writerPart Type hint */
|
|
|
$writerPart = $this->getWriterPart($elmType)->setElement($element);
|
|
$writerPart = $this->getWriterPart($elmType)->setElement($element);
|
|
@@ -221,11 +221,11 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|
|
* Add footnotes/endnotes
|
|
* Add footnotes/endnotes
|
|
|
*
|
|
*
|
|
|
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
|
|
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
|
|
|
- * @param integer &$rId
|
|
|
|
|
|
|
+ * @param integer &$rID
|
|
|
* @param string $noteType
|
|
* @param string $noteType
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
- private function addNotes(ZipArchive $zip, &$rId, $noteType = 'footnote')
|
|
|
|
|
|
|
+ private function addNotes(ZipArchive $zip, &$rID, $noteType = 'footnote')
|
|
|
{
|
|
{
|
|
|
$phpWord = $this->getPhpWord();
|
|
$phpWord = $this->getPhpWord();
|
|
|
$noteType = ($noteType == 'endnote') ? 'endnote' : 'footnote';
|
|
$noteType = ($noteType == 'endnote') ? 'endnote' : 'footnote';
|
|
@@ -240,7 +240,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|
|
$this->addFilesToPackage($zip, $media);
|
|
$this->addFilesToPackage($zip, $media);
|
|
|
$this->registerContentTypes($media);
|
|
$this->registerContentTypes($media);
|
|
|
$this->contentTypes['override']["/word/{$partName}.xml"] = $partName;
|
|
$this->contentTypes['override']["/word/{$partName}.xml"] = $partName;
|
|
|
- $this->relationships[] = array('target' => "{$partName}.xml", 'type' => $partName, 'rID' => ++$rId);
|
|
|
|
|
|
|
+ $this->relationships[] = array('target' => "{$partName}.xml", 'type' => $partName, 'rID' => ++$rID);
|
|
|
|
|
|
|
|
// Write relationships file, e.g. word/_rels/footnotes.xml
|
|
// Write relationships file, e.g. word/_rels/footnotes.xml
|
|
|
if (!empty($media)) {
|
|
if (!empty($media)) {
|
|
@@ -259,10 +259,10 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|
|
* Add chart.
|
|
* Add chart.
|
|
|
*
|
|
*
|
|
|
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
|
|
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
|
|
|
- * @param integer &$rId
|
|
|
|
|
|
|
+ * @param integer &$rID
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
- private function addChart(ZipArchive $zip, &$rId)
|
|
|
|
|
|
|
+ private function addChart(ZipArchive $zip, &$rID)
|
|
|
{
|
|
{
|
|
|
$phpWord = $this->getPhpWord();
|
|
$phpWord = $this->getPhpWord();
|
|
|
|
|
|
|
@@ -271,18 +271,18 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|
|
if ($collection->countItems() > 0) {
|
|
if ($collection->countItems() > 0) {
|
|
|
foreach ($collection->getItems() as $chart) {
|
|
foreach ($collection->getItems() as $chart) {
|
|
|
$index++;
|
|
$index++;
|
|
|
- $rId++;
|
|
|
|
|
|
|
+ $rID++;
|
|
|
$filename = "charts/chart{$index}.xml";
|
|
$filename = "charts/chart{$index}.xml";
|
|
|
|
|
|
|
|
// ContentTypes.xml
|
|
// ContentTypes.xml
|
|
|
$this->contentTypes['override']["/word/{$filename}"] = 'chart';
|
|
$this->contentTypes['override']["/word/{$filename}"] = 'chart';
|
|
|
|
|
|
|
|
// word/_rels/document.xml.rel
|
|
// word/_rels/document.xml.rel
|
|
|
- $this->relationships[] = array('target' => $filename, 'type' => 'chart', 'rID' => $rId);
|
|
|
|
|
|
|
+ $this->relationships[] = array('target' => $filename, 'type' => 'chart', 'rID' => $rID);
|
|
|
|
|
|
|
|
// word/charts/chartN.xml
|
|
// word/charts/chartN.xml
|
|
|
/** @var \PhpOffice\PhpWord\Element\Chart $chart */
|
|
/** @var \PhpOffice\PhpWord\Element\Chart $chart */
|
|
|
- $chart->setRelationId($rId);
|
|
|
|
|
|
|
+ $chart->setRelationID($rID);
|
|
|
$writerPart = $this->getWriterPart('Chart');
|
|
$writerPart = $this->getWriterPart('Chart');
|
|
|
$writerPart->setElement($chart);
|
|
$writerPart->setElement($chart);
|
|
|
$zip->addFromString("word/{$filename}", $writerPart->write());
|
|
$zip->addFromString("word/{$filename}", $writerPart->write());
|