zen 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gems +17 -15
- data/.gitignore +1 -1
- data/.travis.yml +1 -1
- data/MANIFEST +470 -0
- data/README.md +5 -3
- data/Rakefile +8 -6
- data/bin/zen +2 -7
- data/guide/asset_management.md +1 -0
- data/guide/autosaving_forms.md +1 -0
- data/guide/changelog.md +22 -0
- data/guide/faq.md +1 -0
- data/guide/getting_started.md +1 -0
- data/guide/hacking.md +1 -0
- data/guide/images/sections/revisions.png +0 -0
- data/guide/images/sections/revisions_diff.png +0 -0
- data/guide/images/sections/revisions_diff_multiple.png +0 -0
- data/guide/installation.md +4 -3
- data/guide/javascript.md +1 -0
- data/guide/javascript/zen_autosave.md +1 -0
- data/guide/javascript/zen_editor.md +1 -0
- data/guide/javascript/zen_form.md +1 -0
- data/guide/javascript/zen_hash.md +1 -0
- data/guide/javascript/zen_htmltable.md +1 -0
- data/guide/javascript/zen_tabs.md +1 -0
- data/guide/javascript/zen_window.md +1 -0
- data/guide/zen_compared.md +1 -0
- data/lib/zen.rb +10 -12
- data/lib/zen/event.rb +2 -2
- data/lib/zen/helper/controller.rb +13 -13
- data/lib/zen/helper/message.rb +3 -3
- data/lib/zen/helper/search.rb +4 -4
- data/lib/zen/helper/stacked_aspect.rb +9 -9
- data/lib/zen/html_diff.rb +151 -0
- data/lib/zen/language.rb +9 -7
- data/lib/zen/language/translation.rb +8 -8
- data/lib/zen/markup.rb +1 -1
- data/lib/zen/migrator.rb +2 -2
- data/lib/zen/model/helper.rb +4 -4
- data/lib/zen/model/plugin/events.rb +16 -16
- data/lib/zen/package.rb +2 -2
- data/lib/zen/package/all.rb +1 -1
- data/lib/zen/package/categories/lib/categories/controller/categories.rb +4 -4
- data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +4 -4
- data/lib/zen/package/categories/lib/categories/helper/category.rb +3 -3
- data/lib/zen/package/categories/lib/categories/model/category.rb +9 -9
- data/lib/zen/package/categories/lib/categories/model/category_group.rb +9 -9
- data/lib/zen/package/comments/lib/comments/controller/comments.rb +4 -4
- data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +2 -2
- data/lib/zen/package/comments/lib/comments/helper/comment.rb +1 -1
- data/lib/zen/package/comments/lib/comments/model/comment.rb +13 -13
- data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +1 -1
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +4 -4
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +6 -6
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +5 -5
- data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +3 -3
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +9 -9
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb +9 -9
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb +9 -9
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +8 -3
- data/lib/zen/package/custom_fields/migrations/1336171490_revisions.rb +41 -0
- data/lib/zen/package/dashboard/lib/dashboard/controller/dashboard.rb +6 -6
- data/lib/zen/package/dashboard/lib/dashboard/model/widget.rb +3 -3
- data/lib/zen/package/dashboard/lib/dashboard/widget.rb +12 -12
- data/lib/zen/package/extensions/lib/extensions/controller/extensions.rb +3 -3
- data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +5 -5
- data/lib/zen/package/menus/lib/menus/controller/menus.rb +4 -4
- data/lib/zen/package/menus/lib/menus/helper/menu.rb +4 -4
- data/lib/zen/package/menus/lib/menus/model/menu.rb +11 -11
- data/lib/zen/package/menus/lib/menus/model/menu_item.rb +10 -10
- data/lib/zen/package/menus/lib/menus/public/admin/menus/js/lib/nested_sortables.js +13 -13
- data/lib/zen/package/menus/lib/menus/public/admin/menus/js/menu_items.js +1 -1
- data/lib/zen/package/sections/lib/sections.rb +19 -0
- data/lib/zen/package/sections/lib/sections/controller/revisions.rb +184 -0
- data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +5 -5
- data/lib/zen/package/sections/lib/sections/controller/sections.rb +9 -6
- data/lib/zen/package/sections/lib/sections/helper/revision.rb +124 -0
- data/lib/zen/package/sections/lib/sections/helper/section.rb +17 -15
- data/lib/zen/package/sections/lib/sections/helper/section_frontend.rb +104 -6
- data/lib/zen/package/sections/lib/sections/language/en/revisions.rb +34 -0
- data/lib/zen/package/sections/lib/sections/language/en/sections.rb +1 -0
- data/lib/zen/package/sections/lib/sections/language/nl/revisions.rb +35 -0
- data/lib/zen/package/sections/lib/sections/language/nl/sections.rb +1 -0
- data/lib/zen/package/sections/lib/sections/model/revision.rb +76 -0
- data/lib/zen/package/sections/lib/sections/model/section.rb +9 -9
- data/lib/zen/package/sections/lib/sections/model/section_entry.rb +47 -12
- data/lib/zen/package/sections/lib/sections/view/admin/revisions/index.xhtml +89 -0
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +1 -1
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +14 -0
- data/lib/zen/package/sections/migrations/1335711557_revisions.rb +40 -0
- data/lib/zen/package/settings/lib/settings/controller/settings.rb +12 -4
- data/lib/zen/package/settings/lib/settings/setting.rb +6 -6
- data/lib/zen/package/users/lib/users/controller/user_groups.rb +4 -4
- data/lib/zen/package/users/lib/users/controller/users.rb +12 -12
- data/lib/zen/package/users/lib/users/helper/access.rb +1 -1
- data/lib/zen/package/users/lib/users/helper/acl.rb +4 -4
- data/lib/zen/package/users/lib/users/helper/users.rb +2 -2
- data/lib/zen/package/users/lib/users/model/permission.rb +1 -1
- data/lib/zen/package/users/lib/users/model/user.rb +11 -11
- data/lib/zen/package/users/lib/users/model/user_group.rb +9 -9
- data/lib/zen/package/users/lib/users/model/user_status.rb +2 -2
- data/lib/zen/public/admin/zen/css/general.css +54 -0
- data/lib/zen/public/admin/zen/css/messages.css +6 -3
- data/lib/zen/public/admin/zen/css/tables.css +10 -0
- data/lib/zen/public/admin/zen/images/icons/undo.png +0 -0
- data/lib/zen/public/admin/zen/js/lib/autosave.js +8 -8
- data/lib/zen/public/admin/zen/js/lib/base.js +2 -2
- data/lib/zen/public/admin/zen/js/lib/events.js +2 -2
- data/lib/zen/public/admin/zen/js/lib/form.js +7 -7
- data/lib/zen/public/admin/zen/js/lib/hash.js +7 -7
- data/lib/zen/public/admin/zen/js/lib/tabs.js +3 -3
- data/lib/zen/public/admin/zen/js/lib/window.js +1 -1
- data/lib/zen/security.rb +2 -2
- data/lib/zen/spec/helper.rb +3 -9
- data/lib/zen/spec/helper/capybara.rb +4 -4
- data/lib/zen/spec/helper/general.rb +1 -1
- data/lib/zen/spec/simplecov.rb +1 -5
- data/lib/zen/task/build.rake +22 -16
- data/lib/zen/task/db.rake +3 -2
- data/lib/zen/task/spelling.rake +10 -10
- data/lib/zen/task/test.rake +27 -19
- data/lib/zen/theme.rb +6 -6
- data/lib/zen/version.rb +1 -1
- data/spec/zen/all.rb +4 -0
- data/spec/zen/package/sections/controller/revisions.rb +235 -0
- data/spec/zen/package/sections/model/revision.rb +76 -0
- data/zen.gemspec +23 -21
- metadata +88 -29
- data/lib/zen/model/methods.rb +0 -27
- data/lib/zen/task/clean.rake +0 -20
- data/lib/zen/task/setup.rake +0 -4
- data/pkg/.gitkeep +0 -0
@@ -5,12 +5,12 @@ module CustomFields
|
|
5
5
|
# Model that represents a single custom field group.
|
6
6
|
#
|
7
7
|
# @since 0.1
|
8
|
-
# @event
|
9
|
-
# @event
|
10
|
-
# @event
|
11
|
-
# @event
|
12
|
-
# @event
|
13
|
-
# @event
|
8
|
+
# @event before\_new\_custom\_field\_group
|
9
|
+
# @event after\_new\_custom\_field\_group
|
10
|
+
# @event before\_edit\_custom\_field\_group
|
11
|
+
# @event after\_edit\_custom\_field\_group
|
12
|
+
# @event before\_delete\_custom\_field\_group
|
13
|
+
# @event after\_delete\_custom\_field\_group
|
14
14
|
#
|
15
15
|
class CustomFieldGroup < Sequel::Model
|
16
16
|
include Zen::Model::Helper
|
@@ -18,7 +18,7 @@ module CustomFields
|
|
18
18
|
##
|
19
19
|
# Array containing the columns that can be set by the user.
|
20
20
|
#
|
21
|
-
# @since
|
21
|
+
# @since 2012-02-17
|
22
22
|
#
|
23
23
|
COLUMNS = [:name, :description]
|
24
24
|
|
@@ -41,7 +41,7 @@ module CustomFields
|
|
41
41
|
##
|
42
42
|
# Searches for a set of custom field groups.
|
43
43
|
#
|
44
|
-
# @since
|
44
|
+
# @since 2011-10-16
|
45
45
|
# @param [String] query The search query.
|
46
46
|
# @return [Mixed]
|
47
47
|
#
|
@@ -62,7 +62,7 @@ module CustomFields
|
|
62
62
|
##
|
63
63
|
# Hook that is executed before creating or saving an object.
|
64
64
|
#
|
65
|
-
# @since
|
65
|
+
# @since 2012-01-03
|
66
66
|
#
|
67
67
|
def before_save
|
68
68
|
sanitize_fields([:name, :description])
|
@@ -5,12 +5,12 @@ module CustomFields
|
|
5
5
|
# Model for managing custom field types.
|
6
6
|
#
|
7
7
|
# @since 0.2.8
|
8
|
-
# @event
|
9
|
-
# @event
|
10
|
-
# @event
|
11
|
-
# @event
|
12
|
-
# @event
|
13
|
-
# @event
|
8
|
+
# @event before\_new\_custom\_field\_type
|
9
|
+
# @event after\_new\_custom\_field\_type
|
10
|
+
# @event before\_edit\_custom\_field\_type
|
11
|
+
# @event after\_edit\_custom\_field\_type
|
12
|
+
# @event before\_delete\_custom\_field\_type
|
13
|
+
# @event after\_delete\_custom\_field\_type
|
14
14
|
#
|
15
15
|
class CustomFieldType < Sequel::Model
|
16
16
|
include Zen::Model::Helper
|
@@ -18,7 +18,7 @@ module CustomFields
|
|
18
18
|
##
|
19
19
|
# Array containing all the columns that can be set by the user.
|
20
20
|
#
|
21
|
-
# @since
|
21
|
+
# @since 2012-02-17
|
22
22
|
#
|
23
23
|
COLUMNS = [
|
24
24
|
:name, :language_string, :html_class, :serialize, :allow_markup,
|
@@ -43,7 +43,7 @@ module CustomFields
|
|
43
43
|
##
|
44
44
|
# Searches for a set of custom field types.
|
45
45
|
#
|
46
|
-
# @since
|
46
|
+
# @since 2011-10-16
|
47
47
|
# @param [String] query The search query.
|
48
48
|
# @return [Mixed]
|
49
49
|
#
|
@@ -87,7 +87,7 @@ module CustomFields
|
|
87
87
|
##
|
88
88
|
# Hook that is executed before creating or saving an object.
|
89
89
|
#
|
90
|
-
# @since
|
90
|
+
# @since 2012-01-03
|
91
91
|
#
|
92
92
|
def before_save
|
93
93
|
sanitize_fields([:name, :language_string, :html_class])
|
@@ -7,16 +7,21 @@ module CustomFields
|
|
7
7
|
# @since 0.1
|
8
8
|
#
|
9
9
|
class CustomFieldValue < Sequel::Model
|
10
|
-
many_to_one :custom_field ,
|
10
|
+
many_to_one :custom_field ,
|
11
|
+
:class => 'CustomFields::Model::CustomField',
|
11
12
|
:eager => [:custom_field_type]
|
12
13
|
|
13
|
-
many_to_one :section_entry,
|
14
|
+
many_to_one :section_entry,
|
15
|
+
:class => 'Sections::Model::SectionEntry'
|
16
|
+
|
17
|
+
many_to_one :revision,
|
18
|
+
:class => 'Sections::Model::Revision'
|
14
19
|
|
15
20
|
##
|
16
21
|
# Sets the value and serializes it based on the field type.
|
17
22
|
#
|
18
23
|
# @since 0.2.8
|
19
|
-
# @param [Mixed]
|
24
|
+
# @param [Mixed] val The value to store.
|
20
25
|
#
|
21
26
|
def value=(val)
|
22
27
|
val = Zen::Security.sanitize(val)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
up do
|
3
|
+
alter_table :custom_field_values do
|
4
|
+
add_foreign_key :revision_id, :revisions,
|
5
|
+
:on_update => :cascade,
|
6
|
+
:on_delete => :cascade,
|
7
|
+
:key => :id
|
8
|
+
end
|
9
|
+
|
10
|
+
# Create a revision for each existing entry.
|
11
|
+
entries = Zen.database[:section_entries] \
|
12
|
+
.select(:id, :user_id) \
|
13
|
+
.order(:id.asc)
|
14
|
+
|
15
|
+
entries.each do |entry|
|
16
|
+
rev_id = Zen.database[:revisions].insert(
|
17
|
+
:created_at => Time.now,
|
18
|
+
:user_id => entry[:user_id],
|
19
|
+
:section_entry_id => entry[:id]
|
20
|
+
)
|
21
|
+
|
22
|
+
Zen.database[:section_entries] \
|
23
|
+
.filter(:id => entry[:id]) \
|
24
|
+
.update(:revision_id => rev_id)
|
25
|
+
|
26
|
+
Zen.database[:custom_field_values] \
|
27
|
+
.filter(:section_entry_id => entry[:id]) \
|
28
|
+
.update(:revision_id => rev_id)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
down do
|
33
|
+
alter_table :custom_field_values do
|
34
|
+
if Zen.database.database_type.to_s.include?('mysql')
|
35
|
+
drop_constraint :custom_field_values_ibfk_3, :type => :foreign_key
|
36
|
+
end
|
37
|
+
|
38
|
+
drop_column :revision_id
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# * {Dashboard::Widget}
|
15
15
|
# * {Dashboard::WidgetError}
|
16
16
|
#
|
17
|
-
# @since
|
17
|
+
# @since 2012-01-16
|
18
18
|
#
|
19
19
|
module Dashboard
|
20
20
|
module Controller
|
@@ -58,7 +58,7 @@ module Dashboard
|
|
58
58
|
# around the application.
|
59
59
|
# * Recent Entries: a widget that displays the 10 most recent entries.
|
60
60
|
#
|
61
|
-
# @since
|
61
|
+
# @since 2012-01-08
|
62
62
|
# @map /admin
|
63
63
|
#
|
64
64
|
class Dashboard < Zen::Controller::AdminController
|
@@ -75,7 +75,7 @@ module Dashboard
|
|
75
75
|
# Shows all the active widgets and allows the user to manage these widgets
|
76
76
|
# or add new ones.
|
77
77
|
#
|
78
|
-
# @since
|
78
|
+
# @since 2012-01-08
|
79
79
|
#
|
80
80
|
def index; end
|
81
81
|
|
@@ -83,7 +83,7 @@ module Dashboard
|
|
83
83
|
# Updates the sort order of all the widgets for the currently logged in
|
84
84
|
# user.
|
85
85
|
#
|
86
|
-
# @since
|
86
|
+
# @since 2012-01-15
|
87
87
|
#
|
88
88
|
def widget_order
|
89
89
|
::Dashboard::Widget::REGISTERED.each do |name, widget|
|
@@ -105,7 +105,7 @@ module Dashboard
|
|
105
105
|
##
|
106
106
|
# Enables or disables a widget for the currently logged in user.
|
107
107
|
#
|
108
|
-
# @since
|
108
|
+
# @since 2012-01-15
|
109
109
|
#
|
110
110
|
def widget_state
|
111
111
|
widget = request.POST['widget']
|
@@ -140,7 +140,7 @@ module Dashboard
|
|
140
140
|
# Updates the amount of widget columns to use for the currently logged in
|
141
141
|
# user.
|
142
142
|
#
|
143
|
-
# @since
|
143
|
+
# @since 2012-01-15
|
144
144
|
#
|
145
145
|
def widget_columns
|
146
146
|
columns = request.POST['columns']
|
@@ -3,7 +3,7 @@ module Dashboard
|
|
3
3
|
##
|
4
4
|
# Model for the table that contains the active widgets for a user.
|
5
5
|
#
|
6
|
-
# @since
|
6
|
+
# @since 2012-01-12
|
7
7
|
#
|
8
8
|
class Widget < Sequel::Model
|
9
9
|
many_to_one :users, :class => 'Users::Model::User'
|
@@ -12,7 +12,7 @@ module Dashboard
|
|
12
12
|
# Returns an integer containing the order of the last widget. If no
|
13
13
|
# widgets were found 0 is returned.
|
14
14
|
#
|
15
|
-
# @since
|
15
|
+
# @since 2012-01-15
|
16
16
|
# @param [Fixnum] user_id The ID of the user for which to retrieve the
|
17
17
|
# widget order.
|
18
18
|
# @return [Fixnum]
|
@@ -34,7 +34,7 @@ module Dashboard
|
|
34
34
|
##
|
35
35
|
# Validates the model instance before saving it in the database.
|
36
36
|
#
|
37
|
-
# @since
|
37
|
+
# @since 2012-01-13
|
38
38
|
#
|
39
39
|
def validate
|
40
40
|
validates_presence([:name, :order, :user_id])
|
@@ -36,7 +36,7 @@ module Dashboard
|
|
36
36
|
#
|
37
37
|
# Dashboard::Widget[:example_widget] # => <Dashboard::Widget ...>
|
38
38
|
#
|
39
|
-
# @since
|
39
|
+
# @since 2012-01-08
|
40
40
|
#
|
41
41
|
class Widget
|
42
42
|
include Zen::Validation
|
@@ -75,7 +75,7 @@ module Dashboard
|
|
75
75
|
# end
|
76
76
|
# end
|
77
77
|
#
|
78
|
-
# @since
|
78
|
+
# @since 2012-01-08
|
79
79
|
#
|
80
80
|
def add
|
81
81
|
widget = self.new
|
@@ -92,7 +92,7 @@ module Dashboard
|
|
92
92
|
# @example
|
93
93
|
# Dashboard::Widget[:recent_entries]
|
94
94
|
#
|
95
|
-
# @since
|
95
|
+
# @since 2012-01-08
|
96
96
|
#
|
97
97
|
def [](name)
|
98
98
|
name = name.to_sym
|
@@ -108,7 +108,7 @@ module Dashboard
|
|
108
108
|
# Generates the HTML for all active widgets and sorts them by the user's
|
109
109
|
# sort order.
|
110
110
|
#
|
111
|
-
# @since
|
111
|
+
# @since 2012-01-14
|
112
112
|
# @return [String]
|
113
113
|
#
|
114
114
|
def html
|
@@ -129,7 +129,7 @@ module Dashboard
|
|
129
129
|
# Builds the HTML for the radio buttons that can be used to change the
|
130
130
|
# amount of widget columns.
|
131
131
|
#
|
132
|
-
# @since
|
132
|
+
# @since 2012-01-15
|
133
133
|
# @return [String]
|
134
134
|
#
|
135
135
|
def columns_html
|
@@ -160,7 +160,7 @@ module Dashboard
|
|
160
160
|
# Generates a chunk of HTML that contains various checkboxes to toggle the
|
161
161
|
# state of all widgets.
|
162
162
|
#
|
163
|
-
# @since
|
163
|
+
# @since 2012-01-14
|
164
164
|
# @return [String]
|
165
165
|
#
|
166
166
|
def checkbox_html
|
@@ -196,7 +196,7 @@ module Dashboard
|
|
196
196
|
##
|
197
197
|
# Returns the current user model.
|
198
198
|
#
|
199
|
-
# @since
|
199
|
+
# @since 2012-01-15
|
200
200
|
# @return [Users::Model::User]
|
201
201
|
def user
|
202
202
|
return Ramaze::Current.action.node.request.env[
|
@@ -208,7 +208,7 @@ module Dashboard
|
|
208
208
|
##
|
209
209
|
# Sets the name of the widget and converts it to a symbol.
|
210
210
|
#
|
211
|
-
# @since
|
211
|
+
# @since 2012-01-11
|
212
212
|
# @param [#to_sym] name The name of the widget.
|
213
213
|
#
|
214
214
|
def name=(name)
|
@@ -220,7 +220,7 @@ module Dashboard
|
|
220
220
|
# string the value of that string is returned, otherwise the raw title is
|
221
221
|
# returned.
|
222
222
|
#
|
223
|
-
# @since
|
223
|
+
# @since 2012-01-11
|
224
224
|
# @return [String]
|
225
225
|
#
|
226
226
|
def title
|
@@ -234,7 +234,7 @@ module Dashboard
|
|
234
234
|
##
|
235
235
|
# Checks if the user is allowed to view the current widget.
|
236
236
|
#
|
237
|
-
# @since
|
237
|
+
# @since 2012-01-16
|
238
238
|
# @return [TrueClass|Falseclass]
|
239
239
|
#
|
240
240
|
def allowed?
|
@@ -245,7 +245,7 @@ module Dashboard
|
|
245
245
|
##
|
246
246
|
# Validates the instance of the widget.
|
247
247
|
#
|
248
|
-
# @since
|
248
|
+
# @since 2012-01-11
|
249
249
|
#
|
250
250
|
def validate
|
251
251
|
validates_presence([:name, :title, :data])
|
@@ -269,7 +269,7 @@ module Dashboard
|
|
269
269
|
# </div>
|
270
270
|
# </section>
|
271
271
|
#
|
272
|
-
# @since
|
272
|
+
# @since 2012-01-12
|
273
273
|
# @return [String]
|
274
274
|
#
|
275
275
|
def html
|
@@ -8,14 +8,14 @@
|
|
8
8
|
#
|
9
9
|
# This package does not provide any helpers or models.
|
10
10
|
#
|
11
|
-
# @since
|
11
|
+
# @since 2011-11-18
|
12
12
|
#
|
13
13
|
module Extensions
|
14
14
|
module Controller
|
15
15
|
##
|
16
16
|
# Controller that displays all the installed extensions.
|
17
17
|
#
|
18
|
-
# @since
|
18
|
+
# @since 2011-11-18
|
19
19
|
# @map /admin/extensions
|
20
20
|
#
|
21
21
|
class Extensions < Zen::Controller::AdminController
|
@@ -28,7 +28,7 @@ module Extensions
|
|
28
28
|
# Shows an overview of all the installed themes, packages, added
|
29
29
|
# languages, etc.
|
30
30
|
#
|
31
|
-
# @since
|
31
|
+
# @since 2011-11-18
|
32
32
|
# @permission show_extension
|
33
33
|
#
|
34
34
|
def index
|
@@ -76,10 +76,10 @@ module Menus
|
|
76
76
|
#
|
77
77
|
# ## Used Permissions
|
78
78
|
#
|
79
|
-
# *
|
80
|
-
# *
|
81
|
-
# *
|
82
|
-
# *
|
79
|
+
# * show\_menu\_item
|
80
|
+
# * new\_menu\_item
|
81
|
+
# * edit\_menu\_item
|
82
|
+
# * delete\_menu\_item
|
83
83
|
#
|
84
84
|
# @since 0.2a
|
85
85
|
# @map /admin/menu-items
|
@@ -223,7 +223,7 @@ module Menus
|
|
223
223
|
##
|
224
224
|
# Updates the sort order and parent IDs for the given menu items.
|
225
225
|
#
|
226
|
-
# @since
|
226
|
+
# @since 2012-02-11
|
227
227
|
# @permission edit_menu_item
|
228
228
|
#
|
229
229
|
def tree
|
@@ -96,10 +96,10 @@ module Menus
|
|
96
96
|
#
|
97
97
|
# ## Used Permissions
|
98
98
|
#
|
99
|
-
# *
|
100
|
-
# *
|
101
|
-
# *
|
102
|
-
# *
|
99
|
+
# * show\_menu
|
100
|
+
# * new\_menu
|
101
|
+
# * edit\_menu
|
102
|
+
# * delete\_menu
|
103
103
|
#
|
104
104
|
# @since 0.2a
|
105
105
|
# @map /admin/menus
|
@@ -54,7 +54,7 @@ module Ramaze
|
|
54
54
|
# Redirects the user to the menus overview and informs him/her that the
|
55
55
|
# menu he/she tried to access is invalid.
|
56
56
|
#
|
57
|
-
# @since
|
57
|
+
# @since 2012-04-05
|
58
58
|
#
|
59
59
|
def redirect_invalid_menu
|
60
60
|
message(:error, lang('menus.errors.invalid_menu'))
|
@@ -66,7 +66,7 @@ module Ramaze
|
|
66
66
|
# menu and informs the user that the menu item he/she tried to access is
|
67
67
|
# invalid.
|
68
68
|
#
|
69
|
-
# @since
|
69
|
+
# @since 2012-04-05
|
70
70
|
# @param [Fixnum] menu_id The ID of the menu.
|
71
71
|
#
|
72
72
|
def redirect_invalid_menu_item(menu_id)
|
@@ -78,7 +78,7 @@ module Ramaze
|
|
78
78
|
# Builds the menu item tree that can be used by the user to edit the sort
|
79
79
|
# order, create the menu item tree and edit individual menu items.
|
80
80
|
#
|
81
|
-
# @since
|
81
|
+
# @since 2012-02-11
|
82
82
|
# @param [Array] tree The menu item tree to process. This array should be
|
83
83
|
# in the format as returned by {Menus::Model::Menu#menu_items_tree}.
|
84
84
|
# @return [String]
|
@@ -106,7 +106,7 @@ module Ramaze
|
|
106
106
|
# Builds the HTML for a single menu item and recursively calls itself for
|
107
107
|
# any sub menu items.
|
108
108
|
#
|
109
|
-
# @since
|
109
|
+
# @since 2012-02-11
|
110
110
|
# @param [Hash] item A single menu item to process.
|
111
111
|
# @param [Ramaze::Gestalt] gestalt An instance of Ramaze::Gestalt to use
|
112
112
|
# for building the HTML.
|
@@ -23,12 +23,12 @@ module Menus
|
|
23
23
|
# end
|
24
24
|
#
|
25
25
|
# @since 0.2a
|
26
|
-
# @event
|
27
|
-
# @event
|
28
|
-
# @event
|
29
|
-
# @event
|
30
|
-
# @event
|
31
|
-
# @event
|
26
|
+
# @event before\_new\_menu
|
27
|
+
# @event after\_new\_menu
|
28
|
+
# @event before\_edit\_menu
|
29
|
+
# @event after\_edit\_menu
|
30
|
+
# @event before\_delete\_menu
|
31
|
+
# @event after\_delete\_menu
|
32
32
|
#
|
33
33
|
class Menu < Sequel::Model
|
34
34
|
include Zen::Model::Helper
|
@@ -36,7 +36,7 @@ module Menus
|
|
36
36
|
##
|
37
37
|
# Array containing all the columns that can be set by the user.
|
38
38
|
#
|
39
|
-
# @since
|
39
|
+
# @since 2012-02-17
|
40
40
|
#
|
41
41
|
COLUMNS = [:name, :slug, :description, :html_class, :html_id]
|
42
42
|
|
@@ -57,7 +57,7 @@ module Menus
|
|
57
57
|
##
|
58
58
|
# Searches for a set of menus.
|
59
59
|
#
|
60
|
-
# @since
|
60
|
+
# @since 2011-10-16
|
61
61
|
# @param [String] query The search query.
|
62
62
|
# @return [Mixed]
|
63
63
|
#
|
@@ -99,7 +99,7 @@ module Menus
|
|
99
99
|
#
|
100
100
|
# loop_nodes(Menus::Model::Menu[1].menu_items_tree)
|
101
101
|
#
|
102
|
-
# @since
|
102
|
+
# @since 2012-01-30
|
103
103
|
# @param [Symbol] order The sort order to apply to menu items, set to
|
104
104
|
# :asc by default.
|
105
105
|
# @param [Fixnum|NilClass] limit The maximum amount of menu items to
|
@@ -162,7 +162,7 @@ module Menus
|
|
162
162
|
##
|
163
163
|
# Hook that is executed before creating or saving an object.
|
164
164
|
#
|
165
|
-
# @since
|
165
|
+
# @since 2012-01-03
|
166
166
|
#
|
167
167
|
def before_save
|
168
168
|
sanitize_fields([:name, :slug, :description, :html_class, :html_id])
|
@@ -176,7 +176,7 @@ module Menus
|
|
176
176
|
# Sorts a set of sub nodes as returned by
|
177
177
|
# {Menus::Model::Menu#menu_item_tree}.
|
178
178
|
#
|
179
|
-
# @since
|
179
|
+
# @since 2012-02-01
|
180
180
|
# @param [Array] nodes An array of nodes to sort.
|
181
181
|
# @param [Symbol] order The sort order to apply.
|
182
182
|
# @return [Array]
|