<?php
	include_once("./common.php");

	//infos format page
	define('MENU_PAGE', ACCUEIL);

	$PHORUM["DATA"]["tribune_grande"] = 1;
	$PHORUM["DATA"]["tab_afficher"] = "'calendrier', 'search'";

	if(empty($_GET["tdate"])) {
		html_title('La tribune en pleine page');
		$year=date('Y');
		$month=date('m');
		$day=date('d');
	}
	else {
		$tdate = explode(",",$_GET["tdate"]);
		$year = $tdate[2];	
		$month = $tdate[1];	
		$day = $tdate[0];
		$PHORUM["DATA"]["tdate"] = $_GET["tdate"];
		html_title('Les archives de la tribune de l\'Asile du '.$day.'/'.$month.'/'.$year);
		
		//hier
		$PHORUM["DATA"]["hier"] = make_date_fr(mktime(0,0,0,$month,$day-1,$year));
		//demain
		$demain = mktime(0,0,0,$month,$day+1,$year);
		if(time()>$demain)
			$PHORUM["DATA"]["demain"] = make_date_fr($demain);
	}

	$search_motif = isset($_GET["s"]) ? trim($_GET["s"]) : '';
	$tribune =Tribune::doMagic(40, $search_motif);
	$PHORUM["DATA"]["TRIBUNE"] = $tribune["messages"];
	$PHORUM["DATA"]["LIENS_TRIBUNE"] = $tribune["liens"];

	$PHORUM["DATA"]["CALENDRIER"]["current_date"] = mktime(0,0,0,$month,$day,$year);
	$PHORUM["DATA"]["CALENDRIER"]["current_month"] = strftime('%B', mktime(0,0,0,$month,$day,$year));
	$PHORUM["DATA"]["CALENDRIER"]["current_year"] = strftime('%Y', mktime(0,0,0,$month,$day,$year));
	$PHORUM["DATA"]["CALENDRIER"]["limite_min"] = mktime(0,0,0,2,9,2006);
	$PHORUM["DATA"]["CALENDRIER"]["limite_max"] = time();

	$PHORUM["DATA"]["CALENDRIER"]["icone"] = array("mois" => strftime("%b", $PHORUM["DATA"]["CALENDRIER"]["current_date"]), "jour" => date('d'));

	//liste des membres connectes en ce moment
	$PHORUM["DATA"]["LAST_ACTIVE"] = get_last_active();

	//last com
	include_once("classes/last_com.class.php");
	$last_com = new last_com($userid,$isadmin);
	$PHORUM["DATA"]["LAST_COM"] = $last_com->get();
	$PHORUM["DATA"]["LAST_COM_ONGLET"] = "";

	//sondage
	include_once("classes/sondage.class.php");
	$sondage = new sondage();
	$PHORUM["DATA"]["SONDAGE"]["INFOS"] = $sondage->getActif();
	$PHORUM["DATA"]["SONDAGE"]["PROPOSITIONS"] = $sondage->getResultatsPropositions();
	//l'utilisateur a deja vote ?
	if($sondage->verifieVote($userid,Get_ip()))
		$PHORUM["DATA"]["A_VOTE"]=1;

	//last breves
	include("include/home/breves.php");

	$conn = database::getInstance();

/*
	//home articles
	if(isset($_GET['page']) && filter_var($_GET['page'], FILTER_VALIDATE_INT))
		$page = $_GET['page'];
	else
		$page = 1;
	if($page>1)
		$PHORUM["DATA"]["page_prev"] = $page-1;
	$PHORUM["DATA"]["page_next"] = $page+1;
		
	//items
	include_once("classes/item.class.php");
	$item = new item();
	
	//Definition du nombre de pages d'articles existants
	$nb_articles = $item->get_nb($isadmin);

	//liste des items
	$item_par_page = 1;
	$item->get_list($page, $item_par_page, $isadmin);
	$tab_article = $item->articles;
	$tab_ord = $item->order;
*/

	//last article
	$sql = "SELECT `id` AS `id_article`, `date`, `titre`, `titre_url`, `miniature`, `origine` AS `type`, 
					`auteur`, `id_auteur`, `nb_commentaires` 
			FROM `article` 
			WHERE `show` >= 2
			ORDER BY `show` DESC, `date` DESC 
			LIMIT 1";
	$conn->query($sql);
	if ($conn->has_rows()) {
		while($row = $conn->fetch()) {
			$row['titre'] = htmlentities($row['titre'], ENT_COMPAT, "UTF-8");
			$row['date_fr'] = make_date_fr($row['date']);
			$article = $row;
		}
		$PHORUM["DATA"]["LAST_ARTICLE"] = $article;
	}

	//last articles blogs
	include_once("classes/blog_article.class.php");
	$blog_article = new blog_article();
	$PHORUM["DATA"]["LAST_BLOGS"] = $blog_article->get_last(2);

	$PHORUM["DATA"]["colonne"] = array("last_articles", "home_last_breves", "last_com", "home_sondage");

	//chargement et remplissage des templates
	include phorum_get_template("home_head");
	include phorum_get_template("tribune_grande");
	include phorum_get_template("home_foot");
?>