Still a "not many frills just tons of content", it's the best choice to me when a gallery is not made of 1 level and 1 album.
I always thought it would have been a great thing if we could import the images into wcms.
Into Sunsplash days as i am now, i asked my friend and colleague Anthony Barchiesi to write down a script to display the images into wcms. It's a simple script that takes images from coppermine and shrinks them to the needed size, being able to display a full gallery into the site.
The usage is pretty simple:
{COPPER:gallerynum, imagenum, width, height}
Examples:
{COPPER:770,1,400}
will show image 1 (remember they start from 0 as usual) from gallery 770, large 400px and with his height scaled proportionally
{COPPER:420,ALL,210,100}
would show all images from gallery 420, large 210px and 100px high (in case for some reason you needed images scaled to a certain ratio)
Lightbox is enabled, but you need to have it turned on on the article by checking the button.
You have two classes where you can customize stuff, which are the
coppermineLink to customize the appearance of the link itself
coppermine to customize the appearance of the image
SCRIPT
Code: Select all
<?php
/*************************************************************************************
Copyright notice
(c) 2009-2010 Anthony Barchiesi (antbar81@gmail.com) // All rights reserved.
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.
The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
A copy is found in the textfile GPL.txt and important notices to the license
from the author is found in LICENSE.txt distributed with these scripts.
This script 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.
This copyright notice MUST APPEAR in all copies of the script!
*************************************************************************************/
if(strpos($content['all'], '{COPPER')) {
$content['all'] = preg_replace_callback('/\{COPPER(.*?)\}/', 'gallery', $content['all']);
}
function gallery($matches) {
global $content, $aktion;
$data = explode(',', trim($matches[1], ':') );
$data[0] = empty($data[0]) ? '' : trim($data[0]);
$data[1] = empty($data[1]) && $data[1] != 0 ? '' : trim($data[1]);
$data[2] = empty($data[2]) ? '0' : trim($data[2]);
$data[3] = empty($data[3]) ? '0' : trim($data[3]);
if ($data[0] == '' || $data[1] == ''){
// show no error on front page in case of wrong call
return '';
exit;
}
$coppermineDir = 'http://www.site.com/coppermine/albums/'; // coppermine path
// Coppermine configuration file
// MySQL configuration
$CONFIG['dbserver'] = ""; // Your database server
$CONFIG['dbuser'] = ""; // Your mysql username
$CONFIG['dbpass'] = ""; // Your mysql password
$CONFIG['dbname'] = ""; // Your mysql database name
// MySQL TABLE NAMES PREFIX
$CONFIG['TABLE_PREFIX'] = "";
$connessione = @mysql_connect($CONFIG['dbserver'],$CONFIG['dbuser'],$CONFIG['dbpass']);
$selDb = @mysql_select_db($CONFIG['dbname'],$connessione);
if($selDb){
// prende la foto n¡ $parameter[1] partendo da un ordinamento contrario di ID
if($data[1] == 'ALL' || $data[1] == 'all'){
$sql = "SELECT * FROM ".$CONFIG['TABLE_PREFIX']."pictures WHERE aid='".$data[0]."' ORDER BY pid";
} else if($data[1] >= 0) {
$sql = "SELECT * FROM ".$CONFIG['TABLE_PREFIX']."pictures WHERE aid='".$data[0]."' ORDER BY pid LIMIT ".$data[1].",1";
} else {
return '';
exit;
}
$result = mysql_query($sql);
$text = '';
while($row = mysql_fetch_array($result)){
// shrink and resize
list($width, $height) = getimagesize($coppermineDir.$row['filepath'].$row['filename']);
if($data[2] >0 && $data[3] >0){
$newW = $data[2];
$newH = $data[3];
} else if($data[2] >0 && $data[3] == 0){
$newW = $data[2];
$newH = $height*$newW/$width;
} else if($data[2] == 0 && $data[3] > 0){
$newH = $data[3];
$newW = $width*$newH/$height;
} else if($data[2] == 0 && $data[3] == 0){
$newW = $width;
$newH = $height;
}
$text .= '<a class="coppermineLink" href="'.$coppermineDir.$row['filepath'].$row['filename'].'" rel="lightbox[galleria]"><img class="coppermine" src="thumb.php?foto='.$coppermineDir.$row['filepath'].$row['filename'].'&width='.$newW.'&height='.$newH.'" alt="galery" /></a>';
}
}
return $text;
}
?>
INSTALLATION
1) edit those lines configuring those to your setup:
$coppermineDir = 'http://www.site.com/coppermine/albums/'; // coppermine path
// Coppermine configuration file
// MySQL configuration
$CONFIG['dbserver'] = "myserver"; // Your database server
$CONFIG['dbuser'] = "sql_username"; // Your mysql COPPERMINE username
$CONFIG['dbpass'] = "sql_password"; // Your mysql COPPERMINE password
$CONFIG['dbname'] = "sql_dbname"; // Your mysql database name
please double check that these data are the ones from COPPERMINE, not from wcms, especially if you got different dbs
2) Copy the above script into a php file, upload it into template/inc_script/frontend_render directory in your website
that's all, folks!

F