本文整理汇总了PHP中Gdn_Controller::deliveryType方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Controller::deliveryType方法的具体用法?PHP Gdn_Controller::deliveryType怎么用?PHP Gdn_Controller::deliveryType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Controller
的用法示例。
在下文中一共展示了Gdn_Controller::deliveryType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: base_connectData_handler
/**
*
* @param Gdn_Controller $Sender
* @param array $Args
*/
public function base_connectData_handler($Sender, $Args)
{
if (val(0, $Args) != 'facebook') {
return;
}
if (isset($_GET['error'])) {
// TODO global nope x2
throw new Gdn_UserException(val('error_description', $_GET, t('There was an error connecting to Facebook')));
}
$AppID = c('Plugins.Facebook.ApplicationID');
$Secret = c('Plugins.Facebook.Secret');
$Code = val('code', $_GET);
// TODO nope
$Query = '';
if ($Sender->Request->get('display')) {
$Query = 'display=' . urlencode($Sender->Request->get('display'));
}
$RedirectUri = concatSep('&', $this->redirectUri(), $Query);
$AccessToken = $Sender->Form->getFormValue('AccessToken');
// Get the access token.
if (!$AccessToken && $Code) {
// Exchange the token for an access token.
$Code = urlencode($Code);
$AccessToken = $this->getAccessToken($Code, $RedirectUri);
$NewToken = true;
}
// Get the profile.
try {
$Profile = $this->getProfile($AccessToken);
} catch (Exception $Ex) {
if (!isset($NewToken)) {
// There was an error getting the profile, which probably means the saved access token is no longer valid. Try and reauthorize.
if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
redirect($this->authorizeUri());
} else {
$Sender->setHeader('Content-type', 'application/json');
$Sender->deliveryMethod(DELIVERY_METHOD_JSON);
$Sender->RedirectUrl = $this->authorizeUri();
}
} else {
$Sender->Form->addError('There was an error with the Facebook connection.');
}
}
$Form = $Sender->Form;
//new Gdn_Form();
$ID = val('id', $Profile);
$Form->setFormValue('UniqueID', $ID);
$Form->setFormValue('Provider', self::ProviderKey);
$Form->setFormValue('ProviderName', 'Facebook');
$Form->setFormValue('FullName', val('name', $Profile));
$Form->setFormValue('Email', val('email', $Profile));
$Form->setFormValue('Photo', "//graph.facebook.com/{$ID}/picture?width=200&height=200");
$Form->addHidden('AccessToken', $AccessToken);
if (c('Plugins.Facebook.UseFacebookNames')) {
$Form->setFormValue('Name', val('name', $Profile));
saveToConfig(array('Garden.User.ValidationRegex' => UserModel::USERNAME_REGEX_MIN, 'Garden.User.ValidationLength' => '{3,50}', 'Garden.Registration.NameUnique' => false), '', false);
}
// Save some original data in the attributes of the connection for later API calls.
$Attributes = array();
$Attributes[self::ProviderKey] = array('AccessToken' => $AccessToken, 'Profile' => $Profile);
$Form->setFormValue('Attributes', $Attributes);
$Sender->setData('Verified', true);
}
示例2: settingsController_analyticsTick_create
/**
*
* @param Gdn_Controller $Sender
*/
public function settingsController_analyticsTick_create($Sender)
{
$Sender->deliveryMethod(DELIVERY_METHOD_JSON);
$Sender->deliveryType(DELIVERY_TYPE_DATA);
Gdn::statistics()->tick();
$this->fireEvent("AnalyticsTick");
$Sender->render();
}
示例3: base_connectData_handler
/**
*
*
* @param Gdn_Controller $Sender
* @param array $Args
*/
public function base_connectData_handler($Sender, $Args)
{
if (val(0, $Args) != 'twitter') {
return;
}
$Form = $Sender->Form;
//new Gdn_Form();
$RequestToken = val('oauth_token', $_GET);
$AccessToken = $Form->getFormValue('AccessToken');
if ($AccessToken) {
$AccessToken = $this->getOAuthToken($AccessToken);
$this->accessToken($AccessToken);
}
// Get the access token.
if ($RequestToken && !$AccessToken) {
// Get the request secret.
$RequestToken = $this->getOAuthToken($RequestToken);
$Consumer = new OAuthConsumer(c('Plugins.Twitter.ConsumerKey'), c('Plugins.Twitter.Secret'));
$Url = 'https://api.twitter.com/oauth/access_token';
$Params = array('oauth_verifier' => val('oauth_verifier', $_GET));
$Request = OAuthRequest::from_consumer_and_token($Consumer, $RequestToken, 'POST', $Url, $Params);
$SignatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
$Request->sign_request($SignatureMethod, $Consumer, $RequestToken);
$Post = $Request->to_postdata();
$Curl = $this->_Curl($Request);
$Response = curl_exec($Curl);
if ($Response === false) {
$Response = curl_error($Curl);
}
$HttpCode = curl_getinfo($Curl, CURLINFO_HTTP_CODE);
curl_close($Curl);
if ($HttpCode == '200') {
$Data = OAuthUtil::parse_parameters($Response);
$AccessToken = new OAuthToken(val('oauth_token', $Data), val('oauth_token_secret', $Data));
// Save the access token to the database.
$this->setOAuthToken($AccessToken->key, $AccessToken->secret, 'access');
$this->accessToken($AccessToken->key, $AccessToken->secret);
// Delete the request token.
$this->deleteOAuthToken($RequestToken);
} else {
// There was some sort of error.
throw new Exception('There was an error authenticating with twitter.', 400);
}
$NewToken = true;
}
// Get the profile.
try {
$Profile = $this->getProfile($AccessToken);
} catch (Exception $Ex) {
if (!isset($NewToken)) {
// There was an error getting the profile, which probably means the saved access token is no longer valid. Try and reauthorize.
if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
redirect($this->_AuthorizeHref());
} else {
$Sender->setHeader('Content-type', 'application/json');
$Sender->deliveryMethod(DELIVERY_METHOD_JSON);
$Sender->RedirectUrl = $this->_authorizeHref();
}
} else {
throw $Ex;
}
}
$ID = val('id', $Profile);
$Form->setFormValue('UniqueID', $ID);
$Form->setFormValue('Provider', self::ProviderKey);
$Form->setFormValue('ProviderName', 'Twitter');
$Form->setValue('ConnectName', val('screen_name', $Profile));
$Form->setFormValue('Name', val('screen_name', $Profile));
$Form->setFormValue('FullName', val('name', $Profile));
$Form->setFormValue('Photo', val('profile_image_url_https', $Profile));
$Form->addHidden('AccessToken', $AccessToken->key);
// Save some original data in the attributes of the connection for later API calls.
$Attributes = array(self::ProviderKey => array('AccessToken' => array($AccessToken->key, $AccessToken->secret), 'Profile' => $Profile));
$Form->setFormValue('Attributes', $Attributes);
$Sender->setData('Verified', true);
}
示例4: base_render_before
/**
* Fire before every page render.
*
* @param Gdn_Controller $Sender
*/
public function base_render_before($Sender)
{
$Session = Gdn::session();
// Check the statistics.
if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
Gdn::statistics()->check();
}
// Enable theme previewing
if ($Session->isValid()) {
$PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', ''));
$PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', ''));
if ($PreviewThemeName != '') {
$Sender->Theme = $PreviewThemeName;
$Sender->informMessage(sprintf(t('You are previewing the %s theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/', 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
}
}
if ($Session->isValid()) {
$Confirmed = val('Confirmed', Gdn::session()->User, true);
if (UserModel::requireConfirmEmail() && !$Confirmed) {
$Message = formatString(t('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
$Sender->informMessage($Message, '');
}
}
// Add Message Modules (if necessary)
$MessageCache = Gdn::config('Garden.Messages.Cache', array());
$Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
$Exceptions = array('[Base]');
if (in_array($Sender->MasterView, array('', 'default'))) {
$Exceptions[] = '[NonAdmin]';
}
// SignIn popup is a special case
$SignInOnly = $Sender->deliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
if ($SignInOnly) {
$Exceptions = array();
}
if ($Sender->MasterView != 'admin' && !$Sender->data('_NoMessages') && (val('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, false) || InArrayI($Location, $MessageCache))) {
$MessageModel = new MessageModel();
$MessageData = $MessageModel->getMessagesForLocation($Location, $Exceptions, $Sender->data('Category.CategoryID'));
foreach ($MessageData as $Message) {
$MessageModule = new MessageModule($Sender, $Message);
if ($SignInOnly) {
// Insert special messages even in SignIn popup
echo $MessageModule;
} elseif ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
$Sender->addModule($MessageModule);
}
}
$Sender->MessagesLoaded = '1';
// Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
}
if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
$Gdn_Statistics = Gdn::factory('Statistics');
$Gdn_Statistics->check($Sender);
}
// Allow forum embedding
if ($Embed = c('Garden.Embed.Allow')) {
// Record the remote url where the forum is being embedded.
$RemoteUrl = c('Garden.Embed.RemoteUrl');
if (!$RemoteUrl) {
$RemoteUrl = GetIncomingValue('remote');
if ($RemoteUrl) {
saveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl);
}
}
if ($RemoteUrl) {
$Sender->addDefinition('RemoteUrl', $RemoteUrl);
}
if ($remoteUrlFormat = c('Garden.Embed.RemoteUrlFormat')) {
$Sender->addDefinition('RemoteUrlFormat', $remoteUrlFormat);
}
// Force embedding?
if (!IsSearchEngine() && strtolower($Sender->ControllerName) != 'entry') {
if (IsMobile()) {
$forceEmbedForum = c('Garden.Embed.ForceMobile') ? '1' : '0';
} else {
$forceEmbedForum = c('Garden.Embed.ForceForum') ? '1' : '0';
}
$Sender->addDefinition('ForceEmbedForum', $forceEmbedForum);
$Sender->addDefinition('ForceEmbedDashboard', c('Garden.Embed.ForceDashboard') ? '1' : '0');
}
$Sender->addDefinition('Path', Gdn::request()->path());
$get = Gdn::request()->get();
unset($get['p']);
// kludge for old index.php?p=/path
$Sender->addDefinition('Query', http_build_query($get));
// $Sender->addDefinition('MasterView', $Sender->MasterView);
$Sender->addDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
if ($Embed === 2) {
$Sender->addJsFile('vanilla.embed.local.js');
} else {
$Sender->addJsFile('embed_local.js');
}
} else {
$Sender->setHeader('X-Frame-Options', 'SAMEORIGIN');
}
//.........这里部分代码省略.........