当前位置: 首页>>代码示例>>PHP>>正文


PHP Gdn_Controller::Data方法代码示例

本文整理汇总了PHP中Gdn_Controller::Data方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Controller::Data方法的具体用法?PHP Gdn_Controller::Data怎么用?PHP Gdn_Controller::Data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdn_Controller的用法示例。


在下文中一共展示了Gdn_Controller::Data方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: EntryController_Render_Before

 /**
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function EntryController_Render_Before($Sender, $Args)
 {
     if ($Sender->RequestMethod != 'passwordreset') {
         return;
     }
     if (isset($Sender->Data['User'])) {
         // Get all of the users with the same email.
         $Email = $Sender->Data('User.Email');
         $Users = Gdn::SQL()->Select('Name')->From('User')->Where('Email', $Email)->Get()->ResultArray();
         $Names = array_column($Users, 'Name');
         SetValue('Name', $Sender->Data['User'], implode(', ', $Names));
     }
 }
开发者ID:vanilla,项目名称:addons,代码行数:17,代码来源:class.emailpasswordsync.plugin.php

示例2: PostController_AfterDiscussionFormOptions_Handler

 /**
  * Add the tag input to the discussion form.
  * @param Gdn_Controller $Sender
  */
 public function PostController_AfterDiscussionFormOptions_Handler($Sender)
 {
     if (in_array($Sender->RequestMethod, array('discussion', 'editdiscussion', 'question'))) {
         // Setup, get most popular tags
         $TagModel = TagModel::instance();
         $Tags = $TagModel->GetWhere(array('Type' => array_keys($TagModel->defaultTypes())), 'CountDiscussions', 'desc', C('Plugins.Tagging.ShowLimit', 50))->Result(DATASET_TYPE_ARRAY);
         $TagsHtml = count($Tags) ? '' : T('No tags have been created yet.');
         $Tags = Gdn_DataSet::Index($Tags, 'FullName');
         ksort($Tags);
         // The tags must be fetched.
         if ($Sender->Request->IsPostBack()) {
             $tag_ids = TagModel::SplitTags($Sender->Form->GetFormValue('Tags'));
             $tags = TagModel::instance()->GetWhere(array('TagID' => $tag_ids))->ResultArray();
             $tags = ConsolidateArrayValuesByKey($tags, 'FullName', 'TagID');
         } else {
             // The tags should be set on the data.
             $tags = ConsolidateArrayValuesByKey($Sender->Data('Tags', array()), 'TagID', 'FullName');
             $xtags = $Sender->Data('XTags', array());
             foreach (TagModel::instance()->defaultTypes() as $key => $row) {
                 if (isset($xtags[$key])) {
                     $xtags2 = ConsolidateArrayValuesByKey($xtags[$key], 'TagID', 'FullName');
                     foreach ($xtags2 as $id => $name) {
                         $tags[$id] = $name;
                     }
                 }
             }
         }
         echo '<div class="Form-Tags P">';
         // Tag text box
         echo $Sender->Form->Label('Tags', 'Tags');
         echo $Sender->Form->TextBox('Tags', array('data-tags' => json_encode($tags)));
         // Available tags
         echo Wrap(Anchor(T('Show popular tags'), '#'), 'span', array('class' => 'ShowTags'));
         foreach ($Tags as $Tag) {
             $TagsHtml .= Anchor(htmlspecialchars($Tag['FullName']), '#', 'AvailableTag', array('data-name' => $Tag['Name'], 'data-id' => $Tag['TagID'])) . ' ';
         }
         echo Wrap($TagsHtml, 'div', array('class' => 'Hidden AvailableTags'));
         echo '</div>';
     }
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:44,代码来源:class.tagging.plugin.php

示例3: ProfileController_AddProfileTabs_Handler

 /**
  * Handling the event fired at the end of the BuildProfile method of the Profile controller
  * If a valid Steam ID is found, load the profile and add it to the profile sidebar.
  * If no valid Steam ID is found, do nothing.
  *
  * @param Gdn_Controller $Sender
  */
 public function ProfileController_AddProfileTabs_Handler(&$Sender)
 {
     // Instantiating our SteamProfile model and attempting to retrieve the profile data
     $this->SteamProfileModel = new SteamProfileModel();
     // Rustling up the SteamID64 data associated with the user, if available
     $UserMetaSteamID64 = $this->GetUserMeta($Sender->User->UserID, 'SteamID64');
     $SteamID64 = GetValue('Plugin.steamprofile.SteamID64', $UserMetaSteamID64, '');
     // Attempting to retrieve the profile data associated with the SteamID64 field
     $Sender->SetData('SteamProfile', $this->SteamProfileModel->GetByID($SteamID64));
     // Did we get back a valid profile?
     if ($Sender->Data('SteamProfile', FALSE)) {
         // Is there a record(s) for this user's "Most Played Games"?
         if (isset($Sender->Data('SteamProfile')->mostPlayedGames->mostPlayedGame)) {
             // If there are several results, there will be an array of elements.  Is there an array of elements?
             if (is_array($Sender->Data('SteamProfile')->mostPlayedGames->mostPlayedGame)) {
                 //  ...if so, grab the first one.
                 $Sender->SetData('MostPlayedGame', $Sender->Data('SteamProfile')->mostPlayedGames->mostPlayedGame[0]);
             } else {
                 // ...if not, grab the single element.
                 $Sender->SetData('MostPlayedGame', $Sender->Data('SteamProfile')->mostPlayedGames->mostPlayedGame);
             }
         }
         // Attach the style sheet, load up the view, attach it all to the panel
         $Sender->AddCssFile('style.css', 'plugins/steamprofile');
         $Sender->AddAsset('Panel', $Sender->FetchView($this->GetView('panel.php')), 'Steam');
     }
 }
开发者ID:29th,项目名称:VanillaAddons,代码行数:34,代码来源:class.steamprofile.plugin.php

示例4: Base_Render_Before

 /**
  *
  * @param Gdn_Controller $Sender
  */
 public function Base_Render_Before($Sender)
 {
     $Session = Gdn::Session();
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewThemeName = $Session->GetPreference('PreviewThemeName', '');
         $PreviewThemeFolder = $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()) {
         $ConfirmEmail = C('Garden.Registration.ConfirmEmail', false);
         $Confirmed = GetValue('Confirmed', Gdn::Session()->User, true);
         if ($ConfirmEmail && !$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]');
     // 2011-09-09 - mosullivan - No longer allowing messages in dashboard
     //		if ($Sender->MasterView == 'admin')
     //			$Exceptions[] = '[Admin]';
     //		else if (in_array($Sender->MasterView, array('', 'default')))
     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') && (GetValue('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);
         }
         // Force embedding?
         if (!IsSearchEngine() && !IsMobile() && strtolower($Sender->ControllerName) != 'entry') {
             $Sender->AddDefinition('ForceEmbedForum', C('Garden.Embed.ForceForum') ? '1' : '0');
             $Sender->AddDefinition('ForceEmbedDashboard', C('Garden.Embed.ForceDashboard') ? '1' : '0');
         }
         $Sender->AddDefinition('Path', Gdn::Request()->Path());
         // $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');
     }
     // Allow return to mobile site
     $ForceNoMobile = Gdn_CookieIdentity::GetCookiePayload('VanillaNoMobile');
     if ($ForceNoMobile !== FALSE && is_array($ForceNoMobile) && in_array('force', $ForceNoMobile)) {
         $Sender->AddAsset('Foot', Wrap(Anchor(T('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink');
     }
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:94,代码来源:class.hooks.php

示例5: Base_Render_Before

 /**
  *
  * @param Gdn_Controller $Sender
  */
 public function Base_Render_Before($Sender)
 {
     $Session = Gdn::Session();
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewThemeName = $Session->GetPreference('PreviewThemeName', '');
         $PreviewThemeFolder = $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() && ($EmailKey = Gdn::Session()->GetAttribute('EmailKey'))) {
         $NotifyEmailConfirm = TRUE;
         // If this user was manually moved out of the confirmation role, get rid of their 'awaiting confirmation' flag
         $ConfirmEmailRole = C('Garden.Registration.ConfirmEmailRole', FALSE);
         $UserRoles = array();
         $RoleData = Gdn::UserModel()->GetRoles($Session->UserID);
         if ($RoleData !== FALSE && $RoleData->NumRows() > 0) {
             $UserRoles = ConsolidateArrayValuesByKey($RoleData->Result(DATASET_TYPE_ARRAY), 'RoleID', 'Name');
         }
         if ($ConfirmEmailRole !== FALSE && !array_key_exists($ConfirmEmailRole, $UserRoles)) {
             Gdn::UserModel()->SaveAttribute($Session->UserID, "EmailKey", NULL);
             $NotifyEmailConfirm = FALSE;
         }
         if ($NotifyEmailConfirm) {
             $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]');
     // 2011-09-09 - mosullivan - No longer allowing messages in dashboard
     //		if ($Sender->MasterView == 'admin')
     //			$Exceptions[] = '[Admin]';
     //		else if (in_array($Sender->MasterView, array('', 'default')))
     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') && (GetValue('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache))) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions);
         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.
     }
     // 2012-07-18 - This is handled by the mebox now.
     // If there are applicants, alert admins by showing in the main menu
     // if (in_array($Sender->MasterView, array('', 'default')) && $Sender->Menu && C('Garden.Registration.Method') == 'Approval') {
     // $CountApplicants = Gdn::UserModel()->GetApplicantCount();
     // if ($CountApplicants > 0)
     // $Sender->Menu->AddLink('Applicants', T('Applicants').' <span class="Alert">'.$CountApplicants.'</span>', '/dashboard/user/applicants', array('Garden.Applicants.Manage'));
     // $Sender->Menu->AddLink('Applicants', T('Applicants'), '/dashboard/user/applicants', array('Garden.Applicants.Manage'));
     // }
     if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
         $Gdn_Statistics = Gdn::Factory('Statistics');
         $Gdn_Statistics->Check($Sender);
     }
     // Allow forum embedding
     if (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);
         }
         // Force embedding?
         if (!IsSearchEngine() && !IsMobile()) {
             $Sender->AddDefinition('ForceEmbedForum', C('Garden.Embed.ForceForum') ? '1' : '0');
             $Sender->AddDefinition('ForceEmbedDashboard', C('Garden.Embed.ForceDashboard') ? '1' : '0');
         }
         $Sender->AddDefinition('Path', Gdn::Request()->Path());
         // $Sender->AddDefinition('MasterView', $Sender->MasterView);
         $Sender->AddDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
         $Sender->AddJsFile('js/embed_local.js');
     }
//.........这里部分代码省略.........
开发者ID:robhazkes,项目名称:Garden,代码行数:101,代码来源:class.hooks.php


注:本文中的Gdn_Controller::Data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。