diff app/models/wiki.rb @ 441:cbce1fd3b1b7 redmine-1.2

Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author Chris Cannam
date Mon, 06 Jun 2011 14:24:13 +0100
parents 8661b858af72
children 753f1380d6bc cbb26bc654de
line wrap: on
line diff
--- a/app/models/wiki.rb	Thu Mar 03 11:42:28 2011 +0000
+++ b/app/models/wiki.rb	Mon Jun 06 14:24:13 2011 +0100
@@ -44,17 +44,26 @@
   
   # find the page with the given title
   def find_page(title, options = {})
+    @page_found_with_redirect = false
     title = start_page if title.blank?
     title = Wiki.titleize(title)
-    page = pages.first(:conditions => ["LOWER(title) LIKE LOWER(?)", title])
+    page = pages.first(:conditions => ["LOWER(title) = LOWER(?)", title])
     if !page && !(options[:with_redirect] == false)
       # search for a redirect
-      redirect = redirects.first(:conditions => ["LOWER(title) LIKE LOWER(?)", title])
-      page = find_page(redirect.redirects_to, :with_redirect => false) if redirect
+      redirect = redirects.first(:conditions => ["LOWER(title) = LOWER(?)", title])
+      if redirect
+        page = find_page(redirect.redirects_to, :with_redirect => false)
+        @page_found_with_redirect = true
+      end
     end
     page
   end
   
+  # Returns true if the last page was found with a redirect
+  def page_found_with_redirect?
+    @page_found_with_redirect
+  end
+
   # Finds a page by title
   # The given string can be of one of the forms: "title" or "project:title"
   # Examples: