<?php
/*
 *
 * sflog!
 * Copyright (C) 2005 Alberto Sfolcini <a.sfolcini@gmail.com>
 *
 * This file is a part of sflog!.
 *
 * sflog! 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.
 *
 * sflog! 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

			  	 
require_once(dirname(__FILE__)."/../common/File.class.php");
require_once(dirname(__FILE__)."/../common/utils.func.php");
require_once(dirname(__FILE__)."/../cms/Errors.inc.php");

	
/**
 * @title			: PhotoBlogEntry
 * @description		: Manages photoblog's entries   
 * @date			: 20-Dec-2005   
 * @author			: Alberto Sfolcini  <a.sfolcini@gmail.com>
 */
class PhotoBlogEntry {
	
	var $blogID;
	var $photoBlogID;
	
	/**
	 * Constructor
	 * @param $blogID string
	 * @param $photoBlogID string
	 */
	function PhotoBlogEntry($blogID,$photoBlogID){
		error_reporting(E_USER_ERROR);
		$this->blogID = $blogID;
		$this->photoBlogID = $photoBlogID;
	}

	/**
	 * Get all entries
	 * @return 	array[0][] => path to fullsize Image
	 * 			array[1][] => path to thumbnail Image
	 */	
	function getAllEntries(){
		$file = new File();
		if (!strcasecmp(trim($this->photoBlogID),"")==0)
			$contentDir = "./blogs/".$this->blogID.PHOTOBLOG_UPLOADS.$this->photoBlogID;
		// check if photoblog's dir exists
		if (!file_exists($contentDir)){
			print(ERROR_FYLESYSTEM_MISSING);
		} else {
			// scans photoblog's dir
			$files=$file->scandir($contentDir,1);
			$i = 0;
			foreach($files as $key=>$val) {
				if ($val[0]!=".") {
					$file = $contentDir.'/'.$val;
					if (is_dir($file)==false){
						if (!strcasecmp(substr($val,-8),".comment")==0){
							$ret[0][$i] = $file;
							$ret[1][$i] = $contentDir.PHOTOBLOG_THUMBS.$val;
							$i++;
						}
					}
				} // end if
	 		} // end for
	 		return $ret;
	 	}
	} // end
		
} // end class
?>
