HtmlDescribable.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * An HtmlDescribable is an item within a feed that can have a description that may
  4. * include HTML markup.
  5. */
  6. class HtmlDescribable
  7. {
  8. /**
  9. * Indicates whether the description field should be rendered in HTML.
  10. */
  11. public $descriptionHtmlSyndicated;
  12. /**
  13. * Indicates whether and to how many characters a description should be truncated.
  14. */
  15. public $descriptionTruncSize;
  16. /** @var string the Description */
  17. public $description;
  18. /**
  19. * Returns a formatted description field, depending on descriptionHtmlSyndicated and
  20. * $descriptionTruncSize properties
  21. *
  22. * @param bool $overrideSyndicateHtml
  23. * @return string the formatted description
  24. */
  25. public function getDescription($overrideSyndicateHtml = false)
  26. {
  27. $descriptionField = new FeedHtmlField($this->description);
  28. $descriptionField->syndicateHtml = $overrideSyndicateHtml || $this->descriptionHtmlSyndicated;
  29. $descriptionField->truncSize = $this->descriptionTruncSize;
  30. return $descriptionField->output();
  31. }
  32. }