Class: PagesController
Constant Summary
KitController::Pagebase
Instance Attribute Summary
#is_image_request, #kit_request, #layout_being_used, #requested_url, #template_being_used
Instance Method Summary
collapse
#anti_spam_okay?, #app_name, #can_moderate, #can_use, #captcha_okay?, #check_and_record_goal, #check_user, #csv_headers, #dif, #edit_page_path, #feature?, #get_asset, #get_view_content, #host_name, #index_name, #info_page_path, #kit_layout_in_use, #kit_render, #kit_session, #kit_session_end, #link_to, #mailchimp_connect, #mobile_template, #no_read, #no_write, #not_found, #not_found_404, #offline, #page_path, #pref, #rails_app_name, #render, #render_error, #render_page, #render_page_by_url, #routing_error, #sanity_check_okay?, #session_id, #set_requested_url, #show_form, #stylesheets, #super_render, #user_sees_menu?
Instance Method Details
#add_note ⇒ Object
195
196
197
198
199
200
201
202
203
204
205
|
# File 'app/controllers/pages_controller.rb', line 195
def add_note
= .new(:user=>current_user, :body=>params[:body])
.save
@page. <<
Activity.add(_sid, "Add comment to page <a href='#{@page.full_path}'>#{@page.full_path}</a>", current_user.id, "Pages", .body)
if params[:mercury]
render :partial=>"mercury-notes"
else
render "pages/comment.js.erb", :layout=>false
end
end
|
#auto_save_delete ⇒ Object
150
151
152
153
154
155
156
157
158
159
160
|
# File 'app/controllers/pages_controller.rb', line 150
def auto_save_delete
if params[:what] == 'blocks'
BlockInstance.delete_all("version = -2 and page_id = #{@page.id}")
end
if params[:what] == 'contents'
@page.clear_auto_save
end
redirect_to "/page/#{@page.id}/info"
end
|
#browser_dif ⇒ Object
26
27
28
|
# File 'app/controllers/pages_controller.rb', line 26
def browser_dif
return true
end
|
#content_edit ⇒ Object
78
79
80
|
# File 'app/controllers/pages_controller.rb', line 78
def content_edit
@page_content = PageContent.find_sys_id(_sid, params[:content_id])
end
|
#content_update ⇒ Object
82
83
84
85
86
87
|
# File 'app/controllers/pages_controller.rb', line 82
def content_update
@page_content = PageContent.find_sys_id(_sid, params[:content_id])
@page_content.value = params[:page_content][:value]
@page_content.save
redirect_to "/page/#{@page.id}/contents"
end
|
#contents ⇒ Object
89
90
91
|
# File 'app/controllers/pages_controller.rb', line 89
def contents
params[:mode] = 'current' unless params[:mode]
end
|
#cookie_text ⇒ Object
30
31
32
|
# File 'app/controllers/pages_controller.rb', line 30
def cookie_text
render :layout=>false
end
|
#copy ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/pages_controller.rb', line 7
def copy
@original = @page
@page = Page.new
@page.copy_of = @original.id
@page.system_id = _sid
@page.status = Status.default_status(_sid)
@page.page_template = PageTemplate.find(@original.page_template_id)
@page.category_id = @original.category_id
@page.title = @original.title
@page.meta_description = @original.meta_description
@page.meta_keywords = @original.meta_keywords
@page. = @original.
@page.tags = @original.tags
render "new", :layout=>"cms"
end
|
#create ⇒ Object
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
|
# File 'app/controllers/pages_controller.rb', line 381
def create
@page = Page.new(params[:page])
@page.system_id = _sid
@page.mobile_dif = Preference.getCached(_sid, 'mobile_dif_by_default')!='false' ? 1 : 0
@page.created_by = current_user.id
@original = nil
if @page.save
if @page.copy_of
@original = Page.sys(_sid).where(:id=>@page.copy_of).first
@page.copy_content_from(@original)
end
Activity.add(_sid,"Created page '#{@page.name}' as <a href='#{@page.full_path}'>#{@page.full_path}</a>", current_user.id, 'Pages')
@page.generate_block_instances(current_user.id) unless @original
redirect_to @page.link("show", true)
return
else
@page.copy_of = params[:page][:copy_of]
if @page.copy_of
@page.page_template_id = Page.sys(_sid).where(:id=>@page.copy_of).first.page_template_id
else
@page.page_template_id = params[:page][:page_template_id]
end
render "new"
end
end
|
#destroy ⇒ Object
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
# File 'app/controllers/pages_controller.rb', line 325
def destroy
if @page.is_stub?
Page.destroy(params[:id])
else
if params[:destroy]
Page.destroy(params[:id])
flash[:notice] = "Page destroyed"
redirect_to "/pages" and return
else
@page.update_attributes(:is_deleted=>1)
end
end
flash[:notice] = "Page #{'Stub ' if @page.is_stub?}deleted"
unless request.xhr?
redirect_to request.referer
else
render :json=>{:message=>flash[:notice]}
end
end
|
#destroy_draft ⇒ Object
424
425
426
427
428
|
# File 'app/controllers/pages_controller.rb', line 424
def destroy_draft
@page.destroy_draft(current_user.id)
flash[:notice] = "Draft deleted"
redirect_to "/page/#{@page.id}/info"
end
|
#edit ⇒ Object
408
409
|
# File 'app/controllers/pages_controller.rb', line 408
def edit
end
|
#editor_trial ⇒ Object
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
# File 'app/controllers/pages_controller.rb', line 237
def editor_trial
if session[:trial_page_id]==nil || params[:force]
source_id = Preference.get_cached(_sid, "edit_trial_source_page_id")
raise "can't generate a trial page without setting 'edit_trial_source_page_id' preference" unless source_id
source_page = Page.sys(_sid).where(:id=>source_id).first
trial_category_id = Preference.get_cached(_sid, "edit_trial_category")
raise "can't generate a trial page without setting 'edit_trial_category' preference" unless trial_category_id
trial_category = Category.sys(_sid).where(:id=>trial_category_id).first
source_page.name = "trial-#{rand(1000000)}"
trial_page_id = source_page.copy_to(trial_category)
raise "couldn't create trial page" unless trial_page_id
session[:trial_page_id] = trial_page_id
trial_page = Page.find(trial_page_id)
trial_page.publish(0)
else
trial_page_id = session[:trial_page_id]
trial_page = Page.find(trial_page_id)
end
redirect_to trial_page.link('show', true)
end
|
#favourite ⇒ Object
313
314
315
316
317
318
319
320
321
322
323
|
# File 'app/controllers/pages_controller.rb', line 313
def favourite
if request.post?
current_user.pages << @page
notice = "Added to Favourites"
elsif request.delete?
current_user.pages.delete(@page)
notice = "Removed from Favourites"
end
redirect_to "/page/#{@page.id}/info", :notice=>notice
end
|
#index ⇒ Object
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
# File 'app/controllers/pages_controller.rb', line 215
def index
if params[:cat_id]
@category = Category.where(:id=>params[:cat_id]).first
else
@category = Category.root(_sid)
end
if params[:status_id]
@status = Status.find_sys_id(_sid, params[:status_id])
@mode = @status.name
@pages = Page.sys(_sid).where(:status_id=>params[:status_id]).order("updated_at desc").page(params[:page]).per(10)
elsif params[:fav] && current_user
fpc = current_user.favourites_pages_comma
@pages = Page.sys(_sid).where("id in (#{fpc})").order("updated_at desc").page(params[:page]).per(10) if fpc.length>0
@mode = "Favourites"
else
@pages = Page.sys(_sid).order("updated_at desc").page(params[:page])
@mode = "Recent"
end
render "index"
end
|
#info ⇒ Object
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
|
# File 'app/controllers/pages_controller.rb', line 486
def info
if params[:sitemap] && request.post?
@page.skip_history
@page.update_attributes(:in_sitemap=>params[:sitemap])
Activity.add(_sid, "Page <a href='#{@page.full_path}'>#{@page.full_path}</a> #{params[:sitemap]=='1' ? 'added to' : 'removed from'} sitemap", current_user.id, "Pages", '')
flash[:notice] = "Sitemap updated"
redirect_to "/page/#{@page.id}/info"
end
if params[:locked]!=nil && request.post?
@page.locked = params[:locked]=='true' ? 1 : 0
Activity.add(_sid, "Page <a href='#{@page.full_path}'>#{@page.full_path}</a> #{@page.locked ? 'locked' : 'unlocked'}", current_user.id, "Pages", '')
@page.save
end
if params[:anonymous_comments] && request.post?
@page. = params[:anonymous_comments]=='true' ? 1 : 0
Activity.add(_sid, "Set anonymous comments #{@page.allow_anonymous_comments? ? 'on' : 'off'} for page <a href='#{@page.full_path}'>#{@page.full_path}</a>", current_user.id, "Pages", '')
@page.save
end
if params[:user_comments] && request.post?
@page. = params[:user_comments]=='true' ? 1 : 0
Activity.add(_sid, "Set user comments #{@page.allow_user_comments? ? 'on' : 'off'} for page <a href='#{@page.full_path}'>#{@page.full_path}</a>", current_user.id, "Pages", '')
@page.save
end
if params[:remove_term] && request.post?
Term.delete_all("id = #{params[:remove_term]} and system_id = #{_sid}")
end
if params[:mobile_dif] && request.post?
@page.mobile_dif = params[:mobile_dif]
@page.save
end
if params[:publish]=="1" && request.post?
@page.publish(current_user.id)
Activity.add(_sid, "Page <a href='#{@page.full_path}'>#{@page.full_path}</a> published", current_user.id, "Pages", '')
flash[:notice] = "Page published"
redirect_to "/page/#{@page.id}/info"
end
editors = @page.page_edits.includes(:user)
@being_edited_by = editors.map { |e| e.user.email }
end
|
#links ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'app/controllers/pages_controller.rb', line 93
def links
if params[:refresh]
@page.queue_crawl
redirect_to "/page/#{@page.id}/info", :notice=>"Request processed"
return
end
if params[:deep]
Page.sys(_sid).find_each do |p|
p.queue_crawl(false)
redirect_to "/page/#{@page.id}/info", :notice=>"Request processed"
return
end
@page.queue_crawl
redirect_to "/page/#{@page.id}/links"
end
end
|
#load_page ⇒ Object
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
|
# File 'app/controllers/pages_controller.rb', line 596
def load_page
if params[:url]
url = params[:url] || ""
url += ".#{params[:format]}" if params[:format]
use_experiments = Preference.get_cached(_sid, "feature_experiments")=='true'
self.requested_url = url
if use_experiments && experiment = Experiment.alternative(_sid, url)
exp_option = cookies["experiment_#{experiment.id}".to_sym]
url, selected_option = experiment.invoke(exp_option)
cookies["experiment_#{experiment.id}".to_sym] = {:value=>selected_option, :expires=>Time.now+30.minute}
@canonical_tag = "/" + self.requested_url
end
@page = Pagebase.sys(_sid).where(full_path:"/"+url).first
if @page==nil && url =~ /^page\/(\d+)$/
@page = Pagebase.sys(_sid).where(id: $1).first
end
if @page==nil && url
@page = Pagebase.sys(_sid).where(full_path:"/#{url}/index").first
end
else
params[:id] ||= Preference.getCached(_sid, "home_page")
@page= Pagebase.sys(_sid).where(id: params[:id]).first
end
if @page
@page_params = params[:page]
@page.draft = params[:draft]=="1" if @page
else
@form = Form.sys(_sid).where(:url=>"/#{params[:url]}").includes({:form_field_groups=>{:form_fields=>:form_field_type}}).first
if @form
show_form(@form) and return
end
mapping = Mapping.sys(_sid).where(:source_url=>"/#{params[:url]}.#{params[:format]}").where(:is_active=>1).first
mapping ||= Mapping.sys(_sid).where(:source_url=>"/#{params[:url]}").where(:is_active=>1).first
mapping ||= Mapping.sys(_sid).where(["? like source_url", "/#{params[:url]}"]).where(:is_active=>1).first
if mapping
if mapping.is_asset?
target_params = mapping.target_url.split('/')
logger.debug "------ #{target_params[2]}"
get_asset(target_params[2], target_params[3]) and return
end
url = "/#{params[:url]}".split(/\//)
if mapping.params_url
surl = mapping.params_url.split(/\//)
for i in 0..(surl.size-1) do
if surl[i] =~ /\:(.+)/
logger.debug "FOUND NAME: #{$1}"
logger.debug "** #{url[i]}"
params[$1] = url[i]
end
end
end
if mapping.is_page?
@page = Pagebase.where(:full_path=>mapping.target_url).first
else
redirect_to eval('"' + mapping.target_url + '"'), :status=>mapping.status_code || 301
end
else
not_found
end
end
end
|
#make_draft ⇒ Object
417
418
419
420
421
422
|
# File 'app/controllers/pages_controller.rb', line 417
def make_draft
@page.make_draft(current_user.id)
flash[:notice] = "Draft created"
redirect_to "/page/#{@page.id}/info"
return
end
|
#make_home ⇒ Object
411
412
413
414
415
|
# File 'app/controllers/pages_controller.rb', line 411
def make_home
@page.make_home_page!
Activity.add(_sid, "Page <a href='#{@page.full_path}'>#{@page.full_path}</a> made to be home page", current_user.id, "Pages", '')
redirect_to "/page/#{@page.id}/info"
end
|
34
35
36
37
38
|
# File 'app/controllers/pages_controller.rb', line 34
def
= .sys(_sid).where(:id=>params[:menu_id]).first
.add_page(@page, @page.title, params[:parent_id])
redirect_to @page.link('info')
end
|
#new ⇒ Object
371
372
373
374
375
376
377
378
379
|
# File 'app/controllers/pages_controller.rb', line 371
def new
@page = Page.new
@page.system_id = _sid
@page.status = Status.default_status(_sid)
@page.page_template_id = PageTemplate.sys(_sid).where(:is_default=>1).first.id rescue Pagetemplate.first.id
@page.category_id = params[:cat_id]
render "new", :layout=>"cms"
end
|
#notes ⇒ Object
207
208
209
|
# File 'app/controllers/pages_controller.rb', line 207
def notes
render "notes", :layout=>false
end
|
#notification ⇒ Object
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
# File 'app/controllers/pages_controller.rb', line 534
def notification
mode = params[:mode]
if mode=='open'
ActiveRecord::Base.connection.execute("update page_edits set updated_at = now() where page_id = #{params[:id]} and user_id = #{current_user.id}")
render :js=>"notification_done('#{mode}');", :layout=>false
elsif mode=='edit'
two_mins_ago = Time.now - 2.minutes
PageEdit.delete_all(["page_id = ? and (updated_at < ? or user_id = ?)", params[:id], two_mins_ago, current_user.id])
edits = PageEdit.select("distinct page_id, user_id").where(:page_id=>params[:id]).where("user_id <> #{current_user.id}").includes(:user).all
ActiveRecord::Base.connection.execute("insert into page_edits (page_id, user_id, created_at, updated_at) values (#{params[:id]}, #{current_user.id}, now(), now())")
being_edited_by = edits.map { |e| e.user.email }
if being_edited_by.size>0
render :js => "being_edited_by('#{being_edited_by.join(',')}')"
else
render :js => "notification_done('#{mode}');"
end
elsif mode=='finished'
PageEdit.delete_all(["page_id = ? and user_id = ?", params[:id], current_user.id])
render :js=>"notification_done('#{mode}');"
elsif mode=='force'
PageEdit.delete_all(["page_id = ?", params[:id]])
render :js=>"notification_done('#{mode}');"
elsif mode=='delete'
PageEdit.delete_all(["page_id = ?", params[:id]])
p = Page.find_sys_id(_sid, params[:id])
redirect_to p.link('info')
else
logger.info("Unknown Mode");
render :text=>"", :layout=>false
end
end
|
#page_template ⇒ Object
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
|
# File 'app/controllers/pages_controller.rb', line 462
def page_template
if request.put?
page = Page.sys(_sid).where(:id=>params[:id]).first
return unless page
notice = nil
if page.page_template_id != params[:page][:page_template_id]
new_template = PageTemplate.sys(_sid).where(:id=>params[:page][:page_template_id]).first
if new_template
lookup = {}
page.page_template_id = params[:page][:page_template_id]
page.save
params.each do |param_name, new_name|
if param_name =~ /^f_(.+)$/
old_name = $1
PageContent.connection.execute("update page_contents set field_name = '#{new_name}' where field_name = '#{old_name}' and page_id = #{page.id}")
end
end
notice = 'Changes saved'
end
end
redirect_to "/page/#{params[:id]}/info", :notice=>notice
end
end
|
#possible_terms ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/pages_controller.rb', line 40
def possible_terms
data = {}
data[:query] = params[:query]
terms = Term.arel_table
data[:suggestions] = Term.where(:page_template_term_id=>params[:page_template_term_id]).select("distinct terms.value").sys(_sid).where(terms[:value].matches("%#{params[:query]}%")).map { |t| t.value }
data[:data] = data[:suggestions]
render :json=>data
end
|
#publish_draft ⇒ Object
430
431
432
433
434
435
436
|
# File 'app/controllers/pages_controller.rb', line 430
def publish_draft
@page.draft = true
@page.publish(current_user.id)
flash[:notice] = "Draft published"
Activity.add(_sid, "Draft page <a href='#{@page.full_path}'>#{@page.full_path}</a> published", current_user.id, "Pages", '')
redirect_to "/page/#{@page.id}/info"
end
|
#redir ⇒ Object
308
309
310
311
|
# File 'app/controllers/pages_controller.rb', line 308
def redir
redirect_to @page.full_path + (params[:draft] ? "?draft=1" : "")
return
end
|
#save ⇒ Object
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# File 'app/controllers/pages_controller.rb', line 163
def save
raise "cannot save (permissions)" unless @page.id == session[:trial_page_id] || can_use
fields = ActiveSupport::JSON.decode(params[:content])
auto_save = params[:auto]=='1'
version = auto_save ? -2 : (@page.draft ? -1 : 0)
fields.each do |field,data|
field_name = field
field_index = 1
new_value = data["value"]
field_name = data["data"]["fieldid"]
@page.update_field(field_name, new_value, current_user, field_name.titleize, version)
end
@page.clear_auto_save if auto_save==false
PageEdit.delete_all(["page_id = ? and user_id = ?", @page.id, current_user ? current_user.id : 0])
Activity.add(_sid, "Edit page <a href='#{@page.full_path}'>#{@page.full_path}</a>", current_user ? current_user.id : 0, "Pages", '') if auto_save==false
unless auto_save
@page.updated_at = Time.now
@page.save
@page.update_index
@page.queue_crawl
end
render :js=>""
end
|
#search ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'app/controllers/pages_controller.rb', line 112
def search
if params[:search]
search_fields = []
indexes = []
system_id = _sid
search_size = (params[:per] || "5").to_i
the_page = (params[:page] || "1").to_i
[ "Page" ].each do |model|
indexes << "#{index_name}_#{model.downcase.pluralize}"
KitIndexed.indexed_columns(model).collect { |c|
search_fields << c[:name] if c[:user]
}
end
search_term = params[:search]
search = Tire.search indexes.join(',') do
query do
string search_term, :fields=>search_fields.uniq
end
filter :term, :status => "published"
filter :term, :is_deleted => 0
from (the_page-1)*search_size
size search_size
filter :term, :system_id=>system_id
end
logger.info "SEARCH: #{indexes.join(',')} #{search.to_json}"
@results = search.results
else
@results = nil
end
@searched_for = params[:search]
@show_edit_link = user_can_edit = can?(:use, self)
kit_render "pages/search", :layout_o=>Layout.preference(_sid, "layout_search")
end
|
#show ⇒ Object
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
# File 'app/controllers/pages_controller.rb', line 262
def show
return unless check_category_permissions
user_can_edit = can?(:use, self)
@page.editable = (params[:edit]!=nil) && (user_can_edit || @page.id==session[:trial_page_id]) && !@page.locked?
if @page.editable
if @page.is_home_page? && request.post?
save
return
end
if session[:runaway_check]
logger.debug "Doing runaway check"
if session[:runaway_check] > Time.now - 15.seconds
redirect_to "/page/#{@page.id}?edit=1&mercury_frame=1#{'&draft=1' if @page.draft}"
session[:runaway_check] = nil
return
end
end
if !params[:mercury_frame]
session[:runaway_check] = Time.now
render :text=>"", :layout=>"mercury-editor"
return
end
end
session[:runaway_check] = nil
page_name = params[:id]
if (@page==nil || @page.is_deleted==1 || !@page.is_published?) && !@page.editable && cannot?(:use, self)
session[:error_message] = "Page not found"
render "/error/404", :status=>404, :layout_o=>@page ? @page.dif_template(use_mobile?).layout : false
return
end
if (@page==nil && can?(:use, self))
flash[:notice] = "Page not found"
redirect_to "/pages"
return
end
@show_edit_link = true if user_can_edit && !@page.editable
render_page(@page)
end
|
#show_block_content ⇒ Object
64
65
66
67
68
69
70
|
# File 'app/controllers/pages_controller.rb', line 64
def show_block_content
@block_instance = BlockInstance.find_sys_id(_sid, params[:content_id])
@block_contents = BlockInstance.where(:page_id=>@block_instance.page_id).where(:block_id=>@block_instance.block_id).where(:instance_id=>@block_instance.instance_id).where(:version=>@block_instance.version).order(:field_name).all
render "block_content", :layout=>"minimal"
end
|
#show_content ⇒ Object
72
73
74
75
76
|
# File 'app/controllers/pages_controller.rb', line 72
def show_content
@page_content = PageContent.find_sys_id(_sid, params[:content_id])
render "content", :layout=>"minimal"
end
|
#stub ⇒ Object
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
# File 'app/controllers/pages_controller.rb', line 355
def stub
@page = Page.new
@page.system_id = _sid
@page.title = params[:name]
@page.name = @page.name_from_title
@page.status = Status.stub_status(_sid)
@page.category_id = params[:cat_id]
@page.page_template_id = nil
@page.created_by = current_user.id
if @page.save
render :json=>{:id => @page.id, :name => @page.name, :okay=>true, :message=>"Page Stub Created"}
else
render :json=>{:okay=>false, :message=>"Could not save: A page with that name already exists"}
end
end
|
#terms ⇒ Object
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
# File 'app/controllers/pages_controller.rb', line 438
def terms
@page = Page.find_sys_id(_sid, params[:id])
@new_terms = []
page_template_terms = @page.page_template.page_template_terms
if request.post?
params.each do |p,v|
if ptt = @page.page_template.term(p)
new_terms = @page.add_term(ptt, v)
@new_terms += new_terms if new_terms
end
end
render "add_term", :format=>:js
return
end
if request.delete?
@old_term = Term.find_sys_id(_sid, params[:term_id])
Term.delete_all("id = #{params[:term_id]} and system_id = #{_sid}")
render "remove_term", :format=>:js
end
@term = Term.new
@terms = @page.terms
end
|
#undelete ⇒ Object
345
346
347
348
349
350
351
352
353
|
# File 'app/controllers/pages_controller.rb', line 345
def undelete
@page.update_attributes(:is_deleted=>0)
flash[:notice] = "Page undeleted"
unless request.xhr?
redirect_to request.referer
else
render :json=>{:message=>flash[:notice]}
end
end
|
#unique ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/pages_controller.rb', line 52
def unique
category = Category.find_sys_id(_sid, params[:cat_id])
valid = false
if category
if category.pages.where(:name=>params[:name]).count==0
valid = true
end
end
render :js=>"page_name_valid(#{valid});"
end
|
#update ⇒ Object
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
|
# File 'app/controllers/pages_controller.rb', line 572
def update
old_path = @page.full_path
if @page_params[:status_id]
is_published = Status.find_sys_id(_sid, @page_params[:status_id])
if is_published==0 && self.published_at!=nil
self.published_at = nil
end
if is_published==1 && self.published_at==nil
self.published_at = Time.now
end
end
@page.updated_by = current_user.id
if @page.update_attributes(@page_params)
if params[:redirection] && @page.full_path != old_path
Mapping.create(:system_id=>_sid, :source_url=>old_path, :target_url=>@page.full_path, :user_id=>current_user.id, :status_code=>"301", :is_active=>true, :params_url=>"")
end
redirect_to "/page/#{@page.id}/info"
return
else
render "edit", :layout=>"cms"
end
end
|
#zoom ⇒ Object
211
212
213
|
# File 'app/controllers/pages_controller.rb', line 211
def zoom
render "mock"
end
|