File/program/modules/aggregator/aggregator_view.php

Description

/program/modules/aggregator/aggregator_view.php - interface to the view-part of the module

This file defines the interface with the aggregator-module for viewing content. The interface consists of this function:

    aggregator_view(&$output,$area_id,$node_id,$module)

This function is called from /index.php when the node to display is connected to this module.

Functions
aggregator_view (line 103)

display the aggregated information from the nodes linked to this aggregator

his routine grabs information from other, existing pages, and partially shows the this information followed by a 'read more...' link to the corresponding full page. Two types of pages are currently recognised:

  • htmlpage: a configurable # of paragraphs is displayed
  • snapshots: all images are rotated, with configurable number, time, dimensions
The following showstoppers are taken into account.

  • a page must not be expired or under embargo
  • the corresponding area must be accessible to the user
  • database errors yield an empty list of aggregated pages
  • the number of aggregated pages is limited via a config option
Specifiying a section number rather than a page number is interpreted as specifying the individual pages within that section (the above showstoppers do apply, however). The combination of a limited number of pages AND the ability to specify a section id as shorthand for a collection of pages makes it easy to keep the aggregator page up-to-date with a list of the N latest pages within a section.

Note about the styling of aggregated nodes

The aggregator can be completely styled using a mix of id's and classes. Here is a rough sketch, assuming an aggregator with a non-empty header, non-empty introduction, a single snapshots node and two htmlpage modules. This all takes place within the #content div. Note that the various id's are numbered sequential within the page. Currently the DIVs .aggregator_htmlpage_clear and .aggregator_snapshots_clear are empty and unused.

    h2 .aggregator_header div .aggregator_introduction div .aggregator_snapshots_outer #aggregator_outer_1   h3 .aggregator_snapshots_header # aggregator_header_1   div .aggregator_snapshots_inner #aggregator_inner_1   div .aggregator_snapshots_more #aggregator_more_1   div .aggregator_snapshots_clear #aggregator_clear_1 div .aggregator_htmlpage_outer #aggregator_outer_2   h3 .aggregator_htmlpage_header # aggregator_header_2   div .aggregator_htmlpage_inner #aggregator_inner_2   div .aggregator_htmlpage_more #aggregator_more_2   div .aggregator_htmlpage_clear #aggregator_clear_2 div .aggregator_htmlpage_outer #aggregator_outer_3   h3 .aggregator_htmlpage_header # aggregator_header_3   div .aggregator_htmlpage_inner #aggregator_inner_3   div .aggregator_htmlpage_more #aggregator_more_3   div .aggregator_htmlpage_clear #aggregator_clear_2 ...

  • return: TRUE on success + output via $theme, FALSE otherwise
  • todo: what to do with htmlpages containing h1's and h2's? Get rid of those? Mmmm....
bool aggregator_view (object &$theme, int $area_id, int $node_id, array $module)
  • object &$theme: collects the (html) output
  • int $area_id: identifies the area where $node_id lives
  • int $node_id: the node to which this module is connected
  • array $module: the module record straight from the database
aggregator_view_get_config (line 153)

retrieve the configuration information for this aggregator

  • return: configuration record from db OR a handcrafted set of defaults
array aggregator_view_get_config (int $node_id)
  • int $node_id: identifies the aggregator page
aggregator_view_get_modules (line 204)

retrieve a list of modules suitable for aggregation keyed by module_id

this selectively retrieves the module records for the modules we support. The information is used to determine which nodes to process and we also need a module record for the inline slideshow.

  • return: contains selected module records or empty array on db error
array aggregator_view_get_modules ()
aggregator_view_get_nodes (line 229)

construct an array with the node records to aggregate

this routine converts the comma delimited list of node numbers to an array of node records, ready for further processing.

  • return: ordered list of nodes to aggregate (could be empty)
array aggregator_view_get_nodes (array &$config, array &$tree, array &$modules)
  • array &$config: points to the aggregator configuration
  • array &$tree: points to the (cached) tree of the current area
  • array &$modules: points to array with supported modules
aggregator_view_get_node_from_db (line 321)

retrieve an array with node records straight from the database

this routine constructs a list of 0, 1 or more node records based on the $node_id provided by the caller. The node records are retrieved from the database.

This routine takes care of the showstoppers like embargo and expiry and also access permissions to the area. We can not be sure if the user actually has access to a page until we are have checked to area in which the node $node_id resides. This is an extra test compared to above.

  • return: ordered list of nodes to aggregate (could be empty)
array aggregator_view_get_node_from_db (int $node_id, array &$config, array &$modules)
  • int $node_id: identifies page or section to evaluate
  • array &$config: points to the aggregator configuration
  • array &$modules: points to array with supported modules
aggregator_view_get_node_from_tree (line 264)

construct an array with node records using cached tree in current area

this routine constructs a list of 0, 1 or more node records based on the $node_id provided by the caller. The node records are retrieved from the cached tree in &$tree (from $theme->tree).

This routine takes care of the showstoppers like embargo and expiry but not the area because we already have access to this area otherwise we would not be here in the aggregator module in this area.

  • return: ordered list of nodes to aggregate (could be empty)
array aggregator_view_get_node_from_tree (int $node_id, array &$config, array &$tree, array &$modules)
  • int $node_id: identifies page or section to evaluate
  • array &$config: points to the aggregator configuration
  • array &$tree: points to the (cached) tree of the current area
  • array &$modules: points to array with supported modules
aggregator_view_htmlpage (line 399)

construct a title, summary and readmore prompt for an htmlpage page

this routine uses a heuristic approach to snip N paragraphs from the actual text in the html-page. Because we cannot be sure that stripos() is available we resort to first changing any '<P' to '<p ' and subsequently searching the string until the N+1'th '<p '. The offset we calculate this way should contain exactly N paragraphs. Obviously this assumes (dangerous...) that the htmlpage page_data actually contains paragraphs. However, if not enough '<p strings are found, the complete page is used. Heuristics...

  • return: ordered list of nodes to aggregate (could be empty)
array aggregator_view_htmlpage (int $counter, object &$theme, array &$node, array &$config)
  • int $counter: is a sequential number identifying the aggregated nodes
  • object &$theme: points to theme where the output goes
  • array &$node: points to the node record of this htmlpage
  • array &$config: points to the aggregator configuration
aggregator_view_snapshots (line 471)

construct a title, inline slideshow and readmore prompt for a snapshots page

this routine uses the SnapshotViewerInline class to generate a rotating inline slideshow. This leans very heavily on JavaScript. If JavaScript is not enabled, that class has a fall-back showing the first N images statically. Graceful degradation...

  • return: ordered list of nodes to aggregate (could be empty)
array aggregator_view_snapshots (int $counter, object &$theme, array &$node, array &$config, arrat &$modules)
  • int $counter: is a sequential number identifying the aggregated nodes
  • object &$theme: points to theme where the output goes
  • array &$node: points to the node record of this htmlpage
  • array &$config: points to the aggregator configuration
  • arrat &$modules: points to list of records of supported modules

Documentation generated on Tue, 28 Jun 2016 19:08:05 +0200 by phpDocumentor 1.4.0