X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FBookmark%2FBookmarkPlugin.php;h=9ea83c4caf1f2263f43ff3952b5e550093b585fc;hb=66044b7782d622ab6befc5590915032731883ba9;hp=fdd3c359b866fa7d3a8289680af26e470788590a;hpb=ffb9d7ad3fb9ad5d9ed0ada9fb9b88fa7ae8e146;p=quix0rs-gnu-social.git diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index fdd3c359b8..9ea83c4caf 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -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); + } + } }