PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/server/server/modules/codeplex/PHPPowerPoint/Writer/ODPresentation/Meta.php

https://github.com/dweexfuad/roojax
PHP | 105 lines | 39 code | 11 blank | 55 comment | 2 complexity | c5df9d1ef2fb84b79c63149117c68676 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * PHPPowerPoint
  4. *
  5. * Copyright (c) 2009 - 2010 PHPPowerPoint
  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 PHPPowerPoint
  22. * @package PHPPowerPoint_Writer_ODPresentation
  23. * @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. /**
  28. * PHPPowerPoint_Writer_ODPresentation_Meta
  29. *
  30. * @category PHPPowerPoint
  31. * @package PHPPowerPoint_Writer_ODPresentation
  32. * @copyright Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  33. */
  34. class PHPPowerPoint_Writer_ODPresentation_Meta extends PHPPowerPoint_Writer_ODPresentation_WriterPart
  35. {
  36. /**
  37. * Write Meta file to XML format
  38. *
  39. * @param PHPPowerPoint $pPHPPowerPoint
  40. * @return string XML Output
  41. * @throws Exception
  42. */
  43. public function writeMeta(PHPPowerPoint $pPHPPowerPoint = null)
  44. {
  45. // Create XML writer
  46. $objWriter = null;
  47. if ($this->getParentWriter()->getUseDiskCaching()) {
  48. $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
  49. } else {
  50. $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
  51. }
  52. // XML header
  53. $objWriter->startDocument('1.0','UTF-8');
  54. // office:document-meta
  55. $objWriter->startElement('office:document-meta');
  56. $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
  57. $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
  58. $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
  59. $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
  60. $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
  61. $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
  62. $objWriter->writeAttribute('xmlns:smil', 'urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0');
  63. $objWriter->writeAttribute('xmlns:anim', 'urn:oasis:names:tc:opendocument:xmlns:animation:1.0');
  64. $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
  65. $objWriter->writeAttribute('xmlns:officeooo', 'http://openoffice.org/2009/office');
  66. $objWriter->writeAttribute('xmlns:drawooo', 'http://openoffice.org/2010/draw');
  67. $objWriter->writeAttribute('office:version', '1.2');
  68. // office:meta
  69. $objWriter->startElement('office:meta');
  70. // dc:creator
  71. $objWriter->writeElement('dc:creator', $pPHPPowerPoint->getProperties()->getLastModifiedBy());
  72. // dc:date
  73. $objWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000' ,$pPHPPowerPoint->getProperties()->getModified()));
  74. // dc:description
  75. $objWriter->writeElement('dc:description', $pPHPPowerPoint->getProperties()->getDescription());
  76. // dc:subject
  77. $objWriter->writeElement('dc:subject', $pPHPPowerPoint->getProperties()->getSubject());
  78. // dc:title
  79. $objWriter->writeElement('dc:title', $pPHPPowerPoint->getProperties()->getTitle());
  80. // meta:creation-date
  81. $objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000' ,$pPHPPowerPoint->getProperties()->getCreated()));
  82. // meta:initial-creator
  83. $objWriter->writeElement('meta:initial-creator', $pPHPPowerPoint->getProperties()->getCreator());
  84. // meta:keyword
  85. $objWriter->writeElement('meta:keyword', $pPHPPowerPoint->getProperties()->getKeywords());
  86. // @todo : Where these properties are written ?
  87. // $pPHPPowerPoint->getProperties()->getCategory()
  88. // $pPHPPowerPoint->getProperties()->getCompany()
  89. $objWriter->endElement();
  90. $objWriter->endElement();
  91. // Return
  92. return $objWriter->getData();
  93. }
  94. }