Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

Overview

ResourceSpace has multiple metadata field types such as:

  • Text box (single or multi line)
  • Check box lists
  • Dropdown lists
  • Date fields
  • Category trees
  • Radio button lists
  • And many more

Some of these fields can have their options defined by an administrator of the system. These fields are called fixed list fields. An up to date list of which fields are of fixed list type can be found in include/definitions.php, as $FIXED_LIST_FIELD_TYPES.

A fixed list field option is saved as a node internally and its value (ie node name) is broken down into keywords using the add_node_keyword_mappings().

Coding around nodes

All functions that affect nodes should live in include/node_functions.php.

Node structure

Whenever the code refers to a node, unless explicitly mentioned otherwise, always assume the node structure will be:

Array
(
    [ref] => 232
    [resource_type_field] => 3
    [name] => United Kingdom
    [parent] => 
    [orderby] => 30 
)

Core node functions

The following are considered to be core functions for working with nodes:

  • set_node() - Used for both creating and saving a node in the database. Use NULL for ref if you just want to insert a new record.
  • delete_node()
  • delete_nodes_for_resource_type_field()
  • get_node() - Get a specific node by its ref
  • get_nodes() - Get all nodes from the database for a specific metadata field or parent. Use $parent = NULL and recursive = TRUE to get all nodes for a field. IMPORTANT: recursive should only be used for category tree types.
  • is_parent_node()
  • get_tree_node_level() - Determine how many level deep a node is.
  • get_root_node_by_leaf() - Find node ID of the root parent when searching by one of the leaves ID
  • reorder_node()
  • reorder_nodes()
  • get_node_order_by() - Calculate the next order by for a new record
  • add_node_keyword()
  • remove_node_keyword()
  • remove_all_node_keyword_mappings() - Removes all indexed keywords for a specific node ref
  • check_node_indexed()
  • add_node_keyword_mappings()
  • remove_node_keyword_mappings()
  • get_nodes_from_keywords()

The core node functions MUST not check any form of access control as these functions are considered low level. They are used by other functions such as save_resource_data() which are aware of the context they run within and can easily determine the access level required.

Database model snippet

nodes_db_model

From a data model perspective, the resource_type_field can have multiple nodes associated with it.

Each node name is indexed and the keywords are associated with the node. This allows multiple nodes to be associated with keywords which drastically improves performance since keywords are indexed only once.