本文整理汇总了PHP中CheckRequirements函数的典型用法代码示例。如果您正苦于以下问题:PHP CheckRequirements函数的具体用法?PHP CheckRequirements怎么用?PHP CheckRequirements使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CheckRequirements函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: TestPlugin
/**
* Test to see if a plugin throws fatal errors.
*/
public function TestPlugin($PluginName, &$Validation, $Setup = FALSE)
{
// Make sure that the plugin's requirements are met
// Required Plugins
$PluginInfo = $this->GetPluginInfo($PluginName);
$RequiredPlugins = GetValue('RequiredPlugins', $PluginInfo, FALSE);
CheckRequirements($PluginName, $RequiredPlugins, $this->EnabledPlugins(), 'plugin');
// Required Themes
$EnabledThemes = Gdn::ThemeManager()->EnabledThemeInfo();
$RequiredThemes = ArrayValue('RequiredTheme', $PluginInfo, FALSE);
CheckRequirements($PluginName, $RequiredThemes, $EnabledThemes, 'theme');
// Required Applications
$EnabledApplications = Gdn::ApplicationManager()->EnabledApplications();
$RequiredApplications = ArrayValue('RequiredApplications', $PluginInfo, FALSE);
CheckRequirements($PluginName, $RequiredApplications, $EnabledApplications, 'application');
// Include the plugin, instantiate it, and call its setup method
$PluginClassName = ArrayValue('ClassName', $PluginInfo, FALSE);
$PluginFolder = ArrayValue('Folder', $PluginInfo, FALSE);
if ($PluginFolder == '') {
throw new Exception(T('The plugin folder was not properly defined.'));
}
$this->_PluginHook($PluginName, self::ACTION_ENABLE, $Setup);
// If setup succeeded, register any specified permissions
$PermissionName = GetValue('RegisterPermissions', $PluginInfo, FALSE);
if ($PermissionName != FALSE) {
$PermissionModel = Gdn::PermissionModel();
$PermissionModel->Define($PermissionName);
}
return TRUE;
}
示例3: CheckRequirements
/**
* Undocumented method.
*
* @param string $ApplicationName Undocumented variable.
* @todo Document CheckRequirements() method.
*/
public function CheckRequirements($ApplicationName)
{
$AvailableApplications = $this->AvailableApplications();
$RequiredApplications = ArrayValue('RequiredApplications', ArrayValue($ApplicationName, $AvailableApplications, array()), FALSE);
$EnabledApplications = $this->EnabledApplications();
CheckRequirements($ApplicationName, $RequiredApplications, $EnabledApplications, 'application');
}
示例4: TestTheme
public function TestTheme($ThemeName)
{
// Get some info about the currently enabled theme.
$EnabledTheme = $this->EnabledThemeInfo();
$EnabledThemeFolder = GetValue('Folder', $EnabledTheme, '');
$OldClassName = $EnabledThemeFolder . 'ThemeHooks';
// Make sure that the theme's requirements are met
$ApplicationManager = new Gdn_ApplicationManager();
$EnabledApplications = $ApplicationManager->EnabledApplications();
$NewThemeInfo = $this->GetThemeInfo($ThemeName);
$ThemeName = GetValue('Index', $NewThemeInfo, $ThemeName);
$RequiredApplications = ArrayValue('RequiredApplications', $NewThemeInfo, FALSE);
$ThemeFolder = ArrayValue('Folder', $NewThemeInfo, '');
CheckRequirements($ThemeName, $RequiredApplications, $EnabledApplications, 'application');
// Applications
// If there is a hooks file, include it and run the setup method.
$ClassName = "{$ThemeFolder}ThemeHooks";
$HooksFile = GetValue("HooksFile", $NewThemeInfo, NULL);
if (!is_null($HooksFile) && file_exists($HooksFile)) {
include_once $HooksFile;
if (class_exists($ClassName)) {
$ThemeHooks = new $ClassName();
$ThemeHooks->Setup();
}
}
// If there is a hooks in the old theme, include it and run the ondisable method.
if (class_exists($OldClassName)) {
$ThemeHooks = new $OldClassName();
if (method_exists($ThemeHooks, 'OnDisable')) {
$ThemeHooks->OnDisable();
}
}
return TRUE;
}
示例5: EnablePlugin
public function EnablePlugin($PluginName, $Validation, $Setup = FALSE)
{
// 1. Make sure that the plugin's requirements are met
// Required Plugins
$AvailablePlugins = $this->AvailablePlugins();
$RequiredPlugins = ArrayValue('RequiredPlugins', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
CheckRequirements($PluginName, $RequiredPlugins, $this->EnabledPlugins, 'plugin');
// Required Themes
$ThemeManager = new Gdn_ThemeManager();
$EnabledThemes = $ThemeManager->EnabledThemeInfo();
$RequiredThemes = ArrayValue('RequiredTheme', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
CheckRequirements($PluginName, $RequiredThemes, $EnabledThemes, 'theme');
// Required Applications
$ApplicationManager = new Gdn_ApplicationManager();
$EnabledApplications = $ApplicationManager->EnabledApplications();
$RequiredApplications = ArrayValue('RequiredApplications', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
CheckRequirements($PluginName, $RequiredApplications, $EnabledApplications, 'application');
// 2. Include the plugin, instantiate it, and call its setup method
$PluginInfo = ArrayValue($PluginName, $AvailablePlugins, FALSE);
$PluginFolder = ArrayValue('Folder', $PluginInfo, FALSE);
if ($PluginFolder == '') {
throw new Exception(Gdn::Translate('The plugin folder was not properly defined.'));
}
$this->_PluginHook($PluginName, self::ACTION_ENABLE, $Setup);
// 3. If setup succeeded, register any specified permissions
$PermissionName = ArrayValue('RegisterPermissions', $PluginInfo, FALSE);
if ($PermissionName != FALSE) {
$PermissionModel = Gdn::PermissionModel();
$PermissionModel->Define($PermissionName);
}
if (is_object($Validation) && count($Validation->Results()) > 0) {
return FALSE;
}
// 4. If everything succeeded, add the plugin to the
// $EnabledPlugins array in conf/plugins.php
// $EnabledPlugins['PluginClassName'] = 'Plugin Folder Name';
SaveToConfig('EnabledPlugins' . '.' . $PluginName, $PluginFolder);
$ApplicationManager = new Gdn_ApplicationManager();
$Locale = Gdn::Locale();
$Locale->Set($Locale->Current(), $ApplicationManager->EnabledApplicationFolders(), $this->EnabledPluginFolders(), TRUE);
return TRUE;
}
示例6: TestTheme
public function TestTheme($ThemeName)
{
// Get some info about the currently enabled theme.
$EnabledTheme = $this->EnabledThemeInfo();
$EnabledThemeFolder = GetValue('Folder', $EnabledTheme, '');
$OldClassName = $EnabledThemeFolder . 'ThemeHooks';
// 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);
$ThemeFolder = ArrayValue('Folder', $NewThemeInfo, '');
CheckRequirements($ThemeName, $RequiredApplications, $EnabledApplications, 'application');
// Applications
// If there is a hooks file, include it and run the setup method.
$ClassName = $ThemeFolder . 'ThemeHooks';
$HooksFile = PATH_THEMES . DS . $ThemeFolder . DS . 'class.' . strtolower($ClassName) . '.php';
if (file_exists($HooksFile)) {
include $HooksFile;
if (class_exists($ClassName)) {
$ThemeHooks = new $ClassName();
$ThemeHooks->Setup();
}
}
// If there is a hooks in the old theme, include it and run the ondisable method.
if (class_exists($OldClassName)) {
$ThemeHooks = new $OldClassName();
$ThemeHooks->OnDisable();
}
return TRUE;
}
示例7: EnablePlugin
public function EnablePlugin($PluginName, $Validation, $Setup = FALSE)
{
// 1. Make sure that the plugin's requirements are met
// Required Plugins
$AvailablePlugins = $this->AvailablePlugins();
$RequiredPlugins = ArrayValue('RequiredPlugins', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
CheckRequirements($PluginName, $RequiredPlugins, $this->EnabledPlugins, 'plugin');
// Required Themes
$ThemeManager = new Gdn_ThemeManager();
$EnabledThemes = $ThemeManager->EnabledThemeInfo();
$RequiredThemes = ArrayValue('RequiredTheme', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
CheckRequirements($PluginName, $RequiredThemes, $EnabledThemes, 'theme');
// Required Applications
$ApplicationManager = new Gdn_ApplicationManager();
$EnabledApplications = $ApplicationManager->EnabledApplications();
$RequiredApplications = ArrayValue('RequiredApplications', ArrayValue($PluginName, $AvailablePlugins, array()), FALSE);
CheckRequirements($PluginName, $RequiredApplications, $EnabledApplications, 'application');
// 2. Include the plugin, instantiate it, and call it's setup method
$PluginInfo = ArrayValue($PluginName, $AvailablePlugins, FALSE);
$PluginFolder = ArrayValue('Folder', $PluginInfo, FALSE);
if ($PluginFolder == '') {
throw new Exception(Gdn::Translate('The plugin folder was not properly defined.'));
}
$PluginClassName = ArrayValue('ClassName', $PluginInfo, FALSE);
if ($PluginFolder !== FALSE && $PluginClassName !== FALSE && class_exists($PluginClassName) === FALSE) {
$this->IncludePlugins(array($PluginName => $PluginFolder));
if (class_exists($PluginClassName)) {
$Plugin = new $PluginClassName();
$Plugin->Setup();
}
} elseif (class_exists($PluginClassName, FALSE) !== FALSE && $Setup === TRUE) {
$Plugin = new $PluginClassName();
$Plugin->Setup();
}
// 3. If setup succeeded, register any specified permissions
$PermissionName = ArrayValue('RegisterPermissions', $PluginInfo, FALSE);
if ($PermissionName != FALSE) {
$PermissionModel = Gdn::PermissionModel();
$PermissionModel->Define($PermissionName);
}
if (is_object($Validation) && count($Validation->Results()) > 0) {
return FALSE;
}
// 4. If everything succeeded, add the plugin to the
// $EnabledPlugins array in conf/plugins.php
// $EnabledPlugins['PluginClassName'] = 'Plugin Folder Name';
$Config = Gdn::Factory(Gdn::AliasConfig);
$Config->Load(PATH_CONF . DS . 'config.php', 'Save');
$Config->Set('EnabledPlugins' . '.' . $PluginName, $PluginFolder);
$Config->Save();
$ApplicationManager = new Gdn_ApplicationManager();
$Locale = Gdn::Locale();
$Locale->Set($Locale->Current(), $ApplicationManager->EnabledApplicationFolders(), $this->EnabledPluginFolders(), TRUE);
return TRUE;
}
示例8: AddNewKey
function AddNewKey($Key)
{
global $Db, $nsProduct, $BF, $Logs, $Lang;
$Key = str_replace("\n", "", $Key);
$KEY_DECODE = $BF->decrypt($Key);
$License = GetLicenseText($KEY_DECODE);
if (!$License) {
$Logs->Err($Lang['KeyHasNoInfo']);
return;
}
if ($nsProduct->LICENSE == 1 && !isset($License['P'])) {
$Logs->Err($Lang['SecondaryKeyErr']);
return;
}
$KeyId = intval(ValidVar($License['ID']));
if (!ValidId($KeyId) || $KeyId == 0) {
$Logs->Err($Lang['KeyIsInvalid']);
return;
}
if (ValidVar($License['L']) != intval(ValidVar($License['L']))) {
$Logs->Err($Lang['KeyIsInvalid']);
return;
}
$Query = "SELECT ID FROM " . PFX . "_tracker_license WHERE KEY_ID={$KeyId} OR LICENSE_KEY='{$Key}'";
$CheckId = $Db->ReturnValue($Query);
if (ValidId($CheckId)) {
$Logs->Err($Lang['KeyExists']);
return;
}
if (CompareVersions($License['V'], $nsProduct->VERSION, 1) != 0) {
$Logs->Err($Lang['KeyIsInvalid']);
return;
}
if (isset($License['REQ']) && !CheckRequirements($License['REQ'])) {
$Logs->Err($Lang['RequiredNotFound']);
return false;
}
$Query = "INSERT INTO " . PFX . "_tracker_license (LICENSE_KEY, STAMP, KEY_ID) VALUES ('{$Key}', NOW(), {$KeyId})";
$Db->Query($Query);
$nsProduct->Redir("license", "RCrt=1", "admin");
}