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


PHP InArrayI函数代码示例

本文整理汇总了PHP中InArrayI函数的典型用法代码示例。如果您正苦于以下问题:PHP InArrayI函数的具体用法?PHP InArrayI怎么用?PHP InArrayI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: Base_Render_Before

 public function Base_Render_Before(&$Sender)
 {
     $ConfigItem = C('WhosOnline.Location.Show', 'every');
     $Controller = $Sender->ControllerName;
     $Application = $Sender->ApplicationFolder;
     $Session = Gdn::Session();
     // Check if its visible to users
     if (C('WhosOnline.Hide', TRUE) && !$Session->IsValid()) {
         return;
     }
     $ShowOnController = array();
     switch ($ConfigItem) {
         case 'every':
             $ShowOnController = array('discussioncontroller', 'categoriescontroller', 'discussionscontroller', 'profilecontroller', 'activitycontroller');
             break;
         case 'discussion':
         default:
             $ShowOnController = array('discussioncontroller', 'discussionscontroller', 'categoriescontroller');
     }
     if (!InArrayI($Controller, $ShowOnController)) {
         return;
     }
     $UserMetaData = $this->GetUserMeta($Session->UserID, '%');
     include_once PATH_PLUGINS . DS . 'WhosOnline' . DS . 'class.whosonlinemodule.php';
     $WhosOnlineModule = new WhosOnlineModule($Sender);
     $WhosOnlineModule->GetData(ArrayValue('Plugin.WhosOnline.Invisible', $UserMetaData));
     $Sender->AddModule($WhosOnlineModule);
     $Sender->AddJsFile('/plugins/WhosOnline/whosonline.js');
     $Frequency = C('WhosOnline.Frequency', 4);
     if (!is_numeric($Frequency)) {
         $Frequency = 4;
     }
     $Sender->AddDefinition('WhosOnlineFrequency', $Frequency);
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:34,代码来源:default.php

示例2: Base_Render_Before

 public function Base_Render_Before(&$Sender)
 {
     $Session = Gdn::Session();
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
         // echo 'test'.$PreviewThemeFolder;
         if ($PreviewThemeFolder != '') {
             $Sender->Theme = $PreviewThemeFolder;
             $Sender->AddAsset('Content', $Sender->FetchView('previewtheme', 'settingscontroller', 'dashboard'));
             $Sender->AddCssFile('previewtheme.css');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::Config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     if ($Sender->MasterView != 'empty' && in_array('Base', $MessageCache) || InArrayI($Location, $MessageCache)) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->GetMessagesForLocation($Location);
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             $Sender->AddModule($MessageModule);
         }
     }
 }
开发者ID:sheldon,项目名称:Garden,代码行数:25,代码来源:class.hooks.php

示例3: Base_Render_Before

 public function Base_Render_Before(&$Sender)
 {
     $Controller = $Sender->ControllerName;
     if (!InArrayI($Controller, array('categoriescontroller', 'discussioncontroller', 'discussionscontroller', 'messagescontroller', 'profilecontroller'))) {
         return;
     }
     $RecentActivityModule = new RecentActivityModule($Sender);
     $RecentActivityModule->GetData(10);
     $Sender->addModule($RecentActivityModule);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:10,代码来源:default.php

示例4: Base_Render_Before

 public function Base_Render_Before($Sender)
 {
     $Controller = $Sender->ControllerName;
     $ShowOnController = array('discussioncontroller', 'categoriescontroller', 'discussionscontroller', 'profilecontroller', 'activitycontroller');
     if (!InArrayI($Controller, $ShowOnController)) {
         return;
     }
     $Sender->AddCssFile('forumdonate.css', 'plugins/ForumDonate');
     $ForumDonateModule = new ForumDonateModule($Sender);
     $Sender->AddModule($ForumDonateModule);
 }
开发者ID:Nordic-T,项目名称:Nordic-T,代码行数:11,代码来源:default.php

示例5: Base_Render_Before

 /**
  * Call in module here, to have it placed in the panel on every page that 
  * has the panel area. No need to create custom controllers, so this is 
  * good enough for the task. 
  */
 public function Base_Render_Before(&$Sender)
 {
     $Session = Gdn::Session();
     $Controller = $Sender->ControllerName;
     // Only show on these pages
     $ShowOnController = array('discussioncontroller', 'categoriescontroller', 'discussionscontroller', 'profilecontroller', 'activitycontroller');
     // Only display this info to signed in members.
     if ($Session->IsValid() && InArrayI($Controller, $ShowOnController)) {
         $Sender->AddCssFile($this->GetResource('design/countriesonline.css', FALSE, FALSE));
         include_once PATH_PLUGINS . DS . 'CountriesOnline' . DS . 'class.countriesonlinemodule.php';
         $CountriesOnlineModule = new CountriesOnlineModule($Sender);
         $time_threshold = C('Plugin.CountriesOnline.TimeThreshold', $this->default_time_threshold);
         $CountriesOnlineModule->GetData($time_threshold);
         $Sender->AddModule($CountriesOnlineModule);
     }
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:21,代码来源:default.php

示例6: Base_Render_Before

 public function Base_Render_Before(&$Sender)
 {
     // Add menu items.
     $Session = Gdn::Session();
     if ($Sender->Menu) {
         $Sender->Menu->AddLink('Dashboard', 'Dashboard', '/garden/settings', array('Garden.Settings.Manage'));
         $Sender->Menu->AddLink('Dashboard', 'Users', '/user/browse', array('Garden.Users.Add', 'Garden.Users.Edit', 'Garden.Users.Delete'));
         $Sender->Menu->AddLink('Activity', 'Activity', '/activity');
         $Authenticator = Gdn::Authenticator();
         if ($Session->IsValid()) {
             $Sender->Menu->AddLink('SignOut', 'Sign Out', '/entry/leave/{Session_TransientKey}', FALSE, array('class' => 'NonTab'));
             $Notifications = Gdn::Translate('Notifications');
             $CountNotifications = $Session->User->CountNotifications;
             if (is_numeric($CountNotifications) && $CountNotifications > 0) {
                 $Notifications .= '<span>' . $CountNotifications . '</span>';
             }
             $Sender->Menu->AddLink('User', '{Username}', '/profile/{Username}', array('Garden.SignIn.Allow'));
             $Sender->Menu->AddLink('User', '\\' . $Notifications, 'profile/notifications/{Username}');
         } else {
             $Sender->Menu->AddLink('Entry', 'Sign In', $Authenticator->SignInUrl());
         }
     }
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewTheme = $Session->GetPreference('PreviewTheme', '');
         if ($PreviewTheme != '') {
             $Sender->Theme = $PreviewTheme;
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::Config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     if (in_array('Base', $MessageCache) || InArrayI($Location, $MessageCache)) {
         $MessageModel = new Gdn_MessageModel();
         $MessageData = $MessageModel->GetMessagesForLocation($Location);
         foreach ($MessageData as $Message) {
             $MessageModule = new Gdn_MessageModule($Sender, $Message);
             $Sender->AddModule($MessageModule);
         }
     }
 }
开发者ID:Valooo,项目名称:Garden,代码行数:41,代码来源:hooks.php

示例7: Base_Render_Before

 public function Base_Render_Before(&$Sender)
 {
     $Session = Gdn::Session();
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
         // echo 'test'.$PreviewThemeFolder;
         if ($PreviewThemeFolder != '') {
             $Sender->Theme = $PreviewThemeFolder;
             $Sender->AddAsset('Content', $Sender->FetchView('previewtheme', 'settingscontroller', 'dashboard'));
             $Sender->AddCssFile('previewtheme.css');
         }
     }
     // 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 ($Sender->MasterView == 'admin') {
         $Exceptions[] = '[Admin]';
     } else {
         if (in_array($Sender->MasterView, array('', 'default'))) {
             $Exceptions[] = '[NonAdmin]';
         }
     }
     if ($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);
             $Sender->AddModule($MessageModule);
         }
     }
     // 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()->GetApplicants()->NumRows();
         if ($CountApplicants > 0) {
             $Sender->Menu->AddLink('Applicants', T('Applicants') . ' <span>' . $CountApplicants . '</span>', '/dashboard/user/applicants', array('Garden.Registration.Manage'));
         }
     }
 }
开发者ID:kennyma,项目名称:Garden,代码行数:40,代码来源:class.hooks.php

示例8: ValidateUpload

 /**
  * Validates the uploaded file. Returns the temporary name of the uploaded file.
  */
 public function ValidateUpload($InputName)
 {
     if (!array_key_exists($InputName, $_FILES) || !is_uploaded_file($_FILES[$InputName]['tmp_name'])) {
         throw new Exception(Gdn::Translate('The file failed to upload.'));
     }
     switch ($_FILES[$InputName]['error']) {
         case 1:
         case 2:
             throw new Exception(Gdn::Translate('The file is too large to be uploaded to this application.'));
             break;
         case 3:
         case 4:
             throw new Exception(Gdn::Translate('The file failed to upload.'));
             break;
         case 6:
             throw new Exception(Gdn::Translate('The temporary upload folder has not been configured.'));
             break;
         case 7:
             throw new Exception(Gdn::Translate('Failed to write the file to disk.'));
             break;
         case 8:
             throw new Exception(Gdn::Translate('The upload was stopped by extension.'));
             break;
     }
     // Check the maxfilesize again just in case the value was spoofed in the form.
     if (filesize($_FILES[$InputName]['tmp_name']) > $this->_MaxFileSize) {
         throw new Exception(Gdn::Translate('The file is too large to be uploaded to this application.'));
     }
     // Make sure that the file extension is allowed
     $Extension = pathinfo($_FILES[$InputName]['name'], PATHINFO_EXTENSION);
     if (!InArrayI($Extension, $this->_AllowedFileExtensions)) {
         throw new Exception(sprintf(Gdn::Translate('You cannot upload files with this extension (%s).'), $Extension));
     }
     // If all validations were successful, return the tmp name/location of the file.
     $this->_UploadedFile = $_FILES[$InputName];
     return $this->_UploadedFile['tmp_name'];
 }
开发者ID:Beyzie,项目名称:Garden,代码行数:40,代码来源:class.upload.php

示例9: ValidateUpload

 /**
  * Validates the uploaded file. Returns the temporary name of the uploaded file.
  */
 public function ValidateUpload($InputName, $ThrowException = TRUE)
 {
     $Ex = FALSE;
     if (!array_key_exists($InputName, $_FILES) || !is_uploaded_file($_FILES[$InputName]['tmp_name']) && GetValue('error', $_FILES[$InputName], 0) == 0) {
         // Check the content length to see if we exceeded the max post size.
         $ContentLength = Gdn::Request()->GetValueFrom('server', 'CONTENT_LENGTH');
         $MaxPostSize = self::UnformatFileSize(ini_get('post_max_size'));
         if ($ContentLength > $MaxPostSize) {
             $Ex = sprintf(T('Gdn_Upload.Error.MaxPostSize', 'The file is larger than the maximum post size. (%s)'), self::FormatFileSize($MaxPostSize));
         } else {
             $Ex = T('The file failed to upload.');
         }
     } else {
         switch ($_FILES[$InputName]['error']) {
             case 1:
             case 2:
                 $MaxFileSize = self::UnformatFileSize(ini_get('upload_max_filesize'));
                 $Ex = sprintf(T('Gdn_Upload.Error.PhpMaxFileSize', 'The file is larger than the server\'s maximum file size. (%s)'), self::FormatFileSize($MaxFileSize));
                 break;
             case 3:
             case 4:
                 $Ex = T('The file failed to upload.');
                 break;
             case 6:
                 $Ex = T('The temporary upload folder has not been configured.');
                 break;
             case 7:
                 $Ex = T('Failed to write the file to disk.');
                 break;
             case 8:
                 $Ex = T('The upload was stopped by extension.');
                 break;
         }
     }
     $Foo = self::FormatFileSize($this->_MaxFileSize);
     // Check the maxfilesize again just in case the value was spoofed in the form.
     if (!$Ex && $this->_MaxFileSize > 0 && filesize($_FILES[$InputName]['tmp_name']) > $this->_MaxFileSize) {
         $Ex = sprintf(T('Gdn_Upload.Error.MaxFileSize', 'The file is larger than the maximum file size. (%s)'), self::FormatFileSize($this->_MaxFileSize));
     } elseif (!$Ex) {
         // Make sure that the file extension is allowed.
         $Extension = pathinfo($_FILES[$InputName]['name'], PATHINFO_EXTENSION);
         if (!InArrayI($Extension, $this->_AllowedFileExtensions)) {
             $Ex = sprintf(T('You cannot upload files with this extension (%s). Allowed extension(s) are %s.'), $Extension, implode(', ', $this->_AllowedFileExtensions));
         }
     }
     if ($Ex) {
         if ($ThrowException) {
             throw new Gdn_UserException($Ex);
         } else {
             $this->Exception = $Ex;
             return FALSE;
         }
     } else {
         // If all validations were successful, return the tmp name/location of the file.
         $this->_UploadedFile = $_FILES[$InputName];
         return $this->_UploadedFile['tmp_name'];
     }
 }
开发者ID:rnovino,项目名称:Garden,代码行数:61,代码来源:class.upload.php

示例10: TextBox

 /**
  * Returns the xhtml for a text-based input.
  *
  * @param string $FieldName The name of the field that is being displayed/posted with this input. It
  *  should related directly to a field name in $this->_DataArray.
  * @param array $Attributes An associative array of attributes for the input. ie. maxlength, onclick,
  *  class, etc
  * @return string
  */
 public function TextBox($FieldName, $Attributes = FALSE)
 {
     if (!is_array($Attributes)) {
         $Attributes = array();
     }
     $MultiLine = ArrayValueI('MultiLine', $Attributes);
     if ($MultiLine) {
         if (!InArrayI('rows', $Attributes)) {
             $Attributes['rows'] = '6';
         }
         // For xhtml compliance
         if (!InArrayI('cols', $Attributes)) {
             $Attributes['cols'] = '100';
         }
         // For xhtml compliance
     }
     $CssClass = ArrayValueI('class', $Attributes);
     if ($CssClass == FALSE) {
         $Attributes['class'] = $MultiLine ? 'TextBox' : 'InputBox';
     }
     $Return = $MultiLine === TRUE ? '<textarea' : '<input type="text"';
     $Return .= $this->_IDAttribute($FieldName, $Attributes);
     $Return .= $this->_NameAttribute($FieldName, $Attributes);
     $Return .= $MultiLine === TRUE ? '' : $this->_ValueAttribute($FieldName, $Attributes);
     $Return .= $this->_AttributesToString($Attributes);
     $Value = ArrayValueI('value', $Attributes, $this->GetValue($FieldName));
     $Return .= $MultiLine === TRUE ? '>' . htmlentities($Value, ENT_COMPAT, 'UTF-8') . '</textarea>' : ' />';
     return $Return;
 }
开发者ID:Beyzie,项目名称:Garden,代码行数:38,代码来源:class.form.php

示例11: 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' && (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.
     }
     // 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');
     }
     // Allow return to mobile site
//.........这里部分代码省略.........
开发者ID:rnovino,项目名称:Garden,代码行数:101,代码来源:class.hooks.php

示例12: OldIndex

 public function OldIndex($Step = 0)
 {
     $this->Permission('Garden.Data.Import');
     // This permission doesn't exist, so only users with Admin == '1' will succeed.
     $this->AddJsFile('upgrade.js', 'vanilla');
     $Step = is_numeric($Step) && $Step >= 0 && $Step < 20 ? $Step : '';
     $Database = Gdn::Database();
     $Construct = $Database->Structure();
     $PDO = $Database->Connection();
     $SourcePrefix = Gdn::Config('Garden.Import.SourcePrefix', 'LUM_');
     $DestPrefix = Gdn::Config('Database.DatabasePrefix', '');
     if ($Step == 0) {
         $this->View = 'import';
         if ($this->Form->AuthenticatedPostBack()) {
             // Make sure that all of the destination tables exist (assuming that
             // columns are there if tables are there since they were likely just
             // installed moments ago).
             $DbTables = $Database->SQL()->FetchTables();
             $DestTables = explode(',', 'Role,User,UserRole,Conversation,ConversationMessage,UserConversation,Category,Discussion,Comment,UserDiscussion');
             for ($i = 0; $i < count($DestTables); ++$i) {
                 $Table = $DestPrefix . $DestTables[$i];
                 if (!InArrayI($Table, $DbTables)) {
                     $this->Form->AddError('The "' . $Table . '" table is required for import.');
                     break;
                 }
             }
             if ($this->Form->ErrorCount() == 0) {
                 // Make sure that all of the source tables & columns exist.
                 $SourcePrefix = $this->Form->GetFormValue('SourcePrefix');
                 $SourceTables = explode(',', 'Role,User,UserRoleHistory,UserDiscussionWatch,UserBookmark,Category,Discussion,Comment');
                 for ($i = 0; $i < count($SourceTables); ++$i) {
                     $Table = $SourcePrefix . $SourceTables[$i];
                     if (!InArrayI($Table, $DbTables)) {
                         $this->Form->AddError('The "' . $Table . '" source table was not found. Are you sure "' . $SourcePrefix . '" is the correct table prefix for your Vanilla 1 tables?');
                         break;
                     }
                     $Columns = $Database->SQL()->FetchColumns($Table);
                     switch ($SourceTables[$i]) {
                         case 'Role':
                             $RequiredColumns = explode(',', 'RoleID,Name,Description');
                             break;
                         case 'User':
                             $RequiredColumns = explode(',', 'UserID,RoleID,Name,Email,UtilizeEmail,CountVisit,Discovery,DateFirstVisit,DateLastActive,DateFirstVisit,DateLastActive,CountDiscussions,CountComments');
                             break;
                         case 'UserRoleHistory':
                             $RequiredColumns = explode(',', 'UserID,RoleID,AdminUserID,Notes,Date');
                             break;
                         case 'UserDiscussionWatch':
                             $RequiredColumns = explode(',', 'UserID,DiscussionID,CountComments,LastViewed');
                             break;
                         case 'UserBookmark':
                             $RequiredColumns = explode(',', 'UserID,DiscussionID');
                             break;
                         case 'Category':
                             $RequiredColumns = explode(',', 'CategoryID,Name,Description,Priority');
                             break;
                         case 'Discussion':
                             $RequiredColumns = explode(',', 'DiscussionID,CategoryID,AuthUserID,LastUserID,WhisperUserID,Active,Name,CountComments,Closed,Sticky,Sink,DateCreated,DateLastActive');
                             break;
                         case 'Comment':
                             $RequiredColumns = explode(',', 'CommentID,DiscussionID,AuthUserID,EditUserID,WhisperUserID,Deleted,Body,FormatType,DateCreated,DateEdited');
                             break;
                         default:
                             $RequiredColumns = array();
                             break;
                     }
                     if (is_array($RequiredColumns)) {
                         for ($j = 0; $j < count($RequiredColumns); ++$j) {
                             if (!InArrayI($RequiredColumns[$j], $Columns)) {
                                 $this->Form->AddError('The "' . $Table . '" source table does not have the "' . $RequiredColumns[$j] . '" column.');
                                 break;
                             }
                         }
                     }
                 }
             }
             // If there were no errors...
             if ($this->Form->ErrorCount() == 0) {
                 // Save the sourceprefix
                 SaveToConfig('Garden.Import.SourcePrefix', $SourcePrefix);
                 // Proceed with the next step
                 $this->Message = T('<strong>1/19</strong> Checking source & destination tables.');
                 $this->View = 'index';
                 $this->RedirectUrl = Url('/upgrade/1');
                 if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
                     Redirect('/upgrade/1');
                 }
             }
         }
     } else {
         if ($Step == 1) {
             // 1. Add Import IDs to various tables where necessary
             $Construct->Table('Role')->Column('ImportID', 'int', TRUE, 'key')->Set();
             $Construct->Table('User')->Column('ImportID', 'int', TRUE, 'key')->Set();
             $Construct->Table('Category')->Column('ImportID', 'int', TRUE, 'key')->Set();
             $Construct->Table('Discussion')->Column('ImportID', 'int', TRUE, 'key')->Set();
             $Construct->DatabasePrefix($SourcePrefix);
             $Construct->Table('Comment')->Column('ConversationID', 'int', TRUE, 'key')->Set();
             $Construct->DatabasePrefix($DestPrefix);
             $this->Message = T('<strong>2/19</strong> Preparing tables for import.');
//.........这里部分代码省略.........
开发者ID:nbudin,项目名称:Garden,代码行数:101,代码来源:upgrade.php

示例13: 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="PreviewButtons">' . Anchor(T('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->TransientKey(), 'PreviewButton') . ' ' . Anchor(T('Cancel'), 'settings/cancelpreview/', 'PreviewButton') . '</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]';
     }
     if ($Sender->MasterView != 'admin' && (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);
             $Sender->AddModule($MessageModule);
         }
         $Sender->MessagesLoaded = '1';
         // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
     }
     // 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'));
         }
     }
     if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
         $Gdn_Statistics = Gdn::Factory('Statistics');
         $Gdn_Statistics->Check($Sender);
     }
     // Allow forum embedding
     if (C('Garden.Embed.Allow')) {
         $Sender->AddJsFile('js/embed_local.js');
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:71,代码来源:class.hooks.php

示例14: 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

示例15: _FetchController

 /**
  * Searches through the /cache/controller_mappings.php file for the requested
  * controller. If it doesn't find it, it searches through the entire
  * application's folders for the requested controller. If it finds the
  * controller, it adds the mapping to /cache/controller_mappings.php so it
  * won't need to search again. If it doesn't find the controller file
  * anywhere, it throws a fatal error.
  *
  * @param boolean $ThrowErrorOnFailure
  * @todo $ThrowErrorOnFailure needs a description.
  */
 private function _FetchController($ThrowErrorOnFailure = FALSE)
 {
     $ControllerWhiteList = $this->EnabledApplicationFolders();
     // Don't include it if it's already been included
     if (!class_exists($this->ControllerName())) {
         $PathParts = array('controllers');
         if ($this->_ControllerFolder != '') {
             $PathParts[] = $this->_ControllerFolder;
         }
         $PathParts[] = strtolower($this->_ControllerName) . '.php';
         $ControllerFileName = CombinePaths($PathParts);
         // Force the mapping to search in the app folder if it was in the request
         if ($this->_ApplicationFolder != '' && InArrayI($this->_ApplicationFolder, $ControllerWhiteList)) {
             // Limit the white list to the specified application folder
             $ControllerWhiteList = array($this->_ApplicationFolder);
         }
         $ControllerPath = Gdn_FileSystem::FindByMapping('controller_mappings.php', 'Controller', PATH_APPLICATIONS, $ControllerWhiteList, $ControllerFileName);
         if ($ControllerPath !== FALSE) {
             // Strip the "Application Folder" from the controller path (this is
             // used by the controller for various purposes. ie. knowing which
             // application to search in for a view file).
             $this->_ApplicationFolder = explode(DS, str_replace(PATH_APPLICATIONS . DS, '', $ControllerPath));
             $this->_ApplicationFolder = $this->_ApplicationFolder[0];
             // Load the application's master controller
             if (!class_exists($this->_ApplicationFolder . 'Controller')) {
                 include CombinePaths(array(PATH_APPLICATIONS, $this->_ApplicationFolder, 'controllers', 'appcontroller.php'));
             }
             // Now load the library (no need to check for existence - couldn't
             // have made it here if it didn't exist).
             include $ControllerPath;
         }
     }
     if (!class_exists($this->ControllerName())) {
         if ($ThrowErrorOnFailure === TRUE) {
             if (ForceBool(Gdn::Config('Garden.Debug'))) {
                 trigger_error(ErrorMessage('Controller not found: ' . $this->ControllerName(), 'Dispatcher', '_FetchController'), E_USER_ERROR);
             } else {
                 // Return a 404 message
                 list($this->_ApplicationFolder, $this->_ControllerName, $this->_ControllerMethod) = explode('/', $this->Routes['Default404']);
                 $ControllerFileName = CombinePaths(array('controllers', strtolower($this->_ControllerName) . '.php'));
                 $ControllerPath = Gdn_FileSystem::FindByMapping('controller_mappings.php', 'Controller', PATH_APPLICATIONS, $ControllerWhiteList, $ControllerFileName);
                 include CombinePaths(array(PATH_APPLICATIONS, $this->_ApplicationFolder, 'controllers', 'appcontroller.php'));
                 include $ControllerPath;
             }
         }
         return FALSE;
     } else {
         return TRUE;
     }
 }
开发者ID:kidmax,项目名称:Garden,代码行数:61,代码来源:class.dispatcher.php


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