File/program/lib/statisticslib.php

Description

/program/lib/statisticslib.php - statistics

Functions
job_statistics (line 41)

main entry point for statistics (called from admin.php)

Produce a simple ordered table of pages with # of page views for one area or for all areas the user is allowed to access.

Note: Even though expired pages are no longer visible for visitors, the # of views is still displayed. Pages under embargo are completely suppressed.

  • return: results are returned as output in $output
  • todo: this routine is a little bit too long, it should be split into smaller chunks
void job_statistics (object &$output)
  • object &$output: collects the html output
statistics_embargo (line 226)

check ancestors for embargo

ascend the tree via $parent_id to see if there is an embargo. the quest ends when we reach a top level section (indicated by $id == $parent_id) or a section that was examined before (indicated through the existence of the flag element in the $section). before we start recursing we set that flag just to be sure we don't end up in an endless loop if somehow the tree structure is not sane (contains circular references).

  • return: TRUE if under embargo, FALSE otherwise
bool statistics_embargo (array &$sections, string &$now, int $id)
  • array &$sections: holds pertinent information about sections in selected areas
  • string &$now: current time to check agains the embargo time
  • int $id: section id
statistics_get_pages (line 261)

construct an ordered list of pages to show in a statistics report

strategy:

  • start with all pages in selected area(s) NOT under embargo
  • retrieve all sections in selected areas(s)
  • for all pages: if none of the ancestors is under embargo then keep page in $pages[]
If anything goes wrong, return FALSE, otherwise an array with the selected pages

It would be nice if we could simply select $limit records from the database at $offset. Unfortunately we cannot be sure if a page is elegible for display until we have examined the ancestors so we have to retrieve them and perhaps later discard them. oh well, there's room for improvement.

  • return: FALSE on error, array with pages otherwise (could be empty)
bool|array statistics_get_pages (array &$areas, int|null $area_id)
  • array &$areas: list of areas available to the current user
  • int|null $area_id: area of interest or NULL indicating all areas in $areas[]
statistics_show_area_menu (line 176)

show a menu of available areas

output a menu, starting with an entry to show _all_ available areas, followed by links to individual areas. If there is only a single area, the 'all areas' link is suppressed

  • return: results are returned as output in $this->output
void statistics_show_area_menu (object &$output, array &$areas, [int|null $current_area_id = NULL])
  • object &$output: collects the html output
  • array &$areas: list of all areas available for this user
  • int|null $current_area_id: the current area

Documentation generated on Tue, 28 Jun 2016 19:12:09 +0200 by phpDocumentor 1.4.0