[ class tree: functions ] [ index: functions ] [ all elements ]

Procedural File: template-functions.php

Source Location: /template-functions.php

Page Details

Functions used to display content in themes.

Includes
require_once ('controller.php') [line 19]

Invoke the controller to handle requests

[ Top ]

require_once ('class-load.php') [line 14]

Load the classes

[ Top ]


Constants
ALBUM  [line 3678]

ALBUM = 2

[ Top ]

DEFAULT_3GP_HEIGHT  [line 1491]

DEFAULT_3GP_HEIGHT = 304

[ Top ]

DEFAULT_3GP_WIDTHT  [line 1492]

DEFAULT_3GP_WIDTHT = 352

[ Top ]

DEFAULT_MOV_HEIGHT  [line 1489]

DEFAULT_MOV_HEIGHT = 496

[ Top ]

DEFAULT_MOV_WIDTH  [line 1490]

DEFAULT_MOV_WIDTH = 640

[ Top ]

IMAGE  [line 3677]

IMAGE = 1

[ Top ]


Functions
albumNumber  [line 704]

Gets the 'n' for n of m albums


int albumNumber( )

[ Top ]
checkforPassword  [line 3816]

Checks to see if a password is needed displays a password form if log-on is required

Returns true if a login form has been displayed

The password protection is hereditary. This normally only impacts direct url access to an album or image since if you are going down the tree you will be stopped at the first place a password is required.

If the gallery is password protected then every album & image will require that password.

If an album is password protected then all subalbums and images treed below that album will require the password. If there are multiple passwords in the tree and you direct link, the password that is required will be that of the nearest parent that has a password. (The gallery is the ur-parrent to all albums.)

Parameters:
bool   $silent:  set to true to inhibit the logon form

Information Tags:
Since:  1.1.3

bool checkforPassword( [bool $silent = false]  )

[ Top ]
getAlbumCustomData  [line 973]

Returns the custom_data field of the current album


string getAlbumCustomData( )

[ Top ]
getAlbumData  [line 1007]

A composit for getting album data

Parameters:
string   $field:  which field you want


string getAlbumData( string $field  )

[ Top ]
getAlbumDate  [line 876]

Returns the formatted date field of the album

Parameters:
string   $format: 


string getAlbumDate( [string $format = null]  )

[ Top ]
getAlbumDesc  [line 933]

Returns the raw description of the current album.


string getAlbumDesc( )

[ Top ]
getAlbumId  [line 3335]

Returns the record number of the album in the database


int getAlbumId( )

[ Top ]
getAlbumLinkURL  [line 1030]

Returns the album link url of the current album.

Parameters:
   $album: 


string getAlbumLinkURL( [ $album = NULL]  )

[ Top ]
getAlbumPlace  [line 915]

Returns the place of the album.


string getAlbumPlace( )

[ Top ]
getAlbumThumb  [line 1116]

Returns the name of the defined album thumbnail image.


string getAlbumThumb( )

[ Top ]
getAlbumTitle  [line 650]

Returns the raw title of the current album.


string getAlbumTitle( )

[ Top ]
getAllDates  [line 3213]

Retrieves a list of all unique years & months from the images in the gallery

Parameters:
string   $order:  set to 'desc' for the list to be in descending order


array getAllDates( [string $order = 'asc']  )

[ Top ]
getAnnotatedAlbumTitle  [line 670]

Returns an album title taged with of Not visible or password protected status


string; getAnnotatedAlbumTitle( )

[ Top ]
getAnnotatedImageTitle  [line 1531]

Returns the image title taged with not visible annotation.


string getAnnotatedImageTitle( )

[ Top ]
getBareAlbumDesc  [line 944]

Returns a text-only description of the current album.


string getBareAlbumDesc( )

[ Top ]
getBareAlbumTitle  [line 661]

Returns a text-only title of the current album.


string getBareAlbumTitle( )

[ Top ]
getBareGalleryDesc  [line 247]

Returns a text-only description of the gallery.


string getBareGalleryDesc( )

[ Top ]
getBareGalleryTitle  [line 222]

Returns a text-only title of the gallery.


string getBareGalleryTitle( )

[ Top ]
getBareImageDesc  [line 1721]

Returns a text-only description of the current image.


string getBareImageDesc( )

[ Top ]
getBareImageTitle  [line 1522]

Returns a text-only title of the current image.


string getBareImageTitle( )

[ Top ]
getCommentAuthorEmail  [line 2637]

Returns the comment author's email


string getCommentAuthorEmail( )

[ Top ]
getCommentAuthorName  [line 2630]

Returns the comment author's name


string getCommentAuthorName( )

[ Top ]
getCommentAuthorSite  [line 2643]

Returns the comment author's website


string getCommentAuthorSite( )

[ Top ]
getCommentBody  [line 2709]

Returns the body of the current comment


string getCommentBody( )

[ Top ]
getCommentCount  [line 2537]

Retuns the count of comments on the current image


int getCommentCount( )

[ Top ]
getCommentDate  [line 2678]

Retrieves the date of the current comment Returns a formatted date

Parameters:
string   $format:  how to format the result


string getCommentDate( [string $format = NULL]  )

[ Top ]
getCommentsAllowed  [line 2556]

Returns true if neither the album nor the image have comments closed


bool getCommentsAllowed( )

[ Top ]
getCommentStored  [line 2610]

Returns the data from the last comment posted

Parameters:
bool   $numeric:  Set to true for old themes to get 0->6 indices rather than descriptive ones


array getCommentStored( [bool $numeric = false]  )

[ Top ]
getCommentTime  [line 2699]

Retrieves the time of the current comment

Returns a formatted time

Parameters:
string   $format:  how to format the result


string getCommentTime( [string $format = '%I:%M %p']  )

[ Top ]
getCurrentPage  [line 387]

Returns the number of albums without printing it.


int getCurrentPage( )

[ Top ]
getCustomAlbumThumb  [line 1180]

Returns a link to a custom sized thumbnail of the current album

Parameters:
int   $size:  the size of the image to have
int   $width:  width
int   $height:  height
int   $cropw:  cropwidth
int   $croph:  crop height
int   $cropx:  crop part x axis
int   $cropy:  crop part y axis


string getCustomAlbumThumb( int $size, [int $width = NULL], [int $height = NULL], [int $cropw = NULL], [int $croph = NULL], [int $cropx = NULL], [int $cropy = null]  )

[ Top ]
getCustomAlbumThumbMaxSpace  [line 1237]

Returns a link to a uncropped custom sized version of the current album thumb within the given height and width dimensions.

Parameters:
int   $width:  width
int   $height:  height


string getCustomAlbumThumbMaxSpace( [int $width = NULL], [int $height = NULL]  )

[ Top ]
getCustomImageURL  [line 2386]

Returns the url to the image in that dimensions you define with this function.

Parameters:
int   $size:  the size of the image to have
int   $width:  width
int   $height:  height
int   $cropw:  cropwidth
int   $croph:  crop height
int   $cropx:  crop part x axis
int   $cropy:  crop part y axis
bool   $thumbStandin:  set true to inhibit watermarking


string getCustomImageURL( int $size, [int $width = NULL], [int $height = NULL], [int $cropw = NULL], [int $croph = NULL], [int $cropx = NULL], [int $cropy = NULL], [bool $thumbStandin = false]  )

[ Top ]
getCustomPageURL  [line 3283]

Produces the url to a custom page (e.g. one that is not album.php, image.php, or index.php)

Parameters:
string   $linktext:  Text for the URL
string   $page:  page name to include in URL
string   $q:  query string to add to url
string   $album:  optional album for the page


string getCustomPageURL( string $page, [string $q = ''], [string $album = ''], string $linktext  )

[ Top ]
getCustomSizedImageMaxSpace  [line 2474]

Returns a link to a uncropped custom sized version of the current image within the given height and width dimensions.

Use for sized images or thumbnails in an album.

Parameters:
int   $width:  width
int   $height:  height


string getCustomSizedImageMaxSpace( [int $width = NULL], [int $height = NULL]  )

[ Top ]
getDefaultHeight  [line 2163]

Returns the height of the default-sized image (in printDefaultSizedImage)


int getDefaultHeight( )

[ Top ]
getDefaultSizedImage  [line 2202]

Returns the url to the default sized image.


string getDefaultSizedImage( )

[ Top ]
getDefaultWidth  [line 2154]

The width of the default-sized image (in printDefaultSizedImage)


int getDefaultWidth( )

[ Top ]
getFirstImageURL  [line 1886]

Returns the url of the first image in current album.

Information Tags:
Author:  gerben

string getFirstImageURL( )

[ Top ]
getFullHeight  [line 2182]

Returns the height of the original image


int getFullHeight( )

[ Top ]
getFullImageURL  [line 2307]

Returns the url to original image.

It will return a protected image is the option "protect_full_image" is set


string getFullImageURL( )

[ Top ]
getFullWidth  [line 2172]

Returns the width of the original image


int getFullWidth( )

[ Top ]
getGalleryDesc  [line 238]

Returns the raw description of the gallery.


string getGalleryDesc( )

[ Top ]
getGalleryIndexURL  [line 284]

Returns the URL of the main gallery page containing the current album

Parameters:
bool   $relative:  set to false to get the true index page


string getGalleryIndexURL( [bool $relative = true]  )

[ Top ]
getGalleryTitle  [line 213]

Returns the raw title of the gallery.


string getGalleryTitle( )

[ Top ]
getImageCity  [line 1645]

Returns the City field of the current image


string getImageCity( )

[ Top ]
getImageCountry  [line 1667]

Returns the Country field of the current image


string getImageCountry( )

[ Top ]
getImageCustomData  [line 1760]

Returns the custom_data field of the current image


string getImageCustomData( )

[ Top ]
getImageData  [line 1749]

A composit for getting image data

Parameters:
string   $field:  which field you want


string getImageData( string $field  )

[ Top ]
getImageDate  [line 1596]

Returns the image date of the current image in yyyy-mm-dd hh:mm:ss format.

Pass it a date format string for custom formatting

Parameters:
string   $format:  formatting string for the data


string getImageDate( [string $format = null]  )

[ Top ]
getImageDesc  [line 1710]

Returns the raw description of the current image.

new lines are replaced with
tags


string getImageDesc( )

[ Top ]
getImageEXIFData  [line 2003]

Returns the EXIF infromation from the current image


array getImageEXIFData( )

[ Top ]
getImageID  [line 1806]

Get the unique ID of the current image.


int getImageID( )

[ Top ]
getImageLinkURL  [line 1962]

Returns the url of the current image.


string getImageLinkURL( )

[ Top ]
getImageLocation  [line 1634]

Returns the Location field of the current image


string getImageLocation( )

[ Top ]
getImageSortOrder  [line 1826]

Get the sort order of this image.


string getImageSortOrder( )

[ Top ]
getImageState  [line 1656]

Returns the State field of the current image


string getImageState( )

[ Top ]
getImageThumb  [line 2267]

Returns the url to the thumbnail of the current image.


string getImageThumb( )

[ Top ]
getImageTitle  [line 1511]

Returns the raw title of the current image.


string getImageTitle( )

[ Top ]
getLastImageURL  [line 1901]

Returns the url of the last image in current album.

Information Tags:
Author:  gerben

string getLastImageURL( )

[ Top ]
getLatestComments  [line 2769]

Gets latest comments for images and albums

Parameters:
int   $number:  how many comments you want.


void getLatestComments( int $number  )

[ Top ]
getMainSiteName  [line 264]

Returns the name of the main website as set by the "Website Title" option on the gallery options tab.


string getMainSiteName( )

[ Top ]
getMainSiteURL  [line 274]

Returns the URL of the main website as set by the "Website URL" option on the gallery options tab.


string getMainSiteURL( )

[ Top ]
getNextAlbum  [line 1280]

Returns the next album


object getNextAlbum( )

[ Top ]
getNextAlbumURL  [line 1302]

Get the URL of the next album in the gallery.


string getNextAlbumURL( )

[ Top ]
getNextImageThumb  [line 1950]

Returns the thumbnail of the next image.


string getNextImageThumb( )

[ Top ]
getNextImageURL  [line 1858]

Returns the url of the next image.


string getNextImageURL( )

[ Top ]
getNextPageURL  [line 503]

Returns the URL of the next page. Use within If or while loops for pagination.


string getNextPageURL( )

[ Top ]
getNumAlbums  [line 318]

Returns the number of albums.


int getNumAlbums( )

[ Top ]
getNumImages  [line 1379]

Returns the number of images in the album.


int getNumImages( )

[ Top ]
getNumSubalbums  [line 397]

Returns the count of subalbums in the album


int getNumSubalbums( )

[ Top ]
getPageURL  [line 454]

Returns the URL of the page number passed as a parameter

Parameters:
int   $page:  Which page is desired
int   $total:  How many pages there are.


int getPageURL( int $page, [int $total = null]  )

[ Top ]
getParentAlbums  [line 737]

Returns an array of the names of the parents of the current album.

Parameters:
   $album: 


array getParentAlbums( [ $album = null]  )

[ Top ]
getPasswordProtectImage  [line 1127]

Returns an img src link to the password protect thumb substitute

Parameters:
string   $extra:  extra stuff to put in the HTML


string getPasswordProtectImage( string $extra  )

[ Top ]
getPrevAlbum  [line 1316]

Returns the previous album


object getPrevAlbum( )

[ Top ]
getPrevAlbumURL  [line 1338]

Get the URL of the previous album in the gallery.


string getPrevAlbumURL( )

[ Top ]
getPrevImageThumb  [line 1938]

Returns the thumbnail of the previous image.


string getPrevImageThumb( )

[ Top ]
getPrevImageURL  [line 1871]

Returns the url of the previous image.


string getPrevImageURL( )

[ Top ]
getPrevPageURL  [line 535]

Returns the URL of the previous page.


string getPrevPageURL( )

[ Top ]
getProtectedAlbumsWhere  [line 2897]

Returns a where clause for filter password protected album.

Used by the random images functions.

If the viewer is not logged in as ADMIN this function fails all password protected albums. It does not check to see if the viewer has credentials for an album.


string getProtectedAlbumsWhere( )

[ Top ]
getProtectedImageURL  [line 2345]

Returns an url to the password protected/watermarked current image


string getProtectedImageURL( )

[ Top ]
getRandomImages  [line 2930]

Returns a randomly selected image from the gallery. (May be NULL if none exists)

Parameters:
bool   $daily:  set to true and the picture changes only once a day.


object getRandomImages( [bool $daily = false]  )

[ Top ]
getRandomImagesAlbum  [line 2982]

Returns a randomly selected image from the album or its subalbums. (May be NULL if none exists)

Parameters:
string   $rootAlbum:  optional album folder from which to get the image.


object getRandomImagesAlbum( [string $rootAlbum = null]  )

[ Top ]
getRSSHeaderLink  [line 3399]

Returns the RSS link for use in the HTML HEAD

Parameters:
string   $option:  type of RSS: "Gallery" feed for the whole gallery "Album" for only the album it is called from "Collection" for the album it is called from and all of its subalbums "Comments" for all comments
string   $linktext:  title of the link
string   $lang:  optional to display a feed link for a specific language. Enter the locale like "de_DE" (the locale must be installed on your Zenphoto to work of course). If empty the locale set in the admin option or the language selector (getOption('locale') is used.

Information Tags:
Since:  1.1

string getRSSHeaderLink( string $option, [string $linktext = ''], [string $lang = '']  )

[ Top ]
getSearchDate  [line 3665]

Returns the date of the search

Parameters:
string   $format:  formatting of the date, default 'F Y'

Information Tags:
Since:  1.1

string getSearchDate( [string $format = 'F Y']  )

[ Top ]
getSearchURL  [line 3442]

Returns a search URL

Parameters:
string   $words:  the search words target
string   $dates:  the dates that limit the search
int   $fields:  the fields on which to search
int   $page:  the page number for the URL

Information Tags:
Since:  1.1.3

string getSearchURL( string $words, string $dates, int $fields, int $page  )

[ Top ]
getSearchWords  [line 3624]

Returns the a sanitized version of the search string

Information Tags:
Since:  1.1

string getSearchWords( )

[ Top ]
getSizeCustomImage  [line 2054]

Returns a link to a custom sized version of he current image

Parameters:
int   $size:  size
int   $width:  width
int   $height:  height
int   $cw:  crop width
int   $ch:  crop height
int   $cx:  crop x axis
int   $cy:  crop y axis


string getSizeCustomImage( int $size, [int $width = NULL], [int $height = NULL], [int $cw = NULL], [int $ch = NULL], [int $cx = NULL], [int $cy = NULL]  )

[ Top ]
getSizeDefaultImage  [line 2135]

Returns an array [width, height] of the default-sized image.


array getSizeDefaultImage( )

[ Top ]
getSizedImageURL  [line 2369]

Returns a link to the current image custom sized to $size

Parameters:
int   $size: 


void getSizedImageURL( int $size  )

[ Top ]
getSizeFullImage  [line 2144]

Returns an array [width, height] of the original image.


array getSizeFullImage( )

[ Top ]
getTags  [line 3099]

Returns a list of tags for either an image or album, depends on the page called from

Information Tags:
Since:  1.1

string getTags( )

[ Top ]
getTheme  [line 3707]

Finds the name of the themeColor option selected on the admin options tab Returns a path and name of the theme css file. Returns the value passed for defaultcolor if the theme css option file does not exist.

Parameters:
string   $zenCSS:  path to the css file
string   $themeColor:  name of the css file
string   $defaultColor:  name of the default css file
   &$zenCSS: 
   &$themeColor: 

Information Tags:
Since:  1.1

string getTheme( &$zenCSS, &$themeColor, string $defaultColor, string $zenCSS, string $themeColor  )

[ Top ]
getTotalImagesIn  [line 1401]

Returns the count of all the images in the album and any subalbums

Parameters:
object   $album:  The album whose image count you want

Information Tags:
Since:  1.1.4

int getTotalImagesIn( object $album  )

[ Top ]
getTotalPages  [line 419]

Returns the number of pages for the current object

Parameters:
bool   $oneImagePage:  set to true if your theme collapses all image thumbs or their equivalent to one page. This is typical with flash viewer themes


int getTotalPages( [bool $oneImagePage = false]  )

[ Top ]
getUnprotectedImageURL  [line 2336]

Returns the "raw" url to the image in the albums folder


string getUnprotectedImageURL( )

[ Top ]
getURL  [line 3324]

Returns the URL to an image (This is NOT the URL for the image.php page)

Parameters:
   $image: 


string getURL( $image  )

[ Top ]
hasNextImage  [line 1845]

True if there is a next image


bool hasNextImage( )

[ Top ]
hasNextPage  [line 496]

Returns true if there is a next page


bool hasNextPage( )

[ Top ]
hasPrevImage  [line 1851]

True if there is a previous image


bool hasPrevImage( )

[ Top ]
hasPrevPage  [line 528]

Returns TRUE if there is a previous page. Use within If or while loops for pagination.


bool hasPrevPage( )

[ Top ]
hitcounter  [line 2858]

Increments (optionally) and returns the hitcounter if a page is viewed (image.php and album.php only).

Password protected albums are also counted. If you don't want those to be counted, protect the hitcounter with a password check. Does not increment the hitcounter if the viewer is logged in as the gallery admin

Parameters:
string   $option:  "image" for image hit counter (default), "album" for album hit counter
bool   $viewonly:  set to true if you don't want to increment the counter.
int   $id:  Optional record id of the object if not the current image or album

Information Tags:
Since:  1.1.3

string hitcounter( [string $option = 'image'], [bool $viewonly = false], [int $id = NULL]  )

[ Top ]
imageNumber  [line 1559]

Returns the 'n' of n of m images


int imageNumber( )

[ Top ]
isAlbumPage  [line 1364]

Returns true if this page has album thumbs on it


bool isAlbumPage( )

[ Top ]
isImagePage  [line 1352]

Returns true if this page has image thumbs on it


bool isImagePage( )

[ Top ]
isImagePhoto  [line 1694]

Returns true if the image is a standard photo type

Parameters:
object   $image:  optional image object


bool isImagePhoto( [object $image = NULL]  )

[ Top ]
isImageVideo  [line 1679]

Returns video argument of the current Image.

Parameters:
object   $image:  optional image object


bool isImageVideo( [object $image = NULL]  )

[ Top ]
isLandscape  [line 2192]

Returns true if the image is landscape-oriented (width is greater than height)


bool isLandscape( )

[ Top ]
makeAlbumCurrent  [line 639]

Sets the album passed as the current album

Parameters:
object   $album:  the album to be made current


void makeAlbumCurrent( object $album  )

[ Top ]
makeImageCurrent  [line 1499]

Sets the image passed as the current image

Parameters:
object   $image:  the image to become current


void makeImageCurrent( object $image  )

[ Top ]
my_truncate_string  [line 3084]

Shortens a string to $length

Parameters:
string   $string:  the string to be shortened
int   $length:  the desired length for the string


string my_truncate_string( string $string, int $length  )

[ Top ]
next_album  [line 344]

WHILE next_album(): context switches to Album.

If we're already in the album context, this is a sub-albums loop, which, quite simply, changes the source of the album list. Switch back to the previous context when there are no more albums. Returns true if there are albums, false if none

Parameters:
bool   $all:  true to go through all the albums
string   $sorttype:  what you want to sort the albums by

Information Tags:
Since:  0.6

bool next_album( [bool $all = false], [string $sorttype = null]  )

[ Top ]
next_comment  [line 2572]

Iterate through comments; use the ZP_COMMENT context.

Return true if there are more comments

Parameters:
bool   $desc:  set true for desecnding order


bool next_comment( [bool $desc = false]  )

[ Top ]
next_image  [line 1428]

Returns the next image on a page.

sets $_zp_current_image to the next image in the album. Returns true if there is an image to be shown

Parameters:
bool   $all:  set to true disable pagination
int   $firstPageCount:  the number of images which can go on the page that transitions between albums and images
string   $sorttype:  overrides the default sort type
bool   $overridePassword:  the password chedk


bool next_image( [bool $all = false], [int $firstPageCount = 0], [string $sorttype = null], [bool $overridePassword = false]  )

[ Top ]
normalizeColumns  [line 3759]

Passed # of album columns, # of image columns of the theme.

NOTE: The values for these numbers of columns are determined by the theme CSS. They should be set to how many images or albums are displayed in a row. If you get this wrong, your theme will not behave as you expect.

Updates (non-persistent) images_per_page and albums_per_page so that the rows are filled.

This means that the value you set for the images per page and albums per page options may not be the same as what actually gets shown. First, they will be rounded to be an even multiple rows. So, if you have 6 columns of album thumbs your albums per page shown will be a multiple of six (assuming that there are enough albums.) Second, there may be a page where both image and album thumbs are shown--the "transition" page. Fewer than images_per_page will appear on this page.

The "non-persistent" update means that the actual values for these options are not changed. Just the values that will be used for the display of the particular page.

Returns # of images that will go on the album/image transition page.

When you have albums containing both subalbums and images there may be a page where the album thumbnails do not fill the page. This function returns a count of the images that can be used to fill out this transition page. The return value should be passed as the second parameter to next_image() so that the the page is filled out with the proper number of images. If you do not pass this parameter it is assumed that album thumbs and image thumbs are not to be placed on the same (transition) page. (If you do not wish to have an album/image transition page you need not use this function at all.)

This function (combined with the parameter to next_image) impacts the pagination computations zenphoto makes. For this reason, it is important to make identical calls to the function from your theme's index.php, albums.php and image.php pages. Otherwise page and breadcrumb navigation may not be correct.

Parameters:
int   $albumColumns:  number of album columns on the page
int   $imageColumns:  number of image columns on the page

Information Tags:
Since:  1.1

int normalizeColumns( int $albumColumns, int $imageColumns  )

[ Top ]
openedForComments  [line 3687]

Checks to see if comment posting is allowed for an image/album Returns true if comment posting should be allowed

Parameters:
int   $what:  the degree of control desired allowed values: ALBUM, IMAGE, and ALBUM+IMAGE


bool openedForComments( [int $what = 3]  )

[ Top ]
printAdminLink  [line 48]

Prints the admin edit link for al