From 9ba8db761b71b1d0dea43cac98ec18a60ae1911b Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 10:51:53 -0700 Subject: [PATCH 1/8] Update docs/topics/reading-and-writing-to-file.md Co-authored-by: Adrien Crivelli --- docs/topics/reading-and-writing-to-file.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/topics/reading-and-writing-to-file.md b/docs/topics/reading-and-writing-to-file.md index abd7c5f3..aa885f61 100644 --- a/docs/topics/reading-and-writing-to-file.md +++ b/docs/topics/reading-and-writing-to-file.md @@ -703,7 +703,7 @@ echo $writer->generateSheetData(); echo $writer->generateHTMLFooter(); ``` -#### Editing HTML During Save Via a Callback +#### Editing HTML during save via a callback You can also add a callback function to edit the generated html before saving. For example, you could add a webfont From 7e87a9f8d8cdd25dfec07ee2a9a12b791183bf09 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 10:54:30 -0700 Subject: [PATCH 2/8] Update samples/Pdf/21a_Pdf.php Co-authored-by: Adrien Crivelli --- samples/Pdf/21a_Pdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Pdf/21a_Pdf.php b/samples/Pdf/21a_Pdf.php index c4dc2c48..6ab1938f 100644 --- a/samples/Pdf/21a_Pdf.php +++ b/samples/Pdf/21a_Pdf.php @@ -25,7 +25,7 @@ background-color: yellow; EOF; - return preg_replace('@@', "$newstyle", $html); + return preg_replace('~~', "$newstyle", $html); } $helper->log('Write to Dompdf'); From 32b01148f438d534d09739c62c5a8162cfce1ebf Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 10:56:27 -0700 Subject: [PATCH 3/8] Update src/PhpSpreadsheet/Writer/Html.php Co-authored-by: Adrien Crivelli --- src/PhpSpreadsheet/Writer/Html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 963b02d7..2796de50 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -197,9 +197,9 @@ class Html extends BaseWriter // Write footer $html .= $this->generateHTMLFooter(); - $cbk = $this->editHtmlCallback; - if ($cbk) { - $html = $cbk($html); + $callback = $this->editHtmlCallback; + if ($callback) { + $html = $callback($html); } Calculation::setArrayReturnType($saveArrayReturnType); From 68002815ec436157e851d863d4968e9b0417f59a Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 10:59:10 -0700 Subject: [PATCH 4/8] Update src/PhpSpreadsheet/Writer/Html.php Co-authored-by: Adrien Crivelli --- src/PhpSpreadsheet/Writer/Html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 2796de50..1403d9be 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -134,9 +134,9 @@ class Html extends BaseWriter /** * Callback for editing generated html. * - * @var callable + * @var null|callable */ - protected $editHtmlCallback = ''; + protected $editHtmlCallback = null; /** * Create a new HTML. From f42c3ef5a093571f22922c9e708896313e8109a2 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 10:59:52 -0700 Subject: [PATCH 5/8] Update src/PhpSpreadsheet/Writer/Html.php Co-authored-by: Adrien Crivelli --- src/PhpSpreadsheet/Writer/Html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 1403d9be..fceec678 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -208,7 +208,7 @@ class Html extends BaseWriter return $html; } - public function setEditHtmlCallback(callable $cbk): void + public function setEditHtmlCallback(?callable $cbk): void { $this->editHtmlCallback = $cbk; } From 39eeef5ec658b796a689694a3ea66d95de596910 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 11:01:14 -0700 Subject: [PATCH 6/8] Update src/PhpSpreadsheet/Writer/Html.php Co-authored-by: Adrien Crivelli --- src/PhpSpreadsheet/Writer/Html.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index fceec678..942685f6 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -213,11 +213,6 @@ class Html extends BaseWriter $this->editHtmlCallback = $cbk; } - public function resetEditHtmlCallback(): void - { - $this->editHtmlCallback = ''; - } - const VALIGN_ARR = [ Alignment::VERTICAL_BOTTOM => 'bottom', Alignment::VERTICAL_TOP => 'top', From 48c65cff7fe76dc587757ce3e29d482af9055be0 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 11:11:18 -0700 Subject: [PATCH 7/8] Update CallbackTest.php resetEditHtmlCallback was removed per suggestions from PowerKiki --- tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php b/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php index f712419c..388dbd0e 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/CallbackTest.php @@ -33,7 +33,7 @@ EOF; $html1 = $writer->generateHTMLall(); $writer->setEditHtmlCallback([$this, 'yellowBody']); $html2 = $writer->generateHTMLall(); - $writer->resetEditHtmlCallback(); + $writer->setEditHtmlCallback(null); $html3 = $writer->generateHTMLall(); self::assertFalse(strpos($html1, 'background-color: yellow')); From bbaf03c2efec48720c67dbaa8f3b2aab6a112786 Mon Sep 17 00:00:00 2001 From: oleibman Date: Sun, 31 May 2020 11:18:47 -0700 Subject: [PATCH 8/8] Update Html.php Travis says no need to initialize private class variable to null. --- src/PhpSpreadsheet/Writer/Html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 942685f6..752f286f 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -136,7 +136,7 @@ class Html extends BaseWriter * * @var null|callable */ - protected $editHtmlCallback = null; + protected $editHtmlCallback; /** * Create a new HTML.