comparison app/models/.svn/text-base/wiki.rb.svn-base @ 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
comparison
equal deleted inserted replaced
245:051f544170fe 441:cbce1fd3b1b7
42 find_page(title) || WikiPage.new(:wiki => self, :title => Wiki.titleize(title)) 42 find_page(title) || WikiPage.new(:wiki => self, :title => Wiki.titleize(title))
43 end 43 end
44 44
45 # find the page with the given title 45 # find the page with the given title
46 def find_page(title, options = {}) 46 def find_page(title, options = {})
47 @page_found_with_redirect = false
47 title = start_page if title.blank? 48 title = start_page if title.blank?
48 title = Wiki.titleize(title) 49 title = Wiki.titleize(title)
49 page = pages.first(:conditions => ["LOWER(title) LIKE LOWER(?)", title]) 50 page = pages.first(:conditions => ["LOWER(title) = LOWER(?)", title])
50 if !page && !(options[:with_redirect] == false) 51 if !page && !(options[:with_redirect] == false)
51 # search for a redirect 52 # search for a redirect
52 redirect = redirects.first(:conditions => ["LOWER(title) LIKE LOWER(?)", title]) 53 redirect = redirects.first(:conditions => ["LOWER(title) = LOWER(?)", title])
53 page = find_page(redirect.redirects_to, :with_redirect => false) if redirect 54 if redirect
55 page = find_page(redirect.redirects_to, :with_redirect => false)
56 @page_found_with_redirect = true
57 end
54 end 58 end
55 page 59 page
56 end 60 end
57 61
62 # Returns true if the last page was found with a redirect
63 def page_found_with_redirect?
64 @page_found_with_redirect
65 end
66
58 # Finds a page by title 67 # Finds a page by title
59 # The given string can be of one of the forms: "title" or "project:title" 68 # The given string can be of one of the forms: "title" or "project:title"
60 # Examples: 69 # Examples:
61 # Wiki.find_page("bar", project => foo) 70 # Wiki.find_page("bar", project => foo)
62 # Wiki.find_page("foo:bar") 71 # Wiki.find_page("foo:bar")