]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/showstream.php
correct order of params in get_token
[quix0rs-gnu-social.git] / actions / showstream.php
index 7ac036de6303cde666e752a821fcbf4193f8fb92..86c3c76a430ea858e57045df0f529648c9fb9f9c 100644 (file)
@@ -21,7 +21,7 @@ if (!defined('LACONICA')) { exit(1); }
 
 require_once(INSTALLDIR.'/lib/stream.php');
 
-define('SUBSCRIPTIONS_PER_ROW', 5);
+define('SUBSCRIPTIONS_PER_ROW', 4);
 define('SUBSCRIPTIONS', 80);
 
 class ShowstreamAction extends StreamAction {
@@ -45,7 +45,12 @@ class ShowstreamAction extends StreamAction {
                        return;
                }
 
-               # Looks like we're good; show the header
+               # Looks like we're good; start output
+               
+               # For YADIS discovery, we also have a <meta> tag
+
+               header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' =>
+                                                                                                                                  $user->nickname)));
 
                common_show_header($profile->nickname, array($this, 'show_header'), $user);
 
@@ -88,12 +93,16 @@ class ShowstreamAction extends StreamAction {
 
                $cur = common_current_user();
 
-               if ($cur && $cur->id != $profile->id) {
-                       if ($cur->isSubscribed($profile)) {
-                               $this->show_unsubscribe_form($profile);
-                       } else {
-                               $this->show_subscribe_form($profile);
+               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);
                }
 
                $this->show_statistics($profile);
@@ -146,6 +155,15 @@ class ShowstreamAction extends StreamAction {
                common_element_end('form');
        }
 
+       function show_remote_subscribe_form($profile) {
+               common_element_start('form', array('id' => 'remotesubscribe', 'method' => 'POST',
+                                                                                  'action' => common_local_url('remotesubscribe')));
+               common_hidden('nickname', $profile->nickname);
+               common_input('profile', _t('Profile'));
+               common_submit('submit',_t('Subscribe'));
+               common_element_end('form');
+       }
+       
        function show_unsubscribe_form($profile) {
                common_element_start('form', array('id' => 'unsubscribe', 'method' => 'POST',
                                                                                   'action' => common_local_url('unsubscribe')));
@@ -261,21 +279,42 @@ class ShowstreamAction extends StreamAction {
 
                $notice->orderBy('created DESC');
 
-               $page = $this->arg('page') || 1;
+               $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
 
-               $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE);
+               $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
 
-               $notice->find();
+               $cnt = $notice->find();
 
                common_element_start('div', 'notices width66 floatLeft');
 
-               common_element_start('ul', 'bigLinks');
-               
-               while ($notice->fetch()) {
-                       $this->show_notice($notice);
+               for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
+                       if ($notice->fetch()) {
+                               $this->show_notice($notice);
+                       } else {
+                               // shouldn't happen!
+                               break;
+                       }
+               }
+
+               if ($page > 1) {
+                       common_element_start('span', 'floatLeft width25');
+                       common_element('a', array('href' => common_local_url('showstream', 
+                                                                                                                                array('nickname' => $profile->nickname,
+                                                                                                                                          'page' => $page-1)),
+                                                                         'class' => 'newer'),
+                                                  _t('Newer'));
+                       common_element_end('span');
                }
                
-               common_element_end('ul');
+               if ($cnt > NOTICES_PER_PAGE) {
+                       common_element_start('span', 'floatRight width25');
+                       common_element('a', array('href' => common_local_url('showstream', 
+                                                                                                                                array('nickname' => $profile->nickname,
+                                                                                                                                          'page' => $page+1)),
+                                                                         'class' => 'older'),
+                                                  _t('Older'));
+                       common_element_end('span');
+               }
                
                # XXX: show a link for the next page
                common_element_end('div');
@@ -293,8 +332,9 @@ class ShowstreamAction extends StreamAction {
 
                if ($notice->find(true)) {
                        # FIXME: URL, image, video, audio
-                       common_element('span', array('class' => 'content'),
-                                                  $notice->content);
+                       common_element_start('span', array('class' => 'content'));
+                       common_raw(common_render_content($notice->content, $notice));
+                       common_element_end('span');
                }
 
                common_element_end('div');
@@ -303,15 +343,16 @@ class ShowstreamAction extends StreamAction {
        function show_notice($notice) {
                $profile = $notice->getProfile();
                # XXX: RDFa
-               common_element_start('li', array('class' => 'notice',
-                                                                                'id' => 'notice-' . $notice->id));
+               common_element_start('div', array('class' => 'notice',
+                                                                                 'id' => 'notice-' . $notice->id));
                $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
                # FIXME: URL, image, video, audio
-               common_element_start('a', array('class' => 'notice',
-                                                                 'href' => $noticeurl));
-               common_element('span', 'title', common_date_string($notice->created));
-               common_element('span', 'desc', $notice->content);
-               common_element_end('a');
-               common_element_end('li');
+               common_element_start('span', array('class' => 'content'));
+               common_raw(common_render_content($notice->content, $notice));
+               common_element_end('span');
+               common_element('a', array('class' => 'notice',
+                                                                 'href' => $noticeurl),
+                                          common_date_string($notice->created));
+               common_element_end('div');
        }
 }