No Description

Footer.php 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 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. * @link http://www.schemacentral.com/sc/ooxml/a-wtype-4.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. * @return void
  62. */
  63. public function setType($value = self::AUTO)
  64. {
  65. if (!in_array($value, array(self::AUTO, self::FIRST, self::EVEN))) {
  66. $value = self::AUTO;
  67. }
  68. $this->type = $value;
  69. }
  70. /**
  71. * Get type
  72. *
  73. * @return string
  74. * @since 0.10.0
  75. */
  76. public function getType()
  77. {
  78. return $this->type;
  79. }
  80. /**
  81. * Reset type to default
  82. *
  83. * @return string
  84. */
  85. public function resetType()
  86. {
  87. return $this->type = self::AUTO;
  88. }
  89. /**
  90. * First page only header
  91. *
  92. * @return string
  93. */
  94. public function firstPage()
  95. {
  96. return $this->type = self::FIRST;
  97. }
  98. /**
  99. * Even numbered pages only
  100. *
  101. * @return string
  102. */
  103. public function evenPage()
  104. {
  105. return $this->type = self::EVEN;
  106. }
  107. }