2014-05-08 06:03:33 +00:00
|
|
|
module Admin::ArchiveFilesHelper
|
2022-05-22 10:32:22 +00:00
|
|
|
def page_for_archive_file(archive_file)
|
|
|
|
archive_file_page = nil
|
|
|
|
pages = Page.where(:module=>'archive').select{|page| page.enabled_for.include?(I18n.locale.to_s)}
|
|
|
|
|
|
|
|
pages.each do |page|
|
|
|
|
if page.categories.count ==1
|
|
|
|
if (page.categories.include?(archive_file.category.id.to_s) rescue false)
|
|
|
|
archive_file_page = page
|
|
|
|
end
|
|
|
|
end
|
|
|
|
break if !archive_file_page.nil?
|
|
|
|
end
|
|
|
|
if archive_file_page.nil?
|
|
|
|
pages.each do |page|
|
|
|
|
if (page.categories.include?(archive_file.category.id.to_s) rescue false)
|
|
|
|
archive_file_page = page
|
|
|
|
end
|
|
|
|
break if !archive_file_page.nil?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
archive_file_page = pages.first if archive_file_page.nil?
|
|
|
|
request.protocol+(request.host_with_port+archive_file_page.url+'/'+archive_file.to_param).gsub('//','/') rescue "#"
|
|
|
|
end
|
|
|
|
end
|