etp::get_page_attributes (public)

 etp::get_page_attributes [ -package_id package_id ]

Defined in packages/edit-this-page/tcl/etp-procs.tcl

Switches:
-package_id
(optional)
Returns:
Creates the pa variable in the caller's context. Creates an array variable called pa in the caller's stack frame, containing all attributes necessary to render the current page. These attributes include the standard elements from the cr_revisions table such as title, description, and content. If the content_type parameter is provided, any extended page attributes that correspond to it will be included. See docs for etp::make_content_type to learn how this works.

Two database accesses are required to create the array variable. Once created, subsequent calls to this method will find the variable in a cache, unless a) any of the page attributes are changed, or b) the page has been flushed from the cache. (flush details TBD).

The complete list of standard attributes in the pa array is as follows:

  • item_id
  • name
  • revision_id
  • title
  • context_bar
  • context
  • description
  • publish_date
  • content
  • extended attributes, if any, defined by etp::make_content_type
Author:
Luke Pond
Created:
2001-05-31

Partial Call Graph (max 5 caller/called nodes):
%3 ad_conn ad_conn (public) ad_log ad_log (public) ad_returnredirect ad_returnredirect (public) ad_script_abort ad_script_abort (public) empty_string_p empty_string_p (public, deprecated) etp::get_page_attributes etp::get_page_attributes etp::get_page_attributes->ad_conn etp::get_page_attributes->ad_log etp::get_page_attributes->ad_returnredirect etp::get_page_attributes->ad_script_abort etp::get_page_attributes->empty_string_p

Testcases:
No testcase defined.
Source code:
    # TODO: I have no idea if ns_cache automatically flushes
    # items that are out of date.  Must find out or risk
    # running out of memory

    set max_age [parameter::get -parameter cache_max_age -default 600]
    
    if {$package_id eq ""} {
        set package_id [ad_conn package_id]
    } 
    if {![string is integer -strict $package_id]} {
       ad_log Warning "package_id <$package_id> is not an integer"
       #error "package_id <$package_id> is not an integer"
       ns_returnnotfound
       ad_script_abort
    }
    if {![string is integer -strict $package_id]} {
       ad_log Warning "package_id <$package_id> is not an integer"
       #
       # This might happen, when no package_id could be determined
       # via [ad_conn package_id]
       #
       ns_returnnotfound
       ad_script_abort
    }
    set name [etp::get_name]
    set content_type [etp::get_content_type $name]

    upvar pa pa

    if { [catch {
    if {[empty_string_p [ad_conn -get revision_id]]} {
        # asking for the live published revision
        set code "etp::get_pa $package_id $name $content_type"
        array set pa [util_memoize $code $max_age]
    } else {
        # an admin is browsing other revisions - do not use caching.
        array set pa [etp::get_pa [ad_conn package_id] $name $content_type]
    }
    } errmsg] } {
    ns_log debug "Error from etp::get_pa was:\n$errmsg"

    # Page not found.  Redirect admins to setup page;
    # otherwise report 404 error.
    if { $name eq "index" && 
         [permission::permission_p -object_id [ad_conn package_id] -privilege admin] } {
        # set up the new content section
        ad_returnredirect "etp-setup-2"
    } else {
        ns_returnnotfound
    }
    # we're done responding to this request, so do no 
    # further processing on this page
    ad_script_abort
    }
Generic XQL file:
packages/edit-this-page/tcl/etp-procs.xql

PostgreSQL XQL file:
packages/edit-this-page/tcl/etp-procs-postgresql.xql

Oracle XQL file:
packages/edit-this-page/tcl/etp-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: