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
@@ -0,0 +1,79 @@
|
|
1
|
+
#:nodoc:
|
2
|
+
module Ramaze
|
3
|
+
#:nodocL
|
4
|
+
module Helper
|
5
|
+
##
|
6
|
+
# Helper for the custom fields package.
|
7
|
+
#
|
8
|
+
# @author Yorick Peterse
|
9
|
+
# @since 0.2.8
|
10
|
+
#
|
11
|
+
module CustomField
|
12
|
+
##
|
13
|
+
# Validates a custom field group and returns the object if it's valid.
|
14
|
+
#
|
15
|
+
# @author Yorick Peterse
|
16
|
+
# @since 0.2.8
|
17
|
+
# @param [Fixnum] custom_field_group_id An ID of a custom field group
|
18
|
+
# that has to be validated.
|
19
|
+
# @return [CustomFields::Model::CustomFieldGroup]
|
20
|
+
#
|
21
|
+
def validate_custom_field_group(custom_field_group_id)
|
22
|
+
group = ::CustomFields::Model::CustomFieldGroup[custom_field_group_id]
|
23
|
+
|
24
|
+
if group.nil?
|
25
|
+
message(:error, lang('custom_field_groups.errors.invalid_group'))
|
26
|
+
redirect(::CustomFields::Controller::CustomFieldGroups.r(:index))
|
27
|
+
else
|
28
|
+
return group
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Similar to validate_custom_field_group() this method validates a single
|
34
|
+
# custom field and returns it if it's valid.
|
35
|
+
#
|
36
|
+
# @author Yorick Peterse
|
37
|
+
# @since 0.2.8
|
38
|
+
# @param [Fixnum] custom_field_id The ID of the custom field to validate.
|
39
|
+
# @param [Fixnum] custom_field_group_id The ID of the field group the
|
40
|
+
# field is supposed to belong to.
|
41
|
+
# @return [CustomFields::Model::CustomField]
|
42
|
+
#
|
43
|
+
def validate_custom_field(custom_field_id, custom_field_group_id)
|
44
|
+
field = ::CustomFields::Model::CustomField[custom_field_id]
|
45
|
+
|
46
|
+
if field.nil?
|
47
|
+
message(:error, lang('custom_fields.errors.invalid_field'))
|
48
|
+
redirect(
|
49
|
+
::CustomFields::Controller::CustomFields.r(
|
50
|
+
:index, custom_field_group_id
|
51
|
+
)
|
52
|
+
)
|
53
|
+
else
|
54
|
+
return field
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Validates a custom field type and returns it if it's valid.
|
60
|
+
#
|
61
|
+
# @author Yorick Peterse
|
62
|
+
# @since 0.2.8
|
63
|
+
# @param [Fixnum] custom_field_type_id The ID of the field type to
|
64
|
+
# validate.
|
65
|
+
# @return [CustomFields::Model::CustomFieldType]
|
66
|
+
#
|
67
|
+
def validate_custom_field_type(custom_field_type_id)
|
68
|
+
type = ::CustomFields::Model::CustomFieldType[custom_field_type_id]
|
69
|
+
|
70
|
+
if type.nil?
|
71
|
+
message(:error, lang('custom_field_types.errors.invalid_type'))
|
72
|
+
redirect(::CustomFields::Controller::CustomFieldTypes.r(:index))
|
73
|
+
else
|
74
|
+
return type
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end # CustomField
|
78
|
+
end # Helper
|
79
|
+
end # Ramaze
|
@@ -1,32 +1,33 @@
|
|
1
1
|
---
|
2
2
|
titles:
|
3
3
|
index: 'Custom Field Groups'
|
4
|
-
edit: 'Edit Custom Field Group'
|
5
|
-
new: 'Add Custom Field Group'
|
4
|
+
edit : 'Edit Custom Field Group'
|
5
|
+
new : 'Add Custom Field Group'
|
6
6
|
|
7
7
|
labels:
|
8
|
-
id
|
9
|
-
name
|
10
|
-
description
|
11
|
-
sections
|
12
|
-
manage_fields
|
13
|
-
none
|
8
|
+
id : '#'
|
9
|
+
name : 'Name'
|
10
|
+
description : 'Description'
|
11
|
+
sections : 'Sections'
|
12
|
+
manage_fields: 'Manage custom fields'
|
13
|
+
none : 'None'
|
14
14
|
|
15
15
|
messages:
|
16
|
-
no_groups
|
16
|
+
no_groups: 'No custom field groups have been created yet.'
|
17
17
|
|
18
18
|
errors:
|
19
|
-
new
|
20
|
-
save
|
21
|
-
delete
|
22
|
-
no_delete
|
19
|
+
new : 'Failed to create a new custom field group.'
|
20
|
+
save : 'Failed to modify the custom field group.'
|
21
|
+
delete : 'Failed to delete the custom field group with ID #%s'
|
22
|
+
no_delete : "You haven't specified any custom field groups to delete"
|
23
|
+
invalid_group: 'The specified custom field group is invalid.'
|
23
24
|
|
24
25
|
success:
|
25
|
-
new
|
26
|
-
save
|
27
|
-
delete
|
26
|
+
new : 'The custom field group has been created.'
|
27
|
+
save : 'The custom field group has been modified.'
|
28
|
+
delete: 'The selected custom field groups have been deleted.'
|
28
29
|
|
29
30
|
buttons:
|
30
|
-
new
|
31
|
-
delete
|
32
|
-
save
|
31
|
+
new : 'Add group'
|
32
|
+
delete: 'Delete selected groups'
|
33
|
+
save : 'Save group'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
titles:
|
3
|
+
index: 'Custom Field Types'
|
4
|
+
edit : 'Edit Custom Field Type'
|
5
|
+
new : 'Add Custom Field Type'
|
6
|
+
|
7
|
+
labels:
|
8
|
+
id : '#'
|
9
|
+
name : 'Name'
|
10
|
+
language_string : 'Language string'
|
11
|
+
html_class : 'HTML class'
|
12
|
+
serialize : 'Serialize'
|
13
|
+
allow_markup : 'Allow markup'
|
14
|
+
custom_field_method_id: 'Custom field method'
|
15
|
+
|
16
|
+
placeholders:
|
17
|
+
language_string: 'The full language string to use.'
|
18
|
+
html_class : 'A set of HTML classes to apply to all fields.'
|
19
|
+
serialize : 'Whether or not the value of a field has to be serialized.'
|
20
|
+
allow_markup : 'Whether or not markup, such as Markdown, can be used. '
|
21
|
+
|
22
|
+
messages:
|
23
|
+
no_field_types: 'No custom field types have been added yet.'
|
24
|
+
|
25
|
+
errors:
|
26
|
+
new : 'The custom field type could not be added.'
|
27
|
+
save : 'The custom field type could not be modified.'
|
28
|
+
delete : 'The custom field type with ID #%s could not be removed.'
|
29
|
+
no_delete : 'You need to specify at least one custom field type to remove.'
|
30
|
+
invalid_type: 'The specified custom field type is invalid.'
|
31
|
+
|
32
|
+
success:
|
33
|
+
new : 'The custom field type has been added.'
|
34
|
+
save : 'The custom field type has been modified.'
|
35
|
+
delete: 'All selected custom field types have been removed.'
|
36
|
+
|
37
|
+
buttons:
|
38
|
+
new : 'Add field type'
|
39
|
+
delete: 'Delete selected field types'
|
40
|
+
save : 'Save field type'
|
@@ -1,35 +1,36 @@
|
|
1
1
|
---
|
2
2
|
titles:
|
3
|
-
index
|
4
|
-
edit
|
5
|
-
new
|
3
|
+
index: 'Custom Fields'
|
4
|
+
edit : 'Edit Custom Field'
|
5
|
+
new : 'Add Custom Field'
|
6
6
|
|
7
7
|
labels:
|
8
|
-
id
|
9
|
-
name
|
10
|
-
slug
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
id : '#'
|
9
|
+
name : 'Name'
|
10
|
+
slug : 'Slug'
|
11
|
+
format : 'Format'
|
12
|
+
description : 'Description'
|
13
|
+
possible_values : 'Possible values (one value per line)'
|
14
|
+
required : 'Requires a value'
|
15
|
+
text_editor : 'Enable a text editor'
|
16
|
+
textarea_rows : 'Textarea rows'
|
17
|
+
text_limit : 'Character limit'
|
18
|
+
sort_order : 'Sort order'
|
19
|
+
custom_field_type_id: 'Field type'
|
20
20
|
|
21
21
|
tabs:
|
22
|
-
general
|
23
|
-
settings
|
22
|
+
general : 'General'
|
23
|
+
settings: 'Settings'
|
24
24
|
|
25
25
|
messages:
|
26
|
-
no_fields
|
26
|
+
no_fields: 'No custom fields have been added yet.'
|
27
27
|
|
28
28
|
errors:
|
29
|
-
new
|
30
|
-
save
|
31
|
-
delete
|
32
|
-
no_delete
|
29
|
+
new : 'Failed to create a new custom field.'
|
30
|
+
save : 'Failed to modify the custom field.'
|
31
|
+
delete : 'Failed to delete the custom field with ID #%s.'
|
32
|
+
no_delete : "You haven't specified any custom fields to delete."
|
33
|
+
invalid_field: 'The specified custom field is invalid.'
|
33
34
|
|
34
35
|
success:
|
35
36
|
new : 'The new custom field has been created.'
|
@@ -38,15 +39,16 @@ success:
|
|
38
39
|
|
39
40
|
special:
|
40
41
|
type_hash:
|
41
|
-
textbox
|
42
|
-
textarea
|
43
|
-
radio
|
44
|
-
checkbox
|
45
|
-
date
|
46
|
-
select
|
47
|
-
select_multiple
|
42
|
+
textbox : 'Textbox'
|
43
|
+
textarea : 'Textarea'
|
44
|
+
radio : 'Radio button'
|
45
|
+
checkbox : 'Checkbox'
|
46
|
+
date : 'Date'
|
47
|
+
select : 'Select dropdown'
|
48
|
+
select_multiple: 'Multi select'
|
49
|
+
password : 'Password'
|
48
50
|
|
49
51
|
buttons:
|
50
|
-
new
|
51
|
-
delete
|
52
|
-
save
|
52
|
+
new : 'Add custom field'
|
53
|
+
delete: 'Delete selected fields'
|
54
|
+
save : 'Save custom field'
|
@@ -21,10 +21,11 @@ success:
|
|
21
21
|
delete: 'De veld groep is verwijderd.'
|
22
22
|
|
23
23
|
errors:
|
24
|
-
new
|
25
|
-
save
|
26
|
-
delete
|
27
|
-
no_delete: 'U moet ten minste 1 groep specificeren om te verwijderen.'
|
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
|
+
invalid_group: 'De opgegeven veld groep is ongeldig.'
|
28
29
|
|
29
30
|
buttons:
|
30
31
|
new : 'Groep aanmaken'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
titles:
|
3
|
+
index: 'Veld types'
|
4
|
+
edit : 'Veld type aanpassen'
|
5
|
+
new : 'Veld type toevoegen'
|
6
|
+
|
7
|
+
labels:
|
8
|
+
id : '#'
|
9
|
+
name : 'Naam'
|
10
|
+
language_string : 'Vertaal naam'
|
11
|
+
html_class : 'CSS klasse'
|
12
|
+
serialize : 'Serialiseren'
|
13
|
+
allow_markup : 'Opmaak toegestaan'
|
14
|
+
custom_field_method_id: 'Veld methode'
|
15
|
+
|
16
|
+
placeholders:
|
17
|
+
language_string: 'De volledige naam van de vertaling voor dit veld.'
|
18
|
+
html_class : 'Een set aan HTML klasses voor alle velden van dit type.'
|
19
|
+
serialize : 'De waarde wel of niet serialiseren.'
|
20
|
+
allow_markup : 'Opmaak toegestaan of niet.'
|
21
|
+
|
22
|
+
messages:
|
23
|
+
no_field_types: 'Er zijn nog geen veld types aangemaakt.'
|
24
|
+
|
25
|
+
errors:
|
26
|
+
new : 'Het veld type kon niet worden aangemaakt.'
|
27
|
+
save : 'Het veld type kon niet worden aangepast.'
|
28
|
+
delete : 'Het veld type met ID #%s kon niet worden verwijderd.'
|
29
|
+
no_delete : 'U moet ten minste 1 veld type specificeren om te verwijderen.'
|
30
|
+
invalid_type: 'Het opgegeven veld type is ongeldig.'
|
31
|
+
|
32
|
+
success:
|
33
|
+
new : 'Het veld type is aangemaakt.'
|
34
|
+
save : 'Het veld type is aangepast.'
|
35
|
+
delete: 'Alle geselecteerde veld types zijn verwijderd.'
|
36
|
+
|
37
|
+
buttons:
|
38
|
+
new : 'Veld type toevoegen'
|
39
|
+
delete: 'Geselecteerde types verwijderen'
|
40
|
+
save : 'Veld type opslaan'
|
@@ -5,18 +5,18 @@ titles:
|
|
5
5
|
new : 'Veld aanmaken'
|
6
6
|
|
7
7
|
labels:
|
8
|
-
id
|
9
|
-
name
|
10
|
-
slug
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
id : '#'
|
9
|
+
name : 'Naam'
|
10
|
+
slug : 'Slug'
|
11
|
+
format : 'Formaat'
|
12
|
+
description : 'Beschrijving'
|
13
|
+
possible_values : 'Mogelijke waardes (een per regel)'
|
14
|
+
required : 'Vereist een waarde'
|
15
|
+
text_editor : 'Text verwerker'
|
16
|
+
textarea_rows : 'Text veld rijen'
|
17
|
+
text_limit : 'Karakter limiet'
|
18
|
+
sort_order : 'Sorteer volgorde'
|
19
|
+
custom_field_type_id: 'Veld type'
|
20
20
|
|
21
21
|
tabs:
|
22
22
|
general : 'Algemeen'
|
@@ -31,10 +31,11 @@ success:
|
|
31
31
|
delete: 'Alle geselecteerde velden zijn verwijderd.'
|
32
32
|
|
33
33
|
errors:
|
34
|
-
new
|
35
|
-
save
|
36
|
-
delete
|
37
|
-
no_delete: 'U moet ten minste 1 veld specificeren om te verwijderen.'
|
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
|
+
invalid_field: 'Het opgegeven veld is ongeldig.'
|
38
39
|
|
39
40
|
special:
|
40
41
|
type_hash:
|
@@ -45,6 +46,7 @@ special:
|
|
45
46
|
date : 'Datum'
|
46
47
|
select : 'Lijst (enkele waarde)'
|
47
48
|
select_multiple: 'Lijst (meerdere waardes)'
|
49
|
+
password : 'Wachtwoord'
|
48
50
|
|
49
51
|
buttons:
|
50
52
|
new : 'Veld toevoegen'
|
@@ -20,26 +20,46 @@ module CustomFields
|
|
20
20
|
#
|
21
21
|
class CustomField < Sequel::Model
|
22
22
|
one_to_many(
|
23
|
-
:custom_field_values,
|
23
|
+
:custom_field_values,
|
24
24
|
:class => "CustomFields::Model::CustomFieldValue"
|
25
25
|
)
|
26
|
-
|
26
|
+
|
27
|
+
many_to_one(
|
28
|
+
:custom_field_type,
|
29
|
+
:class => 'CustomFields::Model::CustomFieldType',
|
30
|
+
:eager => :custom_field_method
|
31
|
+
)
|
32
|
+
|
27
33
|
plugin :sluggable, :source => :name, :freeze => false
|
28
|
-
|
34
|
+
|
29
35
|
##
|
30
36
|
# Validates rules used whenever the model is created or saved.
|
31
37
|
#
|
32
38
|
# @author Yorick Peterse
|
33
39
|
# @since 0.1
|
34
|
-
#
|
40
|
+
#
|
35
41
|
def validate
|
36
|
-
validates_presence
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
validates_presence([
|
43
|
+
:name,
|
44
|
+
:format,
|
45
|
+
:custom_field_group_id,
|
46
|
+
:custom_field_type_id
|
47
|
+
])
|
48
|
+
|
49
|
+
validates_max_length(255, [:name])
|
50
|
+
|
51
|
+
validates_type(TrueClass, [:required, :text_editor])
|
52
|
+
|
53
|
+
validates_integer([
|
54
|
+
:sort_order,
|
55
|
+
:textarea_rows,
|
56
|
+
:text_limit,
|
57
|
+
:custom_field_group_id,
|
58
|
+
:custom_field_type_id
|
59
|
+
])
|
60
|
+
|
61
|
+
validates_presence(:slug) unless new?
|
62
|
+
validates_unique(:slug)
|
43
63
|
end
|
44
64
|
end # CustomField
|
45
65
|
end # Model
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#:nodoc:
|
2
|
+
module CustomFields
|
3
|
+
#:nodoc:
|
4
|
+
module Model
|
5
|
+
##
|
6
|
+
# Model for managing custom field methods.
|
7
|
+
#
|
8
|
+
# @author Yorick Peterse
|
9
|
+
# @since 0.2.8
|
10
|
+
#
|
11
|
+
class CustomFieldMethod < Sequel::Model
|
12
|
+
|
13
|
+
end # CustomFieldType
|
14
|
+
end # Model
|
15
|
+
end # CustomFields
|