]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/bookmarklistitem.php
non-existent poco
[quix0rs-gnu-social.git] / plugins / Bookmark / bookmarklistitem.php
index 65ebe5036774160ba5717cf31fbf378257cead95..a2dbf8156dafdef83afef57295e23f18edd4e84e 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
@@ -60,29 +60,38 @@ class BookmarkListItem extends NoticeListItemAdapter
         $notice = $this->nli->notice;
         $out    = $this->nli->out;
 
-        $out->elementStart('p', array('class' => 'entry-content'));
-
         $nb = Bookmark::getByNotice($notice);
 
+        if (empty($nb)) {
+            common_log(LOG_ERR, "No bookmark for notice {$notice->id}");
+            parent::showContent();
+            return;
+        } else if (empty($nb->url)) {
+            common_log(LOG_ERR, "No url for bookmark {$nb->id} for notice {$notice->id}");
+            parent::showContent();
+            return;
+        }
+
         $profile = $notice->getProfile();
 
-        $atts = $notice->attachments();
+        $out->elementStart('p', array('class' => 'entry-content'));
 
-        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));
-        }
+        // Whether to nofollow
 
-        $att = $atts[0];
+        $attrs = array('href' => $nb->url,
+                       'class' => 'bookmark-title');
+
+        $nf = common_config('nofollow', 'external');
+
+        if ($nf == 'never' || ($nf == 'sometimes' and $out instanceof ShowstreamAction)) {
+            $attrs['rel'] = 'external';
+        } else {
+            $attrs['rel'] = 'nofollow external';
+        }
 
         $out->elementStart('h3');
         $out->element('a',
-                      array('href' => $att->url,
-                            'class' => 'bookmark-title'),
+                      $attrs,
                       $nb->title);
         $out->elementEnd('h3');
 
@@ -109,13 +118,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');