zen 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gems +34 -0
- data/.travis.yml +7 -0
- data/AUTHORS +5 -0
- data/CHANGELOG +14 -0
- data/{license.txt → LICENSE} +0 -0
- data/MANIFEST +67 -51
- data/README.md +18 -25
- data/Rakefile +2 -3
- data/bin/zen +2 -2
- data/lib/zen.rb +93 -57
- data/lib/zen/asset.rb +7 -8
- data/lib/zen/bin/app.rb +0 -2
- data/lib/zen/controller/admin_controller.rb +4 -9
- data/lib/zen/controller/base_controller.rb +0 -25
- data/lib/zen/controller/main_controller.rb +5 -5
- data/lib/zen/controller/preview.rb +50 -0
- data/lib/zen/helper/common.rb +4 -68
- data/lib/zen/helper/message.rb +82 -0
- data/lib/zen/helper/theme.rb +2 -2
- data/lib/zen/language.rb +68 -38
- data/lib/zen/language/en/zen_general.yml +1 -4
- data/lib/zen/language/nl/zen_general.yml +28 -0
- data/lib/zen/language/nl/zen_models.yml +13 -0
- data/lib/zen/layout/admin.xhtml +1 -1
- data/lib/zen/layout/login.xhtml +1 -1
- data/lib/zen/model/settings.rb +2 -0
- data/lib/zen/package.rb +29 -25
- data/lib/zen/package/all.rb +1 -1
- data/lib/zen/package/categories/lib/categories/controller/categories.rb +51 -63
- data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +45 -52
- data/lib/zen/package/categories/lib/categories/language/en/categories.yml +2 -2
- data/lib/zen/package/categories/lib/categories/language/nl/categories.yml +39 -0
- data/lib/zen/package/categories/lib/categories/language/nl/category_groups.yml +33 -0
- data/lib/zen/package/categories/lib/categories/plugin/categories.rb +2 -2
- data/lib/zen/package/comments/lib/comments.rb +31 -2
- data/lib/zen/package/comments/lib/comments/controller/comments.rb +42 -57
- data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +36 -51
- data/lib/zen/package/comments/lib/comments/language/en/comments.yml +7 -3
- data/lib/zen/package/comments/lib/comments/language/nl/comments.yml +48 -0
- data/lib/zen/package/comments/lib/comments/model/comment.rb +45 -4
- data/lib/zen/package/comments/lib/comments/plugin/anti_spam.rb +152 -0
- data/lib/zen/package/comments/lib/comments/plugin/comments.rb +5 -6
- data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +2 -2
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +43 -52
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +68 -67
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.yml +1 -1
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.yml +32 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.yml +52 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +3 -3
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_group.rb +4 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +3 -3
- data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +37 -44
- data/lib/zen/package/menus/lib/menus/controller/menus.rb +33 -43
- data/lib/zen/package/menus/lib/menus/helper/menu_item.rb +5 -10
- data/lib/zen/package/menus/lib/menus/language/nl/menu_items.yml +41 -0
- data/lib/zen/package/menus/lib/menus/language/nl/menus.yml +39 -0
- data/lib/zen/package/menus/lib/menus/model/menu.rb +3 -3
- data/lib/zen/package/menus/lib/menus/model/menu_item.rb +3 -3
- data/lib/zen/package/menus/lib/menus/plugin/menus.rb +5 -6
- data/lib/zen/package/menus/migrations/1297184342_create_schema.rb +1 -1
- data/lib/zen/package/sections/lib/sections.rb +20 -0
- data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +85 -79
- data/lib/zen/package/sections/lib/sections/controller/sections.rb +58 -66
- data/lib/zen/package/sections/lib/sections/language/en/sections.yml +0 -1
- data/lib/zen/package/sections/lib/sections/language/nl/section_entries.yml +43 -0
- data/lib/zen/package/sections/lib/sections/language/nl/sections.yml +47 -0
- data/lib/zen/package/sections/lib/sections/model/section.rb +11 -15
- data/lib/zen/package/sections/lib/sections/model/section_entry.rb +9 -5
- data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +7 -8
- data/lib/zen/package/sections/lib/sections/plugin/sections.rb +3 -4
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +0 -4
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +8 -2
- data/lib/zen/package/sections/migrations/1306772479_remove_unique_slug.rb +28 -0
- data/lib/zen/package/settings/lib/settings.rb +21 -34
- data/lib/zen/package/settings/lib/settings/controller/settings.rb +29 -22
- data/lib/zen/package/settings/lib/settings/language/en/settings.yml +7 -5
- data/lib/zen/package/settings/lib/settings/language/nl/settings.yml +39 -0
- data/lib/zen/package/settings/lib/settings/model/setting.rb +3 -5
- data/lib/zen/package/settings/lib/settings/plugin/group_base.rb +3 -4
- data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +3 -5
- data/lib/zen/package/settings/lib/settings/plugin/settings.rb +11 -4
- data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +5 -5
- data/lib/zen/package/settings/migrations/1299538742_add_language_key.rb +8 -8
- data/lib/zen/package/settings/migrations/1303196915_settings_plugin.rb +2 -5
- data/lib/zen/package/users/lib/users/controller/access_rules.rb +54 -61
- data/lib/zen/package/users/lib/users/controller/user_groups.rb +49 -57
- data/lib/zen/package/users/lib/users/controller/users.rb +58 -73
- data/lib/zen/package/users/lib/users/language/en/users.yml +6 -0
- data/lib/zen/package/users/lib/users/language/nl/access_rules.yml +37 -0
- data/lib/zen/package/users/lib/users/language/nl/user_groups.yml +31 -0
- data/lib/zen/package/users/lib/users/language/nl/users.yml +56 -0
- data/lib/zen/package/users/lib/users/model/user.rb +16 -1
- data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +27 -2
- data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +15 -3
- data/lib/zen/package/users/migrations/1304939855_user_settings.rb +15 -0
- data/lib/zen/plugin.rb +7 -9
- data/lib/zen/public/admin/css/{buttons.css → zen/buttons.css} +11 -7
- data/lib/zen/public/admin/css/{datepicker.css → zen/datepicker.css} +0 -0
- data/lib/zen/public/admin/css/{editor.css → zen/editor.css} +10 -5
- data/lib/zen/public/admin/css/{forms.css → zen/forms.css} +1 -1
- data/lib/zen/public/admin/css/{general.css → zen/general.css} +7 -7
- data/lib/zen/public/admin/css/{grid.css → zen/grid.css} +0 -0
- data/lib/zen/public/admin/css/{layout.css → zen/layout.css} +4 -5
- data/lib/zen/public/admin/css/zen/messages.css +61 -0
- data/lib/zen/public/admin/css/{notifications.css → zen/notifications.css} +4 -4
- data/lib/zen/public/admin/css/{reset.css → zen/reset.css} +0 -0
- data/lib/zen/public/admin/css/{tables.css → zen/tables.css} +3 -3
- data/lib/zen/public/admin/css/{tabs.css → zen/tabs.css} +5 -5
- data/lib/zen/public/admin/css/zen/window.css +79 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/accept.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/add.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/back.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/bold.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/close.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/delete.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/edit.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/error.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/help.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/info.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/italic.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/large/error.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/large/notice.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/large/success.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/link.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/logout.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/ol.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/pdf.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/preview.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/ul.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/user.png +0 -0
- data/lib/zen/public/admin/images/{icons → zen/icons}/view.png +0 -0
- data/lib/zen/public/admin/js/zen/core.js +73 -0
- data/lib/zen/public/admin/js/zen/editor.js +527 -0
- data/lib/zen/public/admin/js/zen/editor/markdown.js +84 -0
- data/lib/zen/public/admin/js/zen/editor/textile.js +84 -0
- data/lib/zen/public/admin/js/zen/init.js +12 -66
- data/lib/zen/public/admin/js/zen/tabs.js +5 -0
- data/lib/zen/public/admin/js/zen/window.js +206 -0
- data/lib/zen/task/build.rake +23 -6
- data/lib/zen/task/clean.rake +6 -7
- data/lib/zen/task/db.rake +7 -9
- data/lib/zen/task/package.rake +6 -6
- data/lib/zen/task/test.rake +6 -0
- data/lib/zen/task/theme.rake +3 -3
- data/lib/zen/theme.rb +3 -4
- data/lib/zen/validation.rb +7 -9
- data/lib/zen/version.rb +3 -4
- data/lib/zen/view/bottom.xhtml +0 -5
- data/lib/zen/view/main.xhtml +2 -0
- data/proto/app/app.rb +6 -4
- data/proto/app/config/config.rb +1 -7
- data/proto/app/config/database.rb +47 -43
- data/proto/app/config/middlewares.rb +0 -40
- data/proto/app/start.rb +1 -6
- data/proto/app/{vendor → theme}/.gitkeep +0 -0
- data/proto/migration.rb +3 -3
- data/proto/package/lib/package.rb +0 -1
- data/proto/package/lib/package/controller/controllers.rb +7 -40
- data/proto/package/lib/package/model/model.rb +3 -3
- metadata +106 -79
- data/CHANGELOG.md +0 -27
- data/ROADMAP.md +0 -53
- data/lib/zen/database.rb +0 -112
- data/lib/zen/logger.rb +0 -56
- data/lib/zen/public/admin/css/modals.css +0 -63
- data/lib/zen/public/admin/images/icons/close.png +0 -0
- data/lib/zen/public/admin/js/vendor/yepnope.js +0 -1
- data/lib/zen/public/admin/js/zen/editor/base.js +0 -262
- data/lib/zen/public/admin/js/zen/editor/drivers/html.js +0 -89
- data/lib/zen/public/admin/js/zen/editor/drivers/markdown.js +0 -87
- data/lib/zen/public/admin/js/zen/editor/drivers/textile.js +0 -87
- data/lib/zen/public/admin/js/zen/modal.js +0 -146
- data/lib/zen/public/admin/js/zen/notification.js +0 -211
- data/proto/app/config/requires.rb +0 -10
- data/proto/app/vendor/theme/.gitkeep +0 -0
- data/proto/package/lib/package/view/admin/package/edit.xhtml +0 -0
- data/proto/package/lib/package/view/admin/package/form.xhtml +0 -0
- data/proto/package/lib/package/view/admin/package/new.xhtml +0 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
titles:
|
3
|
+
index: 'Veld groepen'
|
4
|
+
edit : 'Veld groep aanpassen'
|
5
|
+
new : 'Veld groep aanmaken'
|
6
|
+
|
7
|
+
labels:
|
8
|
+
id : '#'
|
9
|
+
name : 'Naam'
|
10
|
+
description : 'Beschrijving'
|
11
|
+
sections : 'Secties'
|
12
|
+
manage_fields: 'Beheer velden'
|
13
|
+
none : 'Geen'
|
14
|
+
|
15
|
+
messages:
|
16
|
+
no_groups: 'Er zijn nog geen veld groepen aangemaakt.'
|
17
|
+
|
18
|
+
success:
|
19
|
+
new : 'De veld groep is aangemaakt.'
|
20
|
+
save : 'De veld groep is aangepast.'
|
21
|
+
delete: 'De veld groep is verwijderd.'
|
22
|
+
|
23
|
+
errors:
|
24
|
+
new : 'De veld groep kon niet worden aangemaakt.'
|
25
|
+
save : 'De veld groep kon niet worden aangepast.'
|
26
|
+
delete : 'De veld groep met ID #%s kon niet worden verwijderd.'
|
27
|
+
no_delete: 'U moet ten minste 1 groep specificeren om te verwijderen.'
|
28
|
+
|
29
|
+
buttons:
|
30
|
+
new : 'Groep aanmaken'
|
31
|
+
save : 'Groep opslaan'
|
32
|
+
delete: 'Geselecteerde groepen verwijderen'
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
titles:
|
3
|
+
index: 'Velden'
|
4
|
+
edit : 'Veld aanpassen'
|
5
|
+
new : 'Veld aanmaken'
|
6
|
+
|
7
|
+
labels:
|
8
|
+
id : '#'
|
9
|
+
name : 'Naam'
|
10
|
+
slug : 'Slug'
|
11
|
+
type : 'Type'
|
12
|
+
format : 'Formaat'
|
13
|
+
description : 'Beschrijving'
|
14
|
+
possible_values: 'Mogelijke waardes (een per regel)'
|
15
|
+
required : 'Vereist een waarde'
|
16
|
+
visual_editor : 'Visuele editor'
|
17
|
+
textarea_rows : 'Text veld rijen'
|
18
|
+
text_limit : 'Karakter limiet'
|
19
|
+
sort_order : 'Sorteer volgorde'
|
20
|
+
|
21
|
+
tabs:
|
22
|
+
general : 'Algemeen'
|
23
|
+
settings: 'Instellingen'
|
24
|
+
|
25
|
+
messages:
|
26
|
+
no_fields: 'Er zijn nog geen velden aangemaakt.'
|
27
|
+
|
28
|
+
success:
|
29
|
+
new : 'Het veld is aangemaakt.'
|
30
|
+
save : 'Het veld is aangepast.'
|
31
|
+
delete: 'Alle geselecteerde velden zijn verwijderd.'
|
32
|
+
|
33
|
+
errors:
|
34
|
+
new : 'Het veld kon niet worden aangemaakt.'
|
35
|
+
save : 'Het veld kon niet worden aangepast.'
|
36
|
+
delete : 'Het veld met ID #%s kon niet worden verwijderd.'
|
37
|
+
no_delete: 'U moet ten minste 1 veld specificeren om te verwijderen.'
|
38
|
+
|
39
|
+
special:
|
40
|
+
type_hash:
|
41
|
+
textbox : 'Text veld'
|
42
|
+
textarea : 'Text gebied'
|
43
|
+
radio : 'Keuze knop (enkele waarde)'
|
44
|
+
checkbox : 'Keuze knop (meerdere waardes)'
|
45
|
+
date : 'Datum'
|
46
|
+
select : 'Lijst (enkele waarde)'
|
47
|
+
select_multiple: 'Lijst (meerdere waardes)'
|
48
|
+
|
49
|
+
buttons:
|
50
|
+
new : 'Veld toevoegen'
|
51
|
+
delete: 'Geselecteerde velden verwijderen'
|
52
|
+
save : 'Veld opslaan'
|
@@ -22,10 +22,7 @@ module CustomFields
|
|
22
22
|
:order => :sort_order
|
23
23
|
)
|
24
24
|
|
25
|
-
many_to_many(
|
26
|
-
:sections,
|
27
|
-
:class => "Sections::Model::Section"
|
28
|
-
)
|
25
|
+
many_to_many(:sections, :class => "Sections::Model::Section")
|
29
26
|
|
30
27
|
##
|
31
28
|
# Validates rules used whenever the model is created or saved.
|
@@ -37,6 +34,6 @@ module CustomFields
|
|
37
34
|
validates_presence :name
|
38
35
|
validates_max_length 255, :name
|
39
36
|
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
37
|
+
end # CustomFieldGroup
|
38
|
+
end # Model
|
39
|
+
end # CustomFields
|
@@ -3,7 +3,7 @@ module Menus
|
|
3
3
|
#:nodoc:
|
4
4
|
module Controller
|
5
5
|
##
|
6
|
-
# Controller for managing individual navigation items that belong to a menu.
|
6
|
+
# Controller for managing individual navigation items that belong to a menu.
|
7
7
|
#
|
8
8
|
# @author Yorick Peterse
|
9
9
|
# @since 0.2a
|
@@ -13,13 +13,13 @@ module Menus
|
|
13
13
|
|
14
14
|
map('/admin/menu-items')
|
15
15
|
helper(:menu_item)
|
16
|
-
|
16
|
+
|
17
17
|
before_all do
|
18
18
|
csrf_protection(:save, :delete) do
|
19
19
|
respond(lang('zen_general.errors.csrf'), 403)
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
##
|
24
24
|
# Initializes the class, loads all language packs and sets the form URLs.
|
25
25
|
#
|
@@ -33,10 +33,10 @@ module Menus
|
|
33
33
|
#
|
34
34
|
def initialize
|
35
35
|
super
|
36
|
-
|
36
|
+
|
37
37
|
@form_save_url = MenuItems.r(:save)
|
38
38
|
@form_delete_url = MenuItems.r(:delete)
|
39
|
-
|
39
|
+
|
40
40
|
Zen::Language.load('menu_items')
|
41
41
|
Zen::Language.load('menus')
|
42
42
|
|
@@ -58,7 +58,7 @@ module Menus
|
|
58
58
|
# @since 0.2a
|
59
59
|
# @param [Integer] menu_id The ID of the current navigation menu.
|
60
60
|
#
|
61
|
-
def index(menu_id
|
61
|
+
def index(menu_id)
|
62
62
|
if !user_authorized?([:read])
|
63
63
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
64
64
|
end
|
@@ -66,7 +66,7 @@ module Menus
|
|
66
66
|
validate_menu(menu_id)
|
67
67
|
|
68
68
|
set_breadcrumbs(
|
69
|
-
anchor_to(lang('menus.titles.index'), Menus.r(:index)),
|
69
|
+
anchor_to(lang('menus.titles.index'), Menus.r(:index)),
|
70
70
|
lang('menu_items.titles.index')
|
71
71
|
)
|
72
72
|
|
@@ -87,7 +87,7 @@ module Menus
|
|
87
87
|
# @param [Integer] menu_id The ID of the current navigation menu.
|
88
88
|
# @param [Integer] id The ID of the menu item to edit.
|
89
89
|
#
|
90
|
-
def edit(menu_id
|
90
|
+
def edit(menu_id, id)
|
91
91
|
if !user_authorized?([:read, :update])
|
92
92
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
93
93
|
end
|
@@ -96,7 +96,7 @@ module Menus
|
|
96
96
|
|
97
97
|
set_breadcrumbs(
|
98
98
|
anchor_to(lang('menus.titles.index'), Menus.r(:index)),
|
99
|
-
anchor_to(lang('menu_items.titles.index'), MenuItems.r(:index, menu_id)),
|
99
|
+
anchor_to(lang('menu_items.titles.index'), MenuItems.r(:index, menu_id)),
|
100
100
|
lang('menu_items.titles.edit')
|
101
101
|
)
|
102
102
|
|
@@ -105,7 +105,7 @@ module Menus
|
|
105
105
|
if flash[:form_data]
|
106
106
|
@menu_item = flash[:form_data]
|
107
107
|
else
|
108
|
-
@menu_item = MenuItem[id
|
108
|
+
@menu_item = MenuItem[id]
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -121,16 +121,16 @@ module Menus
|
|
121
121
|
# @since 0.2a
|
122
122
|
# @param [Integer] menu_id The ID of the current navigation menu.
|
123
123
|
#
|
124
|
-
def new(menu_id
|
124
|
+
def new(menu_id)
|
125
125
|
if !user_authorized?([:create, :read])
|
126
126
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
127
|
-
end
|
127
|
+
end
|
128
128
|
|
129
129
|
validate_menu(menu_id)
|
130
130
|
|
131
131
|
set_breadcrumbs(
|
132
132
|
anchor_to(lang('menus.titles.index'), Menus.r(:index)),
|
133
|
-
anchor_to(lang('menu_items.titles.index'), MenuItems.r(:index, menu_id)),
|
133
|
+
anchor_to(lang('menu_items.titles.index'), MenuItems.r(:index, menu_id)),
|
134
134
|
lang('menu_items.titles.new')
|
135
135
|
)
|
136
136
|
|
@@ -139,7 +139,7 @@ module Menus
|
|
139
139
|
end
|
140
140
|
|
141
141
|
##
|
142
|
-
# Saves an existing menu iten or creates a new one using the supplied POST data.
|
142
|
+
# Saves an existing menu iten or creates a new one using the supplied POST data.
|
143
143
|
#
|
144
144
|
# This method requires the following permissions:
|
145
145
|
#
|
@@ -154,21 +154,26 @@ module Menus
|
|
154
154
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
155
155
|
end
|
156
156
|
|
157
|
-
post = request.
|
158
|
-
|
157
|
+
post = request.subset(
|
158
|
+
:id, :parent_id, :name, :url, :order, :css_class, :css_id, :menu_id
|
159
|
+
)
|
160
|
+
|
161
|
+
if post['parent_id'].empty? or post['parent_id'] === post['id']
|
159
162
|
post['parent_id'] = nil
|
160
163
|
end
|
161
164
|
|
162
165
|
# Determine if we're saving changes made to an existing menu item or if we're
|
163
166
|
# going to create a new one.
|
164
167
|
if !post['id'].empty?
|
165
|
-
@menu_item = MenuItem[post['id']
|
168
|
+
@menu_item = MenuItem[post['id']]
|
166
169
|
save_action = :save
|
167
170
|
else
|
168
171
|
@menu_item = MenuItem.new
|
169
172
|
save_action = :new
|
170
173
|
end
|
171
174
|
|
175
|
+
post.delete('id')
|
176
|
+
|
172
177
|
# Set our notifications
|
173
178
|
flash_success = lang("menu_items.success.#{save_action}")
|
174
179
|
flash_error = lang("menu_items.errors.#{save_action}")
|
@@ -176,9 +181,10 @@ module Menus
|
|
176
181
|
# Time to save the data
|
177
182
|
begin
|
178
183
|
@menu_item.update(post)
|
179
|
-
|
180
|
-
rescue
|
181
|
-
|
184
|
+
message(:success, flash_success)
|
185
|
+
rescue => e
|
186
|
+
Ramaze::Log.error(e.inspect)
|
187
|
+
message(:error, flash_error)
|
182
188
|
|
183
189
|
flash[:form_data] = @menu_item
|
184
190
|
flash[:form_errors] = @menu_item.errors
|
@@ -192,7 +198,7 @@ module Menus
|
|
192
198
|
end
|
193
199
|
|
194
200
|
##
|
195
|
-
# Delete all specified menu items based on the values in the POST array
|
201
|
+
# Delete all specified menu items based on the values in the POST array
|
196
202
|
# "menu_item_ids". This method requires the following permissions:
|
197
203
|
#
|
198
204
|
# * delete
|
@@ -205,39 +211,26 @@ module Menus
|
|
205
211
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
206
212
|
end
|
207
213
|
|
208
|
-
post = request.
|
214
|
+
post = request.subset(:menu_item_ids)
|
209
215
|
|
210
216
|
if !post['menu_item_ids'] or post['menu_item_ids'].empty?
|
211
|
-
|
212
|
-
:error,
|
213
|
-
lang('menu_items.titles.index'),
|
214
|
-
lang('menu_items.errors.no_delete')
|
215
|
-
)
|
216
|
-
|
217
|
+
message(:error, lang('menu_items.errors.no_delete'))
|
217
218
|
redirect_referrer
|
218
219
|
end
|
219
220
|
|
220
221
|
post['menu_item_ids'].each do |id|
|
221
222
|
begin
|
222
|
-
MenuItem[id
|
223
|
-
rescue
|
224
|
-
|
225
|
-
|
226
|
-
lang('menu_items.titles.index'),
|
227
|
-
lang('menu_items.errors.delete') % id
|
228
|
-
)
|
223
|
+
MenuItem[id].destroy
|
224
|
+
rescue => e
|
225
|
+
Ramaze::Log.error(e.inspect)
|
226
|
+
message(:error, lang('menu_items.errors.delete') % id)
|
229
227
|
redirect_referrer
|
230
228
|
end
|
231
229
|
end
|
232
230
|
|
233
|
-
|
234
|
-
:success,
|
235
|
-
lang('menu_items.titles.index'),
|
236
|
-
lang('menu_items.success.delete')
|
237
|
-
)
|
238
|
-
|
231
|
+
message(:success, lang('menu_items.success.delete'))
|
239
232
|
redirect_referrer
|
240
233
|
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
234
|
+
end # MenuItems
|
235
|
+
end # Controller
|
236
|
+
end # Menus
|
@@ -13,13 +13,13 @@ module Menus
|
|
13
13
|
include ::Menus::Model
|
14
14
|
|
15
15
|
map('/admin/menus')
|
16
|
-
|
16
|
+
|
17
17
|
before_all do
|
18
18
|
csrf_protection(:save, :delete) do
|
19
19
|
respond(lang('zen_general.errors.csrf'), 403)
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
##
|
24
24
|
# Initializes the class and loads all required language packs.
|
25
25
|
#
|
@@ -32,19 +32,19 @@ module Menus
|
|
32
32
|
#
|
33
33
|
def initialize
|
34
34
|
super
|
35
|
-
|
35
|
+
|
36
36
|
@form_save_url = Menus.r(:save)
|
37
37
|
@form_delete_url = Menus.r(:delete)
|
38
|
-
|
38
|
+
|
39
39
|
Zen::Language.load('menus')
|
40
|
-
|
40
|
+
|
41
41
|
# Set the page title
|
42
42
|
if !action.method.nil?
|
43
43
|
method = action.method.to_sym
|
44
44
|
@page_title = lang("menus.titles.#{method}") rescue nil
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
##
|
49
49
|
# Shows an overview of all exisitng menus and a few properties of these
|
50
50
|
# groups such as the name, slug and the amount of items in that group.
|
@@ -67,10 +67,10 @@ module Menus
|
|
67
67
|
# Get all menus
|
68
68
|
@menus = Menu.all
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
##
|
72
72
|
# Show a form that allows the user to edit the details (such as the name and slug)
|
73
|
-
# of a menu group. This method can not be used to manage all menu items for this
|
73
|
+
# of a menu group. This method can not be used to manage all menu items for this
|
74
74
|
# group.
|
75
75
|
#
|
76
76
|
# This method requires the following permissions:
|
@@ -87,17 +87,17 @@ module Menus
|
|
87
87
|
end
|
88
88
|
|
89
89
|
set_breadcrumbs(
|
90
|
-
anchor_to(lang('menus.titles.index'), Menus.r(:index)),
|
90
|
+
anchor_to(lang('menus.titles.index'), Menus.r(:index)),
|
91
91
|
@page_title
|
92
92
|
)
|
93
|
-
|
93
|
+
|
94
94
|
if flash[:form_data]
|
95
95
|
@menu = flash[:form_data]
|
96
96
|
else
|
97
97
|
@menu = Menu[id]
|
98
98
|
end
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
##
|
102
102
|
# Show a form that can be used to create a new menu group. Once a menu group has
|
103
103
|
# been created users can start adding navigation items to the group.
|
@@ -117,13 +117,13 @@ module Menus
|
|
117
117
|
|
118
118
|
# Breadcrumbs, om nom nom!
|
119
119
|
set_breadcrumbs(
|
120
|
-
anchor_to(lang('menus.titles.index'), Menus.r(:index)),
|
120
|
+
anchor_to(lang('menus.titles.index'), Menus.r(:index)),
|
121
121
|
@page_title
|
122
122
|
)
|
123
123
|
|
124
124
|
@menu = Menu.new
|
125
125
|
end
|
126
|
-
|
126
|
+
|
127
127
|
##
|
128
128
|
# Saves the changes made to an existing menu group or creates a new group using the
|
129
129
|
# supplied POST data. In order to detect this forms that contain data of an existing
|
@@ -137,39 +137,38 @@ module Menus
|
|
137
137
|
#
|
138
138
|
# @author Yorick Peterse
|
139
139
|
# @since 0.2a
|
140
|
-
#
|
140
|
+
#
|
141
141
|
def save
|
142
142
|
if !user_authorized?([:create, :update])
|
143
143
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
144
144
|
end
|
145
145
|
|
146
|
-
|
147
|
-
post = request.params.dup
|
146
|
+
post = request.subset(:name, :slug, :description, :css_class, :css_id, :id)
|
148
147
|
|
149
148
|
# Determine if we're creating a new group or modifying an existing one.
|
150
149
|
if !post['id'].empty?
|
151
|
-
@menu = Menu[post['id']
|
150
|
+
@menu = Menu[post['id']]
|
152
151
|
save_action = :save
|
153
152
|
else
|
154
153
|
@menu = Menu.new
|
155
154
|
save_action = :new
|
156
155
|
|
157
156
|
# Delete the slug if it's empty
|
158
|
-
if post['slug'].empty?
|
159
|
-
post.delete('slug')
|
160
|
-
end
|
157
|
+
post.delete('slug') if post['slug'].empty?
|
161
158
|
end
|
162
159
|
|
163
|
-
|
160
|
+
post.delete('id')
|
161
|
+
|
164
162
|
flash_success = lang("menus.success.#{save_action}")
|
165
163
|
flash_error = lang("menus.errors.#{save_action}")
|
166
164
|
|
167
165
|
# Let's see if we can insert/update the data
|
168
166
|
begin
|
169
167
|
@menu.update(post)
|
170
|
-
|
171
|
-
rescue
|
172
|
-
|
168
|
+
message(:success, flash_success)
|
169
|
+
rescue => e
|
170
|
+
Ramaze::Log.error(e.inspect)
|
171
|
+
message(:error, flash_error)
|
173
172
|
|
174
173
|
flash[:form_data] = @menu
|
175
174
|
flash[:form_errors] = @menu.errors
|
@@ -193,7 +192,7 @@ module Menus
|
|
193
192
|
#
|
194
193
|
# @author Yorick Peterse
|
195
194
|
# @since 0.2a
|
196
|
-
#
|
195
|
+
#
|
197
196
|
def delete
|
198
197
|
if !user_authorized?([:delete])
|
199
198
|
respond(lang('zen_general.errors.not_authorized'), 403)
|
@@ -203,33 +202,24 @@ module Menus
|
|
203
202
|
|
204
203
|
# We always require a set of IDs
|
205
204
|
if !post['menu_ids'] or post['menu_ids'].empty?
|
206
|
-
|
207
|
-
:error,
|
208
|
-
lang('menus.titles.index'),
|
209
|
-
lang('menus.errors.no_delete')
|
210
|
-
)
|
211
|
-
|
205
|
+
message(:error, lang('menus.errors.no_delete'))
|
212
206
|
redirect_referrer
|
213
207
|
end
|
214
208
|
|
215
209
|
# Time to delete all menus
|
216
210
|
post['menu_ids'].each do |id|
|
217
211
|
begin
|
218
|
-
Menu[id
|
219
|
-
rescue
|
220
|
-
|
221
|
-
|
222
|
-
lang('menus.titles.index'),
|
223
|
-
lang('menus.errors.delete') % id
|
224
|
-
)
|
225
|
-
|
212
|
+
Menu[id].destroy
|
213
|
+
rescue => e
|
214
|
+
Ramaze::Log.error(e.inspect)
|
215
|
+
message(:error, lang('menus.errors.delete') % id)
|
226
216
|
redirect_referrer
|
227
217
|
end
|
228
218
|
end
|
229
219
|
|
230
|
-
|
220
|
+
message(:success, lang('menus.success.delete'))
|
231
221
|
redirect_referrer
|
232
222
|
end
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
223
|
+
end # Menus
|
224
|
+
end # Controller
|
225
|
+
end # Menus
|