本文整理汇总了PHP中Fave::byNotice方法的典型用法代码示例。如果您正苦于以下问题:PHP Fave::byNotice方法的具体用法?PHP Fave::byNotice怎么用?PHP Fave::byNotice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fave
的用法示例。
在下文中一共展示了Fave::byNotice方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProfiles
function getProfiles()
{
$faves = Fave::byNotice($this->notice);
$profiles = array();
foreach ($faves as $fave) {
$profiles[] = $fave->user_id;
}
return $profiles;
}
示例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();
//.........这里部分代码省略.........
示例3: onNoticeSimpleStatusArray
//.........这里部分代码省略.........
// 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
if (strpos($attachment_url_wo_protocol, $noticeurl_wo_protocol) === 0) {
$possible_notice_id = str_replace($noticeurl_wo_protocol, '', $attachment_url_wo_protocol);
if (ctype_digit($possible_notice_id)) {
$quoted_notice = Notice::getKV('id', $possible_notice_id);
}
} elseif (strpos($attachment_url_wo_protocol, $instanceurl_wo_protocol) !== 0 && stristr($attachment_url_wo_protocol, '/notice/')) {
$quoted_notice = Notice::getKV('url', $attachment['url']);
// try with http<->https if no match. applies to quitter.se notices mostly
if (!$quoted_notice instanceof Notice) {
if (strpos($attachment['url'], 'https://') === 0) {
$quoted_notice = Notice::getKV('url', str_replace('https://', 'http://', $attachment['url']));
} else {
$quoted_notice = Notice::getKV('url', str_replace('http://', 'https://', $attachment['url']));
}
}
}
// include the quoted notice in the attachment
if ($quoted_notice instanceof Notice) {
$quoted_notice_author = Profile::getKV('id', $quoted_notice->profile_id);
if ($quoted_notice_author instanceof Profile) {
$attachment['quoted_notice']['id'] = $quoted_notice->id;
$attachment['quoted_notice']['content'] = $quoted_notice->content;
$attachment['quoted_notice']['nickname'] = $quoted_notice_author->nickname;
$attachment['quoted_notice']['fullname'] = $quoted_notice_author->fullname;
$quoted_notice_attachments = $quoted_notice->attachments();
foreach ($quoted_notice_attachments as $q_attach) {
if (is_object($q_attach)) {
try {
$qthumb = $q_attach->getThumbnail();
if (method_exists('File_thumbnail', 'url')) {
$thumb_url = File_thumbnail::url($qthumb->filename);
} else {
$thumb_url = $qthumb->getUrl();
}
$attachment['quoted_notice']['attachments'][] = array('thumb_url' => $thumb_url, 'attachment_id' => $q_attach->id);
} catch (Exception $e) {
common_debug('Qvitter: could not get thumbnail for attachment id=' . $q_attach->id . ' in quoted notice id=' . $quoted_notice->id);
}
}
}
}
}
}
}
}
try {
$twitter_status['external_url'] = $notice->getUrl(true);
} catch (InvalidUrlException $e) {
common_debug('Qvitter: No URL available for external notice: id=' . $notice->id);
}
// 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()) {
if ($repeats->verb == ActivityVerb::SHARE) {
// i.e. not deleted repeats
$repeatnum++;
}
}
$twitter_status['repeat_num'] = $repeatnum;
// is this a post? (previously is_activity)
if (method_exists('ActivityUtils', 'compareVerbs')) {
$twitter_status['is_post_verb'] = ActivityUtils::compareVerbs($notice->verb, array(ActivityVerb::POST));
} else {
$twitter_status['is_post_verb'] = $notice->verb == ActivityVerb::POST ? true : false;
}
// some more metadata about notice
if ($notice->is_local == '1') {
$twitter_status['is_local'] = true;
} else {
$twitter_status['is_local'] = false;
if ($twitter_status['is_post_verb'] === true) {
try {
$twitter_status['external_url'] = $notice->getUrl(true);
} catch (InvalidUrlException $e) {
common_debug('Qvitter: No URL available for external notice: id=' . $notice->id);
}
}
}
if (ActivityUtils::compareTypes($notice->verb, array('qvitter-delete-notice', 'delete'))) {
$twitter_status['qvitter_delete_notice'] = true;
}
return true;
}
示例4: onNoticeSimpleStatusArray
//.........这里部分代码省略.........
$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
if (strpos($attachment_url_wo_protocol, $noticeurl_wo_protocol) === 0) {
$possible_notice_id = str_replace($noticeurl_wo_protocol, '', $attachment_url_wo_protocol);
if (ctype_digit($possible_notice_id)) {
$quoted_notice = Notice::getKV('id', $possible_notice_id);
}
} elseif (strpos($attachment_url_wo_protocol, $instanceurl_wo_protocol) !== 0 && stristr($attachment_url_wo_protocol, '/notice/')) {
$quoted_notice = Notice::getKV('url', $attachment['url']);
// try with http<->https if no match. applies to quitter.se notices mostly
if (!$quoted_notice instanceof Notice) {
if (strpos($attachment['url'], 'https://') === 0) {
$quoted_notice = Notice::getKV('url', str_replace('https://', 'http://', $attachment['url']));
} else {
$quoted_notice = Notice::getKV('url', str_replace('http://', 'https://', $attachment['url']));
}
}
}
// include the quoted notice in the attachment
if ($quoted_notice instanceof Notice) {
$quoted_notice_author = Profile::getKV('id', $quoted_notice->profile_id);
if ($quoted_notice_author instanceof Profile) {
$attachment['quoted_notice']['id'] = $quoted_notice->id;
$attachment['quoted_notice']['content'] = $quoted_notice->content;
$attachment['quoted_notice']['nickname'] = $quoted_notice_author->nickname;
$attachment['quoted_notice']['fullname'] = $quoted_notice_author->fullname;
$attachment['quoted_notice']['is_local'] = $quoted_notice_author->isLocal();
$quoted_notice_attachments = $quoted_notice->attachments();
foreach ($quoted_notice_attachments as $q_attach) {
if (is_object($q_attach)) {
try {
$qthumb = $q_attach->getThumbnail();
if (method_exists('File_thumbnail', 'url')) {
$thumb_url = File_thumbnail::url($qthumb->filename);
} else {
$thumb_url = $qthumb->getUrl();
}
$attachment['quoted_notice']['attachments'][] = array('thumb_url' => $thumb_url, 'attachment_id' => $q_attach->id);
} catch (Exception $e) {
common_debug('Qvitter: could not get thumbnail for attachment id=' . $q_attach->id . ' in quoted notice id=' . $quoted_notice->id);
}
}
}
}
}
}
}
}
try {
$twitter_status['external_url'] = $notice->getUrl(true);
} catch (InvalidUrlException $e) {
common_debug('Qvitter: No URL available for external notice: id=' . $notice->id);
}
// 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()) {
if ($repeats->verb == ActivityVerb::SHARE) {
// i.e. not deleted repeats
$repeatnum++;
}
}
$twitter_status['repeat_num'] = $repeatnum;
// is this a post? (previously is_activity)
if (method_exists('ActivityUtils', 'compareVerbs')) {
$twitter_status['is_post_verb'] = ActivityUtils::compareVerbs($notice->verb, array(ActivityVerb::POST));
} else {
$twitter_status['is_post_verb'] = $notice->verb == ActivityVerb::POST ? true : false;
}
// some more metadata about notice
if ($notice->is_local == '1') {
$twitter_status['is_local'] = true;
} else {
$twitter_status['is_local'] = false;
if ($twitter_status['is_post_verb'] === true) {
try {
$twitter_status['external_url'] = $notice->getUrl(true);
} catch (InvalidUrlException $e) {
common_debug('Qvitter: No URL available for external notice: id=' . $notice->id);
}
}
}
if (ActivityUtils::compareTypes($notice->verb, array('qvitter-delete-notice', 'delete'))) {
$twitter_status['qvitter_delete_notice'] = true;
}
return true;
}
示例5: 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;
//.........这里部分代码省略.........
示例6: getProfiles
function getProfiles()
{
$fave = Fave::byNotice($this->notice->id);
$profiles = array();
while ($fave->fetch()) {
$profiles[] = $fave->user_id;
}
return $profiles;
}