a6cbdc6f969547c07878ef7c6365734a5c5a00d0.svn-base 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2014 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 - 2014 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. /**
  28. * PHPExcel_Writer_OpenDocument_MetaInf
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Writer_OpenDocument
  32. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. * @author Alexander Pervakov <frost-nzcr4@jagmort.com>
  34. */
  35. class PHPExcel_Writer_OpenDocument_MetaInf extends PHPExcel_Writer_OpenDocument_WriterPart
  36. {
  37. /**
  38. * Write META-INF/manifest.xml to XML format
  39. *
  40. * @param PHPExcel $pPHPExcel
  41. * @return string XML Output
  42. * @throws PHPExcel_Writer_Exception
  43. */
  44. public function writeManifest(PHPExcel $pPHPExcel = null)
  45. {
  46. if (!$pPHPExcel) {
  47. $pPHPExcel = $this->getParentWriter()->getPHPExcel();
  48. }
  49. $objWriter = null;
  50. if ($this->getParentWriter()->getUseDiskCaching()) {
  51. $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
  52. } else {
  53. $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
  54. }
  55. // XML header
  56. $objWriter->startDocument('1.0', 'UTF-8');
  57. // Manifest
  58. $objWriter->startElement('manifest:manifest');
  59. $objWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0');
  60. $objWriter->writeAttribute('manifest:version', '1.2');
  61. $objWriter->startElement('manifest:file-entry');
  62. $objWriter->writeAttribute('manifest:full-path', '/');
  63. $objWriter->writeAttribute('manifest:version', '1.2');
  64. $objWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.spreadsheet');
  65. $objWriter->endElement();
  66. $objWriter->startElement('manifest:file-entry');
  67. $objWriter->writeAttribute('manifest:full-path', 'meta.xml');
  68. $objWriter->writeAttribute('manifest:media-type', 'text/xml');
  69. $objWriter->endElement();
  70. $objWriter->startElement('manifest:file-entry');
  71. $objWriter->writeAttribute('manifest:full-path', 'settings.xml');
  72. $objWriter->writeAttribute('manifest:media-type', 'text/xml');
  73. $objWriter->endElement();
  74. $objWriter->startElement('manifest:file-entry');
  75. $objWriter->writeAttribute('manifest:full-path', 'content.xml');
  76. $objWriter->writeAttribute('manifest:media-type', 'text/xml');
  77. $objWriter->endElement();
  78. $objWriter->startElement('manifest:file-entry');
  79. $objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png');
  80. $objWriter->writeAttribute('manifest:media-type', 'image/png');
  81. $objWriter->endElement();
  82. $objWriter->startElement('manifest:file-entry');
  83. $objWriter->writeAttribute('manifest:full-path', 'styles.xml');
  84. $objWriter->writeAttribute('manifest:media-type', 'text/xml');
  85. $objWriter->endElement();
  86. $objWriter->endElement();
  87. return $objWriter->getData();
  88. }
  89. }