callback::search::action::impl::syndicate (private)

 callback::search::action::impl::syndicate

Defined in packages/search/tcl/syndicate-procs.tcl

create or replace the record in the syndication table for the given object_id See photo-album-search-procs for an example of what you need to do in the FtsContentProvider datasource proc to make something syndicable. JCD: to fix: should not just glue together XML this way, also assumes rss 2.0, no provision for alternate formats, assumes content:encoded will be defined in the wrapper.

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log ad_log (public) apm_package_id_from_key apm_package_id_from_key (public) db_dml db_dml (public) lc_time_fmt lc_time_fmt (public) parameter::get parameter::get (public) callback::search::action::impl::syndicate callback::search::action::impl::syndicate callback::search::action::impl::syndicate->ad_log callback::search::action::impl::syndicate->apm_package_id_from_key callback::search::action::impl::syndicate->db_dml callback::search::action::impl::syndicate->lc_time_fmt callback::search::action::impl::syndicate->parameter::get

Testcases:
No testcase defined.
Source code:
    ::callback::search::action::contract__arg_parser {*}$args

    if {![parameter::get -boolean  -package_id [apm_package_id_from_key search]  -parameter Syndicate  -default 0]} {
        return
    }
    if {$action eq "DELETE"} {
        db_dml nuke {delete from syndication where object_id = :object_id}
    } else {
        upvar $datasource d

        if {![info exists d(syndication)]} {
            return
        }

        array set syn {
            category {}
            author {}
            guid {}
        }

        array set syn $d(syndication)

        set object_id $d(object_id)
        set url $syn(link)
        set body $d(content)

        set published [lc_time_fmt $syn(pubDate) "%a, %d %b %Y %H:%M:%S GMT"]

        set xmlMap [list & "&amp;" < "&lt;" > "&gt;" \" "&quot;" ' "&apos;"]
        set rss_xml_frag " <item>
  <title>[string map $xmlMap $d(title)]</title>
  <link>[string map $xmlMap $url]</link>
  <guid isPermaLink=\"true\">[string map $xmlMap $syn(guid)]</guid>
  <description>[string map $xmlMap $syn(description)]</description>
  <author>[string map $xmlMap $syn(author)]</author>
  <content:encoded><!\[CDATA\[$body]]></content:encoded>
  <category>[string map $xmlMap $syn(category)]</category>
  <pubDate>$published</pubDate>
 </item>"

        db_dml nuke {delete from syndication where object_id = :object_id}

        #
        # Null character is forbidden in a database bind variable. We
        # replace it with the empty string when found.
        #
        set sanitized 0
        incr sanitized [regsub -all \x00 $rss_xml_frag {} rss_xml_frag]
        incr sanitized [regsub -all \x00 $body {} body]
        #
        # If we had to sanitize the content, we complain in the server
        # log: probably one of the binary-to-text conversion is broken
        # or needs to be revised.
        #
        if {$sanitized > 0} {
            ad_log warning "Attempt to introduce forbidden characters in the syndication table by object ${object_id}"
        }

        db_dml insert {insert into syndication(object_id, rss_xml_frag, body, url)
            values (:object_id, :rss_xml_frag, :body, :url)
        }
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: