attribute-procs.tcl

Procs to help with attributes for object types

Location:
packages/acs-subsite/tcl/attribute-procs.tcl
Created:
Thu Dec 7 10:30:57 2000
Author:
mbryzek@arsdigita.com
CVS Identification:
$Id: attribute-procs.tcl,v 1.20.2.10 2024/02/08 18:04:04 gustafn Exp $

Procedures in this file

Detailed information

ad_page_contract_filter_proc_attribute_dynamic_p (public)

 ad_page_contract_filter_proc_attribute_dynamic_p name value_varname

Checks whether the value (assumed to be an integer) is an attribute of a dynamic type.

Parameters:
name (required)
value_varname (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/30/2000

Testcases:
acs_subsite_attributes

attribute::add (public)

 attribute::add [ -default default ] [ -min_n_values min_n_values ] \
    [ -max_n_values max_n_values ] object_type datatype pretty_name \
    pretty_plural

wrapper for the acs_attribute.create_attribute call. Note that this procedure assumes type-specific storage.

Switches:
-default (optional)
-min_n_values (optional)
-max_n_values (optional)
Parameters:
object_type (required)
datatype (required)
pretty_name (required)
pretty_plural (required)
Returns:
The attribute_id of the newly created attribute
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/2000

Testcases:
acs_subsite_attributes

attribute::add_form_elements (public)

 attribute::add_form_elements [ -form_id form_id ] \
    [ -start_with start_with ] [ -object_type object_type ] \
    [ -variable_prefix variable_prefix ]

Adds form elements to the specified form_id. Each form element corresponds to an attribute belonging to the given object_type.

Switches:
-form_id (optional)
ID of a form to add form elements to.
-start_with (optional, defaults to "acs_object")
Object type to start with. Defaults to acs_object.
-object_type (optional, defaults to "acs_object")
Object type to extract attributes for. Defaults to acs_object.
-variable_prefix (optional)
Variable prefix.

Testcases:
No testcase defined.

attribute::array_for_type (public)

 attribute::array_for_type [ -start_with start_with ] \
    [ -include_storage_types include_storage_types ] array_name \
    enum_array_name object_type

Fills in 2 arrays used for displaying attributes

Switches:
-start_with (optional, defaults to "acs_object")
-include_storage_types (optional, defaults to "type_specific")
Parameters:
array_name (required)
The name of the array to hold the basic attribute information. The attributes defined are: * array_name(pretty_name:$name) The pretty_name of the attribute * array_name(id:$name) The attribute_id of the attribute * array_name(datatype:$name) The datatype of the attribute
enum_array_name (required)
The name of the array to hold the pretty name of the values of an enumeration. This is only used when the datatype of the attribute_name is enumeration. This array is a mapping from "$attribute_name:enum_value" to value_pretty_name.
object_type (required)
The object for which we are looking up attributes
Returns:
A list of all the names of attributes we looked up. This list can be used to iterated through the arrays:
            set attr_list [attribute::array_for_type attr_props enum_values "group"]
            foreach key $attr_list {
                set attribute_id $attr_props(id:$attribute_name)
                ...
            }
        
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
1/8/2001

Testcases:
No testcase defined.

attribute::datatype_to_sql_type (private)

 attribute::datatype_to_sql_type [ -default default ] table column \
    datatype

Returns the appropriate sql type for a table definition based on the table, column, datatype, and default value. Note that for default values, this proc automatically generates appropriate constraint names as well.

Switches:
-default (optional)
If specified, we add a default clause to the SQL statement
Parameters:
table (required)
column (required)
datatype (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/2000

Testcases:
No testcase defined.

attribute::datatype_validator_exists_p (public)

 attribute::datatype_validator_exists_p datatype

Returns 1 if we have a validator for this datatype. 0 otherwise. We currently do not support the "date" datatype and hardcoded support for enumeration. This is hardcoded in this procedure. Also, this procedure assumes that validators are procedures named ::template::data::validate::$datatype

Parameters:
datatype (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/2000

Testcases:
acs_subsite_attribute_datatypes

attribute::delete (public)

 attribute::delete attribute_id

Delete the specified attribute id and all its values. This is irreversible. Returns 1 if the attribute was actually deleted. 0 otherwise.

Parameters:
attribute_id (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/2000

Testcases:
acs_subsite_attributes

attribute::exists_p (public)

 attribute::exists_p [ -convert_p convert_p ] object_type \
    orig_attribute

Returns 1 if the object type already has an attribute of the given name.

Switches:
-convert_p (optional, defaults to "t")
If t, we convert the attribute using plsql_utility::generate_oracle_name
Parameters:
object_type (required)
orig_attribute (required)
The attribute in which we are interested. Note that if convert_p is set to t, we will internally look for the converted attribute name
Returns:
1 if the object type already has an attribute of the specified name. 0 otherwise
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/2000

Testcases:
acs_subsite_attributes

attribute::multirow (public)

 attribute::multirow [ -start_with start_with ] \
    [ -include_storage_types include_storage_types ] \
    [ -datasource_name datasource_name ] [ -object_type object_type ] \
    [ -return_url return_url ] object_id

Sets up a multirow datasource containing the attribute values of object_id. We only support specific storage attributes. We include all attributes of the object's type, or any of its supertypes, up to $start_with.

Switches:
-start_with (optional, defaults to "acs_object")
-include_storage_types (optional, defaults to "type_specific")
-datasource_name (optional, defaults to "attributes")
-object_type (optional)
-return_url (optional)
Parameters:
object_id (required)

Testcases:
No testcase defined.

attribute::translate_datatype (public)

 attribute::translate_datatype datatype

translates the datatype into one that can be validated. Default datatype is text (when no validator is found)

Parameters:
datatype (required)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/2000

Testcases:
acs_subsite_attribute_datatypes

attribute::value_add (public)

 attribute::value_add attribute_id enum_value sort_order

adds the specified enumeration value to the attribute.

Parameters:
attribute_id (required)
The attribute to which we are adding
enum_value (required)
The value which we are adding to the enum
sort_order (required)
Author:
Ben Adida <ben@openforce.net>
Created:
08/2001

Testcases:
acs_subsite_attributes

attribute::value_delete (public)

 attribute::value_delete attribute_id enum_value

deletes the specified enumeration value from the attribute. The net effect is that this attribute will have one fewer options for acceptable values.

Parameters:
attribute_id (required)
The attribute from which we are deleting
enum_value (required)
The value of we are deleting
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/2000

Testcases:
acs_subsite_attributes
[ show source ]