Class cpm

Description

CpmFetch allows you to easily access and display information from your Coppermine Photo Gallery (CPG) in a variety of ways. CpmFetch respects the privacy settings in your gallery and will not display images the public would not be allowed to see normally.

By using CpmFetch you can access:

  • images
  • comments
  • descriptions
  • statistics,
  • last added media
  • random media
then output them to HTML, RSS, Text, Avatars, and more.

CpmFetch will also return just data so that you can use it to query the database, then format the output to your specific needs.

CpmFetch is NOT a modification to CPG - you do not need to worry about it interfering with future CPG upgrades, or breaking your existing gallery.

Located in /cpmfetch/cpmfetch.php (line 50)

cpm_dao
   |
   --cpm
Method Summary
 cpm cpm ([string $config_file = ""])
 void cpm_close ()
 void cpm_formatStats (string $format)
 void cpm_getAlbumListFrom (string $source, int $rows,  $columns, [mixed $options = ""], int $colums)
 void cpm_getCategoryList ([mixed $options = ""])
 number cpm_getMediaCountAddedInLast (int $numberOfDays)
 number cpm_getMediaCountAddedSince (string $timestamp)
 number cpm_getMediaCountForAlbum (int $albumid)
 string cpm_getVersion ()
 void cpm_listMediaAddedOverLastDays (int $numberOfDays, [array $options = ""])
 number cpm_listMediaCountFrom (string $source)
 mixed cpm_setReturnType ([string $_type = "print"])
 void cpm_showAlbumsUpdatedOverLastDays (int $numberOfDays, [array $options = ""])
 void cpm_showCategoriesUpdatedOverLastDays (int $numberOfDays, [array $options = ""])
 void cpm_viewLastAddedMediaFrom ( $source, int $rows, int $columns, [array $options = ""], int $catid)
 void cpm_viewLastCommentedImages (int $rows, int $columns, [array $options = ""])
 void cpm_viewLastUpdatedAlbumsFrom (int $source, int $rows, int $columns, [array $options = ""])
 void cpm_viewMediaByPid (number $pid, [mixed $options = ""])
 void cpm_viewMostVotedMediaFrom (string $source, int $rows, int $columns, [array $options = ""])
 void cpm_viewRandomMediaFrom ( $source, int $rows, int $columns, [array $options = ""], int $sources)
 void cpm_viewRandomMostViewedMediaFrom (string $source, int $rows, int $columns, [array $options = ""])
 void cpm_viewRandomTopRatedMediaFrom (string $source, int $rows, int $columns, [array $options = ""])
 void cpm_viewTopRatedMediaFrom (string $source, int $rows, int $columns, [array $options = ""])
 void debugPrint (string $string)
Methods
Constructor cpm (line 92)

Creates the CpmFetch object

The function creates and initializes the CpmFetch system. You need to pass it the filename and path to your configuration file. Typically this is cpmfetch_config.php, but you are allowed to have multiple config files, so it may be different.

cpm cpm ([string $config_file = ""])
  • string $config_file: Path and filename (path to cpmfetch_config.php)
cpm_close (line 105)

Closes down open database connections and cleans up

This will insure that any open database connections are closed if CpmFetch opened them. In a forum environment, you may need to ommit this call. This should be safe as PHP will clean up open connections on its own. But you should use it unless you have a problem with it.

void cpm_close ()
cpm_formatStats (line 379)

Outputs stats based on a format submitted

The format is specified by placeholders indicated by percent signs '%'. If you actually want a percent sign you will need to put two percent signs in a row '%%'. The most up to date list for supported placeholders can be found in the coppermine_dao formatStats function. But the main ones are:

  • %f - file count
  • %a - album count
  • %c - category count
  • %v - view count
  • %n - comment count (note count)
For example: "There are %f files in %c categories containing %a albums, having served %v views and getting %n comments" This supports the returnType setting except for type resultset. Returns nothing in that case.

  • since: Version 0.7
void cpm_formatStats (string $format)
  • string $format: The format template to output in
cpm_getAlbumListFrom (line 609)

Generates a list of Albums based

void cpm_getAlbumListFrom (string $source, int $rows,  $columns, [mixed $options = ""], int $colums)
  • string $source
  • int $rows
  • int $colums
  • mixed $options
  • $columns
cpm_getCategoryList (line 637)
void cpm_getCategoryList ([mixed $options = ""])
  • mixed $options: A valid CpmFetch options array
cpm_getMediaCountAddedInLast (line 258)

Returns number of items in the gallery for a time range

The results include private entries added in the number of days specified by the $numberOfDays

  • return: Shows the number of items in the gallert
number cpm_getMediaCountAddedInLast (int $numberOfDays)
  • int $numberOfDays: The number of days going back from now to include
cpm_getMediaCountAddedSince (line 228)

Returns number of items in the gallery, including private entries added since the date provided by the timestamp parameter

Returns number of items in the gallery added since the timestamp.

number cpm_getMediaCountAddedSince (string $timestamp)
  • string $timestamp: A valid php timestamp
cpm_getMediaCountForAlbum (line 355)

Returns number representing the number of items in an album, including private entries

Does not Supports returnType,

  • return: Representing the count for a specific album
  • since: Version 0.5
number cpm_getMediaCountForAlbum (int $albumid)
  • int $albumid: Number representing the album number
cpm_getVersion (line 127)

Return the version of CpmFetch you are running.

  • return: representing the version of CpmFetch that is running
string cpm_getVersion ()
cpm_listMediaAddedOverLastDays (line 1216)

Displays a list of category, album and count over past days. Supports the setReturnType option.

void cpm_listMediaAddedOverLastDays (int $numberOfDays, [array $options = ""])
  • int $numberOfDays: The number of days going back to be included.
  • array $options: Optional, Configuration options
cpm_listMediaCountFrom (line 295)

Returns number of items in the gallery, including private entries, as defined by source or source = "" for everything

Returns value of items in the gallery By Default prints the number directly to output. Supports returnType for print and html

number cpm_listMediaCountFrom (string $source)
  • string $source: A valid CpmFetch source string
cpm_setReturnType (line 150)

Sets how most functions will handle returning information

This sets the output from any calls made after this. Output can be selected by setting this function with:

  • print (default) - This causes most functions to dump the results in HTML directly to the output
  • html - returns a string containing all the HTML for the results
  • resultset - returns an array of associative arrays representing the real data
Note: this will change the behavior of CpmFetch from this point forward, not for just the next call. You can call this as many times as you need to. If you call it with no parameters it will be set back to the default (print).

  • return: - string if set to html, array if set to resultset
mixed cpm_setReturnType ([string $_type = "print"])
  • string $_type: - set to "html", "print", or "resultset"
cpm_showAlbumsUpdatedOverLastDays (line 1128)

Displays a list of albums with thumbnails and count over past days

Supports the setReturnType option.

void cpm_showAlbumsUpdatedOverLastDays (int $numberOfDays, [array $options = ""])
  • int $numberOfDays: The number of days going back to be included.
  • array $options: Optional, Configuration options
cpm_showCategoriesUpdatedOverLastDays (line 1040)

Displays a list of albums with icons and count over past days

This function does not currently use the stylehash functionality. Supports the setReturnType option.

void cpm_showCategoriesUpdatedOverLastDays (int $numberOfDays, [array $options = ""])
  • int $numberOfDays: The number of days going back to be included.
  • array $options: Optional, Configuration options
cpm_viewLastAddedMediaFrom (line 532)

Displays images of last added media for a specific category

This will generate a table and populate it with the last added media and style it based on entries in the style hash. The number of photos returned matches the number of rows multiplied by the number of columns. Supports the setReturnType option.

void cpm_viewLastAddedMediaFrom ( $source, int $rows, int $columns, [array $options = ""], int $catid)
  • int $rows: The number of rows desired in the output
  • int $columns: The number of columns desired in the output
  • int $catid: The category id of the album you want to display
  • array $options: Optional, Configuration options
  • $source
cpm_viewLastCommentedImages (line 870)

Displays last comments with images

This will generate a table and populate it with the last commented images The number of photos returned matches the number of rows multiplied by the number of columns. Supports the setReturnType option. This acts like many others excet you now have two new subtitle and title options %C - Which is the comment itself, and %a - which is the author of the comment.

void cpm_viewLastCommentedImages (int $rows, int $columns, [array $options = ""])
  • int $rows: The number of rows desired in the output
  • int $columns: The number of columns desired in the output
  • array $options: Optional, Configuration options
cpm_viewLastUpdatedAlbumsFrom (line 673)

This (in thoery returns the last updated albums and the last photo added to them

void cpm_viewLastUpdatedAlbumsFrom (int $source, int $rows, int $columns, [array $options = ""])
  • int $source: The category id of the album you want to display
  • int $rows: The number of rows desired in the output
  • int $columns: The number of columns desired in the output
  • array $options: Optional, Configuration options
cpm_viewMediaByPid (line 828)

Selects one media item by the CPG pid (Picture Id)

void cpm_viewMediaByPid (number $pid, [mixed $options = ""])
  • number $pid: A valid picture id number from your gallery
  • mixed $options: A valid CpmFetch options array
cpm_viewMostVotedMediaFrom (line 936)
void cpm_viewMostVotedMediaFrom (string $source, int $rows, int $columns, [array $options = ""])
  • string $source: A valid CpmFetch source string
  • int $rows: The number of rows desired in the output
  • int $columns: The number of columns desired in the output
  • array $options: Optional, Configuration options
cpm_viewRandomMediaFrom (line 571)

Displays random images from specific album or category

This will generate a table and populate it with random media from the combination of categories and albums specified and style it based on entries in the style hash. The number of photos returned matches the number of rows multiplied by the number of columns. Supports the setReturnType option.

void cpm_viewRandomMediaFrom ( $source, int $rows, int $columns, [array $options = ""], int $sources)
  • int $rows: The number of rows desired in the output
  • int $columns: The number of columns desired in the output
  • int $sources: The sources you want to draw from ("cat=1,4,5:album=6,7,8")
  • array $options: Optional, Configuration options
  • $source
cpm_viewRandomMostViewedMediaFrom (line 970)
void cpm_viewRandomMostViewedMediaFrom (string $source, int $rows, int $columns, [array $options = ""])
  • string $source: A valid CpmFetch source string
  • int $rows: The number of rows desired in the output
  • int $columns: The number of columns desired in the output
  • array $options: Optional, Configuration options
cpm_viewRandomTopRatedMediaFrom (line 1003)
void cpm_viewRandomTopRatedMediaFrom (string $source, int $rows, int $columns, [array $options = ""])
  • string $source: A valid CpmFetch source string
  • int $rows: The number of rows desired in the output
  • int $columns: The number of columns desired in the output
  • array $options: Optional, Configuration options
cpm_viewTopRatedMediaFrom (line 901)
void cpm_viewTopRatedMediaFrom (string $source, int $rows, int $columns, [array $options = ""])
  • string $source: A valid CpmFetch source string
  • int $rows: The number of rows desired in the output
  • int $columns: The number of columns desired in the output
  • array $options: Optional, Configuration options
debugPrint (line 117)

Used for printing debug information. If will output the parameter directly, preceeding it with a newline, then inside HTML blockquote tag, followed by a newline.

void debugPrint (string $string)
  • string $string: Text to be output

Inherited Methods

Inherited From cpm_dao

 cpm_dao::cpm_debugMode()
 cpm_dao::cpm_setDateFormat()
 cpm_dao::cpm_setFilter()
 cpm_dao::cpm_unlock_private()
 cpm_dao::formatStats()
 cpm_dao::getAlbumCount()
 cpm_dao::getCategoryCount()
 cpm_dao::getCommentCount()
 cpm_dao::getViewcount()

Documentation generated on Tue, 10 Apr 2007 23:00:32 -0400 by phpDocumentor 1.3.0