peopletagsection.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Base class for sections showing lists of peopletags
  6. *
  7. * PHP version 5
  8. *
  9. * LICENCE: This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero 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 Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Widget
  23. * @package StatusNet
  24. * @author Shashi Gowda <connect2shashi@gmail.com>
  25. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  26. * @link http://status.net/
  27. */
  28. if (!defined('STATUSNET') && !defined('LACONICA')) {
  29. exit(1);
  30. }
  31. require_once INSTALLDIR . '/lib/peopletaglist.php';
  32. define('PEOPLETAGS_PER_SECTION', 6);
  33. /**
  34. * Base class for sections
  35. *
  36. * These are the widgets that show interesting data about a person
  37. * peopletag, or site.
  38. *
  39. * @category Widget
  40. * @package StatusNet
  41. * @author Shashi Gowda <connect2shashi@gmail.com>
  42. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  43. * @link http://status.net/
  44. */
  45. class PeopletagSection extends Section
  46. {
  47. protected $avatarSize = AVATAR_MINI_SIZE;
  48. function showContent()
  49. {
  50. $tags = $this->getPeopletags();
  51. if (!$tags) {
  52. return false;
  53. }
  54. $cnt = 0;
  55. $this->out->elementStart('table', 'peopletag_section');
  56. while ($tags->fetch() && ++$cnt <= PEOPLETAGS_PER_SECTION) {
  57. $this->showPeopletag($tags);
  58. }
  59. $this->out->elementEnd('table');
  60. return ($cnt > PEOPLETAGS_PER_SECTION);
  61. }
  62. function getPeopletags()
  63. {
  64. return null;
  65. }
  66. function showPeopletag($peopletag)
  67. {
  68. $tag = new PeopletagSectionItem($peopletag, null, $this->out);
  69. $tag->show();
  70. }
  71. }
  72. class PeopletagSectionItem extends PeopletagListItem
  73. {
  74. function showStart()
  75. {
  76. }
  77. function showEnd()
  78. {
  79. }
  80. function showPeopletag()
  81. {
  82. $this->showCreator();
  83. $this->showTag();
  84. $this->showPrivacy();
  85. }
  86. function show()
  87. {
  88. if (empty($this->peopletag)) {
  89. common_log(LOG_WARNING, "Trying to show missing peopletag; skipping.");
  90. return;
  91. }
  92. $mode = ($this->peopletag->private) ? 'private' : 'public';
  93. $this->out->elementStart('tr');
  94. $this->out->elementStart('td', 'peopletag mode-' . $mode);
  95. $this->showPeopletag();
  96. $this->out->elementEnd('td');
  97. if (isset($this->peopletag->value)) {
  98. $this->out->element('td', 'value', $this->peopletag->value);
  99. }
  100. $this->out->elementEnd('tr');
  101. }
  102. function showTag()
  103. {
  104. // TRANS: List summary. %1$d is the number of users in the list,
  105. // TRANS: %2$d is the number of subscribers to the list.
  106. $title = sprintf(_('Listed: %1$d Subscribers: %2$d'),
  107. $this->peopletag->taggedCount(),
  108. $this->peopletag->subscriberCount());
  109. $this->out->elementStart('span', 'entry-title tag');
  110. $this->out->element('a',
  111. array('rel' => 'bookmark',
  112. 'href' => $this->url(),
  113. 'title' => $title),
  114. htmlspecialchars($this->peopletag->tag));
  115. $this->out->elementEnd('span');
  116. }
  117. }