From 7c8ff2884bcbd0e075929e221580d3e266d97a29 Mon Sep 17 00:00:00 2001 From: jogo Date: Fri, 4 Jul 2014 15:31:48 +0200 Subject: [PATCH] add sample fix undefined Index --- samples/Sample_35_InternalLink.php | 22 ++++++++++++++++++++++ src/PhpWord/PhpWord.php | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 samples/Sample_35_InternalLink.php diff --git a/samples/Sample_35_InternalLink.php b/samples/Sample_35_InternalLink.php new file mode 100644 index 00000000..3b6aae51 --- /dev/null +++ b/samples/Sample_35_InternalLink.php @@ -0,0 +1,22 @@ +addSection(); +$section->addTitle( 'This is page 1', 1 ); +$linkIsInternal = true; +$section->addLink('MyBookmark', 'Take me to page 3', null ,null,$linkIsInternal); +$section->addPageBreak(); +$section->addTitle( 'This is page 2', 1 ); +$section->addPageBreak(); +$section->addTitle( 'This is page 3', 1 ); +$section->addBookmark('MyBookmark'); + +// Save file +echo write($phpWord, basename(__FILE__, '.php'), $writers); +if (!CLI) { + include_once 'Sample_Footer.php'; +} diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 419af4be..cde4351e 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -139,7 +139,7 @@ class PhpWord /** @var \PhpOffice\PhpWord\Collection\AbstractCollection $collectionObject */ $collectionObject = $this->collections[$key]; - return $collectionObject->addItem($args[0]); + return $collectionObject->addItem(array_key_exists(0,$args) ? $args[0] : null); } // Run add style method