Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -r1.73 -r1.74 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 30 Jan 2007 11:36:07 -0000 1.73 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 17 Feb 2007 23:01:36 -0000 1.74 @@ -215,281 +215,16 @@ return $sql } - - Page proc rss_head { - -channel_title - -link - -description - {-language en-us} - } { -# - return " - - - $channel_title - $link - $description - $language - xowiki" - } - - Page proc rss_item {-creator -title -link -guid -description -pubdate } { - append result \n\ - $creator \n\ - $title \n\ - $link \n\ - "" $guid \n\ - $description \n\ - $pubdate \n\ - \n - } - - Page proc rss_tail {} { - return "\n\n\n" - } - - Page ad_proc rss { - -maxentries - -days - -package_id:required - } { - Report content of xowiki folder in rss 2.0 format. The - reporting order is descending by date. The title of the feed - is taken from the title, the description - is taken from the description field of the folder object. + Page proc import {-user_id -package_id -folder_id {-replace 0} -objects} { + my log "DEPRECATED" + if {![info exists package_id]} {set package_id [::xo::cc package_id]} + set cmd [list $package_id import -replace $replace] - @param maxentries maximum number of entries retrieved - @param days report entries changed in speficied last days - @param package_id to determine the xowiki instance - - } { - set folder_id [::$package_id folder_id] - - set limit_clause [expr {[info exists maxentries] ? " limit $maxentries" : ""}] - set timerange_clause [expr {[info exists days] ? - " and p.last_modified > (now() + interval '$days days ago')" : ""}] - - set xmlMap { & & < < > > \" " ' ' } - - set content [my rss_head \ - -channel_title [string map $xmlMap [::$folder_id set title ]] \ - -description [string map $xmlMap [::$folder_id set description]] \ - -link [ad_url][site_node::get_url_from_object_id -object_id $package_id] \ - ] - - db_foreach get_pages \ - "select s.body, p.name, p.creator, p.title, p.page_id,\ - p.object_type as content_type, p.last_modified, p.description \ - from xowiki_pagex p, syndication s, cr_items i \ - where i.parent_id = $folder_id and i.live_revision = s.object_id \ - and s.object_id = p.page_id $timerange_clause \ - order by p.last_modified desc $limit_clause \ - " { - - if {[string match "::*" $name]} continue - if {$content_type eq "::xowiki::PageTemplate::"} continue - - set description [string trim $description] - if {$description eq ""} {set description $body} - regexp {^([^.]+)[.][0-9]+(.*)$} $last_modified _ time tz - - if {$title eq ""} {set title $name} - #append title " ($content_type)" - set time "[clock format [clock scan $time] -format {%a, %d %b %Y %T}] ${tz}00" - append content [my rss_item \ - -creator [string map $xmlMap $creator] \ - -title [string map $xmlMap $title] \ - -link [::$package_id pretty_link -absolute true $name] \ - -guid [ad_url]/$page_id \ - -description [string map $xmlMap $description] \ - -pubdate $time \ - ] - } - - append content [my rss_tail] - #set t text/plain - set t text/xml - ns_return 200 $t $content + if {[info exists user_id]} {lappend cmd -user_id $user_id} + if {[info exists objects]} {lappend cmd -objects $objects} + eval $cmd } - - Page ad_proc google-sitemapindex { - {-changefreq "daily"} - {-priority "priority"} - } { - Provide a sitemap index of all xowiki instances in google site map format - https://www.google.com/webmasters/sitemaps/docs/en/protocol.html - - @param maxentries maximum number of entries retrieved - @param package_id to determine the xowiki instance - @param changefreq changefreq as defined by google - @param priority priority as defined by google - - } { - - set content { - -} - db_foreach get_xowiki_packages {select package_id - from apm_packages p, site_nodes s - where package_key = 'xowiki' and s.object_id = p.package_id} { - set last_modified [db_string get_newest_modification_date \ - "select last_modified from acs_objects where package_id = $package_id \ - order by last_modified desc limit 1"] - - regexp {^([^.]+)[.][0-9]+(.*)$} $last_modified _ time tz - set time "[clock format [clock scan $time] -format {%Y-%m-%dT%T}]${tz}:00" - - my log "--site_node::get_from_object_id -object_id $package_id" - array set info [site_node::get_from_object_id -object_id $package_id] - - append content \n\ - [ad_url]$info(url)?gsm \n\ - $time \n\ - - } - append content \n - set t text/plain - #set t text/xml - ns_return 200 $t $content - } - - Page ad_proc google-sitemap { - -maxentries - -package_id:required - {-changefreq "daily"} - {-priority "0.5"} - } { - Report content of xowiki folder in google site map format - https://www.google.com/webmasters/sitemaps/docs/en/protocol.html - - @param maxentries maximum number of entries retrieved - @param package_id to determine the xowiki instance - @param changefreq changefreq as defined by google - @param priority priority as defined by google - - } { - set folder_id [::$package_id folder_id] - - set limit_clause [expr {[info exists maxentries] ? " limit $maxentries" : ""}] - set timerange_clause "" - set xmlMap { & & < < > > \" " ' ' } - - set content { - -} - db_foreach get_pages \ - "select s.body, p.name, p.creator, p.title, p.page_id,\ - p.object_type as content_type, p.last_modified, p.description \ - from xowiki_pagex p, syndication s, cr_items i \ - where i.parent_id = $folder_id and i.live_revision = s.object_id \ - and s.object_id = p.page_id $timerange_clause \ - order by p.last_modified desc $limit_clause \ - " { - - if {[string match "::*" $name]} continue - if {$content_type eq "::xowiki::PageTemplate::"} continue - - regexp {^([^.]+)[.][0-9]+(.*)$} $last_modified _ time tz - - set time "[clock format [clock scan $time] -format {%Y-%m-%dT%T}]${tz}:00" - append content \n\ - [::$package_id pretty_link -absolute true $name] \n\ - $time \n\ - $changefreq \n\ - $priority \n\ - \n - } - - append content \n - set t text/plain - #set t text/xml - ns_return 200 $t $content - } - - - Page proc import {-user_id -package_id -folder_id {-replace 0} -objects} { - set object_type [self] - if {![info exists folder_id]} {set folder_id [$object_type require_folder -name xowiki]} - if {![info exists package_id]} {set package_id [ad_conn package_id]} - if {![info exists user_id]} {set user_id [ad_conn user_id]} - if {![info exists objects]} {set objects [$object_type allinstances]} - - set msg "processing objects: $objects

" - set added 0 - set replaced 0 - set updated 0 - array set excluded_var { - folder_id 1 package_id 1 absolute_links 1 lang_links 1 - publish_status 1 item_id 1 revision_id 1 last_modified 1 parent_id 1 - } - foreach o $objects { - $o set parent_id $folder_id - $o set package_id $package_id - $o set creation_user $user_id - # page instances have references to page templates, add these first - if {[$o istype ::xowiki::PageInstance]} continue - set item_id [CrItem lookup -name [$o set name] -parent_id $folder_id] - if {$item_id != 0} { - if {$replace} { ;# we delete the original - ::Generic::CrItem delete -item_id $item_id - set item_id 0 - incr replaced - } else { - ::Generic::CrItem instantiate -item_id $item_id - foreach var [$o info vars] { - if {![info exists excluded_var($var)]} { - $item_id set $var [$o set $var] - } - } - $item_id save - incr updated - } - } - if {$item_id == 0} { - $o save_new - incr added - } - } - - foreach o $objects { - if {[$o istype ::xowiki::PageInstance]} { - db_transaction { - set item_id [CrItem lookup -name [$o set name] -parent_id $folder_id] - if {$item_id != 0} { - if {$replace} { ;# we delete the original - ::Generic::CrItem delete -item_id $item_id - set item_id 0 - incr replaced - } else { - ::Generic::CrItem instantiate -item_id $item_id - foreach var [$o info vars] { - if {![info exists excluded_var($var)]} { - $item_id set $var [$o set $var] - } - } - $item_id save - incr updated - } - } - if {$item_id == 0} { ;# the item does not exist -> update reference and save - set old_template_id [$o set page_template] - set template [CrItem lookup \ - -name [$old_template_id set name] \ - -parent_id $folder_id] - $o set page_template $template - $o save_new - incr added - } - } - } - $o destroy - } - append msg "$added objects newly inserted, $updated object updated, $replaced objects replaced

" - } - # # tag management, get_tags works on instance or gobally #