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.php (line 50)

cpm_dao
   |
   --cpm
Variable Summary
 mixed $optionHash
 mixed $returntype
 mixed $styleHash
 mixed $VERSION
Method Summary
 cpm cpm ([string $config_file = ""])
 void addDescriptionsToResultSet ( &$resultset)
 void clearOptions ()
 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_getMediaCount ()
 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 = ""])
 void cpm_listMediaCountForAlbum (int $albumid)
 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 = ""])
 string cpm_viewLastAddedMedia (int $rows, int $columns, [array $options = ""])
 void cpm_viewLastAddedMediaFrom ( $source, int $rows, int $columns, [array $options = ""], int $catid)
 void cpm_viewLastAddedMediaFromAlbum (int $rows, int $columns, int $albumid, [array $options = ""])
 void cpm_viewLastAddedMediaFromCategory (int $rows, int $columns, int $catid, [array $options = ""])
 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_viewRandomMedia (int $rows, int $columns, [array $options = ""])
 void cpm_viewRandomMediaFrom ( $source, int $rows, int $columns, [array $options = ""], int $sources)
 void cpm_viewRandomMediaFromAlbum (int $rows, int $columns, int $albumid, [array $options = ""])
 void cpm_viewRandomMediaFromCategory (int $rows, int $columns, int $catid, [array $options = ""])
 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 = ""])
 string createTable ( $resultset,  $rows,  $columns)
 void debugPrint (string $string)
 void getOption ( $optionname)
 void getOptionAttributes ( $elementname)
 void getPrefixToUse ()
 void htmlTagAHREF ( $contents,  $row)
 void htmlTagIMG ( $row)
 void htmlTagTABLE ()
 void htmlTagTD ( $contents,  $row)
 void htmlTagTH ( $contents,  $row)
 void htmlTagTR ()
 void htmlTagTR_END ()
 void insertOptionAttributes ( $elementname,  $key,  $value)
 void loadOptions ([ $options = ""])
Variables
mixed $optionHash = array() (line 63)

This contains the option array that is submitted by the user.

It should be cleared out between calls that use it.

  • access: private
mixed $returntype = "print" (line 77)

Tracks the current returntype. Default is "print"

  • access: private
mixed $styleHash = array() (line 71)

This contains the style information from the option array that is submitted by the user.

It is cleared out between calls that use it.

  • access: private
mixed $VERSION = "@@@RELEASEVERSION@@@" (line 56)

This is the version number of this release of CpmFetch

  • access: private

Redefinition of:
cpm_dao::$VERSION

Inherited Variables

Inherited from cpm_dao

cpm_dao::$cfCfg
cpm_dao::$cfDefaultComments
cpm_dao::$dbconnection
cpm_dao::$filetypefilter
cpm_dao::$lastSQLErrorMessage
cpm_dao::$lastSQLRowsReturned
cpm_dao::$privacyfilter
cpm_dao::$resultArray
cpm_dao::$sqlPostSelect
cpm_dao::$sqlSelect
cpm_dao::$sqlTableSelect
cpm_dao::$sqlUserDataLink
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)
addDescriptionsToResultSet (line 1688)
  • access: private
void addDescriptionsToResultSet ( &$resultset)
  • &$resultset
clearOptions (line 1857)
  • access: private
void clearOptions ()
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_getMediaCount (line 212)

Returns number of items in the gallery, including private entries

Returns value of items in the gallery as a return value. Does not output directly to the screen. This is the same as cpm_listMediaCount() with the returntype set to html.

  • return: Shows the number of items in the gallert
  • todo: allow for media to be specified / filtered - jpg, mp3, etc
  • deprecated: Will be removed in CpmFetch 4. @see cpm_listMediaCount() instead
  • access: private
number cpm_getMediaCount ()
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
  • todo: allow for media to be specified / filtered - jpg, mp3, etc
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
  • todo: allow for media to be specified / filtered - jpg, mp3, etc
  • 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_listMediaCount (line 182)

Gets the number of items in the gallery.

Prints the value directly to output, but now Supports returnType for print and html. This function will include all media, even media protected as private.

  • todo: allow for media to be specified / filtered - jpg, mp3, etc
  • deprecated: Will be removed in CpmFetch 4.0
  • access: private
void cpm_listMediaCount ()
cpm_listMediaCountForAlbum (line 326)

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

By Default prints the number directly to output. Supports returnType for print and html

  • todo: allow for media to be specified / filtered - jpg, mp3, etc
  • deprecated: Will be removed in CpmFetch 4.0
  • since: Version 0.5
  • access: private
void cpm_listMediaCountForAlbum (int $albumid)
  • int $albumid: Number representing the album number
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_viewLastAddedMedia (line 416)

Displays images of last added media

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.

string cpm_viewLastAddedMedia (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_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_viewLastAddedMediaFromAlbum (line 455)

Displays images of last added media for a specific album

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_viewLastAddedMediaFromAlbum (int $rows, int $columns, int $albumid, [array $options = ""])
  • int $rows: The number of rows desired in the output
  • int $columns: The number of columns desired in the output
  • int $albumid: The album id of the album you want to display
  • array $options: Optional, Configuration options
cpm_viewLastAddedMediaFromCategory (line 494)

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_viewLastAddedMediaFromCategory (int $rows, int $columns, int $catid, [array $options = ""])
  • 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
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_viewRandomMedia (line 798)

Displays random images from database

This will generate a table and populate it with the random 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_viewRandomMedia (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_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_viewRandomMediaFromAlbum (line 716)

Displays random images from specific album

This will generate a table and populate it with random media from one album 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_viewRandomMediaFromAlbum (int $rows, int $columns, int $albumid, [array $options = ""])
  • int $rows: The number of rows desired in the output
  • int $columns: The number of columns desired in the output
  • int $albumid: The album id of the album you want to display
  • array $options: Optional, Configuration options
cpm_viewRandomMediaFromCategory (line 757)

Displays random images from specific category

This will generate a table and populate it with random media from one category 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_viewRandomMediaFromCategory (int $rows, int $columns, int $catid, [array $options = ""])
  • 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
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
createTable (line 1302)

Creates a table to display images

This is an internal helper function to construct tables to hold the images.

  • return: (XHTML code)
  • access: private
string createTable ( $resultset,  $rows,  $columns)
  • $resultset
  • $rows
  • $columns
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.

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

Redefinition of:
cpm_dao::debugPrint()
getOption (line 1807)
  • access: private
void getOption ( $optionname)
  • $optionname
getOptionAttributes (line 1840)
  • access: private
void getOptionAttributes ( $elementname)
  • $elementname
getPrefixToUse (line 1657)
  • access: private
void getPrefixToUse ()
htmlTagAHREF (line 1476)
  • access: private
void htmlTagAHREF ( $contents,  $row)
  • $contents
  • $row
htmlTagIMG (line 1611)
  • access: private
void htmlTagIMG ( $row)
  • $row
htmlTagTABLE (line 1379)
  • access: private
void htmlTagTABLE ()
htmlTagTABLE_END (line 1397)
  • access: private
void htmlTagTABLE_END ()
htmlTagTD (line 1443)
  • access: private
void htmlTagTD ( $contents,  $row)
  • $contents
  • $row
htmlTagTH (line 1426)
  • access: private
void htmlTagTH ( $contents,  $row)
  • $contents
  • $row
htmlTagTR (line 1404)
  • access: private
void htmlTagTR ()
htmlTagTR_END (line 1419)
  • access: private
void htmlTagTR_END ()
insertOptionAttributes (line 1820)
  • access: private
void insertOptionAttributes ( $elementname,  $key,  $value)
  • $elementname
  • $key
  • $value
loadOptions (line 1766)

Sets the member $optionHash with user submission

  • access: private
void loadOptions ([ $options = ""])
  • $options

Inherited Methods

Inherited From cpm_dao

 cpm_dao::cpm_dao()
 cpm_dao::addPathInfo()
 cpm_dao::cpm_debugMode()
 cpm_dao::cpm_getConfigEntry()
 cpm_dao::cpm_setDateFormat()
 cpm_dao::cpm_setFilter()
 cpm_dao::cpm_setMediaPrefixes()
 cpm_dao::cpm_unlock_private()
 cpm_dao::createDescription()
 cpm_dao::createlink()
 cpm_dao::createOldFormatDescription()
 cpm_dao::dbConnect()
 cpm_dao::dbDisconnect()
 cpm_dao::dbExecuteSql()
 cpm_dao::debugPrint()
 cpm_dao::destroy()
 cpm_dao::formatStats()
 cpm_dao::getAlbumCount()
 cpm_dao::getAlbumListFrom()
 cpm_dao::getCategoryCount()
 cpm_dao::getCategoryListFrom()
 cpm_dao::getCommentCount()
 cpm_dao::getdefaultimagename()
 cpm_dao::getImageToUse()
 cpm_dao::getLastAddedMediaFrom()
 cpm_dao::getLastImagesWithComments()
 cpm_dao::getLastUpdatedAlbumsFrom()
 cpm_dao::getMediaAddedSince()
 cpm_dao::getMediaAddedToCategoriesSince()
 cpm_dao::getMediaByPid()
 cpm_dao::getMediaCount()
 cpm_dao::getMediaCountAddedSince()
 cpm_dao::getMediaCountForAlbum()
 cpm_dao::getMediaCountFrom()
 cpm_dao::getMostVotedMediaFrom()
 cpm_dao::getRandomImageFrom()
 cpm_dao::getRandomMostViewedMediaFrom()
 cpm_dao::getRandomSeed()
 cpm_dao::getRandomTopRatedMediaFrom()
 cpm_dao::getTopRatedMediaFrom()
 cpm_dao::getViewcount()
 cpm_dao::makeSourceSql()
 cpm_dao::urlEncodeImagePath()

Documentation generated on Fri, 22 Jun 2007 10:16:57 -0400 by phpDocumentor 1.3.0