X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fshowstream.php;h=d9637c377520da50621b0780c6395405ceaac8d9;hb=4aedce6864eb27a0c37b3dcae22fee0aa16ae537;hp=2130251ce170936173dd218fe6ea56ace2e8fdbc;hpb=9f39fd31afe198fc78c669088710af64a9976c3d;p=quix0rs-gnu-social.git diff --git a/actions/showstream.php b/actions/showstream.php index 2130251ce1..d9637c3775 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -52,10 +52,10 @@ class ShowstreamAction extends StreamAction { header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' => $user->nickname))); - common_show_header($profile->nickname, array($this, 'show_header'), $user); - - $this->views_menu(); - + common_show_header($profile->nickname, + array($this, 'show_header'), $user, + array($this, 'show_top')); + $this->show_profile($profile); $this->show_notices($profile); @@ -63,6 +63,17 @@ class ShowstreamAction extends StreamAction { common_show_footer(); } + function show_top($user) { + + $cur = common_current_user(); + + if ($cur && $cur->id == $user->id) { + common_notice_form(); + } + + $this->views_menu(); + } + function show_header($user) { common_element('link', array('rel' => 'alternate', 'href' => common_local_url('userrss', array('nickname' => @@ -102,27 +113,26 @@ class ShowstreamAction extends StreamAction { function show_personal($profile) { $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - if ($avatar) { - common_element_start('div', array('id' => 'profile_avatar')); - common_element('img', array('src' => $avatar->url, - 'class' => 'avatar profile', - 'width' => AVATAR_PROFILE_SIZE, - 'height' => AVATAR_PROFILE_SIZE, - 'alt' => $profile->nickname)); - $cur = common_current_user(); - if ($cur) { - if ($cur->id != $profile->id) { - if ($cur->isSubscribed($profile)) { - $this->show_unsubscribe_form($profile); - } else { - $this->show_subscribe_form($profile); - } + common_element_start('div', array('id' => 'profile_avatar')); + common_element('img', array('src' => ($avatar) ? $avatar->url : common_default_avatar(AVATAR_PROFILE_SIZE), + 'class' => 'avatar profile', + 'width' => AVATAR_PROFILE_SIZE, + 'height' => AVATAR_PROFILE_SIZE, + 'alt' => $profile->nickname)); + $cur = common_current_user(); + if ($cur) { + if ($cur->id != $profile->id) { + if ($cur->isSubscribed($profile)) { + $this->show_unsubscribe_form($profile); + } else { + $this->show_subscribe_form($profile); } - } else { - $this->show_remote_subscribe_form($profile); } - common_element_end('div'); + } else { + $this->show_remote_subscribe_form($profile); } + common_element_end('div'); + common_element_start('div', array('id' => 'profile_information')); if ($profile->fullname) { @@ -135,7 +145,10 @@ class ShowstreamAction extends StreamAction { common_element('p', 'description', htmlspecialchars($profile->bio)); } if ($profile->homepage) { - common_element('p', 'website', $profile->homepage); + common_element_start('p', 'website'); + common_element('a', array('href' => $profile->homepage), + $profile->homepage); + common_element_end('p'); } $this->show_statistics($profile); @@ -151,7 +164,7 @@ class ShowstreamAction extends StreamAction { 'type' => 'hidden', 'value' => $profile->nickname)); common_element('input', array('type' => 'submit', - 'class' => 'button', + 'class' => 'submit', 'value' => _t('Subscribe'))); common_element_end('form'); } @@ -161,15 +174,15 @@ class ShowstreamAction extends StreamAction { 'method' => 'POST', 'action' => common_local_url('remotesubscribe'))); common_hidden('nickname', $profile->nickname); - common_element('input', array('name' => 'profile', + common_element('input', array('name' => 'profile_url', 'type' => 'text', - 'id' => 'profile', + 'id' => 'profile_url', 'size' => '15')); common_element('input', array('type' => 'submit', 'id' => 'submit', 'name' => 'submit', 'value' => _t('Subscribe'), - 'class' => 'button')); + 'class' => 'submit')); common_element_end('form'); } @@ -181,7 +194,7 @@ class ShowstreamAction extends StreamAction { 'type' => 'hidden', 'value' => $profile->nickname)); common_element('input', array('type' => 'submit', - 'class' => 'button', + 'class' => 'submit', 'value' => _t('Unsubscribe'))); common_element_end('form'); } @@ -189,13 +202,13 @@ class ShowstreamAction extends StreamAction { function show_subscriptions($profile) { global $config; - # XXX: add a limit $subs = DB_DataObject::factory('subscription'); $subs->subscriber = $profile->id; - + $subs->orderBy('created DESC'); + # We ask for an extra one to know if we need to do another page - $subs->limit(0, SUBSCRIPTIONS); + $subs->limit(0, SUBSCRIPTIONS + 1); $subs_count = $subs->find(); @@ -207,7 +220,12 @@ class ShowstreamAction extends StreamAction { common_element_start('ul', array('id' => 'subscriptions_avatars')); - while ($subs->fetch()) { + for ($i = 0; $i < min($subs_count, SUBSCRIPTIONS); $i++) { + + if (!$subs->fetch()) { + common_debug('Weirdly, broke out of subscriptions loop early', __FILE__); + break; + } $other = Profile::staticGet($subs->subscribed); @@ -228,17 +246,19 @@ class ShowstreamAction extends StreamAction { common_element_end('a'); common_element_end('li'); } + common_element_end('ul'); } - common_element_start('p', array('id' => 'subscriptions_viewall')); - - common_element('a', array('href' => common_local_url('subscriptions', - array('nickname' => $profile->nickname)), - 'class' => 'moresubscriptions'), - _t('All subscriptions')); - - common_element_end('p'); + if ($subs_count > SUBSCRIPTIONS) { + common_element_start('p', array('id' => 'subscriptions_viewall')); + + common_element('a', array('href' => common_local_url('subscriptions', + array('nickname' => $profile->nickname)), + 'class' => 'moresubscriptions'), + _t('All subscriptions')); + common_element_end('p'); + } common_element_end('div'); } @@ -263,9 +283,17 @@ class ShowstreamAction extends StreamAction { # Other stats...? common_element_start('dl', 'statistics'); - common_element('dt', 'subscriptions', _t('Subscriptions')); + common_element_start('dt', 'subscriptions'); + common_element('a', array('href' => common_local_url('subscriptions', + array('nickname' => $profile->nickname))), + _t('Subscriptions')); + common_element_end('dt'); common_element('dd', 'subscriptions', $subs_count); - common_element('dt', 'subscribers', _t('Subscribers')); + common_element_start('dt', 'subscribers'); + common_element('a', array('href' => common_local_url('subscribers', + array('nickname' => $profile->nickname))), + _t('Subscribers')); + common_element_end('dt'); common_element('dd', 'subscribers', $subbed_count); common_element('dt', 'notices', _t('Notices')); common_element('dd', 'notices', $notice_count);