RelsRibbon.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * PHPExcel_Writer_Excel2007_RelsRibbon
  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_Excel2007
  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_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_WriterPart
  28. {
  29. /**
  30. * Write relationships for additional objects of custom UI (ribbon)
  31. *
  32. * @param PHPExcel $pPHPExcel
  33. * @return string XML Output
  34. * @throws PHPExcel_Writer_Exception
  35. */
  36. public function writeRibbonRelationships(PHPExcel $pPHPExcel = null)
  37. {
  38. // Create XML writer
  39. $objWriter = null;
  40. if ($this->getParentWriter()->getUseDiskCaching()) {
  41. $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
  42. } else {
  43. $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
  44. }
  45. // XML header
  46. $objWriter->startDocument('1.0', 'UTF-8', 'yes');
  47. // Relationships
  48. $objWriter->startElement('Relationships');
  49. $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
  50. $localRels = $pPHPExcel->getRibbonBinObjects('names');
  51. if (is_array($localRels)) {
  52. foreach ($localRels as $aId => $aTarget) {
  53. $objWriter->startElement('Relationship');
  54. $objWriter->writeAttribute('Id', $aId);
  55. $objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image');
  56. $objWriter->writeAttribute('Target', $aTarget);
  57. $objWriter->endElement();
  58. }
  59. }
  60. $objWriter->endElement();
  61. return $objWriter->getData();
  62. }
  63. }