xo::PackageMgr instproc require_site_wide_pages (public)

 <instance of xo::PackageMgr[i]> require_site_wide_pages \
    [ -refetch on|off ] [ -refetch_if_modified on|off ] \
    [ -pages pages ]

Defined in /var/www/openacs.org/packages/xotcl-core/tcl/06-package-procs.tcl

Load site-wide pages from the prototype page directory. The pages are loaded into to site-wide instance. When a page to be loaded exists already, a new revision is added. If no pages are provided, use the list of pages as defined for the package.

Switches:
-refetch (optional, boolean, defaults to "false")
force fresh loading of prototype pages
-refetch_if_modified (optional, boolean, defaults to "false")
refetch when modification date of file is new than the version in the content repository
-pages (optional)
list of pages (without languages prefix) or empty to refer to per-package definition.

Testcases:
xowiki_test_cases
Source code:
#
# When no pages are provided, take the default of the definition of
# the package class.
#
if {$pages eq ""} {
  set pages ${:site_wide_pages}
}
set info [:require_site_wide_info]
foreach n $pages {
  set item_id [::xo::db::CrClass lookup -name en:$n -parent_id [dict get $info folder_id]]
  #:log "lookup en:$n => $item_id"
  if {$item_id == 0} {
    #:log "require_site_wide_pages lookup for 'en:$n' failed"

    #
    # Try to refetch without prefix to support loading of
    # prefix-less pages.
    #
    set item_id [::xo::db::CrClass lookup -name $n -parent_id [dict get $info folder_id]]
    if {$item_id != 0} {
      :log "Page $n was already loaded without a prefix"
    }
  }
  set refetch_this_page $refetch

  #
  # Check, if we have to refetch the page, since it was changed in
  # the meantime in the file-system.
  #
  if {!$refetch_this_page && $item_id != 0 && $refetch_if_modified} {
    set existing_page [::xo::db::CrClass get_instance_from_db -item_id $item_id]
    set fn [:prototype_page_file_name -name $n -package_key ${:package_key}]
    set time [clock scan [::xo::db::tcl_date [$existing_page publish_date] tz_var]]
    if {[ad_file mtime $fn] > $time} {
      set refetch_this_page true
    }
    if {$refetch_this_page} {
      ns_log notice "page $n: refetch newer-than-installed prototype file"
    }
  }
  if {$item_id == 0 || $refetch_this_page} {
    :log "require_site_wide_pages tries to load en:$n"
    set page [:import_prototype_page  -name $n  -parent_id [dict get $info folder_id]  -package_id [dict get $info instance_id] ]
    :log "Page en:$n loaded as '$page'"
  }
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: