personaltagcloudsection.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Personal tag cloud section
  18. *
  19. * @category Widget
  20. * @package GNUsocial
  21. * @author Evan Prodromou <evan@status.net>
  22. * @copyright 2009 StatusNet, Inc.
  23. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  24. */
  25. defined('GNUSOCIAL') || die();
  26. /**
  27. * Personal tag cloud section
  28. *
  29. * @copyright 2009 StatusNet, Inc.
  30. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  31. */
  32. class PersonalTagCloudSection extends TagCloudSection
  33. {
  34. protected $profile = null;
  35. public function __construct(HTMLOutputter $out, Profile $profile)
  36. {
  37. parent::__construct($out);
  38. $this->profile = $profile;
  39. }
  40. public function title()
  41. {
  42. // TRANS: Title for personal tag cloud section.
  43. return _m('TITLE', 'Tags');
  44. }
  45. public function getTags()
  46. {
  47. $weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
  48. // @fixme should we use the cutoff too? Doesn't help with indexing per-user.
  49. $limit = TAGS_PER_SECTION;
  50. $qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' AS weight ' .
  51. 'FROM notice_tag INNER JOIN notice ' .
  52. 'ON notice_tag.notice_id = notice.id ' .
  53. 'WHERE notice.profile_id = %d ' .
  54. 'GROUP BY notice_tag.tag ' .
  55. 'ORDER BY weight DESC LIMIT ' . $limit;
  56. $tag = Memcached_DataObject::cachedQuery(
  57. 'Notice_tag',
  58. sprintf($qry, $this->profile->getID()),
  59. 3600
  60. );
  61. return $tag;
  62. }
  63. }