midcom_helper_navMain 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/helper/nav.php (line 27)
string
get_breadcrumb_line
([string $separator = " > "], [string $class = null], int $skip_levels, [string $current_class = null])
midcom_helper__basicnav
$_basicnav
(line 35)
A reference to the basicnav instance in use.
int
$_contextid
(line 43)
The context ID we're accociated with.
Create a NAP instance for the given context. If unspecified, it uses the currently active context which should be sufficient in most cases.
This function provides an interface to construct links like "Edit 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 AIS instance as passed to the function.
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.
Compute a toolbar out of the NAP information for a given leaf and its node. Merges both toolbars into one. Always based on a leaf.
You can either pass a leaf structure, a leaf id or null. I the last case the current leaf is used. If the current leaf is undefined, the class will return the current node toolbar instead.
The information from the component will be post-processed so that the URLs point to the right location in NAP.
It uses _check_toolbar_permission to ascertain if the user can edit the leaf/node.
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. (Remeber 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.
Compute a toolbar out of the NAP information for a given leaf.
You can either pass a leaf structure, a leaf id or null. I the last case the current leaf is used. If the current leaf is undefined, the class will return null.
The information from the component will be post-processed so that the URLs point to the right location in NAP.
It uses _check_toolbar_permission to ascertain if the user can edit a leaf.
Returns the ID of the node to which $leaf_id is accociated 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.
Compute a toolbar out of the NAP information for a given node.
You can either pass a node structure, a node id or null. I the last case the current node is used.
The information from the component will be post-processed so that the URLs point to the right location in NAP.
It uses _check_toolbar_permission to ascertain if the user can edit a node.
Returns the ID of the node to which $node_id is accociated 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 superseed 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 unkown parent node ID) you will get FALSE.
Shortcut function, which creates a combined leaf/node-toolbar and renders it immediately.
Shortcut function, which creates a leaf-toolbar and renders it immediately.
Shortcut function, which creates a node-toolbar and renders it immediately.
This function tries to resolve a guid into an 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-recursivly.
A full scan of the NAP data is only done if another MidgardObject is used.
Generate a fully automated navigation.
On the same basis of config data, as show_simple_nav, this function builds a navigation that does not make a structural difference between nodes and leaves, only in markup. It uses the list_child_elements() method of NAP and thus honors topic's user-defined NAVORDER settings.
Generate a fully automated navigation.
This method will print a simple navigation tree. It uses CSS both for line formatting and for indentation. This method starts automatically at the root node, the root node's leaves will not be shown.
Here is a configuration example that can be copy&pasted, everything is mandatory:
- <?php
- // These are CSS-classes, don't set them if you don't have any classes
- // no class=... tags will be written out then
- $config["css_div_leaf_selected"] = "nav_leaf_selected";
- $config["css_div_leaf_unselected"] = "nav_leaf_unselected";
- $config["css_div_node_selected"] = "nav_node_selected";
- $config["css_div_node_unselected"] = "nav_node_unselected";
- $config["css_a_leaf_unselected"] = "nav_leaf_unselected";
- $config["css_a_node_unselected"] = "nav_node_unselected";
- // Prefix automatically prepended to any displayed leaves or nodes,
- // leave empty if you don't want them.
- // It must include trailing spaces if you want them between prefix and element name!
- $config["leaf_prefix"] = "» ";
- $config["node_prefix"] = "";
- // These are css lenght's used to build up the indentation
- $config["indent_size"] = "15";
- $config["indent_linewrap"] = "5";
- $config["indent_unit"] = "px";
- // other Miscellaneous configuration parameters
- // This one controls wether leaves or subnodes are displayed first
- $config["leaves_first"] = true;
- ?>
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.
Checks for the toolbar permissions, uses the cache variables $_user and $_admin to cache the data against repeated calls.
Documentation generated on Mon, 21 Nov 2005 18:19:38 +0100 by phpDocumentor 1.3.0RC3