Comment.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. *
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Element;
  18. use DateTime;
  19. /**
  20. * Comment element.
  21. *
  22. * @see http://datypic.com/sc/ooxml/t-w_CT_Comment.html
  23. */
  24. class Comment extends TrackChange
  25. {
  26. /**
  27. * Initials.
  28. *
  29. * @var string
  30. */
  31. private $initials;
  32. /**
  33. * The Element where this comment starts.
  34. *
  35. * @var AbstractElement
  36. */
  37. private $startElement;
  38. /**
  39. * The Element where this comment ends.
  40. *
  41. * @var AbstractElement
  42. */
  43. private $endElement;
  44. /**
  45. * Is part of collection.
  46. *
  47. * @var bool
  48. */
  49. protected $collectionRelation = true;
  50. /**
  51. * Create a new Comment Element.
  52. *
  53. * @param string $author
  54. * @param null|DateTime $date
  55. * @param string $initials
  56. */
  57. public function __construct($author, $date = null, $initials = null)
  58. {
  59. parent::__construct(null, $author, $date);
  60. $this->initials = $initials;
  61. }
  62. /**
  63. * Get Initials.
  64. *
  65. * @return string
  66. */
  67. public function getInitials()
  68. {
  69. return $this->initials;
  70. }
  71. /**
  72. * Sets the element where this comment starts.
  73. *
  74. * @param \PhpOffice\PhpWord\Element\AbstractElement $value
  75. */
  76. public function setStartElement(AbstractElement $value): void
  77. {
  78. $this->startElement = $value;
  79. if ($value->getCommentRangeStart() == null) {
  80. $value->setCommentRangeStart($this);
  81. }
  82. }
  83. /**
  84. * Get the element where this comment starts.
  85. *
  86. * @return \PhpOffice\PhpWord\Element\AbstractElement
  87. */
  88. public function getStartElement()
  89. {
  90. return $this->startElement;
  91. }
  92. /**
  93. * Sets the element where this comment ends.
  94. *
  95. * @param \PhpOffice\PhpWord\Element\AbstractElement $value
  96. */
  97. public function setEndElement(AbstractElement $value): void
  98. {
  99. $this->endElement = $value;
  100. if ($value->getCommentRangeEnd() == null) {
  101. $value->setCommentRangeEnd($this);
  102. }
  103. }
  104. /**
  105. * Get the element where this comment ends.
  106. *
  107. * @return \PhpOffice\PhpWord\Element\AbstractElement
  108. */
  109. public function getEndElement()
  110. {
  111. return $this->endElement;
  112. }
  113. }