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


PHP Notice::pkeyGet方法代码示例

本文整理汇总了PHP中Notice::pkeyGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::pkeyGet方法的具体用法?PHP Notice::pkeyGet怎么用?PHP Notice::pkeyGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Notice的用法示例。


在下文中一共展示了Notice::pkeyGet方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onNoticeSimpleStatusArray

 /**
  * Add stuff to notices in API responses
  *
  * @param Action $action action being executed
  *
  * @return boolean hook return
  */
 function onNoticeSimpleStatusArray($notice, &$twitter_status, $scoped)
 {
     // groups
     $notice_groups = $notice->getGroups();
     $group_addressees = false;
     foreach ($notice_groups as $g) {
         $group_addressees[] = array('nickname' => $g->nickname, 'url' => $g->mainpage);
     }
     $twitter_status['statusnet_in_groups'] = $group_addressees;
     // for older verions of gnu social: include the repeat-id, which we need when unrepeating later
     if (array_key_exists('repeated', $twitter_status) && $twitter_status['repeated'] === true) {
         $repeated = Notice::pkeyGet(array('profile_id' => $scoped->id, 'repeat_of' => $notice->id, 'verb' => 'http://activitystrea.ms/schema/1.0/share'));
         $twitter_status['repeated_id'] = $repeated->id;
     }
     // more metadata about attachments
     // get all attachments first, and put all the extra meta data in an array
     $attachments = $notice->attachments();
     $attachment_url_to_id = array();
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             if (is_object($attachment)) {
                 try {
                     $enclosure_o = $attachment->getEnclosure();
                     // add id to all attachments
                     $attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
                     // add data about thumbnails
                     $thumb = $attachment->getThumbnail();
                     $large_thumb = $attachment->getThumbnail(1000, 3000, false);
                     if (method_exists('File_thumbnail', 'url')) {
                         $thumb_url = File_thumbnail::url($thumb->filename);
                         $large_thumb_url = File_thumbnail::url($large_thumb->filename);
                     } else {
                         $thumb_url = $thumb->getUrl();
                         $large_thumb_url = $large_thumb->getUrl();
                     }
                     $attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb_url;
                     $attachment_url_to_id[$enclosure_o->url]['large_thumb_url'] = $large_thumb_url;
                     $attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
                     $attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
                     // animated gif?
                     if ($attachment->mimetype == 'image/gif') {
                         $image = ImageFile::fromFileObject($attachment);
                         if ($image->animated == 1) {
                             $attachment_url_to_id[$enclosure_o->url]['animated'] = true;
                         } else {
                             $attachment_url_to_id[$enclosure_o->url]['animated'] = false;
                         }
                     }
                     // this applies to older versions of gnu social, i think
                 } catch (ServerException $e) {
                     $thumb = File_thumbnail::getKV('file_id', $attachment->id);
                     if ($thumb instanceof File_thumbnail) {
                         $thumb_url = $thumb->getUrl();
                         $attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
                         $attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb_url;
                         $attachment_url_to_id[$enclosure_o->url]['large_thumb_url'] = $thumb_url;
                         $attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
                         $attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
                         // animated gif?
                         if ($attachment->mimetype == 'image/gif') {
                             $image = ImageFile::fromFileObject($attachment);
                             if ($image->animated == 1) {
                                 $attachment_url_to_id[$enclosure_o->url]['animated'] = true;
                             } else {
                                 $attachment_url_to_id[$enclosure_o->url]['animated'] = false;
                             }
                         }
                     }
                 }
             }
         }
     }
     // add the extra meta data to $twitter_status
     if (!empty($twitter_status['attachments'])) {
         foreach ($twitter_status['attachments'] as &$attachment) {
             if (!empty($attachment_url_to_id[$attachment['url']])) {
                 $attachment = array_merge($attachment, $attachment_url_to_id[$attachment['url']]);
             }
         }
     }
     // quoted notices
     if (!empty($twitter_status['attachments'])) {
         foreach ($twitter_status['attachments'] as &$attachment) {
             $quoted_notice = false;
             // if this attachment has an url this might be a notice url
             if (isset($attachment['url'])) {
                 $noticeurl = common_path('notice/', StatusNet::isHTTPS());
                 $instanceurl = common_path('', StatusNet::isHTTPS());
                 // remove protocol for the comparison below
                 $noticeurl_wo_protocol = preg_replace('(^https?://)', '', $noticeurl);
                 $instanceurl_wo_protocol = preg_replace('(^https?://)', '', $instanceurl);
                 $attachment_url_wo_protocol = preg_replace('(^https?://)', '', $attachment['url']);
                 // local notice urls
//.........这里部分代码省略.........
开发者ID:Umeaboy,项目名称:qvitter,代码行数:101,代码来源:QvitterPlugin.php

示例2: onNoticeSimpleStatusArray

 /**
  * Add stuff to notices in API responses
  *
  * @param Action $action action being executed
  *
  * @return boolean hook return
  */
 function onNoticeSimpleStatusArray($notice, &$twitter_status, $scoped)
 {
     // groups
     $notice_groups = $notice->getGroups();
     $group_addressees = false;
     foreach ($notice_groups as $g) {
         $group_addressees[] = array('nickname' => $g->nickname, 'url' => $g->mainpage);
     }
     $twitter_status['statusnet_in_groups'] = $group_addressees;
     // for older verions of gnu social: include the repeat-id, which we need when unrepeating later
     if (array_key_exists('repeated', $twitter_status) && $twitter_status['repeated'] === true) {
         $repeated = Notice::pkeyGet(array('profile_id' => $scoped->id, 'repeat_of' => $notice->id, 'verb' => 'http://activitystrea.ms/schema/1.0/share'));
         $twitter_status['repeated_id'] = $repeated->id;
     }
     // more metadata about attachments
     // get all attachments first, and put all the extra meta data in an array
     $attachments = $notice->attachments();
     $attachment_url_to_id = array();
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             if (is_object($attachment)) {
                 try {
                     $enclosure_o = $attachment->getEnclosure();
                     // add id to all attachments
                     $attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
                     // add data about thumbnails
                     $thumb = $attachment->getThumbnail();
                     $large_thumb = $attachment->getThumbnail(1000, 3000, false);
                     if (method_exists('File_thumbnail', 'url')) {
                         $thumb_url = File_thumbnail::url($thumb->filename);
                         $large_thumb_url = File_thumbnail::url($large_thumb->filename);
                     } else {
                         $thumb_url = $thumb->getUrl();
                         $large_thumb_url = $large_thumb->getUrl();
                     }
                     $attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb_url;
                     $attachment_url_to_id[$enclosure_o->url]['large_thumb_url'] = $large_thumb_url;
                     $attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
                     $attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
                     // animated gif?
                     if ($attachment->mimetype == 'image/gif') {
                         $image = ImageFile::fromFileObject($attachment);
                         if ($image->animated == 1) {
                             $attachment_url_to_id[$enclosure_o->url]['animated'] = true;
                         } else {
                             $attachment_url_to_id[$enclosure_o->url]['animated'] = false;
                         }
                     }
                     // this applies to older versions of gnu social, i think
                 } catch (ServerException $e) {
                     $thumb = File_thumbnail::getKV('file_id', $attachment->id);
                     if ($thumb instanceof File_thumbnail) {
                         $thumb_url = $thumb->getUrl();
                         $attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
                         $attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb_url;
                         $attachment_url_to_id[$enclosure_o->url]['large_thumb_url'] = $thumb_url;
                         $attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
                         $attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
                         // animated gif?
                         if ($attachment->mimetype == 'image/gif') {
                             $image = ImageFile::fromFileObject($attachment);
                             if ($image->animated == 1) {
                                 $attachment_url_to_id[$enclosure_o->url]['animated'] = true;
                             } else {
                                 $attachment_url_to_id[$enclosure_o->url]['animated'] = false;
                             }
                         }
                     }
                 }
             }
         }
     }
     // add the extra meta data to $twitter_status
     if (!empty($twitter_status['attachments'])) {
         foreach ($twitter_status['attachments'] as &$attachment) {
             if (!empty($attachment_url_to_id[$attachment['url']])) {
                 $attachment = array_merge($attachment, $attachment_url_to_id[$attachment['url']]);
             }
         }
     }
     // reply-to profile url
     try {
         $reply = $notice->getParent();
         $twitter_status['in_reply_to_profileurl'] = $reply->getProfile()->getUrl();
     } catch (ServerException $e) {
         $twitter_status['in_reply_to_profileurl'] = null;
     }
     // fave number
     $faves = Fave::byNotice($notice);
     $favenum = count($faves);
     $twitter_status['fave_num'] = $favenum;
     // repeat number
     $repeats = $notice->repeatStream();
//.........这里部分代码省略.........
开发者ID:GreenLunar,项目名称:qvitter,代码行数:101,代码来源:QvitterPlugin.php

示例3: onNoticeSimpleStatusArray

 /**
  * Add stuff to notices in API responses
  *
  * @param Action $action action being executed
  *
  * @return boolean hook return
  */
 function onNoticeSimpleStatusArray($notice, &$twitter_status, $scoped)
 {
     // groups
     $notice_groups = $notice->getGroups();
     $group_addressees = false;
     foreach ($notice_groups as $g) {
         $group_addressees[] = array('nickname' => $g->nickname, 'url' => $g->mainpage);
     }
     $twitter_status['statusnet_in_groups'] = $group_addressees;
     // for older verions of gnu social: include the repeat-id, which we need when unrepeating later
     if (array_key_exists('repeated', $twitter_status) && $twitter_status['repeated'] === true) {
         $repeated = Notice::pkeyGet(array('profile_id' => $scoped->id, 'repeat_of' => $notice->id, 'verb' => 'http://activitystrea.ms/schema/1.0/share'));
         $twitter_status['repeated_id'] = $repeated->id;
     }
     // more metadata about attachments
     // get all attachments first, and put all the extra meta data in an array
     $attachments = $notice->attachments();
     $attachment_url_to_id = array();
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             if (is_object($attachment)) {
                 try {
                     $enclosure_o = $attachment->getEnclosure();
                     // Oembed
                     if (array_key_exists('Oembed', StatusNet::getActivePlugins())) {
                         $oembed = File_oembed::getKV('file_id', $attachment->id);
                         if ($oembed instanceof File_oembed) {
                             $oembed_html = str_replace('<!--//-->', '', $oembed->html);
                             // trash left of wordpress' javascript after htmLawed removed the tags
                             if ($oembed->provider == 'Twitter' && strstr($oembed_html, '>— ' . $oembed->author_name)) {
                                 $oembed_html = substr($oembed_html, 0, strpos($oembed_html, '>— ' . $oembed->author_name) + 1);
                                 // remove user data from twitter oembed html (we have it in )
                                 $twitter_username = substr($oembed->html, strpos($oembed->html, '>— ' . $oembed->author_name) + strlen('>— ' . $oembed->author_name));
                                 $twitter_username = substr($twitter_username, strpos($twitter_username, '(@') + 1);
                                 $twitter_username = substr($twitter_username, 0, strpos($twitter_username, ')'));
                                 $oembed->title = $twitter_username;
                             }
                             $oembed_html = str_replace('…', '...', $oembed_html);
                             // ellipsis is sometimes stored as html in db, for some reason
                             $oembed_html = mb_substr(trim(strip_tags(html_entity_decode($oembed_html, ENT_QUOTES))), 0, 250);
                             // sometimes we have html charachters that we want to decode and then strip
                             $oembed_title = trim(strip_tags(html_entity_decode($oembed->title, ENT_QUOTES)));
                             $oembed_provider = trim(strip_tags(html_entity_decode($oembed->provider, ENT_QUOTES)));
                             $oembed_author_name = trim(strip_tags(html_entity_decode($oembed->author_name, ENT_QUOTES)));
                             $attachment_url_to_id[$enclosure_o->url]['oembed'] = array('type' => $oembed->type, 'provider' => $oembed_provider, 'provider_url' => $oembed->provider_url, 'oembedHTML' => $oembed_html, 'title' => $oembed_title, 'author_name' => $oembed_author_name, 'author_url' => $oembed->author_url);
                         } else {
                             $attachment_url_to_id[$enclosure_o->url]['oembed'] = false;
                         }
                     }
                     // add id to all attachments
                     $attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
                     // add an attachment version to all attachments
                     // this means we can force all cached attachments to update, if we change this
                     $attachment_url_to_id[$enclosure_o->url]['version'] = '1.2';
                     // add data about thumbnails
                     $thumb = $attachment->getThumbnail();
                     $large_thumb = $attachment->getThumbnail(1000, 3000, false);
                     if (method_exists('File_thumbnail', 'url')) {
                         $thumb_url = File_thumbnail::url($thumb->filename);
                         $large_thumb_url = File_thumbnail::url($large_thumb->filename);
                     } else {
                         $thumb_url = $thumb->getUrl();
                         $large_thumb_url = $large_thumb->getUrl();
                     }
                     $attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb_url;
                     $attachment_url_to_id[$enclosure_o->url]['large_thumb_url'] = $large_thumb_url;
                     $attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
                     $attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
                     // animated gif?
                     if ($attachment->mimetype == 'image/gif') {
                         $image = ImageFile::fromFileObject($attachment);
                         if ($image->animated == 1) {
                             $attachment_url_to_id[$enclosure_o->url]['animated'] = true;
                         } else {
                             $attachment_url_to_id[$enclosure_o->url]['animated'] = false;
                         }
                     }
                     // this applies to older versions of gnu social, i think
                 } catch (Exception $e) {
                     $thumb = File_thumbnail::getKV('file_id', $attachment->id);
                     if ($thumb instanceof File_thumbnail) {
                         $thumb_url = $thumb->getUrl();
                         $attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
                         $attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb_url;
                         $attachment_url_to_id[$enclosure_o->url]['large_thumb_url'] = $thumb_url;
                         $attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
                         $attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
                         // animated gif?
                         if ($attachment->mimetype == 'image/gif') {
                             $image = ImageFile::fromFileObject($attachment);
                             if ($image->animated == 1) {
                                 $attachment_url_to_id[$enclosure_o->url]['animated'] = true;
                             } else {
//.........这里部分代码省略.........
开发者ID:bashrc,项目名称:gnusocial-qvitter-debian,代码行数:101,代码来源:QvitterPlugin.php

示例4: onNoticeSimpleStatusArray

 /**
  * Add stuff to notices in API responses
  *
  * @param Action $action action being executed
  *
  * @return boolean hook return
  */
 function onNoticeSimpleStatusArray($notice, &$twitter_status, $scoped)
 {
     // groups
     $notice_groups = $notice->getGroups();
     $group_addressees = false;
     foreach ($notice_groups as $g) {
         $group_addressees = array('nickname' => $g->nickname, 'url' => $g->mainpage);
     }
     $twitter_status['statusnet_in_groups'] = $group_addressees;
     // include the repeat-id, which we need when unrepeating later
     if (array_key_exists('repeated', $twitter_status) && $twitter_status['repeated'] === true) {
         $repeated = Notice::pkeyGet(array('profile_id' => $scoped->id, 'repeat_of' => $notice->id));
         $twitter_status['repeated_id'] = $repeated->id;
     }
     // thumb urls
     // find all thumbs
     $attachments = $notice->attachments();
     $attachment_url_to_id = array();
     if (!empty($attachments)) {
         foreach ($attachments as $attachment) {
             if (is_object($attachment)) {
                 try {
                     $enclosure_o = $attachment->getEnclosure();
                     $thumb = $attachment->getThumbnail();
                     $attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
                     $attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb->getUrl();
                     $attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
                     $attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
                     // animated gif?
                     if ($attachment->mimetype == 'image/gif') {
                         $image = ImageFile::fromFileObject($attachment);
                         if ($image->animated == 1) {
                             $attachment_url_to_id[$enclosure_o->url]['animated'] = true;
                         } else {
                             $attachment_url_to_id[$enclosure_o->url]['animated'] = false;
                         }
                     }
                 } catch (ServerException $e) {
                     $thumb = File_thumbnail::getKV('file_id', $attachment->id);
                     if ($thumb instanceof File_thumbnail) {
                         $attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
                         $attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb->getUrl();
                         $attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
                         $attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
                         // animated gif?
                         if ($attachment->mimetype == 'image/gif') {
                             $image = ImageFile::fromFileObject($attachment);
                             if ($image->animated == 1) {
                                 $attachment_url_to_id[$enclosure_o->url]['animated'] = true;
                             } else {
                                 $attachment_url_to_id[$enclosure_o->url]['animated'] = false;
                             }
                         }
                     }
                 }
             }
         }
     }
     // add thumbs to $twitter_status
     if (!empty($twitter_status['attachments'])) {
         foreach ($twitter_status['attachments'] as &$attachment) {
             if (!empty($attachment_url_to_id[$attachment['url']])) {
                 $attachment['id'] = $attachment_url_to_id[$attachment['url']]['id'];
                 $attachment['width'] = $attachment_url_to_id[$attachment['url']]['width'];
                 $attachment['height'] = $attachment_url_to_id[$attachment['url']]['height'];
                 $attachment['thumb_url'] = $attachment_url_to_id[$attachment['url']]['thumb_url'];
                 if (isset($attachment_url_to_id[$attachment['url']]['animated'])) {
                     $attachment['animated'] = $attachment_url_to_id[$attachment['url']]['animated'];
                 }
             }
         }
     }
     // reply-to profile url
     try {
         $reply = $notice->getParent();
         $twitter_status['in_reply_to_profileurl'] = $reply->getProfile()->getUrl();
     } catch (ServerException $e) {
         $twitter_status['in_reply_to_profileurl'] = null;
     }
     // fave number
     $faves = Fave::byNotice($notice);
     $favenum = count($faves);
     $twitter_status['fave_num'] = $favenum;
     // repeat number
     $repeats = $notice->repeatStream();
     $repeatnum = 0;
     while ($repeats->fetch()) {
         $repeatnum++;
     }
     $twitter_status['repeat_num'] = $repeatnum;
     // some more metadata about notice
     if ($notice->is_local == '1') {
         $twitter_status['is_local'] = true;
//.........这里部分代码省略.........
开发者ID:allmende,项目名称:qvitter,代码行数:101,代码来源:QvitterPlugin.php

示例5: onNoticeSimpleStatusArray

 /**
  * Typically just used to fill out Twitter-compatible API status data.
  *
  * FIXME: Make all the calls before this end up with a Notice instead of ArrayWrapper please...
  */
 public function onNoticeSimpleStatusArray($notice, array &$status, Profile $scoped = null, array $args = array())
 {
     $status['repeated'] = $scoped instanceof Profile ? $scoped->hasRepeated($notice) : false;
     if ($status['repeated'] === true) {
         // Qvitter API wants the "repeated_id" value set too.
         $repeated = Notice::pkeyGet(array('profile_id' => $scoped->getID(), 'repeat_of' => $notice->getID()));
         $status['repeated_id'] = $repeated->getID();
     }
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:14,代码来源:SharePlugin.php

示例6: hasRepeated

 public function hasRepeated($notice)
 {
     // XXX: not really a pkey, but should work
     $notice = Notice::pkeyGet(array('profile_id' => $this->id, 'repeat_of' => $notice->id));
     return !empty($notice);
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:6,代码来源:Profile.php

示例7: hasRepeated

 public function hasRepeated($notice)
 {
     // XXX: not really a pkey, but should work
     $notice = Notice::pkeyGet(array('profile_id' => $this->getID(), 'repeat_of' => $notice->getID(), 'verb' => ActivityVerb::SHARE));
     return !empty($notice);
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:6,代码来源:Profile.php


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