PHP Universal Feed Generator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.8 KiB

  1. <?php
  2. namespace FeedWriter\View;
  3. use FeedWriter\View\SyndicationBase;
  4. /*
  5. * Copyright (C) 2012 Michael Bemmerl <mail@mx-server.de>
  6. *
  7. * This file is part of the "Universal Feed Writer" project.
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * Wrapper for creating ATOM feeds
  24. *
  25. * @package UniversalFeedWriter
  26. */
  27. class Atom extends SyndicationBase
  28. {
  29. public $require = [
  30. 'date',
  31. 'author',
  32. 'content',
  33. 'title',
  34. 'link',
  35. ];
  36. /**
  37. * {@inheritdoc}
  38. */
  39. function __construct()
  40. {
  41. parent::__construct(SyndicationBase::ATOM);
  42. }
  43. public function collect ($source_item)
  44. {
  45. $item = $this->createNewItem();
  46. $item->setTitle($source_item->title);
  47. $item->setLink($source_item->link);
  48. $item->setDate($source_item->date);
  49. $item->setAuthor($source_item->author);
  50. // TODO: Hrm.
  51. // $item->setEnclosure('http://upload.wikimedia.org/wikipedia/commons/4/49/En-us-hello-1.ogg', 11779, 'audio/ogg');
  52. // Internally changed to "summary" tag for ATOM feed:
  53. $item->setDescription('This is a test of adding CDATA encoded description by the php <b>Universal Feed Writer</b> class');
  54. $item->setContent($source_item->content);
  55. $this->addItem($item);
  56. }
  57. }