|
15 | 15 | use PhpOffice\PhpPresentation\Shape\RichText;
|
16 | 16 | use PhpOffice\PhpPresentation\Shape\Group;
|
17 | 17 |
|
18 |
| -class PhpPptTree { |
19 |
| - protected $oPhpPresentation; |
20 |
| - protected $htmlOutput; |
21 |
| - |
22 |
| - public function __construct(PhpPresentation $oPHPPpt) |
23 |
| - { |
24 |
| - $this->oPhpPresentation = $oPHPPpt; |
25 |
| - } |
26 |
| - |
27 |
| - public function display() |
28 |
| - { |
29 |
| - $this->append('<div class="container-fluid pptTree">'); |
30 |
| - $this->append('<div class="row">'); |
31 |
| - $this->append('<div class="collapse in col-md-6">'); |
32 |
| - $this->append('<div class="tree">'); |
33 |
| - $this->append('<ul>'); |
34 |
| - $this->displayPhpPresentation($this->oPhpPresentation); |
35 |
| - $this->append('</ul>'); |
36 |
| - $this->append('</div>'); |
37 |
| - $this->append('</div>'); |
38 |
| - $this->append('<div class="col-md-6">'); |
39 |
| - $this->displayPhpPresentationInfo($this->oPhpPresentation); |
40 |
| - $this->append('</div>'); |
41 |
| - $this->append('</div>'); |
42 |
| - $this->append('</div>'); |
43 |
| - |
44 |
| - return $this->htmlOutput; |
45 |
| - } |
46 |
| - |
47 |
| - protected function append($sHTML) |
48 |
| - { |
49 |
| - $this->htmlOutput .= $sHTML; |
50 |
| - } |
51 |
| - |
52 |
| - protected function displayPhpPresentation(PhpPresentation $oPHPPpt) |
53 |
| - { |
54 |
| - $this->append('<li><span><i class="fa fa-folder-open"></i> PhpPresentation</span>'); |
55 |
| - $this->append('<ul>'); |
56 |
| - $this->append('<li><span class="shape" id="divPhpPresentation"><i class="fa fa-info-circle"></i> Info "PhpPresentation"</span></li>'); |
57 |
| - foreach ($oPHPPpt->getAllSlides() as $oSlide) { |
58 |
| - $this->append('<li><span><i class="fa fa-minus-square"></i> Slide</span>'); |
59 |
| - $this->append('<ul>'); |
60 |
| - $this->append('<li><span class="shape" id="div'.$oSlide->getHashCode().'"><i class="fa fa-info-circle"></i> Info "Slide"</span></li>'); |
61 |
| - foreach ($oSlide->getShapeCollection() as $oShape) { |
62 |
| - if($oShape instanceof Group) { |
63 |
| - $this->append('<li><span><i class="fa fa-minus-square"></i> Shape "Group"</span>'); |
64 |
| - $this->append('<ul>'); |
65 |
| - // $this->append('<li><span class="shape" id="div'.$oShape->getHashCode().'"><i class="fa fa-info-circle"></i> Info "Group"</span></li>'); |
66 |
| - foreach ($oShape->getShapeCollection() as $oShapeChild) { |
67 |
| - $this->displayShape($oShapeChild); |
68 |
| - } |
69 |
| - $this->append('</ul>'); |
70 |
| - $this->append('</li>'); |
71 |
| - } else { |
72 |
| - $this->displayShape($oShape); |
73 |
| - } |
74 |
| - } |
75 |
| - $this->append('</ul>'); |
76 |
| - $this->append('</li>'); |
77 |
| - } |
78 |
| - $this->append('</ul>'); |
79 |
| - $this->append('</li>'); |
80 |
| - } |
81 |
| - |
82 |
| - protected function displayShape(AbstractShape $shape) |
83 |
| - { |
84 |
| - if($shape instanceof MemoryDrawing) { |
85 |
| - $this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "MemoryDrawing"</span></li>'); |
86 |
| - } elseif($shape instanceof RichText) { |
87 |
| - $this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "RichText"</span></li>'); |
88 |
| - } else { |
89 |
| - var_export($shape); |
90 |
| - } |
91 |
| - } |
92 |
| - |
93 |
| - protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt) |
94 |
| - { |
95 |
| - $this->append('<div class="infoBlk" id="divPhpPresentationInfo">'); |
96 |
| - $this->append('<dl>'); |
97 |
| - $this->append('<dt>Number of slides</dt><dd>'.$oPHPPpt->getSlideCount().'</dd>'); |
98 |
| - $this->append('<dt>Document Layout Height</dt><dd>'.$oPHPPpt->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER).' mm</dd>'); |
99 |
| - $this->append('<dt>Document Layout Width</dt><dd>'.$oPHPPpt->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER).' mm</dd>'); |
100 |
| - $this->append('<dt>Properties : Category</dt><dd>'.$oPHPPpt->getProperties()->getCategory().'</dd>'); |
101 |
| - $this->append('<dt>Properties : Company</dt><dd>'.$oPHPPpt->getProperties()->getCompany().'</dd>'); |
102 |
| - $this->append('<dt>Properties : Created</dt><dd>'.$oPHPPpt->getProperties()->getCreated().'</dd>'); |
103 |
| - $this->append('<dt>Properties : Creator</dt><dd>'.$oPHPPpt->getProperties()->getCreator().'</dd>'); |
104 |
| - $this->append('<dt>Properties : Description</dt><dd>'.$oPHPPpt->getProperties()->getDescription().'</dd>'); |
105 |
| - $this->append('<dt>Properties : Keywords</dt><dd>'.$oPHPPpt->getProperties()->getKeywords().'</dd>'); |
106 |
| - $this->append('<dt>Properties : Last Modified By</dt><dd>'.$oPHPPpt->getProperties()->getLastModifiedBy().'</dd>'); |
107 |
| - $this->append('<dt>Properties : Modified</dt><dd>'.$oPHPPpt->getProperties()->getModified().'</dd>'); |
108 |
| - $this->append('<dt>Properties : Subject</dt><dd>'.$oPHPPpt->getProperties()->getSubject().'</dd>'); |
109 |
| - $this->append('<dt>Properties : Title</dt><dd>'.$oPHPPpt->getProperties()->getTitle().'</dd>'); |
110 |
| - $this->append('</dl>'); |
111 |
| - $this->append('</div>'); |
112 |
| - |
113 |
| - foreach ($oPHPPpt->getAllSlides() as $oSlide) { |
114 |
| - $this->append('<div class="infoBlk" id="div'.$oSlide->getHashCode().'Info">'); |
115 |
| - $this->append('<dl>'); |
116 |
| - $this->append('<dt>HashCode</dt><dd>'.$oSlide->getHashCode().'</dd>'); |
117 |
| - $this->append('<dt>Slide Layout</dt><dd>'.$oSlide->getSlideLayout().'</dd>'); |
118 |
| - $this->append('<dt>Offset X</dt><dd>'.$oSlide->getOffsetX().'</dd>'); |
119 |
| - $this->append('<dt>Offset Y</dt><dd>'.$oSlide->getOffsetY().'</dd>'); |
120 |
| - $this->append('<dt>Extent X</dt><dd>'.$oSlide->getExtentX().'</dd>'); |
121 |
| - $this->append('<dt>Extent Y</dt><dd>'.$oSlide->getExtentY().'</dd>'); |
122 |
| - $this->append('</dl>'); |
123 |
| - $this->append('</div>'); |
124 |
| - |
125 |
| - foreach ($oSlide->getShapeCollection() as $oShape) { |
126 |
| - if($oShape instanceof Group) { |
127 |
| - foreach ($oShape->getShapeCollection() as $oShapeChild) { |
128 |
| - $this->displayShapeInfo($oShapeChild); |
129 |
| - } |
130 |
| - } else { |
131 |
| - $this->displayShapeInfo($oShape); |
132 |
| - } |
133 |
| - } |
134 |
| - } |
135 |
| - } |
136 |
| - |
137 |
| - protected function displayShapeInfo(AbstractShape $oShape) |
138 |
| - { |
139 |
| - $this->append('<div class="infoBlk" id="div'.$oShape->getHashCode().'Info">'); |
140 |
| - $this->append('<dl>'); |
141 |
| - $this->append('<dt>HashCode</dt><dd>'.$oShape->getHashCode().'</dd>'); |
142 |
| - $this->append('<dt>Offset X</dt><dd>'.$oShape->getOffsetX().'</dd>'); |
143 |
| - $this->append('<dt>Offset Y</dt><dd>'.$oShape->getOffsetY().'</dd>'); |
144 |
| - $this->append('<dt>Height</dt><dd>'.$oShape->getHeight().'</dd>'); |
145 |
| - $this->append('<dt>Width</dt><dd>'.$oShape->getWidth().'</dd>'); |
146 |
| - $this->append('<dt>Rotation</dt><dd>'.$oShape->getRotation().'°</dd>'); |
147 |
| - $this->append('<dt>Hyperlink</dt><dd>'.ucfirst(var_export($oShape->hasHyperlink(), true)).'</dd>'); |
148 |
| - $this->append('<dt>Fill</dt><dd>@Todo</dd>'); |
149 |
| - $this->append('<dt>Border</dt><dd>@Todo</dd>'); |
150 |
| - if($oShape instanceof MemoryDrawing) { |
151 |
| - ob_start(); |
152 |
| - call_user_func($oShape->getRenderingFunction(), $oShape->getImageResource()); |
153 |
| - $sShapeImgContents = ob_get_contents(); |
154 |
| - ob_end_clean(); |
155 |
| - $this->append('<dt>Mime-Type</dt><dd>'.$oShape->getMimeType().'</dd>'); |
156 |
| - $this->append('<dt>Image</dt><dd><img src="data:'.$oShape->getMimeType().';base64,'.base64_encode($sShapeImgContents).'"></dd>'); |
157 |
| - } else { |
158 |
| - // Add another shape |
159 |
| - } |
160 |
| - $this->append('</dl>'); |
161 |
| - $this->append('</div>'); |
162 |
| - } |
163 |
| -} |
164 |
| - |
165 | 18 | $pptReader = PhpOffice\PhpPresentation\IOFactory::createReader('PowerPoint97');
|
166 | 19 | $oPHPPresentation = $pptReader->load('resources/Sample_12.ppt');
|
167 | 20 |
|
|
0 commit comments