Class midcom_helper__basicnav

Description

This class is the basic building stone of the Navigation Access Point System of MidCOM.

It is responsible for collecting the available Information and for building the navigational Tree out of it. This class is only the internal interface to the NAP System and is used by midcom_helper_nav as a node cache. The framework should ensure that only one class of this type is active at one time.

Basicnav will give you a very abstract view of the content tree, modified by the NAP classes of the components. You can retrieve a node/leaf tree of the content, and for each element you can retrieve a URL name and a long name for Navigation display.

Leaves and Nodes are both indexed by Integer constants which are assigned by the framework. The framework defines two starting points in this tree: The root node and the "current" node. The current node defined through the topic of the component that declared to be able to handle the request.

The class will load the necessary information on demand to minimize database traffic.

The interface functions should enable you to build any navigation tree you desire. The public nav class will give you some of those high-level functions.

Node data interchange format

Node NAP data consists of a simple key => value array with the following keys required by the component:

  • MIDCOM_NAV_NAME => The Real (= displayable) name of the element
  • MIDCOM_NAV_TOOLBAR => Toolbar data (see below)
  • MIDCOM_META_CREATOR => Creator of the element (MidgardPerson)
  • MIDCOM_META_CREATED => Creation date (UNIX Timestamp)
  • MIDCOM_META_EDITOR => Last modifier of the element (MidgardPerson)
  • MIDCOM_META_EDITED => Last modification date (UNIX Timestamp)
Other keys delivered to NAP users include:

  • MIDCOM_NAV_URL => The URL name of the element, which is automatically defined by NAP.
Leaf data interchange format

Basically for each leaf the usual meta information is returned:

  • MIDCOM_NAV_URL => URL of the leaf element
  • MIDCOM_NAV_NAME => Name of the leaf element
  • MIDCOM_META_CREATOR => Creator of the element (MidgardPerson)
  • MIDCOM_META_CREATED => Creation date (UNIX Timestamp)
  • MIDCOM_META_EDITOR => Last modifier of the element (MidgardPerson)
  • MIDCOM_META_EDITED => Last modification date (UNIX Timestamp)
  • MIDCOM_NAV_GUID => Optional argument denoting the GUID of the referred element
  • MIDCOM_NAV_SORTABLE => Optional argument denoting whether the element is sortable
  • MIDCOM_NAV_TOOLBAR => Toolbar data (see below)
Both MIDCOM_NAV_SITE and MIDCOM_NAV_ADMIN are both deprecated. MIDCOM_NAV_ADMIN for good, but MIDCOM_NAV_SITE will still support backwards compatibility.

Backwards support for MIDCOM_NAV_SITE is an array that contains both MIDCOM_NAV_URL and MIDCOM_NAV_NAME

 MIDCOM_NAV_SITE => array
 (
     MIDCOM_NAV_URL  => URL of the leaf element
     MIDCOM_NAV_NAME => Name of the leaf element
 ),

The Datamanager will automatically transform (3) to the syntax described in (1) by copying the values.

Important note: The difference outlined above is only valid for leaves (read "articles"), because the topic structure is essentially the same in both AIS and live Site.

Toolbar Syntax

You can add toolbars to your NAP information, that can be used for simple on-site editing. They are indexed using integers and consist of an midcom_helper_toolbar::add_item() compatible array with one exception: The URL is always relative to the AIS topic welcome page, but see the example (it assumes that the referenced l10n libraries are available, of course):

  1.  $toolbar[0Array (
  2.      MIDCOM_TOOLBAR_URL => '',
  3.      MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create article'),
  4.      MIDCOM_TOOLBAR_HELPTEXT => null,
  5.      MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_new.png',
  6.      MIDCOM_TOOLBAR_ENABLED => true
  7.  );
  8.  $toolbar[100Array(
  9.      MIDCOM_TOOLBAR_URL => 'config/',
  10.      MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('component configuration'),
  11.      MIDCOM_TOOLBAR_HELPTEXT => $this->_l10n_midcom->get('component configuration helptext'),
  12.      MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_folder-properties.png',
  13.      MIDCOM_TOOLBAR_ENABLED => true
  14.  );

You can now use a similar in your leaf data and place further buttons between these two using indexes like 50,51,52.

DEPRECATED INFORMATION

Key MIDCOM_NAV_VISIBLE is deprecated from MidCOM 2.4.0 on, visibility is taken into account automatically. The key is set to true for all values now for backwards compatibility and will be removed entirely in MidCOM 2.6.0

Keys MIDCOM_NAV_ADMIN and MIDCOM_NAV_SITE are both deprecated as of MidCOM 2.8. MIDCOM_NAV_ADMIN will not work at all and MIDCOM_NAV_SITE will still be supported during the transition phase, but only if either MIDCOM_NAV_URL or MIDCOM_NAV_NAME are empty.

Located in /midcom.core/midcom/helper/_basicnav.php (line 129)


	
			
Method Summary
midcom_helper__basicnav __construct ([int $context = 0])
Array get_leaf (string $leaf_id)
int get_leaf_uplink (string $leaf_id)
Array get_loaded_object_by_guid (GUID $guid)
Array get_node (int $node_id)
int get_node_uplink (int $node_id)
int get_root_node ()
Array list_leaves (int $parent_node, boolean $show_noentry)
Array list_nodes (int $parent_node, boolean $show_noentry)
boolean _check_leaf_id (string $leaf_id)
int _loadNodeData (mixed $node)
void _load_leaves (Array $node)
Methods
Constructor __construct (line 264)

Constructor

The only constructor of the Basicnav class. It will initialize Root-Topic, Current-Topic and all cache arrays. The function will load all nodes between root and current node.

If the current node is behind an invisible or undescendable node, the last known good node will be used instead for the current node.

The constructor retrieves all initialisation data from the component context. A special process is used, if the context in question is of the type MIDCOM_REQUEST_CONTENTADM: The system then goes into Administration Mode, querying the components for the administrative data instead of their regular data. In addition, the root topic is set to the administrated topic instead of the regular root topic. This way you can build up Admin Interface Navigation for "external" trees.

midcom_helper__basicnav __construct ([int $context = 0])
  • int $context: The Context ID for which to create NAP data for, defaults to 0
get_current_leaf (line 1090)

Retrieve the ID of the currently displayed leaf. This is a leaf that is displayed by the handling topic. If no leaf is active, this function returns FALSE. (Remember to make a type sensitve check, e.g.

nav::get_current_leaf() !== false to distinguish "0" and "false".)

  • return: The ID of the leaf in question or false on failure.
int get_current_leaf ()
get_current_node (line 1076)

Retrieve the ID of the currently displayed node. Defined by the topic of the component that declared able to handle the request.

  • return: The ID of the node in question.
int get_current_node ()
get_leaf (line 1309)

This will give you a key-value pair describeing the leaf with the ID $node_id. The defined keys are described above in leaf data interchange format. You will get false if the leaf ID is invalid.

  • return: The leaf-data as outlined in the class introduction, false on failure
Array get_leaf (string $leaf_id)
  • string $leaf_id: The leaf-id to be retrieved.
get_leaf_uplink (line 1351)

Returns the ID of the node to which $leaf_id is associated to, false on failure.

  • return: The ID of the Node for which we have a match, or false on failure.
int get_leaf_uplink (string $leaf_id)
  • string $leaf_id: The Leaf-ID to search an uplink for.
get_loaded_object_by_guid (line 1334)

This is a helper function used by midcom_helper_nav::resolve_guid(). It checks if the object denoted by the passed GUID is already loaded into memory and returns it, if available. This should speed up GUID lookup heavy code.

Access is restricted to midcom_helper_nav::resolve_guid().

  • return: A NAP structure if the GUID is known, null otherwise.
  • access: protected
Array get_loaded_object_by_guid (GUID $guid)
  • GUID $guid: The GUID to look up in the in-memory cache.
get_node (line 1242)

This will give you a key-value pair describeing the node with the ID $node_id. The defined keys are described above in Node data interchange format. You will get false if the node ID is invalid.

  • return: The node-data as outlined in the class introduction, false on failure
Array get_node (int $node_id)
  • int $node_id: The node-id to be retrieved.
get_node_uplink (line 1372)

Returns the ID of the node to which $node_id is associated to, false on failure. The root node's uplink is -1.

  • return: The ID of the Node for which we have a match, -1 for the root node, or false on failure.
int get_node_uplink (int $node_id)
  • int $node_id: The Leaf-ID to search an uplink for.
get_root_node (line 1104)

Retrieve the ID of the root node. Note that this ID is dependent from the ID of the MidCOM Root topic and therefore will change as easily as the root topic ID might. The MIDCOM_NAV_URL entry of the root node's data will always be empty.

  • return: The ID of the root node.
int get_root_node ()
list_leaves (line 1197)

Lists all leaves of $parent_node. If there are no leaves you will get an empty array, if there was an error (for instance an unknown parent node ID) you will get FALSE.

  • return: A list of leaves found, or false on failure.
Array list_leaves (int $parent_node, boolean $show_noentry)
  • int $parent_node: The ID of the node of which the leaves are searched.
  • boolean $show_noentry: Show all objects on-site which have the noentry flag set. This parameter has no effect in AIS.
list_nodes (line 1119)

Lists all Sub-nodes of $parent_node. If there are no subnodes you will get an empty array, if there was an error (for instance an unknown parent node ID) you will get FALSE.

  • return: An Array of Node IDs or false on failure.
Array list_nodes (int $parent_node, boolean $show_noentry)
  • int $parent_node: The id of the node of which the subnodes are searched.
  • boolean $show_noentry: Show all objects on-site which have the noentry flag set. This parameter has no effect in AIS.
_check_leaf_id (line 1270)

Verifies the existence of a given leaf. Call this before getting a leaf from the $_leaves cache. It will load all necessary nodes/leaves as necessary.

  • return: true if the leaf exists, false otherwise.
boolean _check_leaf_id (string $leaf_id)
  • string $leaf_id: A valid NAP leaf id ($nodeid-$leafid pattern).
_loadNodeData (line 875)

Load the Navigational information associated with the topic $param, which can be passed as an ID or as a MidgardTopic object. This is differentiated by the flag $idmode (true for id, false for MidgardTopic).

This method does query the topic for all information and completes it to build up a full NAP data structure

It determines the URL_NAME of the topic automatically using the name of the topic in question.

The currently active leaf is only queried if and only if the currently processed topic is equal to the current context's content topic. This should prevent dynamically loaded components from disrupting active leaf information, as this can happen if dynamic_load is called before showing the navigation.

  • return: One of the MGD_ERR constants
int _loadNodeData (mixed $node)
  • mixed $node: Topic to be processed. Object or ID
_load_leaves (line 940)

Loads the leaves for a given node from the cache or database.

It will relay the code to _get_leaves() and check the object visibility upon return.

void _load_leaves (Array $node)
  • Array $node: The NAP node data structure to load the nodes for.

Documentation generated on Fri, 10 Oct 2008 22:15:19 +0300 by phpDocumentor 1.4.2