本文整理汇总了PHP中FD::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::getInstance方法的具体用法?PHP FD::getInstance怎么用?PHP FD::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: delete
/**
* Delete's the location from the database.
*
* @since 1.0
* @access public
*/
public function delete()
{
// Check for valid token
FD::checkToken();
// Guest users shouldn't be allowed to delete any location at all.
FD::requireLogin();
$my = FD::user();
$id = JRequest::getInt('id');
$view = FD::getInstance('View', 'Location', false);
$location = FD::table('Location');
$location->load($id);
// If id is invalid throw errors.
if (!$location->id) {
$view->setErrors(JText::_('COM_EASYSOCIAL_LOCATION_INVALID_ID'));
}
// If user do not own item, throw errors.
if ($my->id !== $location->user_id) {
$view->setErrors(JText::_('COM_EASYSOCIAL_LOCATION_ERROR_YOU_ARE_NOT_OWNER'));
}
// Try to delete location.
if (!$location->delete()) {
$view->setErrors($location->getError());
}
return $view->delete();
}
示例3: deleteFilter
public function deleteFilter()
{
// Check for request forgeries.
FD::checkToken();
// In order to access the dashboard apps, user must be logged in.
FD::requireLogin();
$view = FD::view('Stream', false);
$my = FD::user();
$id = JRequest::getInt('id', 0);
if (!$id) {
FD::getInstance('Info')->set(JText::_('Invalid filter id - ' . $id), 'error');
$view->setError(JText::_('Invalid filter id.'));
return $view->call(__FUNCTION__);
}
$filter = FD::table('StreamFilter');
// make sure the user is the filter owner before we delete.
$filter->load(array('id' => $id, 'uid' => $my->id, 'utype' => 'user'));
if (!$filter->id) {
FD::getInstance('Info')->set(JText::_('Filter not found - ' . $id), 'error');
$view->setError(JText::_('Filter not found. Action aborted.'));
return $view->call(__FUNCTION__);
}
$filter->deleteItem();
$filter->delete();
$view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_FILTER_DELETED'), SOCIAL_MSG_SUCCESS);
return $view->call(__FUNCTION__);
}
示例4: load
/**
* Loads a set of configuration given the type.
*
* @since 1.0
* @access public
* @param string The unique type of configuration.
* @return
*/
public function load($key)
{
// Specifically if the key is 'joomla' , we only want to use JConfig.
if ($key == 'joomla') {
$codeName = FD::getInstance('Version')->getCodeName();
$helper = dirname(__FILE__) . '/helpers/' . $codeName . '.php';
require_once $helper;
$className = 'SocialConfig' . $codeName;
$config = new $className();
} else {
// Object construct happens here
$default = SOCIAL_ADMIN . '/defaults/' . $key . '.json';
$defaultData = '';
// Read the default data.
$defaultData = JFile::read($default);
$json = FD::json();
// Load a new copy of Registry
$config = FD::registry($defaultData);
if (!defined('SOCIAL_COMPONENT_CLI')) {
// @task: Now we need to get the user defined configuration that is stored in the database.
$model = FD::model('Config');
$storedConfig = $model->getConfig($key);
// Get stored config
if ($storedConfig) {
$storedConfig = FD::registry($storedConfig->value);
// Merge configurations
$config->mergeObjects($storedConfig->getRegistry());
}
}
}
$this->configs[$key] = $config;
}
示例5: archive
public function archive()
{
$errors = $this->getErrors();
// @TODO: Process errors here.
if ($errors) {
}
FD::getInstance('AJAX')->success();
}
示例6: __construct
public function __construct()
{
$version = FD::getInstance('Version');
$name = $version->getCodeName();
$name = strtolower($name);
require_once dirname(__FILE__) . '/helpers/' . $name . '.php';
$className = 'SocialInstallerHelper' . ucfirst($name);
$this->helper = new $className();
}
示例7: __construct
public function __construct()
{
$codeName = FD::getInstance('Version')->getCodeName();
$fileName = strtolower($codeName);
$helperFile = dirname(__FILE__) . '/helpers/' . $fileName . '.php';
require_once $helperFile;
$className = 'SocialDBHelper' . ucfirst($codeName);
$this->db = new $className();
}
示例8: renderBookmark
/**
* Obtains the application output when a user clicks on a bookmark item.
*
* @since 1.0
* @access public
* @param
*
* @return
*/
public function renderBookmark()
{
$id = JRequest::getInt('id');
$app = FD::table('Application');
$app->load($id);
$lib = FD::getInstance('Apps');
$output = $lib->render('bookmark', $app->element, $app->group);
// Return the JSON output.
$ajax = FD::getInstance('Ajax');
$ajax->success($output);
}
示例9: initScripts
/**
* Initializes javascript on the head of the page.
*
* @since 1.0
* @access public
*/
public function initScripts()
{
if (self::$scriptsLoaded) {
return;
}
$configuration = FD::getInstance('Configuration');
$configuration->attach();
// TODO: Find a better place to define map language code this.
$document = JFactory::getDocument();
$document->addCustomTag('<meta name="foundry:location:language" content="' . FD::config()->get('general.location.language', 'en') . '" />');
self::$scriptsLoaded = true;
}
示例10: __construct
/**
* Class constructor
*
* @since 1.0
* @access public
* @param null
*/
public function __construct()
{
// Determine the code name
$name = FD::getInstance('Version')->getCodename();
$file = dirname(__FILE__) . '/helpers/' . strtolower($name) . '.php';
// If helper is not exist, we need to prevent any fatal errors.
if (!JFile::exists($file)) {
return;
}
require_once $file;
$className = 'SocialParser' . ucfirst($name);
$this->helper = new $className();
}
示例11: __construct
/**
* Class constructor
*
* @since 1.0
* @access public
* @param string The registry's raw data.
*/
public function __construct($data = '')
{
// Load our helpers
$name = FD::getInstance('Version')->getCodename();
$path = dirname(__FILE__) . '/helpers/' . $name . '.php';
require_once $path;
$className = 'SocialRegistry' . ucfirst($name);
$this->helper = new $className('');
// Always use our own load methods.
if (!empty($data)) {
$this->load($data);
}
return $this;
}
示例12: getAppContents
/**
* Responsible to output the application contents.
*
* @since 1.0
* @access public
* @param SocialAppTable The application ORM.
*/
public function getAppContents($app)
{
$ajax = FD::ajax();
// If there's an error throw it back to the caller.
if ($this->hasErrors()) {
return $ajax->reject($this->getMessage());
}
// Get the current logged in user.
$my = FD::user();
// Load the library.
$lib = FD::getInstance('Apps');
$contents = $lib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'dashboard', $app, array('userId' => $my->id));
// Return the contents
return $ajax->resolve($contents);
}
示例13: getFields
/**
* Retrieves a list of custom fields on the site.
*
* @since 1.0
* @access public
*/
public function getFields()
{
$lib = FD::fields();
// TODO: Enforce that group be a type of user , groups only.
$group = JRequest::getWord('group', SOCIAL_FIELDS_GROUP_USER);
// Get a list of fields
$model = FD::model('Apps');
$fields = $model->getApps(array('type' => SOCIAL_APPS_TYPE_FIELDS));
// We might need this? Not sure.
$data = array();
// Trigger: onSample
$lib->trigger('onSample', $group, $fields, $data);
// Once done, pass this back to the view.
$view = FD::getInstance('View', 'Fields');
$view->call(__FUNCTION__, $fields);
}
示例14: load
public function load($contents = '', $isFile = false)
{
$this->version = FD::getInstance('version')->getVersion();
$parser = '';
if ($this->version >= '3.0') {
$parser = JFactory::getXML($contents, $isFile);
} else {
$parser = JFactory::getXMLParser('Simple');
if ($isFile) {
$parser->loadFile($contents);
} else {
$parser->loadString($contents);
}
}
$this->parser = $parser;
return $this->parser;
}
示例15: attach
/**
* Attaches stylesheet on the site.
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function attach($minified = null, $allowOverride = true)
{
// Get configuration
$config = FD::getInstance('Configuration');
$environment = $config->environment;
$mode = $config->mode;
// If caller did not specify whether or not
// to attach compressed stylesheets.
if (is_null($minified)) {
// Then decide from configuration mode
$minified = $mode == 'compressed';
}
// Default settings
$build = false;
// If we're in a development environment,
// always cache compile stylesheet and
// attached uncompressed stylesheets.
if ($environment == 'development') {
$build = true;
// Never attached minified stylesheet while in development mode.
$minified = false;
// Only super developers can build admin stylesheets.
if ($this->location == 'admin') {
$build = false;
}
// Do not build if stylesheet has not been compiled before.
$cacheFolder = $this->folder('cache');
if (!JFolder::exists($cacheFolder)) {
$build = false;
}
// Always build for superdevs
$super = FD::config()->get('general.super');
if ($super) {
$build = true;
}
}
// Rebuild stylesheet on page load if necessary
if ($build) {
$task = $this->build($environment);
// This generates build log in the browser console.
$script = FD::script();
$script->set('task', $task);
$script->attach('themes:/admin/stylesheet/log');
}
parent::attach($minified, $allowOverride);
}