Class: Settings::Controller::Settings
- Inherits:
-
Zen::Controller::AdminController
- Object
- Ramaze::Controller
- Zen::Controller::BaseController
- Zen::Controller::AdminController
- Settings::Controller::Settings
- Defined in:
- lib/zen/package/settings/lib/settings/controller/settings.rb
Overview
Controller for managing settings. Settings are used to store the name of
the website, what anti-spam system to use and so on. These settings can be
managed via the admin interface rather than having to edit configuration
files. Settings can be managed by going to /admin/settings. This page
shows an overview of all the available settings organized in a number of
groups where each group is placed under it's own tab. An example of this
overview can be seen in the image below.
Out of the box Zen ships with the following settings:
- Website name: the name of the website.
- Website description: a short description of the website.
- Language: the default language to use for the admin interface.
- Frontend Language: the default language to use for the frontend of your website.
- Theme: the theme to use for the frontend.
- Date format: the default date format to use in the backend.
- Enable anti-spam: whether or not comments should be verified to see if they're spam or ham.
- Anti-spam system: the anti-spam system to use. Zen by default only comes with Defensio support.
- Defensio key: the API key for the Defensio anti-spam system.
- Allow Registration: defines whether or not visitors are allowed to register a user account.
Used Permissions
This controller uses the following permissions:
- show_setting
- edit_setting
Events
Unlike other controllers events in this controller do not receive an
instance of a model. Instead they'll receive an instance of
Plugin::SettingBase. In order to update the value of a setting
you'll simply call #value=() and specify a new value.
Instance Method Summary (collapse)
-
- (Object) index
Show all settings and allow the user to change them.
-
- (Object) save
Updates all the settings in both the database and the cache (Ramaze::Cache.settings).
Instance Method Details
- (Object) index
Show all settings and allow the user to change them.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/zen/package/settings/lib/settings/controller/settings.rb', line 89 def index (:show_setting) (lang('settings.titles.index')) @settings_ordered = {} @groups = ::Settings::SettingsGroup::REGISTERED # Organize the settings so that each item is a child # item of it's group. ::Settings::Setting::REGISTERED.each do |name, setting| if !@settings_ordered.key?(setting.group) @settings_ordered[setting.group] = [] end @settings_ordered[setting.group].push(setting) end end |
- (Object) save
Updates all the settings in both the database and the cache (Ramaze::Cache.settings).
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/zen/package/settings/lib/settings/controller/settings.rb', line 116 def save (:edit_setting) post = request.params post.delete('csrf_token') post.delete('id') success = lang('settings.success.save') error = lang('settings.errors.save') # Update all settings post.each do |key, value| setting = get_setting(key) begin setting.value = value rescue => e Ramaze::Log.error(e.inspect) (:error, error) flash[:form_errors] = setting.errors redirect_referrer end Zen::Event.call(:after_edit_setting, setting) end (:success, success) redirect_referrer end |