|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Header file |
|
4
|
|
|
*/ |
|
5
|
|
|
use PhpOffice\PhpPresentation\Autoloader; |
|
6
|
|
|
use PhpOffice\PhpPresentation\IOFactory; |
|
7
|
|
|
use PhpOffice\PhpPresentation\Slide; |
|
8
|
|
|
use PhpOffice\PhpPresentation\PhpPresentation; |
|
9
|
|
|
use PhpOffice\PhpPresentation\AbstractShape; |
|
10
|
|
|
use PhpOffice\PhpPresentation\DocumentLayout; |
|
11
|
|
|
use PhpOffice\PhpPresentation\Shape\Drawing; |
|
12
|
|
|
use PhpOffice\PhpPresentation\Shape\Group; |
|
13
|
|
|
use PhpOffice\PhpPresentation\Shape\RichText; |
|
14
|
|
|
use PhpOffice\PhpPresentation\Shape\RichText\BreakElement; |
|
15
|
|
|
use PhpOffice\PhpPresentation\Shape\RichText\TextElement; |
|
16
|
|
|
use PhpOffice\PhpPresentation\Style\Alignment; |
|
17
|
|
|
use PhpOffice\PhpPresentation\Style\Bullet; |
|
18
|
|
|
use PhpOffice\PhpPresentation\Style\Color; |
|
19
|
|
|
|
|
20
|
|
|
error_reporting(E_ALL); |
|
21
|
|
|
define('CLI', (PHP_SAPI == 'cli') ? true : false); |
|
22
|
|
|
define('EOL', CLI ? PHP_EOL : '<br />'); |
|
23
|
|
|
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php')); |
|
24
|
|
|
define('IS_INDEX', SCRIPT_FILENAME == 'index'); |
|
25
|
|
|
|
|
26
|
|
|
require_once __DIR__ . '/../src/PhpPresentation/Autoloader.php'; |
|
27
|
|
|
Autoloader::register(); |
|
28
|
|
|
|
|
29
|
|
|
if (is_file(__DIR__. '/../../../../vendor/autoload.php')) { |
|
30
|
|
|
require_once __DIR__ . '/../../../../vendor/autoload.php'; |
|
31
|
|
|
} else { |
|
32
|
|
|
throw new Exception ('Can not find the vendor folder!'); |
|
33
|
|
|
} |
|
34
|
|
|
// do some checks to make sure the outputs are set correctly. |
|
35
|
|
|
if (is_dir(__DIR__.DIRECTORY_SEPARATOR.'results') === FALSE) { |
|
36
|
|
|
throw new Exception ('The results folder is not present!'); |
|
37
|
|
|
} |
|
38
|
|
|
if (is_writable(__DIR__.DIRECTORY_SEPARATOR.'results'.DIRECTORY_SEPARATOR) === FALSE) { |
|
39
|
|
|
throw new Exception ('The results folder is not writable!'); |
|
40
|
|
|
} |
|
41
|
|
|
if (is_writable(__DIR__.DIRECTORY_SEPARATOR) === FALSE) { |
|
42
|
|
|
throw new Exception ('The samples folder is not writable!'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
// Set writers |
|
46
|
|
|
$writers = array('PowerPoint2007' => 'pptx', 'ODPresentation' => 'odp'); |
|
47
|
|
|
|
|
48
|
|
|
// Return to the caller script when runs by CLI |
|
49
|
|
|
if (CLI) { |
|
50
|
|
|
return; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
// Set titles and names |
|
54
|
|
|
$pageHeading = str_replace('_', ' ', SCRIPT_FILENAME); |
|
55
|
|
|
$pageTitle = IS_INDEX ? 'Welcome to ' : "{$pageHeading} - "; |
|
56
|
|
|
$pageTitle .= 'PHPPresentation'; |
|
57
|
|
|
$pageHeading = IS_INDEX ? '' : "<h1>{$pageHeading}</h1>"; |
|
58
|
|
|
|
|
59
|
|
|
$oShapeDrawing = new Drawing\File(); |
|
60
|
|
|
$oShapeDrawing->setName('PHPPresentation logo') |
|
61
|
|
|
->setDescription('PHPPresentation logo') |
|
62
|
|
|
->setPath('./resources/phppowerpoint_logo.gif') |
|
63
|
|
|
->setHeight(36) |
|
64
|
|
|
->setOffsetX(10) |
|
65
|
|
|
->setOffsetY(10); |
|
66
|
|
|
$oShapeDrawing->getShadow()->setVisible(true) |
|
67
|
|
|
->setDirection(45) |
|
68
|
|
|
->setDistance(10); |
|
69
|
|
|
$oShapeDrawing->getHyperlink()->setUrl('https://github.com/PHPOffice/PHPPresentation/')->setTooltip('PHPPresentation'); |
|
70
|
|
|
|
|
71
|
|
|
// Create a shape (text) |
|
72
|
|
|
$oShapeRichText = new RichText(); |
|
73
|
|
|
$oShapeRichText->setHeight(300) |
|
74
|
|
|
->setWidth(600) |
|
75
|
|
|
->setOffsetX(170) |
|
76
|
|
|
->setOffsetY(180); |
|
77
|
|
|
$oShapeRichText->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_CENTER ); |
|
78
|
|
|
$textRun = $oShapeRichText->createTextRun('Thank you for using PHPPresentation!'); |
|
79
|
|
|
$textRun->getFont()->setBold(true) |
|
80
|
|
|
->setSize(60) |
|
81
|
|
|
->setColor( new Color( 'FFE06B20' ) ); |
|
82
|
|
|
|
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
// Populate samples |
|
86
|
|
|
$files = array(); |
|
87
|
|
|
if ($handle = opendir('.')) { |
|
88
|
|
|
while (false !== ($file = readdir($handle))) { |
|
89
|
|
|
if (preg_match('/^Sample_\d+_/', $file)) { |
|
90
|
|
|
$name = str_replace('_', ' ', preg_replace('/(Sample_|\.php)/', '', $file)); |
|
91
|
|
|
$group = substr($name, 0, 1); |
|
92
|
|
|
if (!isset($files[$group])) { |
|
93
|
|
|
$files[$group] = ''; |
|
94
|
|
|
} |
|
95
|
|
|
$files[$group] .= "<li><a href='{$file}'>{$name}</a></li>"; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
closedir($handle); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Write documents |
|
103
|
|
|
* |
|
104
|
|
|
* @param \PhpOffice\PhpPresentation\PhpPresentation $phpPresentation |
|
105
|
|
|
* @param string $filename |
|
106
|
|
|
* @param array $writers |
|
107
|
|
|
* @return string |
|
108
|
|
|
*/ |
|
109
|
|
|
function write($phpPresentation, $filename, $writers) |
|
110
|
|
|
{ |
|
111
|
|
|
$result = ''; |
|
112
|
|
|
|
|
113
|
|
|
// Write documents |
|
114
|
|
|
foreach ($writers as $writer => $extension) { |
|
115
|
|
|
$result .= date('H:i:s') . " Write to {$writer} format"; |
|
116
|
|
|
if (!is_null($extension)) { |
|
117
|
|
|
$xmlWriter = IOFactory::createWriter($phpPresentation, $writer); |
|
118
|
|
|
$xmlWriter->save(__DIR__ . "/{$filename}.{$extension}"); |
|
119
|
|
|
rename(__DIR__ . "/{$filename}.{$extension}", __DIR__ . "/results/{$filename}.{$extension}"); |
|
120
|
|
|
} else { |
|
121
|
|
|
$result .= ' ... NOT DONE!'; |
|
122
|
|
|
} |
|
123
|
|
|
$result .= EOL; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
$result .= getEndingNotes($writers); |
|
127
|
|
|
|
|
128
|
|
|
return $result; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* Get ending notes |
|
133
|
|
|
* |
|
134
|
|
|
* @param array $writers |
|
135
|
|
|
* @return string |
|
136
|
|
|
*/ |
|
137
|
|
|
function getEndingNotes($writers) |
|
138
|
|
|
{ |
|
139
|
|
|
$result = ''; |
|
140
|
|
|
|
|
141
|
|
|
// Do not show execution time for index |
|
142
|
|
|
if (!IS_INDEX) { |
|
143
|
|
|
$result .= date('H:i:s') . " Done writing file(s)" . EOL; |
|
144
|
|
|
$result .= date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" . EOL; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
// Return |
|
148
|
|
|
if (CLI) { |
|
149
|
|
|
$result .= 'The results are stored in the "results" subdirectory.' . EOL; |
|
150
|
|
|
} else { |
|
151
|
|
|
if (!IS_INDEX) { |
|
152
|
|
|
$types = array_values($writers); |
|
153
|
|
|
$result .= '<p> </p>'; |
|
154
|
|
|
$result .= '<p>Results: '; |
|
155
|
|
|
foreach ($types as $type) { |
|
156
|
|
|
if (!is_null($type)) { |
|
157
|
|
|
$resultFile = 'results/' . SCRIPT_FILENAME . '.' . $type; |
|
158
|
|
|
if (file_exists($resultFile)) { |
|
159
|
|
|
$result .= "<a href='{$resultFile}' class='btn btn-primary'>{$type}</a> "; |
|
160
|
|
|
} |
|
161
|
|
|
} |
|
162
|
|
|
} |
|
163
|
|
|
$result .= '</p>'; |
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
return $result; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* Creates a templated slide |
|
172
|
|
|
* |
|
173
|
|
|
* @param PHPPresentation $objPHPPresentation |
|
174
|
|
|
* @return \PhpOffice\PhpPresentation\Slide |
|
175
|
|
|
*/ |
|
176
|
|
|
function createTemplatedSlide(PhpOffice\PhpPresentation\PhpPresentation $objPHPPresentation) |
|
177
|
|
|
{ |
|
178
|
|
|
// Create slide |
|
179
|
|
|
$slide = $objPHPPresentation->createSlide(); |
|
180
|
|
|
|
|
181
|
|
|
// Add logo |
|
182
|
|
|
$shape = $slide->createDrawingShape(); |
|
183
|
|
|
$shape->setName('PHPPresentation logo') |
|
184
|
|
|
->setDescription('PHPPresentation logo') |
|
185
|
|
|
->setPath('./resources/phppowerpoint_logo.gif') |
|
186
|
|
|
->setHeight(36) |
|
187
|
|
|
->setOffsetX(10) |
|
188
|
|
|
->setOffsetY(10); |
|
189
|
|
|
$shape->getShadow()->setVisible(true) |
|
190
|
|
|
->setDirection(45) |
|
191
|
|
|
->setDistance(10); |
|
192
|
|
|
|
|
193
|
|
|
// Return slide |
|
194
|
|
|
return $slide; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
class PhpPptTree { |
|
198
|
|
|
protected $oPhpPresentation; |
|
199
|
|
|
protected $htmlOutput; |
|
200
|
|
|
|
|
201
|
|
|
public function __construct(PhpPresentation $oPHPPpt) |
|
202
|
|
|
{ |
|
203
|
|
|
$this->oPhpPresentation = $oPHPPpt; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
public function display() |
|
207
|
|
|
{ |
|
208
|
|
|
$this->append('<div class="container-fluid pptTree">'); |
|
209
|
|
|
$this->append('<div class="row">'); |
|
210
|
|
|
$this->append('<div class="collapse in col-md-6">'); |
|
211
|
|
|
$this->append('<div class="tree">'); |
|
212
|
|
|
$this->append('<ul>'); |
|
213
|
|
|
$this->displayPhpPresentation($this->oPhpPresentation); |
|
214
|
|
|
$this->append('</ul>'); |
|
215
|
|
|
$this->append('</div>'); |
|
216
|
|
|
$this->append('</div>'); |
|
217
|
|
|
$this->append('<div class="col-md-6">'); |
|
218
|
|
|
$this->displayPhpPresentationInfo($this->oPhpPresentation); |
|
219
|
|
|
$this->append('</div>'); |
|
220
|
|
|
$this->append('</div>'); |
|
221
|
|
|
$this->append('</div>'); |
|
222
|
|
|
|
|
223
|
|
|
return $this->htmlOutput; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
protected function append($sHTML) |
|
227
|
|
|
{ |
|
228
|
|
|
$this->htmlOutput .= $sHTML; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
protected function displayPhpPresentation(PhpPresentation $oPHPPpt) |
|
232
|
|
|
{ |
|
233
|
|
|
$this->append('<li><span><i class="fa fa-folder-open"></i> PhpPresentation</span>'); |
|
234
|
|
|
$this->append('<ul>'); |
|
235
|
|
|
$this->append('<li><span class="shape" id="divPhpPresentation"><i class="fa fa-info-circle"></i> Info "PhpPresentation"</span></li>'); |
|
236
|
|
|
foreach ($oPHPPpt->getAllSlides() as $oSlide) { |
|
237
|
|
|
$this->append('<li><span><i class="fa fa-minus-square"></i> Slide</span>'); |
|
238
|
|
|
$this->append('<ul>'); |
|
239
|
|
|
$this->append('<li><span class="shape" id="div'.$oSlide->getHashCode().'"><i class="fa fa-info-circle"></i> Info "Slide"</span></li>'); |
|
240
|
|
|
foreach ($oSlide->getShapeCollection() as $oShape) { |
|
241
|
|
|
if($oShape instanceof Group) { |
|
242
|
|
|
$this->append('<li><span><i class="fa fa-minus-square"></i> Shape "Group"</span>'); |
|
243
|
|
|
$this->append('<ul>'); |
|
244
|
|
|
// $this->append('<li><span class="shape" id="div'.$oShape->getHashCode().'"><i class="fa fa-info-circle"></i> Info "Group"</span></li>'); |
|
245
|
|
|
foreach ($oShape->getShapeCollection() as $oShapeChild) { |
|
246
|
|
|
$this->displayShape($oShapeChild); |
|
247
|
|
|
} |
|
248
|
|
|
$this->append('</ul>'); |
|
249
|
|
|
$this->append('</li>'); |
|
250
|
|
|
} else { |
|
251
|
|
|
$this->displayShape($oShape); |
|
252
|
|
|
} |
|
253
|
|
|
} |
|
254
|
|
|
$this->append('</ul>'); |
|
255
|
|
|
$this->append('</li>'); |
|
256
|
|
|
} |
|
257
|
|
|
$this->append('</ul>'); |
|
258
|
|
|
$this->append('</li>'); |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
protected function displayShape(AbstractShape $shape) |
|
262
|
|
|
{ |
|
263
|
|
|
if($shape instanceof Drawing\Gd) { |
|
264
|
|
|
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "Drawing\Gd"</span></li>'); |
|
265
|
|
|
} elseif($shape instanceof Drawing\File) { |
|
266
|
|
|
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "Drawing\File"</span></li>'); |
|
267
|
|
|
} elseif($shape instanceof Drawing\Base64) { |
|
268
|
|
|
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "Drawing\Base64"</span></li>'); |
|
269
|
|
|
} elseif($shape instanceof Drawing\ZipFile) { |
|
270
|
|
|
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "Drawing\Zip"</span></li>'); |
|
271
|
|
|
} elseif($shape instanceof RichText) { |
|
272
|
|
|
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "RichText"</span></li>'); |
|
273
|
|
|
} else { |
|
274
|
|
|
var_dump($shape); |
|
|
|
|
|
|
275
|
|
|
} |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
|
|
protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt) |
|
279
|
|
|
{ |
|
280
|
|
|
$this->append('<div class="infoBlk" id="divPhpPresentationInfo">'); |
|
281
|
|
|
$this->append('<dl>'); |
|
282
|
|
|
$this->append('<dt>Number of slides</dt><dd>'.$oPHPPpt->getSlideCount().'</dd>'); |
|
283
|
|
|
$this->append('<dt>Document Layout Name</dt><dd>'.(empty($oPHPPpt->getLayout()->getDocumentLayout()) ? 'Custom' : $oPHPPpt->getLayout()->getDocumentLayout()).'</dd>'); |
|
284
|
|
|
$this->append('<dt>Document Layout Height</dt><dd>'.$oPHPPpt->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER).' mm</dd>'); |
|
285
|
|
|
$this->append('<dt>Document Layout Width</dt><dd>'.$oPHPPpt->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER).' mm</dd>'); |
|
286
|
|
|
$this->append('<dt>Properties : Category</dt><dd>'.$oPHPPpt->getDocumentProperties()->getCategory().'</dd>'); |
|
287
|
|
|
$this->append('<dt>Properties : Company</dt><dd>'.$oPHPPpt->getDocumentProperties()->getCompany().'</dd>'); |
|
288
|
|
|
$this->append('<dt>Properties : Created</dt><dd>'.$oPHPPpt->getDocumentProperties()->getCreated().'</dd>'); |
|
289
|
|
|
$this->append('<dt>Properties : Creator</dt><dd>'.$oPHPPpt->getDocumentProperties()->getCreator().'</dd>'); |
|
290
|
|
|
$this->append('<dt>Properties : Description</dt><dd>'.$oPHPPpt->getDocumentProperties()->getDescription().'</dd>'); |
|
291
|
|
|
$this->append('<dt>Properties : Keywords</dt><dd>'.$oPHPPpt->getDocumentProperties()->getKeywords().'</dd>'); |
|
292
|
|
|
$this->append('<dt>Properties : Last Modified By</dt><dd>'.$oPHPPpt->getDocumentProperties()->getLastModifiedBy().'</dd>'); |
|
293
|
|
|
$this->append('<dt>Properties : Modified</dt><dd>'.$oPHPPpt->getDocumentProperties()->getModified().'</dd>'); |
|
294
|
|
|
$this->append('<dt>Properties : Subject</dt><dd>'.$oPHPPpt->getDocumentProperties()->getSubject().'</dd>'); |
|
295
|
|
|
$this->append('<dt>Properties : Title</dt><dd>'.$oPHPPpt->getDocumentProperties()->getTitle().'</dd>'); |
|
296
|
|
|
$this->append('</dl>'); |
|
297
|
|
|
$this->append('</div>'); |
|
298
|
|
|
|
|
299
|
|
|
foreach ($oPHPPpt->getAllSlides() as $oSlide) { |
|
300
|
|
|
$this->append('<div class="infoBlk" id="div'.$oSlide->getHashCode().'Info">'); |
|
301
|
|
|
$this->append('<dl>'); |
|
302
|
|
|
$this->append('<dt>HashCode</dt><dd>'.$oSlide->getHashCode().'</dd>'); |
|
303
|
|
|
$this->append('<dt>Slide Layout</dt><dd>Layout::'.$this->getConstantName('\PhpOffice\PhpPresentation\Slide\Layout', $oSlide->getSlideLayout()).'</dd>'); |
|
304
|
|
|
|
|
305
|
|
|
$this->append('<dt>Offset X</dt><dd>'.$oSlide->getOffsetX().'</dd>'); |
|
306
|
|
|
$this->append('<dt>Offset Y</dt><dd>'.$oSlide->getOffsetY().'</dd>'); |
|
307
|
|
|
$this->append('<dt>Extent X</dt><dd>'.$oSlide->getExtentX().'</dd>'); |
|
308
|
|
|
$this->append('<dt>Extent Y</dt><dd>'.$oSlide->getExtentY().'</dd>'); |
|
309
|
|
|
$oBkg = $oSlide->getBackground(); |
|
310
|
|
|
if ($oBkg instanceof Slide\AbstractBackground) { |
|
311
|
|
|
if ($oBkg instanceof Slide\Background\Color) { |
|
312
|
|
|
$this->append('<dt>Background Color</dt><dd>#'.$oBkg->getColor()->getRGB().'</dd>'); |
|
313
|
|
|
} |
|
314
|
|
|
if ($oBkg instanceof Slide\Background\Image) { |
|
315
|
|
|
$sBkgImgContents = file_get_contents($oBkg->getPath()); |
|
316
|
|
|
$this->append('<dt>Background Image</dt><dd><img src="data:image/png;base64,'.base64_encode($sBkgImgContents).'"></dd>'); |
|
317
|
|
|
} |
|
318
|
|
|
} |
|
319
|
|
|
$oNote = $oSlide->getNote(); |
|
320
|
|
|
if ($oNote->getShapeCollection()->count() > 0) { |
|
321
|
|
|
$this->append('<dt>Notes</dt>'); |
|
322
|
|
|
foreach ($oNote->getShapeCollection() as $oShape) { |
|
323
|
|
|
if ($oShape instanceof RichText) { |
|
324
|
|
|
$this->append('<dd>' . $oShape->getPlainText() . '</dd>'); |
|
325
|
|
|
} |
|
326
|
|
|
} |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
$this->append('</dl>'); |
|
330
|
|
|
$this->append('</div>'); |
|
331
|
|
|
|
|
332
|
|
|
foreach ($oSlide->getShapeCollection() as $oShape) { |
|
333
|
|
|
if($oShape instanceof Group) { |
|
334
|
|
|
foreach ($oShape->getShapeCollection() as $oShapeChild) { |
|
335
|
|
|
$this->displayShapeInfo($oShapeChild); |
|
336
|
|
|
} |
|
337
|
|
|
} else { |
|
338
|
|
|
$this->displayShapeInfo($oShape); |
|
339
|
|
|
} |
|
340
|
|
|
} |
|
341
|
|
|
} |
|
342
|
|
|
} |
|
343
|
|
|
|
|
344
|
|
|
protected function displayShapeInfo(AbstractShape $oShape) |
|
345
|
|
|
{ |
|
346
|
|
|
$this->append('<div class="infoBlk" id="div'.$oShape->getHashCode().'Info">'); |
|
347
|
|
|
$this->append('<dl>'); |
|
348
|
|
|
$this->append('<dt>HashCode</dt><dd>'.$oShape->getHashCode().'</dd>'); |
|
349
|
|
|
$this->append('<dt>Offset X</dt><dd>'.$oShape->getOffsetX().'</dd>'); |
|
350
|
|
|
$this->append('<dt>Offset Y</dt><dd>'.$oShape->getOffsetY().'</dd>'); |
|
351
|
|
|
$this->append('<dt>Height</dt><dd>'.$oShape->getHeight().'</dd>'); |
|
352
|
|
|
$this->append('<dt>Width</dt><dd>'.$oShape->getWidth().'</dd>'); |
|
353
|
|
|
$this->append('<dt>Rotation</dt><dd>'.$oShape->getRotation().'°</dd>'); |
|
354
|
|
|
$this->append('<dt>Hyperlink</dt><dd>'.ucfirst(var_export($oShape->hasHyperlink(), true)).'</dd>'); |
|
355
|
|
|
$this->append('<dt>Fill</dt>'); |
|
356
|
|
|
if (is_null($oShape->getFill())) { |
|
357
|
|
|
$this->append('<dd>None</dd>'); |
|
358
|
|
|
} else { |
|
359
|
|
|
switch($oShape->getFill()->getFillType()) { |
|
360
|
|
|
case \PhpOffice\PhpPresentation\Style\Fill::FILL_NONE: |
|
361
|
|
|
$this->append('<dd>None</dd>'); |
|
362
|
|
|
break; |
|
363
|
|
|
case \PhpOffice\PhpPresentation\Style\Fill::FILL_SOLID: |
|
364
|
|
|
$this->append('<dd>Solid ('); |
|
365
|
|
|
$this->append('Color : #'.$oShape->getFill()->getStartColor()->getRGB()); |
|
366
|
|
|
$this->append(' - Alpha : '.$oShape->getFill()->getStartColor()->getAlpha().'%'); |
|
367
|
|
|
$this->append(')</dd>'); |
|
368
|
|
|
break; |
|
369
|
|
|
} |
|
370
|
|
|
} |
|
371
|
|
|
$this->append('<dt>Border</dt><dd>@Todo</dd>'); |
|
372
|
|
|
$this->append('<dt>IsPlaceholder</dt><dd>' . ($oShape->isPlaceholder() ? 'true' : 'false') . '</dd>'); |
|
373
|
|
|
if($oShape instanceof Drawing\Gd) { |
|
374
|
|
|
$this->append('<dt>Name</dt><dd>'.$oShape->getName().'</dd>'); |
|
375
|
|
|
$this->append('<dt>Description</dt><dd>'.$oShape->getDescription().'</dd>'); |
|
376
|
|
|
ob_start(); |
|
377
|
|
|
call_user_func($oShape->getRenderingFunction(), $oShape->getImageResource()); |
|
378
|
|
|
$sShapeImgContents = ob_get_contents(); |
|
379
|
|
|
ob_end_clean(); |
|
380
|
|
|
$this->append('<dt>Mime-Type</dt><dd>'.$oShape->getMimeType().'</dd>'); |
|
381
|
|
|
$this->append('<dt>Image</dt><dd><img src="data:'.$oShape->getMimeType().';base64,'.base64_encode($sShapeImgContents).'"></dd>'); |
|
382
|
|
View Code Duplication |
if ($oShape->hasHyperlink()) { |
|
|
|
|
|
|
383
|
|
|
$this->append('<dt>Hyperlink URL</dt><dd>'.$oShape->getHyperlink()->getUrl().'</dd>'); |
|
384
|
|
|
$this->append('<dt>Hyperlink Tooltip</dt><dd>'.$oShape->getHyperlink()->getTooltip().'</dd>'); |
|
385
|
|
|
} |
|
386
|
|
|
} elseif($oShape instanceof Drawing\AbstractDrawingAdapter) { |
|
387
|
|
|
$this->append('<dt>Name</dt><dd>'.$oShape->getName().'</dd>'); |
|
388
|
|
|
$this->append('<dt>Description</dt><dd>'.$oShape->getDescription().'</dd>'); |
|
389
|
|
|
} elseif($oShape instanceof RichText) { |
|
390
|
|
|
$this->append('<dt># of paragraphs</dt><dd>'.count($oShape->getParagraphs()).'</dd>'); |
|
391
|
|
|
$this->append('<dt>Inset (T / R / B / L)</dt><dd>'.$oShape->getInsetTop().'px / '.$oShape->getInsetRight().'px / '.$oShape->getInsetBottom().'px / '.$oShape->getInsetLeft().'px</dd>'); |
|
392
|
|
|
$this->append('<dt>Text</dt>'); |
|
393
|
|
|
$this->append('<dd>'); |
|
394
|
|
|
foreach ($oShape->getParagraphs() as $oParagraph) { |
|
395
|
|
|
$this->append('Paragraph<dl>'); |
|
396
|
|
|
$this->append('<dt>Alignment Horizontal</dt><dd> Alignment::'.$this->getConstantName('\PhpOffice\PhpPresentation\Style\Alignment', $oParagraph->getAlignment()->getHorizontal()).'</dd>'); |
|
397
|
|
|
$this->append('<dt>Alignment Vertical</dt><dd> Alignment::'.$this->getConstantName('\PhpOffice\PhpPresentation\Style\Alignment', $oParagraph->getAlignment()->getVertical()).'</dd>'); |
|
398
|
|
|
$this->append('<dt>Alignment Margin (L / R)</dt><dd>'.$oParagraph->getAlignment()->getMarginLeft().' px / '.$oParagraph->getAlignment()->getMarginRight().'px</dd>'); |
|
399
|
|
|
$this->append('<dt>Alignment Indent</dt><dd>'.$oParagraph->getAlignment()->getIndent().' px</dd>'); |
|
400
|
|
|
$this->append('<dt>Alignment Level</dt><dd>'.$oParagraph->getAlignment()->getLevel().'</dd>'); |
|
401
|
|
|
$this->append('<dt>Bullet Style</dt><dd> Bullet::'.$this->getConstantName('\PhpOffice\PhpPresentation\Style\Bullet', $oParagraph->getBulletStyle()->getBulletType()).'</dd>'); |
|
402
|
|
View Code Duplication |
if ($oParagraph->getBulletStyle()->getBulletType() != Bullet::TYPE_NONE) { |
|
|
|
|
|
|
403
|
|
|
$this->append('<dt>Bullet Font</dt><dd>' . $oParagraph->getBulletStyle()->getBulletFont() . '</dd>'); |
|
404
|
|
|
$this->append('<dt>Bullet Color</dt><dd>' . $oParagraph->getBulletStyle()->getBulletColor()->getARGB() . '</dd>'); |
|
405
|
|
|
} |
|
406
|
|
|
if ($oParagraph->getBulletStyle()->getBulletType() == Bullet::TYPE_BULLET) { |
|
407
|
|
|
$this->append('<dt>Bullet Char</dt><dd>'.$oParagraph->getBulletStyle()->getBulletChar().'</dd>'); |
|
408
|
|
|
} |
|
409
|
|
View Code Duplication |
if ($oParagraph->getBulletStyle()->getBulletType() == Bullet::TYPE_NUMERIC) { |
|
|
|
|
|
|
410
|
|
|
$this->append('<dt>Bullet Start At</dt><dd>'.$oParagraph->getBulletStyle()->getBulletNumericStartAt().'</dd>'); |
|
411
|
|
|
$this->append('<dt>Bullet Style</dt><dd>'.$oParagraph->getBulletStyle()->getBulletNumericStyle().'</dd>'); |
|
412
|
|
|
} |
|
413
|
|
|
$this->append('<dt>Line Spacing</dt><dd>'.$oParagraph->getLineSpacing().'</dd>'); |
|
414
|
|
|
$this->append('<dt>RichText</dt><dd><dl>'); |
|
415
|
|
|
foreach ($oParagraph->getRichTextElements() as $oRichText) { |
|
416
|
|
|
if($oRichText instanceof BreakElement) { |
|
417
|
|
|
$this->append('<dt><i>Break</i></dt>'); |
|
418
|
|
|
} else { |
|
419
|
|
|
if ($oRichText instanceof TextElement) { |
|
420
|
|
|
$this->append('<dt><i>TextElement</i></dt>'); |
|
421
|
|
|
} else { |
|
422
|
|
|
$this->append('<dt><i>Run</i></dt>'); |
|
423
|
|
|
} |
|
424
|
|
|
$this->append('<dd>'.$oRichText->getText()); |
|
425
|
|
|
$this->append('<dl>'); |
|
426
|
|
|
$this->append('<dt>Font Name</dt><dd>'.$oRichText->getFont()->getName().'</dd>'); |
|
427
|
|
|
$this->append('<dt>Font Size</dt><dd>'.$oRichText->getFont()->getSize().'</dd>'); |
|
428
|
|
|
$this->append('<dt>Font Color</dt><dd>#'.$oRichText->getFont()->getColor()->getARGB().'</dd>'); |
|
429
|
|
|
$this->append('<dt>Font Transform</dt><dd>'); |
|
430
|
|
|
$this->append('<abbr title="Bold">Bold</abbr> : '.($oRichText->getFont()->isBold() ? 'Y' : 'N').' - '); |
|
431
|
|
|
$this->append('<abbr title="Italic">Italic</abbr> : '.($oRichText->getFont()->isItalic() ? 'Y' : 'N').' - '); |
|
432
|
|
|
$this->append('<abbr title="Underline">Underline</abbr> : Underline::'.$this->getConstantName('\PhpOffice\PhpPresentation\Style\Font', $oRichText->getFont()->getUnderline()).' - '); |
|
433
|
|
|
$this->append('<abbr title="Strikethrough">Strikethrough</abbr> : '.($oRichText->getFont()->isStrikethrough() ? 'Y' : 'N').' - '); |
|
434
|
|
|
$this->append('<abbr title="SubScript">SubScript</abbr> : '.($oRichText->getFont()->isSubScript() ? 'Y' : 'N').' - '); |
|
435
|
|
|
$this->append('<abbr title="SuperScript">SuperScript</abbr> : '.($oRichText->getFont()->isSuperScript() ? 'Y' : 'N')); |
|
436
|
|
|
$this->append('</dd>'); |
|
437
|
|
View Code Duplication |
if ($oRichText instanceof TextElement) { |
|
|
|
|
|
|
438
|
|
|
if ($oRichText->hasHyperlink()) { |
|
439
|
|
|
$this->append('<dt>Hyperlink URL</dt><dd>'.$oRichText->getHyperlink()->getUrl().'</dd>'); |
|
440
|
|
|
$this->append('<dt>Hyperlink Tooltip</dt><dd>'.$oRichText->getHyperlink()->getTooltip().'</dd>'); |
|
441
|
|
|
} |
|
442
|
|
|
} |
|
443
|
|
|
$this->append('</dl>'); |
|
444
|
|
|
$this->append('</dd>'); |
|
445
|
|
|
} |
|
446
|
|
|
} |
|
447
|
|
|
$this->append('</dl></dd></dl>'); |
|
448
|
|
|
} |
|
449
|
|
|
$this->append('</dd>'); |
|
450
|
|
|
} else { |
|
451
|
|
|
// Add another shape |
|
452
|
|
|
} |
|
453
|
|
|
$this->append('</dl>'); |
|
454
|
|
|
$this->append('</div>'); |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
|
|
protected function getConstantName($class, $search, $startWith = '') { |
|
458
|
|
|
$fooClass = new ReflectionClass($class); |
|
459
|
|
|
$constants = $fooClass->getConstants(); |
|
460
|
|
|
$constName = null; |
|
461
|
|
|
foreach ($constants as $key => $value ) { |
|
462
|
|
|
if ($value == $search) { |
|
463
|
|
|
if (empty($startWith) || (!empty($startWith) && strpos($key, $startWith) === 0)) { |
|
464
|
|
|
$constName = $key; |
|
465
|
|
|
} |
|
466
|
|
|
break; |
|
467
|
|
|
} |
|
468
|
|
|
} |
|
469
|
|
|
return $constName; |
|
470
|
|
|
} |
|
471
|
|
|
} |
|
472
|
|
|
?> |
|
473
|
|
|
<title><?php echo $pageTitle; ?></title> |
|
474
|
|
|
<meta charset="utf-8"> |
|
475
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
|
476
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
|
477
|
|
|
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" /> |
|
478
|
|
|
<link rel="stylesheet" href="bootstrap/css/font-awesome.min.css" /> |
|
479
|
|
|
<link rel="stylesheet" href="bootstrap/css/phppresentation.css" /> |
|
480
|
|
|
</head> |
|
481
|
|
|
<body> |
|
482
|
|
|
<div class="container"> |
|
483
|
|
|
<div class="navbar navbar-default" role="navigation"> |
|
484
|
|
|
<div class="container-fluid"> |
|
485
|
|
|
<div class="navbar-header"> |
|
486
|
|
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> |
|
487
|
|
|
<span class="sr-only">Toggle navigation</span> |
|
488
|
|
|
<span class="icon-bar"></span> |
|
489
|
|
|
<span class="icon-bar"></span> |
|
490
|
|
|
<span class="icon-bar"></span> |
|
491
|
|
|
</button> |
|
492
|
|
|
<a class="navbar-brand" href="./">PHPPresentation</a> |
|
493
|
|
|
</div> |
|
494
|
|
|
<div class="navbar-collapse collapse"> |
|
495
|
|
|
<ul class="nav navbar-nav"> |
|
496
|
|
|
<?php foreach ($files as $key => $fileStr) :?> |
|
497
|
|
|
<li class="dropdown active"> |
|
498
|
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-code fa-lg"></i> Samples <?php echo $key?>x<strong class="caret"></strong></a> |
|
499
|
|
|
<ul class="dropdown-menu"><?php echo $fileStr; ?></ul> |
|
500
|
|
|
</li> |
|
501
|
|
|
<?php endforeach; ?> |
|
502
|
|
|
</ul> |
|
503
|
|
|
<ul class="nav navbar-nav navbar-right"> |
|
504
|
|
|
<li><a href="https://github.com/PHPOffice/PHPPresentation"><i class="fa fa-github fa-lg" title="GitHub"></i> </a></li> |
|
505
|
|
|
<li><a href="http://phppresentation.readthedocs.org/en/develop/"><i class="fa fa-book fa-lg" title="Docs"></i> </a></li> |
|
506
|
|
|
<li><a href="http://twitter.com/PHPOffice"><i class="fa fa-twitter fa-lg" title="Twitter"></i> </a></li> |
|
507
|
|
|
</ul> |
|
508
|
|
|
</div> |
|
509
|
|
|
</div> |
|
510
|
|
|
</div> |
|
511
|
|
|
<?php echo $pageHeading; |
|
512
|
|
|
|