drg_cms 0.5.52.12 → 0.5.52.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/app/assets/javascripts/drg_cms/drg_cms.js +17 -2
- data/app/assets/stylesheets/drg_cms/drg_cms.css +16 -3
- data/app/assets/stylesheets/drg_cms/select-multiple.css +1 -1
- data/app/controllers/cmsedit_controller.rb +56 -16
- data/app/controllers/dc_application_controller.rb +83 -1
- data/app/controllers/dc_common_controller.rb +2 -52
- data/app/forms/all_options.yml +27 -4
- data/app/forms/cms_menu.yml +5 -0
- data/app/forms/dc_gallery.yml +53 -0
- data/app/forms/dc_link.yml +16 -10
- data/app/forms/dc_menu_item.yml +5 -0
- data/app/forms/dc_page.yml +1 -2
- data/app/forms/dc_removed_url.yml +42 -0
- data/app/helpers/cmsedit_helper.rb +63 -22
- data/app/helpers/dc_application_helper.rb +35 -11
- data/app/helpers/dc_gallery_renderer.rb +94 -0
- data/app/helpers/dc_page_renderer.rb +20 -3
- data/app/helpers/dc_poll_renderer.rb +6 -7
- data/app/models/concerns/dc_page_concern.rb +1 -1
- data/app/models/dc_filter.rb +15 -7
- data/app/models/dc_gallery.rb +64 -0
- data/app/models/dc_link.rb +1 -0
- data/app/models/dc_memory.rb +19 -4
- data/app/models/dc_page.rb +1 -1
- data/app/models/dc_removed_url.rb +54 -0
- data/app/models/drgcms_form_fields.rb +5 -1649
- data/app/models/drgcms_form_fields/check_box.rb +69 -0
- data/app/models/drgcms_form_fields/comment.rb +49 -0
- data/app/models/drgcms_form_fields/date_picker.rb +102 -0
- data/app/models/drgcms_form_fields/date_select.rb +68 -0
- data/app/models/drgcms_form_fields/date_time_picker.rb +87 -0
- data/app/models/drgcms_form_fields/datetime_select.rb +73 -0
- data/app/models/drgcms_form_fields/drgcms_field.rb +241 -0
- data/app/models/drgcms_form_fields/drgcms_form_fields.rb +25 -0
- data/app/models/drgcms_form_fields/embedded.rb +84 -0
- data/app/models/drgcms_form_fields/file_select.rb +70 -0
- data/app/models/drgcms_form_fields/hidden_field.rb +52 -0
- data/app/models/drgcms_form_fields/html_field.rb +70 -0
- data/app/models/drgcms_form_fields/journal_diff.rb +60 -0
- data/app/models/drgcms_form_fields/link_to.rb +69 -0
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +195 -0
- data/app/models/drgcms_form_fields/number_field.rb +83 -0
- data/app/models/drgcms_form_fields/password_field.rb +62 -0
- data/app/models/drgcms_form_fields/readonly.rb +79 -0
- data/app/models/drgcms_form_fields/select.rb +164 -0
- data/app/models/drgcms_form_fields/submit_tag.rb +58 -0
- data/app/models/drgcms_form_fields/text_area.rb +68 -0
- data/app/models/drgcms_form_fields/text_autocomplete.rb +143 -0
- data/app/models/drgcms_form_fields/text_field.rb +56 -0
- data/app/models/drgcms_form_fields/text_with_select.rb +92 -0
- data/app/models/drgcms_form_fields/tree_select.rb +150 -0
- data/config/locales/drgcms_en.yml +1 -0
- data/config/locales/drgcms_sl.yml +2 -1
- data/config/locales/models_en.yml +42 -6
- data/config/locales/models_sl.yml +38 -3
- data/lib/drg_cms.rb +1 -1
- data/lib/drg_cms/version.rb +1 -1
- data/lib/tasks/dc_cleanup.rake +1 -1
- metadata +33 -4
data/app/forms/cms_menu.yml
CHANGED
@@ -118,6 +118,11 @@ menu:
|
|
118
118
|
controller: cmsedit
|
119
119
|
icon: filter lg
|
120
120
|
table: dc_filter
|
121
|
+
90:
|
122
|
+
caption: helpers.label.dc_removed_url.tabletitle
|
123
|
+
controller: cmsedit
|
124
|
+
icon: trash-o lg
|
125
|
+
table: dc_removed_url
|
121
126
|
500:
|
122
127
|
caption: helpers.label.dc_journal.tabletitle
|
123
128
|
controller: cmsedit
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Form for dc_gallery
|
2
|
+
table: dc_gallery
|
3
|
+
index:
|
4
|
+
filter: id as text_field, doc_id as text_field
|
5
|
+
actions: standard
|
6
|
+
|
7
|
+
result_set:
|
8
|
+
actions: standard
|
9
|
+
|
10
|
+
# Choose from
|
11
|
+
# _id,created_at,updated_at,title,description,picture,thumbnail,doc_id,order,active,created_by,updated_by
|
12
|
+
columns:
|
13
|
+
10:
|
14
|
+
name: doc_id
|
15
|
+
20:
|
16
|
+
name: title
|
17
|
+
30:
|
18
|
+
name: created_at
|
19
|
+
width: 10%
|
20
|
+
50:
|
21
|
+
name: active
|
22
|
+
eval: dc_icon4_boolean
|
23
|
+
|
24
|
+
form:
|
25
|
+
actions: standard
|
26
|
+
|
27
|
+
fields:
|
28
|
+
10:
|
29
|
+
name: doc_id
|
30
|
+
type: readonly
|
31
|
+
20:
|
32
|
+
name: title
|
33
|
+
type: text_field
|
34
|
+
size: 50
|
35
|
+
30:
|
36
|
+
name: description
|
37
|
+
type: text_area
|
38
|
+
size: 80x10
|
39
|
+
40:
|
40
|
+
name: picture
|
41
|
+
type: file_select
|
42
|
+
size: 50
|
43
|
+
50:
|
44
|
+
name: thumbnail
|
45
|
+
type: file_select
|
46
|
+
size: 50
|
47
|
+
60:
|
48
|
+
name: order
|
49
|
+
type: text_field
|
50
|
+
size: 3
|
51
|
+
70:
|
52
|
+
name: active
|
53
|
+
type: check_box
|
data/app/forms/dc_link.yml
CHANGED
@@ -14,13 +14,14 @@ result_set:
|
|
14
14
|
3: delete
|
15
15
|
|
16
16
|
columns:
|
17
|
-
|
17
|
+
10:
|
18
18
|
name: name
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
width: 20%
|
20
|
+
20:
|
21
|
+
name: redirect
|
22
|
+
width: 20%
|
23
|
+
30:
|
22
24
|
name: params
|
23
|
-
style: "text-align: left;"
|
24
25
|
|
25
26
|
form:
|
26
27
|
title:
|
@@ -32,24 +33,29 @@ form:
|
|
32
33
|
10:
|
33
34
|
name: name
|
34
35
|
type: text_field
|
35
|
-
|
36
|
-
size: 30
|
36
|
+
size: 40
|
37
37
|
|
38
38
|
20:
|
39
39
|
name: dc_site_id
|
40
40
|
type: select
|
41
41
|
eval: DcSite.choices4_site
|
42
|
+
html:
|
43
|
+
include_blank: true
|
42
44
|
|
43
45
|
30:
|
46
|
+
name: redirect
|
47
|
+
type: text_field
|
48
|
+
size: 40
|
49
|
+
|
50
|
+
40:
|
44
51
|
name: page_id
|
45
52
|
type: text_autocomplete
|
46
53
|
table:
|
47
54
|
eval: '@parent.session[:site_page_table]'
|
48
55
|
search: subject
|
49
|
-
|
50
|
-
size: 80
|
56
|
+
size: 60
|
51
57
|
|
52
|
-
|
58
|
+
50:
|
53
59
|
name: params
|
54
60
|
type: text_area
|
55
61
|
html:
|
data/app/forms/dc_menu_item.yml
CHANGED
data/app/forms/dc_page.yml
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Form for dc_removed_url
|
2
|
+
table: dc_removed_url
|
3
|
+
|
4
|
+
index:
|
5
|
+
filter: url, dc_site_id
|
6
|
+
actions: standard
|
7
|
+
|
8
|
+
result_set:
|
9
|
+
actions: standard
|
10
|
+
|
11
|
+
columns:
|
12
|
+
10:
|
13
|
+
name: dc_site_id
|
14
|
+
eval: dc_name4_id,dc_site,name
|
15
|
+
20:
|
16
|
+
name: url
|
17
|
+
width: 40%
|
18
|
+
30:
|
19
|
+
name: updated_at
|
20
|
+
format: '%d.%m.%Y'
|
21
|
+
|
22
|
+
form:
|
23
|
+
title:
|
24
|
+
field: url
|
25
|
+
|
26
|
+
actions: standard
|
27
|
+
|
28
|
+
fields:
|
29
|
+
10:
|
30
|
+
name: url
|
31
|
+
type: text_field
|
32
|
+
size: 50
|
33
|
+
20:
|
34
|
+
name: description
|
35
|
+
type: text_field
|
36
|
+
size: 50
|
37
|
+
30:
|
38
|
+
name: dc_site_id
|
39
|
+
type: select
|
40
|
+
eval: dc_choices4('dc_site','name','_id')
|
41
|
+
html:
|
42
|
+
include_blank: true
|
@@ -134,6 +134,16 @@ EOT
|
|
134
134
|
when action == 'menu' then
|
135
135
|
caption = t(v['caption'], v['caption']) + ' ' + fa_icon('caret-down lg')
|
136
136
|
caption + eval(v['eval'])
|
137
|
+
=begin
|
138
|
+
# reorder
|
139
|
+
when action == 'reorder' then
|
140
|
+
caption = t('drgcms.reorder')
|
141
|
+
parms = @parms.clone
|
142
|
+
parms['operation'] = v
|
143
|
+
parms['id'] = params[:ids]
|
144
|
+
parms['table'] = @form['table']
|
145
|
+
dc_link_to( caption, 'reorder', parms, method: :delete )
|
146
|
+
=end
|
137
147
|
else
|
138
148
|
caption = yaml['caption'] || yaml['text']
|
139
149
|
icon = yaml['icon'] ? yaml['icon'] : action
|
@@ -173,7 +183,7 @@ def dc_div_filter()
|
|
173
183
|
field_name, operators_value = nil, nil
|
174
184
|
end
|
175
185
|
#{ form_tag :table => @form['table'], filter: :on, filter_input: 1, action: :index, method: :post }
|
176
|
-
url = url_for(:
|
186
|
+
url = url_for(table: @form['table'],form_name: params['form_name'], filter: :on, filter_input: 1, action: :index, controller: :cmsedit)
|
177
187
|
html =<<EOT
|
178
188
|
<div id="drgcms_filter" class="div-hidden">
|
179
189
|
<h1>#{t('drgcms.filter_set')}</h1>
|
@@ -350,7 +360,7 @@ def dc_clicks_for_result(document)
|
|
350
360
|
html << ' data-dblclick=' + url_for(opts)
|
351
361
|
else
|
352
362
|
html << (' data-dblclick=' +
|
353
|
-
url_for(action: 'show', controller: 'cmsedit', id: document,
|
363
|
+
url_for(action: 'show', controller: 'cmsedit', id: document.id,
|
354
364
|
readonly: (params[:readonly] ? 2 : 1), table: params[:table],
|
355
365
|
form_name: params[:form_name], ids: params[:ids]) ) if @form['form']
|
356
366
|
end
|
@@ -475,6 +485,17 @@ def dc_columns_for_result(document)
|
|
475
485
|
html.html_safe
|
476
486
|
end
|
477
487
|
|
488
|
+
############################################################################
|
489
|
+
# Will return value for parameter required on form
|
490
|
+
############################################################################
|
491
|
+
def dc_value_for_parameter(param)
|
492
|
+
if param.class == Hash
|
493
|
+
dc_internal_var(param['object'] || 'record', param['method'])
|
494
|
+
else
|
495
|
+
param
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
478
499
|
############################################################################
|
479
500
|
# Creates actions div for edit form.
|
480
501
|
#
|
@@ -490,6 +511,7 @@ def dc_actions_for_form()
|
|
490
511
|
unless @record.id.nil?
|
491
512
|
std_actions.merge!({' 6' => 'new'} )
|
492
513
|
std_actions.merge!(@record.active ? {' 5' => 'disable'} : {' 5' => 'enable'} ) if @record.respond_to?('active')
|
514
|
+
std_actions.merge!({' 7' => 'refresh'} )
|
493
515
|
end
|
494
516
|
actions = @form['form']['actions']
|
495
517
|
# shortcut for actions: standard
|
@@ -531,6 +553,8 @@ def dc_actions_for_form()
|
|
531
553
|
next
|
532
554
|
end
|
533
555
|
#
|
556
|
+
action_active = !(dc_dont?(v['when_new']) and @record.new_record?)
|
557
|
+
# p [v['caption'], action_active]
|
534
558
|
parms = @parms.clone
|
535
559
|
if v.class == String
|
536
560
|
next if params[:readonly] and !(v == 'back')
|
@@ -562,21 +586,28 @@ def dc_actions_for_form()
|
|
562
586
|
parms['operation'] = v
|
563
587
|
parms['id'] = @record.id
|
564
588
|
dc_link_to( "drgcms.#{v}",v, parms )
|
589
|
+
when v == 'refresh' then
|
590
|
+
"<span onclick='window.location.href=window.location.href;'>#{fa_icon('refresh')} #{t('drgcms.refresh')}</span></li>"
|
565
591
|
else
|
566
592
|
"err1 #{element[0]}=>#{v}"
|
567
593
|
end
|
568
594
|
c << '</td>'
|
569
|
-
# non standard actions
|
595
|
+
# non standard actions
|
570
596
|
else
|
571
597
|
c << case
|
572
|
-
# submit button
|
598
|
+
# submit button
|
573
599
|
when v['type'] == 'submit'
|
574
600
|
caption = v['caption'] || 'drgcms.save'
|
575
601
|
icon = v['icon'] || 'save'
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
602
|
+
if action_active
|
603
|
+
'<li class="dc-link-submit dc-animate">' +
|
604
|
+
dc_submit_tag(caption, icon, {:data => v['params'], :title => v['title'] }) +
|
605
|
+
'</li>'
|
606
|
+
else
|
607
|
+
"<li class=\"dc-link-no\">#{fa_icon(icon)} #{caption}</li>"
|
608
|
+
end
|
609
|
+
|
610
|
+
# delete with some sugar added
|
580
611
|
when v['type'] == 'delete'
|
581
612
|
parms['id'] = @record.id
|
582
613
|
parms.merge!(v['params'])
|
@@ -585,40 +616,50 @@ def dc_actions_for_form()
|
|
585
616
|
'<li class="dc-link dc-animate">' +
|
586
617
|
dc_link_to( caption, icon, parms, data: t('drgcms.confirm_delete'), method: :delete ) +
|
587
618
|
'</li>'
|
588
|
-
|
589
|
-
|
619
|
+
|
620
|
+
# ajax or link button
|
621
|
+
when v['type'] == 'ajax' || v['type'] == 'link' || v['type'] == 'window'
|
590
622
|
parms = {}
|
591
|
-
|
623
|
+
# direct url
|
592
624
|
if v['url']
|
593
625
|
parms['controller'] = v['url']
|
594
|
-
parms['idr'] = @record
|
595
|
-
|
626
|
+
parms['idr'] = dc_document_path(@record)
|
627
|
+
# make url from action controller
|
596
628
|
else
|
597
629
|
parms['controller'] = v['controller']
|
598
630
|
parms['action'] = v['action']
|
599
631
|
parms['table'] = v['table']
|
600
632
|
parms['form_name'] = v['form_name']
|
601
|
-
parms['id'] = @record.id
|
602
|
-
# additional parameters
|
603
|
-
v['params'].each { |k,v| parms[k] = v } if v['params']
|
604
633
|
end
|
605
|
-
|
634
|
+
# add current id to parameters
|
635
|
+
parms['id'] = dc_document_path(@record)
|
636
|
+
# additional parameters
|
637
|
+
v['params'].each { |k,v| parms[k] = dc_value_for_parameter(v) } if v['params']
|
638
|
+
# Error if controller parameter is missing
|
606
639
|
if parms['controller'].nil?
|
607
640
|
"<li>#{t('drgcms.error')}</li>"
|
608
641
|
else
|
609
642
|
v['caption'] ||= v['text']
|
610
643
|
caption = t("#{v['caption'].downcase}", v['caption'])
|
611
|
-
|
644
|
+
#
|
645
|
+
url = url_for(parms) rescue ''
|
612
646
|
request = v['request'] || v['method'] || 'get'
|
613
647
|
icon = v['icon'] ? "#{fa_icon(v['icon'])} " : ''
|
614
648
|
if v['type'] == 'ajax' # ajax button
|
615
|
-
|
649
|
+
clas = action_active ? "dc-link-ajax dc-animate" : "dc-link-no"
|
650
|
+
%Q[<li class="#{clas}" data-url="#{action_active ? url : ''}"
|
616
651
|
data-request="#{request}" title="#{v['title']}">#{icon}#{caption}</li>]
|
617
|
-
|
618
|
-
|
619
|
-
%Q[<li class="
|
652
|
+
elsif v['type'] == 'link' # link button
|
653
|
+
clas = action_active ? "dc-link dc-animate" : "dc-link-no"
|
654
|
+
%Q[<li class="#{clas}">#{action_active ? dc_link_to(v['caption'],v['icon'], parms, {target: v['target']} ) : caption}</li>]
|
655
|
+
elsif v['type'] == 'window'
|
656
|
+
clas = action_active ? "dc-link dc-animate dc-window-open" : "dc-link-no"
|
657
|
+
%Q[<li class="#{clas}" data-url="#{action_active ? url : ''}">#{icon}#{caption}</li>]
|
658
|
+
else
|
659
|
+
'Action Type error'
|
620
660
|
end
|
621
661
|
end
|
662
|
+
|
622
663
|
# Javascript action
|
623
664
|
when v['type'] == 'script'
|
624
665
|
# v['caption'] ||= 'Caption missing!'
|
@@ -54,7 +54,9 @@ attr_reader :part
|
|
54
54
|
attr_accessor :page_title
|
55
55
|
# all parts read from page, design, ...
|
56
56
|
attr_accessor :parts
|
57
|
-
|
57
|
+
#
|
58
|
+
attr_accessor :record
|
59
|
+
#
|
58
60
|
attr_accessor :record_footer
|
59
61
|
|
60
62
|
############################################################################
|
@@ -283,7 +285,7 @@ def dc_edit_title()
|
|
283
285
|
dc_deprecate('form:edit_title will be deprecated. Use form:title:field instead.') if @form['form']['edit_title']
|
284
286
|
#
|
285
287
|
c << "#{@record[ title ]} : " if title and @record.respond_to?(title)
|
286
|
-
c << @record.
|
288
|
+
c << @record.id if @record
|
287
289
|
end
|
288
290
|
c
|
289
291
|
end
|
@@ -440,7 +442,7 @@ end
|
|
440
442
|
# String. HTML code formatted for display.
|
441
443
|
####################################################################
|
442
444
|
def dc_error_messages_for(doc)
|
443
|
-
return '' unless doc.errors.any?
|
445
|
+
return '' unless doc and doc.errors.any?
|
444
446
|
msgs = ''
|
445
447
|
doc.errors.each do |attribute, errors_array|
|
446
448
|
label = t("helpers.label.#{decamelize_type(doc.class)}.#{attribute}", attribute)
|
@@ -527,13 +529,15 @@ end
|
|
527
529
|
# Create edit link with edit picture. Subroutine of dc_page_edit_menu.
|
528
530
|
####################################################################
|
529
531
|
def dc_link_menu_tag(title) #:nodoc:
|
530
|
-
html
|
531
|
-
|
532
|
+
html = %Q[
|
533
|
+
<dl>
|
532
534
|
<dt><div class='drgcms_popmenu' href="#">
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
535
|
+
#{_origin.fa_icon('file-text-o lg', class: 'dc-inline-link', title: title)}
|
536
|
+
</div></dt>
|
537
|
+
<dd>
|
538
|
+
<ul class=' div-hidden drgcms_popmenu_class'>
|
539
|
+
]
|
540
|
+
|
537
541
|
yield html
|
538
542
|
html << "</ul></dd></dl>"
|
539
543
|
end
|
@@ -1288,7 +1292,7 @@ end
|
|
1288
1292
|
# [var_name] String[symbol]: Variable name (:user_name, 'user_id', ...)
|
1289
1293
|
#
|
1290
1294
|
# Example:
|
1291
|
-
# # called when
|
1295
|
+
# # called when constructing iframe for display
|
1292
1296
|
# dc_internal_var(session, :user_id)
|
1293
1297
|
# dc_internal_var(params, :some_external_parameter)
|
1294
1298
|
# dc_internal_var(site, :name)
|
@@ -1303,13 +1307,33 @@ def dc_internal_var(object, var_name)
|
|
1303
1307
|
when object == 'params' then _origin.params[var_name]
|
1304
1308
|
when object == 'site' then _origin.dc_get_site.send(var_name)
|
1305
1309
|
when object == 'page' then _origin.page.send(var_name)
|
1310
|
+
when object == 'record' then _origin.record.send(var_name)
|
1306
1311
|
else
|
1307
1312
|
'VARIABLE: UNKNOWN OBJECT'
|
1308
1313
|
end
|
1309
1314
|
rescue Exception => e
|
1310
|
-
Rails.logger.
|
1315
|
+
Rails.logger.error "Method dc_internal var. Runtime error. #{e.message}"
|
1311
1316
|
'VARIABLE: ERROR'
|
1312
1317
|
end
|
1313
1318
|
end
|
1314
1319
|
|
1320
|
+
|
1321
|
+
########################################################################
|
1322
|
+
# Will return whole path to document if document is embedded in another document.
|
1323
|
+
#
|
1324
|
+
# Parameters:
|
1325
|
+
# [document] Object: Document object
|
1326
|
+
#
|
1327
|
+
# Returns:
|
1328
|
+
# String of ID-s separated by semicolon.
|
1329
|
+
#######################################################################
|
1330
|
+
def dc_document_path(document)
|
1331
|
+
path, parent = [document.id], document._parent
|
1332
|
+
while parent
|
1333
|
+
path << parent.id
|
1334
|
+
parent = parent._parent
|
1335
|
+
end
|
1336
|
+
path.reverse.join(';')
|
1337
|
+
end
|
1338
|
+
|
1315
1339
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2012+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
########################################################################
|
25
|
+
# DcGalleryRenderer renders data for displaying picture galary under the document.
|
26
|
+
#
|
27
|
+
# Example:
|
28
|
+
# <div id="page">
|
29
|
+
# <%= dc_render(:dc_gallery) if document.gallery %>
|
30
|
+
# </div>
|
31
|
+
#
|
32
|
+
########################################################################
|
33
|
+
class DcGalleryRenderer
|
34
|
+
|
35
|
+
include DcApplicationHelper
|
36
|
+
|
37
|
+
########################################################################
|
38
|
+
# Object initialization.
|
39
|
+
########################################################################
|
40
|
+
def initialize( parent, opts={} ) #:nodoc:
|
41
|
+
@parent = parent
|
42
|
+
@opts = opts
|
43
|
+
@page = @parent.page
|
44
|
+
@css = ''
|
45
|
+
end
|
46
|
+
|
47
|
+
#########################################################################
|
48
|
+
# Default DcGallery render method. It will simply put thumbnail pictures side by side and
|
49
|
+
# open big picture when clicked on thumbnail.
|
50
|
+
#########################################################################
|
51
|
+
def default
|
52
|
+
can_view, msg = dc_user_can_view(@parent, @page)
|
53
|
+
return msg unless can_view
|
54
|
+
#
|
55
|
+
html = '<div class="picture-gallery"><ul>'
|
56
|
+
DcGallery.where(doc_id: @opts[:doc_id], active: true).order_by(order: 1).each do |picture|
|
57
|
+
html << '<li>'
|
58
|
+
html << edit_menu(picture) if @opts[:edit_mode] > 1
|
59
|
+
html << "#{@parent.link_to(i@parent.mage_tag(picture.thumbnail, title: picture.title), picture.picture)}<li>"
|
60
|
+
end
|
61
|
+
#
|
62
|
+
html << '</ul></div>'
|
63
|
+
end
|
64
|
+
|
65
|
+
#########################################################################
|
66
|
+
# Renderer dispatcher. Method returns HTML part of code.
|
67
|
+
########################################################################
|
68
|
+
def render_html
|
69
|
+
method = @opts[:method] || 'default'
|
70
|
+
respond_to?(method) ? send(method) : "Error DcPage: Method #{method} doesn't exist!"
|
71
|
+
end
|
72
|
+
|
73
|
+
########################################################################
|
74
|
+
# Return CSS part of code.
|
75
|
+
########################################################################
|
76
|
+
def render_css
|
77
|
+
@css
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
########################################################################
|
82
|
+
#
|
83
|
+
########################################################################
|
84
|
+
def edit_menu(picture)
|
85
|
+
opts = { controller: 'cmsedit', action: 'edit' }
|
86
|
+
opts[:title] = "#{t('drgcms.edit')}: #{picture.title}"
|
87
|
+
opts[:id] = picture.id
|
88
|
+
opts[:table] = 'dc_gallery'
|
89
|
+
|
90
|
+
'<li>'+dc_link_for_edit(opts)+'</li>'
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
end
|