Strona 1 z 1

[pomoc] [php] galeria SPMG

: wt sie 03, 2004 7:58 pm
autor: farafel
Korzystam z galeri SPMG hxxp://spgm.sourceforge.net/

Mam problem z przemieszczeniem buttonow przelaczajacych pelnoekranowe obrazki. Chcialbym aby byly one pod spodem pic, gdyz jest to bardziej przyjazne przegladajacemu.

Nizej podaje kody 4 plikow, ktore moim zdaniem sa wazne.

spgm.php - to najprawdopodbniej caly trzon skryptu
spgm.conf - plik konfiguracyjny

spgm_style.css i spgm.thm to pliki odpowiedzilne za wyglad skorki galeri.

Re: [pomoc] [php] galeria SPMG

: wt sie 03, 2004 10:55 pm
autor: farafel
pliki odpowiedzialne za grafike tych przyciskow to:
- previuous_pic.png
- next_pic.png

spgm.php :

<?php

# SPGM (Simple Picture Gallery Manager), a basic and configurable PHP script
# to display picture galleries on the web
# Copyright (C) 2002, Sylvain Pajot <[email protected]>
# Official website: http://spgm.sourceforge.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


###### Toggles #############
define("MODE_TRACE", false); // toggles debug mode
define("MODE_WARNING", true); // toggles warning mode
define("REGISTER_GLOBALS", false); // toggle for register_globals mode
// must match the php.ini configuration
define("URL_EXTRA_PARAMS", ""); // used when spgm is called from templates
// will be removed as of 1.4
// ex: "&cat=pics&lg=$lg"

define("DIR_GAL", "gal/"); // galleries base directory (relative path from spgm.php or the file requiring it if there's one)
define("DIR_LANG", "lang/"); // language packs (relative path from spgm.php or the file requiring it if there's one)
define("DIR_THEMES", "flavors/"); // themes base directory (relative path from spgm.php or the file requiring it if there's one)
define("FILE_GAL_CAPTION", "gallery.msg"); // default caption file for a gallery
define("FILE_PICTURE_CAPTIONS", "captions.txt"); // default caption file for pictures/thumbnails
define("FILE_GAL_SORT", "gallery.sort"); // file for explicit gallery sort
define("FILE_PIC_SORT", "picture.sort"); // file for explicit picture sort
define("FILE_THEME", "spgm.thm"); // theme file
define("FILE_CONF", "spgm.conf"); // config file
define("FILE_LANG", "lang"); // language file short name (without extension)
define("PREF_THUMB", "_thb_"); // prefix for thumbnail pictures

define("PARAM_NAME_GALID", "spgmGal");
define("PARAM_NAME_PICID", "spgmPic");
define("PARAM_NAME_PAGE", "spgmPage");
define("PARAM_NAME_FILTER", "spgmFilters");
define("PARAM_VALUE_FILTER_NEW", "n");
define("PARAM_VALUE_FILTER_NOTHUMBS", "t");
define("PARAM_VALUE_FILTER_SLIDESHOW", "s");

define("CLASS_TABLE_WRAPPER", "table-wrapper");
define("CLASS_TABLE_MAIN_TITLE", "table-main-title");
define("CLASS_TD_SPGM_LINK", "td-main-title-spgm-link");
define("CLASS_A_SPGM_LINK", "a-spgm-link");
define("CLASS_TABLE_GALLISTING_GRID", "table-gallisting-grid");
define("CLASS_TD_GALLISTING_CELL", "td-gallisting-cell");
define("CLASS_TABLE_GALITEM", "table-galitem");
define("CLASS_TD_GALITEM_ICON", "td-galitem-icon");
define("CLASS_TD_GALITEM_TITLE", "td-galitem-title");
define("CLASS_TD_GALITEM_CAPTION", "td-galitem-caption");
define("CLASS_TABLE_PICTURE", "table-picture");
define("CLASS_TD_PICTURE_NAVI", "td-picture-navi");
define("CLASS_TD_ZOOM_FACTORS", "td-zoom-factors");
define("ID_PICTURE", "picture");
define("CLASS_BUTTON_ZOOM_FACTORS", "button-zoom-factors");
define("CLASS_TD_PICTURE_PIC", "td-picture-pic");
define("ID_PICTURE_NAVI", "pic-navi");
define("CLASS_TD_PICTURE_FILENAME", "td-picture-filename");
define("CLASS_TD_PICTURE_CAPTION", "td-picture-caption");
define("CLASS_TABLE_THUMBNAILS", "table-thumbnails");
define("CLASS_TD_THUMBNAILS_THUMB", "td-thumbnails-thumb");
define("CLASS_TD_THUMBNAILS_THUMB_SELECTED", "td-thumbnails-thumb-selected");
define("CLASS_TD_THUMBNAILS_NAVI", "td-thumbnails-navi");
define("CLASS_DIV_THUMBNAILS_CAPTION", "div-thumbnails-caption");
define("CLASS_SPAN_FILTERS", "span-filters");
define("CLASS_IMG_PICTURE", "img-picture");
define("CLASS_IMG_THUMBNAIL", "img-thumbnail");
define("CLASS_IMG_THUMBNAIL_SELECTED", "img-thumbnail-selected");
define("CLASS_IMG_FOLDER", "img-folder");
define("CLASS_IMG_GALICON", "img-galicon");
define("CLASS_IMG_PICTURE_PREV", "img-picture-prev");
define("CLASS_IMG_PICTURE_NEXT", "img-picture-next");
define("CLASS_IMG_THMBNAVI_PREV", "img-thmbnavi-prev");
define("CLASS_IMG_THMBNAVI_NEXT", "img-thmbnavi-next");
define("CLASS_IMG_NEW", "img-new");
define("CLASS_DIV_GALHEADER", "div-galheader");

define("ERRMSG_UNKNOWN_GALLERY", "unknown gallery");
define("ERRMSG_UNKNOWN_PICTURE", "unknown picture");
define("ERRMSG_INVALID_NUMBER_OF_PICTURES", "invalid number of picture");
define("ERRMSG_INVALID_VALUE", "invalid value");
define("WARNMSG_FILE_INSUFFICIENT_PERMISSIONS", "insufficient permissions (644 required)");
define("WARNMSG_THUMBNAIL_UNREADABLE", "no associated thumbnail or insufficient permissions");
define("WARNMSG_DIR_INSUFFICIENT_PERMISSIONS", "insufficient permissions (755 required)");

define("GALICON_NONE", 0);
define("GALICON_RANDOM", 1);
define("ORIGINAL_SIZE", 0);
define("SORTTYPE_CREATION_DATE", 0);
define("SORTTYPE_NAME", 1);
define("SORT_ASCENDING", 0);
define("SORT_DESCENDING", 1);
define("RIGHT", 0);
define("BOTTOM", 1);

/* multi-language support... */
define("PATTERN_SPGM_LINK", ">SPGM_LINK<");
define("PATTERN_CURRENT_PAGE", ">CURRENT_PAGE<");
define("PATTERN_NB_PAGES", ">NB_PAGES<");
define("PATTERN_CURRENT_PIC", ">CURRENT_PIC<");
define("PATTERN_NB_PICS", ">NB_PICS<");

// Used for variable variables in main function
$strVarGalleryId = PARAM_NAME_GALID;
$strVarPictureId = PARAM_NAME_PICID;
$strVarPageIndex = PARAM_NAME_PAGE;
$strVarFilterFlags = PARAM_NAME_FILTER;

$cfg = array();
$cfg['conf']['newStatusDuration'] = 30;
$cfg['conf']['thumbnailsPerPage'] = 9;
$cfg['conf']['thumbnailsPerRow'] = 3;
$cfg['conf']['galleryListingCols'] = 2;
$cfg['conf']['galleryCaptionPos'] = RIGHT;
$cfg['conf']['subGalleryLevel'] = 1;
$cfg['conf']['gallerySortType'] = SORTTYPE_NAME;
$cfg['conf']['gallerySortOptions'] = SORT_ASCENDING;
$cfg['conf']['pictureSortType'] = SORTTYPE_NAME;
$cfg['conf']['pictureSortOptions'] = SORT_ASCENDING;
$cfg['conf']['pictureInfoedThumbnails'] = false;
$cfg['conf']['captionedThumbnails'] = false;
$cfg['conf']['pictureCaptionedThumbnails'] = false;
$cfg['conf']['filenameWithThumbnails'] = false;
$cfg['conf']['filenameWithPictures'] = false;
$cfg['conf']['popupPictures'] = false;
$cfg['conf']['popupWidth'] = 750;
$cfg['conf']['popupHeight'] = 600;
$cfg['conf']['filters'] = '';
$cfg['conf']['zoomFactors'] = array();
$cfg['conf']['galleryIconType'] = GALICON_NONE;
$cfg['conf']['galleryIconHeight'] = ORIGINAL_SIZE;
$cfg['conf']['galleryIconWidth'] = ORIGINAL_SIZE;
$cfg['conf']['theme'] = 'default';
$cfg['conf']['language'] = 'en';

$cfg['locale']['spgmLink']
= 'a gallery generated by '.PATTERN_SPGM_LINK;
$cfg['locale']['thumbnailNaviBar']
= 'Page '.PATTERN_CURRENT_PAGE.' of '.PATTERN_NB_PAGES;
$cfg['locale']['filter'] = 'filter';
$cfg['locale']['filterNew'] = 'new';
$cfg['locale']['filterAll'] = 'all';
$cfg['locale']['filterSlideshow'] = 'Slideshow';
$cfg['locale']['pictureNaviBar']
= 'Picture '.PATTERN_CURRENT_PIC.' of '.PATTERN_NB_PICS;
$cfg['locale']['newPictures'] = 'new pictures';
$cfg['locale']['newPicture'] = 'new picture';
$cfg['locale']['newGallery'] = 'new gallery';
$cfg['locale']['pictures'] = 'pictures';
$cfg['locale']['picture'] = 'picture';
$cfg['locale']['rootGallery'] = 'Main gallery';

$cfg['theme']['gallerySmallIcon'] = '';
$cfg['theme']['galleryBigIcon'] = '';
$cfg['theme']['newItemIcon'] = '';
$cfg['theme']['previousPictureIcon'] = '';
$cfg['theme']['nextPictureIcon'] = '';
$cfg['theme']['previousPageIcon'] = '';
$cfg['theme']['nextPageIcon'] = '';

$cfg['global']['supportedExtensions']
= array('.jpg', '.png', '.gif'); // supported picture file extensions
$cfg['global']['propagateFilters'] = false; // used to propagate filters in URLs
$cfg['global']['documentSelf'] = '';
$cfg['global']['tmpPathToPics'] = ''; // hack to avoid comparisons of long
// strings (only used by the spgm_CallbackCompareMTime
// callback function)

# A bit of logic to set a few of the variables above...
if (REGISTER_GLOBALS) {
if (isset($$var_filter) ) $cfg['global']['propagateFilters'] = true;
$cfg['global']['documentSelf'] = basename($PHP_SELF);
} else {
if (isset($_GET[PARAM_NAME_FILTER]) ) $cfg['global']['propagateFilters'] = true;
$cfg['global']['documentSelf'] = basename( $_SERVER['PHP_SELF'] );
}






###### REPORTING FUNCTIONS #############################################

function spgm_Error($strErrorMessage) {
print '<div style="color: #ff0000; font_family: helvetica, arial; font-size:12pt; font-weight: bold;">'.$strErrorMessage.'</div>'."\n";
}

function spgm_Warning($strWarningMessage) {
if (MODE_WARNING) {
print '<div style="color: #0000ff; font_family: helvetica, arial; font-size:12pt; font-weight: bold;">'.$strWarningMessage.'</div>'."\n";
}
}

function spgm_Trace($strTrace) {
if (MODE_TRACE) {
print '<div style="color: #000000; font_family: verdana, helvetica, arial; font-size:12pt;">'.$strTrace.'</div>'."\n";
}
}



################## DISPLAY INFO FUNCTIONS #####################################

function spgm_DispSPGMLink() {

global $cfg;

spgm_Trace( '<p>function spgm_DispSPGMLink</p>'."\n" );

// multi-language support
$cfg['locale']['spgmLink'] = ereg_replace(PATTERN_SPGM_LINK, '<a href="http://spgm.sourceforge.net" class="'.CLASS_A_SPGM_LINK.'">SPGM</a>', $cfg['locale']['spgmLink']);

print $cfg['locale']['spgmLink'];
}

################################################################################
# Checks if a file or directory is "new"
function spgm_IsNew($strFilePath) {

global $cfg;

spgm_Trace(
'<p>function spgm_IsNew</p>'."\n"
.'strFilePath: '.$strFilePath.'<br />'."\n"
);

if (! file_exists($strFilePath) || $cfg['conf']['newStatusDuration'] == 0) return false;
return (filemtime($strFilePath) > (time()-$cfg['conf']['newStatusDuration']*24*3600));
}

################################################################################
# Checks for permissions on either pictures, galleries, config files, etc...

function spgm_CheckPerms($strFilePath) {

spgm_Trace(
'<p>function spgm_CheckPerms</p>'."\n"
.'strFilePath: '.$strFilePath.'<br />'."\n"
);

if (! file_exists($strFilePath)) return false;

$fileperms = fileperms($strFilePath);
$isreadable = $fileperms & 4;
if ( is_file($strFilePath) ) {
// pictures, thumbnails, config files and comments only need to be readable
if (! $isreadable) {
spgm_Warning(
$strFilePath.': '.WARNMSG_DIR_INSUFFICIENT_PERMISSIONS.'<br />'
);
}
return $isreadable;
}
else if ( is_dir($strFilePath) ) {
// galleries need to be both readable and executable
$isexecutable = $fileperms & 1;
if (! $isreadable || ! $isexecutable)
spgm_Warning(
$strFilePath.': '.WARNMSG_DIR_INSUFFICIENT_PERMISSIONS.'<br />'
);
return ( $isreadable && $isexecutable); // ($dirperms & 5) == 5 ?
}

// default behavior: the strFilePath does not exist
return false;
}

################################################################################
# Checks if the filname exists, refers to a picture associated to a thumbnail
# and is granted the necessary access rigths

function spgm_IsPicture($strPictureFileName, $strGalleryId) {

global $cfg;

$strPicturePath = DIR_GAL.$strGalleryId.'/'.$strPictureFileName;
$strThumbnailPath = DIR_GAL.$strGalleryId.'/'.PREF_THUMB.$strPictureFileName;

spgm_Trace(
'<p>function spgm_IsPicture</p>'."\n"
.'strPictureFileName: '.$strPictureFileName.'<br />'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
.'strPicturePath: '.$strPicturePath.'<br />'."\n"
.'strThumbnailPath: '.$strThumbnailPath.'<br />'."\n"
);

// check filename patterns
if ( eregi('^'.PREF_THUMB.'*', $strPictureFileName) )
return false;
$validated = false;
$extnb = count($cfg['global']['supportedExtensions']);
for ($i=0; $i<$extnb; $i++) {
if ( eregi($cfg['global']['supportedExtensions'][$i].'$', $strPictureFileName) ) {
$validated = true;
break;
}
}
if (! $validated)
return false;

// does it exist, is it a regular file and does it have the expected permissions ?
if (! spgm_CheckPerms($strPicturePath) ) {
return false;
}

// an associated thumbnail is required... same job again !
if (! spgm_CheckPerms($strThumbnailPath) ) {
spgm_Warning( $strPicturePath.': '.WARNMSG_THUMBNAIL_UNREADABLE.'<br />' );
return false;
}

return true;
}

##############################################################################
# Checks if the directory corresponding the gallery is well-formed, exists
# and is granted the necessary access rights
# $galid can be empty

function spgm_IsGallery($strGalleryId) {

$strPathToPictures = DIR_GAL.$strGalleryId;

spgm_Trace(
'<p>function spgm_IsGallery</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
.'strPathToPictures: '.$strPathToPictures.'<br />'."\n"
);

// searching for hazardous patterns
if ( ereg('^/', $strGalleryId) || ereg('\.\.', $strGalleryId) || ereg('/$', $strGalleryId) ) {
return false;
}

// does it exist, is it a directory and does it have the expected permissions ?
if (! is_dir($strPathToPictures))
return false;
if (! spgm_CheckPerms($strPathToPictures) ) {
spgm_Warning(
$strPathToPictures.': '.WARNMSG_FILE_INSUFFICIENT_PERMISSIONS.'<br />'
);
return false;
}

return true;
}


################################################################################
# Loads a flavor
function spgm_LoadFlavor($strThemeName) {

global $cfg;

spgm_Trace(
'<p>function spgm_LoadFlavor</p>'."\n"
.'strThemeName: '.$strThemeName.'<br />'."\n"
);

if ( spgm_CheckPerms(DIR_THEMES.$strThemeName.'/'.FILE_THEME) ) {
include(DIR_THEMES.$strThemeName.'/'.FILE_THEME);
}
else
spgm_Warning(
'unable to load '.DIR_THEMES.$strThemeName.'/'.FILE_THEME.': '
.WARNMSG_FILE_INSUFFICIENT_PERMISSIONS.'<br />'
);
}

################################################################################
# Loads textual ressources from an SPGM language file.

function spgm_LoadLanguage($strCountryCode) {

global $cfg;

spgm_Trace(
'<p>funtion spgm_LoadLanguage</p>'."\n"
.'country code: '.$strCountryCode.'<br />'."\n"
);

if ($strCountryCode != '') {
$filename_lang = DIR_LANG.FILE_LANG.'.'.$strCountryCode;
if (file_exists($filename_lang) ) {
if ( spgm_CheckPerms($filename_lang) ) {
include($filename_lang);
}
}
else
spgm_Warning(
'No support for lang. '.$strCountryCode.' » default: english<br />'
);
}
}


###############################################################################
# Loads picture/thumbnail captions for a given gallery
function spgm_LoadPictureCaptions($strGalleryId) {

global $cfg;

spgm_Trace(
'<p>funtion spgm_LoadPictureCaption</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
);


if ( spgm_CheckPerms(DIR_GAL.$strGalleryId.'/'.FILE_PICTURE_CAPTIONS) ) {
include(DIR_GAL.$strGalleryId.'/'.FILE_PICTURE_CAPTIONS);
}

}

################################################################################
function spgm_PostInitCheck() {

global $cfg;

spgm_Trace( '<p>funtion spgm_PostInitCheck</p>'."\n" );

$_mix = $cfg['conf']['newStatusDuration'];
if (! is_int($_mix) || ($_mix < 0) )
spgm_Error('cfg[conf][newStatusDuration]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['thumbnailsPerPage'];
if (! is_int($_mix) || ($_mix < 1) )
spgm_Error('cfg[conf][thumbnailsPerPage]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['thumbnailsPerRow'];
if (! is_int($_mix) || ($_mix < 1) )
spgm_Error('cfg[conf][thumbnailsPerRow]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['galleryListingCols'];
if (! is_int($_mix) || ($_mix < 1) )
spgm_Error('cfg[conf][galleryListingCols]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['subGalleryLevel'];
if (! is_int($_mix) || ($_mix < 0) )
spgm_Error('cfg[conf][subGalleryLevel]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['galleryIconType'];
if ( ! is_int($_mix) || ($_mix != GALICON_NONE
&& $_mix != GALICON_RANDOM) )
spgm_Error('cfg[conf][galleryIconType]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['galleryIconHeight'];
if (! is_int($_mix) || ($_mix < ORIGINAL_SIZE) )
spgm_Error('cfg[conf][galleryIconHeight]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['galleryIconWidth'];
if (! is_int($_mix) || ($_mix < ORIGINAL_SIZE) )
spgm_Error('cfg[conf][galleryIconWidth]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['galleryCaptionPos'];
if ( ! is_int($_mix) || ($_mix != RIGHT && $_mix != BOTTOM) )
spgm_Error('cfg[conf][galleryCaptionPos]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['gallerySortType'];
if ( ! is_int($_mix) || ($_mix != SORTTYPE_CREATION_DATE
&& $_mix != SORTTYPE_NAME) )
spgm_Error('cfg[conf][gallerySortType]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['gallerySortOptions'];
if ( ! is_int($_mix) || ($_mix != SORT_ASCENDING
&& $_mix != SORT_DESCENDING) )
spgm_Error('cfg[conf][gallerySortOptions]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['pictureSortType'];
if ( ! is_int($_mix) || ($_mix != SORTTYPE_CREATION_DATE
&& $_mix != SORTTYPE_NAME) )
spgm_Error('cfg[conf][pictureSortType]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['pictureSortOptions'];
if ( ! is_int($_mix) || ($_mix != SORT_ASCENDING
&& $_mix != SORT_DESCENDING) )
spgm_Error('cfg[conf][pictureSortOptions]: '.ERRMSG_INVALID_VALUE);

// is_bool is not available as of PHP 3
/*
if ( ! is_bool($cfg['conf']['pictureInfoedThumbnails']) )
spgm_Error('cfg[conf][pictureInfoedThumbnail]: '.ERRMSG_INVALID_VALUE);

if ( ! is_bool($cfg['conf']['captionedThumbnails']) )
spgm_Error('cfg[conf][captionedThumbnails]: '.ERRMSG_INVALID_VALUE);

if ( ! is_bool($cfg['conf']['pictureCaptionedThumbnails']) )
spgm_Error('cfg[conf][pictureCaptionedThumbnails]: '.ERRMSG_INVALID_VALUE);

if ( ! is_bool($cfg['conf']['popupPictures']) )
spgm_Error('cfg[conf][popupPictures]: '.ERRMSG_INVALID_VALUE);
*/

$_mix = $cfg['conf']['popupWidth'];
if ( ! is_int($_mix) || $_mix < 1)
spgm_Error('cfg[conf][popupWidth]: '.ERRMSG_INVALID_VALUE);

$_mix = $cfg['conf']['popupHeight'];
if ( ! is_int($_mix) || $_mix < 1)
spgm_Error('cfg[conf][popupHeight]: '.ERRMSG_INVALID_VALUE);

if ( ! is_string($cfg['conf']['filters']) )
spgm_Error('cfg[conf][filters]: '.ERRMSG_INVALID_VALUE);

if ( ! is_array($cfg['conf']['zoomFactors']) )
spgm_Error('cfg[conf][zoomFactors]: '.ERRMSG_INVALID_VALUE);

if ( ! is_string($cfg['conf']['theme']) )
spgm_Error('cfg[conf][theme]: '.ERRMSG_INVALID_VALUE);

if ( ! is_string($cfg['conf']['language']) )
spgm_Error('cfg[conf][language]: '.ERRMSG_INVALID_VALUE);



# Link labels initialization

$arrIconInfo = array(
// key in $cfg | ALT value | CLASS value | alternative (if resource is N/A)
array('gallerySmallIcon', '', CLASS_IMG_FOLDER, ''),
array('galleryBigIcon', '', CLASS_IMG_FOLDER, '»'),
array('previousPageIcon', 'Previous thumbnail page',
CLASS_IMG_THMBNAVI_PREV, '«'),
array('nextPageIcon', 'Next thumbnail page', CLASS_IMG_THMBNAVI_NEXT,
'»'),
array('previousPictureIcon', 'Previous picture', CLASS_IMG_PICTURE_PREV,
'«'),
array('nextPictureIcon', 'Next picture', CLASS_IMG_PICTURE_NEXT, '»'),
array('newItemIcon', '', CLASS_IMG_NEW, '')
);

$dim = array();
$iIconNumber = count($arrIconInfo);
$strIconFileName = '';
$_key = '';
$_lblAlt = '';
$_lblClass = '';
$_lblNa = '';

for ($i=0; $i<$iIconNumber; $i++) {

$_key = $arrIconInfo[$i][0];
$_lblAlt = $arrIconInfo[$i][1];
$_lblClass = $arrIconInfo[$i][2];
$_lblNa = $arrIconInfo[$i][3];
$strIconFileName = DIR_THEMES.$cfg['conf']['theme'].'/'.$cfg['theme'][$_key];

if ( $cfg['theme'][$_key] != '' && spgm_CheckPerms($strIconFileName) ) {
$dim = getimagesize($strIconFileName);
$cfg['theme'][$_key] = '<img src="'.$strIconFileName.'"';
$cfg['theme'][$_key] .= ' alt="'.$_lblAlt.'"';
$cfg['theme'][$_key] .= ' class="'.$_lblClass.'"';
$cfg['theme'][$_key] .= ' width="'.$dim[0].'"';
$cfg['theme'][$_key] .= ' height="'.$dim[1].'" />';
} else {
if ($_lblNa != '')
$cfg['theme'][$_key] = $_lblNa;
}
}
}



################################################################################
# Loads config files from the possible different locations.
# To allow properties inheritance, it includes all the config file from the
# top level gallery to the gallery itself.
# TODO: support for INI files (PHP4) ?

function spgm_LoadConfig($strGalleryId) {

global $cfg;

spgm_Trace(
'<p>funtion spgm_LoadConfig</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
);


if ( spgm_IsGallery($strGalleryId) ) {

// always load the default config file
$strConfigurationFileName = DIR_GAL.FILE_CONF;

if ( spgm_CheckPerms($strConfigurationFileName) ) {
include($strConfigurationFileName);
}

// now, include all the possible config files
if ( $strGalleryId != '' ) {
$strConfigurationPathElements = explode('/', $strGalleryId);
$iPathDepth = count($strConfigurationPathElements);
$_strConfigurationPath = ''; // grows inside the follwing loop ("gal1" -> "gal1/gal2"...)
for ($i=0; $i<$iPathDepth; $i++) { // use "foreach ($strConfigurationPathElements as $dir_name) {" in PHP4
$_strConfigurationPath .= $strConfigurationPathElements[$i].'/';
$strConfigurationFileName = DIR_GAL.$_strConfigurationPath.FILE_CONF;
if ( spgm_CheckPerms($strConfigurationFileName) ) {
include($strConfigurationFileName);
}
}
}
}

spgm_LoadLanguage($cfg['conf']['language']);
spgm_LoadFlavor($cfg['conf']['theme']);
spgm_PostInitCheck();

}





################################################################################
# returns an array containing various information for a given gallery and its
# provided pictures.
# returned array:
# $array[0] = total number of pictures
# $array[1] = number of new pictures
# $array[2] = the thumbnail's filename to use for the gallery icon

function spgm_GetGalleryInfo($strGalleryId, $arrPictureFilenames) {

global $cfg;

$iPictureNumber = 0;
$iNewPictureNumber = 0;
$strPathToGalleries = DIR_GAL.$strGalleryId;
$iPictureNumber = count($arrPictureFilenames);
$iNewPictureNumber = 0;
for ($i=0; $i<$iPictureNumber; $i++)
if (spgm_IsNew($strPathToGalleries.'/'.$arrPictureFilenames[$i]) )
$iNewPictureNumber++;

spgm_Trace(
'<p>function spgm_GetGalleryInfo</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
.'iPictureNumber: '.$iPictureNumber.'<br />'."\n"
.'strPathToGalleries: '.$strPathToGalleries.'<br />'."\n"
);

$arrGalleryInfo[0] = $iPictureNumber;
$arrGalleryInfo[1] = $iNewPictureNumber;
if ($cfg['conf']['galleryIconType'] == GALICON_RANDOM && $iPictureNumber > 0)
@$arrGalleryInfo[2] = $arrPictureFilenames[rand(0, $iPictureNumber - 1)];
else $arrGalleryInfo[2] = '';
return $arrGalleryInfo;
}



###############################################################################
# Callback function used to sort galleries/pictures against modification date
# The two parameters are automatically passed by the usort() function

function spgm_CallbackCompareMTime($strFilePath1, $strFilePath2) {

global $cfg;

if ( !strcmp($strFilePath1, $strFilePath2) ) return 0;

return
( filemtime($cfg['global']['tmpPathToPics'].$strFilePath1)
> filemtime($cfg['global']['tmpPathToPics'].$strFilePath2)
) ? 1 : -1;
}



################################################################################
# Creates a sorted array containing first level sub-galleries of a given gallery
# $galid - the gallery ID to introspect
# $display - boolean indicating that galleries will be rendered and that sort
# options consequently have to be turned on
# returns: a sorted array containing the sub-gallery filenames for the given
# gallery

function spgm_CreateGalleryArray($strGalleryId, $bToBeDisplayed) {

global $cfg;

$strPathToGallery = DIR_GAL.$strGalleryId;

spgm_Trace(
'<p>function spgm_CreateGalleryArray</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
.'strPathToGallery: '.$strPathToGallery.'<br />'."\n"
.'bToBeDisplayed: '.$bToBeDisplayed.'<br />'."\n"
);

if ( spgm_IsGallery($strGalleryId) ) $_hDir = @opendir($strPathToGallery);
else spgm_Error($strGalleryId.': '.ERRMSG_UNKNOWN_GALLERY);
if ($strGalleryId != '') $strGalleryId .= '/'; // little hack

if ($strPathToGallery == DIR_GAL) $strSortFilePath = $strPathToGallery.FILE_GAL_SORT;
else $strSortFilePath = $strPathToGallery.'/'.FILE_GAL_SORT;

$arrSubGalleries = array();
if ( spgm_CheckPerms($strSortFilePath) ) {
$strGalleryNames = file($strSortFilePath);
$iGalleryNumber = count($strGalleryNames);
for ($i=0; $i<$iGalleryNumber; $i++) {
$strGalleryName = trim($strGalleryNames[$i]);
if (spgm_IsGallery($strGalleryId.$strGalleryName))
$arrSubGalleries[] = $strGalleryName;
}
} else {
while ($_strFilename = readdir($_hDir)) {
if ($_strFilename != '.' && $_strFilename != '..' && spgm_IsGallery($strGalleryId.$_strFilename))
$arrSubGalleries[] = $_strFilename;
}
closedir($_hDir);

// Apply sort options if needed
if ($bToBeDisplayed) {
if (count($arrSubGalleries) > 0) {
if ($cfg['conf']['gallerySortType'] == SORTTYPE_NAME) {
if ($cfg['conf']['gallerySortOptions'] == SORT_DESCENDING) rsort($arrSubGalleries);
else sort($arrSubGalleries);
} else if ($cfg['conf']['gallerySortType'] == SORTTYPE_CREATION_DATE) {
$cfg['global']['tmpPathToPics'] = DIR_GAL.$strGalleryId;
usort($arrSubGalleries, 'spgm_CallbackCompareMTime'); // TODO: omit it ?
if ($cfg['conf']['gallerySortOptions'] == SORT_DESCENDING)
$arrSubGalleries = array_reverse($arrSubGalleries);
}
}
}
}
return $arrSubGalleries;
}


################################################################################
# Creates a sorted array of the pictures to diplay for a given gallery
# $galid - the gallery ID (must be always valid)
# $filter - the filter that defines the pictures to include in the list
# $display - boolean indicating that thumbnails will be rendered and that sort
# options consequently have to be turned on
# returns: a sorted array containing the thumbnails' basenames of the gallery

function spgm_CreatePictureArray($strGalleryId, $strFilterFlags, $bForDisplayPurpose) {

global $cfg;

$strPathToGallery = DIR_GAL.$strGalleryId.'/';
$hDir=opendir($strPathToGallery);

spgm_Trace(
'<p>function spgm_CreatePictureArray</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
.'strFilterFlags: '.$strFilterFlags.'<br />'."\n"
.'strPathToGallery: '.$strPathToGallery.'<br />'."\n"
.'bForDisplayPurpose: '.$bForDisplayPurpose.'<br />'."\n"
);

$arrPictureFilenames = array();
$strPathToSortFile = $strPathToGallery.FILE_PIC_SORT;
if ( spgm_CheckPerms($strPathToSortFile) ) {
$arrSortedPictureFilenames = file($strPathToSortFile);
$_max = count($arrSortedPictureFilenames);
for ($i=0; $i<$_max; $i++) {
$strPictureName = trim($arrSortedPictureFilenames[$i]);
if ( spgm_IsPicture($strPictureName, $strGalleryId) ) {
if ( strstr($strFilterFlags, PARAM_VALUE_FILTER_NEW) ) {
if ( spgm_IsNew($strPathToGallery.$strPictureName) )
$arrPictureFilenames[] = $strPictureName;
} else $arrPictureFilenames[] = $strPictureName;
}
}
}
else {
while ($strFileName = readdir($hDir)) {
if ( spgm_IsPicture($strFileName, $strGalleryId) ) {
if ( strstr($strFilterFlags, PARAM_VALUE_FILTER_NEW) ) {
if ( spgm_IsNew($strPathToGallery.$strFileName) )
$arrPictureFilenames[] = $strFileName;
} else $arrPictureFilenames[] = $strFileName;
}
}
closedir($hDir);

// Apply sort optionsif needed
if ($bForDisplayPurpose) {
if (count($arrPictureFilenames) > 0) {
if ($cfg['conf']['pictureSortType'] == SORTTYPE_NAME) {
if ($cfg['conf']['pictureSortOptions'] == SORT_DESCENDING) rsort($arrPictureFilenames);
else sort($arrPictureFilenames);
} else if ($cfg['conf']['pictureSortType'] == SORTTYPE_CREATION_DATE) {
$cfg['global']['tmpPathToPics'] = $strPathToGallery;
usort($arrPictureFilenames, 'spgm_CallbackCompareMTime'); // TODO: omit it ?
if ($cfg['conf']['pictureSortOptions'] == SORT_DESCENDING)
$arrPictureFilenames = array_reverse($arrPictureFilenames);
}
}
}
}

return $arrPictureFilenames;
}


################################################################################
function spgm_DisplayThumbnailNavibar($iCurrentPageIndex, $iPageNumber, $strGalleryId, $strFilterFlags) {

global $cfg;

spgm_Trace(
'<p>function spgm_DisplayThumbnailNavibar</p>'."\n"
.'iCurrentPageIndex: '.$iCurrentPageIndex.'<br />'."\n"
.'iPageNumber: '.$iPageNumber.'<br />'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
);

// multi-language support
$cfg['locale']['thumbnailNaviBar'] = ereg_replace(PATTERN_CURRENT_PAGE, "$iCurrentPageIndex", $cfg['locale']['thumbnailNaviBar']);
$cfg['locale']['thumbnailNaviBar'] = ereg_replace(PATTERN_NB_PAGES, "$iPageNumber", $cfg['locale']['thumbnailNaviBar']);
print ' '.$cfg['locale']['thumbnailNaviBar'].' - ';

// display the left arrow
if ($iCurrentPageIndex > 1) {
$iPreviousPageIndex = $iCurrentPageIndex - 1;
print '<a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strGalleryId.'&'.PARAM_NAME_PAGE.'='.$iPreviousPageIndex.'&'.PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).URL_EXTRA_PARAMS.'">'.$cfg['theme']['previousPageIcon'].'</a> ';
}

// display the page numbers
for ($i = 1; $i <= $iPageNumber; $i++) {
if ($i != $iCurrentPageIndex)
print '<a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strGalleryId.'&'.PARAM_NAME_PAGE.'='.$i.'&'.PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).URL_EXTRA_PARAMS.'" class="navi">'.$i.'</a>';
else print $i; // don't make it an anchor if this is the current page
if ($i < $iPageNumber) print '·';
}

// display the right arrow
if ($iCurrentPageIndex < $iPageNumber) {
$iNextPageIndex = $iCurrentPageIndex + 1;
print ' <a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strGalleryId.'&'.PARAM_NAME_PAGE.'='.$iNextPageIndex.'&'.PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).URL_EXTRA_PARAMS.'">'.$cfg['theme']['nextPageIcon'].'</a> ';
}
}

################################################################################
function spgm_DisplayFilterToggles($strGalleryId, $strFilterFlags, $arrGalleryInfo) {

global $cfg;

spgm_Trace(
'<p>function spgm_DisplayFilterToggles</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
.'strFilterFlags: '.$strFilterFlags.'<br />'."\n"
);

$strHtmlToggles = '';
$bFilterNewOn = strstr($strFilterFlags, PARAM_VALUE_FILTER_NEW);
if (($arrGalleryInfo[1] > 0 && $arrGalleryInfo[0] != $arrGalleryInfo[1]) || $bFilterNewOn) {
if ( $bFilterNewOn ) {
$strHtmlToggles .= '<a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strGalleryId.'&'.PARAM_NAME_FILTER.'=';
$strHtmlToggles .= str_replace(PARAM_VALUE_FILTER_NEW, '', $strFilterFlags).URL_EXTRA_PARAMS.'">';
$strHtmlToggles .= $cfg['locale']['filterAll'].'</a>';
}
else {
$strHtmlToggles .= '<a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strGalleryId.'&'.PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags);
$strHtmlToggles .= PARAM_VALUE_FILTER_NEW.URL_EXTRA_PARAMS.'">'.$cfg['locale']['filterNew'].'</a>';
}

print ' <span class="'.CLASS_SPAN_FILTERS.'">['.$cfg['locale']['filter'].' » '.$strHtmlToggles.']</span>'."\n";
}
}


################################################################################
# Prerequisite: spgm_IsGallery($galid) == true

function spgm_DisplayGalleryNavibar($strGalleryId, $strFilterFlags, $mixPictureId = '', $arrPictureFilenames) {

global $cfg;

spgm_Trace(
'<p>function spgm_DisplayGalleryNavibar</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
.'strFilterFlags: '.$strFilterFlags.'<br />'."\n"
.'mixPictureId: '.$mixPictureId.'<br />'."\n"
);

$arrExplodedPathToGallery = explode('/', $strGalleryId);

// display main gallery link
print ' <div class="'.CLASS_DIV_GALHEADER.'">'."\n";
print ' <a href="'.$cfg['global']['documentSelf'].'?';
if ($cfg['global']['propagateFilters']) print PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags);
print URL_EXTRA_PARAMS.'" class="'.CLASS_TD_GALITEM_TITLE.'">';
if ( $cfg['theme']['gallerySmallIcon'] != '' ) {
print $cfg['theme']['gallerySmallIcon'];
} else {
print $cfg['locale']['rootGallery'];
}
print '</a>';

// display each gallery of the hierarchy
$strHtmlGalleryLink = $arrExplodedPathToGallery[0]; // to avoid the first '/'
$_max = count($arrExplodedPathToGallery)-1;

for ($i=0; $i<$_max; $i++) {
$strHtmlGalleryName = ereg_replace('_', ' ', $arrExplodedPathToGallery[$i]);
print ' » ';
print '<a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strHtmlGalleryLink;
if ($cfg['global']['propagateFilters']) print '&'.PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags);
print URL_EXTRA_PARAMS.'" ';
print 'class="'.CLASS_DIV_GALHEADER.'">'.$strHtmlGalleryName.'</a>';
$strHtmlGalleryLink .= '/'.$arrExplodedPathToGallery[$i+1];
}

print ' » ';
$strHtmlGalleryName = ereg_replace('_', ' ', $arrExplodedPathToGallery[$i]);
if ( strstr($strFilterFlags, PARAM_VALUE_FILTER_NOTHUMBS)
|| strstr($strFilterFlags, PARAM_VALUE_FILTER_SLIDESHOW) ) {
if ($mixPictureId == '') {
print $strHtmlGalleryName;
} else {
$iCurrentPageIndex = ((int)($mixPictureId / $cfg['conf']['thumbnailsPerPage'])) + 1;
print '<a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strHtmlGalleryLink;
print '&'.PARAM_NAME_PAGE.'='.$iCurrentPageIndex.'&'.PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).URL_EXTRA_PARAMS.'"';
print ' class="'.CLASS_DIV_GALHEADER.'">'.$strHtmlGalleryName.'</a>';
}
} else {
print $strHtmlGalleryName;
}

// Notify if we are in "new picture mode"
if ( strstr($strFilterFlags, PARAM_VALUE_FILTER_NEW) )
print ' ('.$cfg['locale']['newPictures'].')';

// Link to slideshow mode
if ( ! strstr($strFilterFlags, PARAM_VALUE_FILTER_SLIDESHOW)
&& count($arrPictureFilenames) > 0 ) {
print ' [<a href="'.$cfg['global']['documentSelf'].'?';
print PARAM_NAME_GALID.'='.$strHtmlGalleryLink;
print '&'.PARAM_NAME_PAGE.'='.$iCurrentPageIndex;
print '&'.PARAM_NAME_PICID.'=0';
print '&'.PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).PARAM_VALUE_FILTER_SLIDESHOW.URL_EXTRA_PARAMS.'"';
print ' class="'.CLASS_DIV_GALHEADER.'">'.$cfg['locale']['filterSlideshow'];
print '</a>]';
}


print "\n".' </div>'."\n";

}


################################################################################
# Recursive function to display all galleries as a hierarchy

function spgm_DisplayGalleryHierarchy($strGalleryId, $iGalleryDepth, $strFilterFlags) {

global $cfg;

$strPathToGallery = DIR_GAL.$strGalleryId;

spgm_Trace(
'<p>function spgm_DisplayGalleryHierarchy</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
.'iGalleryDepth: '.$iGalleryDepth.'<br />'."\n"
.'strFilterFlags: '.$strFilterFlags.'<br />'."\n"
.'strPathToGallery: '.$strPathToGallery.'<br />'."\n"
);

$strHtmlOffset = '';

// check for super gallery.
if ($strGalleryId == '') {
$strPathToSuperGallery = '';
}
else {
$strPathToSuperGallery = $strGalleryId.'/';
for ($i=0; $i < $iGalleryDepth; $i++)
$strHtmlOffset .= '          ';
}

# 'new' label tuning according to the actual new item
if ($cfg['theme']['newItemIcon'] != '') {
$strHtmlNewGallery = $cfg['theme']['newItemIcon'];
$strHtmlNewPictures = $cfg['theme']['newItemIcon'];
$strNewPicture = $cfg['theme']['newItemIcon'];
} else {
$strHtmlSpanNewItem = '<span style="color: #ffd600">';
$strHtmlNewGallery = $strHtmlSpanNewItem.$cfg['locale']['newGallery'].'</span>';
$strHtmlNewPictures = $strHtmlSpanNewItem.$cfg['locale']['newPictures'].'</span>';
$strNewPicture = $strHtmlSpanNewItem.$cfg['locale']['newPicture'].'</span>';
}

$arrSubGalleryFilenames = spgm_CreateGalleryArray($strGalleryId, true);
$_max = count($arrSubGalleryFilenames);

if ($iGalleryDepth == 1 && $_max > 0) {
print '<table class="'.CLASS_TABLE_GALLISTING_GRID.'">'."\n";
print '<tr>'."\n";
}

for ($i=0; $i<$_max; $i++) {
$strGalleryName = $arrSubGalleryFilenames[$i]; //*
$strPathToSubGallery = $strPathToSuperGallery.$strGalleryName; //*
$strGalleryThumbnailBasename = DIR_GAL.$strPathToSuperGallery.PREF_THUMB.$strGalleryName;
$strHtmlGalleryName = ereg_replace('_', ' ', $strGalleryName);
$arrPictureFilenames = spgm_CreatePictureArray($strPathToSubGallery, '', false); // no filter is provided to get all the pictures
$arrGalleryInfo = spgm_GetGalleryInfo($strPathToSubGallery, $arrPictureFilenames);
$iPictureNumber = $arrGalleryInfo[0];
$iNewPictureNumber = $arrGalleryInfo[1];
$strRandomPictureFilename = $arrGalleryInfo[2];

// should never happen
if ($iPictureNumber < 0 || $iNewPictureNumber < 0)
spgm_Error('Error while generating gallery ' + ERRMSG_INVALID_NUMBER_OF_PICTURES);

else {
if ($cfg['conf']['thumbnailsPerPage'] > 0) $strUrlParamPage = '&'.PARAM_NAME_PAGE.'=1';
if ($iPictureNumber == 0) $strHtmlPictureNumber = '';
else {
if ($iPictureNumber > 1) $strHtmlPictureNumber = '[ '.$iPictureNumber.' '.$cfg['locale']['pictures'];
else $strHtmlPictureNumber = '[ '.$iPictureNumber.' '.$cfg['locale']['picture'];
$bAllPicturesNew = ($iPictureNumber == $iNewPictureNumber);
if ($bAllPicturesNew)
$strHtmlPictureNumber = $strHtmlNewGallery.' '.$strHtmlPictureNumber;
if ($iNewPictureNumber>0 && !$bAllPicturesNew) {
$strHtmlPictureNumber .= ' - '.$iNewPictureNumber.' <a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strPathToSubGallery;

$_strFilters = ''; // goo
if ($cfg['global']['propagateFilters']) {
$_strFilters = ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags);
}
if (! strstr($_strFilters, PARAM_VALUE_FILTER_NEW) )
$_strFilters .= PARAM_VALUE_FILTER_NEW;

$strHtmlPictureNumber .= '&'.PARAM_NAME_FILTER.'='.$_strFilters;
$strHtmlPictureNumber .= URL_EXTRA_PARAMS.'">';
if ($iNewPictureNumber == 1) $strHtmlPictureNumber .= $strNewPicture.'</a>';
else $strHtmlPictureNumber .= $strHtmlNewPictures.'</a>';
}
$strHtmlPictureNumber .= ' ]';
}

if ($iGalleryDepth <= 1) {
if (
($i % $cfg['conf']['galleryListingCols'] == 0)
&& ($i != 0)
)
print ' </tr>'."\n".' <tr>'."\n";
print ' <td class="'.CLASS_TD_GALLISTING_CELL.'">'."\n";
}

print ' <table class="'.CLASS_TABLE_GALITEM.'">'."\n";
print ' <tr>'."\n";

// display the gallery icon
$iRowSpan = ($cfg['conf']['galleryCaptionPos'] == BOTTOM) ? 1 : 2;
print ' <td rowspan="'.$iRowSpan.'" valign="top" class="'.CLASS_TD_GALITEM_ICON.'">'."\n";
if ($strHtmlOffset != '') print ' '.$strHtmlOffset."\n";
print ' <a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strPathToSubGallery;
if ($cfg['global']['propagateFilters']) print '&'.PARAM_NAME_FILTER.'='.str_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', str_replace(PARAM_VALUE_FILTER_NEW, '', $strFilterFlags));
print URL_EXTRA_PARAMS.'" class="'.CLASS_TD_GALITEM_TITLE.'">';
// no '\n' above to prevent trailing whitespaces within the link

// TODO: clean up the following part

$bGalleryThumbnailFound = false;
$iSupportedExtensionNumber = count($cfg['global']['supportedExtensions']);
for ($j=0; $j<$iSupportedExtensionNumber; $j++) {
$strGalleryThumbnailFilename = $strGalleryThumbnailBasename.$cfg['global']['supportedExtensions'][$j];
if ( spgm_CheckPerms($strGalleryThumbnailFilename) ) {
$arrPictureSize = getimagesize($strGalleryThumbnailFilename);
print '<img src="'.$strGalleryThumbnailFilename.'" width="'.$arrPictureSize[0].'"';
print ' height="'.$arrPictureSize[1].'"';
print ' alt="" class="'.CLASS_IMG_GALICON.'" />';
$bGalleryThumbnailFound = true;
break;
}
}

if (! $bGalleryThumbnailFound) {
if ($strRandomPictureFilename != '') {
$strGalleryThumbnailFilename = DIR_GAL.$strPathToSubGallery.'/'.PREF_THUMB.$strRandomPictureFilename;
$arrPictureSize = getimagesize($strGalleryThumbnailFilename);
if ($cfg['conf']['galleryIconHeight'] != ORIGINAL_SIZE)
$strHtmlHeight = 'height="'.$cfg['conf']['galleryIconHeight'].'"';
else {
if ($cfg['conf']['galleryIconWidth'] != ORIGINAL_SIZE) {
$iHeight = (int)$arrPictureSize[1]*($cfg['conf']['galleryIconWidth']/$arrPictureSize[0]);
$strHtmlHeight = 'height="'.$iHeight.'"';
}
else $strHtmlHeight = 'height="'.$arrPictureSize[1].'"';
}

if ($cfg['conf']['galleryIconWidth'] != ORIGINAL_SIZE)
$strHtmlWidth = 'width="'.$cfg['conf']['galleryIconWidth'].'"';
else {
if ($cfg['conf']['galleryIconHeight'] != ORIGINAL_SIZE) {
$iWidth = (int)$arrPictureSize[0]*($cfg['conf']['galleryIconHeight']/$arrPictureSize[1]);
$strHtmlWidth = 'width="'.$iWidth.'"';
}
else $strHtmlWidth = 'width="'.$arrPictureSize[0].'"';
}

print '<img src="'.$strGalleryThumbnailFilename.'" '.$strHtmlHeight.' '.$strHtmlWidth;
print ' alt="" class="'.CLASS_IMG_GALICON.'" />';
}
else {
if ($cfg['conf']['galleryIconType'] == GALICON_NONE) {
$fnameGalleryIcon = $cfg['theme']['gallerySmallIcon'];
} else {
$fnameGalleryIcon = $cfg['theme']['galleryBigIcon'];
}

($fnameGalleryIcon != '') ? print $fnameGalleryIcon : print '»';
}
}

print '</a>'."\n";
print ' </td>'."\n";

if ($cfg['conf']['galleryCaptionPos'] == BOTTOM)
print ' </tr>'."\n".' <tr>'."\n";

// display the gallery title
print ' <td class="'.CLASS_TD_GALITEM_TITLE.'">'."\n";
print ' <a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strPathToSubGallery;
if ($cfg['global']['propagateFilters']) print '&'.PARAM_NAME_FILTER.'='.str_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', str_replace(PARAM_VALUE_FILTER_NEW, '', $strFilterFlags));
print URL_EXTRA_PARAMS.'" class="'.CLASS_TD_GALITEM_TITLE.'">'.$strHtmlGalleryName.'</a> '.$strHtmlPictureNumber.' '."\n";
print ' </td>'."\n";
print ' </tr>'."\n";

// display the gallery caption
print ' <tr>'."\n";
print ' <td class="'.CLASS_TD_GALITEM_CAPTION.'">'."\n";
$strPathToGalleryCaption = $strPathToGallery.'/'.$strGalleryName.'/'.FILE_GAL_CAPTION;
if (spgm_CheckPerms($strPathToGalleryCaption)) { // check perms
print ' ';
include($strPathToGalleryCaption);
}
print ' </td>'."\n";
print ' </tr>'."\n";
print ' </table>'."\n";
}

// TODO check this: one test ?
if ($cfg['conf']['subGalleryLevel'] == 0) spgm_DisplayGalleryHierarchy($strPathToSubGallery, $iGalleryDepth+1, $strFilterFlags);
else if ($iGalleryDepth < $cfg['conf']['subGalleryLevel'] - 1) spgm_DisplayGalleryHierarchy($strPathToSubGallery, $iGalleryDepth+1, $strFilterFlags);

if ($iGalleryDepth <= 1)
print ' </td>'."\n";

} // endfor

if ($iGalleryDepth == 1 && $_max > 0) {
print ' </tr>'."\n";
print '</table>'."\n";
}
}

################################################################################
function spgm_DisplayPicture($strGalleryId, $iPictureId, $strFilterFlags) {

global $cfg;

$arrPictureFilenames = spgm_CreatePictureArray($strGalleryId, $strFilterFlags, true);
$iPictureNumber = count($arrPictureFilenames);
$strPathToPictures = DIR_GAL.$strGalleryId.'/';
$strPictureFilename = $arrPictureFilenames[$iPictureId];
$_strFileExtension = strrchr($strPictureFilename, '.');
$strPictureBasename = substr($strPictureFilename, 0, -strlen($_strFileExtension));
$strPictureURL = $strPathToPictures.$strPictureFilename;
$strGalleryName = ereg_replace('_', ' ', $strGalleryId);
$strGalleryName = ereg_replace('/', ' » ', $strGalleryName);
$bSlideshowMode = strstr($strFilterFlags, PARAM_VALUE_FILTER_SLIDESHOW) != FALSE;

if ($cfg['conf']['thumbnailsPerPage'] != 0) {
$iPageNumber = $iPictureNumber / $cfg['conf']['thumbnailsPerPage'];
if ($iPageNumber > (int)($iPictureNumber / $cfg['conf']['thumbnailsPerPage']))
$iPageNumber = (int)++$iPageNumber;
}

spgm_Trace(
'<p>function spgm_DisplayPicture</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
.'strPictureFilename: '.$strPictureFilename.'<br />'."\n"
.'strPathToPictures: '.$strPathToPictures.'<br />'."\n"
.'strPictureURL: '.$strPictureURL.'<br />'."\n"
);


if (($iPictureId < 0) || ($iPictureId > $iPictureNumber-1) || $iPictureId == '')
spgm_Error(ERRMSG_UNKNOWN_PICTURE);

if (! spgm_IsGallery($strGalleryId) )
spgm_Error(ERRMSG_UNKNOWN_GALLERY);


if ( spgm_IsPicture($strPictureFilename, $strGalleryId) ) {
$arrPictureDim = getimagesize($strPictureURL);
$iPreviousPictureId = $iPictureId - 1;
$iNextPictureId = $iPictureId + 1;

// always display the gallery header
spgm_DisplayGalleryNavibar($strGalleryId, $strFilterFlags, $iPictureId, $arrPictureFilenames);

// thumbnails are only displayed if wanted
if ( ! strstr($strFilterFlags, PARAM_VALUE_FILTER_NOTHUMBS)
&& ! $bSlideshowMode )
spgm_DisplayThumbnails($strGalleryId, $arrPictureFilenames, $iPictureId, '', $strFilterFlags);

// display the previous/next arrow section
if ( ! $bSlideshowMode ) {
if ( ! strstr($strFilterFlags, PARAM_VALUE_FILTER_NOTHUMBS) )
print '<br /><br />'."\n"; // for visual improvement
print '<table cellspacing="0" class="'.CLASS_TABLE_PICTURE.'">'."\n";
print '<tr>'."\n";
print ' <td class="'.CLASS_TD_PICTURE_NAVI.'"><a name="pic" id="'.ID_PICTURE_NAVI.'"></a>'."\n";

if ($iPreviousPictureId >= 0)
print ' <a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strGalleryId.'&'.PARAM_NAME_PICID.'='.$iPreviousPictureId.'&'.PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).URL_EXTRA_PARAMS.'#pic">'.$cfg['theme']['previousPictureIcon'].'</a> ';

//multi-language support
$cfg['locale']['pictureNaviBar'] = ereg_replace(PATTERN_CURRENT_PIC, "$iNextPictureId", $cfg['locale']['pictureNaviBar']);
$cfg['locale']['pictureNaviBar'] = ereg_replace(PATTERN_NB_PICS, "$iPictureNumber", $cfg['locale']['pictureNaviBar']);
print ' '.$cfg['locale']['pictureNaviBar'].' ';

if ($iNextPictureId < $iPictureNumber)
print '<a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strGalleryId.'&'.PARAM_NAME_PICID.'='.$iNextPictureId.'&'.PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).URL_EXTRA_PARAMS.'#pic">'.$cfg['theme']['nextPictureIcon'].'</a>'."\n";
print ' </td>'."\n";
}

// Client side zoom buttons
if (count($cfg['conf']['zoomFactors']) > 0) {
print '</tr>'."\n".'<tr>'."\n".' <td class="'.CLASS_TD_ZOOM_FACTORS.'">'."\n";
for ($i=0; $i<count($cfg['conf']['zoomFactors']); $i++) {
$iHeight = (int)($arrPictureDim[1]*$cfg['conf']['zoomFactors'][$i]/100);
$iWidth = (int)($arrPictureDim[0]*$cfg['conf']['zoomFactors'][$i]/100);
print '<input type="button" class="'.CLASS_BUTTON_ZOOM_FACTORS.'" value=" '.$cfg['conf']['zoomFactors'][$i].'% " ';
print 'onClick="document.getElementById('."'".ID_PICTURE."'".').setAttribute('."'".'height'."'".', '.$iHeight.'); ';
print 'document.getElementById('."'".ID_PICTURE."'".').setAttribute('."'".'width'."'".', '.$iWidth.'); ';
print 'document.getElementById('."'".ID_PICTURE_NAVI."'".').scrollIntoView();">'."\n";
}
print "\n".' </td>'."\n";
}

print '</tr>'."\n";


// Load pictures if slideshow mode is enabled
if ( $bSlideshowMode ) {
print '<script language="Javascript">'."\n";
$iPictureNumber = count( $arrPictureFilenames );
$_dim = array();
$_strPicturePath = '';
for ($i=0; $i<$iPictureNumber; $i++) {
$_strPicturePath = $strPathToPictures.$arrPictureFilenames[$i];
$_dim = getimagesize($_strPicturePath);
print ' addPicture(\''.$_strPicturePath.'\', '.$_dim[0].', '.$_dim[1].');'."\n";
}
print '</script>'."\n";
}


// Eventually display the picture
print '<tr>'."\n";
print ' <td class="'.CLASS_TD_PICTURE_PIC.'">'."\n";
if (! ($iNextPictureId < $iPictureNumber) ) $iNextPictureId = 0; // to link to the appropriate next pic

if ( ! $bSlideshowMode ) {
print ' <a href="'.$cfg['global']['documentSelf'].'?';
print PARAM_NAME_GALID.'='.$strGalleryId.'&';
print PARAM_NAME_PICID.'='.$iNextPictureId.'&';
print PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).URL_EXTRA_PARAMS.'#pic">';
}
print '<img id="'.ID_PICTURE.'" src="'.$strPictureURL.'" width="'.$arrPictureDim[0].'" height="'.$arrPictureDim[1].'" alt="'.$strPictureURL;
print '" class="'.CLASS_IMG_PICTURE.'" />';
if ( ! $bSlideshowMode ) {
print '</a>'."\n";
}
print ' </td>'."\n";
print '</tr>'."\n";

// display the picture's filename if needed
if ($cfg['conf']['filenameWithPictures'] == true) {
print '<tr>'."\n";
print ' <td class="'.CLASS_TD_PICTURE_FILENAME.'">'."\n";
print $strPictureBasename.'<br />'."\n";
print ' </td>'."\n";
print '</tr>'."\n";
}

// display the caption
if ($cfg['captions']['pictures'][$strPictureFilename] != '') {
print '<tr>'."\n";
print ' <td class="'.CLASS_TD_PICTURE_CAPTION.'">'."\n";
print $cfg['captions']['pictures'][$strPictureFilename];
print ' </td>'."\n";
print '</tr>'."\n";
}
print '</table>'."\n";

if ( $bSlideshowMode ) {
print '<script language="Javascript">runSlideShow();</script>'."\n";
}

}
else
spgm_Error(ERRMSG_UNKNOWN_PICTURE);

}

################################################################################
function spgm_DisplayGallery($strGalleryId, $iPageIndex, $strFilterFlags) {

spgm_Trace(
'<p>function spgm_DisplayGallery</p>'."\n"
.'strGalleryId: '.$strGalleryId.'<br />'."\n"
.'iPageIndex: '.$iPageIndex.'<br />'."\n"
.'strFilterFlags: '.$strFilterFlags.'<br />'."\n"
);


if (! spgm_IsGallery($strGalleryId) )
spgm_Error(ERRMSG_UNKNOWN_GALLERY);
else {
$arrPictureFilenames = spgm_CreatePictureArray($strGalleryId, $strFilterFlags, true);
if ($iPageIndex == '') $iPageIndex = 1;
spgm_DisplayGalleryNavibar($strGalleryId, $strFilterFlags, '', $arrPictureFilenames);
// display sub-galleries in a hierarchical manner
spgm_DisplayGalleryHierarchy($strGalleryId, 1, $strFilterFlags);
if (count($arrPictureFilenames) > 0)
spgm_DisplayThumbnails($strGalleryId, $arrPictureFilenames, '', $iPageIndex, $strFilterFlags);
// extra vertical padding before displaying the subgalleries
print '<br />'."\n\n";
}
}


################################################################################
function spgm_DisplayThumbnails($strGalleryId, $arrPictureFilenames, $iPictureId, $iPageIndex, $strFilterFlags) {

global $cfg;

$strPathToPictures = DIR_GAL.$strGalleryId.'/';
$iPictureNumber = count($arrPictureFilenames);
$iPageNumber = $iPictureNumber / $cfg['conf']['thumbnailsPerPage'];
if ($iPageNumber > (int)($iPictureNumber / $cfg['conf']['thumbnailsPerPage'])) $iPageNumber = (int)++$iPageNumber;
if (! isset($iPageIndex) ) {
$iPictureOffsetStart = 0;
$iPageFrom = 1;
} else {
if (($iPageIndex == '') || ($iPageIndex < 1) || ($iPageIndex > $iPageNumber)) $iPageIndex = 1;
}

if ($iPictureId == '') $iPictureId = -1; // so picture information are not highlighted
else $iPageIndex = ((int)($iPictureId / $cfg['conf']['thumbnailsPerPage'])) + 1;

$iPictureOffsetStart = ($iPageIndex-1)*$cfg['conf']['thumbnailsPerPage'];
$iPictureOffsetStop = $iPictureOffsetStart + $cfg['conf']['thumbnailsPerPage'];
if ($iPictureOffsetStop > $iPictureNumber) $iPictureOffsetStop = $iPictureNumber;
$iPageFrom = $iPageIndex;

spgm_Trace(
'<p>function spgm_DisplayThumbnails</p>'."\n"
.'strPathToPictures: '.$strPathToPictures.'<br />'."\n"
.'iPictureNumber: '.$iPictureNumber.'<br />'."\n"
.'iPictureId: '.$iPictureId.'<br />'."\n"
.'iPictureOffsetStart: '.$iPictureOffsetStart.'<br />'."\n"
.'iPictureOffsetStop: '.$iPictureOffsetStop.'<br />'."\n"
.'iPageFrom: '.$iPageFrom.'<br />'."\n"
.'iPageNumber: '.$iPageNumber.'<br />'."\n"
.'iPageIndex: '.$iPageIndex.'<br />'."\n"
);



print '<table cellpadding="0" cellspacing="0" class="'.CLASS_TABLE_THUMBNAILS.'">'."\n";
print '<tr>'."\n";

$iItemCounter = 0;

for ($i = $iPictureOffsetStart; $i < $iPictureOffsetStop; $i++) {
$strPictureFilename = $arrPictureFilenames[$i];
$_strFileExtension = strrchr($strPictureFilename, '.');
$strPictureBasename = substr($strPictureFilename, 0, -strlen($_strFileExtension));
$strPictureURL = $strPathToPictures.$strPictureFilename;
$strThumbnailFilename = PREF_THUMB.$arrPictureFilenames[$i];
$strThumbnailURL = $strPathToPictures.$strThumbnailFilename;
$arrThumbnailDim = getimagesize($strThumbnailURL);
$iCurrentPictureIndex = $i + 1; // index that is displayed
$strClassThumbnailThumb = CLASS_TD_THUMBNAILS_THUMB;
$strClassImgThumbnail = CLASS_IMG_THUMBNAIL;
if ($i == $iPictureId) {
$strClassThumbnailThumb = CLASS_TD_THUMBNAILS_THUMB_SELECTED;
$strClassImgThumbnail = CLASS_IMG_THUMBNAIL_SELECTED;
}


// new line
if ( ($iItemCounter++ % $cfg['conf']['thumbnailsPerRow']) == 0)
if ($iItemCounter > 1) print '</tr>'."\n".'<tr>'."\n"; // test for HTML 4.01 compatibility

// TD opening for XHTML compliance when MODE_TRACE is on
// TODO: valign=top does not work when new pictures reside amongst old ones
print ' <td valign="top" class="'.$strClassThumbnailThumb.'">'."\n";
// ...

if ( spgm_IsNew($strPictureURL) && ! strstr($strFilterFlags, PARAM_VALUE_FILTER_NEW) ) {
if ($cfg['theme']['newItemIcon'] != '' ) {
$strHtmlNew = $cfg['theme']['newItemIcon'].'<br />'."\n";
} else {
$strHtmlNew = '<center><span style="color: #ffd600">'.$cfg['locale']['filterNew'];
$strHtmlNew .= '</span></center>'."\n";
}
}
else $strHtmlNew = '';

$arrPictureDim = getimagesize($strPictureURL);

// ...
print ' '.$strHtmlNew;
if ($cfg['conf']['popupPictures']) {
if ( ! strstr($strFilterFlags, PARAM_VALUE_FILTER_NOTHUMBS) ) {
$strFilterFlags .= PARAM_VALUE_FILTER_NOTHUMBS;
}

$iWidth = $cfg['conf']['popupWidth'];
$iHeight = $cfg['conf']['popupHeight'];
$strURL = $cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strGalleryId.'&'.PARAM_NAME_PICID.'='.$i.'&'.PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).URL_EXTRA_PARAMS.'#pic';
;
if ($cfg['conf']['popupFitPicture'] == true) {
$iWidth = $arrPictureDim[0];
$iHeight = $arrPictureDim[1];
$strURL = $strPictureURL;
}

print ' <a href="#?"';
print ' onclick="window.open(\''.$strURL.'\', \'\', ';
print '\'width='.$iWidth.',height='.$iHeight;
print ',scrollbars=1,location=0,';
print 'menubar=0,resizable=1\'); return false;"';
print '>';

} else {
print ' <a href="'.$cfg['global']['documentSelf'].'?';
print PARAM_NAME_GALID.'='.$strGalleryId;
print '&'.PARAM_NAME_PICID.'='.$i.'&';
print PARAM_NAME_FILTER.'='.ereg_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).URL_EXTRA_PARAMS.'#pic">';
}

print '<img src="'.$strThumbnailURL.'" width="'.$arrThumbnailDim[0].'"';
print ' height="'.$arrThumbnailDim[1].'" alt="'.$strThumbnailURL;
print '" class="'.$strClassImgThumbnail.'" /></a><br />'."\n";

// display picture extra information if wanted
if ($cfg['conf']['filenameWithThumbnails'] == true) {
print $strPictureBasename.'<br />';
}
if ($cfg['conf']['pictureInfoedThumbnails'] == true) {
$picsize = (int) (filesize($strPictureURL) / 1024);
print ' [ '.$arrPictureDim[0].'x'.$arrPictureDim[1].' - '.$picsize.' KB ]'."\n";
}

// display caption along with the thumbnail
if ($cfg['conf']['captionedThumbnails'] == true) {
if ($cfg['captions']['thumbnails'][$strPictureFilename] != "") {
print ' <div class="'.CLASS_DIV_THUMBNAILS_CAPTION.'">';
print $cfg['captions']['thumbnails'][$strPictureFilename];
print '</div>'."\n";
} else if ($cfg['conf']['pictureCaptionedThumbnails']) {
if ($cfg['captions']['pictures'][$strPictureFilename] != "") {
print "\n".' <div class="'.CLASS_DIV_THUMBNAILS_CAPTION.'">';
print $cfg['captions']['pictures'][$strPictureFilename];
print '</div>'."\n";
}
}
}

print ' </td>'."\n";
}

// navi bar generation
if ($iPictureNumber > 0) {
print '</tr>'."\n";
print '<tr>'."\n";
print ' <td colspan="'.$cfg['conf']['thumbnailsPerRow'].'" class="'.CLASS_TD_THUMBNAILS_NAVI.'">';
// display "thumbnail navi" if all the thumbs are not displayed on the same page
spgm_DisplayThumbnailNavibar($iPageIndex, $iPageNumber, $strGalleryId, $strFilterFlags);

// toggles
$iPictureNumber_info = spgm_GetGalleryInfo($strGalleryId, $arrPictureFilenames);
spgm_DisplayFilterToggles($strGalleryId, $strFilterFlags, $iPictureNumber_info);
}

// for HTML 4.01 compatibility ...
// if there are no thumbnails, then format the <td> markup correctly
if ($iItemCounter == 0) print ' <td>'."\n";

print ' </td>'."\n";
print '</tr>'."\n";
print '</table>'."\n";

}



#############
# Main
#############

$strParamGalleryId = '';
$strParamPictureId = '';
$strParamPageIndex = '';
$strParamFilterFlags = '';

if (REGISTER_GLOBALS) {
$strParamGalleryId = $$strVarGalleryId;
$strParamPictureId = $$strVarPictureId;
$strParamPageIndex = $$strVarPageIndex;
$strParamFilterFlags = $$strVarFilterFlags;
}
else {
if (isset($_GET[PARAM_NAME_GALID]))
$strParamGalleryId = $_GET[PARAM_NAME_GALID];
if (isset($_GET[PARAM_NAME_PICID]))
$strParamPictureId = $_GET[PARAM_NAME_PICID];
if (isset($_GET[PARAM_NAME_PAGE]))
$strParamPageIndex = $_GET[PARAM_NAME_PAGE];
if (isset($_GET[PARAM_NAME_FILTER]))
$strParamFilterFlags = $_GET[PARAM_NAME_FILTER];
}

spgm_LoadConfig($strParamGalleryId);
spgm_LoadPictureCaptions($strParamGalleryId);

// User filter initialization
if ($cfg['conf']['filters'] != '') {
if (! $cfg['global']['propagateFilters']) {
if ( strstr($cfg['conf']['filters'], PARAM_VALUE_FILTER_NOTHUMBS)
&& ! strstr($strParamFilterFlags, PARAM_VALUE_FILTER_NOTHUMBS) )

Re: [pomoc] [php] galeria SPMG

: wt sie 03, 2004 11:22 pm
autor: farafel
$strParamFilterFlags .= PARAM_VALUE_FILTER_NOTHUMBS;
if ( strstr($cfg['conf']['filters'], PARAM_VALUE_FILTER_NEW)
&& ! strstr($strParamFilterFlags, PARAM_VALUE_FILTER_NEW) )
$strParamFilterFlags .= PARAM_VALUE_FILTER_NEW;
}
}


print "\n\n".'<!-- begin table wrapper -->'."\n".'<table class="'.CLASS_TABLE_WRAPPER.'">'."\n".' <tr>'."\n";

if ($strParamGalleryId == '') {
// the gallery is not specified -> generate the gallery "tree"
spgm_DisplayGalleryHierarchy('', 0, $strParamFilterFlags);
}
else {
print ' <td>'."\n";
if ($strParamPictureId == '') {
// we've got a gallery but no picture -> display thumbnails
spgm_DisplayGallery($strParamGalleryId, $strParamPageIndex, $strParamFilterFlags);
}
else {
spgm_DisplayPicture($strParamGalleryId, $strParamPictureId, $strParamFilterFlags);
}
print ' </td>'."\n";
}

print ' </tr>'."\n";

// display the link to SPGM website
print ' <tr>'."\n".' <td colspan="'.$cfg['conf']['galleryListingCols'].'" class="'.CLASS_TD_SPGM_LINK.'">'."\n";
spgm_DispSPGMLink();
print ' </td>'."\n".' </tr>'."\n";


print '</table>'."\n".'<!-- end table wrapper -->'."\n\n";

?>

Re: [pomoc] [php] galeria SPMG

: wt sie 03, 2004 11:24 pm
autor: farafel
kod pliku konfiguracyjnego spgm.conf

<?php

##############################################################################
# Sample configuration file for SPGM.
# You can modify it at your ease...
#
# The properties defined in this file are inherited in each subgallery.
#################################################### by Sylvain Pajot ########

# duration within wich pictures/galleries are considered to be new.
# value must be a number > 0, or 0 to disable this feature.
# if commented out, default value is 30 (30 days)
#
#$cfg['conf']['newStatusDuration'] = 15;


# number of thumnails per page.
# value must be a number > 0
# if commented out, default value is 10
#
#$cfg['conf']['thumbnailsPerPage'] = 3;


# number of thumnails per row
# value must be a number > 0
# if commented out, default value is 5
#
#$cfg['conf']['thumbnailsPerRow'] = 2;


# number of columns to list galleries into.
# value must be a number > 0
# if commented out, default value is 2
#
#$cfg['conf']['galleryListingCols'] = 1;


# Position of gallery title and caption
# value must be either RIGHT or BOTTOM
# if commented out, default value is RIGHT
#
#$cfg['conf']['galleryCaptionPos'] = RIGHT;


# level of subgalleries to go down into when displaying a gallery.
# value must be a number > or = to 0 (0 to reveal all levels)
# if commented out, default value is 1
#
#$cfg['conf']['subGalleryLevel'] = 1;


# sort type to apply for gallery listing.
# value must be one of the following:
# - SORTTYPE_CREATION_DATE for a sort against galleries' creation date
# - SORTTYPE_NAME for a lexicographical sort against galleries' filename
# - just put a file named gallery.sort within the gallery to sort (containing
# one sub-gallery filename per line) for an explicit sort
# if commented out, default value is SORTTYPE_NAME
#
#$cfg['conf']['gallerySortType'] = SORTTYPE_CREATION_DATE;


# gallery sort options (applied when $gallery_sort_type is
# SORTTYPE_CREATION_DATE or SORTTYPE_NAME).
# value must be either SORT_ASCENDING or SORT_DESCENDING
# if commented out, default value is SORT_ASCENDING
#
#$cfg['conf']['gallerySortOptions'] = SORT_DESCENDING;


# sort type to apply for picture listings.
# value must be one of the following:
# - SORTTYPE_CREATION_DATE for a sort against pictures' creation date
# - SORTTYPE_NAME for a lexicographical sort against pictures' filename
# - just put a file named picture.sort within the gallery to sort (containing
# one picture filename per line) for an explicit sort
# if commented out, default value is SORTTYPE_NAME
#
#$cfg['conf']['pictureSortType'] = SORTTYPE_CREATION_DATE;


# picture sort options (applied when $picture_sort_type is
# SORTTYPE_CREATION_DATE or SORTTYPE_NAME).
# value must be either SORT_ASCENDING or SORT_DESCENDING
# if commented out, default value is SORT_ASCENDING
#
#$cfg['conf']['pictureSortOptions'] = SORT_DESCENDING;


# toggle to display picture information along with the thumbnails.
# value must be true or false
# if commented out, default value is false
#
#$cfg['conf']['pictureInfoedThumbnails'] = false;


# toggle to display picture captions along with the thumbnails.
# value must be true or false
# if commented out, default value is false
#
#$cfg['conf']['captionedThumbnails'] = false;
#$cfg['conf']['pictureCaptionedThumbnails'] = false;

# toggle to display the picture's filename above the thumbnail.
# value must be true or false
# if commented out, default value is false
#
#$cfg['conf']['filenameWithThumbnails'] = true;

# toggle to display the picture's filename above the picture.
# value must be true or false
# if commented out, default value is false
#
#$cfg['conf']['filenameWithPictures'] = false;

# Pop-up picture mode
# Toggling this on displays pictures in a new window along with
# the previous/next buttons
# value must be true or false
# if commented out, default value is false
#
#$cfg['conf']['popupPictures'] = false;


# Pop-up window dimension
# if commented out, default values are 750x600
#$cfg['conf']['popupWidth'] = 800;
#$cfg['conf']['popupHeight'] = 600;
#$cfg['conf']['popupFitPicture'] = false;

# Filters toggles
# Note that filters are not set for good, they are runtime
# modifyable instead, for interaction improvements
# Available toggles:
# - n only new pictures are displayed by default (should not be set)
# - t thumbnails are not displayed along with pictures
# Simply put the desired toggles in this string variable
# ex: $filter = "tn";
# if commented out, no filters are toggled 'on'
#
#$cfg['conf']['filters'] = 't';


# Zoom factor buttons.
# For each value (a positive percentage) within the array, a button is
# generated.
# values within the array must be postive numbers
# if commented out, default array is empty and no buttons are generated
#
#$cfg['conf']['zoomFactors'] = array(50, 100, 150);


# Gallery icon type
# - GALICON_NONE displays the folder icon if it is provided by the used theme
# - GALICON_RANDOM diplays a random thumbnail
# value must be either GALICON_NONE or GALICON_RANDOM
# if commented out, default value is GALICON_NONE.
#
# You can also use a pre-defined thumbnail: put it at the same level than the
# gallery directory and name it _thb_<gallery directory name>.<extension>, which
# takes over the $gallery_icon variable's role.
#
#$cfg['conf']['galleryIconType'] = GALICON_RANDOM;

# Gallery icon height/width in pixels (applied when $gallery_icon is set to
# GALICON_RANDOM).
# One of the two can be omitted to keep the thumbnail's original ratio.
# The ORIGINAL_SIZE value is meant to get the thumbnail's original dimension
# if both parameters are set to this value, whereas the original ratio is
# conserved in case one of them has an integer value.
# Value must be a positive integer or ORIGINAL_SIZE
# if commented out, default value is ORIGINAL_SIZE for both
#
#$cfg['conf']['galleryIconHeight'] = 40;
#$cfg['conf']['galleryIconWidth'] = ORIGINAL_SIZE;


# Language choice.
# values must correspond to a file extension within the "lang" directory (e.g.
# "lang.fr")
# if commented out, default value is "en" for "english"
#
#$cfg['conf']['language'] = 'fr';


# theme used.
# the value refers to a directory name in the "themes" directory
# if commented out, the default theme is used
#
#$cfg['conf']['theme'] = 'bvk';

?>

Re: [pomoc] [php] galeria SPMG

: wt sie 03, 2004 11:26 pm
autor: farafel
kod pliku odpowiedzialnego za skurke
spgm_style.css
BODY {
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
background-color: #DDDDDD;
color: #000000;
}

A {
color: #555555;
background-color: transparent;
}

A:visited {
color: #555555;
background-color: transparent;
}



IMG { vertical-align: middle; }
IMG.img-picture { border: 1px solid #333333; }
IMG.img-folder { border: 0px; }
IMG.img-galicon { border: 1px solid #555555; }
IMG.img-thumbnail { border: 1px solid #333333; }
IMG.img-thumbnail-selected { border: 1px solid #0000ff; }
IMG.img-picture-prev { border: 0px; }
IMG.img-picture-next { border: 0px; }
IMG.img-thmbnavi-prev { border: 0px; }
IMG.img-thmbnavi-next { border: 0px; }
IMG.img-new { border: 0px; }


TABLE.table-wrapper {
border: 1px solid #000000;
background-color: #ffffff;
width: 600px;
padding: 10px;
margin-left: auto;
margin-right: auto;
}




TD.td-thumbnails-thumb {
padding: 6px;
font-family: helvetica, arial, sans-serif;
color: #555555;
font-size: 8pt;
vertical-align: bottom;
background-color: transparent;
white-space: nowrap;
}

TD.td-thumbnails-thumb-selected {
padding: 5px;
font-family: helvetica, arial, sans-serif;
color: #333333;
font-size: 8pt;
font-weight: bold;
background-color: transparent;
vertical-align: bottom;
}

DIV.div-thumbnails-caption {
font-family: helvetica, arial, sans-serif;
color: #000000;
font-size: 8pt;
font-weight: normal;
background-color: transparent;
}



TABLE.table-main-title {}

TD.td-main-title {
font-family: verdana, helvetica, arial, sans-serif;
color: #000000;
font-size: 12pt;
font-weight: bold;
background-color: transparent;
}

TD.td-main-title-spgm-link {
color:#999999;
font-size:8pt;
font-family: helvetica, arial, sans-serif;
text-align: center;
background-color: transparent;
}

A.a-spgm-link {
color: #999999;
font-size:8pt;
font-family: helvetica, arial, sans-serif;
background-color: transparent;
}





TABLE.table-gallisting-grid {
}

TD.td-gallisting-cell {
}




TABLE.table-galitem {
width: 100%;
}

TD.td-galitem-icon {
padding-right: 10px;
}

TD.td-galitem-title {
font-family: helvetica, arial, sans-serif;
font-size: 10pt;
font-weight: bold;
width: 100%;
text-align: left;
}

TD.td-galitem-caption {
font-family: helvetica, arial, sans-serif;
font-size: 10pt;
font-style: italic;
}




TABLE.table-picture {
width: 100%;
text-align: center;
}

TD.td-picture-navi {
font-family: helvetica, arial, sans-serif;
font-size: 10pt;
font-weight: bold;
color: #000000;
text-align: center;
background-color: transparent;
}

TD.td-zoom-factors {
padding: 3pt;
text-align: center;
}

INPUT.button-zoom-factors {
border: 1px solid #777777;
font-family: helvetica, arial, sans-serif;
font-size: 9pt;
font-weight: bold;
color: #777777;
background-color: #dddddd;
text-align: center;
}

TD.td-picture-pic {}

TD.td-picture-filename {
font-family: helvetica, arial, sans-serif;
font-size: 8pt;
font-weight: bold;
text-align: center;
background-color: #ececec;
padding:7px;
background-color: transparent;
}

TD.td-picture-caption {
font-family: helvetica, arial, sans-serif;
font-size: 9pt;
text-align: center;
font-style:italic;
background-color: #ececec;
/*border: 1px dashed #333333;*/
padding:7px;
background-color: transparent;
}




TABLE.table-thumbnails {
margin-left: auto;
margin-right: auto;
}

TD.td-thumbnails-navi {
color: #000000;
border-top: 2px solid #444444;
font-family: helvetica, arial, sans-serif;
font-size: 10pt;
font-weight: bold;
text-align: right;
padding: 8px;
}

SPAN.span-filters {
font-size: 8pt;
font-weight: normal;
}


DIV.div-galheader {
font-family: verdana, helvetica, arial, sans-serif;
font-size: 10pt;
font-weight: bold;
color: #000000;
margin-bottom: 20px;
padding: 1px;
width: 100%;
text-align: left;
}

Re: [pomoc] [php] galeria SPMG

: wt sie 03, 2004 11:27 pm
autor: farafel
kolejny plik odpowiedzilny za wyglad
spgm.thm
<?php

###########################################
# SPGM's default theme file
#
################# by Sylvain Pajot ########

# the gallery icon (small size)
$cfg['theme']['gallerySmallIcon'] = 'folder.png';

# the gallery icon (thumbnail size)
$cfg['theme']['galleryBigIcon'] = 'gal_big.png';

# the image that highlights new pictures
$cfg['theme']['newItemIcon'] = 'new.png';

# previous picture button icon
$cfg['theme']['previousPictureIcon'] = 'previous_pic.png';

# next picture button icon
$cfg['theme']['nextPictureIcon'] = 'next_pic.png';

# previous thumnail page button icon
$cfg['theme']['previousPageIcon'] = 'previous_page.png';

# next thumnail page button icon
$cfg['theme']['nextPageIcon'] = 'next_page.png';

?>