<?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 guest_api extends ModuleAPI
{
	public $module='guest';
	protected $implemented=array('sitemap');
	
	function sitemap()
	{
		$result=array();
		
		$link=getModulePath($this->module);
		$result[$link]=array('changefreq'=>'hourly','lastmod'=>time());
		
		//TODO перенести в mapper
		$posts=Db::i()->selectCol("SELECT putdate as `date` FROM ?_guest ORDER BY putdate");
		
		if ($posts) {
			$guestbook_posts_at_page=config::get('module.guest.guestbook_posts_at_page');
			for ($i=1;$i<(count($posts)-1);$i+=$guestbook_posts_at_page) {
				$date=$posts[$i]; 
				
				$changefreq=getFreq($date);
				
				$loc=LabCMS::instance()->url(ceil($i/$guestbook_posts_at_page), false, false, $link);
				
				$result[$loc]=array('changefreq'=>$changefreq,'lastmod'=>$date);
			}
		}
		return $result;
	}
}