]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/BookmarkPlugin.php
ensureActivityObjectProfile is more thorough than createAct...
[quix0rs-gnu-social.git] / plugins / Bookmark / BookmarkPlugin.php
index fdd3c359b866fa7d3a8289680af26e470788590a..9ea83c4caf1f2263f43ff3952b5e550093b585fc 100644 (file)
@@ -109,11 +109,11 @@ class BookmarkPlugin extends MicroAppPlugin
     /**
      * Map URLs to actions
      *
-     * @param Net_URL_Mapper $m path-to-action mapper
+     * @param URLMapper $m path-to-action mapper
      *
      * @return boolean hook value; true means continue processing, false means stop.
      */
-    function onRouterInitialized($m)
+    public function onRouterInitialized(URLMapper $m)
     {
         if (common_config('singleuser', 'enabled')) {
             $nickname = User::singleUserNickname();
@@ -440,19 +440,6 @@ class BookmarkPlugin extends MicroAppPlugin
         return $object;
     }
 
-    /**
-     * Given a notice list item, returns an adapter specific
-     * to this plugin.
-     *
-     * @param NoticeListItem $nli item to adapt
-     *
-     * @return NoticeListItemAdapter adapter or null
-     */
-    function adaptNoticeListItem($nli)
-    {
-        return new BookmarkListItem($nli);
-    }
-
     function entryForm($out)
     {
         return new InitialBookmarkForm($out);
@@ -505,4 +492,87 @@ class BookmarkPlugin extends MicroAppPlugin
 
         return true;
     }
+
+    protected function showNoticeItemNotice(NoticeListItem $nli)
+    {
+        $nli->out->elementStart('div', 'entry-title');
+        $nli->showAuthor();
+        $nli->showContent();
+        $nli->out->elementEnd('div');
+    }
+
+    protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped=null)
+    {
+        $nb = Bookmark::getByNotice($stored);
+
+        if (empty($nb)) {
+            common_log(LOG_ERR, "No bookmark for notice {$stored->id}");
+            parent::showContent();
+            return;
+        } else if (empty($nb->url)) {
+            common_log(LOG_ERR, "No url for bookmark {$nb->id} for notice {$stored->id}");
+            parent::showContent();
+            return;
+        }
+
+        $profile = $stored->getProfile();
+
+        // Whether to nofollow
+        $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', $attrs, $nb->title);
+        $out->elementEnd('h3');
+
+        // Replies look like "for:" tags
+        $replies = $stored->getReplies();
+        $tags = $stored->getTags();
+
+        if (!empty($replies) || !empty($tags)) {
+
+            $out->elementStart('ul', array('class' => 'bookmark-tags'));
+
+            foreach ($replies as $reply) {
+                $other = Profile::getKV('id', $reply);
+                if (!empty($other)) {
+                    $out->elementStart('li');
+                    $out->element('a', array('rel' => 'tag',
+                                             'href' => $other->profileurl,
+                                             'title' => $other->getBestName()),
+                                  sprintf('for:%s', $other->nickname));
+                    $out->elementEnd('li');
+                    $out->text(' ');
+                }
+            }
+
+            foreach ($tags as $tag) {
+                $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');
+        }
+
+        if (!empty($nb->description)) {
+            $out->element('p',
+                          array('class' => 'bookmark-description'),
+                          $nb->description);
+        }
+    }
 }