Class: Goldberg::MenuItemsController
Instance Method Summary
collapse
Methods included from Controller
included
#copy, #six_local_auto_login
#active_scaffold_render_secure_download, #assign_names_with_active_scaffold, #render_with_active_scaffold, #search_generic_view_paths?
Instance Method Details
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 41
def create
if (params[:menu_item][:controller_action_id] == nil or
params[:menu_item][:controller_action_id].length == 0 ) and
(params[:menu_item][:content_page_id] == nil or
params[:menu_item][:content_page_id].length == 0 )
flash[:error] = "You must specify either an Action or a Page!"
@menu_item = MenuItem.new(params[:menu_item])
@parent_item = MenuItem.find(params[:menu_item][:parent_id])
foreign
@can_change_parent = false
render :action => 'new', :id => params[:id]
return
end
@menu_item = MenuItem.new(params[:menu_item])
@menu_item.seq = MenuItem.next_seq(@menu_item.parent_id)
if @menu_item.save
flash[:notice] = 'MenuItem was successfully created.'
Role.rebuild_cache
redirect_to :action => 'list'
else
foreign
render :action => 'new'
end
end
|
139
140
141
142
143
144
145
146
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 139
def destroy
@menu_item = MenuItem.find(params[:id])
repack_for = @menu_item.parent_id
@menu_item.destroy
MenuItem.repack(repack_for)
Role.rebuild_cache
redirect_to :action => 'list'
end
|
69
70
71
72
73
74
75
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 69
def edit
@menu_item = MenuItem.find(params[:id])
foreign
@menu = Menu.new
@items = @menu.(0)
@can_change_parent = true
end
|
10
11
12
13
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 10
def index
list
render :action => 'list'
end
|
148
149
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 148
def link
item_name = params[:name].join('/')
node = Goldberg..select(item_name)
if node
session[:goldberg][:menu_item] = item_name
session[:goldberg][:menu_history] ||= Hash.new
session[:goldberg][:menu_history][node.url] = item_name
redirect_to node.url
else
logger.error "(error in menu)"
redirect_to "/"
end
end
|
15
16
17
18
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 15
def list
@menu = Menu.new
@items = @menu.(0)
end
|
#move_down ⇒ Object
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 127
def move_down
@menu_item = MenuItem.find(params[:id])
@below = @menu_item.below
if @below
@menu_item.update_attribute :seq, (@menu_item.seq + 1)
@below.update_attribute :seq, (@below.seq - 1)
Role.rebuild_cache
end
redirect_to :action => 'list'
end
|
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 115
def move_up
@menu_item = MenuItem.find(params[:id])
@above = @menu_item.above
if @above
@menu_item.update_attribute :seq, (@menu_item.seq - 1)
@above.update_attribute :seq, (@above.seq + 1)
Role.rebuild_cache
end
redirect_to :action => 'list'
end
|
24
25
26
27
28
29
30
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 24
def new
@menu_item = MenuItem.new
@menu = Menu.new
@items = @menu.(0)
foreign
@can_change_parent = false
end
|
32
33
34
35
36
37
38
39
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 32
def new_for
@parent_item = MenuItem.find(params[:id])
@menu_item = MenuItem.new
@menu_item.parent_id = @parent_item.id
foreign
@can_change_parent = false
render :action => 'new'
end
|
20
21
22
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 20
def show
@menu_item = MenuItem.find(params[:id])
end
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/controllers/goldberg/menu_items_controller.rb', line 77
def update
if (params[:menu_item][:controller_action_id] == nil or
params[:menu_item][:controller_action_id].length == 0 ) and
(params[:menu_item][:content_page_id] == nil or
params[:menu_item][:content_page_id].length == 0 )
flash[:error] = "You must specify either an Action or a Page!"
edit
render :action => 'edit'
return
end
@menu_item = MenuItem.find(params[:id])
if params[:parent_id] != @menu_item.parent_id
do_repack = true
repack_for = @menu_item.parent_id
params[:menu_item][:seq] = MenuItem.next_seq(params[:menu_item][:parent_id])
else
do_repack = false
end
if @menu_item.update_attributes(params[:menu_item])
flash[:notice] = 'MenuItem was successfully updated.'
if do_repack
MenuItem.repack(repack_for)
end
Role.rebuild_cache
redirect_to :action => 'list'
else
foreign
render :action => 'edit'
end
end
|