app/controllers/management/cms_controller.rb in imagine_cms-3.0.4 vs app/controllers/management/cms_controller.rb in imagine_cms-3.0.5
- old
+ new
@@ -171,11 +171,11 @@
# logger.debug e
# return
# end
#
# begin
- # if params[:file_content].empty?
+ # if params[:file_content].blank?
# flash[:error] = 'An error occurred, please contact support.'
# else
# File.open(filename, 'w') { |f| f.write(params[:file_content]) }
# flash[:notice] = 'File saved.'
# end
@@ -192,11 +192,11 @@
# end
# end
# end
def pages
- @page_levels = [ '' ].concat((params[:path] || session[:cms_pages_path] || '').split('/').reject { |l| l.empty? })
+ @page_levels = [ '' ].concat((params[:path] || session[:cms_pages_path] || '').split('/').reject { |l| l.blank? })
@page_levels << ''
@path = ''
@page = nil
end
@@ -274,11 +274,11 @@
if @pg.send(save_function)
# now try to save tags
begin
tags_to_delete = @pg.tags
- params[:tags].split(',').map { |t| t.strip }.reject { |t| t.empty? }.compact.each do |t|
+ params[:tags].split(',').map { |t| t.strip }.reject { |t| t.blank? }.compact.each do |t|
@pg.tags.create(:name => t) unless @pg.tags.find_by_name(t)
tags_to_delete.reject! { |tag| tag.name == t }
end
tags_to_delete.each { |t| t.destroy }
rescue Exception => e
@@ -288,11 +288,11 @@
# now try to save page objects (just attributes in this case)
begin
objects_to_delete = @pg.objects.find(:all, :conditions => [ "obj_type = 'attribute' or obj_type = 'option'" ])
(params[:page_objects] || {}).each do |key,val|
- next if key.empty? || val.empty?
+ next if key.blank? || val.blank?
key =~ /^obj-(\w+?)-(.+?)$/
obj = @pg.objects.find(:first, :conditions => [ "name = ? and obj_type = ?", $2, $1 ])
obj ||= @pg.objects.build(:name => $2, :obj_type => $1)
obj.content = val
@@ -452,11 +452,11 @@
if @page_objects["#{key}-sources-tag-count"].to_i > 0
tags = []
for i in 0...@page_objects["#{key}-sources-tag-count"].to_i
tags << @page_objects["#{key}-sources-tag#{i}"]
end
- tags.reject! { |tag| tag.empty? }
+ tags.reject! { |tag| tag.blank? }
@page_objects["#{key}-sources-tag-count"] = tags.size
tags.each_with_index do |tag, i|
@page_objects["#{key}-sources-tag#{i}"] = tag
end
end
@@ -464,11 +464,11 @@
if @page_objects["#{key}-sources-folder-count"].to_i > 0
folders = []
for i in 0...@page_objects["#{key}-sources-folder-count"].to_i
folders << @page_objects["#{key}-sources-folder#{i}"]
end
- folders.reject! { |folder| folder.empty? }
+ folders.reject! { |folder| folder.blank? }
@page_objects["#{key}-sources-folder-count"] = folders.size
folders.each_with_index do |folder, i|
@page_objects["#{key}-sources-folder#{i}"] = folder
end
end
@@ -642,13 +642,13 @@
key = "obj-#{type.to_s}-#{name.gsub(/[^\w]/, '_')}"
@page_objects[key] ||= ''
case type.to_sym
when :string
- @page_objects[key] = options[:content] if @page_objects[key].empty?
+ @page_objects[key] = options[:content] if @page_objects[key].blank?
text_field(:page_objects, key, options)
when :text
- @page_objects[key] = options[:content] if @page_objects[key].empty?
+ @page_objects[key] = options[:content] if @page_objects[key].blank?
focusOnLoad = !defined?(@cms_text_editor_placed)
@cms_text_editor_placed = true
content = ''.html_safe
content << text_area(:page_objects, key, { :dojoType => 'Editor2', :toolbarGroup => 'main', :isToolbarGroupLeader => 'false',
:focusOnLoad => focusOnLoad.to_s, :style => 'border: 2px dashed gray; padding: 5px',