<?php
/**
 * $Source: /home/cvs/nukescripts/blocks/block-CPG_Last_pictures_scroll.php,v $
 * $Revision: 1.0.0 $
 * $Author: cyril $
 * $Date: 2007/04/19 17:01:24 $
 *
 */
/************************************************************************/
/* 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 Last Pictures scroll directly...');

global $db, $prefix, $CONFIG, $cpg_dir, $lang_block;

$cpg_block = true;

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

$length = secure( $CONFIG['thumbcols'], 'num', '1' ); //nombre d'images
$title_length = 15; // longueur du titre maximale

$content = '';
$content .= '<p><marquee behavior="scroll" direction="up" height="150" scrollamount="1" scrolldelay="1" onMouseOver=\'this.stop()\' onMouseOut=\'this.start()\'><center>';

$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 $length");
$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 .= '<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, $title_length) . '</a><br />';
    $pic++;
}
$content .= '</center></marquee></p><p align="center"><a href="modules.php?name=Coppermine">' . $lang_block["photogallery"] . '</a></p>';

