noticesearchrss.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * RSS feed for notice search action class.
  4. *
  5. * PHP version 5
  6. *
  7. * @category Action
  8. * @package StatusNet
  9. * @author Evan Prodromou <evan@status.net>
  10. * @author Robin Millette <millette@status.net>
  11. * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
  12. * @link http://status.net/
  13. *
  14. * StatusNet - the distributed open-source microblogging tool
  15. * Copyright (C) 2008, 2009, StatusNet, Inc.
  16. *
  17. * This program is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License as published by
  19. * the Free Software Foundation, either version 3 of the License, or
  20. * (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  29. */
  30. if (!defined('GNUSOCIAL')) { exit(1); }
  31. /**
  32. * RSS feed for notice search action class.
  33. *
  34. * Formatting of RSS handled by Rss10Action
  35. *
  36. * @category Action
  37. * @package StatusNet
  38. * @author Evan Prodromou <evan@status.net>
  39. * @author Robin Millette <millette@status.net>
  40. * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
  41. * @link http://status.net/
  42. */
  43. class NoticesearchrssAction extends Rss10Action
  44. {
  45. protected function getNotices()
  46. {
  47. $q = $this->trimmed('q');
  48. $notices = array();
  49. $notice = new Notice();
  50. $search_engine = $notice->getSearchEngine('notice');
  51. $search_engine->set_sort_mode('chron');
  52. $search_engine->limit(0, $this->limit, true);
  53. if (false === $search_engine->query($q)) {
  54. $cnt = 0;
  55. } else {
  56. $cnt = $notice->find();
  57. }
  58. if ($cnt > 0) {
  59. while ($notice->fetch()) {
  60. $notices[] = clone($notice);
  61. }
  62. }
  63. return $notices;
  64. }
  65. function getChannel()
  66. {
  67. $q = $this->trimmed('q');
  68. $c = array('url' => common_local_url('noticesearchrss', array('q' => $q)),
  69. // TRANS: RSS notice search feed title. %s is the query.
  70. 'title' => sprintf(_('Updates with "%s"'), $q),
  71. 'link' => common_local_url('noticesearch', array('q' => $q)),
  72. // TRANS: RSS notice search feed description.
  73. // TRANS: %1$s is the query, %2$s is the StatusNet site name.
  74. 'description' => sprintf(_('Updates matching search term "%1$s" on %2$s.'),
  75. $q, common_config('site', 'name')));
  76. return $c;
  77. }
  78. function getImage()
  79. {
  80. return null;
  81. }
  82. function isReadOnly($args)
  83. {
  84. return true;
  85. }
  86. }