Referring Pages for File List

For the file_list  action, include the pages which link to the given file(s).
This required rejiggering so that that information is actually retained in the database.
Unfortunately, you'll actually need to revise the page(s) in question, because that's the
only time this information is updated in the database.
This commit is contained in:
Jacques Distler 2009-01-10 00:18:25 -06:00
parent f456691609
commit 82e7aa52c7
4 changed files with 41 additions and 5 deletions

View file

@ -33,6 +33,15 @@ class WikiReference < ActiveRecord::Base
names = connection.select_all(sanitize_sql([query, page_name])).map { |row| row['name'] }
end
def self.pages_that_link_to_file(web, file_name)
query = 'SELECT name FROM pages JOIN wiki_references ' +
'ON pages.id = wiki_references.page_id ' +
'WHERE wiki_references.referenced_name = ? ' +
"AND wiki_references.link_type in ('#{FILE}') " +
"AND pages.web_id = '#{web.id}'"
names = connection.select_all(sanitize_sql([query, file_name])).map { |row| row['name'] }
end
def self.pages_that_include(web, page_name)
query = 'SELECT name FROM pages JOIN wiki_references ' +
'ON pages.id = wiki_references.page_id ' +