本文整理汇总了PHP中FD::stream方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::stream方法的具体用法?PHP FD::stream怎么用?PHP FD::stream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::stream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createStream
public function createStream($verb)
{
// Create a new stream item for this discussion
$stream = FD::stream();
// Get the stream template
$tpl = $stream->getTemplate();
// Someone just joined the event
$tpl->setActor($this->created_by, SOCIAL_TYPE_USER);
// Set the params to cache the event data
$registry = FD::registry();
$registry->set('news', $this);
// Set the context
$tpl->setContext($this->id, 'news');
$event = FD::event($this->cluster_id);
// Set the cluster
$tpl->setCluster($this->cluster_id, SOCIAL_TYPE_EVENT, $event->type);
// Set the verb
$tpl->setVerb($verb);
// Set the params
$tpl->setParams($registry);
if ($this->_stream_date) {
$tpl->setDate($this->_stream_date);
}
$tpl->setAccess('core.view');
// Add the stream
$stream->add($tpl);
}
示例2: getContent
public function getContent()
{
$source = explode('.', $this->share->element);
$element = $source[0];
$group = $source[1];
$message = $this->formatContent($this->share->content);
$preview = "";
$content = "";
$title = "";
$stream = FD::stream();
$data = $stream->getItem($this->share->uid);
if ($data !== true && !empty($data)) {
$title = $data[0]->title;
$content = $data[0]->content;
if (isset($data[0]->preview) && $data[0]->preview) {
$preview = $data[0]->preview;
}
}
$theme = FD::themes();
$theme->set('message', $message);
$theme->set('content', $content);
$theme->set('preview', $preview);
$theme->set('title', $title);
$html = $theme->output('apps/user/shares/streams/stream/content');
return $html;
}
示例3: display
public function display()
{
// Get the configuration objects
$config = FD::config();
$jConfig = FD::config('joomla');
// Get the stream library
$stream = FD::stream();
$stream->get();
// Get the result in an array form
$result = $stream->toArray();
// Set the document properties
$doc = JFactory::getDocument();
$doc->link = FRoute::dashboard();
FD::page()->title(JText::_('COM_EASYSOCIAL_STREAM_FEED_TITLE'));
$doc->setDescription(JText::sprintf('COM_EASYSOCIAL_STREAM_FEED_DESC', $jConfig->getValue('sitename')));
if ($result) {
$useEmail = $jConfig->getValue('feed_email');
foreach ($result as $row) {
$item = new JFeedItem();
$item->title = $row->title;
$item->link = FRoute::stream(array('id' => $row->uid));
$item->description = $row->content;
$item->date = $row->created->toMySQL();
$item->author = $row->actor->getName();
if ($useEmail != 'none') {
$item->authorEmail = $jConfig->getValue('mailfrom');
if ($useEmail == 'author') {
$item->authorEmail = $row->actor->email;
}
}
$doc->addItem($item);
}
}
}
示例4: item
/**
* Responsible to output a single stream item.
*
* @access public
* @return null
*
*/
public function item()
{
// Check for user profile completeness
FD::checkCompleteProfile();
// Get the stream id from the request
$id = JRequest::getInt('id');
if (!$id) {
return JError::raiseError(404, JText::_('COM_EASYSOCIAL_STREAM_INVALID_STREAM_ID'));
}
// Get the current logged in user.
$user = FD::user();
// Retrieve stream
$streamLib = FD::stream();
$stream = $streamLib->getItem($id);
if ($stream === false) {
return JError::raiseError(404, JText::_('COM_EASYSOCIAL_STREAM_CONTENT_NOT_AVAILABLE'));
}
// If the user is not allowed to view this stream, display the appropriate message
if ($stream === true || count($stream) <= 0) {
$streamTable = FD::table('Stream');
$streamTable->load($id);
$type = $streamTable->cluster_type ? $streamTable->cluster_type : SOCIAL_TYPE_USER;
$template = 'site/stream/restricted.' . $type;
$this->set('streamTable', $streamTable);
parent::display($template);
return;
}
// Get the first stream item
$stream = $stream[0];
// Strip off any html tags from the title
$title = strip_tags($stream->title);
// Set the page title
FD::page()->title($title);
// Append opengraph tags
$image = $streamLib->getContentImage($stream);
if ($image) {
$stream->opengraph->addImage($image);
}
// Get the permalink of this stream
$permalink = FRoute::stream(array('id' => $stream->uid, 'layout' => 'item', 'external' => 1));
// Append additional opengraph details
$stream->opengraph->addUrl($permalink);
$stream->opengraph->addType('article');
$stream->opengraph->addTitle(trim($title));
// render the meta tags here.
$stream->opengraph->render();
// Get stream actions
$actions = '';
if ($stream->display == SOCIAL_STREAM_DISPLAY_FULL) {
$actions = $streamLib->getActions($stream);
}
$this->set('actions', $actions);
$this->set('user', $user);
$this->set('stream', $stream);
parent::display('site/stream/item');
return;
}
示例5: __construct
public function __construct($uid, $group, $element)
{
$stream = FD::stream();
$data = $stream->getItem($uid);
$item = $data[0];
$this->title = $item->title;
$this->content = $item->content;
if (isset($item->preview) && $item->preview) {
$this->content = $item->preview;
}
}
示例6: update
/**
* Post processes after a user submits a story.
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function update($streamTable = '')
{
// Only logged in users allowed here
FD::requireLogin();
$ajax = FD::ajax();
if ($this->hasErrors()) {
return $ajax->reject($this->getMessage());
}
$stream = FD::stream();
$stream->getItem($streamTable->uid);
$output = $stream->html(false, '', array('contentOnly' => true));
return $ajax->resolve($output, $streamTable->uid);
}
示例7: toggleLike
function toggleLike()
{
//init variable
$app = JFactory::getApplication();
$log_user = JFactory::getUser($this->plugin->get('user')->id);
$result = new stdClass();
$id = $app->input->get('id', 0, 'INT');
$type = $app->input->get('type', null, 'STRING');
$group = $app->input->get('group', 'user', 'STRING');
$itemVerb = $app->input->get('verb', null, 'STRING');
$streamid = $app->input->get('stream_id', 0, 'INT');
$my = FD::user($log_user->id);
// Load likes library.
$model = FD::model('Likes');
// Build the key for likes
$key = $type . '.' . $group;
if ($itemVerb) {
$key = $key . '.' . $itemVerb;
}
// Determine if user has liked this item previously.
$hasLiked = $model->hasLiked($id, $key, $my->id);
$useStreamId = $type == 'albums' ? '' : $streamid;
// If user had already liked this item, we need to unlike it.
if ($hasLiked) {
$state = $model->unlike($id, $key, $my->id, $useStreamId);
} else {
$state = $model->like($id, $key, $my->id, $useStreamId);
//now we need to update the associated stream id from the liked object
if ($streamid) {
$doUpdate = true;
if ($type == 'photos') {
$sModel = FD::model('Stream');
$totalItem = $sModel->getStreamItemsCount($streamid);
if ($totalItem > 1) {
$doUpdate = false;
}
}
if ($doUpdate) {
$stream = FD::stream();
$stream->updateModified($streamid);
}
}
}
// The current action
$verb = $hasLiked ? 'Unlike' : 'Like';
$result->status = $state;
$result->data = $state && $verb == 'like' ? $model->getLikesCount($id, $type) : 0;
$result->message = $state ? $verb . " successful" : $verb . " unsuccessful";
return $result;
}
示例8: 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);
}
}
示例9: toggle
/**
* Toggle the likes on an object.
*
* @since 1.0
* @access public
* @param
* @return string
*/
public function toggle()
{
// Validate the current request
$userId = $this->validateAuth();
// Get the item properties
$id = $this->input->get('uid', 0, 'int');
$type = $this->input->get('element', '', 'cmd');
$group = $this->input->get('group', SOCIAL_APPS_GROUP_USER, 'cmd');
$itemVerb = $this->input->get('verb', '', 'string');
// Get the stream id.
$streamid = $this->input->get('stream_id', 0, 'int');
// If id is invalid, throw an error.
if (!$id || !$type) {
$this->set('status', 0);
return parent::display();
}
// Get current logged in user.
$my = FD::user();
// Load likes library.
$model = FD::model('Likes');
// Build the key for likes
$key = $type . '.' . $group;
if ($itemVerb) {
$key = $key . '.' . $itemVerb;
}
// Determine if user has liked this item previously.
$hasLiked = $model->hasLiked($id, $key, $my->id);
// If user had already liked this item, we need to unlike it.
if ($hasLiked) {
$state = $model->unlike($id, $key, $my->id, $streamid);
} else {
$state = $model->like($id, $key, $my->id, $streamid);
//now we need to update the associated stream id from the liked object
if ($streamid) {
$stream = FD::stream();
$stream->updateModified($streamid);
}
}
// The current action
$verb = $hasLiked ? 'unlike' : 'like';
$this->set('status', $state ? 1 : 0);
parent::display();
}
示例10: item
/**
* Displays a single profile item layout
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function item()
{
$id = $this->input->get('id', 0, 'int');
// Get the profile object
$profile = FD::table('Profile');
$profile->load($id);
if (!$id || !$profile->id) {
return JError::raiseError(404, JText::_('COM_EASYSOCIAL_404_PROFILE_NOT_FOUND'));
}
$model = FD::model('Profiles');
$randomMembers = array();
// if this profile is a ESAD profile, we do not show the random members
if ($profile->community_access) {
$randomMembers = $model->getMembers($profile->id, array('randomize' => true, 'limit' => 20));
}
$totalUsers = $profile->getMembersCount();
// Get statistics of user registration for this profile type
$stats = $model->getRegistrationStats($profile->id);
$stats = $stats->profiles[0]->items;
// Get the stream for this profile
$startlimit = JRequest::getInt('limitstart', 0);
$stream = FD::stream();
$options = array('profileId' => $profile->id);
if ($startlimit) {
$options['startlimit'] = $startlimit;
}
$stream->get($options);
// Set the page title to this category
FD::page()->title($profile->get('title'));
// Set the breadcrumbs
FD::page()->breadcrumb($profile->get('title'));
// Get a list of random albums from this profile
$albums = $model->getRandomAlbums(array('core' => false, 'withCovers' => true));
$this->set('albums', $albums);
$this->set('stream', $stream);
$this->set('stats', $stats);
$this->set('randomMembers', $randomMembers);
$this->set('totalUsers', $totalUsers);
$this->set('profile', $profile);
echo parent::display('site/profiles/item');
}
示例11: update
/**
* to update privacy on an object by current logged in user
*
* @since 1.0
* @access public
* @param
* @return string
*/
public function update()
{
FD::checkToken();
FD::requireLogin();
$my = FD::user();
// get data from form post.
$uid = JRequest::getInt('uid');
$utype = JRequest::getVar('utype');
$value = JRequest::getVar('value');
$pid = JRequest::getVar('pid');
$customIds = JRequest::getVar('custom', '');
$streamid = JRequest::getVar('streamid', '');
$view = FD::view('Privacy', false);
// If id is invalid, throw an error.
if (!$uid) {
//Internal error logging.
FD::logError(__FILE__, __LINE__, 'Privacy Log: Unable to update privacy on item because id provided is invalid.');
$view->setError(JText::_('COM_EASYSOCIAL_ERROR_UNABLE_TO_LOCATE_ID'));
return $view->call(__FUNCTION__);
}
$model = FD::model('Privacy');
$state = $model->update($my->id, $pid, $uid, $utype, $value, $customIds);
// If there's an error, log this down.
if (!$state) {
//Internal error logging.
FD::logError(__FILE__, __LINE__, 'Privacy Log: Unable to update privacy on item because model returned the error, ' . $model->getError());
$view->setError($model->getError());
return $view->call(__FUNCTION__);
}
// lets check if there is stream id presented or not. if yes, means we need to update
// privacy access in stream too.
if ($streamid) {
$access = FD::privacy()->toValue($value);
$stream = FD::stream();
$stream->updateAccess($streamid, $access, $customIds);
}
return $view->call(__FUNCTION__);
}
示例12: share
/**
* Returns an ajax chain.
*
* @since 1.0
* @access public
* @param string The verb that we have performed.
*/
public function share($uid = null, $element = null, $group = SOCIAL_APPS_GROUP_USER, $streamId = 0)
{
// 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 message
$share = FD::get('Repost', $uid, $element, $group);
$cnt = $share->getCount();
$cntPluralize = FD::language()->pluralize($cnt, true)->getString();
$text = JText::sprintf('COM_EASYSOCIAL_REPOST' . $cntPluralize, $cnt);
//$text = $share->getHTML();
$isHidden = $cnt > 0 ? false : true;
$streamHTML = '';
if ($streamId) {
$stream = FD::stream();
$stream->getItem($streamId);
$streamHTML = $stream->html();
}
return $ajax->resolve($text, $isHidden, $cnt, $streamHTML);
}
示例13: follow
/**
* Allows a user to follow another user.
*
* @since 1.0
* @access public
*/
public function follow()
{
// Check for request forgeries.
FD::checkToken();
// Ensure that the user needs to be logged in.
FD::requireLogin();
// Get the current view.
$view = $this->getCurrentView();
// Get the object identifier.
$id = JRequest::getInt('id');
// Get the user that is being followed
$user = FD::user($id);
$type = JRequest::getVar('type');
$group = JRequest::getVar('group', SOCIAL_APPS_GROUP_USER);
// Get the current logged in user.
$my = FD::user();
// Load subscription table.
$subscription = FD::table('Subscription');
// Get subscription library
$subscriptionLib = FD::get('Subscriptions');
// User should never be allowed to follow themselves.
if ($my->id == $id) {
$view->setMessage(JText::_('COM_EASYSOCIAL_FOLLOWERS_NOT_ALLOWED_TO_FOLLOW_SELF'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, $subscription);
}
// Determine if the current user is already a follower
$isFollowing = $subscriptionLib->isFollowing($id, $type, $group, $my->id);
// If it's already following, throw proper message
if ($isFollowing) {
$view->setMessage(JText::_('COM_EASYSOCIAL_SUBSCRIPTIONS_ERROR_ALREADY_FOLLOWING_USER'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, $subscription);
}
// If the user isn't alreayd following, create a new subscription record.
$subscription->uid = $id;
$subscription->type = $type . '.' . $group;
$subscription->user_id = $my->id;
$state = $subscription->store();
if (!$state) {
$view->setMessage($subscription->getError(), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, $subscription);
}
// @badge: followers.follow
$badge = FD::badges();
$badge->log('com_easysocial', 'followers.follow', $my->id, JText::_('COM_EASYSOCIAL_FOLLOWERS_BADGE_FOLLOWING_USER'));
// @badge: followers.followed
$badge->log('com_easysocial', 'followers.followed', $user->id, JText::_('COM_EASYSOCIAL_FOLLOWERS_BADGE_FOLLOWED'));
// @points: profile.follow
// Assign points when user follows another person
$points = FD::points();
$points->assign('profile.follow', 'com_easysocial', $my->id);
// @points: profile.followed
// Assign points when user is being followed by another person
$points->assign('profile.followed', 'com_easysocial', $user->id);
// check if admin want to add stream on following a user or not.
$config = FD::config();
if ($config->get('users.stream.following')) {
// Share this on the stream.
$stream = FD::stream();
$streamTemplate = $stream->getTemplate();
// Set the actor.
$streamTemplate->setActor($my->id, SOCIAL_TYPE_USER);
// Set the context.
$streamTemplate->setContext($subscription->id, SOCIAL_TYPE_FOLLOWERS);
// Set the verb.
$streamTemplate->setVerb('follow');
$streamTemplate->setAccess('followers.view');
// Create the stream data.
$stream->add($streamTemplate);
}
// Set the email options
$emailOptions = array('title' => 'COM_EASYSOCIAL_EMAILS_NEW_FOLLOWER_SUBJECT', 'template' => 'site/followers/new.followers', 'actor' => $my->getName(), 'actorAvatar' => $my->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $my->getPermalink(true, true), 'target' => $user->getName(), 'targetLink' => $user->getPermalink(true, true), 'totalFriends' => $my->getTotalFriends(), 'totalFollowing' => $my->getTotalFollowing(), 'totalFollowers' => $my->getTotalFollowers());
$state = FD::notify('profile.followed', array($user->id), $emailOptions, array('url' => $my->getPermalink(false, false, false), 'actor_id' => $my->id, 'uid' => $id));
return $view->call(__FUNCTION__, $subscription);
}
示例14: store
/**
* Creates a new note.
*
* @since 1.0
* @access public
*/
public function store()
{
// Check for request forgeriess
FD::checkToken();
// Ensure that the user is logged in.
FD::requireLogin();
// Get ajax lib
$ajax = FD::ajax();
// Get the current user.
$my = FD::user();
// Get the app id.
$appId = JRequest::getInt('appId');
// Get the title from request
$title = JRequest::getVar('title');
// Get the note content from request
$content = JRequest::getVar('content');
$stream = JRequest::getBool('stream');
// Check if this is an edited entry
$id = JRequest::getInt('id');
// Create the note
$note = $this->getTable('Note');
$state = $note->load($id);
if ($id && $state) {
if ($note->user_id != $my->id) {
return $ajax->reject();
}
}
$note->title = $title;
$note->content = $content;
$note->user_id = $my->id;
$state = $note->store();
$note->link = FRoute::_('index.php?option=com_easysocial&view=apps&layout=canvas&id=' . $appId . '&cid=' . $note->id . '&userId=' . $my->id);
if (!$state) {
return $ajax->reject($note->getError());
}
// Format the note comments
// Get the comments count
$comments = FD::comments($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::apps(array('layout' => 'canvas', 'userid' => $my->getAlias(), 'cid' => $note->id))));
$note->comments = $comments->getCount();
// Get the likes count
$likes = FD::likes($note->id, 'notes', 'create', SOCIAL_APPS_GROUP_USER);
$note->likes = $likes->getCount();
// Create a stream record
if ($stream) {
$verb = $id ? 'update' : 'create';
$note->createStream($verb);
}
// Format the 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);
$stream = FD::stream();
$options = array('comments' => $comments, 'likes' => $likes);
$note->actions = $stream->getActions($options);
$app = $this->getApp();
$theme = FD::themes();
$theme->set('app', $app);
$theme->set('user', $my);
$theme->set('appId', $appId);
$theme->set('note', $note);
$content = $theme->output('apps/user/notes/dashboard/item');
return $ajax->resolve($content);
}
示例15: addFile
/**
* Override parent's implementation as we need to generate the stream
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function addFile($title = null)
{
// Run the parent's logics first
$result = parent::addFile($title);
if ($result instanceof SocialException) {
return $result;
}
// Create a stream item for the groups now
$stream = FD::stream();
$tpl = $stream->getTemplate();
$actor = FD::user();
// this is a cluster stream and it should be viewable in both cluster and user page.
$tpl->setCluster($this->group->id, SOCIAL_TYPE_GROUP, $this->group->type);
// Set the actor
$tpl->setActor($actor->id, SOCIAL_TYPE_USER);
// Set the context
$tpl->setContext($result->id, SOCIAL_TYPE_FILES);
// Set the verb
$tpl->setVerb('uploaded');
$file = FD::table('File');
$file->load($result->id);
// Set the params to cache the group data
$registry = FD::registry();
$registry->set('group', $this->group);
$registry->set('file', $file);
// Set the params to cache the group data
$tpl->setParams($registry);
// since this is a cluster and user stream, we need to call setPublicStream
// so that this stream will display in unity page as well
// This stream should be visible to the public
$tpl->setAccess('core.view');
$streamItem = $stream->add($tpl);
// Prepare the stream permalink
$permalink = FRoute::stream(array('layout' => 'item', 'id' => $streamItem->uid));
// Notify group members when a new file is uploaded
$this->group->notifyMembers('file.uploaded', array('fileId' => $file->id, 'fileName' => $file->name, 'fileSize' => $file->getSize(), 'permalink' => $permalink, 'userId' => $file->user_id));
return $result;
}