zen 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/.mailmap +2 -0
- data/.rvmrc +2 -0
- data/.travis.yml +8 -3
- data/AUTHORS +1 -2
- data/CHANGELOG.md +48 -17
- data/README.md +44 -39
- data/Rakefile +4 -0
- data/bin/zen +5 -30
- data/lib/zen.rb +13 -19
- data/lib/zen/asset.rb +99 -64
- data/lib/zen/bin/create.rb +94 -0
- data/lib/zen/bin/runner.rb +118 -0
- data/lib/zen/controller/admin_controller.rb +52 -36
- data/lib/zen/controller/base_controller.rb +5 -5
- data/lib/zen/controller/frontend_controller.rb +7 -7
- data/lib/zen/controller/main_controller.rb +12 -10
- data/lib/zen/controller/preview.rb +15 -11
- data/lib/zen/helper/acl.rb +73 -53
- data/lib/zen/helper/blue_form_vendor.rb +689 -0
- data/lib/zen/helper/breadcrumb.rb +23 -19
- data/lib/zen/helper/message.rb +3 -3
- data/lib/zen/helper/theme.rb +18 -13
- data/lib/zen/language.rb +62 -58
- data/lib/zen/language/en/zen_general.yml +2 -4
- data/lib/zen/language/nl/zen_general.yml +2 -4
- data/lib/zen/layout/admin.xhtml +3 -12
- data/lib/zen/layout/login.xhtml +1 -6
- data/lib/zen/model/methods.rb +6 -6
- data/lib/zen/model/settings.rb +5 -4
- data/lib/zen/package.rb +47 -38
- data/lib/zen/package/all.rb +3 -5
- data/lib/zen/package/base.rb +7 -7
- data/lib/zen/package/categories/lib/categories.rb +8 -3
- data/lib/zen/package/categories/lib/categories/controller/categories.rb +81 -55
- data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +45 -44
- data/lib/zen/package/categories/lib/categories/helper/category.rb +88 -0
- data/lib/zen/package/categories/lib/categories/language/en/categories.yml +5 -4
- data/lib/zen/package/categories/lib/categories/language/en/category_groups.yml +5 -4
- data/lib/zen/package/categories/lib/categories/language/nl/categories.yml +5 -4
- data/lib/zen/package/categories/lib/categories/language/nl/category_groups.yml +5 -4
- data/lib/zen/package/categories/lib/categories/model/category.rb +15 -13
- data/lib/zen/package/categories/lib/categories/model/category_group.rb +3 -3
- data/lib/zen/package/categories/lib/categories/plugin/categories.rb +36 -25
- data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +49 -56
- data/lib/zen/package/categories/lib/categories/view/admin/categories/index.xhtml +48 -35
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/form.xhtml +36 -29
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/index.xhtml +42 -37
- data/lib/zen/package/comments/lib/comments.rb +4 -1
- data/lib/zen/package/comments/lib/comments/controller/comments.rb +39 -32
- data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +45 -26
- data/lib/zen/package/comments/lib/comments/helper/comment.rb +35 -0
- data/lib/zen/package/comments/lib/comments/language/en/comments.yml +9 -7
- data/lib/zen/package/comments/lib/comments/language/nl/comments.yml +10 -8
- data/lib/zen/package/comments/lib/comments/model/comment.rb +31 -17
- data/lib/zen/package/comments/lib/comments/model/comment_status.rb +15 -0
- data/lib/zen/package/comments/lib/comments/plugin/anti_spam.rb +27 -18
- data/lib/zen/package/comments/lib/comments/plugin/comments.rb +25 -20
- data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +61 -54
- data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +38 -23
- data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +60 -0
- data/lib/zen/package/custom_fields/lib/custom_fields.rb +33 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +209 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +50 -47
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +215 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +111 -73
- data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +79 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_groups.yml +20 -19
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_types.yml +40 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.yml +34 -32
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.yml +5 -4
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_types.yml +40 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.yml +18 -16
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +31 -11
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_method.rb +15 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb +50 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +28 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/form.xhtml +33 -28
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/index.xhtml +48 -46
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/form.xhtml +61 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/index.xhtml +93 -0
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +105 -99
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/index.xhtml +43 -39
- data/lib/zen/package/custom_fields/migrations/1295255665_create_schema.rb +47 -16
- data/lib/zen/package/custom_fields/migrations/1310659580_custom_field_types.rb +148 -0
- data/lib/zen/package/custom_fields/migrations/1311694920_rename_css_class.rb +11 -0
- data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +40 -35
- data/lib/zen/package/menus/lib/menus/controller/menus.rb +47 -43
- data/lib/zen/package/menus/lib/menus/helper/{menu_item.rb → menu.rb} +42 -15
- data/lib/zen/package/menus/lib/menus/language/en/menu_items.yml +5 -5
- data/lib/zen/package/menus/lib/menus/language/en/menus.yml +9 -8
- data/lib/zen/package/menus/lib/menus/language/nl/menu_items.yml +8 -8
- data/lib/zen/package/menus/lib/menus/language/nl/menus.yml +11 -10
- data/lib/zen/package/menus/lib/menus/model/menu.rb +5 -5
- data/lib/zen/package/menus/lib/menus/model/menu_item.rb +6 -5
- data/lib/zen/package/menus/lib/menus/plugin/menus.rb +41 -43
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/form.xhtml +59 -63
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/index.xhtml +35 -30
- data/lib/zen/package/menus/lib/menus/view/admin/menus/form.xhtml +46 -37
- data/lib/zen/package/menus/lib/menus/view/admin/menus/index.xhtml +37 -37
- data/lib/zen/package/menus/migrations/1297184342_create_schema.rb +5 -5
- data/lib/zen/package/menus/migrations/1308671733_rename_order_column.rb +11 -0
- data/lib/zen/package/menus/migrations/1311695030_rename_css_class.rb +17 -0
- data/lib/zen/package/sections/lib/sections.rb +18 -11
- data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +115 -109
- data/lib/zen/package/sections/lib/sections/controller/sections.rb +72 -50
- data/lib/zen/package/sections/lib/sections/helper/section.rb +53 -0
- data/lib/zen/package/sections/lib/sections/language/en/section_entries.yml +5 -4
- data/lib/zen/package/sections/lib/sections/language/en/sections.yml +5 -4
- data/lib/zen/package/sections/lib/sections/language/nl/section_entries.yml +5 -4
- data/lib/zen/package/sections/lib/sections/language/nl/sections.yml +5 -4
- data/lib/zen/package/sections/lib/sections/model/section.rb +17 -9
- data/lib/zen/package/sections/lib/sections/model/section_entry.rb +192 -13
- data/lib/zen/package/sections/lib/sections/model/section_entry_status.rb +13 -0
- data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +60 -39
- data/lib/zen/package/sections/lib/sections/plugin/sections.rb +14 -11
- data/lib/zen/package/sections/lib/sections/view/admin/form.xhtml +100 -97
- data/lib/zen/package/sections/lib/sections/view/admin/index.xhtml +41 -39
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +95 -215
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +48 -40
- data/lib/zen/package/sections/migrations/1308672298_use_id_for_default_section.rb +40 -0
- data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +58 -0
- data/lib/zen/package/settings/lib/settings/controller/settings.rb +5 -8
- data/lib/zen/package/settings/lib/settings/model/setting.rb +2 -37
- data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +18 -1
- data/lib/zen/package/settings/lib/settings/plugin/settings.rb +13 -7
- data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +2 -1
- data/lib/zen/package/users/lib/users.rb +3 -1
- data/lib/zen/package/users/lib/users/controller/access_rules.rb +77 -60
- data/lib/zen/package/users/lib/users/controller/user_groups.rb +41 -36
- data/lib/zen/package/users/lib/users/controller/users.rb +48 -42
- data/lib/zen/package/users/lib/users/helper/users.rb +72 -0
- data/lib/zen/package/users/lib/users/language/en/access_rules.yml +6 -5
- data/lib/zen/package/users/lib/users/language/en/user_groups.yml +5 -4
- data/lib/zen/package/users/lib/users/language/en/users.yml +1 -0
- data/lib/zen/package/users/lib/users/language/nl/access_rules.yml +5 -4
- data/lib/zen/package/users/lib/users/language/nl/user_groups.yml +5 -4
- data/lib/zen/package/users/lib/users/language/nl/users.yml +1 -0
- data/lib/zen/package/users/lib/users/model/access_rule.rb +5 -1
- data/lib/zen/package/users/lib/users/model/user.rb +17 -10
- data/lib/zen/package/users/lib/users/public/admin/js/users/access_rules.js +10 -37
- data/lib/zen/package/users/lib/users/public/admin/js/users/lib/access_rules.js +49 -0
- data/lib/zen/package/users/lib/users/view/admin/access-rules/form.xhtml +105 -96
- data/lib/zen/package/users/lib/users/view/admin/access-rules/index.xhtml +48 -41
- data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +42 -32
- data/lib/zen/package/users/lib/users/view/admin/user-groups/index.xhtml +43 -38
- data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +76 -67
- data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +43 -41
- data/lib/zen/package/users/lib/users/view/admin/users/login.xhtml +12 -9
- data/lib/zen/package/users/migrations/1295281013_create_schema.rb +2 -2
- data/lib/zen/plugin.rb +56 -50
- data/lib/zen/plugin/markup/lib/markup/markup.rb +33 -21
- data/lib/zen/public/admin/css/zen/buttons.css +11 -7
- data/lib/zen/public/admin/css/zen/datepicker.css +6 -6
- data/lib/zen/public/admin/css/zen/forms.css +2 -1
- data/lib/zen/public/admin/css/zen/general.css +15 -10
- data/lib/zen/public/admin/css/zen/layout.css +51 -20
- data/lib/zen/public/admin/css/zen/tables.css +39 -11
- data/lib/zen/public/admin/css/zen/tabs.css +6 -4
- data/lib/zen/public/admin/css/zen/window.css +11 -11
- data/lib/zen/public/{favicon.ico → admin/favicon.ico} +0 -0
- data/lib/zen/public/admin/images/zen/icons/asc.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/desc.png +0 -0
- data/lib/zen/public/admin/js/vendor/datepicker.js +0 -11
- data/lib/zen/public/admin/js/{mootools → vendor/mootools}/core.js +0 -1
- data/lib/zen/public/admin/js/{mootools → vendor/mootools}/more.js +100 -29
- data/lib/zen/public/admin/js/zen/index.js +48 -0
- data/lib/zen/public/admin/js/zen/lib/asset.js +111 -0
- data/lib/zen/public/admin/js/zen/{editor.js → lib/editor.js} +107 -127
- data/lib/zen/public/admin/js/zen/{editor → lib/editor}/markdown.js +7 -9
- data/lib/zen/public/admin/js/zen/{editor → lib/editor}/textile.js +7 -9
- data/lib/zen/public/admin/js/zen/lib/html_table.js +143 -0
- data/lib/zen/public/admin/js/zen/{tabs.js → lib/tabs.js} +40 -37
- data/lib/zen/public/admin/js/zen/{window.js → lib/window.js} +24 -20
- data/lib/zen/spec/bacon/color_output.rb +39 -0
- data/lib/zen/spec/helper.rb +152 -0
- data/lib/zen/spec/simplecov.rb +22 -0
- data/lib/zen/task/build.rake +20 -43
- data/lib/zen/task/clean.rake +2 -6
- data/lib/zen/task/db.rake +8 -12
- data/lib/zen/task/package.rake +4 -10
- data/lib/zen/task/plugin.rake +3 -9
- data/lib/zen/task/proto.rake +0 -62
- data/lib/zen/task/test.rake +6 -3
- data/lib/zen/task/theme.rake +4 -11
- data/lib/zen/theme.rb +22 -24
- data/lib/zen/validation.rb +34 -27
- data/lib/zen/version.rb +2 -8
- data/lib/zen/view/head.xhtml +7 -0
- data/lib/zen/view/main.xhtml +7 -22
- data/{proto/package/migrations → pkg}/.gitkeep +0 -0
- data/proto/app/app.rb +1 -0
- data/proto/app/config/config.rb +5 -4
- data/proto/app/config/database.rb +19 -41
- data/proto/app/config/middlewares.rb +32 -29
- data/proto/{package/lib/package/view/admin/package/index.xhtml → app/log/database/dev/.gitkeep} +0 -0
- data/proto/app/log/database/live/.gitkeep +0 -0
- data/spec/Rakefile +26 -0
- data/spec/fixtures/zen/asset.rb +18 -0
- data/spec/fixtures/zen/helper/acl.rb +39 -0
- data/spec/fixtures/zen/helper/message.rb +19 -0
- data/spec/fixtures/zen/language/en/spec.yml +10 -0
- data/spec/fixtures/zen/language/nl/spec.yml +7 -0
- data/spec/fixtures/zen/package.rb +17 -0
- data/spec/fixtures/zen/package/comments/controller/comments_form.rb +27 -0
- data/spec/fixtures/zen/package/settings/plugin/settings.rb +20 -0
- data/spec/fixtures/zen/plugin.rb +7 -0
- data/spec/fixtures/zen/theme/404.xhtml +1 -0
- data/spec/fixtures/zen/theme/default-section/index.xhtml +1 -0
- data/spec/fixtures/zen/theme/helper/404.xhtml +1 -0
- data/spec/fixtures/zen/theme/helper/partial.xhtml +1 -0
- data/spec/fixtures/zen/theme/helper/wrong_partial.xhtml +1 -0
- data/spec/fixtures/zen/theme/partials/partial.xhtml +1 -0
- data/spec/fixtures/zen/theme/theme.rb +11 -0
- data/spec/fixtures/zen/validation.rb +22 -0
- data/spec/helper.rb +41 -0
- data/spec/zen/all.rb +5 -0
- data/spec/zen/asset.rb +97 -0
- data/spec/zen/bin/create.rb +89 -0
- data/spec/zen/bin/runner.rb +47 -0
- data/spec/zen/controller/admin_controller.rb +26 -0
- data/spec/zen/controller/main_controller.rb +81 -0
- data/spec/zen/controller/preview.rb +33 -0
- data/spec/zen/helper/acl.rb +149 -0
- data/spec/zen/helper/breadcrumb.rb +38 -0
- data/spec/zen/helper/message.rb +31 -0
- data/spec/zen/helper/theme.rb +58 -0
- data/spec/zen/language.rb +55 -0
- data/spec/zen/package.rb +23 -0
- data/spec/zen/package/categories/controller/categories.rb +123 -0
- data/spec/zen/package/categories/controller/category_groups.rb +108 -0
- data/spec/zen/package/categories/helper/category.rb +75 -0
- data/spec/zen/package/categories/plugin/categories.rb +92 -0
- data/spec/zen/package/comments/controller/comments.rb +134 -0
- data/spec/zen/package/comments/controller/comments_form.rb +343 -0
- data/spec/zen/package/comments/helper/comment.rb +47 -0
- data/spec/zen/package/comments/plugin/anti_spam.rb +59 -0
- data/spec/zen/package/comments/plugin/comments.rb +107 -0
- data/spec/zen/package/custom_fields/blue_form_parameters.rb +183 -0
- data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +120 -0
- data/spec/zen/package/custom_fields/controller/custom_field_types.rb +169 -0
- data/spec/zen/package/custom_fields/controller/custom_fields.rb +158 -0
- data/spec/zen/package/custom_fields/helper/custom_field.rb +86 -0
- data/spec/zen/package/menus/controller/menu_items.rb +110 -0
- data/spec/zen/package/menus/controller/menus.rb +110 -0
- data/spec/zen/package/menus/helper/menu.rb +75 -0
- data/spec/zen/package/menus/plugin/menus.rb +120 -0
- data/spec/zen/package/sections/controller/section_entries.rb +201 -0
- data/spec/zen/package/sections/controller/sections.rb +116 -0
- data/spec/zen/package/sections/helper/section.rb +74 -0
- data/spec/zen/package/sections/plugin/section_entries.rb +161 -0
- data/spec/zen/package/sections/plugin/sections.rb +75 -0
- data/spec/zen/package/settings/controller/settings.rb +36 -0
- data/spec/zen/package/settings/plugin/settings.rb +33 -0
- data/spec/zen/package/users/controller/access_rules.rb +90 -0
- data/spec/zen/package/users/controller/user_groups.rb +101 -0
- data/spec/zen/package/users/controller/users.rb +130 -0
- data/spec/zen/package/users/helper/users.rb +97 -0
- data/spec/zen/plugin.rb +64 -0
- data/spec/zen/plugin/helper.rb +11 -0
- data/spec/zen/plugin/markup.rb +44 -0
- data/spec/zen/theme.rb +41 -0
- data/spec/zen/validation.rb +63 -0
- data/zen.gemspec +36 -0
- metadata +159 -113
- data/MANIFEST +0 -266
- data/lib/zen/bin/app.rb +0 -40
- data/lib/zen/ext/string.rb +0 -185
- data/lib/zen/helper/common.rb +0 -106
- data/lib/zen/package/categories/lib/categories/view/admin/categories/edit.xhtml +0 -7
- data/lib/zen/package/categories/lib/categories/view/admin/categories/new.xhtml +0 -7
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/edit.xhtml +0 -7
- data/lib/zen/package/categories/lib/categories/view/admin/category-groups/new.xhtml +0 -7
- data/lib/zen/package/comments/lib/comments/view/admin/comments/edit.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/edit.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/new.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/edit.xhtml +0 -7
- data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/new.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/edit.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menu-items/new.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menus/edit.xhtml +0 -7
- data/lib/zen/package/menus/lib/menus/view/admin/menus/new.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/edit.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/new.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/edit.xhtml +0 -7
- data/lib/zen/package/sections/lib/sections/view/admin/section-entries/new.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/access-rules/edit.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/access-rules/new.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/user-groups/edit.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/user-groups/new.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/users/edit.xhtml +0 -7
- data/lib/zen/package/users/lib/users/view/admin/users/new.xhtml +0 -7
- data/lib/zen/plugin/controller.rb +0 -59
- data/lib/zen/public/admin/css/zen/notifications.css +0 -84
- data/lib/zen/public/admin/images/zen/icons/large/error.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/large/notice.png +0 -0
- data/lib/zen/public/admin/images/zen/icons/large/success.png +0 -0
- data/lib/zen/public/admin/js/zen/core.js +0 -73
- data/lib/zen/public/admin/js/zen/init.js +0 -80
- data/proto/package/lib/package.rb +0 -21
- data/proto/package/lib/package/controller/controllers.rb +0 -50
- data/proto/package/lib/package/language/en/languages.yml +0 -4
- data/proto/package/lib/package/model/model.rb +0 -12
@@ -3,15 +3,15 @@
|
|
3
3
|
<h1>#{get_breadcrumbs}</h1>
|
4
4
|
</header>
|
5
5
|
|
6
|
-
<form method="post" action="#{
|
6
|
+
<form method="post" action="#{Menus::Controller::MenuItems.r(:delete)}">
|
7
7
|
<input name="csrf_token" type="hidden" value="#{get_csrf_token}" />
|
8
8
|
|
9
|
-
<?r if
|
10
|
-
<table
|
9
|
+
<?r if !@menu_items.empty? ?>
|
10
|
+
<table>
|
11
11
|
<thead>
|
12
12
|
<tr>
|
13
13
|
<?r if user_authorized?([:delete]) ?>
|
14
|
-
<th>
|
14
|
+
<th class="no_sort">
|
15
15
|
<input type="checkbox" />
|
16
16
|
</th>
|
17
17
|
<?r end ?>
|
@@ -21,8 +21,8 @@
|
|
21
21
|
<th>#{lang('menu_items.labels.url')}</th>
|
22
22
|
<th>#{lang('menu_items.labels.parent_id')}</th>
|
23
23
|
<th>#{lang('menu_items.labels.order')}</th>
|
24
|
-
<th>#{lang('menu_items.labels.
|
25
|
-
<th>#{lang('menu_items.labels.
|
24
|
+
<th>#{lang('menu_items.labels.html_class')}</th>
|
25
|
+
<th>#{lang('menu_items.labels.html_id')}</th>
|
26
26
|
</tr>
|
27
27
|
</thead>
|
28
28
|
<tbody>
|
@@ -31,7 +31,8 @@
|
|
31
31
|
<tr>
|
32
32
|
<?r if user_authorized?([:delete]) ?>
|
33
33
|
<td>
|
34
|
-
<input name="menu_item_ids[]" type="checkbox"
|
34
|
+
<input name="menu_item_ids[]" type="checkbox"
|
35
|
+
value="#{item.id}" />
|
35
36
|
</td>
|
36
37
|
<?r end ?>
|
37
38
|
|
@@ -39,46 +40,50 @@
|
|
39
40
|
|
40
41
|
<?r if user_authorized?([:update]) ?>
|
41
42
|
<td>
|
42
|
-
#{
|
43
|
-
item.name,
|
44
|
-
Menus::Controller::MenuItems.r(:edit, @menu_id, item.id)
|
43
|
+
#{Menus::Controller::MenuItems.a(
|
44
|
+
item.name, :edit, @menu_id, item.id
|
45
45
|
)}
|
46
46
|
</td>
|
47
47
|
<?r else ?>
|
48
48
|
<td>#{item.name}</td>
|
49
49
|
<?r end ?>
|
50
50
|
|
51
|
-
<td
|
51
|
+
<td>
|
52
|
+
<a href="#{item.url}">#{item.url}</a>
|
53
|
+
</td>
|
54
|
+
|
52
55
|
<td>#{item.ancestors.map { |a| a.name }.join(', ')}</td>
|
53
|
-
<td>#{item.
|
54
|
-
<td>#{item.
|
55
|
-
<td>#{item.
|
56
|
+
<td>#{item.sort_order}</td>
|
57
|
+
<td>#{item.html_class}</td>
|
58
|
+
<td>#{item.html_id}</td>
|
56
59
|
</tr>
|
57
60
|
<?r end ?>
|
58
61
|
|
59
62
|
</tbody>
|
60
63
|
</table>
|
61
64
|
|
65
|
+
#{
|
66
|
+
if @menu_items.respond_to?(:navigation) and @menu_items.page_count > 1
|
67
|
+
@menu_items.navigation
|
68
|
+
end
|
69
|
+
}
|
70
|
+
|
62
71
|
<?r else ?>
|
63
72
|
<p>#{lang('menu_items.messages.no_items')}</p>
|
64
73
|
<?r end ?>
|
65
74
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
Menus::Controller::MenuItems.r(:new, @menu_id)
|
72
|
-
)}
|
73
|
-
</div>
|
74
|
-
<?r end ?>
|
75
|
-
|
76
|
-
<?r if user_authorized?([:delete]) ?>
|
77
|
-
<div class="button">
|
78
|
-
<input type="submit" value="#{lang('menu_items.buttons.delete')}" />
|
79
|
-
</div>
|
80
|
-
<?r end ?>
|
75
|
+
<?r if user_authorized?([:create, :read]) ?>
|
76
|
+
<div class="button">
|
77
|
+
#{Menus::Controller::MenuItems.a(
|
78
|
+
lang('menu_items.buttons.new'), :new, @menu_id
|
79
|
+
)}
|
81
80
|
</div>
|
82
|
-
|
81
|
+
<?r end ?>
|
83
82
|
|
83
|
+
<?r if user_authorized?([:delete]) ?>
|
84
|
+
<div class="button">
|
85
|
+
<input type="submit" value="#{lang('menu_items.buttons.delete')}" />
|
86
|
+
</div>
|
87
|
+
<?r end ?>
|
88
|
+
</form>
|
84
89
|
</article>
|
@@ -1,42 +1,51 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<article>
|
2
|
+
<header>
|
3
|
+
<h1>#{get_breadcrumbs}</h1>
|
4
|
+
</header>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
#{
|
7
|
+
form_for(
|
8
|
+
@menu,
|
9
|
+
:method => :post,
|
10
|
+
:action => Menus::Controller::Menus.r(:save),
|
11
|
+
:id => :menu_form
|
12
|
+
) do |f|
|
13
|
+
f.input_hidden(:csrf_token, get_csrf_token)
|
14
|
+
f.input_hidden(:id , @menu.id)
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
f.input_text(
|
19
|
-
lang('menus.labels.css_class'),
|
20
|
-
:css_class,
|
21
|
-
:placeholder => lang('menus.placeholders.css_class')
|
22
|
-
)
|
16
|
+
f.input_text(
|
17
|
+
lang('menus.labels.name'),
|
18
|
+
:name,
|
19
|
+
:placeholder => lang('menus.placeholders.name')
|
20
|
+
)
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
f.input_text(
|
23
|
+
lang('menus.labels.slug'),
|
24
|
+
:slug,
|
25
|
+
:placeholder => lang('menus.placeholders.slug')
|
26
|
+
)
|
27
|
+
|
28
|
+
f.input_text(
|
29
|
+
lang('menus.labels.html_class'),
|
30
|
+
:html_class,
|
31
|
+
:placeholder => lang('menus.placeholders.html_class')
|
32
|
+
)
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
f.input_text(
|
35
|
+
lang('menus.labels.html_id'),
|
36
|
+
:html_id,
|
37
|
+
:placeholder => lang('menus.placeholders.html_id')
|
38
|
+
)
|
39
|
+
|
40
|
+
f.textarea(
|
41
|
+
lang('menus.labels.description'),
|
42
|
+
:description,
|
43
|
+
:rows => 8
|
44
|
+
)
|
45
|
+
|
46
|
+
f.g.div(:class => "button") do
|
47
|
+
f.g.input(:type => :submit, :value => lang('menus.buttons.save'))
|
48
|
+
end
|
39
49
|
end
|
40
|
-
|
41
|
-
|
42
|
-
}
|
50
|
+
}
|
51
|
+
</article>
|
@@ -3,16 +3,16 @@
|
|
3
3
|
<h1>#{get_breadcrumbs}</h1>
|
4
4
|
</header>
|
5
5
|
|
6
|
-
<form action="#{
|
6
|
+
<form action="#{Menus::Controller::Menus.r(:delete)}" method="post">
|
7
7
|
<input name="csrf_token" type="hidden" value="#{get_csrf_token}" />
|
8
8
|
|
9
9
|
<?r if @menus and !@menus.empty? ?>
|
10
10
|
|
11
|
-
<table
|
11
|
+
<table>
|
12
12
|
<thead>
|
13
13
|
<tr>
|
14
14
|
<?r if user_authorized?([:delete]) ?>
|
15
|
-
<th>
|
15
|
+
<th class="no_sort">
|
16
16
|
<input type="checkbox" />
|
17
17
|
</th>
|
18
18
|
<?r end ?>
|
@@ -20,46 +20,46 @@
|
|
20
20
|
<th>#{lang('menus.labels.id')}</th>
|
21
21
|
<th>#{lang('menus.labels.name')}</th>
|
22
22
|
<th>#{lang('menus.labels.slug')}</th>
|
23
|
-
<th>#{lang('menus.labels.
|
24
|
-
<th>#{lang('menus.labels.
|
23
|
+
<th>#{lang('menus.labels.html_class')}</th>
|
24
|
+
<th>#{lang('menus.labels.html_id')}</th>
|
25
25
|
|
26
|
-
<?r if user_authorized?(
|
26
|
+
<?r if user_authorized?(
|
27
|
+
[:read], true, 'Menus::Controller::MenuItems'
|
28
|
+
) ?>
|
27
29
|
<th></th>
|
28
30
|
<?r end ?>
|
29
31
|
</tr>
|
30
32
|
</thead>
|
31
|
-
|
32
33
|
<tbody>
|
33
34
|
<?r @menus.each do |menu| ?>
|
34
35
|
<tr>
|
35
36
|
<?r if user_authorized?([:delete]) ?>
|
36
37
|
<td>
|
37
|
-
<input type="checkbox" name="menu_ids[]"
|
38
|
+
<input type="checkbox" name="menu_ids[]"
|
39
|
+
value="#{menu.id}" />
|
38
40
|
</td>
|
39
41
|
<?r end ?>
|
40
42
|
|
41
43
|
<td>#{menu.id}</td>
|
42
|
-
|
44
|
+
|
43
45
|
<?r if user_authorized?([:update]) ?>
|
44
46
|
<td>
|
45
|
-
#{
|
46
|
-
menu.name,
|
47
|
-
Menus::Controller::Menus.r(:edit, menu.id)
|
48
|
-
)}
|
47
|
+
#{Menus::Controller::Menus.a(menu.name, :edit, menu.id)}
|
49
48
|
</td>
|
50
49
|
<?r else ?>
|
51
50
|
<td>#{menu.name}</td>
|
52
51
|
<?r end ?>
|
53
52
|
|
54
53
|
<td>#{menu.slug}</td>
|
55
|
-
<td>#{menu.
|
56
|
-
<td>#{menu.
|
54
|
+
<td>#{menu.html_class}</td>
|
55
|
+
<td>#{menu.html_id}</td>
|
57
56
|
|
58
|
-
<?r if user_authorized?(
|
57
|
+
<?r if user_authorized?(
|
58
|
+
[:read], true, 'Menus::Controller::MenuItems'
|
59
|
+
) ?>
|
59
60
|
<td>
|
60
|
-
#{
|
61
|
-
lang('menus.labels.manage_items'),
|
62
|
-
Menus::Controller::MenuItems.r(:index, menu.id)
|
61
|
+
#{Menus::Controller::MenuItems.a(
|
62
|
+
lang('menus.labels.manage_items'), :index, menu.id
|
63
63
|
)}
|
64
64
|
</td>
|
65
65
|
<?r end ?>
|
@@ -68,28 +68,28 @@
|
|
68
68
|
</tbody>
|
69
69
|
</table>
|
70
70
|
|
71
|
+
#{
|
72
|
+
if @menus.respond_to?(:navigation) and @menus.page_count > 1
|
73
|
+
@menus.navigation
|
74
|
+
end
|
75
|
+
}
|
76
|
+
|
71
77
|
<?r else ?>
|
72
78
|
<p>#{lang('menus.messages.no_menus')}</p>
|
73
79
|
<?r end ?>
|
74
80
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
)}
|
83
|
-
</div>
|
84
|
-
<?r end ?>
|
85
|
-
|
86
|
-
<?r if user_authorized?([:delete]) ?>
|
87
|
-
<div class="button">
|
88
|
-
<input type="submit" value="#{lang('menus.buttons.delete')}" />
|
89
|
-
</div>
|
90
|
-
<?r end ?>
|
81
|
+
<?r if user_authorized?([:create, :read]) ?>
|
82
|
+
<div class="button">
|
83
|
+
#{Menus::Controller::Menus.a(
|
84
|
+
lang('menus.buttons.new'), :new
|
85
|
+
)}
|
86
|
+
</div>
|
87
|
+
<?r end ?>
|
91
88
|
|
89
|
+
<?r if user_authorized?([:delete]) ?>
|
90
|
+
<div class="button">
|
91
|
+
<input type="submit" value="#{lang('menus.buttons.delete')}" />
|
92
92
|
</div>
|
93
|
-
|
94
|
-
</form>
|
93
|
+
<?r end ?>
|
94
|
+
</form>
|
95
95
|
</article>
|
@@ -15,16 +15,16 @@ Sequel.migration do
|
|
15
15
|
primary_key :id
|
16
16
|
|
17
17
|
Integer :parent_id, :index => true
|
18
|
-
String
|
19
|
-
String
|
18
|
+
String :name , :null => false
|
19
|
+
String :url , :null => false
|
20
20
|
Integer :order , :default => 0
|
21
|
-
String
|
22
|
-
String
|
21
|
+
String :css_class
|
22
|
+
String :css_id
|
23
23
|
|
24
24
|
foreign_key :menu_id, :menus, :update => :on_cascade, :on_delete => :cascade, :key => :id
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
down do
|
29
29
|
drop_table :menu_items
|
30
30
|
drop_table :menus
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
# Updates the database with the changes specified in the block.
|
3
|
+
up do
|
4
|
+
rename_column(:menu_items, :order, :sort_order)
|
5
|
+
end
|
6
|
+
|
7
|
+
# Reverts the changes made in the up() block.
|
8
|
+
down do
|
9
|
+
rename_column(:menu_items, :sort_order, :order)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
# Updates the database with the changes specified in the block.
|
3
|
+
up do
|
4
|
+
rename_column(:menu_items, :css_class, :html_class)
|
5
|
+
rename_column(:menu_items, :css_id , :html_id)
|
6
|
+
rename_column(:menus , :css_class, :html_class)
|
7
|
+
rename_column(:menus , :css_id , :html_id)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Reverts the changes made in the up() block.
|
11
|
+
down do
|
12
|
+
rename_column(:menu_items, :html_class, :css_class)
|
13
|
+
rename_column(:menu_items, :html_id , :css_id)
|
14
|
+
rename_column(:menus , :html_class, :css_class)
|
15
|
+
rename_column(:menus , :html_id , :css_id)
|
16
|
+
end
|
17
|
+
end
|
@@ -1,5 +1,8 @@
|
|
1
|
+
Ramaze::HelpersHelper.options.paths.push(__DIR__('sections'))
|
2
|
+
|
1
3
|
require __DIR__('sections/model/section')
|
2
4
|
require __DIR__('sections/model/section_entry')
|
5
|
+
require __DIR__('sections/model/section_entry_status')
|
3
6
|
require __DIR__('sections/controller/sections')
|
4
7
|
require __DIR__('sections/controller/section_entries')
|
5
8
|
require __DIR__('sections/plugin/sections')
|
@@ -48,21 +51,25 @@ Zen::Plugin.add do |p|
|
|
48
51
|
end
|
49
52
|
|
50
53
|
# Register all the settings
|
51
|
-
section_hash = {}
|
52
|
-
|
53
|
-
begin
|
54
|
-
Sections::Model::Section.select(:name, :slug).each do |s|
|
55
|
-
section_hash[s.slug] = s.name
|
56
|
-
end
|
57
|
-
rescue => e
|
58
|
-
Ramaze::Log.warn("The settings plugin failed to retrieve all sections: #{e.message}")
|
59
|
-
end
|
60
|
-
|
61
54
|
plugin(:settings, :register) do |setting|
|
62
55
|
setting.title = lang('settings.labels.default_section')
|
63
56
|
setting.description = lang('settings.placeholders.default_section')
|
64
57
|
setting.name = 'default_section'
|
65
58
|
setting.group = 'general'
|
66
59
|
setting.type = 'select'
|
67
|
-
setting.values =
|
60
|
+
setting.values = lambda do
|
61
|
+
section_hash = {}
|
62
|
+
|
63
|
+
begin
|
64
|
+
Sections::Model::Section.select(:name, :id).all.each do |s|
|
65
|
+
section_hash[s.id] = s.name
|
66
|
+
end
|
67
|
+
|
68
|
+
return section_hash
|
69
|
+
rescue => e
|
70
|
+
Ramaze::Log.warn(
|
71
|
+
"The settings plugin failed to retrieve all sections: #{e.message}"
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
68
75
|
end
|
@@ -13,12 +13,22 @@ module Sections
|
|
13
13
|
include ::Sections::Model
|
14
14
|
|
15
15
|
map '/admin/section-entries'
|
16
|
+
helper :section
|
16
17
|
|
17
18
|
# Load all required Javascript files
|
18
|
-
javascript
|
19
|
+
javascript(
|
20
|
+
[
|
21
|
+
'zen/lib/tabs',
|
22
|
+
'zen/lib/editor',
|
23
|
+
'zen/lib/editor/markdown',
|
24
|
+
'zen/lib/editor/textile',
|
25
|
+
'vendor/datepicker'
|
26
|
+
],
|
27
|
+
:method => [:edit, :new]
|
28
|
+
)
|
19
29
|
|
20
30
|
# Load all required CSS files
|
21
|
-
stylesheet
|
31
|
+
stylesheet(['zen/datepicker'], :method => [:edit, :new])
|
22
32
|
|
23
33
|
before_all do
|
24
34
|
csrf_protection(:save, :delete) do
|
@@ -42,9 +52,6 @@ module Sections
|
|
42
52
|
def initialize
|
43
53
|
super
|
44
54
|
|
45
|
-
@form_save_url = SectionEntries.r(:save)
|
46
|
-
@form_delete_url = SectionEntries.r(:delete)
|
47
|
-
|
48
55
|
Zen::Language.load('section_entries')
|
49
56
|
Zen::Language.load('sections')
|
50
57
|
|
@@ -53,14 +60,9 @@ module Sections
|
|
53
60
|
method = action.method.to_sym
|
54
61
|
@page_title = lang("section_entries.titles.#{method}") rescue nil
|
55
62
|
end
|
56
|
-
|
57
|
-
@status_hash = {
|
58
|
-
'draft' => lang('section_entries.special.status_hash.draft'),
|
59
|
-
'published' => lang('section_entries.special.status_hash.published')
|
60
|
-
}
|
61
63
|
end
|
62
64
|
|
63
|
-
##
|
65
|
+
##]
|
64
66
|
# Show an overview of all entries for the current section.
|
65
67
|
#
|
66
68
|
# This method requires the following permissions:
|
@@ -68,22 +70,21 @@ module Sections
|
|
68
70
|
# * read
|
69
71
|
#
|
70
72
|
# @author Yorick Peterse
|
71
|
-
# @param [
|
73
|
+
# @param [Fixnum] section_id The ID of the current section.
|
72
74
|
# @since 0.1
|
73
75
|
#
|
74
76
|
def index(section_id)
|
75
|
-
|
76
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
77
|
-
end
|
77
|
+
require_permissions(:read)
|
78
78
|
|
79
79
|
set_breadcrumbs(
|
80
|
-
|
80
|
+
Sections.a(lang('sections.titles.index'), :index),
|
81
81
|
lang('section_entries.titles.index')
|
82
82
|
)
|
83
83
|
|
84
|
-
section =
|
84
|
+
section = validate_section(section_id)
|
85
85
|
@section_id = section_id
|
86
|
-
@entries =
|
86
|
+
@entries = SectionEntry.filter(:section_id => section_id)
|
87
|
+
@entries = paginate(@entries)
|
87
88
|
end
|
88
89
|
|
89
90
|
##
|
@@ -95,38 +96,36 @@ module Sections
|
|
95
96
|
# * update
|
96
97
|
#
|
97
98
|
# @author Yorick Peterse
|
98
|
-
# @param [
|
99
|
-
# @param [
|
99
|
+
# @param [Fixnum] section_id The ID of the current section.
|
100
|
+
# @param [Fixnum] entry_id The ID of the current section entry.
|
100
101
|
# @since 0.1
|
101
102
|
#
|
102
103
|
def edit(section_id, entry_id)
|
103
|
-
|
104
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
105
|
-
end
|
104
|
+
require_permissions(:read, :update)
|
106
105
|
|
107
106
|
set_breadcrumbs(
|
108
|
-
|
109
|
-
lang('sections.titles.index'),
|
110
|
-
Sections.r(:index)
|
107
|
+
Sections.a(
|
108
|
+
lang('sections.titles.index'), :index
|
111
109
|
),
|
112
|
-
|
113
|
-
lang('section_entries.titles.index'),
|
114
|
-
SectionEntries.r(:index, section_id)
|
110
|
+
SectionEntries.a(
|
111
|
+
lang('section_entries.titles.index'), :index, section_id
|
115
112
|
),
|
116
113
|
lang('section_entries.titles.edit')
|
117
114
|
)
|
118
115
|
|
119
|
-
|
116
|
+
validate_section(section_id)
|
120
117
|
|
121
118
|
if flash[:form_data]
|
122
119
|
@entry = flash[:form_data]
|
123
120
|
else
|
124
|
-
@entry =
|
121
|
+
@entry = validate_section_entry(entry_id, section_id)
|
125
122
|
end
|
126
123
|
|
127
|
-
@
|
124
|
+
@section_id = section_id
|
125
|
+
@possible_categories = @entry.possible_categories
|
126
|
+
@custom_fields_hash = @entry.custom_fields_hash
|
128
127
|
|
129
|
-
|
128
|
+
render_view(:form)
|
130
129
|
end
|
131
130
|
|
132
131
|
##
|
@@ -138,37 +137,37 @@ module Sections
|
|
138
137
|
# * create
|
139
138
|
#
|
140
139
|
# @author Yorick Peterse
|
141
|
-
# @param [
|
140
|
+
# @param [Fixnum] section_id The ID of the current section.
|
142
141
|
# @since 0.1
|
143
142
|
#
|
144
143
|
def new(section_id)
|
145
|
-
|
146
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
147
|
-
end
|
144
|
+
require_permissions(:read, :create)
|
148
145
|
|
149
146
|
set_breadcrumbs(
|
150
|
-
|
151
|
-
lang('sections.titles.index'),
|
152
|
-
Sections.r(:index)
|
147
|
+
Sections.a(
|
148
|
+
lang('sections.titles.index'), :index
|
153
149
|
),
|
154
|
-
|
155
|
-
lang('section_entries.titles.index'),
|
156
|
-
SectionEntries.r(:index, section_id)
|
150
|
+
SectionEntries.a(
|
151
|
+
lang('section_entries.titles.index'), :index, section_id
|
157
152
|
),
|
158
153
|
lang('section_entries.titles.new')
|
159
154
|
)
|
160
155
|
|
161
|
-
|
162
|
-
|
163
|
-
@
|
156
|
+
validate_section(section_id)
|
157
|
+
|
158
|
+
@section_id = section_id
|
159
|
+
@entry = SectionEntry.new(:section_id => section_id)
|
160
|
+
@possible_categories = @entry.possible_categories
|
161
|
+
@custom_fields_hash = @entry.custom_fields_hash
|
164
162
|
|
165
|
-
|
163
|
+
render_view(:form)
|
166
164
|
end
|
167
165
|
|
168
166
|
##
|
169
|
-
# Method used for processing the form data and redirecting the user back
|
170
|
-
# the proper URL. Based on the value of a hidden field named "id" we'll
|
171
|
-
# if the data will be used to create a new section or to update
|
167
|
+
# Method used for processing the form data and redirecting the user back
|
168
|
+
# to the proper URL. Based on the value of a hidden field named "id" we'll
|
169
|
+
# determine if the data will be used to create a new section or to update
|
170
|
+
# an existing one.
|
172
171
|
#
|
173
172
|
# This method requires the following permissions:
|
174
173
|
#
|
@@ -177,81 +176,87 @@ module Sections
|
|
177
176
|
#
|
178
177
|
# @author Yorick Peterse
|
179
178
|
# @since 0.1
|
180
|
-
# @todo The way this method handles the creation of field values might
|
181
|
-
# patches as it executes quite a few queries. I'll keep it
|
179
|
+
# @todo The way this method handles the creation of field values might
|
180
|
+
# require some patches as it executes quite a few queries. I'll keep it
|
181
|
+
# as it is for now.
|
182
182
|
#
|
183
183
|
def save
|
184
|
-
|
185
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
186
|
-
end
|
184
|
+
section_id = request.params['section_id']
|
187
185
|
|
188
|
-
|
189
|
-
section_id = post['section_id']
|
190
|
-
field_values = post['custom_field_values']
|
191
|
-
custom_field_errors = {}
|
186
|
+
validate_section(section_id)
|
192
187
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
if !post['category_pks'].nil?
|
197
|
-
post['category_pks'].map! { |value| value.to_i }
|
198
|
-
else
|
199
|
-
post['category_pks'] = []
|
200
|
-
end
|
188
|
+
if request.params['id'] and !request.params['id'].empty?
|
189
|
+
require_permissions(:update)
|
201
190
|
|
202
|
-
|
203
|
-
|
204
|
-
save_action = :save
|
191
|
+
@entry = SectionEntry[request.params['id']]
|
192
|
+
save_action = :save
|
205
193
|
|
206
|
-
# Section entries aren't considered to be updated whenever a custom
|
207
|
-
# is modified, this solves that problem
|
208
|
-
|
194
|
+
# Section entries aren't considered to be updated whenever a custom
|
195
|
+
# field value is modified, this solves that problem
|
196
|
+
request.params['updated_at'] = Time.new
|
209
197
|
else
|
210
|
-
|
211
|
-
|
198
|
+
require_permissions(:create)
|
199
|
+
|
200
|
+
@entry = SectionEntry.new(:section_id => section_id)
|
201
|
+
save_action = :new
|
212
202
|
end
|
213
203
|
|
214
|
-
|
204
|
+
request.params.delete('slug') if request.params['slug'].empty?
|
205
|
+
request.params.delete('id')
|
215
206
|
|
216
207
|
flash_success = lang("section_entries.success.#{save_action}")
|
217
208
|
flash_error = lang("section_entries.errors.#{save_action}")
|
209
|
+
custom_fields = @entry.custom_fields
|
210
|
+
field_errors = {}
|
211
|
+
field_values = {}
|
212
|
+
|
213
|
+
@entry.custom_field_values.each do |value|
|
214
|
+
field_values[value.custom_field_id] = value
|
215
|
+
end
|
218
216
|
|
219
|
-
# Transactions ahoy!
|
220
217
|
begin
|
221
218
|
Zen.database.transaction do
|
222
219
|
# Update the entry itself
|
223
|
-
@entry.update(
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
if field_value.nil?
|
234
|
-
field_value = @entry.add_custom_field_value(
|
235
|
-
:section_entry_id => @entry.id,
|
236
|
-
:custom_field_id => field_id
|
237
|
-
)
|
238
|
-
end
|
220
|
+
@entry.update(request.subset(
|
221
|
+
:title,
|
222
|
+
:created_at,
|
223
|
+
:updated_at,
|
224
|
+
:section_id,
|
225
|
+
:user_id,
|
226
|
+
:slug,
|
227
|
+
:section_entry_status_id
|
228
|
+
))
|
239
229
|
|
240
|
-
|
241
|
-
custom_field = field_value.custom_field
|
230
|
+
message(:success, flash_success)
|
242
231
|
|
243
|
-
|
244
|
-
|
245
|
-
|
232
|
+
# Update/add all the custom field values
|
233
|
+
custom_fields.each do |field|
|
234
|
+
key = "custom_field_value_#{field.id}"
|
235
|
+
|
236
|
+
# The custom field has been submitted, let's see if we have to
|
237
|
+
# update it or add it.
|
238
|
+
if request.params.key?(key)
|
239
|
+
# Validate it
|
240
|
+
if field.required and request.params[key].empty?
|
241
|
+
field_errors[:"custom_field_value_#{field.id}"] = \
|
242
|
+
lang('zen_models.presence')
|
243
|
+
|
244
|
+
raise
|
245
|
+
end
|
246
|
+
|
247
|
+
# Update it
|
248
|
+
if field_values.key?(field.id)
|
249
|
+
field_values[field.id].update(:value => request.params[key])
|
250
|
+
# Add it
|
251
|
+
else
|
252
|
+
@entry.add_custom_field_value(
|
253
|
+
:custom_field_id => field.id,
|
254
|
+
:value => request.params[key]
|
255
|
+
)
|
256
|
+
end
|
246
257
|
end
|
247
|
-
|
248
|
-
raise unless custom_field_errors.empty?
|
249
|
-
|
250
|
-
field_value.value = value
|
251
|
-
field_value.save
|
252
258
|
end
|
253
259
|
end
|
254
|
-
|
255
260
|
# The rescue statement is called whenever the following happens:
|
256
261
|
#
|
257
262
|
# 1. The fields for the section entry (title, slug, etc) are invalid
|
@@ -261,7 +266,7 @@ module Sections
|
|
261
266
|
Ramaze::Log.error(e.inspect)
|
262
267
|
message(:error, flash_error)
|
263
268
|
|
264
|
-
flash[:form_errors] = @entry.errors.merge(
|
269
|
+
flash[:form_errors] = @entry.errors.merge(field_errors)
|
265
270
|
flash[:form_data] = @entry
|
266
271
|
|
267
272
|
redirect_referrer
|
@@ -286,11 +291,10 @@ module Sections
|
|
286
291
|
# @since 0.1
|
287
292
|
#
|
288
293
|
def delete
|
289
|
-
|
290
|
-
respond(lang('zen_general.errors.not_authorized'), 403)
|
291
|
-
end
|
294
|
+
require_permissions(:delete)
|
292
295
|
|
293
|
-
if !request.params['section_entry_ids']
|
296
|
+
if !request.params['section_entry_ids'] \
|
297
|
+
or request.params['section_entry_ids'].empty?
|
294
298
|
message(:error, lang('section_entries.errors.no_delete'))
|
295
299
|
redirect_referrer
|
296
300
|
end
|
@@ -302,6 +306,8 @@ module Sections
|
|
302
306
|
rescue => e
|
303
307
|
Ramaze::Log.error(e.inspect)
|
304
308
|
message(:error,lang('section_entries.errors.delete') % id)
|
309
|
+
|
310
|
+
redirect_referrer
|
305
311
|
end
|
306
312
|
end
|
307
313
|
|