diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-11-22 11:44:07 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-11-22 11:44:07 +0000 |
commit | 06266c8fecd78d620b7eb55c7d9df1b65340b5b1 (patch) | |
tree | 1c6938e22bf0b3fe52c7f2f4c2d9ade991224339 /app/models/wiki.rb | |
parent | af7e586b063398fe75104837b1d11d0886139b7e (diff) | |
download | redmine-06266c8fecd78d620b7eb55c7d9df1b65340b5b1.tar.gz redmine-06266c8fecd78d620b7eb55c7d9df1b65340b5b1.zip |
Extends child_pages macro to display child pages based on page parameter (#1975).
It can also be called from anywhere now (not only from wiki pages).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2053 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/wiki.rb')
-rw-r--r-- | app/models/wiki.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/wiki.rb b/app/models/wiki.rb index 3432a2bc7..be048775a 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -43,6 +43,25 @@ class Wiki < ActiveRecord::Base page end + # Finds a page by title + # The given string can be of one of the forms: "title" or "project:title" + # Examples: + # Wiki.find_page("bar", project => foo) + # Wiki.find_page("foo:bar") + def self.find_page(title, options = {}) + project = options[:project] + if title.to_s =~ %r{^([^\:]+)\:(.*)$} + project_identifier, title = $1, $2 + project = Project.find_by_identifier(project_identifier) || Project.find_by_name(project_identifier) + end + if project && project.wiki + page = project.wiki.find_page(title) + if page && page.content + page + end + end + end + # turn a string into a valid page title def self.titleize(title) # replace spaces with _ and remove unwanted caracters |