<?php
// $Id: data.inc.php,v 1.4 2005/10/22 08:37:48 ohwada Exp $

// 2005-10-01 K.OHWADA
// category, counter

// 2005-06-20 K.OHWADA
// get and set image width, height

// 2005-06-06 K.OHWADA
// small change for plugin.

//================================================================
// What's New Module
// get aritciles from module
// for myAlbum-P 2.84  <http://www.peak.ne.jp/xoops/>
// 2004-11-26 cinnamons <http://www.cinnamons.jp>
//================================================================

if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;

// $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
$mydirname = basename( dirname( __FILE__ ) ) ;

if( ! preg_match( '/^myalbum\d*$/' , $mydirname ) ) die ( "invalid dirname of myalbum: " . htmlspecialchars( $mydirname ) ) ;

eval( '

function '.$mydirname.'_new( $limit=0, $offset=0)
{
	global $xoopsDB ;


	include( XOOPS_ROOT_PATH."/modules/'.$mydirname.'/include/read_configs.php" ) ;

//	$sql = "SELECT l.lid,l.cid,l.title,l.ext,l.submitter,l.date,t.description FROM $table_photos l LEFT JOIN $table_text t ON t.lid=l.lid WHERE status>0 ORDER BY l.date DESC";

	$sql = "SELECT p.lid, p.cid, p.title as ptitle, p.ext, p.hits, p.submitter, p.date, t.description, c.title as ctitle FROM $table_photos p, $table_text t, $table_cat c WHERE t.lid=p.lid AND p.cid=c.cid AND p.status>0 ORDER BY p.date DESC";

	$result = $xoopsDB->query( $sql , $limit , $offset ) ;
	$ret = array() ;

	$url_mod = XOOPS_URL."/modules/".$mydirname;

	while( $row = $xoopsDB->fetchArray($result) ) 
	{
		$lid = $row["lid"];
		$ext = $row["ext"];

		$file_image = $thumbs_dir."/".$lid.".".$ext;
		$image_url = "";
		$width     = "";
		$height    = "";

		// added 2004/12/02
		if( is_file($file_image) ) 
		{
			$image_url = $thumbs_url."/".$lid.".".$ext;

// get image width, height
			$size = getimagesize( $file_image );

			if ($size)
			{
				$width  = intval( $size[0] );
				$height = intval( $size[1] );
			}

		}
		else 
		{
			$image_url = "";
		}
		// end

		$ret[] = array(
			"link"     => $url_mod."/photo.php?lid=".$lid ,
			"cat_link" => $url_mod."/viewcat.php?cid=".$row["cid"] ,
			"title"    => $row["ptitle"] ,
			"cat_name" => $row["ctitle"] ,
			"hits"   => $row["hits"] ,
			"time"   => $row["date"] ,
			"image"  => $image_url,
			"width"  => $width,
			"height" => $height,
			"id"  => $lid ,
			"uid" => $row["submitter"] ,
			"description" => $row["description"]
		) ;
	}

	return $ret;
}

' ) ;

?>