groupminilist.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Widget to show a mini-list of groups
  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 Public
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @copyright 2008-2009 StatusNet, Inc.
  26. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  27. * @link http://status.net/
  28. */
  29. if (!defined('STATUSNET') && !defined('LACONICA')) {
  30. exit(1);
  31. }
  32. require_once INSTALLDIR.'/lib/grouplist.php';
  33. define('GROUPS_PER_MINILIST', 8);
  34. /**
  35. * Widget to show a list of groups, good for sidebar
  36. *
  37. * @category Public
  38. * @package StatusNet
  39. * @author Evan Prodromou <evan@status.net>
  40. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  41. * @link http://status.net/
  42. */
  43. class GroupMiniList extends GroupList
  44. {
  45. function show()
  46. {
  47. $this->out->elementStart('ul', 'entities groups xoxo');
  48. $cnt = 0;
  49. while ($this->group->fetch()) {
  50. $cnt++;
  51. if($cnt > GROUPS_PER_MINILIST) {
  52. break;
  53. }
  54. $this->showGroup();
  55. }
  56. $this->out->elementEnd('ul');
  57. return $cnt;
  58. }
  59. function showGroup()
  60. {
  61. $this->out->elementStart('li', 'h-card');
  62. $this->out->elementStart('a', array('title' => $this->group->getBestName(),
  63. 'href' => $this->group->homeUrl(),
  64. 'rel' => 'contact group',
  65. 'class' => 'p-name u-url org'));
  66. $logo = ($this->group->mini_logo) ?
  67. $this->group->mini_logo : User_group::defaultLogo(AVATAR_MINI_SIZE);
  68. $this->out->element('img', array('src' => $logo,
  69. 'width' => AVATAR_MINI_SIZE,
  70. 'height' => AVATAR_MINI_SIZE,
  71. 'class' => 'avatar photo',
  72. 'alt' => $this->group->getBestName()));
  73. $this->out->elementEnd('a');
  74. $this->out->elementEnd('li');
  75. }
  76. }