forked from GNUsocial/gnu-social
Rationalize logic in showProfile()
Pulled together some of the if() statements in showProfile() so they weren't so redundant. Also, reformatted the file. Lots of whitespace gar.
This commit is contained in:
parent
8ade2e1c7d
commit
5702764e52
@ -115,11 +115,11 @@ class ShowstreamAction extends ProfileAction
|
|||||||
{
|
{
|
||||||
if (!empty($this->tag)) {
|
if (!empty($this->tag)) {
|
||||||
return array(new Feed(Feed::RSS1,
|
return array(new Feed(Feed::RSS1,
|
||||||
common_local_url('userrss',
|
common_local_url('userrss',
|
||||||
array('nickname' => $this->user->nickname,
|
array('nickname' => $this->user->nickname,
|
||||||
'tag' => $this->tag)),
|
'tag' => $this->tag)),
|
||||||
sprintf(_('Notice feed for %s tagged %s (RSS 1.0)'),
|
sprintf(_('Notice feed for %s tagged %s (RSS 1.0)'),
|
||||||
$this->user->nickname, $this->tag)));
|
$this->user->nickname, $this->tag)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(new Feed(Feed::RSS1,
|
return array(new Feed(Feed::RSS1,
|
||||||
@ -250,6 +250,7 @@ class ShowstreamAction extends ProfileAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
$tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
|
$tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
|
||||||
|
|
||||||
if (count($tags) > 0) {
|
if (count($tags) > 0) {
|
||||||
$this->elementStart('dl', 'entity_tags');
|
$this->elementStart('dl', 'entity_tags');
|
||||||
$this->element('dt', null, _('Tags'));
|
$this->element('dt', null, _('Tags'));
|
||||||
@ -259,8 +260,8 @@ class ShowstreamAction extends ProfileAction
|
|||||||
$this->elementStart('li');
|
$this->elementStart('li');
|
||||||
// Avoid space by using raw output.
|
// Avoid space by using raw output.
|
||||||
$pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
|
$pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
|
||||||
common_local_url('peopletag', array('tag' => $tag)) .
|
common_local_url('peopletag', array('tag' => $tag)) .
|
||||||
'">' . $tag . '</a>';
|
'">' . $tag . '</a>';
|
||||||
$this->raw($pt);
|
$this->raw($pt);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
@ -268,23 +269,30 @@ class ShowstreamAction extends ProfileAction
|
|||||||
$this->elementEnd('dd');
|
$this->elementEnd('dd');
|
||||||
$this->elementEnd('dl');
|
$this->elementEnd('dl');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->elementEnd('div');
|
$this->elementEnd('div');
|
||||||
|
|
||||||
$this->elementStart('div', 'entity_actions');
|
$this->elementStart('div', 'entity_actions');
|
||||||
$this->element('h2', null, _('User actions'));
|
$this->element('h2', null, _('User actions'));
|
||||||
$this->elementStart('ul');
|
$this->elementStart('ul');
|
||||||
|
|
||||||
if ($cur && $cur->id == $this->profile->id) {
|
if (empty($cur)) { // not logged in
|
||||||
$this->elementStart('li', 'entity_edit');
|
$this->elementStart('li', 'entity_subscribe');
|
||||||
$this->element('a', array('href' => common_local_url('profilesettings'),
|
$this->showRemoteSubscribeLink();
|
||||||
'title' => _('Edit profile settings')),
|
|
||||||
_('Edit'));
|
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
} else {
|
||||||
|
if ($cur->id == $this->profile->id) { // your own page
|
||||||
|
$this->elementStart('li', 'entity_edit');
|
||||||
|
$this->element('a', array('href' => common_local_url('profilesettings'),
|
||||||
|
'title' => _('Edit profile settings')),
|
||||||
|
_('Edit'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
} else { // someone else's page
|
||||||
|
|
||||||
|
// subscribe/unsubscribe button
|
||||||
|
|
||||||
if ($cur) {
|
|
||||||
if ($cur->id != $this->profile->id) {
|
|
||||||
$this->elementStart('li', 'entity_subscribe');
|
$this->elementStart('li', 'entity_subscribe');
|
||||||
|
|
||||||
if ($cur->isSubscribed($this->profile)) {
|
if ($cur->isSubscribed($this->profile)) {
|
||||||
$usf = new UnsubscribeForm($this, $this->profile);
|
$usf = new UnsubscribeForm($this, $this->profile);
|
||||||
$usf->show();
|
$usf->show();
|
||||||
@ -293,44 +301,46 @@ class ShowstreamAction extends ProfileAction
|
|||||||
$sf->show();
|
$sf->show();
|
||||||
}
|
}
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$this->elementStart('li', 'entity_subscribe');
|
|
||||||
$this->showRemoteSubscribeLink();
|
|
||||||
$this->elementEnd('li');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) {
|
if ($cur->mutuallySubscribed($user)) {
|
||||||
$this->elementStart('li', 'entity_send-a-message');
|
|
||||||
$this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)),
|
|
||||||
'title' => _('Send a direct message to this user')),
|
|
||||||
_('Message'));
|
|
||||||
$this->elementEnd('li');
|
|
||||||
|
|
||||||
if ($user->email && $user->emailnotifynudge) {
|
// message
|
||||||
$this->elementStart('li', 'entity_nudge');
|
|
||||||
$nf = new NudgeForm($this, $user);
|
$this->elementStart('li', 'entity_send-a-message');
|
||||||
$nf->show();
|
$this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)),
|
||||||
|
'title' => _('Send a direct message to this user')),
|
||||||
|
_('Message'));
|
||||||
|
$this->elementEnd('li');
|
||||||
|
|
||||||
|
// nudge
|
||||||
|
|
||||||
|
if ($user->email && $user->emailnotifynudge) {
|
||||||
|
$this->elementStart('li', 'entity_nudge');
|
||||||
|
$nf = new NudgeForm($this, $user);
|
||||||
|
$nf->show();
|
||||||
|
$this->elementEnd('li');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// block/unblock
|
||||||
|
|
||||||
|
$blocked = $cur->hasBlocked($this->profile);
|
||||||
|
$this->elementStart('li', 'entity_block');
|
||||||
|
if ($blocked) {
|
||||||
|
$ubf = new UnblockForm($this, $this->profile,
|
||||||
|
array('action' => 'showstream',
|
||||||
|
'nickname' => $this->profile->nickname));
|
||||||
|
$ubf->show();
|
||||||
|
} else {
|
||||||
|
$bf = new BlockForm($this, $this->profile,
|
||||||
|
array('action' => 'showstream',
|
||||||
|
'nickname' => $this->profile->nickname));
|
||||||
|
$bf->show();
|
||||||
|
}
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cur && $cur->id != $this->profile->id) {
|
|
||||||
$blocked = $cur->hasBlocked($this->profile);
|
|
||||||
$this->elementStart('li', 'entity_block');
|
|
||||||
if ($blocked) {
|
|
||||||
$ubf = new UnblockForm($this, $this->profile,
|
|
||||||
array('action' => 'showstream',
|
|
||||||
'nickname' => $this->profile->nickname));
|
|
||||||
$ubf->show();
|
|
||||||
} else {
|
|
||||||
$bf = new BlockForm($this, $this->profile,
|
|
||||||
array('action' => 'showstream',
|
|
||||||
'nickname' => $this->profile->nickname));
|
|
||||||
$bf->show();
|
|
||||||
}
|
|
||||||
$this->elementEnd('li');
|
|
||||||
}
|
|
||||||
$this->elementEnd('ul');
|
$this->elementEnd('ul');
|
||||||
$this->elementEnd('div');
|
$this->elementEnd('div');
|
||||||
}
|
}
|
||||||
@ -368,7 +378,7 @@ class ShowstreamAction extends ProfileAction
|
|||||||
function showNotices()
|
function showNotices()
|
||||||
{
|
{
|
||||||
$notice = empty($this->tag)
|
$notice = empty($this->tag)
|
||||||
? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
|
? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
|
||||||
: $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
|
: $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
|
||||||
|
|
||||||
$pnl = new ProfileNoticeList($notice, $this);
|
$pnl = new ProfileNoticeList($notice, $this);
|
||||||
@ -390,14 +400,14 @@ class ShowstreamAction extends ProfileAction
|
|||||||
{
|
{
|
||||||
if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
|
if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
|
||||||
$m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
$m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||||
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
|
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
|
||||||
'[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
|
'[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
|
||||||
$this->user->nickname, $this->user->nickname);
|
$this->user->nickname, $this->user->nickname);
|
||||||
} else {
|
} else {
|
||||||
$m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
$m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||||
'based on the Free Software [StatusNet](http://status.net/) tool. '),
|
'based on the Free Software [StatusNet](http://status.net/) tool. '),
|
||||||
$this->user->nickname, $this->user->nickname);
|
$this->user->nickname, $this->user->nickname);
|
||||||
}
|
}
|
||||||
$this->elementStart('div', array('id' => 'anon_notice'));
|
$this->elementStart('div', array('id' => 'anon_notice'));
|
||||||
$this->raw(common_markup_to_html($m));
|
$this->raw(common_markup_to_html($m));
|
||||||
$this->elementEnd('div');
|
$this->elementEnd('div');
|
||||||
|
Loading…
Reference in New Issue
Block a user