Footer.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @see https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2018 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Element;
  18. /**
  19. * Footer element
  20. */
  21. class Footer extends AbstractContainer
  22. {
  23. /**
  24. * Header/footer types constants
  25. *
  26. * @var string
  27. * @see http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type
  28. */
  29. const AUTO = 'default'; // default and odd pages
  30. const FIRST = 'first';
  31. const EVEN = 'even';
  32. /**
  33. * @var string Container type
  34. */
  35. protected $container = 'Footer';
  36. /**
  37. * Header type
  38. *
  39. * @var string
  40. */
  41. protected $type = self::AUTO;
  42. /**
  43. * Create new instance
  44. *
  45. * @param int $sectionId
  46. * @param int $containerId
  47. * @param string $type
  48. */
  49. public function __construct($sectionId, $containerId = 1, $type = self::AUTO)
  50. {
  51. $this->sectionId = $sectionId;
  52. $this->setType($type);
  53. $this->setDocPart($this->container, ($sectionId - 1) * 3 + $containerId);
  54. }
  55. /**
  56. * Set type.
  57. *
  58. * @since 0.10.0
  59. *
  60. * @param string $value
  61. */
  62. public function setType($value = self::AUTO)
  63. {
  64. if (!in_array($value, array(self::AUTO, self::FIRST, self::EVEN))) {
  65. $value = self::AUTO;
  66. }
  67. $this->type = $value;
  68. }
  69. /**
  70. * Get type
  71. *
  72. * @return string
  73. * @since 0.10.0
  74. */
  75. public function getType()
  76. {
  77. return $this->type;
  78. }
  79. /**
  80. * Reset type to default
  81. *
  82. * @return string
  83. */
  84. public function resetType()
  85. {
  86. return $this->type = self::AUTO;
  87. }
  88. /**
  89. * First page only header
  90. *
  91. * @return string
  92. */
  93. public function firstPage()
  94. {
  95. return $this->type = self::FIRST;
  96. }
  97. /**
  98. * Even numbered pages only
  99. *
  100. * @return string
  101. */
  102. public function evenPage()
  103. {
  104. return $this->type = self::EVEN;
  105. }
  106. }