diff app/models/.svn/text-base/wiki.rb.svn-base @ 511:107d36338b70 live

Merge from branch "cannam"
author Chris Cannam
date Thu, 14 Jul 2011 10:43:07 +0100
parents 753f1380d6bc
children
line wrap: on
line diff
--- a/app/models/.svn/text-base/wiki.rb.svn-base	Thu Jun 09 16:51:06 2011 +0100
+++ b/app/models/.svn/text-base/wiki.rb.svn-base	Thu Jul 14 10:43:07 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.find_by_title(title)
+    page = pages.first(:conditions => ["LOWER(title) = LOWER(?)", title])
     if !page && !(options[:with_redirect] == false)
       # search for a redirect
-      redirect = redirects.find_by_title(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: