Class Node

Description

/program/lib/node.class.php - taking care of nodes

This file defines a class for dealing with nodes.

  • author: Peter Fokker <peter@berestijn.nl>
  • version: $Id: node.class.php,v 1.2 2011-02-03 14:04:04 pfokker Exp $
  • copyright: Copyright (C) 2008-2011 Ingenieursbureau PSD/Peter Fokker
  • todo: we probably need to get rid of this file because it is not used (2010-12-07/PF)
  • license: GNU AGPLv3+Additional Terms

Located in /program/lib/node.class.php (line 30)


	
			
Variable Summary
 mixed $node_exists
 mixed $node_path
Method Summary
 Node Node ([ $requested_node = NULL], [ $requested_area = NULL])
 bool|array calculate_node (integer|null $node, integer|null $area, array &$node_path)
 void exists ()
 void get_area_id ()
 void get_node_path ()
Variables
mixed $node_exists = FALSE (line 32)
mixed $node_path = array() (line 34)
Methods
Constructor Node (line 36)
Node Node ([ $requested_node = NULL], [ $requested_area = NULL])
  • $requested_node
  • $requested_area
calculate_node (line 111)

determine which node should be displayed based on user's request

In total there are 4 cases for node n and area a:

  1. n defined, a defined return n if it is visible and it matches with a and a is visible, otherwise FALSE
2. n defined, a undefined return n if n is visible and the corresponding a is visible, otherwise FALSE

3. n undefined, a defined return the default n in the specified a if a is active or FALSE if not found

4. n undefined, a undefined return the default n in the default a or FALSE if no active default area exists

Cases 1 and 2 might lead to a node that is not available (ie expired or under embargo). In order to not 'give away' information about the possible existence of the requested node, we simply return FALSE, indicating that the node was not found.

There is a potential problem with a request for a node that is of type 'section' (i.e. not a page that eventually yields actual content). The problem is that in that case we should look for a valid page-type node in that section-type node. The question is whether we should look for a default page in a (default) subsection or not (nested default). Currently the strategy is to look for the first suitable page if available, and otherwise descend into the first suitable subsection and try again repeatedly until we find a page or we reach the end of the tree.

Note: As a side effect of this function, the path from the area root to the final page is calculated. This navigation path is returned in the variable reference $node_path.

Calculation of this navigation path is necessary in order to determine the visibility of a node; if a section-type node higher in the tree is not available, all underlying nodes should also not be available. IOW: not anly do we have to check the actual node, we need to check all parent nodes too.

The array returned in $node_path is keyed with the node_id, i.e. the array element $node_path[$node_id] yields the database record for node $node_id.

Note that we check the node embargo date and the expiry date in two separate expressions rather than using the 'BETWEEN low AND high' because you never can be sure if it is inclusive low/high or not and the database might assume the low is always smaller than high.

  • return: an array with valid node record and $node_path filled or FALSE if no node could be found
  • todo: refactor into two different functions: one for specified node, other for unspecified node
bool|array calculate_node (integer|null $node, integer|null $area, array &$node_path)
  • integer|null $node: the requested node number or null if none specified
  • integer|null $area: the requested area number or null if none specified
  • array &$node_path: this referenced variable receives the (valid) path to the node to show
exists (line 46)
void exists ()
get_area_id (line 54)
void get_area_id ()
get_node_path (line 50)
void get_node_path ()

Documentation generated on Wed, 11 May 2011 23:45:31 +0200 by phpDocumentor 1.4.0