Main Navigation interface class.
Basically, this class proxies all requests to a midcom_helper__basicnav class. See the interface definition of it for further details.
Additionally this class implements a couple of helper functions to make common NAP tasks easier.
Important note: Whenever you add new code to this class, or extend it through inheritance, never call the proxy-functions of basicnav directly, this is strictly forbidden.
Located in /midcom.core/midcom/helper/nav.php (line 27)
Create a NAP instance for the given context. If unspecified, it uses the currently active context which should be sufficient in most cases.
Construct source data for a breadcrumb line.
Gives you the data needed to construct a line like 'Start > Topic1 > Topic2 > Article' using NAP to traverse upwards till the root node. The components custom breadcrumb data is inserted at the end of the computed breadcrumb line after any set NAP leaf.
See get_breadcrumb_line for a more end-user oriented way of life.
Return Value
The breadcrumb data will be returned as a list of associative arrays each containing these keys:
Adding custom data
Custom elements are added to this array by using the MidCOM custom component context at this time. You need to add a list with the same structure as above into the custom component context key midcom.helper.nav.breadcrumb. (This needs to be an array always, even if you return only one element.)
Note, that the URL you pass in that list is always prepended with the current anchor prefix. It is not possible to specify absolute URLs there. No leading slash is required.
Example:
Construct a breadcrumb line.
Gives you a line like 'Start > Topic1 > Topic2 > Article' using NAP to traverse upwards till the root node. $separator is inserted between the pairs, $class, if non-null, will be used as CSS-class for the A-Tags.
The parameter skip_levels indicates how much nodes should be skipped at the beginning of the current path. Default is to show the complete path. A value of 1 will skip the home link, 2 will skip the home link and the first subtopic and so on. If a leaf or node is selected, that normally would be hidden, only its name will be shown.
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'.)
Retrieve the ID of the currently displayed node. Defined by the topic of the component that declared able to handle the request.
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.
Returns the ID of the node to which $leaf_id is associated to, false on failure.
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.
Returns the ID of the node to which $node_id is associated to, false on failure. The root node's uplink is -1.
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.
This function returns the toolbar definition for the NAP object passed. This must supersede all calls to $nap_object[MIDCOM_NAV_TOOLBAR] as this information is not usable directly - it would result from the MidCOM cache and thus be out of date always (and especially not adapted to the current user).
Implementation note: This is a hotfix, that works around the current problem. It is not very performant if you query large numbers of NAP toolbars at this time. We have some basic caching in this function, but nevertheless we need a better solution here.
Checks if the given node is within the tree of another node.
List all child elements, nodes and leaves alike, of the node with ID $parent_node_id. For every child element, an array of ID and type (node/leaf) is given as
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.
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.
This function tries to resolve a guid into a NAP object.
The code is optimized trying to avoid a full-scan if possible. To do this it will treat topic and article guids specially: In both cases the system will translate it using the topic id into a node id and scan only that part of the tree non-recursively.
A full scan of the NAP data is only done if another MidgardObject is used.
Note: If you want to resolve a GUID you got from a Permalink, use the Permalinks service within MidCOM, as it covers more objects then the NAP listings.
This function provides an interface to construct links like 'View this page'.
It takes the currently displayed content element (either a leaf or node) and constructs the respective URL relative to the root of the website as passed to the function.
Documentation generated on Fri, 10 Oct 2008 22:05:19 +0300 by phpDocumentor 1.4.2