Index: openacs-4/packages/xowiki/tcl/xowiki-sc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-sc-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/xowiki/tcl/xowiki-sc-procs.tcl 26 Jan 2006 12:21:11 -0000 1.1 @@ -0,0 +1,76 @@ +ad_library { + XoWiki - Search Service Contracts + + @creation-date 2006-01-10 + @author Gustaf Neumann + @cvs-id $Id: xowiki-sc-procs.tcl,v 1.1 2006/01/26 12:21:11 gustafn Exp $ +} + +namespace eval ::xowiki {} + +ad_proc -private ::xowiki::datasource { revision_id } { + @param revision_id + + returns a datasource for the search package +} { + #ns_log notice "--datasource called with revision_id = $revision_id" + + set page [::Generic::CrItem instantiate -item_id 0 -revision_id $revision_id] + $page volatile + set content [expr {[$page set object_type] eq "::xowiki::PlainPage" ? + [$page set text] : [lindex [$page set text] 0]}] + $page set unresolved_references 0 + set content [ad_html_text_convert -from [$page set mime_type] -to text/plain -- $content] + + #ns_log notice "--datasource content=$content, oid=$revision_id" + return [list object_id $revision_id title [$page set title] \ + content $content keywords {} \ + storage_type text mime text/plain ] +} + +ad_proc -private ::xowiki::url { revision_id } { + @param revision_id + + returns a url for a message to the search package +} { + set page [::Generic::CrItem instantiate -item_id 0 -revision_id $revision_id] + $page volatile + set folder_id [$page set parent_id] + set pid [db_string get_package_id \ + "select package_id from acs_objects where object_id = $folder_id"] + return "[site_node::get_url_from_object_id -object_id $pid]pages/[ad_urlencode [$page set title]]" +} + + + +namespace eval ::xowiki::sc {} + +ad_proc -private ::xowiki::sc::register_implementations {} { + Register the content type fts contract +} { + acs_sc::impl::new_from_spec -spec { + name "::xowiki::Page" + aliases { + datasource ::xowiki::datasource + url ::xowiki::url + } + contract_name FtsContentProvider + owner xowiki + } + acs_sc::impl::new_from_spec -spec { + name "::xowiki::PlainPage" + aliases { + datasource ::xowiki::datasource + url ::xowiki::url + } + contract_name FtsContentProvider + owner xowiki + } +} + +ad_proc -private ::xowiki::sc::unregister_implementations {} { + acs_sc::impl::delete -contract_name FtsContentProvider -impl_name ::xowiki::Page + acs_sc::impl::delete -contract_name FtsContentProvider -impl_name ::xowiki::PlainPage +} + +