当前位置: 首页>>代码示例>>PHP>>正文


PHP Bookmark::getByNotice方法代码示例

本文整理汇总了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');
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:59,代码来源:bookmarklistitem.php

示例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');
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:48,代码来源:bookmarklistitem.php

示例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;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:37,代码来源:BookmarkPlugin.php

示例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;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:18,代码来源:BookmarkPlugin.php


注:本文中的Bookmark::getByNotice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。