No Description

MetaInf.php 4.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. }