comparison app/models/wiki_page.rb @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents e248c7af89ec
children
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
80 def handle_redirects 80 def handle_redirects
81 self.title = Wiki.titleize(title) 81 self.title = Wiki.titleize(title)
82 # Manage redirects if the title has changed 82 # Manage redirects if the title has changed
83 if !@previous_title.blank? && (@previous_title != title) && !new_record? 83 if !@previous_title.blank? && (@previous_title != title) && !new_record?
84 # Update redirects that point to the old title 84 # Update redirects that point to the old title
85 wiki.redirects.find_all_by_redirects_to(@previous_title).each do |r| 85 wiki.redirects.where(:redirects_to => @previous_title).each do |r|
86 r.redirects_to = title 86 r.redirects_to = title
87 r.title == r.redirects_to ? r.destroy : r.save 87 r.title == r.redirects_to ? r.destroy : r.save
88 end 88 end
89 # Remove redirects for the new title 89 # Remove redirects for the new title
90 wiki.redirects.find_all_by_title(title).each(&:destroy) 90 wiki.redirects.where(:title => title).each(&:destroy)
91 # Create a redirect to the new title 91 # Create a redirect to the new title
92 wiki.redirects << WikiRedirect.new(:title => @previous_title, :redirects_to => title) unless redirect_existing_links == "0" 92 wiki.redirects << WikiRedirect.new(:title => @previous_title, :redirects_to => title) unless redirect_existing_links == "0"
93 @previous_title = nil 93 @previous_title = nil
94 end 94 end
95 end 95 end
96 96
97 def remove_redirects 97 def remove_redirects
98 # Remove redirects to this page 98 # Remove redirects to this page
99 wiki.redirects.find_all_by_redirects_to(title).each(&:destroy) 99 wiki.redirects.where(:redirects_to => title).each(&:destroy)
100 end 100 end
101 101
102 def pretty_title 102 def pretty_title
103 WikiPage.pretty_title(title) 103 WikiPage.pretty_title(title)
104 end 104 end
105 105
106 def content_for_version(version=nil) 106 def content_for_version(version=nil)
107 result = content.versions.find_by_version(version.to_i) if version 107 if content
108 result ||= content 108 result = content.versions.find_by_version(version.to_i) if version
109 result 109 result ||= content
110 result
111 end
110 end 112 end
111 113
112 def diff(version_to=nil, version_from=nil) 114 def diff(version_to=nil, version_from=nil)
113 version_to = version_to ? version_to.to_i : self.content.version 115 version_to = version_to ? version_to.to_i : self.content.version
114 content_to = content.versions.find_by_version(version_to) 116 content_to = content.versions.find_by_version(version_to)