I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
ConfigUIHandler.java 1.34 KiB
Newer Older
  • Learn to ignore specific revisions
  • zzz's avatar
    zzz committed
    package net.i2p.router.web;
    
    /** set the theme */
    public class ConfigUIHandler extends FormHandler {
        private boolean _shouldSave;
        private String _config;
        
    
        @Override
    
    zzz's avatar
    zzz committed
        protected void processForm() {
            if (_shouldSave)
                saveChanges();
        }
        
        public void setShouldsave(String moo) { _shouldSave = true; }
        
        public void setTheme(String val) {
            _config = val;
        }
        
    
    zzz's avatar
    zzz committed
        /** note - lang change is handled in CSSHelper but we still need to save it here */
    
    zzz's avatar
    zzz committed
        private void saveChanges() {
            if (_config == null)
                return;
    
    zzz's avatar
    zzz committed
            String oldTheme = _context.getProperty(CSSHelper.PROP_THEME_NAME, CSSHelper.DEFAULT_THEME);
    
            if (_config.equals("default")) // obsolete
    
    zzz's avatar
    zzz committed
                _context.router().removeConfigSetting(CSSHelper.PROP_THEME_NAME);
    
    zzz's avatar
    zzz committed
            else
    
    zzz's avatar
    zzz committed
                _context.router().setConfigSetting(CSSHelper.PROP_THEME_NAME, _config);
    
    zzz's avatar
    zzz committed
            if (_context.router().saveConfig()) {
                if (!oldTheme.equals(_config))
                    addFormNotice(_("Theme change saved.") +
    
    zzz's avatar
    zzz committed
                                  " <a href=\"configui\">" +
    
    zzz's avatar
    zzz committed
                                  _("Refresh the page to view.") +
                                  "</a>");
            } else {
    
    zzz's avatar
    zzz committed
                addFormError(_("Error saving the configuration (applied but not saved) - please see the error logs."));
    
    zzz's avatar
    zzz committed
            }
    
    zzz's avatar
    zzz committed
        }
    }