• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Gdn_ApplicationManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Structure

 public function Structure($AppName = 'all', $CaptureOnly = '1', $Drop = '0', $Explicit = '0')
 {
     $this->Permission('Garden.AdminUser.Only');
     $Files = array();
     $AppName = $AppName == '' ? 'all' : $AppName;
     if ($AppName == 'all') {
         // Load all application structure files.
         $ApplicationManager = new Gdn_ApplicationManager();
         $Apps = $ApplicationManager->EnabledApplications();
         $AppNames = ConsolidateArrayValuesByKey($Apps, 'Folder');
         foreach ($AppNames as $AppName) {
             $Files[] = CombinePaths(array(PATH_APPLICATIONS, $AppName, 'settings', 'structure.php'), DS);
         }
         $AppName = 'all';
     } else {
         // Load that specific application structure file.
         $Files[] = CombinePaths(array(PATH_APPLICATIONS, $AppName, 'settings', 'structure.php'), DS);
     }
     $Validation = new Gdn_Validation();
     $Database = Gdn::Database();
     $Drop = $Drop == '0' ? FALSE : TRUE;
     $Explicit = $Explicit == '0' ? FALSE : TRUE;
     $CaptureOnly = !($CaptureOnly == '0');
     $Structure = Gdn::Structure();
     $Structure->CaptureOnly = $CaptureOnly;
     $SQL = Gdn::SQL();
     $SQL->CaptureModifications = $CaptureOnly;
     $this->SetData('CaptureOnly', $Structure->CaptureOnly);
     $this->SetData('Drop', $Drop);
     $this->SetData('Explicit', $Explicit);
     $this->SetData('ApplicationName', $AppName);
     $this->SetData('Status', '');
     $FoundStructureFile = FALSE;
     foreach ($Files as $File) {
         if (file_exists($File)) {
             $FoundStructureFile = TRUE;
             try {
                 include $File;
             } catch (Exception $Ex) {
                 $this->Form->AddError($Ex);
             }
         }
         if (property_exists($Structure->Database, 'CapturedSql')) {
             $this->SetData('CapturedSql', (array) $Structure->Database->CapturedSql);
         } else {
             $this->SetData('CapturedSql', array());
         }
     }
     if ($this->Form->ErrorCount() == 0 && !$CaptureOnly && $FoundStructureFile) {
         $this->SetData('Status', 'The structure was successfully executed.');
     }
     $this->AddSideMenu('dashboard/settings/configure');
     $this->AddCssFile('admin.css');
     $this->SetData('Title', T('Database Structure Upgrades'));
     $this->Render();
 }
开发者ID:sipp11,项目名称:Garden,代码行数:56,代码来源:class.utilitycontroller.php


示例2: applications

 /**
  * Application management screen.
  *
  * @since 2.0.0
  * @access public
  * @param string $Filter 'enabled', 'disabled', or 'all' (default)
  * @param string $ApplicationName Unique ID of app to be modified.
  * @param string $TransientKey Security token.
  */
 public function applications($Filter = '', $ApplicationName = '', $TransientKey = '')
 {
     $this->permission('Garden.Settings.Manage');
     // Page setup
     $this->addJsFile('addons.js');
     $this->addJsFile('applications.js');
     $this->title(t('Applications'));
     $this->addSideMenu('dashboard/settings/applications');
     // Validate & set parameters
     $Session = Gdn::session();
     if ($ApplicationName && !$Session->validateTransientKey($TransientKey)) {
         $ApplicationName = '';
     }
     if (!in_array($Filter, array('enabled', 'disabled'))) {
         $Filter = 'all';
     }
     $this->Filter = $Filter;
     $ApplicationManager = new Gdn_ApplicationManager();
     $this->AvailableApplications = $ApplicationManager->availableVisibleApplications();
     $this->EnabledApplications = $ApplicationManager->enabledVisibleApplications();
     if ($ApplicationName != '') {
         $this->EventArguments['ApplicationName'] = $ApplicationName;
         if (array_key_exists($ApplicationName, $this->EnabledApplications) === true) {
             try {
                 $ApplicationManager->disableApplication($ApplicationName);
                 Gdn_LibraryMap::clearCache();
                 $this->fireEvent('AfterDisableApplication');
             } catch (Exception $e) {
                 $this->Form->addError(strip_tags($e->getMessage()));
             }
         } else {
             try {
                 $ApplicationManager->checkRequirements($ApplicationName);
             } catch (Exception $e) {
                 $this->Form->addError(strip_tags($e->getMessage()));
             }
             if ($this->Form->errorCount() == 0) {
                 $Validation = new Gdn_Validation();
                 $ApplicationManager->registerPermissions($ApplicationName, $Validation);
                 $ApplicationManager->enableApplication($ApplicationName, $Validation);
                 Gdn_LibraryMap::clearCache();
                 $this->Form->setValidationResults($Validation->results());
                 $this->EventArguments['Validation'] = $Validation;
                 $this->fireEvent('AfterEnableApplication');
             }
         }
         if ($this->Form->errorCount() == 0) {
             redirect('settings/applications/' . $this->Filter);
         }
     }
     $this->render();
 }
开发者ID:R-J,项目名称:vanilla,代码行数:61,代码来源:class.settingscontroller.php


示例3: EnableTheme

 public function EnableTheme($ThemeName)
 {
     // 1. Make sure that the theme's requirements are met
     $ApplicationManager = new Gdn_ApplicationManager();
     $EnabledApplications = $ApplicationManager->EnabledApplications();
     $AvailableThemes = $this->AvailableThemes();
     $NewThemeInfo = ArrayValue($ThemeName, $AvailableThemes, array());
     $RequiredApplications = ArrayValue('RequiredApplications', $NewThemeInfo, FALSE);
     CheckRequirements($ThemeName, $RequiredApplications, $EnabledApplications, 'application');
     // Applications
     // 5. Set the theme
     $ThemeFolder = ArrayValue('Folder', $NewThemeInfo, '');
     if ($ThemeFolder == '') {
         throw new Exception(Gdn::Translate('The theme folder was not properly defined.'));
     } else {
         SaveToConfig('Garden.Theme', $ThemeFolder);
     }
     return TRUE;
 }
开发者ID:Aetasiric,项目名称:Garden,代码行数:19,代码来源:class.thememanager.php


示例4: GetAllowedPermissionNamespaces

 /**
  * Returns a complete list of all enabled applications & plugins. This list
  * can act as a namespace list for permissions.
  * @return array
  */
 public function GetAllowedPermissionNamespaces()
 {
     $ApplicationManager = new Gdn_ApplicationManager();
     $EnabledApplications = $ApplicationManager->EnabledApplications();
     $PluginManager = Gdn::Factory('PluginManager');
     $PluginNamespaces = array();
     foreach ($PluginManager->EnabledPlugins as $Plugin) {
         if (!array_key_exists('RegisterPermissions', $Plugin) || !is_array($Plugin['RegisterPermissions'])) {
             continue;
         }
         foreach ($Plugin['RegisterPermissions'] as $PermissionName) {
             $Namespace = substr($PermissionName, 0, strrpos($PermissionName, '.'));
             $PluginNamespaces[$Namespace] = TRUE;
         }
     }
     return array_merge(array_keys($EnabledApplications), array_keys($PluginNamespaces));
 }
开发者ID:Beyzie,项目名称:Garden,代码行数:22,代码来源:class.permissionmodel.php


示例5: GetAllowedPermissionNamespaces

 /**
  * Returns a complete list of all enabled applications & plugins. This list
  * can act as a namespace list for permissions.
  * @return array
  */
 public function GetAllowedPermissionNamespaces()
 {
     $ApplicationManager = new Gdn_ApplicationManager();
     $EnabledApplications = $ApplicationManager->EnabledApplications();
     $PluginNamespaces = array();
     foreach (Gdn::PluginManager()->EnabledPlugins() as $Plugin) {
         if (!array_key_exists('RegisterPermissions', $Plugin) || !is_array($Plugin['RegisterPermissions'])) {
             continue;
         }
         foreach ($Plugin['RegisterPermissions'] as $Index => $PermissionName) {
             if (is_string($Index)) {
                 $PermissionName = $Index;
             }
             $Namespace = substr($PermissionName, 0, strrpos($PermissionName, '.'));
             $PluginNamespaces[$Namespace] = TRUE;
         }
     }
     $Result = array_merge(array_keys($EnabledApplications), array_keys($PluginNamespaces));
     if (in_array('Dashboard', $Result)) {
         $Result[] = 'Garden';
     }
     return $Result;
 }
开发者ID:rnovino,项目名称:Garden,代码行数:28,代码来源:class.permissionmodel.php


示例6: DisablePlugin

 public function DisablePlugin($PluginName)
 {
     // 1. Check to make sure that no other enabled plugins rely on this one
     // Get all available plugins and compile their requirements
     foreach ($this->EnabledPlugins as $CheckingName => $CheckingInfo) {
         $RequiredPlugins = ArrayValue('RequiredPlugins', $CheckingInfo, FALSE);
         if (is_array($RequiredPlugins) && array_key_exists($PluginName, $RequiredPlugins) === TRUE) {
             throw new Exception(sprintf(T('You cannot disable the %1$s plugin because the %2$s plugin requires it in order to function.'), $PluginName, $CheckingName));
         }
     }
     // 2. Perform necessary hook action
     $this->_PluginHook($PluginName, self::ACTION_DISABLE, TRUE);
     // 3. Disable it
     RemoveFromConfig('EnabledPlugins' . '.' . $PluginName);
     unset($this->EnabledPlugins[$PluginName]);
     // Redefine the locale manager's settings $Locale->Set($CurrentLocale, $EnabledApps, $EnabledPlugins, TRUE);
     $ApplicationManager = new Gdn_ApplicationManager();
     $Locale = Gdn::Locale();
     $Locale->Set($Locale->Current(), $ApplicationManager->EnabledApplicationFolders(), $this->EnabledPluginFolders(), TRUE);
 }
开发者ID:nickhx,项目名称:Garden,代码行数:20,代码来源:class.pluginmanager.php


示例7: enableApplications

 /**
  * Enable applications and create permisisions for roles.
  *
  * @return void
  */
 protected function enableApplications()
 {
     $ApplicationManager = new Gdn_ApplicationManager();
     $AppNames = c('Garden.Install.Applications', ['Conversations', 'Vanilla']);
     foreach ($AppNames as $AppName) {
         $Validation = new Gdn_Validation();
         $ApplicationManager->RegisterPermissions($AppName, $Validation);
         $ApplicationManager->EnableApplication($AppName, $Validation);
     }
     Gdn::pluginManager()->start(true);
     // Flag the application as installed
     saveToConfig('Garden.Installed', true);
     // Setup default permissions for all roles
     PermissionModel::ResetAllRoles();
 }
开发者ID:TFidryForks,项目名称:spira,代码行数:20,代码来源:VanillaConfigurator.php


示例8: runStructure

 /**
  *
  *
  * @param null $AddonCode
  * @param bool $Explicit
  * @param bool $Drop
  * @throws Exception
  */
 public function runStructure($AddonCode = null, $Explicit = false, $Drop = false)
 {
     // Get the structure files for all of the enabled applications.
     $ApplicationManager = new Gdn_ApplicationManager();
     $Apps = $ApplicationManager->EnabledApplications();
     $AppNames = consolidateArrayValuesByKey($Apps, 'Folder');
     $Paths = array();
     foreach ($Apps as $Key => $AppInfo) {
         $Path = PATH_APPLICATIONS . "/{$AppInfo['Folder']}/settings/structure.php";
         if (file_exists($Path)) {
             $Paths[] = $Path;
         }
         Gdn::ApplicationManager()->RegisterPermissions($Key, $this->Validation);
     }
     // Execute the structures.
     $Database = Gdn::database();
     $SQL = Gdn::sql();
     $Structure = Gdn::structure();
     foreach ($Paths as $Path) {
         include $Path;
     }
     // Execute the structures for all of the plugins.
     $PluginManager = Gdn::pluginManager();
     $Registered = $PluginManager->RegisteredPlugins();
     foreach ($Registered as $ClassName => $Enabled) {
         if (!$Enabled) {
             continue;
         }
         try {
             $Plugin = $PluginManager->GetPluginInstance($ClassName, Gdn_PluginManager::ACCESS_CLASSNAME);
             if (method_exists($Plugin, 'Structure')) {
                 trace("{$ClassName}->Structure()");
                 $Plugin->Structure();
             }
         } catch (Exception $Ex) {
             // Do nothing, plugin wouldn't load/structure.
             if (Debug()) {
                 throw $Ex;
             }
         }
     }
     $this->fireEvent('AfterStructure');
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:51,代码来源:class.updatemodel.php


示例9: T

?>
</div>
<h1><?php 
echo T('Homepage');
?>
</h1>
<div class="Info">
   <?php 
printf(T('Use the content at this url as your homepage.', 'Choose the page people should see when they visit: <strong style="white-space: nowrap;">%s</strong>'), Url('/', TRUE));
?>
</div>
<div class="Homepage">
   <div class="HomeOptions">
      <?php 
// Only show the vanilla pages if Vanilla is enabled
$ApplicationManager = new Gdn_ApplicationManager();
$EnabledApplications = $ApplicationManager->EnabledVisibleApplications();
$CurrentTarget = $this->Data('CurrentTarget');
if (array_key_exists('Vanilla', $EnabledApplications)) {
    echo WriteHomepageOption('Discussions', 'discussions', 'SpDiscussions', $CurrentTarget);
    echo WriteHomepageOption('Categories', 'categories', 'SpCategories', $CurrentTarget);
    // echo WriteHomepageOption('Categories &amp; Discussions', 'categories/discussions', 'categoriesdiscussions', $CurrentTarget);
}
echo WriteHomepageOption('Activity', 'activity', 'SpActivity', $CurrentTarget);
?>
   </div>
   <?php 
if (array_key_exists('Vanilla', $EnabledApplications)) {
    ?>
   <div class="LayoutOptions DiscussionsLayout">
      <p>
开发者ID:rnovino,项目名称:Garden,代码行数:31,代码来源:homepage.php


示例10: Configure

 /**
  * Garden management screen.
  */
 public function Configure()
 {
     $this->Permission('Garden.Settings.Manage');
     $this->AddSideMenu('garden/settings/configure');
     $this->AddJsFile('email.js');
     $this->Title(Translate('General Settings'));
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('Garden.Locale', 'Garden.Title', 'Garden.RewriteUrls', 'Garden.Email.SupportName', 'Garden.Email.SupportAddress', 'Garden.Email.UseSmtp', 'Garden.Email.SmtpHost', 'Garden.Email.SmtpUser', 'Garden.Email.SmtpPassword', 'Garden.Email.SmtpPort'));
     // Set the model on the form.
     $this->Form->SetModel($ConfigurationModel);
     // Load the locales for the locale dropdown
     $Locale = Gdn::Locale();
     $AvailableLocales = $Locale->GetAvailableLocaleSources();
     $this->LocaleData = ArrayCombine($AvailableLocales, $AvailableLocales);
     // Check to see if mod_rewrit is enabled.
     if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) {
         $this->SetData('HasModRewrite', TRUE);
     } else {
         $this->SetData('HasModRewrite', FALSE);
     }
     // If seeing the form for the first time...
     if ($this->Form->AuthenticatedPostBack() === FALSE) {
         // Apply the config settings to the form.
         $this->Form->SetData($ConfigurationModel->Data);
     } else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->ApplyRule('Garden.Locale', 'Required');
         $ConfigurationModel->Validation->ApplyRule('Garden.Title', 'Required');
         $ConfigurationModel->Validation->ApplyRule('Garden.RewriteUrls', 'Boolean');
         $ConfigurationModel->Validation->ApplyRule('Garden.Email.SupportName', 'Required');
         $ConfigurationModel->Validation->ApplyRule('Garden.Email.SupportAddress', 'Required');
         $ConfigurationModel->Validation->ApplyRule('Garden.Email.SupportAddress', 'Email');
         // If changing locale, redefine locale sources:
         $NewLocale = $this->Form->GetFormValue('Garden.Locale', FALSE);
         if ($NewLocale !== FALSE && Gdn::Config('Garden.Locale') != $NewLocale) {
             $ApplicationManager = new Gdn_ApplicationManager();
             $PluginManager = Gdn::Factory('PluginManager');
             $Locale = Gdn::Locale();
             $Locale->Set($NewLocale, $ApplicationManager->EnabledApplicationFolders(), $PluginManager->EnabledPluginFolders(), TRUE);
         }
         if ($this->Form->Save() !== FALSE) {
             $this->StatusMessage = Translate("Your settings have been saved.");
         }
     }
     $this->Render();
 }
开发者ID:jeastwood,项目名称:Garden,代码行数:50,代码来源:settings.php


示例11: RunStructure

 public function RunStructure($AddonCode = NULL, $Explicit = FALSE, $Drop = FALSE)
 {
     // Get the structure files for all of the enabled applications.
     $ApplicationManager = new Gdn_ApplicationManager();
     $Apps = $ApplicationManager->EnabledApplications();
     $AppNames = ConsolidateArrayValuesByKey($Apps, 'Folder');
     $Paths = array();
     foreach ($Apps as $AppInfo) {
         $Path = PATH_APPLICATIONS . "/{$AppInfo['Folder']}/settings/structure.php";
         if (file_exists($Path)) {
             $Paths[] = $Path;
         }
     }
     // Execute the structures.
     $Database = Gdn::Database();
     $SQL = Gdn::SQL();
     $Structure = Gdn::Structure();
     foreach ($Paths as $Path) {
         include $Path;
     }
     // Execute the structures for all of the plugins.
     $PluginManager = Gdn::PluginManager();
     $Registered = $PluginManager->RegisteredPlugins();
     foreach ($Registered as $ClassName => $Enabled) {
         if (!$Enabled) {
             continue;
         }
         try {
             $Plugin = $PluginManager->GetPluginInstance($ClassName, Gdn_PluginManager::ACCESS_CLASSNAME);
             if (method_exists($Plugin, 'Structure')) {
                 Trace("{$ClassName}->Structure()");
                 $Plugin->Structure();
             }
         } catch (Exception $Ex) {
             // Do nothing, plugin wouldn't load/structure.
         }
     }
 }
开发者ID:bishopb,项目名称:vanilla,代码行数:38,代码来源:class.updatemodel.php


示例12: GetAddons

 public function GetAddons($Enabled = FALSE)
 {
     $Addons = array();
     // Get the core.
     self::_AddAddon(array('AddonKey' => 'vanilla', 'AddonType' => 'core', 'Version' => APPLICATION_VERSION, 'Folder' => '/'), $Addons);
     // Get a list of all of the applications.
     $ApplicationManager = new Gdn_ApplicationManager();
     if ($Enabled) {
         $Applications = $ApplicationManager->AvailableApplications();
     } else {
         $Applications = $ApplicationManager->EnabledApplications();
     }
     foreach ($Applications as $Key => $Info) {
         // Exclude core applications.
         if (in_array(strtolower($Key), array('conversations', 'dashboard', 'skeleton', 'vanilla'))) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'application', 'Version' => GetValue('Version', $Info, '0.0'), 'Folder' => '/applications/' . GetValue('Folder', $Info, strtolower($Key)));
         self::_AddAddon($Addon, $Addons);
     }
     // Get a list of all of the plugins.
     $PluginManager = Gdn::PluginManager();
     if ($Enabled) {
         $Plugins = $PluginManager->EnabledPlugins();
     } else {
         $Plugins = $PluginManager->AvailablePlugins();
     }
     foreach ($Plugins as $Key => $Info) {
         // Exclude core plugins.
         if (in_array(strtolower($Key), array())) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'plugin', 'Version' => GetValue('Version', $Info, '0.0'), 'Folder' => '/applications/' . GetValue('Folder', $Info, $Key));
         self::_AddAddon($Addon, $Addons);
     }
     // Get a list of all the themes.
     $ThemeManager = new Gdn_ThemeManager();
     if ($Enabled) {
         $Themes = $ThemeManager->EnabledThemeInfo(TRUE);
     } else {
         $Themes = $ThemeManager->AvailableThemes();
     }
     foreach ($Themes as $Key => $Info) {
         // Exclude core themes.
         if (in_array(strtolower($Key), array('default'))) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'theme', 'Version' => GetValue('Version', $Info, '0.0'), 'Folder' => '/themes/' . GetValue('Folder', $Info, $Key));
         self::_AddAddon($Addon, $Addons);
     }
     // Get a list of all locales.
     $LocaleModel = new LocaleModel();
     if ($Enabled) {
         $Locales = $LocaleModel->EnabledLocalePacks(TRUE);
     } else {
         $Locales = $LocaleModel->AvailableLocalePacks();
     }
     foreach ($Locales as $Key => $Info) {
         // Exclude core themes.
         if (in_array(strtolower($Key), array('skeleton'))) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'locale', 'Version' => GetValue('Version', $Info, '0.0'), 'Folder' => '/locales/' . GetValue('Folder', $Info, $Key));
         self::_AddAddon($Addon, $Addons);
     }
     return $Addons;
 }
开发者ID:kennyma,项目名称:Garden,代码行数:67,代码来源:class.updatemodel.php


示例13: EnablePlugin

 public function EnablePlugin($PluginName, $Validation, $Setup = FALSE, $EnabledPluginValueIndex = 'Folder')
 {
     // Check that the plugin is in AvailablePlugins...
     $Plugin = $this->GetPluginInfo($PluginName, self::ACCESS_PLUGINNAME);
     // If not, we're dealing with a special case. Enabling with a classname...
     if (!$Plugin) {
         $ClassName = $PluginName;
         $PluginFile = Gdn_LibraryMap::GetCache('plugin', $ClassName);
         if ($PluginFile) {
             $Plugin = $this->PluginAvailable($PluginFile);
             $PluginName = $Plugin['Index'];
         }
     }
     // Couldn't load the plugin info.
     if (!$Plugin) {
         return;
     }
     $PluginName = $Plugin['Index'];
     $this->TestPlugin($PluginName, $Validation, $Setup);
     if (is_object($Validation) && count($Validation->Results()) > 0) {
         return FALSE;
     }
     // If everything succeeded, add the plugin to the $EnabledPlugins array in conf/config.php
     // $EnabledPlugins['PluginClassName'] = 'Plugin Folder Name';
     // $PluginInfo = ArrayValue($PluginName, $this->AvailablePlugins(), FALSE);
     $PluginInfo = $this->GetPluginInfo($PluginName);
     $PluginFolder = ArrayValue('Folder', $PluginInfo);
     $PluginEnabledValue = ArrayValue($EnabledPluginValueIndex, $PluginInfo, $PluginFolder);
     SaveToConfig('EnabledPlugins.' . $PluginName, $PluginEnabledValue);
     $this->EnabledPlugins[$PluginName] = $PluginInfo;
     $this->RegisterPlugin($PluginInfo['ClassName'], $PluginInfo);
     $ApplicationManager = new Gdn_ApplicationManager();
     $Locale = Gdn::Locale();
     $Locale->Set($Locale->Current(), $ApplicationManager->EnabledApplicationFolders(), $this->EnabledPluginFolders(), TRUE);
     return TRUE;
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:36,代码来源:class.pluginmanager.php


示例14: DisablePlugin

 public function DisablePlugin($PluginName)
 {
     // 1. Check to make sure that no other enabled plugins rely on this one
     // Get all available plugins and compile their requirements
     foreach ($this->EnabledPlugins as $CheckingName => $CheckingInfo) {
         $RequiredPlugins = ArrayValue('RequiredPlugins', $CheckingInfo, FALSE);
         if (is_array($RequiredPlugins) && array_key_exists($PluginName, $RequiredPlugins) === TRUE) {
             throw new Exception(sprintf(Gdn::Translate('You cannot disable the %1$s plugin because the %2$s plugin requires it in order to function.'), $PluginName, $CheckingName));
         }
     }
     // 2. Disable it
     $Config = Gdn::Factory(Gdn::AliasConfig);
     $Config->Load(PATH_CONF . DS . 'config.php', 'Save');
     $Config->Remove('EnabledPlugins' . '.' . $PluginName);
     $Config->Save();
     unset($this->EnabledPlugins[$PluginName]);
     // Redefine the locale manager's settings $Locale->Set($CurrentLocale, $EnabledApps, $EnabledPlugins, TRUE);
     $ApplicationManager = new Gdn_ApplicationManager();
     $Locale = Gdn::Locale();
     $Locale->Set($Locale->Current(), $ApplicationManager->EnabledApplicationFolders(), $this->EnabledPluginFolders(), TRUE);
 }
开发者ID:Beyzie,项目名称:Garden,代码行数:21,代码来源:class.pluginmanager.php


示例15: RunStructure

 public function RunStructure($AddonCode = NULL, $Explicit = FALSE, $Drop = FALSE)
 {
     // Get the structure files for all of the enabled applications.
     $ApplicationManager = new Gdn_ApplicationManager();
     $Apps = $ApplicationManager->EnabledApplications();
     $AppNames = ConsolidateArrayValuesByKey($Apps, 'Folder');
     $Paths = array();
     foreach ($Apps as $AppInfo) {
         $Path = PATH_APPLICATIONS . "/{$AppInfo['Folder']}/settings/structure.php";
         if (file_exists($Path)) {
             $Paths[] = $Path;
         }
     }
     // Execute the structures.
     $Database = Gdn::Database();
     $SQL = Gdn::SQL();
     $Structure = Gdn::Structure();
     foreach ($Paths as $Path) {
         include $Path;
     }
     // Execute the structures for all of the plugins.
     $PluginManager = Gdn::PluginManager();
     $Plugins = $PluginManager->EnabledPlugins();
     foreach ($Plugins as $Key => $PluginInfo) {
         $PluginName = GetValue('Index', $PluginInfo);
         $Plugin = $PluginManager->GetPluginInstance($PluginName, Gdn_PluginManager::ACCESS_PLUGINNAME);
         if (method_exists($Plugin, 'Structure')) {
             $Plugin->Structure();
         }
     }
 }
开发者ID:elpum,项目名称:TgaForumBundle,代码行数:31,代码来源:class.updatemodel.php


示例16: configure

 /**
  * Allows the configuration of basic setup information in Garden. This
  * should not be functional after the application has been set up.
  *
  * @since 2.0.0
  * @access public
  * @param string $RedirectUrl Where to send user afterward.
  */
 private function configure($RedirectUrl = '')
 {
     // Create a model to save configuration settings
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->setField(array('Garden.Locale', 'Garden.Title', 'Garden.WebRoot', 'Garden.Cookie.Salt', 'Garden.Cookie.Domain', 'Database.Name', 'Database.Host', 'Database.User', 'Database.Password', 'Garden.Registration.ConfirmEmail', 'Garden.Email.SupportName'));
     // Set the models on the forms.
     $this->Form->setModel($ConfigurationModel);
     // Load the locales for the locale dropdown
     // $Locale = Gdn::locale();
     // $AvailableLocales = $Locale->GetAvailableLocaleSources();
     // $this->LocaleData = array_combine($AvailableLocales, $AvailableLocales);
     // If seeing the form for the first time...
     if (!$this->Form->isPostback()) {
         // Force the webroot using our best guesstimates
         $ConfigurationModel->Data['Database.Host'] = 'localhost';
         $this->Form->setData($ConfigurationModel->Data);
     } else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->applyRule('Database.Name', 'Required', 'You must specify the name of the database in which you want to set up Vanilla.');
         // Let's make some user-friendly custom errors for database problems
         $DatabaseHost = $this->Form->getFormValue('Database.Host', '~~Invalid~~');
         $DatabaseName = $this->Form->getFormValue('Database.Name', '~~Invalid~~');
         $DatabaseUser = $this->Form->getFormValue('Database.User', '~~Invalid~~');
         $DatabasePassword = $this->Form->getFormValue('Database.Password', '~~Invalid~~');
         $ConnectionString = GetConnectionString($DatabaseName, $DatabaseHost);
         try {
             $Connection = new PDO($ConnectionString, $DatabaseUser, $DatabasePassword);
         } catch (PDOException $Exception) {
             switch ($Exception->getCode()) {
                 case 1044:
                     $this->Form->addError(t('The database user you specified does not have permission to access the database. Have you created the database yet? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                     break;
                 case 1045:
                     $this->Form->addError(t('Failed to connect to the database with the username and password you entered. Did you mistype them? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                     break;
                 case 1049:
                     $this->Form->addError(t('It appears as though the database you specified does not exist yet. Have you created it yet? Did you mistype the name? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                     break;
                 case 2005:
                     $this->Form->addError(t("Are you sure you've entered the correct database host name? Maybe you mistyped it? The database reported: <code>%s</code>"), strip_tags($Exception->getMessage()));
                     break;
                 default:
                     $this->Form->addError(sprintf(t('ValidateConnection'), strip_tags($Exception->getMessage())));
                     break;
             }
         }
         $ConfigurationModel->Validation->applyRule('Garden.Title', 'Required');
         $ConfigurationFormValues = $this->Form->formValues();
         if ($ConfigurationModel->validate($ConfigurationFormValues) !== true || $this->Form->errorCount() > 0) {
             // Apply the validation results to the form(s)
             $this->Form->setValidationResults($ConfigurationModel->validationResults());
         } else {
             $Host = array_shift(explode(':', Gdn::request()->requestHost()));
             $Domain = Gdn::request()->domain();
             // Set up cookies now so that the user can be signed in.
             $ExistingSalt = c('Garden.Cookie.Salt', false);
             $ConfigurationFormValues['Garden.Cookie.Salt'] = $ExistingSalt ? $ExistingSalt : betterRandomString(16, 'Aa0');
             $ConfigurationFormValues['Garden.Cookie.Domain'] = '';
             // Don't set this to anything by default. # Tim - 2010-06-23
             // Additional default setup values.
             $ConfigurationFormValues['Garden.Registration.ConfirmEmail'] = true;
             $ConfigurationFormValues['Garden.Email.SupportName'] = $ConfigurationFormValues['Garden.Title'];
             $ConfigurationModel->save($ConfigurationFormValues, true);
             // If changing locale, redefine locale sources:
             $NewLocale = 'en-CA';
             // $this->Form->getFormValue('Garden.Locale', false);
             if ($NewLocale !== false && Gdn::config('Garden.Locale') != $NewLocale) {
                 $ApplicationManager = new Gdn_ApplicationManager();
                 $Locale = Gdn::locale();
                 $Locale->set($NewLocale, $ApplicationManager->enabledApplicationFolders(), Gdn::pluginManager()->enabledPluginFolders(), true);
             }
             // Install db structure & basic data.
             $Database = Gdn::database();
             $Database->init();
             $Drop = false;
             $Explicit = false;
             try {
                 include PATH_APPLICATIONS . DS . 'dashboard' . DS . 'settings' . DS . 'structure.php';
             } catch (Exception $ex) {
                 $this->Form->addError($ex);
             }
             if ($this->Form->errorCount() > 0) {
                 return false;
             }
             // Create the administrative user
             $UserModel = Gdn::userModel();
             $UserModel->defineSchema();
             $UsernameError = t('UsernameError', 'Username can only contain letters, numbers, underscores, and must be between 3 and 20 characters long.');
             $UserModel->Validation->applyRule('Name', 'Username', $UsernameError);
             $UserModel->Validation->applyRule('Name', 'Required', t('You must specify an admin username.'));
             $UserModel->Validation->applyRule('Password', 'Required', t('You must specify an admin password.'));
//.........这里部分代码省略.........
开发者ID:korelstar,项目名称:vanilla,代码行数:101,代码来源:class.setupcontroller.php


示例17: structure

 /**
  * Update database structure based on current definitions in each app's structure.php file.
  *
  * @since 2.0.?
  * @access public
  * @param string $AppName Unique app name or 'all' (default).
  * @param int $CaptureOnly Whether to list changes rather than execture (0 or 1).
  * @param int $Drop Whether to drop first (0 or 1).
  * @param int $Explicit Whether to force to only columns currently listed (0 or 1).
  */
 public function structure($AppName = 'all', $CaptureOnly = '1', $Drop = '0', $Explicit = '0')
 {
     $this->permission('Garden.Settings.Manage');
     $Files = array();
     $AppName = $AppName == '' ? 'all' : $AppName;
     if ($AppName == 'all') {
         // Load all application structure files.
         $ApplicationManager = new Gdn_ApplicationManager();
         $Apps = $ApplicationManager->enabledApplications();
         $AppNames = array_column($Apps, 'Folder');
         foreach ($AppNames as $AppName) {
             $Files[] = combinePaths(array(PATH_APPLICATIONS, $AppName, 'settings', 'structure.php'), DS);
         }
         $AppName = 'all';
     } else {
         // Load that specific application structure file.
         $Files[] = combinePaths(array(PATH_APPLICATIONS, $AppName, 'settings', 'structure.php'), DS);
     }
     $Validation = new Gdn_Validation();
     $Database = Gdn::database();
     $Drop = $Drop == '0' ? false : true;
     $Explicit = $Explicit == '0' ? false : true;
     $CaptureOnly = !($CaptureOnly == '0');
     $Structure = Gdn::structure();
     $Structure->CaptureOnly = $CaptureOnly;
     $SQL = Gdn::sql();
     $SQL->CaptureModifications = $CaptureOnly;
     $this->setData('CaptureOnly', $Structure->CaptureOnly);
     $this->setData('Drop', $Drop);
     $this->setData('Explicit', $Explicit);
     $this->setData('ApplicationName', $AppName);
     $this->setData('Status', '');
     $FoundStructureFile = false;
     foreach ($Files as $File) {
         if (file_exists($File)) {
             $FoundStructureFile = true;
             try {
                 include $File;
             } catch (Exception $Ex) {
                 $this->Form->addError($Ex);
             }
         }
     }
     // Run the structure of all of the plugins.
     $Plugins = Gdn::pluginManager()->enabledPlugins();
     foreach ($Plugins as $PluginKey => $Plugin) {
         $PluginInstance = Gdn::pluginManager()->getPluginInstance($PluginKey, Gdn_PluginManager::ACCESS_PLUGINNAME);
         if (method_exists($PluginInstance, 'Structure')) {
             $PluginInstance->structure();
         }
     }
     if (property_exists($Structure->Database, 'CapturedSql')) {
         $this->setData('CapturedSql', (array) $Structure->Database->CapturedSql);
     } else {
         $this->setData('CapturedSql', array());
     }
     if ($this->Form->errorCount() == 0 && !$CaptureOnly && $FoundStructureFile) {
         $this->setData('Status', 'The structure was successfully executed.');
     }
     $this->addSideMenu('dashboard/settings/configure');
     $this->addCssFile('admin.css');
     $this->setData('Title', t('Database Structure Upgrades'));
     $this->render();
 }
开发者ID:bryanjamesmiller,项目名称:vanilla,代码行数:74,代码来源:class.utilitycontroller.php


示例18: runStructure

 /**
  * Run the database structure or /utility/structure.
  *
  * Note: Keep this method protected!
  *
  * @param string $appName Unique app name or 'all' (default).
  * @param bool $captureOnly Whether to list changes rather than execute (0 or 1).
  * @throws Exception
  */
 protected function runStructure($appName = 'all', $captureOnly = true)
 {
     // This permission is run again to be sure someone doesn't accidentally call this method incorrectly.
     $this->permission('Garden.Settings.Manage');
     $Files = array();
     $appName = $appName == '' ? 'all' : $appName;
     if ($appName == 'all') {
         // Load all application structure files.
         $ApplicationManager = new Gdn_ApplicationManager();
         $Apps = $ApplicationManager->enabledApplications();
         $AppNames = array_column($Apps, 'Folder');
         foreach ($AppNames as $appName) {
             $Files[] = combinePaths(array(PATH_APPLICATIONS, $appName, 'settings', 'structure.php'), DS);
         }
         $appName = 'all';
     } else {
         // Load that specific application structure file.
         $Files[] = combinePaths(array(PATH_APPLICATIONS, $appName, 'settings', 'structure.php'), DS);
     }
     $Drop = false;
     $Explicit = false;
     $captureOnly = !($captureOnly == '0');
     $Structure = Gdn::structure();
     $Structure->CaptureOnly = $captureOnly;
     $SQL = Gdn::sql();
     $SQL->CaptureModifications = $captureOnly;
     $this->setData('CaptureOnly', $Structure->CaptureOnly);
     $this->setData('Drop', $Drop);
     $this->setData('Explicit', $Explicit);
     $this->setData('ApplicationName', $appName);
     $this->setData('Status', '');
     $FoundStructureFile = false;
     foreach ($Files as $File) {
         if (file_exists($File)) {
             $FoundStructureFile = true;
             try {
                 include $File;
             } catch (Exception $Ex) {
                 $this->Form->addError($Ex);
             }
         }
     }
     // Run the structure of all of the plugins.
     $Plugins = Gdn::pluginManager()->enabledPlugins();
     foreach ($Plugins as $PluginKey => $Plugin) {
         $PluginInstance = Gdn::pluginManager()->getPluginInstance($PluginKey, Gdn_PluginManager::ACCESS_PLUGINNAME);
         if (method_exists($PluginInstance, 'Structure')) {
             $PluginInstance->structure();
         }
     }
     if (property_exists($Structure->Database, 'CapturedSql')) {
         $this->setData('CapturedSql', (array) $Structure->Database->CapturedSql);
     } else {
         $this->setData('CapturedSql', array());
     }
     if ($this->Form->errorCount() == 0 && !$captureOnly && $FoundStructureFile) {
         $this->setData('Status', 'The structure was successfully executed.');
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:68,代码来源:class.utilitycontroller.php


示例19: Configure

 /**
  * Allows the configuration of basic setup information in Garden. This
  * should not be functional after the application has been set up.
  */
 public function Configure($RedirectUrl = '')
 {
     $Config = Gdn::Factory(Gdn::AliasConfig);
     $ConfigFile = PATH_CONF . DS . 'config.php';
     // Create 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Gdn_AuthenticationProviderModel类代码示例发布时间:2022-05-23
下一篇:
PHP Gdn类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap