public function writeDocPropsCore(Document_Word_Writer $pPHPWord = null) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new Document_Word_Writer_Shared_XMLWriter(Document_Word_Writer_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new Document_Word_Writer_Shared_XMLWriter(Document_Word_Writer_Shared_XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8', 'yes'); // cp:coreProperties $objWriter->startElement('cp:coreProperties'); $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); // dc:creator $objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getCreator()); // cp:lastModifiedBy $objWriter->writeElement('cp:lastModifiedBy', $pPHPWord->getProperties()->getLastModifiedBy()); // dcterms:created $objWriter->startElement('dcterms:created'); $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getCreated())); $objWriter->endElement(); // dcterms:modified $objWriter->startElement('dcterms:modified'); $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); $objWriter->writeRaw(date(DATE_W3C, $pPHPWord->getProperties()->getModified())); $objWriter->endElement(); // dc:title $objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle()); // dc:description $objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription()); // dc:subject $objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject()); // cp:keywords $objWriter->writeElement('cp:keywords', $pPHPWord->getProperties()->getKeywords()); // cp:category $objWriter->writeElement('cp:category', $pPHPWord->getProperties()->getCategory()); $objWriter->endElement(); // Return return $objWriter->getData(); }
public function writeDocument(Document_Word_Writer $pPHPWord = null) { // Create XML writer if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new Document_Word_Writer_Shared_XMLWriter(Document_Word_Writer_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new Document_Word_Writer_Shared_XMLWriter(Document_Word_Writer_Shared_XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8', 'yes'); // w:document $objWriter->startElement('w:document'); $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math'); $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing'); $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word'); $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'); $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml'); $objWriter->startElement('w:body'); $_sections = $pPHPWord->getSections(); $countSections = count($_sections); $pSection = 0; if ($countSections < 1) { $_sections = array(); } foreach ($_sections as $section) { $pSection++; $_elements = $section->getElements(); foreach ($_elements as $element) { if ($element instanceof Document_Word_Writer_Section_Text) { $this->_writeText($objWriter, $element); } elseif ($element instanceof Document_Word_Writer_Section_TextRun) { $this->_writeTextRun($objWriter, $element); } elseif ($element instanceof Document_Word_Writer_Section_Link) { $this->_writeLink($objWriter, $element); } elseif ($element instanceof Document_Word_Writer_Section_Title) { $this->_writeTitle($objWriter, $element); } elseif ($element instanceof Document_Word_Writer_Section_TextBreak) { $this->_writeTextBreak($objWriter); } elseif ($element instanceof Document_Word_Writer_Section_PageBreak) { $this->_writePageBreak($objWriter); } elseif ($element instanceof Document_Word_Writer_Section_Table) { $this->_writeTable($objWriter, $element); } elseif ($element instanceof Document_Word_Writer_Section_ListItem) { $this->_writeListItem($objWriter, $element); } elseif ($element instanceof Document_Word_Writer_Section_Image || $element instanceof Document_Word_Writer_Section_MemoryImage) { $this->_writeImage($objWriter, $element); } elseif ($element instanceof Document_Word_Writer_Section_Object) { $this->_writeObject($objWriter, $element); } elseif ($element instanceof Document_Word_Writer_TOC) { $this->_writeTOC($objWriter); } } if ($pSection == $countSections) { $this->_writeEndSection($objWriter, $section); } else { $this->_writeSection($objWriter, $section); } } $objWriter->endElement(); // End w:body $objWriter->endElement(); // End w:document // Return return $objWriter->getData(); }