本文整理汇总了PHP中FD::story方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::story方法的具体用法?PHP FD::story怎么用?PHP FD::story使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::story方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Displays the edit stream form
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function edit()
{
$ajax = FD::ajax();
$id = JRequest::getInt('id');
$stream = FD::table('Stream');
$stream->load($id);
$mentions = $stream->getTags(array('user', 'hashtag'));
$story = FD::story();
$story->setContent($stream->content);
$story->setMentions($mentions);
$contents = $story->getMentionsForm();
return $ajax->resolve($contents);
}
示例2: share
/**
* Restful api to share a new story
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function share()
{
// Validate the user first
$userId = $this->validateAuth();
// Get the content for the story
$content = $this->input->get('content', '', 'default');
// The target item to comment on
$target = $this->input->get('target_user', 0, 'int');
if (!$content) {
$this->set('code', '403');
$this->set('message', JText::_('Please enter some contents.'));
return parent::display();
}
// Load up story library
$story = FD::story(SOCIAL_TYPE_USER);
// Create the story
$args = array('content' => $content, 'contextIds' => $target, 'contextType' => SOCIAL_TYPE_STORY, 'actorId' => $userId);
$result = $story->create($args);
$this->set('status', 1);
parent::display();
}
示例3: post
public function post()
{
$app = JFactory::getApplication();
//$share_for = $app->input->get('share_for','','CMD');
$type = $app->input->get('type', 'story', 'STRING');
$content = $app->input->get('content', '', 'RAW');
//$targetId = $app->input->get('target_user','All','raw');
$targetId = $app->input->get('target_user', 0, 'INT');
$cluster = $app->input->get('cluster_id', null, 'INT');
$clusterType = $app->input->get('cluster_type', null, 'STRING');
$friends_tags = $app->input->get('friends_tags', null, 'ARRAY');
$log_usr = intval($this->plugin->get('user')->id);
//now take login user stream for target
$targetId = $targetId != $log_usr ? $targetId : $log_usr;
$valid = 1;
$result = new stdClass();
$story = FD::story(SOCIAL_TYPE_USER);
// Check whether the user can really post something on the target
if ($targetId) {
$tuser = FD::user($targetId);
$allowed = $tuser->getPrivacy()->validate('profiles.post.status', $targetId, SOCIAL_TYPE_USER);
if (!$allowed) {
$result->id = 0;
$result->status = 0;
$result->message = 'User not allowed any post in share';
$valid = 0;
}
}
if (empty($type)) {
$result->id = 0;
$result->status = 0;
$result->message = 'Empty type not allowed';
$valid = 0;
} else {
if ($valid) {
// Determines if the current posting is for a cluster
$cluster = isset($cluster) ? $cluster : 0;
//$clusterType = ($cluster) ? 'group' : null;
$isCluster = $cluster ? true : false;
if ($isCluster) {
$group = FD::group($cluster);
$permissions = $group->getParams()->get('stream_permissions', null);
if ($permissions != null) {
// If the user is not an admin, ensure that permissions has member
if ($group->isMember() && !in_array('member', $permissions) && !$group->isOwner() && !$group->isAdmin()) {
$result->message = 'This group memder do not have share data permission';
}
// If the user is an admin, ensure that permissions has admin
if ($group->isAdmin() && !in_array('admin', $permissions) && !$group->isOwner()) {
$result->message = 'This group admin do not have share data permission';
}
$result->id = 0;
$result->status = 0;
$this->plugin->setResponse($result);
return;
}
}
//validate friends
$friends = array();
if (!empty($friends_tags)) {
// Get the friends model
$model = FD::model('Friends');
// Check if the user is really a friend of him / her.
foreach ($friends_tags as $id) {
if (!$model->isFriends($log_usr, $id)) {
continue;
}
$friends[] = $id;
}
} else {
$friends = null;
}
$privacyRule = $type == 'photos' ? 'photos.view' : 'story.view';
//for hashtag mentions
$mentions = null;
//if($type == 'hashtag' || !empty($content))
if (!empty($content)) {
//$type = 'story';
$start = 0;
$posn = array();
//code adjust for 0 position hashtag
$content = 'a ' . $content;
while ($pos = strpos($content, '#', $start)) {
//echo 'Found # at position '.$pos."\n";
$posn[] = $pos - 2;
$start = $pos + 1;
}
$content = substr($content, 2);
//
//$pos = strpos(($content),'#',$start);
$cont_arr = explode(' ', $content);
$indx = 0;
foreach ($cont_arr as $val) {
if (preg_match('/[\'^#,|=_+¬-]/', $val)) {
//$vsl = substr_count($val,'#');
$val_arr = array_filter(explode('#', $val));
foreach ($val_arr as $subval) {
$subval = '#' . $subval;
$mention = new stdClass();
$mention->start = $posn[$indx++];
//.........这里部分代码省略.........
示例4: display
//.........这里部分代码省略.........
// If layout is empty, means we want to get the default view
// Previously timeline is always the default
if (empty($appId) && empty($layout) && $filter != 'appFilter') {
$defaultDisplay = $this->config->get('users.profile.display', 'timeline');
$layout = $defaultDisplay;
}
// Default variables
$timeline = null;
$newCover = false;
// Viewing info of a user.
if ($layout === 'about') {
$showTimeline = false;
$usersModel = FD::model('Users');
$steps = $usersModel->getAbout($user);
// We should generate a canonical link if user is viewing the about section and the default page is about
if ($this->config->get('users.profile.display') == 'about') {
$this->page->canonical($user->getPermalink(false, true));
}
if ($steps) {
foreach ($steps as $step) {
if ($step->active) {
$theme = FD::themes();
$theme->set('fields', $step->fields);
$contents = $theme->output('site/events/item.info');
}
}
}
$this->set('infoSteps', $steps);
}
// Should we filter stream items by specific app types
$appType = $this->input->get('filterid', '', 'string');
// If contents is still empty at this point, then we just get the stream items as the content
if (empty($contents) || $filter == 'appFilter') {
// Should the timeline be active
$timeline = true;
// Retrieve user's stream
$theme = FD::themes();
// Get story
$story = FD::story(SOCIAL_TYPE_USER);
$story->target = $user->id;
// Get the stream
$stream = FD::stream();
//lets get the sticky posts 1st
$stickies = $stream->getStickies(array('userId' => $user->id, 'limit' => 0));
if ($stickies) {
$stream->stickies = $stickies;
}
$streamOptions = array('userId' => $user->id, 'nosticky' => true, 'startlimit' => $startLimit);
if ($filter == 'appFilter') {
$timeline = false;
$streamOptions['actorId'] = $user->id;
}
if ($appType) {
$streamOptions['context'] = $appType;
// Should this be set now or later
$stream->filter = 'custom';
}
$stream->get($streamOptions);
// Only registered users can access the story form
if (!$this->my->guest) {
$stream->story = $story;
}
// Set stream to theme
$theme->set('stream', $stream);
$contents = $theme->output('site/profile/default.stream');
}
// Get user's cover object
$cover = $user->getCoverData();
// If we're setting a cover
$coverId = $this->input->get('cover_id', 0, 'int');
// Load cover photo
if ($coverId) {
$coverTable = FD::table('Photo');
$coverTable->load($coverId);
// If the cover photo belongs to the user
if ($coverTable->isMine()) {
$newCover = $coverTable;
}
}
$streamModel = FD::model('Stream');
// Get a list of application filters
$appFilters = $streamModel->getAppFilters(SOCIAL_TYPE_USER);
// Retrieve list of apps for this user
$appsModel = FD::model('Apps');
$options = array('view' => 'profile', 'uid' => $user->id, 'key' => SOCIAL_TYPE_USER);
$apps = $appsModel->getApps($options);
$this->set('appFilters', $appFilters);
$this->set('filterId', $appType);
$this->set('timeline', $timeline);
$this->set('newCover', $newCover);
$this->set('cover', $cover);
$this->set('contents', $contents);
$this->set('appsLib', $appsLib);
$this->set('apps', $apps);
$this->set('activeApp', $appId);
$this->set('privacy', $privacy);
$this->set('user', $user);
// Load the output of the profile.
return parent::display('site/profile/default');
}
示例5: getStream
/**
* Retrieves the group's stream items.
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function getStream()
{
// Check for request forgeries
FD::checkToken();
// Load up the group
$id = $this->input->get('id', 0, 'int');
$group = FD::group($id);
// Check if the group can be seen by this user
if ($group->isClosed() && !$group->isMember() && !$my->isSiteAdmin()) {
$this->view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_NO_ACCESS'), SOCIAL_MSG_ERROR);
return $this->view->call(__FUNCTION__);
}
// Retrieve the stream
$stream = FD::stream();
$stickies = $stream->getStickies(array('clusterId' => $group->id, 'clusterType' => SOCIAL_TYPE_GROUP, 'limit' => 0));
if ($stickies) {
$stream->stickies = $stickies;
}
// Determines if the user should see the story form
if ($group->isMember() || $this->my->isSiteAdmin()) {
$story = FD::story(SOCIAL_TYPE_GROUP);
$story->setCluster($group->id, SOCIAL_TYPE_GROUP);
$story->showPrivacy(false);
$stream->story = $story;
// Get the group params
$params = $group->getParams();
// Ensure that the user has permissions to see the story form
$permissions = $params->get('stream_permissions', null);
// If permissions has been configured before.
if (!is_null($permissions)) {
// If the user is not an admin, ensure that permissions has member
if (!$group->isAdmin() && !in_array('member', $permissions)) {
unset($stream->story);
}
// If the user is an admin, ensure that permissions has admin
if ($group->isAdmin() && !in_array('admin', $permissions) && !$group->isOwner()) {
unset($stream->story);
}
}
}
// lets get stream items for this group
$options = array('clusterId' => $group->id, 'clusterType' => SOCIAL_TYPE_GROUP, 'nosticky' => true);
// Determines if we should only display moderated stream items
$options['onlyModerated'] = $this->input->get('moderation', false, 'bool');
// Determines if we should filter stream items by specific filters
$filterId = $this->input->get('filterId', 0, 'int');
if ($filterId) {
$streamFilter = FD::table('StreamFilter');
$streamFilter->load($filterId);
// Get a list of hashtags
$hashtags = $streamFilter->getHashTag();
$tags = explode(',', $hashtags);
if ($tags) {
$options['tag'] = $tags;
}
}
// Retrieving stream items by app element
$appElement = $this->input->get('app', '', 'word');
if ($appElement) {
$options['context'] = $appElement;
}
$stream->get($options);
return $this->view->call(__FUNCTION__, $stream);
}
示例6: item
//.........这里部分代码省略.........
$type = FD::config()->get('events.item.display', 'timeline');
}
// Determines if the current request is to filter specific items
$filterId = $this->input->get('filterId', 0, 'int');
// Load Stream filter table
$streamFilter = FD::table('StreamFilter');
if ($filterId) {
$streamFilter->load($filterId);
}
$this->set('filterId', $filterId);
// If the current view is to display filters form
if ($type == 'filterForm' && $guest->isGuest()) {
$theme = FD::themes();
$theme->set('controller', 'events');
$theme->set('filter', $streamFilter);
$theme->set('uid', $event->id);
$contents = $theme->output('site/stream/form.edit');
}
if ($type == 'info') {
FD::language()->loadAdmin();
$currentStep = JRequest::getInt('step', 1);
$steps = FD::model('Steps')->getSteps($event->category_id, SOCIAL_TYPE_CLUSTERS, SOCIAL_EVENT_VIEW_DISPLAY);
$fieldsLib = FD::fields();
$fieldsLib->init(array('privacy' => false));
$fieldsModel = FD::model('Fields');
$index = 1;
foreach ($steps as $step) {
$step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $event->id, 'dataType' => SOCIAL_TYPE_EVENT, 'visible' => SOCIAL_EVENT_VIEW_DISPLAY));
if (!empty($step->fields)) {
$args = array($event);
$fieldsLib->trigger('onDisplay', SOCIAL_FIELDS_GROUP_EVENT, $step->fields, $args);
}
$step->hide = true;
foreach ($step->fields as $field) {
// As long as one of the field in the step has an output, then this step shouldn't be hidden
// If step has been marked false, then no point marking it as false again
// We don't break from the loop here because there is other checking going on
if (!empty($field->output) && $step->hide === true) {
$step->hide = false;
}
}
if ($index === 1) {
$step->url = FRoute::events(array('layout' => 'item', 'id' => $event->getAlias(), 'type' => 'info'), false);
} else {
$step->url = FRoute::events(array('layout' => 'item', 'id' => $event->getAlias(), 'type' => 'info', 'infostep' => $index), false);
}
$step->title = $step->get('title');
$step->active = !$step->hide && $currentStep == $index;
if ($step->active) {
$theme = FD::themes();
$theme->set('fields', $step->fields);
$contents = $theme->output('site/events/item.info');
}
$step->index = $index;
$index++;
}
$this->set('infoSteps', $steps);
}
$this->set('appId', $appId);
$this->set('apps', $apps);
$this->set('type', $type);
$this->set('contents', $contents);
if (!empty($contents)) {
return parent::display('site/events/item');
}
// If no content then only we proceed to get the stream
$stream = FD::stream();
$streamOptions = array('clusterId' => $event->id, 'clusterType' => $event->cluster_type);
// Load the story
$story = FD::story($event->cluster_type);
$story->setCluster($event->id, $event->cluster_type);
$story->showPrivacy(false);
// Determines if this is a hashtag
$hashtag = $this->input->get('tag', 0, 'int');
$hashtagAlias = $this->input->get('tag', '', 'default');
if (!empty($hashtag)) {
$tag = $stream->getHashTag($hashtag);
if (!empty($tag->id)) {
$this->set('hashtag', $tag->title);
$this->set('hashtagAlias', $hashtagAlias);
$story->setHashtags(array($tag->title));
$streamOptions['tag'] = array($tag->title);
}
}
if (!empty($streamFilter->id)) {
$tags = $streamFilter->getHashtag();
$tags = explode(',', $tags);
$streamOptions['tag'] = $tags;
}
if ($guest->isGuest()) {
$stream->story = $story;
}
$streamOptions['startlimit'] = $startlimit;
if ($context) {
$streamOptions['context'] = $context;
}
$stream->get($streamOptions);
$this->set('stream', $stream);
parent::display('site/events/item');
}