Skip to content

Commit 915be63

Browse files
committed
#125 : PHP CS
1 parent ba9d147 commit 915be63

File tree

5 files changed

+63
-62
lines changed

5 files changed

+63
-62
lines changed

src/PhpPresentation/PresentationProperties.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class PresentationProperties
3131
* @var bool
3232
*/
3333
protected $markAsFinal = false;
34-
35-
/*
36-
* @var string
37-
*/
38-
protected $thumbnail;
34+
35+
/*
36+
* @var string
37+
*/
38+
protected $thumbnail;
3939

4040
/**
4141
* Zoom
@@ -64,7 +64,7 @@ public function setLoopContinuouslyUntilEsc($value = false)
6464
}
6565

6666
/**
67-
* Return the thumbnail file path
67+
* Return the thumbnail file path
6868
* @return string
6969
*/
7070
public function getThumbnailPath()
@@ -73,15 +73,15 @@ public function getThumbnailPath()
7373
}
7474

7575
/**
76-
* Define the path for the thumbnail file / preview picture
76+
* Define the path for the thumbnail file / preview picture
7777
* @param string $value
7878
* @return \PhpOffice\PhpPresentation\PresentationProperties
7979
*/
8080
public function setThumbnailPath($path = '')
8181
{
82-
if (file_exists($path)) {
83-
$this->thumbnail = $path;
84-
}
82+
if (file_exists($path)) {
83+
$this->thumbnail = $path;
84+
}
8585
return $this;
8686
}
8787

src/PhpPresentation/Writer/ODPresentation.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -185,35 +185,35 @@ public function save($pFilename)
185185

186186
// Add META-INF/manifest.xml
187187
$objZip->addFromString('META-INF/manifest.xml', $writerPartManifest->writePart());
188-
189-
// Add Thumbnail
190-
if ($this->presentation->getPresentationProperties()->getThumbnailPath()) {
191-
$pathThumbnail = $this->presentation->getPresentationProperties()->getThumbnailPath();
192-
// Size : 128x128 pixel
193-
// PNG : 8bit, non-interlaced with full alpha transparency
194-
$gdImage = imagecreatefromstring(file_get_contents($pathThumbnail));
195-
if ($gdImage) {
196-
list($width, $height) = getimagesize($pathThumbnail);
197-
198-
$gdRender = imagecreatetruecolor(128, 128);
199-
$colorBgAlpha = imagecolorallocatealpha($gdRender, 0, 0, 0, 127);
200-
imagecolortransparent($gdRender, $colorBgAlpha);
201-
imagefill($gdRender, 0, 0, $colorBgAlpha);
202-
imagecopyresampled($gdRender, $gdImage, 0, 0, 0, 0, 128, 128, $width, $height);
203-
imagetruecolortopalette($gdRender, false, 255);
204-
imagesavealpha($gdRender, true);
205-
206-
ob_start();
188+
189+
// Add Thumbnail
190+
if ($this->presentation->getPresentationProperties()->getThumbnailPath()) {
191+
$pathThumbnail = $this->presentation->getPresentationProperties()->getThumbnailPath();
192+
// Size : 128x128 pixel
193+
// PNG : 8bit, non-interlaced with full alpha transparency
194+
$gdImage = imagecreatefromstring(file_get_contents($pathThumbnail));
195+
if ($gdImage) {
196+
list($width, $height) = getimagesize($pathThumbnail);
197+
198+
$gdRender = imagecreatetruecolor(128, 128);
199+
$colorBgAlpha = imagecolorallocatealpha($gdRender, 0, 0, 0, 127);
200+
imagecolortransparent($gdRender, $colorBgAlpha);
201+
imagefill($gdRender, 0, 0, $colorBgAlpha);
202+
imagecopyresampled($gdRender, $gdImage, 0, 0, 0, 0, 128, 128, $width, $height);
203+
imagetruecolortopalette($gdRender, false, 255);
204+
imagesavealpha($gdRender, true);
205+
206+
ob_start();
207207
imagepng($gdRender);
208208
$imageContents = ob_get_contents();
209209
ob_end_clean();
210-
211-
imagedestroy($gdRender);
212-
imagedestroy($gdImage);
210+
211+
imagedestroy($gdRender);
212+
imagedestroy($gdImage);
213213

214214
$objZip->addFromString('Thumbnails/thumbnail.png', $imageContents);
215-
}
216-
}
215+
}
216+
}
217217

218218
// Add charts
219219
foreach ($this->chartArray as $keyChart => $shapeChart) {

src/PhpPresentation/Writer/ODPresentation/Manifest.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,20 @@ public function writePart()
124124
$objWriter->endElement();
125125
}
126126
}
127-
if ($parentWriter->getPhpPresentation()->getPresentationProperties()->getThumbnailPath()) {
128-
$pathThumbnail = $parentWriter->getPhpPresentation()->getPresentationProperties()->getThumbnailPath();
129-
// Size : 128x128 pixel
130-
// PNG : 8bit, non-interlaced with full alpha transparency
131-
$gdImage = imagecreatefromstring(file_get_contents($pathThumbnail));
132-
if ($gdImage) {
133-
imagedestroy($gdImage);
134-
$objWriter->startElement('manifest:file-entry');
135-
$objWriter->writeAttribute('manifest:media-type', 'image/png');
136-
$objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png');
137-
$objWriter->endElement();
138-
}
139-
}
127+
128+
if ($parentWriter->getPhpPresentation()->getPresentationProperties()->getThumbnailPath()) {
129+
$pathThumbnail = $parentWriter->getPhpPresentation()->getPresentationProperties()->getThumbnailPath();
130+
// Size : 128x128 pixel
131+
// PNG : 8bit, non-interlaced with full alpha transparency
132+
$gdImage = imagecreatefromstring(file_get_contents($pathThumbnail));
133+
if ($gdImage) {
134+
imagedestroy($gdImage);
135+
$objWriter->startElement('manifest:file-entry');
136+
$objWriter->writeAttribute('manifest:media-type', 'image/png');
137+
$objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png');
138+
$objWriter->endElement();
139+
}
140+
}
140141

141142
$objWriter->endElement();
142143

src/PhpPresentation/Writer/PowerPoint2007.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,20 +227,20 @@ public function save($pFilename)
227227
$objZip->addFromString('docProps/app.xml', $wPartDocProps->writeDocPropsApp($this->presentation));
228228
$objZip->addFromString('docProps/core.xml', $wPartDocProps->writeDocPropsCore($this->presentation));
229229
$objZip->addFromString('docProps/custom.xml', $wPartDocProps->writeDocPropsCustom($this->presentation));
230-
// Add Thumbnail to ZIP file
231-
if ($this->presentation->getPresentationProperties()->getThumbnailPath()) {
232-
$pathThumbnail = file_get_contents($this->presentation->getPresentationProperties()->getThumbnailPath());
233-
$gdImage = imagecreatefromstring($pathThumbnail);
234-
if ($gdImage) {
235-
ob_start();
230+
// Add Thumbnail to ZIP file
231+
if ($this->presentation->getPresentationProperties()->getThumbnailPath()) {
232+
$pathThumbnail = file_get_contents($this->presentation->getPresentationProperties()->getThumbnailPath());
233+
$gdImage = imagecreatefromstring($pathThumbnail);
234+
if ($gdImage) {
235+
ob_start();
236236
imagejpeg($gdImage);
237237
$imageContents = ob_get_contents();
238238
ob_end_clean();
239-
imagedestroy($gdImage);
239+
imagedestroy($gdImage);
240240

241241
$objZip->addFromString('docProps/thumbnail.jpeg', $imageContents);
242-
}
243-
}
242+
}
243+
}
244244

245245
$masterSlides = $this->getLayoutPack()->getMasterSlides();
246246
foreach ($masterSlides as $masterSlide) {

src/PhpPresentation/Writer/PowerPoint2007/Rels.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ public function writeRelationships(PhpPresentation $pPhpPresentation)
6565

6666
// Relationship ppt/presentation.xml
6767
$this->writeRelationship($objWriter, 1, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', 'ppt/presentation.xml');
68-
69-
if ($pPhpPresentation->getPresentationProperties()->getThumbnailPath()) {
70-
$pathThumbnail = file_get_contents($pPhpPresentation->getPresentationProperties()->getThumbnailPath());
71-
$gdImage = imagecreatefromstring($pathThumbnail);
72-
if ($gdImage) {
68+
69+
if ($pPhpPresentation->getPresentationProperties()->getThumbnailPath()) {
70+
$pathThumbnail = file_get_contents($pPhpPresentation->getPresentationProperties()->getThumbnailPath());
71+
$gdImage = imagecreatefromstring($pathThumbnail);
72+
if ($gdImage) {
7373
imagedestroy($gdImage);
7474
// Relationship docProps/thumbnail.jpeg
7575
$this->writeRelationship($objWriter, 5, 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail', 'docProps/thumbnail.jpeg');
7676
}
77-
}
77+
}
7878

7979
$objWriter->endElement();
8080

0 commit comments

Comments
 (0)