Class: PagesController
Constant Summary
KitController::Pagebase
Instance Attribute Summary
#is_image_request, #kit_request, #layout_name_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, #csv_headers, #dif, #edit_page_path, #feature?, #get_asset, #get_view_content, #host_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, #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
175
176
177
178
179
180
181
182
183
184
185
|
# File 'app/controllers/pages_controller.rb', line 175
def add_note
= PageComment.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
131
132
133
134
135
136
137
138
139
140
141
|
# File 'app/controllers/pages_controller.rb', line 131
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
27
28
29
|
# File 'app/controllers/pages_controller.rb', line 27
def browser_dif
return true
end
|
#content_edit ⇒ Object
79
80
81
|
# File 'app/controllers/pages_controller.rb', line 79
def content_edit
@page_content = PageContent.find_sys_id(_sid, params[:content_id])
end
|
#content_update ⇒ Object
83
84
85
86
87
88
|
# File 'app/controllers/pages_controller.rb', line 83
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
90
91
92
|
# File 'app/controllers/pages_controller.rb', line 90
def contents
params[:mode] = 'current' unless params[:mode]
end
|
#cookie_text ⇒ Object
31
32
33
|
# File 'app/controllers/pages_controller.rb', line 31
def cookie_text
render :layout=>false
end
|
#copy ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/pages_controller.rb', line 8
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
# File 'app/controllers/pages_controller.rb', line 361
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
# File 'app/controllers/pages_controller.rb', line 305
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
404
405
406
407
408
|
# File 'app/controllers/pages_controller.rb', line 404
def destroy_draft
@page.destroy_draft(current_user.id)
flash[:notice] = "Draft deleted"
redirect_to "/page/#{@page.id}/info"
end
|
#edit ⇒ Object
388
389
|
# File 'app/controllers/pages_controller.rb', line 388
def edit
end
|
#editor_trial ⇒ Object
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
# File 'app/controllers/pages_controller.rb', line 217
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
293
294
295
296
297
298
299
300
301
302
303
|
# File 'app/controllers/pages_controller.rb', line 293
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
# File 'app/controllers/pages_controller.rb', line 195
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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
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
|
# File 'app/controllers/pages_controller.rb', line 466
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. ? '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. ? '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
|
#load_page ⇒ Object
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
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
|
# File 'app/controllers/pages_controller.rb', line 576
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
397
398
399
400
401
402
|
# File 'app/controllers/pages_controller.rb', line 397
def make_draft
@page.make_draft(current_user.id)
flash[:notice] = "Draft created"
redirect_to "/page/#{@page.id}/info"
return
end
|
#make_home ⇒ Object
391
392
393
394
395
|
# File 'app/controllers/pages_controller.rb', line 391
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
|
35
36
37
38
39
|
# File 'app/controllers/pages_controller.rb', line 35
def
= Menu.sys(_sid).where(:id=>params[:menu_id]).first
.add_page(@page, @page.title, params[:parent_id])
redirect_to @page.link('info')
end
|
#new ⇒ Object
351
352
353
354
355
356
357
358
359
|
# File 'app/controllers/pages_controller.rb', line 351
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
187
188
189
|
# File 'app/controllers/pages_controller.rb', line 187
def notes
render "notes", :layout=>false
end
|
#notification ⇒ Object
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
# File 'app/controllers/pages_controller.rb', line 514
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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
# File 'app/controllers/pages_controller.rb', line 442
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
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/pages_controller.rb', line 41
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
410
411
412
413
414
415
416
|
# File 'app/controllers/pages_controller.rb', line 410
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
288
289
290
291
|
# File 'app/controllers/pages_controller.rb', line 288
def redir
redirect_to @page.full_path + (params[:draft] ? "?draft=1" : "")
return
end
|
#save ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
# File 'app/controllers/pages_controller.rb', line 144
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
end
render :js=>""
end
|
#search ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'app/controllers/pages_controller.rb', line 94
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 << "kit_#{app_name.downcase}_#{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
@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=>Preference.getCached(_sid, "layout_search") || "application"
end
|
#show ⇒ Object
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
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
|
# File 'app/controllers/pages_controller.rb', line 242
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=>@page ? @page.dif_template(use_mobile?).layout.path : 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
65
66
67
68
69
70
71
|
# File 'app/controllers/pages_controller.rb', line 65
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
73
74
75
76
77
|
# File 'app/controllers/pages_controller.rb', line 73
def show_content
@page_content = PageContent.find_sys_id(_sid, params[:content_id])
render "content", :layout=>"minimal"
end
|
#stub ⇒ Object
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
# File 'app/controllers/pages_controller.rb', line 335
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
|
# File 'app/controllers/pages_controller.rb', line 418
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
325
326
327
328
329
330
331
332
333
|
# File 'app/controllers/pages_controller.rb', line 325
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
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/controllers/pages_controller.rb', line 53
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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
|
# File 'app/controllers/pages_controller.rb', line 552
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
191
192
193
|
# File 'app/controllers/pages_controller.rb', line 191
def zoom
render "mock"
end
|