- Publicity: Public Only All
etp-procs.tcl
Helper procedures for Edit This Page
- Location:
- packages/edit-this-page/tcl/etp-procs.tcl
- Created:
- 31 May 2001
- Author:
- Luke Pond dlpond@pobox.com
- CVS Identification:
$Id: etp-procs.tcl,v 1.35 2024/08/21 11:29:02 gustafn Exp $
Procedures in this file
- etp::check_write_access (public)
- etp::define_application (public)
- etp::define_content_type (public)
- etp::get_application_param (public)
- etp::get_application_params (public)
- etp::get_attribute_data_type (public)
- etp::get_attribute_default (public)
- etp::get_attribute_desc (public)
- etp::get_attribute_descriptors (public)
- etp::get_attribute_html (public)
- etp::get_attribute_id (public)
- etp::get_attribute_lookup_sql (public)
- etp::get_attribute_name (public)
- etp::get_attribute_pretty_name (public)
- etp::get_content_items (public)
- etp::get_content_type (public)
- etp::get_defined_applications (public)
- etp::get_etp_link (public)
- etp::get_etp_url (public)
- etp::get_ext_attribute_columns (public)
- etp::get_folder_id (public)
- etp::get_latest_revision_id (public)
- etp::get_live_revision_id (public)
- etp::get_name (public)
- etp::get_pa (private)
- etp::get_page_attributes (public)
- etp::get_subtopics (public)
- etp::make_content_type (public, deprecated)
- etp::make_page (public)
- etp::modify_application (public)
Detailed information
etp::check_write_access (public)
etp::check_write_access
- Author:
- Luke Pond
- Created:
- 2001-08-29 Designed to be used at the top of every ETP admin page. Returns an HTTP 403 Access Denied and aborts page processing if the user doesn't have "write" permission for the current package.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::define_application (public)
etp::define_application name params
TODO: Need documentation TODO: Check the parameters passed in
- Parameters:
- name (required)
- params (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::define_content_type (public)
etp::define_content_type content_type pretty_name pretty_plural \ attribute_metadata
Call this at server startup time to register the extended page attributes for a particular content type. It ensures that there is a corresponding entry in acs_object_types for the content type, and that for each of the extended page attributes given there is an appropriate entry in acs_attributes. Also, a namespace variable stores all extended page attributes in memory data structure for quick retrieval.
Extended page attribute values are stored in the acs_attribute_values table (so-called "generic" storage) to prevent the necessity of creating a table for each content type. This is the reason we're not using the attribute procs defined in the acs-subsite package, as they only support type-specific storage.
NOTE: get the attribute metadata right the first time. If you decide to add a new attribute to an existing object type, the procedure will create it for you. But it won't process updates to existing attributes or remove them. You'll have to do that by hand.
- Parameters:
- content_type (required)
- The content type you're registering. This name must be unique across all pages that must store extended page attributes.
- pretty_name (required)
- The display name for the content type
- pretty_plural (required)
- The plural form of the display name
- attribute_metadata (required)
- A list of records describing each extended page attribute. Each record is a list containing the following values (in sequence):
# TODO: other features are needed such as making an attribute optional # and also specifying options for select lists.
- attribute_name
- pretty_name
- pretty_plural
- datatype (must be one of the entries in acs_datatypes: string, boolean, number, integer, date, etc.)
- html (a string containing html attributes for the input control. useful attributes are "size=X" to specify the size of standard input controls, and "rows=X cols=X" to specify the size of a textarea. Textareas will be used only if the datatype is string and html specifies rows or cols.)
- default_value (can either be a string denoting a single default value, or the name of a callback function you've defined in the etp namespace which is used to provide values for select lists).
- Author:
- Luke Pond
- Created:
- 2001-05-31
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_application_param (public)
etp::get_application_param param_name [ app ]
NYI: Need documentation
- Parameters:
- param_name (required)
- app (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_application_params (public)
etp::get_application_params [ app ]
NYI: Need documentation
- Parameters:
- app (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_attribute_data_type (public)
etp::get_attribute_data_type attribute_desc
- Parameters:
- attribute_desc (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_attribute_default (public)
etp::get_attribute_default attribute_desc
- Parameters:
- attribute_desc (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_attribute_desc (public)
etp::get_attribute_desc name content_type
returns the attribute descriptor for the given attribute. works for extended attributes defined by the given content_type as well as for the standard attributes (title, description, and content). (the documentation for etp_make_content_type explains what's in an attribute descriptor contains)
- Parameters:
- name (required)
- content_type (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_attribute_descriptors (public)
etp::get_attribute_descriptors content_type
returns a list of attribute descriptors for the given content_type. this includes standard attributes as well as extended attributes.
- Parameters:
- content_type (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_attribute_html (public)
etp::get_attribute_html attribute_desc
- Parameters:
- attribute_desc (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_attribute_id (public)
etp::get_attribute_id attribute_desc
- Parameters:
- attribute_desc (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_attribute_lookup_sql (public)
etp::get_attribute_lookup_sql attribute_desc
- Parameters:
- attribute_desc (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_attribute_name (public)
etp::get_attribute_name attribute_desc
- Parameters:
- attribute_desc (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_attribute_pretty_name (public)
etp::get_attribute_pretty_name attribute_desc [ page_name ]
- Parameters:
- attribute_desc (required)
- page_name (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_content_items (public)
etp::get_content_items [ -orderby orderby ] [ -limit limit ] \ [ -where where ] [ -package_id package_id ] \ [ -result_name result_name ] [ args... ]
- Switches:
- -orderby (optional)
- -limit (optional)
- -where (optional)
- -package_id (optional)
- -result_name (optional, defaults to
"content_items"
)- Author:
- Luke Pond
- Created:
- 2001-06-10
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_content_type (public)
etp::get_content_type [ name ]
- Parameters:
- name (optional)
- specify "index" to get the index_content_type parameter. otherwise returns the content_type parameter. Returns the content_type specified in the package parameters.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_defined_applications (public)
etp::get_defined_applications
returns a list of all defined applications
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_etp_link (public)
etp::get_etp_link
- Author:
- Luke Pond
- Created:
- 2001-05-31 If the current package is an instance of Edit This Page, and the user has write access, returns the html "Edit This Page" link which should be displayed at the bottom of the page.
This may be called either from your master template, or from individual pages that are used within an ETP package instance. It incurs 1 database hit to do the permissions check. The package type is acquired via the in-memory copy of the site-nodes layout.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_etp_url (public)
etp::get_etp_url
- Author:
- Luke Pond
- Created:
- 2001-05-31 If the current package is an instance of Edit This Page, and the user has write access, returns the URL to where you can edit the current page.
This may be called either from your master template, or from individual pages that are used within an ETP package instance. It incurs 1 database hit to do the permissions check. The package type is acquired via the in-memory copy of the site-nodes layout.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_ext_attribute_columns (public)
etp::get_ext_attribute_columns content_type
Constructs some dynamic SQL to get each of the extended page attributes. note that the attribute values are stored for each *revision*, so we look them up based on the live revision id, not on the item id.
- Parameters:
- content_type (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_folder_id (public)
etp::get_folder_id package_id
- Parameters:
- package_id (required)
- Returns:
- content folder associated with package_id etp package instance
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_latest_revision_id (public)
etp::get_latest_revision_id package_id name
- Parameters:
- package_id (required)
- name (required)
- Author:
- Luke Pond
- Created:
- 2001-06-10 Returns the latest revision id for the given content item.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_live_revision_id (public)
etp::get_live_revision_id package_id name
- Parameters:
- package_id (required)
- name (required)
- Author:
- Luke Pond
- Created:
- 2001-06-10 Returns the published ("live") revision id for the given content item.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_name (public)
etp::get_name
- Author:
- Luke Pond
- Created:
- 2001-06-10 Returns the canonical page name for the current request.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_pa (private)
etp::get_pa package_id name [ content_type ]
- Parameters:
- package_id (required)
- The package_id for the current request
- name (required)
- The page name of the current request.
- content_type (optional)
- Returns:
- The tcl array (in list form) of page attributes. Does the real work of setting up the page-attribute array, which is then fed to the cache. The (package_id name) combination uniquely identifies a page.
- Author:
- Luke Pond
- Created:
- 2001-05-31
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::get_page_attributes (public)
etp::get_page_attributes [ -package_id package_id ]
- 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.
etp::get_subtopics (public)
etp::get_subtopics
- Author:
- Luke Pond
- Created:
- 2001-06-13 Creates a variable named "subtopics" in the caller's context. This is a multirow result set suitable for passing to an index template, containing all the structured data necessary to present a list of links to subtopics. The columns in the "subtopics" query are:
- name
- title
- description
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::make_content_type (public, deprecated)
etp::make_content_type content_type pretty_name pretty_plural \ attribute_metadata
Deprecated. Invoking this procedure generates a warning.
- Parameters:
- content_type (required)
- pretty_name (required)
- pretty_plural (required)
- attribute_metadata (required)
- See Also:
- define_content_type
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::make_page (public)
etp::make_page name [ title ] [ item_id ]
- Parameters:
- name (required)
- the name of the page you wish to create in the current package Creates a new page (content item) with the given name by inserting a row into the cr_items table, and creates an initial revision by inserting a row into the cr_revisions table.
- title (optional, defaults to
"Untitled"
)- item_id (optional)
- Author:
- Luke Pond
- Created:
- 2001-05-31
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
etp::modify_application (public)
etp::modify_application name params
TODO: Need documentation TODO: Check the parameters passed in
- Parameters:
- name (required)
- params (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.