<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/



class lc_album_albums
{
	var $page=1;
	var $total=0;
	var $items_at_page=10;
	public $pager=array();
	
	function __construct($page)
	{
		if($page) $this->page=$page;
	}
	
	public function getList()
	{
		if (!$this->total) $this->total=Db::i()->selectCell("SELECT COUNT(album_id) FROM ?_lc_album_albums");
		if ($this->total)
		{
			$albums=Db::i()->select("SELECT * FROM ?_lc_album_albums ORDER BY sort LIMIT ?d, ?d", $this->_getStart(), $this->items_at_page);
			if ($albums) foreach($albums as $key=>$album)
			{
				$albums[$key]['describe_html']=getbb($album['describe']);
				if ($album['logo']) $albums[$key]['logo_file']=lc_album_main::$basepath.lc_album_main::$logo_path.'/'.$album['logo'];
			}
			return $albums;
		}
	}
	
	protected function _getStart()
	{
		$pg=new Paginator($this->total, $this->items_at_page, $this->page);
		$this->pager=$pg->getPages();
		$this->page=$this->pager['current'];
		return $this->pager['sql_start'];
	}
}