本文整理汇总了PHP中FD::likes方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::likes方法的具体用法?PHP FD::likes怎么用?PHP FD::likes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::likes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Displays the application output in the canvas.
*
* @since 1.0
* @access public
* @param int The user id that is currently being viewed.
*/
public function display($uid = null, $docType = null)
{
$event = FD::event($uid);
// Get the article item
$news = FD::table('EventNews');
$news->load($this->input->get('newsId', 0, 'int'));
// Check if the user is really allowed to view this item
if (!$event->canViewItem()) {
return $this->redirect($event->getPermalink(false));
}
// Get the author of the article
$author = FD::user($news->created_by);
// Get the url for the article
$url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $this->app->getAlias(), 'articleId' => $news->id), false);
// Apply comments for the article
$comments = FD::comments($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT, array('url' => $url));
// Apply likes for the article
$likes = FD::likes()->get($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT);
// Set the page title
FD::page()->title($news->get('title'));
// Retrieve the params
$params = $this->app->getParams();
$this->set('app', $this->app);
$this->set('params', $params);
$this->set('event', $event);
$this->set('likes', $likes);
$this->set('comments', $comments);
$this->set('author', $author);
$this->set('news', $news);
echo parent::display('canvas/item');
}
示例2: display
/**
* Displays the application output in the canvas.
*
* @since 1.0
* @access public
* @param int The user id that is currently being viewed.
*/
public function display($userId = null, $docType = null)
{
// Require user to be logged in
FD::requireLogin();
$id = JRequest::getVar('schedule_id');
// Get the user that's being accessed.
$user = FD::user($userId);
$calendar = FD::table('Calendar');
$calendar->load($id);
if (!$calendar->id || !$id) {
FD::info()->set(false, JText::_('APP_CALENDAR_CANVAS_INVALID_SCHEDULE_ID'), SOCIAL_MSG_ERROR);
return $this->redirect(FD::profile(array('id' => $user->getAlias()), false));
}
$my = FD::user();
$privacy = FD::privacy($my->id);
$result = $privacy->validate('apps.calendar', $calendar->id, 'view', $user->id);
if (!$result) {
FD::info()->set(false, JText::_('APP_CALENDAR_NO_ACCESS'), SOCIAL_MSG_ERROR);
JFactory::getApplication()->redirect(FRoute::dashboard());
}
FD::page()->title($calendar->title);
// Render the comments and likes
$likes = FD::likes();
$likes->get($id, 'calendar', 'create', SOCIAL_APPS_GROUP_USER);
// Apply comments on the stream
$comments = FD::comments($id, 'calendar', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::albums(array('layout' => 'item', 'id' => $id))));
$params = $this->app->getParams();
$this->set('params', $params);
$this->set('likes', $likes);
$this->set('comments', $comments);
$this->set('calendar', $calendar);
$this->set('user', $user);
echo parent::display('canvas/item/default');
}
示例3: setLikes
/**
* Sets the likes on the stream
*
* @since 1.3.8
* @access public
* @param string
* @return
*/
public function setLikes($group, $useStreamId, $uid = null, $context = null, $verb = null)
{
$uid = is_null($uid) ? $this->uid : $uid;
$context = is_null($context) ? $this->context : $context;
$verb = is_null($verb) ? $this->verb : $verb;
$likes = FD::likes();
$likes->get($uid, $context, $verb, $group, $useStreamId);
$this->likes = $likes;
}
示例4: format
public function format(&$notes)
{
if (!$notes) {
return;
}
// Since this is the dashboard view, we may freely use the current user.
$my = FD::user();
$stream = FD::stream();
foreach ($notes as &$note) {
$comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::apps(array('layout' => 'canvas', 'userid' => $my->getAlias(), 'cid' => $note->id))));
$likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER);
$options = array('comments' => $comments, 'likes' => $likes);
$note->actions = $stream->getActions($options);
}
}
示例5: toggle
/**
* Returns an ajax chain.
*
* @since 1.0
* @access public
* @param string The verb that we have performed.
*/
public function toggle($verb = '', $id = null, $type = null, $group = SOCIAL_APPS_GROUP_USER, $itemVerb = '')
{
// Load ajax lib
$ajax = FD::ajax();
// Determine if there's any errors on the form.
$error = $this->getError();
if ($error) {
return $ajax->reject($error);
}
// Set the label
$label = $verb == 'like' ? JText::_('COM_EASYSOCIAL_LIKES_UNLIKE') : JText::_('COM_EASYSOCIAL_LIKES_LIKE');
// Set the message
$likes = FD::likes($id, $type, $itemVerb, $group);
$likes->get($id, $type, $itemVerb, $group);
$likeCnt = count($likes->data);
$isHidden = $likeCnt > 0 ? false : true;
$contents = $likes->toString();
return $ajax->resolve($contents, $label, $isHidden, $verb, $likeCnt);
}
示例6: display
/**
* Displays the single note item
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function display($userId = null, $docType = null)
{
$id = JRequest::getInt('cid');
$appid = JRequest::getInt('id');
// Get the current owner of this app canvas
$user = FD::user($userId);
$note = $this->getTable('Note');
$note->load($id);
if (!$id || !$note) {
FD::info()->set(false, JText::_('APP_USER_NOTES_INVALID_NOTE_ID_PROVIDED'), SOCIAL_MSG_ERROR);
return $this->redirect(FD::profile(array('id' => $user->getAlias()), false));
}
// Load up likes library for this note.
$likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER);
// Load up comments library for this note.
$comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => ''));
$this->set('likes', $likes);
$this->set('comments', $comments);
$this->set('note', $note);
$this->set('user', $user);
$this->set('appId', $appid);
echo parent::display('canvas/default');
}
示例7: onPrepareStream
/**
* Generates the stream title of event.
*
* @since 1.0
* @access public
* @param object $params A standard object with key / value binding.
*
* @return none
*/
public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
{
if ($stream->context != 'links') {
return;
}
// event access checking
$event = FD::event($stream->cluster_id);
if (!$event || !$event->canViewItem()) {
return;
}
//get links object, in this case, is the stream_item
$uid = $stream->uid;
$stream->color = '#5580BE';
$stream->fonticon = 'ies-link';
$stream->label = FD::_('APP_EVENT_LINKS_STREAM_TOOLTIP', true);
// Apply likes on the stream
$likes = FD::likes();
$likes->get($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_EVENT, $stream->uid);
$stream->likes = $likes;
// Apply comments on the stream
$comments = FD::comments($stream->uid, $stream->context, $stream->verb, SOCIAL_APPS_GROUP_EVENT, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream->uid))), $stream->uid);
$stream->comments = $comments;
// Apply repost on the stream
$stream->repost = FD::get('Repost', $stream->uid, SOCIAL_TYPE_STREAM, SOCIAL_APPS_GROUP_EVENT);
$my = FD::user();
$privacy = FD::privacy($my->id);
if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_LINKS, $stream->actor->id)) {
return;
}
$actor = $stream->actor;
$target = count($stream->targets) > 0 ? $stream->targets[0] : '';
$stream->display = SOCIAL_STREAM_DISPLAY_FULL;
$assets = $stream->getAssets();
if (empty($assets)) {
return;
}
$assets = $assets[0];
$videoHtml = '';
// Retrieve the link that is stored.
$hash = md5($assets->get('link'));
$link = FD::table('Link');
$link->load(array('hash' => $hash));
$linkObj = FD::json()->decode($link->data);
// Determine if there's any embedded object
$oembed = isset($linkObj->oembed) ? $linkObj->oembed : '';
// Get app params
$params = $this->getParams();
$this->set('event', $event);
$this->set('params', $params);
$this->set('oembed', $oembed);
$this->set('assets', $assets);
$this->set('actor', $actor);
$this->set('target', $target);
$this->set('stream', $stream);
$stream->title = parent::display('streams/title.' . $stream->verb);
$stream->preview = parent::display('streams/preview.' . $stream->verb);
return true;
}
示例8: attachActions
private function attachActions(&$item, &$news, $permalink, $appParams)
{
// We need to link the comments to the news
$item->comments = FD::comments($news->id, 'news', 'create', SOCIAL_APPS_GROUP_GROUP, array('url' => $permalink), $item->uid);
// The comments for the stream item should link to the news itself.
if (!$appParams->get('allow_comments') || !$news->comments) {
$item->comments = false;
}
// The likes needs to be linked to the news itself
$likes = FD::likes();
$likes->get($news->id, 'news', 'create', SOCIAL_APPS_GROUP_GROUP, $item->uid);
$item->likes = $likes;
}
示例9: defined
<?php
/**
* @package EasySocial
* @copyright Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* EasySocial is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Unauthorized Access');
?>
<div data-photo-likes-holder class="es-item-likes">
<?php
echo FD::likes($photo->id, SOCIAL_TYPE_PHOTO, 'upload', SOCIAL_APPS_GROUP_USER)->toString();
?>
</div>
<div data-photo-comments-holder class="es-item-comments">
<?php
echo FD::comments($photo->id, SOCIAL_TYPE_PHOTO, 'upload', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::photos(array('layout' => 'item', 'id' => $photo->id))))->getHTML();
?>
</div>
示例10: onPrepareStream
/**
* Triggered to prepare the stream item
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function onPrepareStream(SocialStreamItem &$item)
{
// If this is not it's context, we don't want to do anything here.
if ($item->context != 'story') {
return;
}
// Get the event object
$group = $item->getCluster();
if (!$group) {
return;
}
if (!$group->canViewItem()) {
return;
}
// Allow editing of the stream item
$item->editable = $this->my->isSiteAdmin() || $group->isAdmin() || $item->actor->id == $this->my->id;
// Get the actor
$actor = $item->getActor();
// Decorate the stream
$item->fonticon = 'ies-pencil-2';
$item->color = '#6E9545';
$item->label = FD::_('APP_GROUP_STORY_STREAM_TOOLTIP', true);
$item->display = SOCIAL_STREAM_DISPLAY_FULL;
$this->set('group', $group);
$this->set('actor', $actor);
$this->set('stream', $item);
$item->title = parent::display('streams/title.' . $item->verb);
$item->content = parent::display('streams/content.' . $item->verb);
// Apply likes on the stream
$likes = FD::likes();
$likes->get($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, $item->uid);
$item->likes = $likes;
// If this update is posted in a group, the comments should be linked to the group item
$comments = FD::comments($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
$item->comments = $comments;
return true;
}
示例11: processThanked
/**
* Processes the stream item for new thanks
*
* @since 1.0
* @access public
* @param SocialStreamItem The stream item object
* @param bool Determine if we should include the privacy or not.
* @return
*/
private function processThanked(&$item, $includePrivacy = true)
{
$message = KunenaForumMessageHelper::get($item->contextId);
$topic = $message->getTopic();
$category = $topic->getCategory();
if (!$category->authorise('read') || !$topic->authorise('read')) {
// user not allow to view the content.
return;
}
// Apply likes on the stream
$likes = FD::likes()->get($item->contextId, 'kunena', 'thank', SOCIAL_APPS_GROUP_USER, $item->uid);
$item->likes = $likes;
// disable comments on the stream
$item->comments = false;
// Define standard stream looks
$item->display = SOCIAL_STREAM_DISPLAY_MINI;
$item->color = '#6f90b5';
// Set the actor
$actor = $item->actor;
$target = $item->targets[0];
$parent = $this->createParent($message->id);
$message->message = KunenaHtmlParser::parseBBCode($message->message, $parent, 250);
$message->message = $this->filterContent($message->message);
$this->set('actor', $actor);
$this->set('target', $target);
$this->set('topic', $topic);
$this->set('message', $message);
$item->title = parent::display('streams/' . $item->verb . '.title');
$item->opengraph->addDescription($item->title);
}
示例12: onPrepareStream
/**
* Trigger for onPrepareStream
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
{
// We only want to process related items
if ($item->cluster_type !== SOCIAL_TYPE_GROUP || empty($item->cluster_id)) {
return;
}
$allowed = array('groups', 'tasks', 'discussions', 'news');
if (!in_array($item->context, $allowed)) {
return;
}
// Get the group object
$group = FD::group($item->cluster_id);
// If we can't find the group, skip this.
if (!$group) {
return;
}
// Determines if the user can view this group item.
if (!$group->canViewItem()) {
return;
}
// Get the app params so that we determine which stream should be appearing
$app = $this->getApp();
$params = $app->getParams();
$item->display = SOCIAL_STREAM_DISPLAY_FULL;
$item->color = '#303229';
$item->fonticon = 'ies-users';
$item->label = FD::_('APP_USER_GROUPS_STREAM_TOOLTIP', true);
if ($item->context == 'news') {
$this->prepareGroupNewsStream($item, $group, $includePrivacy);
} else {
if ($item->context == 'tasks') {
$this->prepareGroupTask($item, $group, $includePrivacy);
} else {
if ($item->context == 'discussions') {
$this->prepareGroupDiscussion($item, $group, $includePrivacy);
} else {
// Prepare the likes
$likes = FD::likes($item->uid, 'groups', $item->verb, SOCIAL_TYPE_USER, $item->uid);
$item->likes = $likes;
$item->display = SOCIAL_STREAM_DISPLAY_MINI;
// Display stream item for new member join
if ($item->verb == 'join' && $params->get('stream_join', true)) {
$this->prepareJoinStream($item, $group);
}
// Display stream item if member leaves a group
if ($item->verb == 'leave' && $params->get('stream_leave', true)) {
$this->prepareLeaveStream($item, $group);
}
// Display stream item for new group creation
if ($item->verb == 'create' && $params->get('stream_create', true)) {
$this->prepareCreateStream($item, $group);
}
// Display stream item when a member is promoted to be a group admin
if ($item->verb == 'makeadmin' && $params->get('stream_admin', true)) {
$this->prepareMakeAdminStream($item, $group);
}
if ($item->verb == 'update' && $params->get('stream_update', true)) {
$this->prepareUpdateStream($item, $group);
}
}
}
}
// Hide these items if the user is not a member of the group.
if (!$group->isMember()) {
$item->commentLink = false;
$item->repost = false;
$item->commentForm = false;
}
// Only show Social sharing in public group
if ($group->type != SOCIAL_GROUPS_PUBLIC_TYPE) {
$item->sharing = false;
}
}
示例13: onPrepareStream
/**
* Responsible to generate the stream contents.
*
* @since 1.0
* @access public
* @param object $params A standard object with key / value binding.
*
* @return none
*/
public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
{
if ($item->context != 'friends') {
return;
}
// Determines if the stream should be generated
$params = $this->getParams();
if (!$params->get('stream_friends', true)) {
return;
}
// Get the actor
$actor = $item->actor;
// check if the actor is ESAD profile or not, if yes, we skip the rendering.
if (!$actor->hasCommunityAccess()) {
$item->title = '';
return;
}
$my = FD::user();
$privacy = FD::privacy($my->id);
if ($includePrivacy) {
if (!$privacy->validate('core.view', $item->contextId, 'friends', $item->actor->id)) {
return;
}
}
// Get the context id.
$id = $item->contextId;
// no target. this could be data error. ignore this item.
if (!$item->targets) {
return;
}
// Receiving actor.
$target = $item->targets[0];
// Get the current id.
$id = JRequest::getInt('id');
// Decorate the stream
$item->display = SOCIAL_STREAM_DISPLAY_MINI;
$item->color = '#7AD7EE';
$item->fonticon = 'ies-user';
$item->label = FD::_('APP_USER_FRIENDS_STREAM_TOOLTIP', true);
// Apply likes on the stream
$likes = FD::likes();
$likes->get($item->contextId, $item->context, $item->verb, SOCIAL_APPS_GROUP_USER, $item->uid);
$item->likes = $likes;
$this->set('actor', $actor);
$this->set('target', $target);
$item->title = parent::display('streams/' . $item->verb . '.title');
if ($includePrivacy) {
$item->privacy = $privacy->form($item->contextId, 'friends', $item->actor->id, 'core.view', false, $item->uid);
}
return true;
}
示例14: getStreamNotificationTargets
/**
* Retrieves a list of notification targets
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function getStreamNotificationTargets($uid, $element, $group, $verb, $targets = array(), $exclusion = array())
{
// Get a list of people that also likes this
$likes = FD::likes($uid, $element, $verb, $group);
$targets = array_merge($targets, $likes->getParticipants(false));
// Get people who are part of the comments
$comments = FD::comments($uid, $element, $verb, $group);
$targets = array_merge($targets, $comments->getParticipants(array(), false));
// Remove exclustion
$targets = array_diff($targets, $exclusion);
// Ensure that recipients are unique now.
$targets = array_unique($targets);
// Reset all indexes
$targets = array_values($targets);
return $targets;
}
示例15: like
/**
* Post processing after a photo is liked
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function like($photoId)
{
$ajax = FD::ajax();
if ($this->hasErrors()) {
return $ajax->reject($this->getMessage());
}
$like = FD::likes($photoId, SOCIAL_TYPE_PHOTO, 'upload', SOCIAL_APPS_GROUP_USER);
$obj = new stdClass();
$obj->state = true;
$obj->count = $like->getCount();
$obj->html = $like->toString();
return $ajax->resolve($obj);
}