Skip to content

Commit e26c842

Browse files
committed
Merge branch 'develop' into issue192
2 parents e35f3f4 + 5764b5c commit e26c842

File tree

18 files changed

+259
-23
lines changed

18 files changed

+259
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- ODPresentation & PowerPoint2007 & Serialized Writer : Support for Zip Adapter - @Progi1984 GH-176
2424
- ODPresentation & PowerPoint2007 Writer : language property to TextElement - @skrajewski & @Progi1984 GH-180
2525
- ODPresentation & PowerPoint2007 Writer : Add Font Support For Chart Axis - @jrking4 GH-186
26+
- ODPresentation & PowerPoint2007 Writer : Support for video - @Progi1984 GH-123
2627
- PowerPoint2007 Writer : Presentation with predefined View Type - @Progi1984 GH-120
2728

2829
## 0.6.0 - 2016-01-24

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ PHPPresentation is a library written in pure PHP that provides a set of classes
3434

3535
shapes_chart
3636
shapes_comment
37+
shapes_media
3738
shapes_richtext
3839
shapes_table
3940

docs/shapes.rst

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,11 @@ Example:
2727
->setOffsetX(170)
2828
->setOffsetY(180);
2929
30-
Rich text
31-
---------
32-
33-
The Rich text has :ref:`its own page <shapes_richtext>`.
34-
3530
Line
3631
----
3732

3833
To create a line, use `createLineShape` method of slide.
3934

40-
Chart
41-
-----
42-
43-
The Chart has :ref:`its own page <shapes_chart>`.
44-
45-
Comment
46-
-------
47-
48-
The Comment has :ref:`its own page <shapes_comment>`.
4935

5036
Drawing
5137
-------
@@ -58,8 +44,3 @@ To create a drawing, use `createDrawingShape` method of slide.
5844
$drawing->setName('Unique name')
5945
->setDescription('Description of the drawing')
6046
->setPath('/path/to/drawing.filename');
61-
62-
Table
63-
-----
64-
65-
The Table has :ref:`its own page <shapes_table>`.

docs/shapes_media.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. _shapes_table:
2+
3+
Media
4+
=====
5+
6+
To create a video, create an object `Media`.
7+
8+
Example:
9+
10+
.. code-block:: php
11+
12+
use PhpOffice\PhpPresentation\Shape\Media;
13+
14+
$oMedia = new Media();
15+
$oMedia->setPath('file.mp4');
16+
// $oMedia->setPath('file.ogv');
17+
$oSlide->addShape($oMedia);
18+
19+
You can define text and date with setters.
20+
21+
Example:
22+
23+
.. code-block:: php
24+
25+
use PhpOffice\PhpPresentation\Shape\Media;
26+
27+
$oMedia = new Media();
28+
$oMedia->setName('Name of the Media');
29+
$oSlide->addShape($oMedia);
30+
31+
32+
Quirks
33+
------
34+
35+
For PowerPoint2007 Writer, the prefered file format is MP4.
36+
For ODPresentation Writer, the prefered file format is OGV.

samples/Sample_03_Image.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PhpOffice\PhpPresentation\PhpPresentation;
66
use PhpOffice\PhpPresentation\Shape\Drawing;
7+
use PhpOffice\PhpPresentation\Shape\Media;
78

89
// Create new PHPPresentation object
910
echo date('H:i:s') . ' Create new PHPPresentation object'.EOL;
@@ -66,6 +67,18 @@
6667
->setOffsetY(200);
6768
$currentSlide->addShape($shape);
6869

70+
// Add a video to the slide
71+
$shape = new Media();
72+
$shape->setName('Video')
73+
->setDescription('Video')
74+
->setPath(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? './resources/sintel_trailer-480p.mp4' : './resources/sintel_trailer-480p.ogv')
75+
->setResizeProportional(false)
76+
->setHeight(90)
77+
->setWidth(90)
78+
->setOffsetX(10)
79+
->setOffsetY(300);
80+
$currentSlide->addShape($shape);
81+
6982
// Save file
7083
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
7184
if (!CLI) {
4.17 MB
Binary file not shown.
12.4 MB
Binary file not shown.
-6.96 MB
Binary file not shown.

src/PhpPresentation/Shape/Media.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* This file is part of PHPPresentation - A pure PHP library for reading and writing
4+
* presentations documents.
5+
*
6+
* PHPPresentation is free software distributed under the terms of the GNU Lesser
7+
* General Public License version 3 as published by the Free Software Foundation.
8+
*
9+
* For the full copyright and license information, please read the LICENSE
10+
* file that was distributed with this source code. For the full list of
11+
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
12+
*
13+
* @link https://github.com/PHPOffice/PHPPresentation
14+
* @copyright 2009-2015 PHPPresentation contributors
15+
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16+
*/
17+
18+
namespace PhpOffice\PhpPresentation\Shape;
19+
20+
use PhpOffice\PhpPresentation\ComparableInterface;
21+
22+
/**
23+
* Media element
24+
*/
25+
class Media extends Drawing implements ComparableInterface
26+
{
27+
}

src/PhpPresentation/Writer/ODPresentation.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,25 @@ public function save($pFilename)
9999
$oPresentation = $this->getPhpPresentation();
100100
$arrayChart = array();
101101

102+
$arrayFiles = array();
102103
$oDir = new DirectoryIterator(dirname(__FILE__).DIRECTORY_SEPARATOR.'ODPresentation');
103104
foreach ($oDir as $oFile) {
104105
if (!$oFile->isFile()) {
105106
continue;
106107
}
107-
$class = __NAMESPACE__.'\\ODPresentation\\'.$oFile->getBasename('.php');
108+
109+
$class = __NAMESPACE__ . '\\ODPresentation\\' . $oFile->getBasename('.php');
108110
$o = new \ReflectionClass($class);
109111

110112
if ($o->isAbstract() || !$o->isSubclassOf('PhpOffice\PhpPresentation\Writer\ODPresentation\AbstractDecoratorWriter')) {
111113
continue;
112114
}
115+
$arrayFiles[$oFile->getBasename('.php')] = $o;
116+
}
117+
118+
ksort($arrayFiles);
119+
120+
foreach ($arrayFiles as $o) {
113121
$oService = $o->newInstance();
114122
$oService->setZip($oZip);
115123
$oService->setPresentation($oPresentation);

0 commit comments

Comments
 (0)