]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/noticelist.php
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
[quix0rs-gnu-social.git] / lib / noticelist.php
index a106478eddf120a286e95891195175bbab1b8f24..c05b990245f01acdce345b4866d94212367b9c46 100644 (file)
@@ -191,6 +191,14 @@ class NoticeListItem extends Widget
 
     function show()
     {
+        if (empty($this->notice)) {
+            common_log(LOG_WARNING, "Trying to show missing notice; skipping.");
+            return;
+        } else if (empty($this->profile)) {
+            common_log(LOG_WARNING, "Trying to show missing profile (" . $this->notice->profile_id . "); skipping.");
+            return;
+        }
+
         $this->showStart();
         if (Event::handle('StartShowNoticeItem', array($this))) {
             $this->showNotice();
@@ -243,8 +251,9 @@ class NoticeListItem extends Widget
     {
         // XXX: RDFa
         // TODO: add notice_type class e.g., notice_video, notice_image
+        $id = (empty($this->repeat)) ? $this->notice->id : $this->repeat->id;
         $this->out->elementStart('li', array('class' => 'hentry notice',
-                                             'id' => 'notice-' . $this->notice->id));
+                                             'id' => 'notice-' . $id));
     }
 
     /**
@@ -285,6 +294,7 @@ class NoticeListItem extends Widget
         }
         $this->out->elementStart('a', $attrs);
         $this->showAvatar();
+        $this->out->text(' ');
         $this->showNickname();
         $this->out->elementEnd('a');
         $this->out->elementEnd('span');
@@ -370,7 +380,7 @@ class NoticeListItem extends Widget
 
     function showNoticeLink()
     {
-        if($this->notice->is_local){
+        if($this->notice->is_local == Notice::LOCAL_PUBLIC || $this->notice->is_local == Notice::LOCAL_NONPUBLIC){
             $noticeurl = common_local_url('shownotice',
                                       array('notice' => $this->notice->id));
         }else{
@@ -423,8 +433,10 @@ class NoticeListItem extends Widget
 
         $url  = $location->getUrl();
 
+        $this->out->text(' ');
         $this->out->elementStart('span', array('class' => 'location'));
         $this->out->text(_('at'));
+        $this->out->text(' ');
         if (empty($url)) {
             $this->out->element('span', array('class' => 'geo',
                                               'title' => $latlon),
@@ -464,9 +476,11 @@ class NoticeListItem extends Widget
     function showNoticeSource()
     {
         if ($this->notice->source) {
+            $this->out->text(' ');
             $this->out->elementStart('span', 'source');
             $this->out->text(_('from'));
             $source_name = _($this->notice->source);
+            $this->out->text(' ');
             switch ($this->notice->source) {
              case 'web':
              case 'xmpp':
@@ -477,12 +491,28 @@ class NoticeListItem extends Widget
                 $this->out->element('span', 'device', $source_name);
                 break;
              default:
+
+                $name = null;
+                $url  = null;
+
                 $ns = Notice_source::staticGet($this->notice->source);
+
                 if ($ns) {
+                    $name = $ns->name;
+                    $url  = $ns->url;
+                } else {
+                    $app = Oauth_application::staticGet('name', $this->notice->source);
+                    if ($app) {
+                        $name = $app->name;
+                        $url  = $app->source_url;
+                    }
+                }
+
+                if (!empty($name) && !empty($url)) {
                     $this->out->elementStart('span', 'device');
-                    $this->out->element('a', array('href' => $ns->url,
+                    $this->out->element('a', array('href' => $url,
                                                    'rel' => 'external'),
-                                        $ns->name);
+                                        $name);
                     $this->out->elementEnd('span');
                 } else {
                     $this->out->element('span', 'device', $source_name);
@@ -515,6 +545,7 @@ class NoticeListItem extends Widget
             }
         }
         if ($hasConversation){
+            $this->out->text(' ');
             $convurl = common_local_url('conversation',
                                          array('id' => $this->notice->conversation));
             $this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id,
@@ -535,7 +566,7 @@ class NoticeListItem extends Widget
 
             $repeater = Profile::staticGet('id', $this->repeat->profile_id);
 
-            $attrs = array('href' => $this->profile->profileurl,
+            $attrs = array('href' => $repeater->profileurl,
                            'class' => 'url');
 
             if (!empty($repeater->fullname)) {
@@ -544,24 +575,10 @@ class NoticeListItem extends Widget
 
             $this->out->elementStart('span', 'repeat vcard');
 
-            $this->out->elementStart('a', $attrs);
-
             $this->out->raw(_('Repeated by'));
 
-            $avatar = $repeater->getAvatar(AVATAR_MINI_SIZE);
-
-            $this->out->element('img', array('src' => ($avatar) ?
-                                             $avatar->displayUrl() :
-                                             Avatar::defaultImage(AVATAR_MINI_SIZE),
-                                             'class' => 'avatar photo',
-                                             'width' => AVATAR_MINI_SIZE,
-                                             'height' => AVATAR_MINI_SIZE,
-                                             'alt' =>
-                                             ($repeater->fullname) ?
-                                             $repeater->fullname :
-                                             $repeater->nickname));
-
-            $this->out->element('span', 'nickname', $repeater->nickname);
+            $this->out->elementStart('a', $attrs);
+            $this->out->element('span', 'fn nickname', $repeater->nickname);
             $this->out->elementEnd('a');
 
             $this->out->elementEnd('span');
@@ -580,12 +597,14 @@ class NoticeListItem extends Widget
     function showReplyLink()
     {
         if (common_logged_in()) {
+            $this->out->text(' ');
             $reply_url = common_local_url('newnotice',
                                           array('replyto' => $this->profile->nickname, 'inreplyto' => $this->notice->id));
             $this->out->elementStart('a', array('href' => $reply_url,
                                                 'class' => 'notice_reply',
                                                 'title' => _('Reply to this notice')));
             $this->out->text(_('Reply'));
+            $this->out->text(' ');
             $this->out->element('span', 'notice_id', $this->notice->id);
             $this->out->elementEnd('a');
         }
@@ -601,11 +620,13 @@ class NoticeListItem extends Widget
     {
         $user = common_current_user();
 
-        if (!empty($user) &&
-            ($this->notice->profile_id == $user->id || $user->hasRight(Right::DELETEOTHERSNOTICE))) {
+        $todel = (empty($this->repeat)) ? $this->notice : $this->repeat;
 
+        if (!empty($user) &&
+            ($todel->profile_id == $user->id || $user->hasRight(Right::DELETEOTHERSNOTICE))) {
+            $this->out->text(' ');
             $deleteurl = common_local_url('deletenotice',
-                                          array('notice' => $this->notice->id));
+                                          array('notice' => $todel->id));
             $this->out->element('a', array('href' => $deleteurl,
                                            'class' => 'notice_delete',
                                            'title' => _('Delete this notice')), _('Delete'));
@@ -622,9 +643,12 @@ class NoticeListItem extends Widget
     {
         $user = common_current_user();
         if ($user && $user->id != $this->notice->profile_id) {
+            $this->out->text(' ');
             $profile = $user->getProfile();
             if ($profile->hasRepeated($this->notice->id)) {
-                $this->out->text(_('Repeated'));
+                $this->out->element('span', array('class' => 'repeated',
+                                                  'title' => _('Notice repeated')),
+                                            _('Repeated'));
             } else {
                 $rf = new RepeatForm($this->out, $this->notice);
                 $rf->show();