drg_cms 0.7.0.2 → 0.7.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/drg_cms/drg_cms.js +63 -18
- data/app/assets/javascripts/drg_cms/jquery.bpopup.js +372 -0
- data/app/assets/javascripts/drg_cms_application.js +1 -1
- data/app/assets/javascripts/drg_cms_cms.js +1 -1
- data/app/assets/stylesheets/drg_cms/drg_cms.css +37 -5
- data/app/assets/stylesheets/drg_cms/select-multiple.css +2 -2
- data/app/controllers/cmsedit_controller.rb +22 -24
- data/app/controllers/dc_application_controller.rb +8 -8
- data/app/controllers/dc_common_controller.rb +9 -6
- data/app/controllers/dc_main_controller.rb +0 -1
- data/app/controls/{dc_category_control.rb → dc_gallery_control.rb} +15 -30
- data/app/controls/dc_image_control.rb +180 -0
- data/app/controls/dc_page_control.rb +3 -3
- data/app/controls/dc_poll_result_control.rb +7 -8
- data/app/controls/dc_report.rb +9 -4
- data/app/controls/design_element_settings_control.rb +88 -37
- data/app/forms/all_options.yml +18 -7
- data/app/forms/cms_menu.yml +7 -2
- data/app/forms/dc_gallery.yml +1 -1
- data/app/forms/dc_image.yml +122 -0
- data/app/forms/dc_image_search.yml +72 -0
- data/app/forms/dc_page.yml +11 -8
- data/app/forms/dc_steps_template.yml +2 -1
- data/app/helpers/cms_common_helper.rb +24 -16
- data/app/helpers/cms_edit_helper.rb +26 -33
- data/app/helpers/cms_helper.rb +21 -5
- data/app/helpers/cms_index_helper.rb +53 -38
- data/app/helpers/dc_application_helper.rb +64 -72
- data/app/helpers/dc_image_helper.rb +127 -0
- data/app/models/concerns/dc_policy_rule_concern.rb +1 -1
- data/app/models/concerns/dc_user_concern.rb +12 -4
- data/app/models/dc_category.rb +12 -0
- data/app/models/dc_design.rb +5 -4
- data/app/models/dc_filter.rb +19 -18
- data/app/models/dc_image.rb +237 -0
- data/app/models/dc_internals.rb +5 -9
- data/app/models/dc_policy_role.rb +8 -8
- data/app/models/drgcms_form_fields/drgcms_field.rb +9 -26
- data/app/models/drgcms_form_fields/embedded.rb +11 -8
- data/app/models/drgcms_form_fields/journal_diff.rb +2 -2
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +51 -47
- data/app/models/drgcms_form_fields/select.rb +20 -14
- data/app/models/drgcms_form_fields/text_with_select.rb +5 -9
- data/app/renderers/dc_gallery_renderer.rb +10 -4
- data/app/renderers/dc_page_renderer.rb +7 -7
- data/app/renderers/dc_poll_renderer.rb +13 -12
- data/app/views/cmsedit/_edit_stuff.html.erb +1 -1
- data/app/views/cmsedit/edit.html.erb +1 -1
- data/app/views/cmsedit/index.html.erb +1 -1
- data/app/views/cmsedit/new.html.erb +1 -0
- data/config/locales/drgcms_en.yml +14 -2
- data/config/locales/drgcms_sl.yml +13 -2
- data/config/locales/models_en.yml +33 -0
- data/config/locales/models_sl.yml +44 -1
- data/drg_cms.gemspec +1 -1
- data/lib/drg_cms/version.rb +1 -1
- data/lib/drg_cms.rb +19 -5
- data/lib/generators/convert_to_ar/USAGE +8 -0
- data/lib/generators/convert_to_ar/convert_to_ar_generator.rb +158 -0
- metadata +16 -10
- data/app/assets/javascripts/drg_cms/jquery.bpopup.min.js +0 -7
- data/app/views/layouts/__cmsedit.html.erb +0 -16
@@ -1,4 +1,3 @@
|
|
1
|
-
#encoding: utf-8
|
2
1
|
#--
|
3
2
|
# Copyright (c) 2014+ Damjan Rems
|
4
3
|
#
|
@@ -23,7 +22,7 @@
|
|
23
22
|
#++
|
24
23
|
|
25
24
|
######################################################################
|
26
|
-
#
|
25
|
+
# DRG Controls for editing settings in a document.
|
27
26
|
#
|
28
27
|
# Parameters to settings call:
|
29
28
|
# :location - model_name where settings document is located. Typicaly dc_page or dc_site.
|
@@ -40,33 +39,36 @@ module DesignElementSettingsControl
|
|
40
39
|
# Return:
|
41
40
|
# [document, data] : Mongoid document, yaml as String
|
42
41
|
######################################################################
|
43
|
-
def get_settings
|
44
|
-
# On save. Set required variables
|
42
|
+
def get_settings
|
43
|
+
# On save. Set required variables
|
45
44
|
if params[:record]
|
46
45
|
params[:location] = params[:record][:dc_location]
|
47
46
|
params[:field_name] = params[:record][:dc_field_name]
|
48
47
|
params[:element] = params[:record][:dc_element]
|
49
48
|
params[:id] = params[:record][:dc_document_id]
|
50
49
|
end
|
51
|
-
|
50
|
+
|
51
|
+
# Check model
|
52
52
|
begin
|
53
53
|
model = params[:location].classify.constantize
|
54
54
|
rescue
|
55
55
|
flash[:error] = "Invalid or undefined model name! #{params[:location]}"
|
56
56
|
return false
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
|
+
# Check fild name
|
59
60
|
begin
|
60
61
|
document = model.find(params[:id])
|
61
62
|
params[:field_name] ||= (params[:location] == 'dc_site' ? 'settings' : 'params')
|
62
|
-
# field not defined on document
|
63
|
+
# field not defined on document
|
63
64
|
raise unless document.respond_to?(params[:field_name])
|
64
65
|
yaml = document[params[:field_name]] || ''
|
65
66
|
rescue
|
66
67
|
flash[:error] = 'Invalid or undefined field name!'
|
67
68
|
return false
|
68
69
|
end
|
69
|
-
|
70
|
+
|
71
|
+
# Check data
|
70
72
|
begin
|
71
73
|
data = YAML.load(yaml) || {}
|
72
74
|
rescue
|
@@ -81,14 +83,12 @@ end
|
|
81
83
|
#
|
82
84
|
# Load fields on form with values from settings document.
|
83
85
|
######################################################################
|
84
|
-
def dc_new_record
|
86
|
+
def dc_new_record
|
85
87
|
document, data = get_settings
|
86
|
-
return false if document.class == FalseClass
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
91
|
-
# add some fields required at post as hidden fields to form
|
88
|
+
return false if document.class == FalseClass
|
89
|
+
|
90
|
+
record_fill_with_values(data)
|
91
|
+
# add some fields required at post as hidden fields to form
|
92
92
|
form = @form['form']['tabs'] ? @form['form']['tabs'].to_a.last : @form['form']['fields']
|
93
93
|
form[9999] = {'type' => 'hidden_field', 'name' => 'dc_location', 'html' => {'value' => params[:location]}}
|
94
94
|
form[9998] = {'type' => 'hidden_field', 'name' => 'dc_field_name'}
|
@@ -96,7 +96,6 @@ def dc_new_record()
|
|
96
96
|
form[9997] = {'type' => 'hidden_field', 'name' => 'dc_element'}
|
97
97
|
@record.dc_element = params[:element]
|
98
98
|
form[9996] = {'type' => 'hidden_field', 'name' => 'dc_document_id', 'html' => {'value' => params[:id]}}
|
99
|
-
true
|
100
99
|
end
|
101
100
|
|
102
101
|
######################################################################
|
@@ -104,32 +103,84 @@ end
|
|
104
103
|
#
|
105
104
|
# Convert data from fields on form to yaml and save it to document settings field.
|
106
105
|
######################################################################
|
107
|
-
def dc_before_save
|
106
|
+
def dc_before_save
|
108
107
|
document, data = get_settings
|
109
|
-
return false if document.class == FalseClass
|
110
|
-
|
111
|
-
|
112
|
-
session[:form_processing] = v['name'] # for debuging
|
113
|
-
next if v['type'].nil? or
|
114
|
-
v['readonly'] # fields with readonly option don't return value and would be wiped
|
115
|
-
# return value from form field definition
|
116
|
-
value = DrgcmsFormFields.const_get(v['type'].camelize).get_data(params, v['name'])
|
117
|
-
value = value.map {|e| e.to_s} if value.class == Array
|
118
|
-
# set to nil if blank
|
119
|
-
value = nil if value.blank?
|
120
|
-
data['settings'] ||= {}
|
121
|
-
data['settings'][ params[:element] ] ||= {}
|
122
|
-
data['settings'][ params[:element] ][ v['name'] ] = value
|
123
|
-
end
|
124
|
-
# remove nil elements
|
125
|
-
data['settings'][ params[:element] ].compact!
|
126
|
-
# save data to document field
|
108
|
+
return false if document.class == FalseClass
|
109
|
+
|
110
|
+
field_fill_with_values(data)
|
127
111
|
document.send("#{params[:field_name]}=", data.to_yaml)
|
112
|
+
# save to journal
|
113
|
+
params[:table] = params[:location] # for journal
|
114
|
+
save_journal(:update, document.changes)
|
128
115
|
document.save
|
129
|
-
|
116
|
+
params[:table] = 'dc_memory' # restore
|
117
|
+
# to re-set form again
|
130
118
|
dc_new_record
|
131
119
|
false # must be
|
132
120
|
end
|
133
121
|
|
122
|
+
private
|
134
123
|
|
135
|
-
|
124
|
+
######################################################################
|
125
|
+
# Fill @record with values found in document hash field
|
126
|
+
######################################################################
|
127
|
+
def record_fill_with_values(data)
|
128
|
+
# settings
|
129
|
+
if params[:element]
|
130
|
+
if data['settings'] && data['settings'][params[:element]]
|
131
|
+
data['settings'][params[:element]].each { |key, value| @record.send("#{key}=", value) }
|
132
|
+
end
|
133
|
+
else
|
134
|
+
# any field
|
135
|
+
fields_on_form.each do |field|
|
136
|
+
keys = field['key'] ? field['key'].split(/\.|\,|\;/) : [field['name']]
|
137
|
+
value = data.dig(*keys)
|
138
|
+
@record.send("#{field['name']}=", value)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
######################################################################
|
144
|
+
# Fill field with values entered on a form
|
145
|
+
######################################################################
|
146
|
+
def field_fill_with_values(data)
|
147
|
+
fields_on_form.each do |field|
|
148
|
+
session[:form_processing] = field['name'] # for debuging
|
149
|
+
next if field['type'].nil? || field['readonly']
|
150
|
+
|
151
|
+
# return value from form field definition
|
152
|
+
value = DrgcmsFormFields.const_get(field['type'].camelize).get_data(params, field['name'])
|
153
|
+
value = value.map(&:to_s) if value.class == Array
|
154
|
+
# set to nil if blank
|
155
|
+
value = nil if value.blank?
|
156
|
+
|
157
|
+
keys = field['key'] ? field['key'].split(/\.|\,|\;/) : [field['name']]
|
158
|
+
if params[:element].present?
|
159
|
+
keys = ['settings', params[:element]] + keys
|
160
|
+
end
|
161
|
+
|
162
|
+
h = data
|
163
|
+
if value.blank?
|
164
|
+
# remove field from hash if empty
|
165
|
+
keys.each_with_index do |key, i|
|
166
|
+
if i + 1 == keys.size
|
167
|
+
h.delete(keys.last) if h
|
168
|
+
else
|
169
|
+
h = h[key]
|
170
|
+
end
|
171
|
+
break if h.nil?
|
172
|
+
end
|
173
|
+
# set hash element
|
174
|
+
else
|
175
|
+
keys.each_with_index do |key, i|
|
176
|
+
break if i + 1 == keys.size
|
177
|
+
|
178
|
+
h[key] = {} unless h.key?(key)
|
179
|
+
h = h[key]
|
180
|
+
end
|
181
|
+
h[keys.last] = value
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
data/app/forms/all_options.yml
CHANGED
@@ -10,6 +10,7 @@ controls: controls_file
|
|
10
10
|
readonly: 1
|
11
11
|
permissions:
|
12
12
|
can_view: role_name
|
13
|
+
class: angular-like
|
13
14
|
|
14
15
|
script: "
|
15
16
|
javascript code
|
@@ -129,13 +130,16 @@ result_set:
|
|
129
130
|
eval: dc_name4_value
|
130
131
|
|
131
132
|
form:
|
132
|
-
title:
|
133
|
-
|
134
|
-
|
133
|
+
title: Title text
|
134
|
+
title:
|
135
|
+
field: field_name
|
135
136
|
title:
|
136
|
-
edit: Title for edit
|
137
|
-
show: Title for show
|
138
|
-
|
137
|
+
edit: Title text for edit
|
138
|
+
show: Title text for show
|
139
|
+
|
140
|
+
height: 600
|
141
|
+
labels_pos: top
|
142
|
+
multipart: true
|
139
143
|
|
140
144
|
actions: standard
|
141
145
|
actions: none
|
@@ -214,6 +218,7 @@ form:
|
|
214
218
|
eval: "dc_choices4('model','description_field_name','_id',site: :with_nil)"
|
215
219
|
eval: ModelName.choices4_site
|
216
220
|
eval: dc_big_table 'key-name'
|
221
|
+
depend: field_on_form,another_field_on_form,and_so_on
|
217
222
|
html:
|
218
223
|
include_blank: true
|
219
224
|
90:
|
@@ -274,12 +279,18 @@ form:
|
|
274
279
|
html:
|
275
280
|
height: 800
|
276
281
|
20:
|
277
|
-
name:
|
282
|
+
name: time
|
278
283
|
type: datetime_picker
|
284
|
+
step: 15
|
285
|
+
inline: true
|
279
286
|
20:
|
280
287
|
name: gender
|
281
288
|
type: radio
|
282
289
|
inline: true
|
290
|
+
30:
|
291
|
+
name: galery
|
292
|
+
type: method
|
293
|
+
eval: show_gallery
|
283
294
|
|
284
295
|
40:
|
285
296
|
name: customer_id
|
data/app/forms/cms_menu.yml
CHANGED
@@ -37,12 +37,17 @@ menu:
|
|
37
37
|
controller: cmsedit
|
38
38
|
icon: web
|
39
39
|
table: dc_design
|
40
|
-
30:
|
40
|
+
30:
|
41
41
|
caption: helpers.label.dc_page.tabletitle
|
42
42
|
controller: cmsedit
|
43
43
|
icon: description-o
|
44
44
|
table: dc_page
|
45
|
-
|
45
|
+
40:
|
46
|
+
caption: helpers.label.dc_image.tabletitle
|
47
|
+
controller: cmsedit
|
48
|
+
icon: image-o
|
49
|
+
table: dc_image
|
50
|
+
50:
|
46
51
|
caption: helpers.label.dc_piece.tabletitle
|
47
52
|
controller: cmsedit
|
48
53
|
icon: extension-o
|
data/app/forms/dc_gallery.yml
CHANGED
@@ -0,0 +1,122 @@
|
|
1
|
+
# Form for dc_image
|
2
|
+
table: dc_image
|
3
|
+
|
4
|
+
index:
|
5
|
+
actions: standard
|
6
|
+
|
7
|
+
result_set:
|
8
|
+
actions: standard
|
9
|
+
|
10
|
+
# Choose from
|
11
|
+
# _id,created_at,updated_at,name,text,size_l,size_m,size_s,categories,created_by,dc_user_id
|
12
|
+
columns:
|
13
|
+
10:
|
14
|
+
name: short
|
15
|
+
width: 20%
|
16
|
+
20:
|
17
|
+
name: created_by
|
18
|
+
eval: dc_name4_id,dc_user,name
|
19
|
+
30:
|
20
|
+
name: created_at
|
21
|
+
format: '%d.%m.%Y'
|
22
|
+
40:
|
23
|
+
name: categories_line
|
24
|
+
width: 40%
|
25
|
+
|
26
|
+
form:
|
27
|
+
actions: standard
|
28
|
+
multipart: true
|
29
|
+
|
30
|
+
fields:
|
31
|
+
10:
|
32
|
+
name: upload_file
|
33
|
+
type: file_field
|
34
|
+
group: 2
|
35
|
+
20:
|
36
|
+
name: image
|
37
|
+
type: method
|
38
|
+
caption: ' '
|
39
|
+
eval: dc_image_preview
|
40
|
+
30:
|
41
|
+
name: short
|
42
|
+
type: text_field
|
43
|
+
size: 50
|
44
|
+
40:
|
45
|
+
name: text
|
46
|
+
type: text_area
|
47
|
+
size: 80x5
|
48
|
+
50:
|
49
|
+
name: cats_input
|
50
|
+
type: text_area
|
51
|
+
size: 50x5
|
52
|
+
line: bottom
|
53
|
+
60:
|
54
|
+
name: keep_original
|
55
|
+
type: check_box
|
56
|
+
70:
|
57
|
+
name: size_o
|
58
|
+
type: readonly
|
59
|
+
|
60
|
+
100:
|
61
|
+
name: size_ls
|
62
|
+
type: text_with_select
|
63
|
+
eval: dc_image_choices_for_image_size
|
64
|
+
size: 8
|
65
|
+
group: 3
|
66
|
+
110:
|
67
|
+
name: size_ms
|
68
|
+
type: text_with_select
|
69
|
+
eval: dc_image_choices_for_image_size
|
70
|
+
size: 8
|
71
|
+
120:
|
72
|
+
name: size_ss
|
73
|
+
type: text_with_select
|
74
|
+
eval: dc_image_choices_for_image_size
|
75
|
+
size: 8
|
76
|
+
210:
|
77
|
+
name: offset_lx
|
78
|
+
type: text_field
|
79
|
+
help: helpers.help.dc_image.offset
|
80
|
+
size: 3
|
81
|
+
group: 3
|
82
|
+
220:
|
83
|
+
name: offset_mx
|
84
|
+
type: text_field
|
85
|
+
help: helpers.help.dc_image.offset
|
86
|
+
size: 3
|
87
|
+
230:
|
88
|
+
name: offset_sx
|
89
|
+
type: text_field
|
90
|
+
help: helpers.help.dc_image.offset
|
91
|
+
size: 3
|
92
|
+
|
93
|
+
310:
|
94
|
+
name: offset_ly
|
95
|
+
type: text_field
|
96
|
+
help: helpers.help.dc_image.offset
|
97
|
+
size: 3
|
98
|
+
group: 3
|
99
|
+
320:
|
100
|
+
name: offset_my
|
101
|
+
type: text_field
|
102
|
+
help: helpers.help.dc_image.offset
|
103
|
+
size: 3
|
104
|
+
330:
|
105
|
+
name: offset_sy
|
106
|
+
type: text_field
|
107
|
+
help: helpers.help.dc_image.offset
|
108
|
+
size: 3
|
109
|
+
|
110
|
+
410:
|
111
|
+
name: preview_l
|
112
|
+
type: method
|
113
|
+
group: 3
|
114
|
+
eval: dc_image_preview_resized
|
115
|
+
420:
|
116
|
+
name: preview_m
|
117
|
+
type: method
|
118
|
+
eval: dc_image_preview_resized
|
119
|
+
430:
|
120
|
+
name: preview_s
|
121
|
+
type: method
|
122
|
+
eval: dc_image_preview_resized
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Form for dc_image search
|
2
|
+
table: dc_image
|
3
|
+
title: drgcms.dc_image.search
|
4
|
+
|
5
|
+
index:
|
6
|
+
actions:
|
7
|
+
1: close
|
8
|
+
2:
|
9
|
+
type: window
|
10
|
+
action: new
|
11
|
+
icon: plus
|
12
|
+
caption: drgcms.new
|
13
|
+
table: dc_image
|
14
|
+
params:
|
15
|
+
window_close: 0
|
16
|
+
3:
|
17
|
+
type: ajax
|
18
|
+
action: run
|
19
|
+
icon: search
|
20
|
+
caption: drgcms.search
|
21
|
+
method: post
|
22
|
+
control: dc_image.images_search
|
23
|
+
params:
|
24
|
+
field_name:
|
25
|
+
object: params
|
26
|
+
method: field_name
|
27
|
+
|
28
|
+
10:
|
29
|
+
type: field
|
30
|
+
name: short
|
31
|
+
field_type: text_field
|
32
|
+
size: 20
|
33
|
+
|
34
|
+
20:
|
35
|
+
type: field
|
36
|
+
name: categories
|
37
|
+
field_type: text_field
|
38
|
+
size: 40
|
39
|
+
|
40
|
+
30:
|
41
|
+
type: field
|
42
|
+
caption: user
|
43
|
+
name: created_by
|
44
|
+
field_type: select
|
45
|
+
eval: DcImage.all_users
|
46
|
+
html:
|
47
|
+
include_blank: true
|
48
|
+
|
49
|
+
result_set:
|
50
|
+
filter: search_filter
|
51
|
+
actions: false
|
52
|
+
|
53
|
+
# Choose from
|
54
|
+
# _id,created_at,updated_at,name,text,size_l,size_m,size_s,categories,created_by,dc_user_id
|
55
|
+
columns:
|
56
|
+
10:
|
57
|
+
name: preview
|
58
|
+
eval: dc_image_first
|
59
|
+
caption: drgcms.dc_image.image
|
60
|
+
width: 20%
|
61
|
+
20:
|
62
|
+
name: short
|
63
|
+
30:
|
64
|
+
name: links
|
65
|
+
eval: dc_image_select_links
|
66
|
+
caption: drgcms.dc_image.available
|
67
|
+
|
68
|
+
css: "
|
69
|
+
.img-link {padding: 2px 4px; margin-right: 1rem; background-color: #ddd; border-bottom: 3px solid #222;}
|
70
|
+
.dc-image-preview img {max-height: 3rem;}
|
71
|
+
.img-link i:hover {color: #2C8EFF; cursor: pointer;}
|
72
|
+
"
|
data/app/forms/dc_page.yml
CHANGED
@@ -58,7 +58,8 @@ form:
|
|
58
58
|
|
59
59
|
70:
|
60
60
|
name: publish_date
|
61
|
-
type:
|
61
|
+
type: datetime_picker
|
62
|
+
step: 15
|
62
63
|
|
63
64
|
80:
|
64
65
|
name: picture
|
@@ -69,14 +70,14 @@ form:
|
|
69
70
|
type: check_box
|
70
71
|
100:
|
71
72
|
name: valid_from
|
72
|
-
type:
|
73
|
-
|
74
|
-
|
73
|
+
type: datetime_picker
|
74
|
+
step: 15
|
75
|
+
|
75
76
|
110:
|
76
77
|
name: valid_to
|
77
|
-
type:
|
78
|
-
|
79
|
-
|
78
|
+
type: datetime_picker
|
79
|
+
step: 15
|
80
|
+
|
80
81
|
# 120:
|
81
82
|
# name: kats
|
82
83
|
# type: select
|
@@ -96,7 +97,9 @@ form:
|
|
96
97
|
10:
|
97
98
|
name: dc_design_id
|
98
99
|
type: select
|
99
|
-
eval: DcDesign.choices4_design(@parent.dc_get_site)
|
100
|
+
# eval: DcDesign.choices4_design(@parent.dc_get_site)
|
101
|
+
eval: DcDesign.choices4_design
|
102
|
+
depend: dc_site_id
|
100
103
|
html:
|
101
104
|
include_blank: true
|
102
105
|
15:
|
@@ -44,20 +44,20 @@ module CmsCommonHelper
|
|
44
44
|
# Returns:
|
45
45
|
# String. Translated text.
|
46
46
|
####################################################################
|
47
|
-
def self.t(key, default=nil)
|
47
|
+
def self.t(key, default = nil)
|
48
48
|
c = I18n.t(key)
|
49
|
-
if c.class == Hash
|
49
|
+
if c.class == Hash || c.match( /translation missing/i )
|
50
50
|
c = I18n.t(key, locale: 'en')
|
51
|
-
# Still not found
|
52
|
-
if c.class == Hash
|
53
|
-
c = default
|
51
|
+
# Still not found, return default
|
52
|
+
if c.class == Hash || c.match( /translation missing/i )
|
53
|
+
c = default || key
|
54
54
|
end
|
55
55
|
end
|
56
56
|
c
|
57
57
|
end
|
58
58
|
|
59
59
|
####################################################################
|
60
|
-
def t(key, default=nil) #:nodoc
|
60
|
+
def t(key, default = nil) #:nodoc
|
61
61
|
CmsCommonHelper.t(key, default)
|
62
62
|
end
|
63
63
|
|
@@ -72,7 +72,7 @@ end
|
|
72
72
|
# Returns:
|
73
73
|
# String. Translated text.
|
74
74
|
####################################################################
|
75
|
-
def t_tablename(tablename, default=nil)
|
75
|
+
def t_tablename(tablename, default = nil)
|
76
76
|
t('helpers.label.' + tablename + '.tabletitle', default || tablename)
|
77
77
|
end
|
78
78
|
|
@@ -81,21 +81,29 @@ end
|
|
81
81
|
# Translation is provided by lang.helpers.label.table_name.field_name locale. If
|
82
82
|
# translation is not found method will capitalize field_name and replace '_' with ' '.
|
83
83
|
############################################################################
|
84
|
-
def t_label_for_field(field_name, default='')
|
85
|
-
c =
|
86
|
-
c = field_name
|
87
|
-
|
84
|
+
def t_label_for_field(field_name, default = '')
|
85
|
+
c = (@form['i18n_prefix'] || "helpers.label.#{@form['table']}") + ".#{field_name}"
|
86
|
+
c = field_name if field_name.match(/helpers\./)
|
87
|
+
|
88
|
+
label = t(c, default)
|
89
|
+
label = field_name.capitalize.gsub('_', ' ') if c.match( /translation missing/i )
|
90
|
+
label
|
88
91
|
end
|
89
92
|
|
90
93
|
############################################################################
|
91
|
-
# Returns label for field translated to current locale for usage browser header.
|
94
|
+
# Returns label for field translated to current locale for usage in browser header.
|
92
95
|
# Translation is provided by lang.helpers.label.table_name.field_name locale. If
|
93
96
|
# not found method will look in standard drgcms translations.
|
94
|
-
#
|
95
97
|
############################################################################
|
96
98
|
def t_label_for_column(options)
|
97
99
|
label = options['caption'] || options['label']
|
98
|
-
|
100
|
+
if label.blank?
|
101
|
+
label = if options['name']
|
102
|
+
prefix = @form['i18n_prefix'] || "helpers.label.#{@form['table']}"
|
103
|
+
"#{prefix}.#{options['name']}"
|
104
|
+
end
|
105
|
+
label = label.to_s
|
106
|
+
end
|
99
107
|
label = t(label) if label.match(/\./)
|
100
108
|
label = t("drgcms.#{options['name']}") if label.match('helpers.') # standard field names like created_by, updated_at
|
101
109
|
label
|
@@ -161,8 +169,8 @@ end
|
|
161
169
|
############################################################################
|
162
170
|
def self.dc_choices_for_field(model, field)
|
163
171
|
c = CmsCommonHelper.t('helpers.label.' + model + '.choices4_' + field )
|
164
|
-
return ['error'] if c.match(
|
165
|
-
c.chomp.split(',').inject([]) {|r,v| r << v.split(':') }
|
172
|
+
return ['error'] if c.match( /translation missing/i )
|
173
|
+
c.chomp.split(',').inject([]) { |r, v| r << v.split(':') }
|
166
174
|
end
|
167
175
|
|
168
176
|
############################################################################
|