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):
- 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" # # 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 {[ad_conn -get revision_id] eq ""} { # asking for the live published revision array set pa [util_memoize [list etp::get_pa $package_id $name $content_type] $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] } } errorMsg] } { # # This part of the code is a weird construct: If the page # does not exist, an exception is raised. In practice, # requests for non-existing pages happens quite often and # should not raise exceptions. Since unfortunately, no # exception code is set, we check here for the error # message. # if {$errorMsg ne "Query did not return any rows"} { ns_log warning "etp::get_pa revision_id '[ad_conn -get revision_id]'" "package_id '[ad_conn package_id]' raised exception:" $errorMsg } # 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