etp-sc-procs.tcl


Procedures in this file

Detailed information

etp::create_search_impl (public)

 etp::create_search_impl -content_type content_type

Creates and registers a service contract implementation alias for an ETP custom application type if it does not already exist. This will define the datasource proc for the type as etp::revision_datasource. That proc will attempt to call a specially named tcl proc of the form etp::content_type where content_type is the acs_object type of the content type. If the proc does not exist only the attributes of the default type will be used to create the datasource.

Switches:
-content_type (required)
Author:
Dave Bauer

Partial Call Graph (max 5 caller/called nodes):
%3 etp::define_content_type etp::define_content_type (public) etp::create_search_impl etp::create_search_impl etp::define_content_type->etp::create_search_impl acs_sc_binding_exists_p acs_sc_binding_exists_p (public) etp::create_search_impl->acs_sc_binding_exists_p db_exec_plsql db_exec_plsql (public) etp::create_search_impl->db_exec_plsql db_transaction db_transaction (public) etp::create_search_impl->db_transaction etp::search_impl_exists_p etp::search_impl_exists_p (public) etp::create_search_impl->etp::search_impl_exists_p

Testcases:
No testcase defined.

etp::revision_datasource (public)

 etp::revision_datasource object_id

Returns a search package compatible array

Parameters:
object_id (required)
Author:
Dave Bauer

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.ftscontentprovider.datasource.etp_page_revision AcsSc.ftscontentprovider.datasource.etp_page_revision (private) etp::revision_datasource etp::revision_datasource AcsSc.ftscontentprovider.datasource.etp_page_revision->etp::revision_datasource AcsSc.ftscontentprovider.datasource.journal_article AcsSc.ftscontentprovider.datasource.journal_article (private) AcsSc.ftscontentprovider.datasource.journal_article->etp::revision_datasource AcsSc.ftscontentprovider.datasource.journal_issue AcsSc.ftscontentprovider.datasource.journal_issue (private) AcsSc.ftscontentprovider.datasource.journal_issue->etp::revision_datasource AcsSc.ftscontentprovider.datasource.news_item AcsSc.ftscontentprovider.datasource.news_item (private) AcsSc.ftscontentprovider.datasource.news_item->etp::revision_datasource acs_object_type acs_object_type (public) etp::revision_datasource->acs_object_type db_0or1row db_0or1row (public) etp::revision_datasource->db_0or1row

Testcases:
No testcase defined.

etp::revision_url (public)

 etp::revision_url object_id

returns the url of an etp page revision

Parameters:
object_id (required)
Author:
Dave Bauer

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.ftscontentprovider.url.etp_page_revision AcsSc.ftscontentprovider.url.etp_page_revision (private) etp::revision_url etp::revision_url AcsSc.ftscontentprovider.url.etp_page_revision->etp::revision_url AcsSc.ftscontentprovider.url.journal_article AcsSc.ftscontentprovider.url.journal_article (private) AcsSc.ftscontentprovider.url.journal_article->etp::revision_url AcsSc.ftscontentprovider.url.journal_issue AcsSc.ftscontentprovider.url.journal_issue (private) AcsSc.ftscontentprovider.url.journal_issue->etp::revision_url AcsSc.ftscontentprovider.url.news_item AcsSc.ftscontentprovider.url.news_item (private) AcsSc.ftscontentprovider.url.news_item->etp::revision_url ad_url ad_url (public) etp::revision_url->ad_url db_1row db_1row (public) etp::revision_url->db_1row db_string db_string (public) etp::revision_url->db_string

Testcases:
No testcase defined.

etp::search::etp_page_revision (public)

 etp::search::etp_page_revision [ -array_name array_name ]

Sample Custom content type search proc We are allowed to add/modify the elements for the search compatible datasource array via upvar

Switches:
-array_name (optional)

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.

etp::search_impl_exists_p (public)

 etp::search_impl_exists_p -content_type content_type

checks for the existence of a search service contract implementation and returns 1 if it exists, and 0 is it does not

Switches:
-content_type (required)
Author:
Dave Bauer

Partial Call Graph (max 5 caller/called nodes):
%3 etp::create_search_impl etp::create_search_impl (public) etp::search_impl_exists_p etp::search_impl_exists_p etp::create_search_impl->etp::search_impl_exists_p acs_sc_binding_exists_p acs_sc_binding_exists_p (public) etp::search_impl_exists_p->acs_sc_binding_exists_p

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

# edit-this-page/tcl/etp-sc-procs.tcl
# implements OpenFTS Search service contracts
# Dave Bauer dave@thedesignexperience.org
# 2002-08-13

# Right now I am leaving the keywords blank
# in the future we should either extract them from the META keyword tag
# or allow assignment of cr_keywords to static_pages

# 2003-01-13 added procs to create new service contract implementations
# when a new application type is added -DaveB


namespace eval etp {}

d_proc etp::revision_datasource {
    object_id
} {
    Returns a search package compatible array
    @author Dave Bauer
} {
        
    db_0or1row revision_datasource ""     -column_array datasource
    set content_type [acs_object_type $object_id]
    
    ns_log debug "etp::revision_datasource: content_type=$content_type"
    # call a specially named proc to extend search content for
    # this content_type if it exists
    # we pass in the name of the tcl array for the datasource
    # which the proc can modify if it likes to add additional
    # content to be indexed.

    if {[info commands "etp::search::$content_type"] ne ""} {
    [etp::search::$content_type -array_name "datasource"]
    }

    return [array get datasource]
}

d_proc etp::revision_url {
    object_id
} {
    returns the url of an etp page revision 
    @author Dave Bauer
} {
    db_1row revision_url {}
  
    set package_url [db_string package_url {} -default "/"]
    
    return [string trimright "[ad_url]${package_url}${url}" "index"]
}

d_proc etp::create_search_impl {
    {-content_type:required}
} {
    Creates and registers a service contract implementation alias
    for an ETP custom application type if it does not already exist.

    This will define the datasource proc for the type as
    etp::revision_datasource. That proc will attempt to call a specially
    named tcl proc of the form etp::content_type where content_type is the
    acs_object type of the content type. If the proc does not exist only the
    attributes of the default type will be used to create the datasource.
    @author Dave Bauer
} {
     db_transaction {
        # create the implementation if it does not exist
        if {![etp::search_impl_exists_p -content_type $content_type]} {
            db_exec_plsql create_search_impl {}
            db_exec_plsql create_datasource_alias {}
            db_exec_plsql create_url_alias {}
        }
        # install the binding if it does not exist
        if {[acs_sc_binding_exists_p "FtsContentProvider" $content_type] != 1} {
            db_exec_plsql install_binding {}
        }
    } on_error {
        ns_log Error "etp::create_search_impl: Service contract implementation for content type \"${content_type}\" is not valid"
    }
}
    

d_proc etp::search_impl_exists_p {
    {-content_type:required}
} {
    checks for the existence of a search service contract implementation
    and returns 1 if it exists, and 0 is it does not
    @author Dave Bauer
} {
    # check for service contract here
    ns_log debug "etp::search_impl_exists_p: search_contract_exists_p content type=$content_type
                   exists_p=[acs_sc_binding_exists_p FtsContentProvider $content_type]"
    return [acs_sc_binding_exists_p FtsContentProvider $content_type]
}

namespace eval etp::search {}

d_proc etp::search::etp_page_revision {
    {-array_name ""}
} {
    Sample Custom content type search proc
    We are allowed to add/modify the elements for the
    search compatible datasource array via upvar
} {
    if {([info exists array_name] && $array_name ne "")} {
    upvar search_array $array_name
    ns_log debug "etp::search::etp_page_revision: arrayname:$array_name"
    }
}