forked from GNUsocial/gnu-social
Fixed group representation in Directory plugin, also some ->raw calls
This commit is contained in:
parent
c02f23e63f
commit
9e5c71e701
@ -1422,6 +1422,18 @@ class Profile extends Managed_DataObject
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
$url = null;
|
||||
if ($this->isGroup()) {
|
||||
// FIXME: Get rid of this event, it fills no real purpose, data should be in Profile->profileurl (replaces User_group->mainpage)
|
||||
if (Event::handle('StartUserGroupHomeUrl', array($this->getGroup(), &$url))) {
|
||||
$url = $this->isLocal()
|
||||
? common_local_url('showgroup', array('nickname' => $this->getNickname()))
|
||||
: $this->profileurl;
|
||||
}
|
||||
Event::handle('EndUserGroupHomeUrl', array($this->getGroup(), $url));
|
||||
} else {
|
||||
$url = $this->profileurl;
|
||||
}
|
||||
if (empty($this->profileurl) ||
|
||||
!filter_var($this->profileurl, FILTER_VALIDATE_URL)) {
|
||||
throw new InvalidUrlException($this->profileurl);
|
||||
|
@ -115,18 +115,7 @@ class User_group extends Managed_DataObject
|
||||
|
||||
function homeUrl()
|
||||
{
|
||||
$url = null;
|
||||
if (Event::handle('StartUserGroupHomeUrl', array($this, &$url))) {
|
||||
// normally stored in mainpage, but older ones may be null
|
||||
if (!empty($this->mainpage)) {
|
||||
$url = $this->mainpage;
|
||||
} elseif ($this->isLocal()) {
|
||||
$url = common_local_url('showgroup',
|
||||
array('nickname' => $this->nickname));
|
||||
}
|
||||
}
|
||||
Event::handle('EndUserGroupHomeUrl', array($this, &$url));
|
||||
return $url;
|
||||
$this->getProfile()->getUrl();
|
||||
}
|
||||
|
||||
function getUri()
|
||||
|
@ -105,7 +105,7 @@ class SortableGroupList extends SortableSubscriptionList
|
||||
$this->out->elementStart('tbody');
|
||||
}
|
||||
|
||||
function newListItem($profile)
|
||||
function newListItem(Profile $profile)
|
||||
{
|
||||
return new SortableGroupListItem($profile, $this->owner, $this->action);
|
||||
}
|
||||
@ -115,28 +115,20 @@ class SortableGroupListItem extends SortableSubscriptionListItem
|
||||
{
|
||||
function showHomepage()
|
||||
{
|
||||
if (!empty($this->profile->homepage)) {
|
||||
if ($this->profile->getHomepage()) {
|
||||
$this->out->text(' ');
|
||||
$aAttrs = $this->homepageAttributes();
|
||||
$this->out->elementStart('a', $aAttrs);
|
||||
$this->out->raw($this->highlight($this->profile->homepage));
|
||||
$this->out->text($this->profile->getHomepage());
|
||||
$this->out->elementEnd('a');
|
||||
}
|
||||
}
|
||||
|
||||
function showDescription()
|
||||
{
|
||||
if (!empty($this->profile->description)) {
|
||||
$cutoff = 140; // XXX Should this be configurable?
|
||||
$description = htmlspecialchars($this->profile->description);
|
||||
|
||||
if (mb_strlen($description) > $cutoff) {
|
||||
$description = mb_substr($description, 0, $cutoff - 1)
|
||||
.'<a href="' . $this->profile->homeUrl() .'">…</a>';
|
||||
}
|
||||
|
||||
if ($this->profile->getDescription()) {
|
||||
$this->out->elementStart('p', 'note');
|
||||
$this->out->raw($description);
|
||||
$this->out->text($this->profile->getDescription());
|
||||
$this->out->elementEnd('p');
|
||||
}
|
||||
|
||||
@ -181,8 +173,8 @@ class SortableGroupListItem extends SortableSubscriptionListItem
|
||||
{
|
||||
$this->startProfile();
|
||||
|
||||
$this->showAvatar($this->profile->getProfile());
|
||||
$this->out->element('a', array('href' => $this->profile->homeUrl(),
|
||||
$this->showAvatar($this->profile);
|
||||
$this->out->element('a', array('href' => $this->profile->getUrl(),
|
||||
'class' => 'p-org p-nickname',
|
||||
'rel' => 'contact group'),
|
||||
$this->profile->getNickname());
|
||||
@ -231,7 +223,7 @@ class SortableGroupListItem extends SortableSubscriptionListItem
|
||||
$this->out->elementStart('li', 'entity_subscribe');
|
||||
// XXX: special-case for user looking at own
|
||||
// subscriptions page
|
||||
if ($user->isMember($this->profile)) {
|
||||
if ($user->isMember($this->profile->getGroup())) {
|
||||
$lf = new LeaveForm($this->out, $this->profile);
|
||||
$lf->show();
|
||||
} else if (!Group_block::isBlocked($this->profile, $user->getProfile())) {
|
||||
@ -246,7 +238,7 @@ class SortableGroupListItem extends SortableSubscriptionListItem
|
||||
function showMemberCount()
|
||||
{
|
||||
$this->out->elementStart('td', 'entry_member_count');
|
||||
$this->out->raw($this->profile->getMemberCount());
|
||||
$this->out->text($this->profile->getGroup()->getMemberCount());
|
||||
$this->out->elementEnd('td');
|
||||
}
|
||||
|
||||
@ -254,7 +246,7 @@ class SortableGroupListItem extends SortableSubscriptionListItem
|
||||
{
|
||||
$this->out->elementStart('td', 'entry_created');
|
||||
// @todo FIXME: Should we provide i18n for timestamps in core?
|
||||
$this->out->raw(date('j M Y', strtotime($this->profile->created)));
|
||||
$this->out->text(date('j M Y', strtotime($this->profile->created)));
|
||||
$this->out->elementEnd('td');
|
||||
}
|
||||
|
||||
@ -262,7 +254,7 @@ class SortableGroupListItem extends SortableSubscriptionListItem
|
||||
{
|
||||
$this->out->elementStart('td', 'entry_admins');
|
||||
// @todo
|
||||
$this->out->raw('gargargar');
|
||||
$this->out->text('gargargar');
|
||||
$this->out->elementEnd('td');
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ class SortableSubscriptionList extends SubscriptionList
|
||||
$this->out->elementEnd('table');
|
||||
}
|
||||
|
||||
function newListItem($profile)
|
||||
function newListItem(Profile $profile)
|
||||
{
|
||||
return new SortableSubscriptionListItem($profile, $this->owner, $this->action);
|
||||
}
|
||||
@ -197,41 +197,29 @@ class SortableSubscriptionListItem extends SubscriptionListItem
|
||||
function showSubscriberCount()
|
||||
{
|
||||
$this->out->elementStart('td', 'entry_subscriber_count');
|
||||
$this->out->raw($this->profile->subscriberCount());
|
||||
$this->out->text($this->profile->subscriberCount());
|
||||
$this->out->elementEnd('td');
|
||||
}
|
||||
|
||||
function showCreatedDate()
|
||||
{
|
||||
$this->out->elementStart('td', 'entry_created');
|
||||
$this->out->raw(date('j M Y', strtotime($this->profile->created)));
|
||||
$this->out->text(date('j M Y', strtotime($this->profile->created)));
|
||||
$this->out->elementEnd('td');
|
||||
}
|
||||
|
||||
function showNoticeCount()
|
||||
{
|
||||
$this->out->elementStart('td', 'entry_notice_count');
|
||||
$this->out->raw($this->profile->noticeCount());
|
||||
$this->out->text($this->profile->noticeCount());
|
||||
$this->out->elementEnd('td');
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrided to truncate the bio if it's real long, because it
|
||||
* looks better that way in the SortableSubscriptionList's table
|
||||
*/
|
||||
function showBio()
|
||||
{
|
||||
if (!empty($this->profile->bio)) {
|
||||
$cutoff = 140; // XXX Should this be configurable?
|
||||
$bio = htmlspecialchars($this->profile->bio);
|
||||
|
||||
if (mb_strlen($bio) > $cutoff) {
|
||||
$bio = mb_substr($bio, 0, $cutoff - 1)
|
||||
.'<a href="' . $this->profile->profileurl .'">…</a>';
|
||||
}
|
||||
|
||||
if ($this->profile->getDescription()) {
|
||||
$this->out->elementStart('p', 'note');
|
||||
$this->out->raw($bio);
|
||||
$this->out->text($this->profile->getDescription());
|
||||
$this->out->elementEnd('p');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user