本文整理汇总了PHP中FRoute::referer方法的典型用法代码示例。如果您正苦于以下问题:PHP FRoute::referer方法的具体用法?PHP FRoute::referer怎么用?PHP FRoute::referer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FRoute
的用法示例。
在下文中一共展示了FRoute::referer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: oauthDialog
/**
* This is the first entry point when the social site redirects back to this callback.
* It is responsible to close the popup and redirect to the appropriate url.
*
* @since 1.0
* @access public
*/
public function oauthDialog()
{
// Get allowed clients
$allowedClients = array_keys((array) $this->config->get('oauth'));
// Get the current client.
$oauthClient = $this->input->get('client', '', 'word');
if (!in_array($oauthClient, $allowedClients)) {
FD::info()->set(false, JText::sprintf('COM_EASYSOCIAL_OAUTH_INVALID_OAUTH_CLIENT_PROVIDED', $oauthClient), SOCIAL_MSG_ERROR);
return $this->redirect(FRoute::login(array(), false));
}
// Get the oauth client object.
$client = FD::oauth($oauthClient);
// Detect if the user has already registered with the site.
if ($client->isRegistered()) {
// We need to update the token
$client->updateToken();
$client->login();
// Determine which URL to redirect the user to based on the settings
$url = FRoute::getMenuLink($this->config->get('general.site.login'));
if ($url === false) {
// Default URL redirection
$url = FRoute::dashboard(array(), false);
// Determine if there a referer URL
$callback = FRoute::referer();
if ($callback) {
$url = $callback;
}
}
$redirect = $url;
} else {
// Get the access
$access = $client->getAccess();
// Set the access token on the session
$key = $oauthClient . '.token';
$session = JFactory::getSession();
$session->set($key, $access->token, SOCIAL_SESSION_NAMESPACE);
$redirect = FRoute::registration(array('layout' => 'oauth', 'client' => $oauthClient), false);
}
$this->set('redirect', $redirect);
parent::display('site/registration/oauth.popup');
}
示例2: requireLogin
/**
* Renders a login page if necessary. If this is called via an ajax method, it will trigger a dialog instead.
*
* @access public
* @param null
* @return string Contents.
*/
public static function requireLogin()
{
$document = JFactory::getDocument();
$my = FD::user();
if ($my->id > 0) {
return true;
}
switch ($document->getType()) {
case 'html':
// Do some redirects here?
$info = FD::info();
$message = new stdClass();
$message->message = JText::_('COM_EASYSOCIAL_PLEASE_LOGIN_FIRST');
$message->type = SOCIAL_MSG_INFO;
$info->set($message);
// Get the application framework.
$app = JFactory::getApplication();
// Get the current URI.
$callback = FRoute::current();
FD::setCallback($callback);
$url = FRoute::login(array(), false);
$app->redirect($url);
$app->close();
break;
case 'ajax':
$ajax = FD::ajax();
// Get the referer URI.
$callback = FRoute::referer();
if ($callback) {
FD::setCallback($callback);
}
$ajax->script('EasySocial.login();');
return $ajax->send();
break;
}
}