public function render()
{
// Create XML writer
$objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
// XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Types
$objWriter->startElement('Types');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
// Rels
$this->writeDefaultContentType($objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml');
// XML
$this->writeDefaultContentType($objWriter, 'xml', 'application/xml');
// Presentation
$this->writeOverrideContentType($objWriter, '/ppt/presentation.xml', 'application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml');
// PptProps
$this->writeOverrideContentType($objWriter, '/ppt/presProps.xml', 'application/vnd.openxmlformats-officedocument.presentationml.presProps+xml');
$this->writeOverrideContentType($objWriter, '/ppt/tableStyles.xml', 'application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml');
$this->writeOverrideContentType($objWriter, '/ppt/viewProps.xml', 'application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml');
// DocProps
$this->writeOverrideContentType($objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml');
$this->writeOverrideContentType($objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml');
$this->writeOverrideContentType($objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml');
// Slide masters
$sldLayoutNr = 0;
$sldLayoutId = time() + 689016272;
// requires minimum value of 2 147 483 648
foreach ($this->oPresentation->getAllMasterSlides() as $idx => $oSlideMaster) {
$oSlideMaster->setRelsIndex($idx + 1);
$this->writeOverrideContentType($objWriter, '/ppt/slideMasters/slideMaster' . $oSlideMaster->getRelsIndex() . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml');
$this->writeOverrideContentType($objWriter, '/ppt/theme/theme' . $oSlideMaster->getRelsIndex() . '.xml', 'application/vnd.openxmlformats-officedocument.theme+xml');
foreach ($oSlideMaster->getAllSlideLayouts() as $oSlideLayout) {
$oSlideLayout->layoutNr = ++$sldLayoutNr;
$oSlideLayout->layoutId = ++$sldLayoutId;
$this->writeOverrideContentType($objWriter, '/ppt/slideLayouts/slideLayout' . $oSlideLayout->layoutNr . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml');
}
}
// Slides
$slideCount = $this->oPresentation->getSlideCount();
for ($i = 0; $i < $slideCount; ++$i) {
$this->writeOverrideContentType($objWriter, '/ppt/slides/slide' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.slide+xml');
if ($this->oPresentation->getSlide($i)->getNote()->getShapeCollection()->count() > 0) {
$this->writeOverrideContentType($objWriter, '/ppt/notesSlides/notesSlide' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml');
}
}
// Add media content-types
$aMediaContentTypes = array();
// GIF, JPEG, PNG
$aMediaContentTypes['gif'] = 'image/gif';
$aMediaContentTypes['jpg'] = 'image/jpeg';
$aMediaContentTypes['jpeg'] = 'image/jpeg';
$aMediaContentTypes['png'] = 'image/png';
foreach ($aMediaContentTypes as $key => $value) {
$this->writeDefaultContentType($objWriter, $key, $value);
}
// XLSX
$this->writeDefaultContentType($objWriter, 'xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
// Other media content types
$mediaCount = $this->getDrawingHashTable()->count();
for ($i = 0; $i < $mediaCount; ++$i) {
$shapeIndex = $this->getDrawingHashTable()->getByIndex($i);
if ($shapeIndex instanceof ShapeChart) {
// Chart content type
$this->writeOverrideContentType($objWriter, '/ppt/charts/chart' . $shapeIndex->getImageIndex() . '.xml', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml');
} else {
$extension = strtolower($shapeIndex->getExtension());
$mimeType = $shapeIndex->getMimeType();
if (!isset($aMediaContentTypes[$extension])) {
$aMediaContentTypes[$extension] = $mimeType;
$this->writeDefaultContentType($objWriter, $extension, $mimeType);
}
}
}
$objWriter->endElement();
$this->oZip->addFromString('[Content_Types].xml', $objWriter->getData());
return $this->oZip;
}