app/models/page.rb in refinerycms-pages-0.9.9.15 vs app/models/page.rb in refinerycms-pages-0.9.9.16
- old
+ new
@@ -3,15 +3,15 @@
class Page < ActiveRecord::Base
translates :title, :meta_keywords, :meta_description, :browser_title, :custom_title if self.respond_to?(:translates)
# Set up support for meta tags through translations.
- if defined?(::Page::Translation) && Page::Translation.table_exists?
+ if defined?(::Page::Translation) && ::Page::Translation.table_exists?
def translation
- if @translation.nil? or @translation.try(:locale) != Globalize.locale
- @translation = translations.with_locale(Globalize.locale).first
- @translation ||= translations.build(:locale => Globalize.locale)
+ if @translation.nil? or @translation.try(:locale) != ::Globalize.locale
+ @translation = translations.with_locale(::Globalize.locale).first
+ @translation ||= translations.build(:locale => ::Globalize.locale)
end
@translation
end
@@ -260,12 +260,14 @@
def use_marketable_urls?
RefinerySetting.find_or_set(:use_marketable_urls, true, :scoping => 'pages')
end
def expire_page_caching
- if File.writable?(Rails.cache.cache_path)
- Pathname.glob(File.join(Rails.cache.cache_path, '**', '*pages*')).each(&:delete)
+ begin
+ Rails.cache.delete_matched(/.*pages.*/)
+ rescue NotImplementedError
+ warn "**** [REFINERY] The cache store you are using is not compatible with Rails.cache#delete_matched so please disable caching to ensure proper operation. ***"
end
end
end
# Accessor method to get a page part from a page.
@@ -289,10 +291,15 @@
part.try(:body)
end
# In the admin area we use a slightly different title to inform the which pages are draft or hidden pages
def title_with_meta
- title = [self.title.to_s]
+ if self.title.nil?
+ title = [::Page::Translation.where(:page_id => self.id).first.title.to_s]
+ else
+ title = [self.title.to_s]
+ end
+
title << "<em>(#{::I18n.t('hidden', :scope => 'admin.pages.page')})</em>" unless show_in_menu?
title << "<em>(#{::I18n.t('draft', :scope => 'admin.pages.page')})</em>" if draft?
title.join(' ')
end