本文整理汇总了PHP中Bookmark::getByNotice方法的典型用法代码示例。如果您正苦于以下问题:PHP Bookmark::getByNotice方法的具体用法?PHP Bookmark::getByNotice怎么用?PHP Bookmark::getByNotice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bookmark
的用法示例。
在下文中一共展示了Bookmark::getByNotice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showContent
function showContent()
{
$notice = $this->nli->notice;
$out = $this->nli->out;
$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();
$out->elementStart('p', array('class' => 'entry-content'));
// 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 = $notice->getReplies();
$tags = $notice->getTags();
if (!empty($replies) || !empty($tags)) {
$out->elementStart('ul', array('class' => 'bookmark-tags'));
foreach ($replies as $reply) {
$other = Profile::staticGet('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);
}
$out->elementEnd('p');
}
示例2: showContent
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));
}
$att = $atts[0];
$out->elementStart('h3');
$out->element('a', array('href' => $att->url, 'class' => 'bookmark-title'), $nb->title);
$out->elementEnd('h3');
// Replies look like "for:" tags
$replies = $notice->getReplies();
$tags = $notice->getTags();
if (!empty($replies) || !empty($tags)) {
$out->elementStart('ul', array('class' => 'bookmark-tags'));
foreach ($replies as $reply) {
$other = Profile::staticGet('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);
}
$out->elementEnd('p');
}
示例3: activityObjectFromNotice
function activityObjectFromNotice($notice)
{
assert($this->isMyNotice($notice));
common_log(LOG_INFO, "Formatting notice {$notice->uri} as a bookmark.");
$object = new ActivityObject();
$nb = Bookmark::getByNotice($notice);
$object->id = $notice->uri;
$object->type = ActivityObject::BOOKMARK;
$object->title = $nb->title;
$object->summary = $nb->description;
$object->link = $notice->bestUrl();
// Attributes of the URL
$attachments = $notice->attachments();
if (count($attachments) != 1) {
// TRANS: Server exception thrown when a bookmark has multiple attachments.
throw new ServerException(_m('Bookmark notice with the ' . 'wrong number of attachments.'));
}
$target = $attachments[0];
$attrs = array('rel' => 'related', 'href' => $target->url);
if (!empty($target->title)) {
$attrs['title'] = $target->title;
}
$object->extra[] = array('link', $attrs, null);
// Attributes of the thumbnail, if any
$thumbnail = $target->getThumbnail();
if (!empty($thumbnail)) {
$tattrs = array('rel' => 'preview', 'href' => $thumbnail->url);
if (!empty($thumbnail->width)) {
$tattrs['media:width'] = $thumbnail->width;
}
if (!empty($thumbnail->height)) {
$tattrs['media:height'] = $thumbnail->height;
}
$object->extra[] = array('link', $attrs, null);
}
return $object;
}
示例4: onStartOpenNoticeListItemElement
/**
* Output our CSS class for bookmark notice list elements
*
* @param NoticeListItem $nli The item being shown
*
* @return boolean hook value
*/
function onStartOpenNoticeListItemElement($nli)
{
$nb = Bookmark::getByNotice($nli->notice);
if (!empty($nb)) {
$id = empty($nli->repeat) ? $nli->notice->id : $nli->repeat->id;
$nli->out->elementStart('li', array('class' => 'hentry notice bookmark', 'id' => 'notice-' . $id));
Event::handle('EndOpenNoticeListItemElement', array($nli));
return false;
}
return true;
}