MetaInf.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * PHPExcel_Writer_OpenDocument_MetaInf
  4. *
  5. * Copyright (c) 2006 - 2015 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Writer_OpenDocument
  23. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. class PHPExcel_Writer_OpenDocument_MetaInf extends PHPExcel_Writer_OpenDocument_WriterPart
  28. {
  29. /**
  30. * Write META-INF/manifest.xml to XML format
  31. *
  32. * @param PHPExcel $pPHPExcel
  33. * @return string XML Output
  34. * @throws PHPExcel_Writer_Exception
  35. */
  36. public function writeManifest(PHPExcel $pPHPExcel = null)
  37. {
  38. if (!$pPHPExcel) {
  39. $pPHPExcel = $this->getParentWriter()->getPHPExcel();
  40. }
  41. $objWriter = null;
  42. if ($this->getParentWriter()->getUseDiskCaching()) {
  43. $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
  44. } else {
  45. $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
  46. }
  47. // XML header
  48. $objWriter->startDocument('1.0', 'UTF-8');
  49. // Manifest
  50. $objWriter->startElement('manifest:manifest');
  51. $objWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0');
  52. $objWriter->writeAttribute('manifest:version', '1.2');
  53. $objWriter->startElement('manifest:file-entry');
  54. $objWriter->writeAttribute('manifest:full-path', '/');
  55. $objWriter->writeAttribute('manifest:version', '1.2');
  56. $objWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.spreadsheet');
  57. $objWriter->endElement();
  58. $objWriter->startElement('manifest:file-entry');
  59. $objWriter->writeAttribute('manifest:full-path', 'meta.xml');
  60. $objWriter->writeAttribute('manifest:media-type', 'text/xml');
  61. $objWriter->endElement();
  62. $objWriter->startElement('manifest:file-entry');
  63. $objWriter->writeAttribute('manifest:full-path', 'settings.xml');
  64. $objWriter->writeAttribute('manifest:media-type', 'text/xml');
  65. $objWriter->endElement();
  66. $objWriter->startElement('manifest:file-entry');
  67. $objWriter->writeAttribute('manifest:full-path', 'content.xml');
  68. $objWriter->writeAttribute('manifest:media-type', 'text/xml');
  69. $objWriter->endElement();
  70. $objWriter->startElement('manifest:file-entry');
  71. $objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png');
  72. $objWriter->writeAttribute('manifest:media-type', 'image/png');
  73. $objWriter->endElement();
  74. $objWriter->startElement('manifest:file-entry');
  75. $objWriter->writeAttribute('manifest:full-path', 'styles.xml');
  76. $objWriter->writeAttribute('manifest:media-type', 'text/xml');
  77. $objWriter->endElement();
  78. $objWriter->endElement();
  79. return $objWriter->getData();
  80. }
  81. }