]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/bookmarklistitem.php
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / plugins / Bookmark / bookmarklistitem.php
index c4dcb7798f353ec3031c57b8518f6b90b242bd60..a0d98d591a777b335b1ed0ce0f6940315fd97c56 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2011, StatusNet, Inc.
  *
  * Adapter to show bookmarks in a nicer way
- * 
+ *
  * PHP version 5
  *
  * This program is free software: you can redistribute it and/or modify
@@ -47,42 +47,56 @@ if (!defined('STATUSNET')) {
 
 class BookmarkListItem extends NoticeListItemAdapter
 {
+    function showNotice()
+    {
+        $this->nli->out->elementStart('div', 'entry-title');
+        $this->nli->showAuthor();
+        $this->showContent();
+        $this->nli->out->elementEnd('div');
+    }
+
     function showContent()
     {
         $notice = $this->nli->notice;
         $out    = $this->nli->out;
 
+        $out->elementStart('p', array('class' => 'entry-content'));
+
         $nb = Bookmark::getByNotice($notice);
 
         $profile = $notice->getProfile();
 
         $atts = $notice->attachments();
 
-        if (count($atts) < 1) {
-            // Something wrong; let default code deal with it.
-            // TRANS: Exception thrown when a bookmark has no attachments.
-            // TRANS: %1$s is a bookmark ID, %2$s is a notice ID (number).
-            throw new Exception(sprintf(_m('Bookmark %1$s (notice %2$d) has no attachments.'),
-                                        $nb->id,
-                                        $notice->id));
+        if (empty($atts)) {
+
+            // Something went wrong!
+
+            common_log(
+                LOG_ERR,
+                sprintf(
+                    _m('Bookmark %1$s (notice %2$d) has no attachments.'),
+                    $nb->id,
+                    $notice->id
+                )
+            );
+
+            // try to show the notice as plain text
+
+            parent::showContent();
+            return;
+
         }
 
         $att = $atts[0];
 
         $out->elementStart('h3');
         $out->element('a',
-                      array('href' => $att->url,
-                            'class' => 'bookmark-title entry-title'),
-                      $nb->title);
+                  array('href' => $att->url,
+                        'class' => 'bookmark-title'),
+                  $nb->title);
         $out->elementEnd('h3');
 
-        $countUrl = common_local_url('noticebyurl',
-                                     array('id' => $att->id));
-
-        $out->element('a', array('class' => 'bookmark-notice-count',
-                                 'href' => $countUrl),
-                      $att->noticeCount());
-
         // Replies look like "for:" tags
 
         $replies = $notice->getReplies();
@@ -106,13 +120,16 @@ class BookmarkListItem extends NoticeListItemAdapter
             }
 
             foreach ($tags as $tag) {
-                $out->elementStart('li');
-                $out->element('a',
-                              array('rel' => 'tag',
-                                    'href' => Notice_tag::url($tag)),
-                              $tag);
-                $out->elementEnd('li');
-                $out->text(' ');
+                $tag = trim($tag);
+                if (!empty($tag)) {
+                    $out->elementStart('li');
+                    $out->element('a',
+                                  array('rel' => 'tag',
+                                        'href' => Notice_tag::url($tag)),
+                                  $tag);
+                    $out->elementEnd('li');
+                    $out->text(' ');
+                }
             }
 
             $out->elementEnd('ul');
@@ -123,5 +140,7 @@ class BookmarkListItem extends NoticeListItemAdapter
                           array('class' => 'bookmark-description'),
                           $nb->description);
         }
+
+        $out->elementEnd('p');
     }
 }