本文整理汇总了PHP中FD::comments方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::comments方法的具体用法?PHP FD::comments怎么用?PHP FD::comments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::comments方法的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($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');
}
示例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($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');
}
示例3: getContents
/**
* Returns the contents of this action.
*
* @since 1.0
* @access public
* @return string The html codes for the comments.
*/
public function getContents()
{
$config = FD::config();
if (!$config->get('stream.comments.enabled')) {
return false;
}
$obj = $this->getElementSource();
$output = FD::comments($obj->uid, $obj->element, $this->item->verb, SOCIAL_APPS_GROUP_USER, array('url' => ''))->getHtml(array('hideEmpty' => true));
return $output;
}
示例4: getCount
/**
* Renders the comment count for Komento
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function getCount(EasyBlogPost $post)
{
if (!$this->exists()) {
return;
}
FD::language()->load('com_easysocial', JPATH_ROOT);
$url = $post->getPermalink();
$comments = FD::comments($post->id, 'blog', SOCIAL_APPS_GROUP_USER, $url);
$count = $comments->getCount();
return $count;
}
示例5: 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);
}
}
示例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
/**
* Prepares the stream item
*
* @since 1.0
* @access public
* @param SocialStreamItem The stream object.
* @param bool Determines if we should respect the privacy
*/
public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
{
if ($item->context != 'discussions') {
return;
}
// group access checking
$group = FD::group($item->cluster_id);
if (!$group) {
return;
}
if (!$group->canViewItem()) {
return;
}
// Ensure that announcements are enabled for this group
$registry = $group->getParams();
if (!$registry->get('discussions', true)) {
return;
}
// Define standard stream looks
$item->display = SOCIAL_STREAM_DISPLAY_FULL;
$item->color = '#69b598';
$item->fonticon = 'ies-comments';
$item->label = FD::_('COM_EASYSOCIAL_STREAM_CONTEXT_TITLE_DISCUSSIONS_TOOLTIP', true);
$params = $this->getApp()->getParams();
if ($params->get('stream_' . $item->verb, true) == false) {
return;
}
// Do not allow user to repost discussions
$item->repost = false;
// Process likes and comments differently.
$likes = FD::likes();
$likes->get($item->contextId, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, $item->uid);
$item->likes = $likes;
// Apply comments on the stream
$comments = FD::comments($item->contextId, $item->context, $item->verb, SOCIAL_APPS_GROUP_GROUP, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
$item->comments = $comments;
if ($item->verb == 'create') {
$this->prepareCreateDiscussionStream($item);
}
if ($item->verb == 'reply') {
$this->prepareReplyStream($item);
}
if ($item->verb == 'answered') {
$this->prepareAnsweredStream($item);
}
if ($item->verb == 'lock') {
$this->prepareLockedStream($item);
}
}
示例8: onContentPrepare
/**
* Triggered when preparing an article for display
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function onContentPrepare($context, &$article, &$params)
{
if ($context != 'com_content.article') {
return;
}
if (!$this->exists()) {
return;
}
// Get the current viewer
$my = FD::user();
// Get app and plugin params
$pluginParams = $this->getPluginParams();
$appParams = $this->getAppParams();
// Only assign points to viewer when they are not a guest and not the owner of the article
if ($my->id && $my->id != $article->created_by && JRequest::getVar('view') == 'article' && !$this->sessionExists()) {
// Assign points to viewer
$this->assignPoints('read.article', $my->id);
// Assign badge to the viewer
$this->assignBadge('read.article', JText::_('PLG_CONTENT_EASYSOCIAL_UPDATED_EXISTING_ARTICLE'));
// Assign points to author when their article is being read
$this->assignPoints('author.read.article', $article->created_by);
// Create a new stream item when an article is being read
if ($appParams->get('stream_read', true)) {
$this->createStream($article, 'read', $my->id);
}
}
$comments = '';
// Load css files
$this->loadAssets();
FD::language()->loadSite();
// If configured to display comemnts
if ($my->id && $pluginParams->get('load_comments', false)) {
$url = ContentHelperRoute::getArticleRoute($article->id . ':' . $article->alias, $article->catid);
$comments = FD::comments($article->id, 'article', 'create', SOCIAL_APPS_GROUP_USER, array('url' => $url));
$comments = $comments->getHtml();
}
// Get the author of the article
if (isset($article->created_by)) {
$author = FD::user($article->created_by);
$displayAuthor = $pluginParams->get('display_author', true);
$displayInfo = $pluginParams->get('display_info', true);
// Get a list of badges the author has
$badges = $author->getBadges();
ob_start();
require_once dirname(__FILE__) . '/tmpl/article.php';
$contents = ob_get_contents();
ob_end_clean();
$article->text .= $contents;
}
}
示例9: 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;
}
示例10: 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;
}
示例11: 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)
{
// Load up the config object
$config = FD::config();
if ($item->context != 'badges' || !$config->get('badges.enabled')) {
return;
}
// Check if the app should be able to generate the stream.
$params = $this->getParams();
if (!$params->get('stream_achieved', true)) {
return;
}
// Test if stream item is allowed
if (!$this->onStreamValidatePrivacy($item)) {
return;
}
// Get the actor
$actor = $item->actor;
// Try to get the badge object from the params
$raw = $item->params;
$badge = FD::table('Badge');
$badge->load($item->contextId);
// Set the display mode to be full.
$item->display = SOCIAL_STREAM_DISPLAY_FULL;
$item->color = '#FEBC9D';
$item->fonticon = 'ies-crown';
$item->label = JText::_('APP_USER_BADGES_STREAM_TOOLTIP');
// Format the likes for the stream
$likes = FD::likes();
$likes->get($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, $item->uid);
$item->likes = $likes;
// Apply comments on the stream
$comments = FD::comments($item->contextId, $item->context, $item->verb . '.' . $item->actor->id, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
$item->comments = $comments;
$this->set('badge', $badge);
$this->set('actor', $actor);
$item->title = parent::display('streams/' . $item->verb . '.title');
$item->content = parent::display('streams/' . $item->verb . '.content');
return true;
}
示例12: 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>
示例13: onPrepareStream
/**
* Prepares the stream item
*
* @since 1.0
* @access public
* @param SocialStreamItem The stream object.
* @param bool Determines if we should respect the privacy
*/
public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
{
if ($item->context != SOCIAL_TYPE_FILES) {
return;
}
// if this is a cluster stream, let check if user can view this stream or not.
if ($item->cluster_id && $item->cluster_type) {
$cluster = FD::cluster($item->cluster_type, $item->cluster_id);
if (!$cluster) {
return;
}
if (!$cluster->canViewItem()) {
return;
}
$item->display = SOCIAL_STREAM_DISPLAY_FULL;
if ($item->cluster_type == SOCIAL_TYPE_GROUP) {
$item->color = '#303229';
$item->fonticon = 'ies-users';
$item->label = JText::_('APP_USER_FILES_GROUPS_STREAM_TOOLTIP');
}
if ($item->cluster_type == SOCIAL_TYPE_EVENT) {
$item->color = '#f06050';
$item->fonticon = 'ies-calendar';
$item->label = JText::_('APP_USER_EVENTS_STREAM_TOOLTIP');
}
if ($item->verb == 'uploaded') {
$this->prepareUploadedStream($item);
}
return;
}
// File uploads by user
if (isset($item->contextParams[0])) {
$params = FD::registry($item->contextParams[0]);
$items = $params->get('files');
$total = count($items);
$files = array();
if (!$items) {
return;
}
foreach ($items as $id) {
$file = FD::table('File');
$file->load($id);
$files[] = $file;
}
$plurality = $total > 1 ? '_PLURAL' : '_SINGULAR';
$targets = $item->targets ? $item->targets[0] : false;
$this->set('target', $targets);
$this->set('content', $item->content);
$this->set('plurality', $plurality);
$this->set('total', $total);
$this->set('files', $files);
$this->set('actor', $item->actor);
$item->display = SOCIAL_STREAM_DISPLAY_FULL;
$item->color = '#00B6AD';
$item->fonticon = 'ies-file';
$item->label = JText::_('APP_USER_FILES_STREAM_TOOLTIP');
// Apply likes on the stream
$likes = FD::likes();
$likes->get($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_USER, $item->uid);
$item->likes = $likes;
// Apply comments on the stream
$comments = FD::comments($item->uid, $item->context, $item->verb, SOCIAL_APPS_GROUP_USER, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item->uid))), $item->uid);
$item->comments = $comments;
$item->title = parent::display('streams/uploaded.title.user');
$item->content = parent::display('streams/uploaded.content.user');
}
}
示例14: getCommentsCount
/**
* Retrieves the comments count for this photo
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function getCommentsCount()
{
static $comments = array();
if (!isset($comments[$this->id])) {
// Default context
$context = SOCIAL_TYPE_PHOTO;
$verb = 'add';
$group = $this->type;
$id = $this->id;
// We need to determine if the album is a core one
$album = $this->getAlbum();
if ($album->core == SOCIAL_ALBUM_PROFILE_PHOTOS) {
$verb = 'uploadAvatar';
}
if ($album->core == SOCIAL_ALBUM_PROFILE_COVERS) {
$verb = 'updateCover';
}
if ($album->core == SOCIAL_ALBUM_STORY_ALBUM) {
$verb = 'upload';
$context = SOCIAL_TYPE_STREAM;
// We need to test if this photo contains single stream item or aggregated
$model = FD::model('Stream');
$aggregated = $model->isAggregated($this->id, 'photos');
if (!$aggregated) {
$context = SOCIAL_TYPE_PHOTO;
$verb = 'upload';
}
}
$count = FD::comments($id, $context, $verb, $group)->getCount();
$comments[$this->id] = $count;
}
return $comments[$this->id];
}
示例15: 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;
}