]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/showstream.php
use notice URIs in RSS feeds
[quix0rs-gnu-social.git] / actions / showstream.php
index 5a04e9f4712c5c32f5fefb5403b9f771f296c75f..3de9a6e23bd4f4f85e1a7d387719f26ab1b5957b 100644 (file)
@@ -47,7 +47,7 @@ class ShowstreamAction extends StreamAction {
 
                # Looks like we're good; show the header
 
-               common_show_header($profile->nickname);
+               common_show_header($profile->nickname, array($this, 'show_header'), $user);
 
                $cur = common_current_user();
 
@@ -62,6 +62,14 @@ class ShowstreamAction extends StreamAction {
                common_show_footer();
        }
 
+       function show_header($user) {
+               common_element('link', array('rel' => 'alternate',
+                                                                        'href' => common_local_url('userrss', array('nickname' =>
+                                                                                                                                                          $user->nickname)),
+                                                                        'type' => 'application/rss+xml',
+                                                                        'title' => _t('Notice feed for ') . $user->nickname));
+       }
+       
        function no_such_user() {
                common_user_error('No such user');
        }
@@ -74,6 +82,8 @@ class ShowstreamAction extends StreamAction {
 
                $this->show_last_notice($profile);
 
+               $cur = common_current_user();
+
                if ($cur && $cur->id != $profile->id) {
                        if ($cur->isSubscribed($profile)) {
                                $this->show_unsubscribe_form($profile);
@@ -92,8 +102,6 @@ class ShowstreamAction extends StreamAction {
        function show_profile($profile) {
                common_element_start('div', 'profile');
 
-               common_element('h2', 'nickname', $profile->nickname);
-
                $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
                if ($avatar) {
                        common_element('img', array('src' => $avatar->url,
@@ -103,16 +111,17 @@ class ShowstreamAction extends StreamAction {
                                                                                'alt' => $profile->nickname));
                }
                if ($profile->fullname) {
+                       common_element_start('div', 'fullname');
                        if ($profile->homepage) {
-                               common_element('a', array('href' => $profile->homepage,
-                                                                                 'class' => 'fullname'),
+                               common_element('a', array('href' => $profile->homepage),
                                                           $profile->fullname);
                        } else {
-                               common_element('span', 'fullname', $profile->fullname);
+                               common_text($profile->fullname);
                        }
+                       common_element_end('div');
                }
                if ($profile->location) {
-                       common_element('span', 'location', $profile->location);
+                       common_element('div', 'location', $profile->location);
                }
                if ($profile->bio) {
                        common_element('div', 'bio', $profile->bio);
@@ -127,7 +136,9 @@ class ShowstreamAction extends StreamAction {
                                                                          'name' => 'subscribeto',
                                                                          'type' => 'hidden',
                                                                          'value' => $profile->nickname));
-               common_element('input', array('type' => 'submit', 'value' => _t('Subscribe')));
+               common_element('input', array('type' => 'submit',
+                                                                         'class' => 'button',
+                                                                         'value' => _t('Subscribe')));
                common_element_end('form');
        }
 
@@ -138,53 +149,68 @@ class ShowstreamAction extends StreamAction {
                                                                          'name' => 'unsubscribeto',
                                                                          'type' => 'hidden',
                                                                          'value' => $profile->nickname));
-               common_element('input', array('type' => 'submit'), _t('Unsubscribe'));
+               common_element('input', array('type' => 'submit',
+                                                                         'class' => 'button',
+                                                                         'value' => _t('Unsubscribe')));
                common_element_end('form');
        }
 
        function show_subscriptions($profile) {
-
+               global $config;
+               
                # XXX: add a limit
-               $subs = $profile->getLink('id', 'subscription', 'subscriber');
+               $subs = DB_DataObject::factory('subscription');
+               $subs->subscriber = $profile->id;
+
+               # We ask for an extra one to know if we need to do another page
+
+               $subs->limit(0, SUBSCRIPTIONS);
+
+               $subs_count = $subs->find();
 
                common_element_start('div', 'subscriptions');
 
                common_element('h2', 'subscriptions', _t('Subscriptions'));
 
-               $cnt = 0;
-
-               if ($subs) {
-                       while ($subs->fetch()) {
-                               $cnt++;
-                               if ($cnt % SUBSCRIPTIONS_PER_ROW == 1) {
-                                       common_element_start('div', 'row');
-                               }
-
-                               common_element_start('a', array('title' => ($subs->fullname) ?
-                                                                                               $subs->fullname :
-                                                                                               $subs->nickname,
-                                                                                               'href' => $subs->profileurl,
-                                                                                               'class' => 'subscription'));
-                               $avatar = $subs->getAvatar(AVATAR_MINI_SIZE);
-                               common_element('img', array('src' => (($avatar) ? $avatar->url : DEFAULT_MINI_AVATAR),
-                                                                                       'width' => AVATAR_MINI_SIZE,
-                                                                                       'height' => AVATAR_MINI_SIZE,
-                                                                                       'class' => 'avatar mini',
-                                                                                       'alt' =>  ($subs->fullname) ?
-                                                                                               $subs->fullname :
-                                                                                               $subs->nickname));
-                               common_element_end('a');
-
-                               if ($cnt % SUBSCRIPTIONS_PER_ROW == 0) {
-                                       common_element_end('div');
-                               }
-
-                               if ($cnt == SUBSCRIPTIONS) {
-                                       break;
-                               }
+               $idx = 0;
+
+               while ($subs->fetch()) {
+                       $idx++;
+                       if ($idx % SUBSCRIPTIONS_PER_ROW == 1) {
+                               common_element_start('div', 'row');
+                       }
+                       
+                       $other = Profile::staticGet($subs->subscribed);
+                       
+                       common_element_start('a', array('title' => ($other->fullname) ?
+                                                                                       $other->fullname :
+                                                                                       $other->nickname,
+                                                                                       'href' => $other->profileurl,
+                                                                                       'class' => 'subscription'));
+                       $avatar = $other->getAvatar(AVATAR_MINI_SIZE);
+                       common_element('img', array('src' => (($avatar) ? $avatar->url :  common_default_avatar(AVATAR_MINI_SIZE)),
+                                                                               'width' => AVATAR_MINI_SIZE,
+                                                                               'height' => AVATAR_MINI_SIZE,
+                                                                               'class' => 'avatar mini',
+                                                                               'alt' =>  ($other->fullname) ?
+                                                                               $other->fullname :
+                                                                               $other->nickname));
+                       common_element_end('a');
+                       
+                       if ($idx % SUBSCRIPTIONS_PER_ROW == 0) {
+                               common_element_end('div');
+                       }
+                       
+                       if ($idx == SUBSCRIPTIONS) {
+                               break;
                        }
                }
 
+               # close any unclosed row
+               if ($idx % SUBSCRIPTIONS_PER_ROW != 0) {
+                       common_element_end('div');
+               }
+
                common_element('a', array('href' => common_local_url('subscriptions',
                                                                                                                         array('nickname' => $profile->nickname)),
                                                                  'class' => 'moresubscriptions'),
@@ -198,27 +224,15 @@ class ShowstreamAction extends StreamAction {
                // XXX: WORM cache this
                $subs = DB_DataObject::factory('subscription');
                $subs->subscriber = $profile->id;
-               $subs_count = $subs->count();
-
-               if (!$subs_count) {
-                       $subs_count = 0;
-               }
+               $subs_count = (int) $subs->count();
 
                $subbed = DB_DataObject::factory('subscription');
                $subbed->subscribed = $profile->id;
-               $subbed_count = $subbed->count();
-
-               if (!$subbed_count) {
-                       $subbed_count = 0;
-               }
+               $subbed_count = (int) $subbed->count();
 
                $notices = DB_DataObject::factory('notice');
                $notices->profile_id = $profile->id;
-               $notice_count = $notices->count();
-
-               if (!$notice_count) {
-                       $notice_count = 0;
-               }
+               $notice_count = (int) $notices->count();
 
                common_element_start('div', 'statistics');
                common_element('h2', 'statistics', _t('Statistics'));