Exemple #1
0
        private void UpdateUI(PHPIniFile file)
        {
            PHPIniSetting setting = file.GetSetting(_settingNames[0]);

            string[] settingValues = null;

            if (setting != null)
            {
                if (String.Equals(setting.GetTrimmedValue(), _settingsDevValues[0]))
                {
                    _errorReportingPreset = ErrorReportingPreset.Development;
                    settingValues         = _settingsDevValues;
                }
                else if (String.Equals(setting.GetTrimmedValue(), _settingsProdValues[0]))
                {
                    _errorReportingPreset = ErrorReportingPreset.Production;
                    settingValues         = _settingsProdValues;
                }

                int i    = 1;
                var php7 = new Version(Module.Proxy.GetPHPConfigInfo().Version) >= new Version("7.2");
                while (_errorReportingPreset != ErrorReportingPreset.Undefined && i < _settingNames.Length)
                {
                    if (php7 && _settingNames[i] == "track_errors")
                    {
                        // IMPORTANT: skip obsolete setting.
                        i++;
                        continue;
                    }

                    setting = file.GetSetting(_settingNames[i]);
                    if (setting == null || !String.Equals(setting.GetTrimmedValue(), settingValues[i]))
                    {
                        _errorReportingPreset = ErrorReportingPreset.Undefined;
                    }

                    i++;
                }
            }

            if (_errorReportingPreset == ErrorReportingPreset.Development)
            {
                _devMachineRadioButton.Checked = true;
            }
            else if (_errorReportingPreset == ErrorReportingPreset.Production)
            {
                _prodMachineRadioButton.Checked = true;
            }

            setting = file.GetSetting("error_log");
            if (setting != null)
            {
                _errorLogFile             = setting.GetTrimmedValue();
                _errorLogFileTextBox.Text = setting.GetTrimmedValue();
            }
        }
        protected override bool ApplyChanges()
        {
            bool appliedChanges = false;

            string[] settingValues = null;

            Debug.Assert(_devMachineRadioButton.Checked || _prodMachineRadioButton.Checked);
            if (_devMachineRadioButton.Checked)
            {
                settingValues = SettingsDevValues;
            }
            else if (_prodMachineRadioButton.Checked)
            {
                settingValues = SettingsProdValues;
            }

            RemoteObjectCollection <PHPIniSetting> settings = new RemoteObjectCollection <PHPIniSetting>();

            for (int i = 0; i < settingValues.Length; i++)
            {
                settings.Add(new PHPIniSetting(SettingNames[i], settingValues[i], "PHP"));
            }

            string errorLogValue = '"' + _errorLogFileTextBox.Text.Trim(new char [] { ' ', '"' }) + '"';

            settings.Add(new PHPIniSetting("error_log", errorLogValue, "PHP"));

            try
            {
                Module.Proxy.AddOrUpdateSettings(settings);
                appliedChanges = true;

                // Update the values used for determining if changes have been made
                _errorLogFile = _errorLogFileTextBox.Text;
                if (_devMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Development;
                }
                else if (_prodMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Production;
                }
                _hasChanges = false;
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
            finally
            {
                Update();
            }

            return(appliedChanges);
        }
        private void UpdateUI(PHPIniFile file)
        {
            PHPIniSetting setting = file.GetSetting(SettingNames[0]);

            string[] settingValues = null;

            if (setting != null)
            {
                if (String.Equals(setting.GetTrimmedValue(), SettingsDevValues[0]))
                {
                    _errorReportingPreset = ErrorReportingPreset.Development;
                    settingValues         = SettingsDevValues;
                }
                else if (String.Equals(setting.GetTrimmedValue(), SettingsProdValues[0]))
                {
                    _errorReportingPreset = ErrorReportingPreset.Production;
                    settingValues         = SettingsProdValues;
                }

                int i = 1;
                while (_errorReportingPreset != ErrorReportingPreset.Undefined && i < SettingNames.Length)
                {
                    setting = file.GetSetting(SettingNames[i]);
                    if (setting == null || !String.Equals(setting.GetTrimmedValue(), settingValues[i]))
                    {
                        _errorReportingPreset = ErrorReportingPreset.Undefined;
                    }
                    i = i + 1;
                }
            }

            if (_errorReportingPreset == ErrorReportingPreset.Development)
            {
                _devMachineRadioButton.Checked = true;
            }
            else if (_errorReportingPreset == ErrorReportingPreset.Production)
            {
                _prodMachineRadioButton.Checked = true;
            }

            setting = file.GetSetting("error_log");
            if (setting != null)
            {
                _errorLogFile             = setting.GetTrimmedValue();
                _errorLogFileTextBox.Text = setting.GetTrimmedValue();
            }
        }
Exemple #4
0
        protected override bool ApplyChanges()
        {
            var appliedChanges = false;

            string[] settingValues = null;

            Debug.Assert(_devMachineRadioButton.Checked || _prodMachineRadioButton.Checked);
            if (_devMachineRadioButton.Checked)
            {
                settingValues = _settingsDevValues;
            }
            else if (_prodMachineRadioButton.Checked)
            {
                settingValues = _settingsProdValues;
            }

            var php7     = new Version(Module.Proxy.GetPHPConfigInfo().Version) >= new Version("7.2");
            var settings = new RemoteObjectCollection <PHPIniSetting>();

            for (int i = 0; i < settingValues.Length; i++)
            {
                if (php7 && _settingNames[i] == "track_errors")
                {
                    // IMPORTANT: skip obsolete setting.
                    continue;
                }

                settings.Add(new PHPIniSetting(_settingNames[i], settingValues[i], "PHP"));
            }

            string errorLogValue = '"' + _errorLogFileTextBox.Text.Trim(new[] { ' ', '"' }) + '"';

            settings.Add(new PHPIniSetting("error_log", errorLogValue, "PHP"));

            try
            {
                Module.Proxy.AddOrUpdateSettings(settings);
                appliedChanges = true;

                // Update the values used for determining if changes have been made
                _errorLogFile = _errorLogFileTextBox.Text;
                if (_devMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Development;
                }
                else if (_prodMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Production;
                }
                _hasChanges = false;
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
            finally
            {
                Update();
            }

            return(appliedChanges);
        }
        private void UpdateUI(PHPIniFile file)
        {
            PHPIniSetting setting = file.GetSetting(SettingNames[0]);
            string[] settingValues = null;

            if (setting != null)
            {
                if (String.Equals(setting.TrimmedValue, SettingsDevValues[0]))
                {
                    _errorReportingPreset = ErrorReportingPreset.Development;
                    settingValues = SettingsDevValues;
                }
                else if (String.Equals(setting.TrimmedValue, SettingsProdValues[0]))
                {
                    _errorReportingPreset = ErrorReportingPreset.Production;
                    settingValues = SettingsProdValues;
                }

                int i = 1;
                while (_errorReportingPreset != ErrorReportingPreset.Undefined && i < SettingNames.Length)
                {
                    setting = file.GetSetting(SettingNames[i]);
                    if (setting == null || !String.Equals(setting.TrimmedValue, settingValues[i]))
                    {
                        _errorReportingPreset = ErrorReportingPreset.Undefined;
                    }
                    i = i + 1;
                }
            }

            if (_errorReportingPreset == ErrorReportingPreset.Development)
            {
                _devMachineRadioButton.Checked = true;
            }
            else if (_errorReportingPreset == ErrorReportingPreset.Production)
            {
                _prodMachineRadioButton.Checked = true;
            }

            setting = file.GetSetting("error_log");
            if (setting != null)
            {
                _errorLogFile = setting.TrimmedValue;
                _errorLogFileTextBox.Text = setting.TrimmedValue;
            }
        }
        protected override bool ApplyChanges()
        {
            bool appliedChanges = false;

            string[] settingValues = null;

            Debug.Assert(_devMachineRadioButton.Checked || _prodMachineRadioButton.Checked);
            if (_devMachineRadioButton.Checked)
            {
                settingValues = SettingsDevValues;
            }
            else if (_prodMachineRadioButton.Checked)
            {
                settingValues = SettingsProdValues;
            }

            RemoteObjectCollection<PHPIniSetting> settings = new RemoteObjectCollection<PHPIniSetting>();
            for (int i = 0; i < settingValues.Length; i++)
            {
                settings.Add(new PHPIniSetting(SettingNames[i], settingValues[i], "PHP"));
            }

            string errorLogValue = '"' + _errorLogFileTextBox.Text.Trim(new char [] {' ', '"'}) + '"';
            settings.Add(new PHPIniSetting("error_log", errorLogValue, "PHP"));

            try
            {
                Module.Proxy.AddOrUpdateSettings(settings);
                appliedChanges = true;
                
                // Update the values used for determining if changes have been made
                _errorLogFile = _errorLogFileTextBox.Text;
                if (_devMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Development;
                }
                else if (_prodMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Production;
                }
                _hasChanges = false;
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
            finally
            {
                Update();
            }

            return appliedChanges;
        }