本文整理汇总了PHP中FD类的典型用法代码示例。如果您正苦于以下问题:PHP FD类的具体用法?PHP FD怎么用?PHP FD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getElementSource
private function getElementSource()
{
$element = $this->item->context;
$uid = $this->item->contextId;
// photos has the special threatment. if the item is a aggregated item, then the context is album and the uid is albumid.
if ($element == 'photos') {
if (count($this->item->contextIds) > 1) {
$photo = FD::table('Photo');
$photo->load($uid);
$element = 'albums';
$uid = $photo->album_id;
}
}
if ($element == 'story' || $element == 'links') {
$uid = $this->item->uid;
}
if ($element == 'badges') {
$tbl = FD::table('StreamItem');
$tbl->load(array('uid' => $this->item->uid));
$element = SOCIAL_TYPE_ACTIVITY;
$uid = $tbl->id;
}
$obj = new stdClass();
$obj->element = $element;
$obj->uid = $uid;
return $obj;
}
示例2: isValid
/**
* Validates the username.
*
* @since 1.0
* @access public
* @param null
* @return JSON A jsong encoded string.
*
* @author Jason Rey <jasonrey@stackideas.com>
*/
public function isValid()
{
// Render the ajax lib.
$ajax = FD::getInstance('Ajax');
// Get the userid
$userid = JRequest::getInt('userid', 0);
// Get the event
$event = JRequest::getString('event');
// Set the current username
$current = '';
if (!empty($userid)) {
$user = FD::user($userid);
$current = $user->username;
}
// Get the provided username that the user has typed.
$username = JRequest::getVar('username', '');
// Username is required, check if username is empty
if (JString::strlen($username) < $this->params->get('min')) {
return $ajax->reject(JText::sprintf('PLG_FIELDS_JOOMLA_USERNAME_MIN_CHARACTERS', $this->params->get('min')));
}
// Test if username is allowed (by pass for adminedit).
if ($event !== 'onAdminEdit' && !SocialFieldsUserJoomlaUsernameHelper::allowed($username, $this->params)) {
return $ajax->reject(JText::_('PLG_FIELDS_JOOMLA_USERNAME_NOT_ALLOWED'));
}
// Test if username exists.
if (SocialFieldsUserJoomlaUsernameHelper::exists($username, $current)) {
return $ajax->reject(JText::_('PLG_FIELDS_JOOMLA_USERNAME_NOT_AVAILABLE'));
}
// Test if the username is valid
if (!SocialFieldsUserJoomlaUsernameHelper::isValid($username, $this->params)) {
return $ajax->reject(JText::_('PLG_FIELDS_JOOMLA_USERNAME_IS_INVALID'));
}
$text = JText::_('PLG_FIELDS_JOOMLA_USERNAME_AVAILABLE');
return $ajax->resolve($text);
}
示例3: createCover
/**
* Some desc
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function createCover($file, $inputName)
{
// Load our own image library
$image = FD::image();
// Generates a unique name for this image.
$name = $file['name'];
// Load up the file.
$image->load($file['tmp_name'], $name);
// Ensure that the image is valid.
if (!$image->isValid()) {
// @TODO: Add some logging here.
echo JText::_('PLG_FIELDS_AVATAR_VALIDATION_INVALID_IMAGE');
exit;
}
// Get the storage path
$storage = SocialFieldsUserCoverHelper::getStoragePath($inputName);
// Create a new avatar object.
$photos = FD::get('Photos', $image);
// Create avatars
$sizes = $photos->create($storage);
// We want to format the output to get the full absolute url.
$base = basename($storage);
$result = array();
foreach ($sizes as $size => $value) {
$row = new stdClass();
$row->title = $file['name'];
$row->file = $value;
$row->path = JPATH_ROOT . '/media/com_easysocial/tmp/' . $base . '/' . $value;
$row->uri = rtrim(JURI::root(), '/') . '/media/com_easysocial/tmp/' . $base . '/' . $value;
$result[$size] = $row;
}
return $result;
}
示例4: getItems
public function getItems($options = array())
{
$db = FD::db();
$sql = $db->sql();
$sql->select('#__social_clusters_nodes', 'a');
$sql->column('a.*');
$eventid = isset($options['eventid']) ? $options['eventid'] : 0;
$sql->where('cluster_id', $eventid);
if (isset($options['state'])) {
$sql->where('state', $state);
}
if (isset($options['admin'])) {
$sql->where('admin', $options['admin']);
}
$ordering = $this->getState('ordering');
if (!empty($ordering)) {
$direction = $this->getState('direction');
if ($ordering == 'username') {
$sql->leftjoin('#__users', 'b');
$sql->on('a.uid', 'b.id');
$sql->order('b.username', $direction);
} elseif ($ordering == 'name') {
$sql->leftjoin('#__users', 'b');
$sql->on('a.uid', 'b.id');
$sql->order('b.name', $direction);
} else {
$sql->order($ordering, $direction);
}
}
$this->setTotal($sql->getTotalSql());
$result = $this->getData($sql->getSql());
$guests = $this->bindTable('EventGuest', $result);
return $guests;
}
示例5: main
public function main()
{
$db = FD::db();
$sql = $db->sql();
// First we get the core.view privacy id
$sql->select('#__social_privacy')->column('id')->where('type', 'core')->where('rule', 'view');
$db->setQuery($sql);
$origId = $db->loadResult();
// Then we cache a copy of all the new field rules and the id
$sql->clear();
$sql->select('#__social_privacy')->column('id')->column('rule')->where('type', 'field');
$db->setQuery($sql);
$rules = $db->loadObjectList('rule');
// Then we get all the privacy items with this id and type = 'field'
$sql->clear();
$sql->select('#__social_privacy_items', 'a')->column('a.*')->column('c.element')->leftjoin('#__social_fields', 'b')->on('b.id', 'a.uid')->leftjoin('#__social_apps', 'c')->on('b.app_id', 'c.id')->where('(')->where('a.type', 'field')->where('a.type', 'field.datetime.year', '=', 'OR')->where(')');
$db->setQuery($sql);
$result = $db->loadObjectList();
// Based on the element, we need to find the new id to map it to the rule
foreach ($result as $row) {
if (isset($rules[$row->element])) {
$table = FD::table('privacyitems');
$table->bind($row);
$table->privacy_id = $rules[$row->element]->id;
$table->store();
}
}
// field.datetime.year need to change to year
$sql->clear();
$sql->update('#__social_privacy_items')->set('type', 'year')->where('type', 'field.datetime.year');
$db->setQuery($sql);
$db->query();
return true;
}
示例6: create_report
public function create_report()
{
$app = JFactory::getApplication();
$msg = $app->input->get('message', '', 'STRING');
$title = $app->input->get('user_title', '', 'STRING');
$item_id = $app->input->get('itemId', 0, 'INT');
$log_user = $this->plugin->get('user')->id;
$data = array();
$data['message'] = $msg;
$data['uid'] = $item_id;
$data['type'] = 'stream';
$data['title'] = $title;
$data['extension'] = 'com_easysocial';
//build share url use for share post through app
$sharing = FD::get('Sharing', array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item_id, 'external' => true, 'xhtml' => true)), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small'));
$url = $sharing->url;
$data['url'] = $url;
// Get the reports model
$model = FD::model('Reports');
// Determine if this user has the permissions to submit reports.
$access = FD::access();
// Determine if this user has exceeded the number of reports that they can submit
$total = $model->getCount(array('created_by' => $log_user));
if ($access->exceeded('reports.limit', $total)) {
$final_result['message'] = "Limit exceeds";
$final_result['status'] = true;
return $final_result;
}
// Create the report
$report = FD::table('Report');
$report->bind($data);
// Set the creator id.
$report->created_by = $log_user;
// Set the default state of the report to new
$report->state = 0;
// Try to store the report.
$state = $report->store();
// If there's an error, throw it
if (!$state) {
$final_result['message'] = "Can't save report";
$final_result['status'] = true;
return $final_result;
}
// @badge: reports.create
// Add badge for the author when a report is created.
$badge = FD::badges();
$badge->log('com_easysocial', 'reports.create', $log_user, JText::_('COM_EASYSOCIAL_REPORTS_BADGE_CREATED_REPORT'));
// @points: reports.create
// Add points for the author when a report is created.
$points = FD::points();
$points->assign('reports.create', 'com_easysocial', $log_user);
// Determine if we should send an email
$config = FD::config();
if ($config->get('reports.notifications.moderators')) {
$report->notify();
}
$final_result['message'] = "Report logged successfully!";
$final_result['status'] = true;
return $final_result;
}
示例7: getResult
public function getResult($queries = array())
{
$this->setQueries($queries);
// There is 2 parts to this
// nearbysearch
// textsearch
$nearbysearchUrl = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json';
$textsearchUrl = 'https://maps.googleapis.com/maps/api/place/textsearch/json';
$nearbysearchOptions = array('location' => $this->queries['location'], 'radius' => $this->queries['radius'], 'key' => $this->queries['key'], 'keyword' => $this->queries['keyword']);
$textsearchOptions = array('query' => $this->queries['query'], 'key' => $this->queries['key']);
$connector = FD::connector();
$connector->setMethod('GET');
$connector->addUrl($nearbysearchUrl . '?' . http_build_query($nearbysearchOptions));
if (!empty($this->queries['query'])) {
$connector->addUrl($textsearchUrl . '?' . http_build_query($textsearchOptions));
}
$connector->execute();
$results = $connector->getResults();
$venues = array();
foreach ($results as $result) {
$obj = json_decode($result->contents);
foreach ($obj->results as $row) {
$obj = new SocialLocationData();
$obj->latitude = $row->geometry->location->lat;
$obj->longitude = $row->geometry->location->lng;
$obj->name = $row->name;
$obj->address = isset($row->formatted_address) ? $row->formatted_address : '';
$obj->fulladdress = !empty($obj->address) ? $obj->name . ', ' . $obj->address : '';
$venues[$row->id] = $obj;
}
}
$venues = array_values($venues);
return $venues;
}
示例8: 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');
}
示例9: fetch
/**
* Does a remote call to the server to fetch contents of a given url.
*
* @since 1.0
* @access public
*/
public function fetch()
{
// Check for request forgeries!
$urls = $this->input->get('urls', array(), 'array');
// Result placeholder
$result = array();
if (!$urls) {
$this->view->setMessage('COM_EASYSOCIAL_CRAWLER_INVALID_URL_PROVIDED', SOCIAL_MSG_ERROR);
return $this->view->call(__FUNCTION__);
}
// Get the crawler
$crawler = FD::get('crawler');
foreach ($urls as $url) {
// Generate a hash for the url
$hash = md5($url);
$link = FD::table('Link');
$exists = $link->load(array('hash' => $hash));
// If it doesn't exist, store it.
if (!$exists) {
$crawler->crawl($url);
// Get the data from our crawler library
$data = $crawler->getData();
// Now we need to cache the link so that the next time, we don't crawl it again.
$link->hash = $hash;
$link->data = json_encode($data);
$link->store();
}
$result[$url] = json_decode($link->data);
}
return $this->view->call(__FUNCTION__, $result);
}
示例10: load
public function load($path)
{
// Locate for the manifest file in the folder.
$files = FD::get('Folders')->files($path, '.xml', self::RECURSIVE_SEARCH, self::RETRIEVE_FULL_PATH);
$this->source = $path;
if (!count($files)) {
// Throw errors
FD::get('Errors')->set('installer.xml', self::XML_NOT_FOUND);
return false;
}
// Load through the list of manifest files to perform the installation.
foreach ($files as $file) {
$xml = JFactory::getXML($file);
if (!$xml) {
FD::get('Errors')->set('installer', self::XML_NOT_VALID);
unset($xml);
continue;
}
$this->type = (string) $xml->attributes()->type;
if ($xml->getName() != 'social' || !in_array($this->type, $this->allowed)) {
FD::get('Errors')->set('installer', self::XML_NOT_VALID);
unset($parser);
continue;
}
$this->parser = JFactory::getXMLParser('Simple');
$this->parser->loadFile($file);
// Set the path of the current xml file.
$this->path = $file;
// Retrieves the element
$this->element = $this->parser->document->getElementByPath('element')->data();
unset($xml);
return true;
}
return false;
}
示例11: 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)
{
$group = FD::group($uid);
$editor = JFactory::getEditor();
// Only allow group admin to create or edit news
if (!$group->isAdmin() && !$this->my->isSiteAdmin()) {
FD::info()->set(false, JText::_('COM_EASYSOCIAL_GROUPS_ONLY_MEMBER_ARE_ALLOWED'), SOCIAL_MSG_ERROR);
return $this->redirect($group->getPermalink(false));
}
$id = JRequest::getInt('newsId');
$news = FD::table('GroupNews');
$news->load($id);
FD::page()->title(JText::_('APP_GROUP_NEWS_FORM_UPDATE_PAGE_TITLE'));
// Determine if this is a new record or not
if (!$id) {
$news->comments = true;
FD::page()->title(JText::_('APP_GROUP_NEWS_FORM_CREATE_PAGE_TITLE'));
}
// Get app params
$params = $this->app->getParams();
$this->set('params', $params);
$this->set('news', $news);
$this->set('editor', $editor);
$this->set('group', $group);
echo parent::display('canvas/form');
}
示例12: 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);
}
示例13: getItems
public function getItems()
{
$db = FD::db();
$query = 'SELECT * FROM ' . $db->nameQuote('#__social_toolbar') . ' WHERE ' . $db->nameQuote('state') . '=' . $db->Quote(SOCIAL_STATE_PUBLISHED);
$db->setQuery($query);
return $db->loadObjectList();
}
示例14: onDisplay
public function onDisplay($user)
{
$regDate = FD::date($user->registerDate);
$format = 'd M Y';
switch ($this->params->get('date_format')) {
case 2:
case '2':
$format = 'M d Y';
break;
case 3:
case '3':
$format = 'Y d M';
break;
case 4:
case '4':
$format = 'Y M d';
break;
}
// linkage to advanced search page.
// place the code here so that the timezone wont kick in. we search the date using GMT value.
$field = $this->field;
if ($field->searchable) {
$date = $regDate->toFormat('Y-m-d');
$params = array('layout' => 'advanced');
$params['criterias[]'] = $field->unique_key . '|' . $field->element;
$params['operators[]'] = 'between';
$params['conditions[]'] = $date . ' 00:00:00' . '|' . $date . ' 23:59:59';
$advsearchLink = FRoute::search($params);
$this->set('advancedsearchlink', $advsearchLink);
}
$this->set('date', $regDate->toFormat($format));
return $this->display();
}
示例15: route
/**
* Redirects a notification item to the intended location
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function route()
{
// The user needs to be logged in to access notifications
FD::requireLogin();
// Check for user profile completeness
FD::checkCompleteProfile();
$id = JRequest::getInt('id');
$table = FD::table('Notification');
$table->load($id);
if (!$id || !$table->id) {
FD::info()->set(JText::_('COM_EASYSOCIAL_NOTIFICATIONS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
return $this->redirect(FRoute::dashboard(array(), false));
}
// Check if the user is allowed to view this notification item.
$my = FD::user();
if ($table->target_id != $my->id) {
FD::info()->set(JText::_('COM_EASYSOCIAL_NOTIFICATIONS_NOT_ALLOWED'), SOCIAL_MSG_ERROR);
return $this->redirect(FRoute::dashboard(array(), false));
}
// Mark the notification item as read
$table->markAsRead();
// Ensure that all & are replaced with &
$url = str_ireplace('&', '&', $table->url);
$this->redirect(FRoute::_($url, false));
$this->close();
}