profileblock.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2011, StatusNet, Inc.
  5. *
  6. * Superclass for profile blocks
  7. *
  8. * PHP version 5
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * @category Widget
  24. * @package StatusNet
  25. * @author Evan Prodromou <evan@status.net>
  26. * @copyright 2011 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('STATUSNET')) {
  31. // This check helps protect against security problems;
  32. // your code file can't be executed directly from the web.
  33. exit(1);
  34. }
  35. /**
  36. * Class comment
  37. *
  38. * @category General
  39. * @package StatusNet
  40. * @author Evan Prodromou <evan@status.net>
  41. * @copyright 2011 StatusNet, Inc.
  42. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  43. * @link http://status.net/
  44. */
  45. abstract class ProfileBlock extends Widget
  46. {
  47. protected $avatarSize = AVATAR_PROFILE_SIZE;
  48. abstract function name();
  49. abstract function url();
  50. abstract function location();
  51. abstract function homepage();
  52. abstract function description();
  53. function show()
  54. {
  55. $this->showActions();
  56. $this->showAvatar($this->profile);
  57. $this->showName();
  58. $this->showLocation();
  59. $this->showHomepage();
  60. $this->showOtherProfiles();
  61. $this->showDescription();
  62. $this->showTags();
  63. }
  64. function showName()
  65. {
  66. $name = $this->name();
  67. if (!empty($name)) {
  68. $this->out->elementStart('p', 'profile_block_name');
  69. $url = $this->url();
  70. if (!empty($url)) {
  71. $this->out->element('a', array('href' => $url),
  72. $name);
  73. } else {
  74. $this->out->text($name);
  75. }
  76. $this->out->elementEnd('p');
  77. }
  78. }
  79. function showDescription()
  80. {
  81. $description = $this->description();
  82. if (!empty($description)) {
  83. $this->out->element(
  84. 'p',
  85. 'profile_block_description',
  86. $description
  87. );
  88. }
  89. }
  90. function showLocation()
  91. {
  92. $location = $this->location();
  93. if (!empty($location)) {
  94. $this->out->element('p', 'profile_block_location', $location);
  95. }
  96. }
  97. function showHomepage()
  98. {
  99. $homepage = $this->homepage();
  100. if (!empty($homepage)) {
  101. $this->out->element('a',
  102. array('href' => $homepage,
  103. 'rel' => 'me',
  104. 'class' => 'profile_block_homepage'),
  105. $homepage);
  106. }
  107. }
  108. function showOtherProfiles()
  109. {
  110. $otherProfiles = $this->otherProfiles();
  111. if (!empty($otherProfiles)) {
  112. $this->out->elementStart('ul',
  113. array('class' => 'profile_block_otherprofile_list'));
  114. foreach ($otherProfiles as $otherProfile) {
  115. $this->out->elementStart('li');
  116. $this->out->elementStart('a',
  117. array('href' => $otherProfile['href'],
  118. 'rel' => 'me',
  119. 'class' => 'profile_block_otherprofile',
  120. 'title' => $otherProfile['text']));
  121. $this->out->element('img',
  122. array('src' => $otherProfile['image'],
  123. 'class' => 'profile_block_otherprofile_icon'));
  124. $this->out->elementEnd('a');
  125. $this->out->elementEnd('li');
  126. }
  127. $this->out->elementEnd('ul');
  128. }
  129. }
  130. function showTags()
  131. {
  132. }
  133. function showActions()
  134. {
  135. }
  136. }