Comment.php 2.9 KB

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