<?php
/**
 * $Source: /home/cvs/nukescripts/blocks/block-CPG_Center_Last_Images.php,v $
 * $Revision: 1.0.0 $
 * $Author: cyril $
 * $Date: 2007/04/17 09:39:51 $
 * BugFix Dav ( Bug 233 )
 */
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2007                                            */
/* http://www.php-maximus.org                                           */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* 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.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
/* Portage Coppermine Photo Gallery                                     */
/************************************************************************/
defined('MAXIMUS') or die ('Access denied block CPG MAXIMUS directly...');

define('NO_HEADER', true);
global $prefix, $CONFIG, $lang_block;
$content = "";

include_once('modules/Coppermine/include/constants.php');
include_once('modules/Coppermine/include/load.inc.php');

$length = secure( $CONFIG['thumbcols'], 'num', '1' ); //nombre d'images

$result = $GLOBALS['db']->sql_query("SELECT pid, filepath, filename, p.aid, p.title FROM ".TABLE_CPG_PICTURES." AS p INNER JOIN ".TABLE_CPG_ALBUMS." AS a ON (p.aid = a.aid ) WHERE approved='YES' GROUP BY pid ORDER BY pid DESC LIMIT 0, $length");
$content .= '<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"><tr>';
$pic = 0;
while ($row = $GLOBALS['db']->sql_fetchrow($result)) {

        $thumb_title  = secure( $row['filename'], 'strip', '1');
	$row['title'] = secure( $row['title'], 'strip', '1');
        if ($row['title'] != '') {
            $thumb_title = $row['title'];
        } else {
            $thumb_title = substr($row['filename'], 0, -4);
        }

    $content .= '<td align="center"><a href="modules.php?name=Coppermine&amp;op=displayimage&amp;album=lastup&amp;cat=0&amp;pos=' . $pic . '"><img src="' . get_pic_url($row, 'thumb') . '" border="0" alt="' . $thumb_title . '" title="' . $thumb_title . '" /><br />' . truncate_stringblocks($thumb_title) . '</a></td>';
    $pic++;
}
$content .= '</tr><tr><td colspan="'.$length.'" align="center"><br /><a href="modules.php?name=Coppermine">' . $lang_block["photogallery"] . '</a></center></td></tr></table>';