本文整理汇总了PHP中Fave类的典型用法代码示例。如果您正苦于以下问题:PHP Fave类的具体用法?PHP Fave怎么用?PHP Fave使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fave类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle the request
*
* Get favs and return them as json object
*
* @param array $args $_REQUEST data (unused)
*
* @return void
*/
protected function handle()
{
parent::handle();
$fave = new Fave();
$fave->selectAdd();
$fave->selectAdd('user_id');
$fave->notice_id = $this->original->id;
$fave->orderBy('modified');
if (!is_null($this->cnt)) {
$fave->limit(0, $this->cnt);
}
$ids = $fave->fetchAll('user_id');
// get nickname and profile image
$ids_with_profile_data = array();
$i = 0;
foreach ($ids as $id) {
$profile = Profile::getKV('id', $id);
$ids_with_profile_data[$i]['user_id'] = $id;
$ids_with_profile_data[$i]['nickname'] = $profile->nickname;
$ids_with_profile_data[$i]['fullname'] = $profile->fullname;
$ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
$profile = new Profile();
$profile->id = $id;
$avatarurl = $profile->avatarUrl(24);
$ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
$i++;
}
$this->initDocument('json');
$this->showJsonObjects($ids_with_profile_data);
$this->endDocument('json');
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:40,代码来源:apistatusesfavs.php
示例2: addNew
static function addNew($user, $notice)
{
$fave = new Fave();
$fave->user_id = $user->id;
$fave->notice_id = $notice->id;
if (!$fave->insert()) {
common_log_db_error($fave, 'INSERT', __FILE__);
return false;
}
return $fave;
}
开发者ID:Br3nda,项目名称:laconica,代码行数:11,代码来源:Fave.php
示例3: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if (!common_logged_in()) {
// TRANS: Client error displayed when trying to remove a favorite while not logged in.
$this->clientError(_('Not logged in.'));
return;
}
$user = common_current_user();
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
return;
}
$id = $this->trimmed('notice');
$notice = Notice::staticGet($id);
$token = $this->trimmed('token-' . $notice->id);
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
$fave = new Fave();
$fave->user_id = $user->id;
$fave->notice_id = $notice->id;
if (!$fave->find(true)) {
// TRANS: Client error displayed when trying to remove favorite status for a notice that is not a favorite.
$this->clientError(_('This notice is not a favorite!'));
return;
}
$result = $fave->delete();
if (!$result) {
common_log_db_error($fave, 'DELETE', __FILE__);
// TRANS: Server error displayed when removing a favorite from the database fails.
$this->serverError(_('Could not delete favorite.'));
return;
}
$user->blowFavesCache();
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Title for page on which favorites can be added.
$this->element('title', null, _('Add to favorites'));
$this->elementEnd('head');
$this->elementStart('body');
$favor = new FavorForm($this, $notice);
$favor->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)), 303);
}
}
开发者ID:microcosmx,项目名称:experiments,代码行数:59,代码来源:disfavor.php
示例4: getNotices
protected function getNotices()
{
// is this our own stream?
$own = $this->scoped instanceof Profile ? $this->target->getID() === $this->scoped->getID() : false;
$stream = Fave::stream($this->target->getID(), 0, $this->limit, $own);
return $stream->fetchAll();
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:7,代码来源:favoritesrss.php
示例5: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
$profile = AnonymousFavePlugin::getAnonProfile();
if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') {
// TRANS: Client error.
$this->clientError(_m('Could not favor notice! Please make sure your browser has cookies enabled.'));
}
$id = $this->trimmed('notice');
$notice = Notice::getKV($id);
$token = $this->checkSessionToken();
// Throws exception
$stored = Fave::addNew($profile, $notice);
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Title.
$this->element('title', null, _m('Disfavor favorite'));
$this->elementEnd('head');
$this->elementStart('body');
$disfavor = new AnonDisFavorForm($this, $notice);
$disfavor->show();
$this->elementEnd('body');
$this->endHTML();
} else {
$this->returnToPrevious();
}
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:35,代码来源:anonfavor.php
示例6: _streamDirect
function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id)
{
$fav = new Fave();
$qry = null;
if ($own) {
$qry = 'SELECT fave.* FROM fave ';
$qry .= 'WHERE fave.user_id = ' . $user_id . ' ';
} else {
$qry = 'SELECT fave.* FROM fave ';
$qry .= 'INNER JOIN notice ON fave.notice_id = notice.id ';
$qry .= 'WHERE fave.user_id = ' . $user_id . ' ';
$qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' ';
}
if ($since_id != 0) {
$qry .= 'AND notice_id > ' . $since_id . ' ';
}
if ($max_id != 0) {
$qry .= 'AND notice_id <= ' . $max_id . ' ';
}
// NOTE: we sort by fave time, not by notice time!
$qry .= 'ORDER BY modified DESC ';
if (!is_null($offset)) {
$qry .= "LIMIT {$limit} OFFSET {$offset}";
}
$fav->query($qry);
$ids = array();
while ($fav->fetch()) {
$ids[] = $fav->notice_id;
}
$fav->free();
unset($fav);
return $ids;
}
开发者ID:Br3nda,项目名称:StatusNet,代码行数:33,代码来源:Fave.php
示例7: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
return;
}
$user = common_current_user();
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
return;
}
$id = $this->trimmed('notice');
$notice = Notice::staticGet($id);
$token = $this->trimmed('token-' . $notice->id);
if (!$token || $token != common_session_token()) {
$this->clientError(_("There was a problem with your session token. Try again, please."));
return;
}
$fave = new Fave();
$fave->user_id = $this->id;
$fave->notice_id = $notice->id;
if (!$fave->find(true)) {
$this->clientError(_('This notice is not a favorite!'));
return;
}
$result = $fave->delete();
if (!$result) {
common_log_db_error($fave, 'DELETE', __FILE__);
$this->serverError(_('Could not delete favorite.'));
return;
}
$user->blowFavesCache();
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
$this->element('title', null, _('Add to favorites'));
$this->elementEnd('head');
$this->elementStart('body');
$favor = new FavorForm($this, $notice);
$favor->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
}
}
开发者ID:Br3nda,项目名称:laconica,代码行数:54,代码来源:disfavor.php
示例8: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
$profile = AnonymousFavePlugin::getAnonProfile();
if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') {
$this->clientError(_m('Could not disfavor notice! Please make sure your browser has cookies enabled.'));
return;
}
$id = $this->trimmed('notice');
$notice = Notice::staticGet($id);
$token = $this->trimmed('token-' . $notice->id);
if (!$token || $token != common_session_token()) {
// TRANS: Client error.
$this->clientError(_m('There was a problem with your session token. Try again, please.'));
return;
}
$fave = new Fave();
$fave->user_id = $profile->id;
$fave->notice_id = $notice->id;
if (!$fave->find(true)) {
// TRANS: Client error.
$this->clientError(_m('This notice is not a favorite!'));
return;
}
$result = $fave->delete();
if (!$result) {
common_log_db_error($fave, 'DELETE', __FILE__);
// TRANS: Server error.
$this->serverError(_m('Could not delete favorite.'));
return;
}
$profile->blowFavesCache();
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Title.
$this->element('title', null, _m('Add to favorites'));
$this->elementEnd('head');
$this->elementStart('body');
$favor = new AnonFavorForm($this, $notice);
$favor->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
$this->returnToPrevious();
}
}
开发者ID:microcosmx,项目名称:experiments,代码行数:54,代码来源:anondisfavor.php
示例9: getNotices
/**
* Get notices
*
* @param integer $limit max number of notices to return
*
* @return array notices
*/
function getNotices($limit = 0)
{
$notice = Fave::stream($this->user->id, 0, $limit, $false);
$notices = array();
while ($notice->fetch()) {
$notices[] = clone $notice;
}
return $notices;
}
开发者ID:phpsource,项目名称:gnu-social,代码行数:16,代码来源:favoritesrss.php
示例10: getProfiles
function getProfiles()
{
$faves = Fave::byNotice($this->notice);
$profiles = array();
foreach ($faves as $fave) {
$profiles[] = $fave->user_id;
}
return $profiles;
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:9,代码来源:threadednoticelistfavesitem.php
示例11: moveActivity
function moveActivity($act, $sink, $user, $remote)
{
if (empty($user)) {
// TRANS: Exception thrown if a non-existing user is provided. %s is a user ID.
throw new Exception(sprintf(_('No such user "%s".'), $act->actor->id));
}
switch ($act->verb) {
case ActivityVerb::FAVORITE:
$this->log(LOG_INFO, "Moving favorite of {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
// push it, then delete local
$sink->postActivity($act);
$notice = Notice::staticGet('uri', $act->objects[0]->id);
if (!empty($notice)) {
$fave = Fave::pkeyGet(array('user_id' => $user->id, 'notice_id' => $notice->id));
$fave->delete();
}
break;
case ActivityVerb::POST:
$this->log(LOG_INFO, "Moving notice {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
// XXX: send a reshare, not a post
$sink->postActivity($act);
$notice = Notice::staticGet('uri', $act->objects[0]->id);
if (!empty($notice)) {
$notice->delete();
}
break;
case ActivityVerb::JOIN:
$this->log(LOG_INFO, "Moving group join of {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
$sink->postActivity($act);
$group = User_group::staticGet('uri', $act->objects[0]->id);
if (!empty($group)) {
$user->leaveGroup($group);
}
break;
case ActivityVerb::FOLLOW:
if ($act->actor->id == $user->uri) {
$this->log(LOG_INFO, "Moving subscription to {$act->objects[0]->id} by " . "{$act->actor->id} to {$remote->nickname}.");
$sink->postActivity($act);
$other = Profile::fromURI($act->objects[0]->id);
if (!empty($other)) {
Subscription::cancel($user->getProfile(), $other);
}
} else {
$otherUser = User::staticGet('uri', $act->actor->id);
if (!empty($otherUser)) {
$this->log(LOG_INFO, "Changing sub to {$act->objects[0]->id}" . "by {$act->actor->id} to {$remote->nickname}.");
$otherProfile = $otherUser->getProfile();
Subscription::start($otherProfile, $remote);
Subscription::cancel($otherProfile, $user->getProfile());
} else {
$this->log(LOG_NOTICE, "Not changing sub to {$act->objects[0]->id}" . "by remote {$act->actor->id} " . "to {$remote->nickname}.");
}
}
break;
}
}
开发者ID:Grasia,项目名称:bolotweet,代码行数:56,代码来源:activitymover.php
示例12: getFaves
function getFaves()
{
$faves = array();
$fave = new Fave();
$fave->user_id = $this->user->id;
if ($fave->find()) {
while ($fave->fetch()) {
$faves[] = clone $fave;
}
}
return $faves;
}
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:12,代码来源:useractivitystream.php
示例13: handle
function handle($channel)
{
$notice = $this->getNotice($this->other);
try {
$fave = Fave::addNew($this->user->getProfile(), $notice);
} catch (Exception $e) {
$channel->error($this->user, $e->getMessage());
return;
}
// TRANS: Text shown when a notice has been marked as favourite successfully.
$channel->output($this->user, _('Notice marked as fave.'));
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:12,代码来源:favcommand.php
示例14: prepare
protected function prepare(array $args = array())
{
parent::prepare($args);
$this->_profile = Profile::getKV('id', $this->trimmed('profile'));
if (!$this->_profile instanceof Profile) {
// TRANS: Client exception thrown when requesting a favorite feed for a non-existing profile.
throw new ClientException(_('No such profile.'), 404);
}
$offset = ($this->page - 1) * $this->count;
$limit = $this->count + 1;
$this->_faves = Fave::byProfile($this->_profile->id, $offset, $limit);
return true;
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:13,代码来源:atompubfavoritefeed.php
示例15: getNoticeIds
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
$weightexpr = common_sql_weight('modified', common_config('popular', 'dropoff'));
$cutoff = sprintf("modified > '%s'", common_sql_date(time() - common_config('popular', 'cutoff')));
$fave = new Fave();
$fave->selectAdd();
$fave->selectAdd('notice_id');
$fave->selectAdd("{$weightexpr} as weight");
$fave->whereAdd($cutoff);
$fave->orderBy('weight DESC');
$fave->groupBy('notice_id');
if (!is_null($offset)) {
$fave->limit($offset, $limit);
}
// FIXME: $since_id, $max_id are ignored
$ids = array();
if ($fave->find()) {
while ($fave->fetch()) {
$ids[] = $fave->notice_id;
}
}
return $ids;
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:23,代码来源:popularnoticestream.php
示例16: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if (!common_logged_in()) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
return;
}
$user = common_current_user();
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
return;
}
$id = $this->trimmed('notice');
$notice = Notice::staticGet($id);
$token = $this->trimmed('token-' . $notice->id);
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
if ($user->hasFave($notice)) {
// TRANS: Client error displayed when trying to mark a notice as favorite that already is a favorite.
$this->clientError(_('This notice is already a favorite!'));
return;
}
$fave = Fave::addNew($user->getProfile(), $notice);
if (!$fave) {
// TRANS: Server error displayed when trying to mark a notice as favorite fails in the database.
$this->serverError(_('Could not create favorite.'));
return;
}
$this->notify($notice, $user);
$user->blowFavesCache();
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Page title for page on which favorite notices can be unfavourited.
$this->element('title', null, _('Disfavor favorite.'));
$this->elementEnd('head');
$this->elementStart('body');
$disfavor = new DisFavorForm($this, $notice);
$disfavor->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)), 303);
}
}
开发者ID:Grasia,项目名称:bolotweet,代码行数:56,代码来源:favor.php
示例17: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
$profile = AnonymousFavePlugin::getAnonProfile();
if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') {
// TRANS: Client error.
$this->clientError(_m('Could not favor notice! Please make sure your browser has cookies enabled.'));
return;
}
$id = $this->trimmed('notice');
$notice = Notice::staticGet($id);
$token = $this->trimmed('token-' . $notice->id);
if (empty($token) || $token != common_session_token()) {
// TRANS: Client error.
$this->clientError(_m('There was a problem with your session token. Try again, please.'));
return;
}
if ($profile->hasFave($notice)) {
// TRANS: Client error.
$this->clientError(_m('This notice is already a favorite!'));
return;
}
$fave = Fave::addNew($profile, $notice);
if (!$fave) {
// TRANS: Server error.
$this->serverError(_m('Could not create favorite.'));
return;
}
$profile->blowFavesCache();
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
// TRANS: Title.
$this->element('title', null, _m('Disfavor favorite'));
$this->elementEnd('head');
$this->elementStart('body');
$disfavor = new AnonDisFavorForm($this, $notice);
$disfavor->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
$this->returnToPrevious();
}
}
开发者ID:Grasia,项目名称:bolotweet,代码行数:51,代码来源:anonfavor.php
示例18: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return void
*/
function handle($args)
{
parent::handle($args);
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
return;
}
$user = common_current_user();
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
return;
}
$id = $this->trimmed('notice');
$notice = Notice::staticGet($id);
$token = $this->trimmed('token-' . $notice->id);
if (!$token || $token != common_session_token()) {
$this->clientError(_("There was a problem with your session token. Try again, please."));
return;
}
if ($user->hasFave($notice)) {
$this->clientError(_('This notice is already a favorite!'));
return;
}
$fave = Fave::addNew($user, $notice);
if (!$fave) {
$this->serverError(_('Could not create favorite.'));
return;
}
$this->notify($notice, $user);
$user->blowFavesCache();
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
$this->element('title', null, _('Disfavor favorite'));
$this->elementEnd('head');
$this->elementStart('body');
$disfavor = new DisFavorForm($this, $notice);
$disfavor->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
}
}
开发者ID:Br3nda,项目名称:laconica,代码行数:51,代码来源:favor.php
示例19: handle
protected function handle()
{
parent::handle();
if (!in_array($this->format, array('xml', 'json'))) {
$this->clientError(_('API method not found.'), 404, $this->format);
}
if (empty($this->notice)) {
$this->clientError(_('No status found with that ID.'), 404, $this->format);
}
try {
$stored = Fave::addNew($this->scoped, $this->notice);
} catch (AlreadyFulfilledException $e) {
// Note: Twitter lets you fave things repeatedly via API.
$this->clientError($e->getMessage(), 403);
}
if ($this->format == 'xml') {
$this->showSingleXmlStatus($this->notice);
} elseif ($this->format == 'json') {
$this->show_single_json_status($this->notice);
}
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:21,代码来源:apifavoritecreate.php
示例20: prepare
/**
* For initializing members of the class.
*
* @param array $args misc. arguments
*
* @return boolean true
*/
protected function prepare(array $args = array())
{
parent::prepare($args);
$profileId = $this->trimmed('profile');
$noticeId = $this->trimmed('notice');
$this->_profile = Profile::getKV('id', $profileId);
if (empty($this->_profile)) {
// TRANS: Client exception.
throw new ClientException(_('No such profile.'), 404);
}
$this->_notice = Notice::getKV('id', $noticeId);
if (empty($this->_notice)) {
// TRANS: Client exception thrown when referencing a non-existing notice.
throw new ClientException(_('No such notice.'), 404);
}
$this->_fave = Fave::pkeyGet(array('user_id' => $profileId, 'notice_id' => $noticeId));
if (empty($this->_fave)) {
// TRANS: Client exception thrown when referencing a non-existing favorite.
throw new ClientException(_('No such favorite.'), 404);
}
return true;
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:29,代码来源:atompubshowfavorite.php
注:本文中的Fave类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论