Class SnapshotViewer

Description

this class implements methods to display snapshots

Located in /program/modules/snapshots/snapshots_view.php (line 70)


	
			
Direct descendents
Class Description
 class SnapshotViewerInline this class implements methods to display snapshots
Variable Summary
 int $area_id
 string $domain
 string $header
 string $introduction
 int $node_id
 null|array $snapshots
 $theme $theme
 int $variant
Method Summary
 SnapshotViewer SnapshotViewer (object &$theme, int $area_id, int $node_id, array $module)
 void add_snapshot_navbar (int $snapshot_index, [ $m = ''])
 array get_snapshots (string $path)
 void get_snapshots_configuration (int $node_id)
 array images_array ()
 void javascript_add_configuration (array $imgs, [string $m = ''])
 void javascript_include_once (string $filename)
 bool run ()
 bool view_raw (array $images)
 bool view_slideshow ()
 bool view_snapshot (int $snapshot_index)
 bool view_thumbnails ()
Variables
int $area_id (line 75)
  • var: $area_id indicates the working area
int $default_showtime = 5 (line 105)
  • var: $default_showtime is the default # of seconds between images in a slideshow
int $dimension (line 96)
  • var: $dimension defines the box size for variant 2
string $domain (line 84)
  • var: $domain language domain where we get our translations from, usually 'm_<modulename>'
string $header (line 87)
  • var: $header the (optional) title to display
string $introduction (line 90)
  • var: $introduction the (optional) introductory text to display
array $module_record (line 81)
  • var: $module_record the module record straight from the database
int $node_id (line 78)
  • var: $node_id indicates the node associated with the snapshots
null|array $snapshots = NULL (line 102)
  • var: $snapshots snapshot information from snapshot directory or NULL if not yet set
string $snapshots_path (line 99)
  • var: $snapshots_path the directory containing the snapshots
$theme $theme (line 72)
  • var: collects the (html) output
int $variant (line 93)
  • var: $variant 1=thumbnails, 2=first, 3=slideshow
Methods
Constructor SnapshotViewer (line 115)

the constructor only stores relevant data for future use

SnapshotViewer SnapshotViewer (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 (currently unused)
  • int $node_id: the node to which this module is connected
  • array $module: the module record straight from the database
add_snapshot_navbar (line 349)

add a navigation bar / tool bar for a snapshot

this bar contains the following elements:

  • double arrow left links to the first snapshot in the series
  • left arrow links to the previous snapshot in the series
  • up arrow links to the thumbnails overview
  • right arrow links to the next snapshot in the series
  • double right arrow links to the last snapshot in the series
  • position indicator (snapshot i from n snapshots) in the form: i/n

  • return: navigation bar added to output
  • todo: clean up this ugly code
void add_snapshot_navbar (int $snapshot_index, [ $m = ''])
  • int $snapshot_index: indicates which element of $snapshots contains the current snapshot
  • $m
get_snapshots (line 475)

retrieve all image files (snapshots) from directory $path

This creates an array containing a (filtered) listing of the images in the directory called $path. These items are suppressed:

  • current directory '.'
  • parent directory '..'
  • index.html (used to 'protect' directory against prying eyes)
  • symbolic links
The files THUMBNAIL_PREFIX* (the thumbnails of images) are a special case: these are used to show a small image in the thumbnail overview.

A second filtering makes sure that the items returned are actually images.

  • return: all snapshots in the directory (could be empty)
  • uses: $CFG;
array get_snapshots (string $path)
  • string $path: the directory to scan (relative to $CFG->datadir)
get_snapshots_configuration (line 633)

retrieve configuration data for this set of snapshots

this routine fetches the configuration from the snapshots table and stores the sanitised information from the various fields in the object variables.

  • return: and information stored in object variables
  • todo: check for information leaks (private path) here?
void get_snapshots_configuration (int $node_id)
  • int $node_id: this key identifies the snapshots series
images_array (line 594)

construct an image configuration array

this steps through the snapshots list and prepares an array. The n'th image (starting at 0) in that array is defined as follows:

img[n][0] = width of the image (in pixels) img[n][1] = height of the image (in pixels) img[n][2] = the url of the image file (src-attribute of the img tag) img[n][3] = the number of seconds to display this image img[n][4] = title to add to the display (document title)

  • return: with image data according to above specification
array images_array ()
javascript_add_configuration (line 558)

construct configuration data for javascript processing

this outputs JavaScript code that is necessary to setup a slideshow. We create a 0-based array img[] with information about all available images. We also plug in a few translations and our own URL-variant.

void javascript_add_configuration (array $imgs, [string $m = ''])
  • array $imgs: contains array with values to convey to javascript code in an array img[]
  • string $m: code readability
javascript_include_once (line 676)

include an external javascript file once

this adds an inclusion of a javascript file once in the document we are creating in $this->theme. If multiple instances of this SnapshowViewer-class exist the file is included only once.

  • return: $filename inluded in $this->theme on the first call, otherwise nothing happens
void javascript_include_once (string $filename)
  • string $filename: name of the js-file relative to /program directory
run (line 131)

task dispatcher

this routine decides what to do and calls the appropriate workhorse routine(s)

  • return: TRUE on success, FALSE otherwise
  • todo: check permissions (ACL) to prevent leaking a private area path to anonymous visitors?
bool run ()

Redefined in descendants as:
view_raw (line 322)

output the raw image data as a tab-delimited file

output format ('|' denotes TAB-character): width | height | image url | displaytime | title

  • return: TRUE on success + output sent directly, FALSE otherwise
bool view_raw (array $images)
view_slideshow (line 306)

show the regular thumbnails overview and then pop-up a full-screen slideshow on top

this is basically the same as the thumbnail overview, be it that we get the effect of 'automagically' entering the slideshow (take it from the top).

  • return: TRUE on success (always)
bool view_slideshow ()
view_snapshot (line 240)

display a single full-size snapshot scaled to the specified dimension

  • return: TRUE on success, FALSE otherwise
bool view_snapshot (int $snapshot_index)
  • int $snapshot_index: indicates the snapshot to show
view_thumbnails (line 191)

display snapshots in the form of 0 or more clickable thumbnails

  • return: TRUE on success + output via $this->theme, FALSE otherwise
bool view_thumbnails ()

Documentation generated on Tue, 28 Jun 2016 19:11:59 +0200 by phpDocumentor 1.4.0