IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Fatal error: Call to undefined method


Sujet :

Langage PHP

  1. #1
    Futur Membre du Club
    Homme Profil pro
    formateur
    Inscrit en
    Octobre 2014
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : formateur

    Informations forums :
    Inscription : Octobre 2014
    Messages : 17
    Points : 5
    Points
    5
    Par défaut Fatal error: Call to undefined method
    Bonjour.

    Je reviens de nouveau sur le forum suite à mes précédents messages. En effet depuis que Hostpapa nous a migré sur le dernier PHP notre site est surbeugué. Pour rappel celui-ci a été développé par un développeur freelance qui semble avoir fermé boutique et est donc injoignable. Du coup j'essaie de le rafistoler sachant que je n'ai strictement aucune notion de php.

    Voici donc mon problème : dans un "CMS" maison nous avons une fonctionnalité permettant d'importer une image. Or, lorsqu'on y fait appel j'ai le message suivant :

    Fatal error: Call to undefined method Fichier::estImageClassique() in /home/o102272/public_html/lsl_website/gestion_catalogue_categorie.php on line 37
    J'ai donc regardé la fameuse ligne 37 qui me dit ce qui suit :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    /* 36 */ require_once('./ressources/dependances/fichier.php');
    /* 37 */ if (Fichier::estImageClassique($_FILES['catalogue_categorie_image_url']['name']))
    Je suis par conséquent allé voir dans le fameux fichier.php et là.... aucune fonction estImageClassique

    Donc je sèche. Est-ce que j'ai regardé au bon endroit ?

    Je vous joins ci-dessous les fichiers concernés.

    Merci d'avance pour votre aide.

    fichier.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    <?php
    	// v20110725
     	// LSL (c) Tous droits réservés
     
    	class Fichier
    	{
    		private $adresse;
    		private $extension;
     
    		public static $_getImagesHtml_images = array();
     
    		function Fichier($adresse_fichier)
    		{
    			$this->adresse = $adresse_fichier;
    			$this->extension = strtolower(substr($this->adresse, strrpos($this->adresse, '.') + 1));
    		}
     
    		function getAdresse() { return $this->adresse; }
    		public function getSiteRacine($url)
    		{
    			$url = parse_url($url);
    			return $url['scheme'].'://'.$url['host'].'/';
    		}
    		//public function getSiteRacine($url) { return preg_replace('^(http://){1}([^/]*)(/){1}(.*)$', '$2', $url); }
    		function getExtension($adresse_fichier = false)
    		{
    			if ($adresse_fichier !== false)
    				return strtolower(substr($adresse_fichier, strrpos($adresse_fichier, '.') + 1));
    			return $this->extension;
    		}
    		function getTailleIntitule($adresse = null)
    		{
    			if ($adresse == null)
    				$adresse = $this->adresse;
    			$taille = filesize($adresse);
    			if ($taille > (1024 * 1024))
    				return number_format($taille / 1024 / 1024, 2, ',', ' ').' Mo';
    			if ($taille > 1024)
    				return number_format($taille / 1024, 2, ',', ' ').' Ko';
    			return $taille.' o';
    		}
    		function getMimeType($filename, $mimePath = '/etc')
    		{
    			$fileext = substr(strrchr($filename, '.'), 1);
    			if (!empty($fileext))
    			{
    				$regex = "/^([\w\+\-\.\/]+)\s+(\w+\s)*($fileext\s)/i";
    				$lines = file($mimePath.'/mime.types');
    				foreach($lines as $line)
    				{
    					if (substr($line, 0, 1) == '#') continue; // skip comments
    					$line = rtrim($line) . " ";
    					if (!preg_match($regex, $line, $matches)) continue; // no match to the extension
    					return ($matches[1]);
    				}
    			}
    			switch (Fichier::getExtension($filename))
    			{
    				case 'dot': return 'application/msword';
    			}
    			return 'application';
    		}
     
    		function existe()
    		{
    			return file_exists($this->adresse);
    		}
     
    		function changePlace($autre_adresse)
    		{
    			$retour = false;
    			if (is_uploaded_file($this->adresse))
    				$retour = move_uploaded_file($this->adresse, $autre_adresse);
    			else $retour = rename($this->adresse, $autre_adresse);
    			if ($retour)
    			{
    				$this->adresse = $autre_adresse;
    				$this->extension = Fichier::getExtension($autre_adresse);
    			}
    			return $retour;
    		}
    		function deplace($nouvelle_adresse)
    		{
    			return $this->changePlace($nouvelle_adresse);
    		}
    		function copie($nouvelle_adresse)
    		{
    			return copy($this->adresse, $nouvelle_adresse);
    		}
    		/** Retourne la taille récursive d'un dossier en octets */
    		public function getTailleDossier($adresseDossier)
    		{
    			$result = 0;
    			if (!is_dir($adresseDossier) || !is_readable($adresseDossier))
    				return 0;
    			$dossier = dir($adresseDossier);
    			while ($fichier = $dossier->read())
    				if (($fichier != '.') && ($fichier != '..'))
    				{
    					if (@is_dir($adresseDossier.'/'.$fichier))
    						$result += Fichier::getTailleDossier($adresseDossier.'/'.$fichier);
    					else $result += filesize($adresseDossier.'/'.$fichier);
    				}
    			$dossier->close();
    			return $result;
    		}
    		/** Créer le dossier uniquement si inexistant */
    		public function creeDossier($adresseDossier)
    		{
    			if (!is_dir($adresseDossier))
    				mkdir($adresseDossier);
    		}
     
    		function encodePourAdresse($texte, $caractere_separateur = '-', $tout_en_minuscule = true)
    		{
    			$ch = str_replace(
    				array(' ','_','-','.','\'','’','&','~','#','`','\\','/','^','@','°','+','*','$','€','£','¤','%','§','<','>'),
    				$caractere_separateur,
    				str_replace(
    					array(',',';','?','!',':','"','{','}','(',')','[',']','«','»','='),
    					'',
    					str_replace(
    						array('À','Â','à','á','â','ã','ä','å','ò','ó','ô','õ','ö','ø','È','É','Ê','è','é','ê','ë','Ç','ç','Î','ì','í','î','ï','ù','ú','û','ü','ÿ','ñ','²','œ','Œ'),
    						array('A','A','a','a','a','a','a','a','o','o','o','o','o','o','E','E','E','e','e','e','e','C','c','I','i','i','i','i','u','u','u','u','y','n','2','oe','Oe'),
    						$texte
    					)
    				)
    			);
    			if ($tout_en_minuscule)
    				$ch = strtolower($ch);
    			return preg_replace('/(\\'.$caractere_separateur.')+/', $caractere_separateur, trim($ch, $caractere_separateur));
    		}
    		// Retourne le nom du fichier s'il est libre, sinon NOM_FICHIER-1 si libre, sinon NOM_FICHIER-2, etc
    		public function getNomFichierLibre($fichier,$separateur)
    		{
    			if (file_exists($fichier))
    			{
    				$tab = array();
    				if (preg_match('/(.*)(\\'.$separateur.'){1}([0-9]+)([\.]){1}([a-zA-Z0-9]){1,5}/', $fichier, $tab) != false)
    					if (count($tab) > 4)
    						return Fichier::getNomFichierLibre($tab[1].$tab[2].(intval($tab[3]) + 1).'.'.Fichier::getExtension($fichier), $separateur);
    				return Fichier::getNomFichierLibre(substr($fichier, 0, strrpos($fichier, '.')).$separateur.'1'.'.'.Fichier::getExtension($fichier), $separateur);
    			}
    			return $fichier;
    		}
     
    		//<-- Images
    			function getCheminImagesPourHtml($html)
    			{
    				Fichier::$_getImagesHtml_images = array();
    				$html = str_get_html($html);
    				$html->set_callback('_getImagesHtml_rechercheImages');
    				$html = $html->save();
    				return Fichier::$_getImagesHtml_images;
    			}
    		//-->
     
    		//<-- Objets
    			function afficheFlash($largeur, $hauteur, $description, $adresse, $var = array())
    			{
    				echo '<script type="text/javascript">'.
    						'document.write(\'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'.$largeur.'" height="'.$hauteur.'" title="'.$description.'"><param name="movie" value="'.$adresse.'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="'.$adresse.'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'.$largeur.'" height="'.$hauteur.'"></embed></object>\');'.
    					'</script>'.
    					'<noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'.$largeur.'" height="'.$hauteur.'" title="'.$description.'">'.
    						'<param name="movie" value="'.$adresse.'" />'.
    						'<param name="quality" value="high" />'.
    						'<param name="wmode" value="transparent" />'.
    						'<param name="allowFullScreen" value="true" />';
    						foreach ($var as $indice => $valeur)
    							echo '<param name="'.$indice.'" value="'.$valeur.'" />';
    						echo '<embed src="'.$adresse.'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'.$largeur.'" height="'.$hauteur.'"'; 
    						foreach ($var as $indice => $valeur)
    							echo ' '.$indice.'="'.$valeur.'"';
    						echo '></embed>';
    					echo '</object></noscript>';
    			}
    		//-->
    	}
     
    	function _getImagesHtml_rechercheImages($element)
    	{
    		if ($element->tag == 'img' && $element->src != '')
    			Fichier::$_getImagesHtml_images[] = $element->src;
    		else
    		{
    			if ($element->style != null && ereg('background-image'.'([\ ]*)'.':'.'([\ ]*)'.'url\('.'([a-zA-Z0-9\/\:\.]+)'.'\)', $element->style, $tab))
    				Fichier::$_getImagesHtml_images[] = $tab[3];
    			if ($element->background != null && $element->background != '')
    				Fichier::$_getImagesHtml_images[] = $element->background;
    		}
    	}
    Gestion_catalogue_categorie.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    <?php
    	require_once('./ressources/mysql_connexion.php');
    	require_once('./ressources/controleur.php');
    	require_once('./ressources/dependances/catalogue_categorie.php');
     
    	if (!$_client->estConnecte() || !$_client->getClientModules()->aCatalogue())
    		$_client->deconnecte();
     
    	if (isset($_GET['catalogue_categorie'])) // Formulaire de modification
    		$_catalogueCategorie = CatalogueCategorie::getCatalogueCategoriePourIdEtClient(intval($_GET['catalogue_categorie']), $_client);
    	elseif (isset($_POST['catalogue_categorie_id']) && $_POST['catalogue_categorie_id'] != '') // Modification
    		$_catalogueCategorie = CatalogueCategorie::getCatalogueCategoriePourIdEtClient(intval($_POST['catalogue_categorie_id']), $_client);
    	else // Formulaire de création
    		$_catalogueCategorie = new CatalogueCategorie(null, $_client);
    	if ($_client->getId() != $_catalogueCategorie->getClient()->getId())
    		$_client->deconnecte();
     
    	require_once('./ressources/dependances/formulaire.php');
    	$formulaire = new Formulaire('catalogue_categorie_form', isset($_POST['catalogue_categorie_enregistrement']));
    	$formulaire->setChamp('catalogue_categorie_parente_id', 'Catégorie parente', ($_catalogueCategorie->getCatalogueCategorieParente() == null ? '' : $_catalogueCategorie->getCatalogueCategorieParente()->getId()), false);
    	$formulaire->setChamp('catalogue_categorie_ordre', 'Ordre', $_catalogueCategorie->getOrdre(), true, Formulaire::$FORMULAIRE_FILTRE_ENTIER);
    	foreach ($_client->getLangues() as $langue)
    	{
    		$formulaire->setChamp('catalogue_categorie_titre_'.$langue->getId(), 'Titre '.$langue->getNom(), $_catalogueCategorie->getTitre($langue), false);
    		$formulaire->setChamp('catalogue_categorie_description_'.$langue->getId(), 'Description '.$langue->getNom(), $_catalogueCategorie->getDescription($langue), false);
    	}
    	$formulaire->initialiseChamps('post');
    	if ($formulaire->estValide())
    	{
    		if ($formulaire->getValeur('catalogue_categorie_parente_id') != '')
    			$_catalogueCategorie->setCatalogueCategorieParente(CatalogueCategorie::getCatalogueCategoriePourIdEtClient(intval($formulaire->getValeur('catalogue_categorie_parente_id')), $_client));
    		else $_catalogueCategorie->setCatalogueCategorieParente(null);
    		$_catalogueCategorie->setOrdre($formulaire->getValeur('catalogue_categorie_ordre'));
    		if ($_FILES['catalogue_categorie_image_url']['size'] > 0)
    		{
    			require_once('./ressources/dependances/fichier.php');
    			if (Fichier::estImageClassique($_FILES['catalogue_categorie_image_url']['name']))
    			{
    				if ($_catalogueCategorie->aImage())
    					unlink(SITE_DOSSIER_CLIENTS.$_client->getId().'/catalogues/'.$_catalogueCategorie->getImageUrl());
    				$fichier = new Fichier($_FILES['catalogue_categorie_image_url']['tmp_name']);
    				$nomFichier = Fichier::encodePourAdresse($_catalogueCategorie->getTitre(), '_', true).'-'.$_catalogueCategorie->getId().'.'.Fichier::getExtension($_FILES['catalogue_categorie_image_url']['name']);
    				Fichier::creeDossier(SITE_DOSSIER_CLIENTS.$_client->getId());
    				Fichier::creeDossier(SITE_DOSSIER_CLIENTS.$_client->getId().'/catalogues');
    				if ($fichier->deplace(SITE_DOSSIER_CLIENTS.$_client->getId().'/catalogues/'.$nomFichier))
    				{
    					$_catalogueCategorie->setImageUrl($nomFichier);
    					$dimensions = getimagesize($_catalogueCategorie->getImageChemin($_sites[0]));
    					$_catalogueCategorie->setImageLargeur($dimensions[0]);
    					$_catalogueCategorie->setImageHauteur($dimensions[1]);
    				}
    				else $formulaire->addMessageErreur('Enregistrement de l\'image impossible.');
    			}
    			else $formulaire->addMessageErreur('Le format de l\'image n\'est pas valide.');
    		}
    		foreach ($_client->getLangues() as $langue)
    		{
    			$_catalogueCategorie->setTitre($langue, $formulaire->getValeur('catalogue_categorie_titre_'.$langue->getId()));
    			$_catalogueCategorie->setDescription($langue, $formulaire->getValeur('catalogue_categorie_description_'.$langue->getId()));
    		}
    		if ($_catalogueCategorie->enregistre())
    			$formulaire->addMessageValidation('La catégorie de catalogue produits a été enregistrée.');
    		else $formulaire->addMessageErreur('La catégorie de catalogue produits n\'a pas été enregistrée.');
    	}
     
    	$_catalogueCategories = CatalogueCategorie::getCatalogueCategoriesParClient($_client);
     
    	require_once('./ressources/mysql_deconnexion.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    		<title>Catégories de catalogue - <?=LSL_WEBSITE_TITRE?></title>
    		<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    		<meta name="robots" content="noindex, nofollow" />
    		<link href="<?=LSL_WEBSITE_RACINE?>favicon.png" rel="shortcut icon" type="image/png" />
    		<link type="text/css" rel="stylesheet" href="<?=LSL_WEBSITE_RACINE?>ressources/style/general.css" />
    		<script type="text/javascript" src="<?=LSL_WEBSITE_RACINE?>ressources/javascript/prototype.js"></script>
    		<script type="text/javascript" src="<?=LSL_WEBSITE_RACINE?>ressources/javascript/formulaire.js"></script>
    	</head>
    	<body><div class="page_general">
    		<?php require_once('./ressources/vues/haut.php'); ?>
    		<div class="page_interne">
    			<div class="page_menu">
    				<?php require_once('./ressources/vues/menu.php'); ?>
    				<ul>
    					<li><span>Gestion des catégories de catalogue</span>
    						<ul class="fond_en_evidence"><li><a href="<?=LSL_WEBSITE_RACINE?>gestion_catalogue_categorie.php">Créer une nouvelle catégorie de catalogue</a></li><?php foreach ($_catalogueCategories as $catalogueCategorie) : ?>
    							<li><a href="<?=LSL_WEBSITE_RACINE?>gestion_catalogue_categorie.php?catalogue_categorie=<?=$catalogueCategorie->getId()?>"><?=$catalogueCategorie->getTitre()?></a></li>
    						<?php endforeach; ?></ul>
    					</li>
    					<li><a href="<?=LSL_WEBSITE_RACINE?>gestion_catalogue.php">Créer un catalogue</a></li>
    					<li><a href="<?=LSL_WEBSITE_RACINE?>gestion_catalogue_produit.php">Créer une fiche</a></li>
    				</ul>
    			</div>
    			<div class="page_contenu">
    				<h1><?php if ($_catalogueCategorie->existe()) : ?>Modifier la catégorie de catalogue <?=$_catalogueCategorie->getTitre()?><?php else : ?>Créer une nouvelle catégorie de catalogue<?php endif; ?></h1>
    				<?php $formulaire->afficheMessages(); ?>
    				<form method="post" id="catalogue_categorie_form" action="<?=LSL_WEBSITE_RACINE?>gestion_catalogue_categorie.php" enctype="multipart/form-data"><div class="formulaire">
    					<input type="hidden" name="catalogue_categorie_id" value="<?=$_catalogueCategorie->getId()?>" />
    					<div>
    						<div class="gauche"><label for="catalogue_categorie_parente_id">* Catégorie parente :</label></div>
    						<div class="droite"><select name="catalogue_categorie_parente_id" id="catalogue_categorie_parente_id">
    							<option value="">## AUCUNE CATÉGORIE PARENTE ##</option>
    							<?php foreach ($_catalogueCategories as $catalogueCategorie) : if ($catalogueCategorie->getId() != $_catalogueCategorie->getId()) : ?><option value="<?=$catalogueCategorie->getId()?>"><?=$catalogueCategorie->getTitre()?></option><?php endif; endforeach; ?>
    						</select></div>
    					</div>
    					<div>
    						<div class="gauche"><label for="catalogue_categorie_ordre">* Ordre :</label></div>
    						<div class="droite"><input type="text" name="catalogue_categorie_ordre" id="catalogue_categorie_ordre" maxlength="4" /></div>
    					</div>
    					<?php foreach ($_client->getLangues() as $langue) : ?><div>
    						<div class="gauche"><label for="catalogue_categorie_titre_<?=$langue->getId()?>"><img src="/images/icones/drapeaux/<?=$langue->getIcone()?>" alt="<?=$langue->getNom()?>" title="<?=$langue->getNom()?>" width="16" height="11" /> Titre :</label></div>
    						<div class="droite"><input type="text" name="catalogue_categorie_titre_<?=$langue->getId()?>" id="catalogue_categorie_titre_<?=$langue->getId()?>" maxlength="128" /></div>
    					</div>
    					<div>
    						<div class="gauche"><label for="catalogue_categorie_description_<?=$langue->getId()?>"><img src="/images/icones/drapeaux/<?=$langue->getIcone()?>" alt="<?=$langue->getNom()?>" title="<?=$langue->getNom()?>" width="16" height="11" /> Description :</label></div>
    						<div class="droite"><input type="text" name="catalogue_categorie_description_<?=$langue->getId()?>" id="catalogue_categorie_description_<?=$langue->getId()?>" maxlength="255" /></div>
    					</div><?php endforeach; ?>
    					<div>
    						<div class="gauche"><label for="catalogue_categorie_image_url">Image :</label></div>
    						<div class="droite">
    							<input type="file" name="catalogue_categorie_image_url" id="catalogue_categorie_image_url" />
    							<?php if ($_catalogueCategorie->aImage()) : ?><p><img src="<?=$_catalogueCategorie->getImageChemin($_sites[0])?>" alt="<?=$_catalogueCategorie->getTitre()?>" /></p><?php endif; ?>
    						</div>
    					</div>
    					<div class="boutons"><input type="submit" name="catalogue_categorie_enregistrement" value="Enregistrer" /></div>
    				</div></form>
     
    				<div class="a_la_ligne"></div>
    			</div>
    		</div>
    		<?php require_once('./ressources/vues/bas.php'); ?>
    	</div></body>
    </html>

    Catalogue_categorie.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    <?php
    	// v. 20110707
    	// LSL (c) Tous droits réservés
     
    	class CatalogueCategorie
    	{
    		private $id;
    		private $client;
    		private $catalogueCategorieParente;
    		private $ordre;
    		private $imageUrl;
    		private $imageLargeur;
    		private $imageHauteur;
     
    		private $traductions = array();
     
    		function CatalogueCategorie($id = null, $client = null, $catalogueCategorieParente = null, $ordre = null, $imageUrl = null, $imageLargeur = 0, $imageHauteur = 0)
    		{
    			$this->id = $id;
    			$this->client = $client;
    			$this->catalogueCategorieParente = $catalogueCategorieParente;
    			$this->ordre = $ordre;
    			$this->imageUrl = $imageUrl;
    			$this->imageLargeur = $imageLargeur;
    			$this->imageHauteur = $imageHauteur;
    		}
    		public function getId() { return $this->id; }
    		public function getClient() { return $this->client; }
    		public function getCatalogueCategorieParente() { return $this->catalogueCategorieParente; }
    		public function setCatalogueCategorieParente($catalogueCategorieParente) { $this->catalogueCategorieParente = $catalogueCategorieParente; }
    		public function getOrdre() { return $this->ordre; }
    		public function setOrdre($ordre) { $this->ordre = $ordre; }
    		public function getImageUrl() { return $this->imageUrl; }
    		public function setImageUrl($imageUrl) { $this->imageUrl = $imageUrl; }
    		public function getImageLargeur() { return $this->imageLargeur; }
    		public function setImageLargeur($imageLargeur) { $this->imageLargeur = $imageLargeur; }
    		public function getImageHauteur() { return $this->imageHauteur; }
    		public function setImageHauteur($imageHauteur) { $this->imageHauteur = $imageHauteur; }
     
    		public function getTitre($langue = null)
    		{
    			if ($langue == null && $this->traductions[0] != null)
    				return $this->traductions[0]->getTitre();
    			foreach ($this->traductions as $traduction)
    				if ($traduction->getLangue()->getId() == $langue->getId())
    					return $traduction->getTitre();
    			return '';
    		}
    		public function setTitre($langue, $titre)
    		{
    			foreach ($this->traductions as $traduction)
    				if ($traduction->getLangue()->getId() == $langue->getId())
    				{
    					$traduction->setTitre($titre);
    					return;
    				}
    			$this->traductions[] = new CatalogueCategorieTraduction(new CatalogueCategorie($this->id), $langue, $titre, '');
    		}
    		public function getDescription($langue = null)
    		{
    			if ($langue == null && $this->traductions[0] != null)
    				return $this->traductions[0]->getDescription();
    			foreach ($this->traductions as $traduction)
    				if ($traduction->getLangue()->getId() == $langue->getId())
    					return $traduction->getDescription();
    			return '';
    		}
    		public function setDescription($langue, $description)
    		{
    			foreach ($this->traductions as $traduction)
    				if ($traduction->getLangue()->getId() == $langue->getId())
    				{
    					$traduction->setDescription($description);
    					return;
    				}
    			$this->traductions[] = new CatalogueCategorieTraduction(new CatalogueCategorie($this->id), $langue, '', $description);
    		}
    		public function aImage() { return $this->imageUrl != null; }
    		public function getImageChemin($site) { return Fichier::getSiteRacine($site->getRacine()).'docs-'.$site->getClient()->getId().'/catalogues/'.$this->imageUrl; }
    		public function getChemin($site, $catalogue) { return $site->getRacine().Fichier::encodePourAdresse($catalogue->getTitre(), '_', false).'/'.Fichier::encodePourAdresse($this->getTitre(), '_', false).'-c'.$catalogue->getId().'-'.$this->getId(); }
    		public function addTraduction($catalogueTraduction) { $this->traductions[] = $catalogueTraduction; }
     
    		public function existe() { return $this->id != null; }
    		public function enregistre()
    		{
    			if ($this->existe())
    			{
    				if ($this->enregistreTraductions())
    				{
    					$sql = 'UPDATE '.MYSQL_PREFIXE.'catalogue_categorie SET '.
    							'catalogue_categorie_parente_id = '.($this->catalogueCategorieParente == null ? 'NULL' : '\''.$this->catalogueCategorieParente->getId().'\'').','.
    							'catalogue_categorie_ordre = '.$this->ordre.', '.
    							'catalogue_categorie_image_url = '.($this->imageUrl != null ? '\''.$this->imageUrl.'\'' : 'NULL').','.
    							'catalogue_categorie_image_largeur = '.$this->imageLargeur.','.
    							'catalogue_categorie_image_hauteur = '.$this->imageHauteur.' '.
    						'WHERE catalogue_categorie_id = '.$this->id;
    					return mysql_query($sql);
    				}
    			}
    			else
    			{
    				$sql = 'INSERT INTO '.MYSQL_PREFIXE.'catalogue_categorie('.
    						'client_id,'.
    						'catalogue_categorie_parente_id,'.
    						'catalogue_categorie_ordre,'.
    						'catalogue_categorie_image_url,'.
    						'catalogue_categorie_image_largeur,'.
    						'catalogue_categorie_image_hauteur'.
    					') VALUES ('.
    						'\''.$this->client->getId().'\','.
    						($this->catalogueCategorieParente == null ? 'NULL' : '\''.$this->catalogueCategorieParente->getId().'\'').','.
    						$this->ordre.','.
    						($this->imageUrl != null ? '\''.$this->imageUrl.'\'' : 'NULL').','.
    						$this->imageLargeur.','.
    						$this->imageHauteur.
    					')';
    				if (mysql_query($sql))
    				{
    					$this->id = mysql_insert_id();
    					return $this->enregistreTraductions();
    				}
    			}
    			return false;
    		}
    		private function enregistreTraductions()
    		{
    			$sql = 'DELETE FROM '.MYSQL_PREFIXE.'catalogue_categorie_traduction '.
    				'WHERE catalogue_categorie_id = '.$this->id.';';
    			if (mysql_query($sql))
    			{
    				foreach ($this->traductions as $traduction)
    					if (strlen($traduction->getTitre()) > 0)
    					{
    						$sql = 'INSERT INTO '.MYSQL_PREFIXE.'catalogue_categorie_traduction('.
    							'catalogue_categorie_id,'.
    							'langue_id,'.
    							'catalogue_categorie_titre,'.
    							'catalogue_categorie_description'.
    						') VALUES ('.
    							$this->id.','.
    							$traduction->getLangue()->getId().','.
    							'\''.addslashes($traduction->getTitre()).'\','.
    							'\''.addslashes($traduction->getDescription()).'\''.
    						');';
    						if (!mysql_query($sql))
    							return false;
    					}
    				return true;
    			}
    			return false;
    		}
     
    		public function getCatalogueCategories($catalogue, $catalogueCategorieParente, $client)
    		{
    			$tab = array();
    			$sql = 'SELECT '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id, catalogue_categorie_titre, catalogue_categorie_description, langue_id '.
    				'FROM '.MYSQL_PREFIXE.'catalogue_categorie '.
    				'LEFT JOIN '.MYSQL_PREFIXE.'catalogue_categorie_traduction ON '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id = '.MYSQL_PREFIXE.'catalogue_categorie_traduction.catalogue_categorie_id '.
    				'INNER JOIN '.MYSQL_PREFIXE.'catalogue_produit ON '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id = '.MYSQL_PREFIXE.'catalogue_produit.catalogue_categorie_id '.
    					'AND catalogue_id = '.$catalogue->getId().' '.
    				'WHERE catalogue_categorie_parente_id '.($catalogueCategorieParente != null ? '= '.$catalogueCategorieParente->getId() : 'IS NULL').' '.
    					'AND '.MYSQL_PREFIXE.'catalogue_categorie.client_id = '.$client->getId().' '.
    				'ORDER BY catalogue_categorie_ordre ASC';
    			if ($requete = mysql_query($sql))
    			{
    				$catalogueCategorieId = -1;
    				$catalogueCategorie = null;
    				while ($resultat = mysql_fetch_object($requete))
    				{
    					if ($catalogueCategorieId != $resultat->catalogue_categorie_id)
    					{
    						if ($catalogueCategorieId != -1)
    							$tab[] = $catalogueCategorie;
    						$catalogueCategorieId = $resultat->catalogue_categorie_id;
    						$catalogueCategorie = new CatalogueCategorie(intval($resultat->catalogue_categorie_id));
    						$catalogueCategorie->addTraduction(new CatalogueCategorieTraduction(null, new Langue(intval($resultat->langue_id)), $resultat->catalogue_categorie_titre, $resultat->catalogue_categorie_description));
    					}
    					else $catalogueCategorie->addTraduction(new CatalogueCategorieTraduction(null, new Langue(intval($resultat->langue_id)), $resultat->catalogue_categorie_titre, $resultat->catalogue_categorie_description));
    				}
    				if ($catalogueCategorieId != -1)
    					$tab[] = $catalogueCategorie;
    				return $tab;
    			}
    			return new CatalogueCategorie();
    		}
    		public function getCatalogueCategoriePourIdEtClient($catalogueCategorieId, $client)
    		{
    			$sql = 'SELECT catalogue_categorie_parente_id, catalogue_categorie_ordre, catalogue_categorie_image_url, catalogue_categorie_titre, catalogue_categorie_description, langue_id '.
    				'FROM '.MYSQL_PREFIXE.'catalogue_categorie '.
    				'LEFT JOIN '.MYSQL_PREFIXE.'catalogue_categorie_traduction ON '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id = '.MYSQL_PREFIXE.'catalogue_categorie_traduction.catalogue_categorie_id '.
    				'WHERE '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id = '.$catalogueCategorieId.' '.
    					'AND client_id = '.$client->getId();
    			if ($requete = mysql_query($sql))
    				if ($resultat = mysql_fetch_object($requete))
    				{
    					$catalogueCategorie = new CatalogueCategorie($catalogueCategorieId, $client, new CatalogueCategorie(intval($resultat->catalogue_categorie_parente_id)), $resultat->catalogue_categorie_ordre, $resultat->catalogue_categorie_image_url);
    					$catalogueCategorie->addTraduction(new CatalogueCategorieTraduction(null, new Langue(intval($resultat->langue_id)), $resultat->catalogue_categorie_titre, $resultat->catalogue_categorie_description));
    					while ($resultat = mysql_fetch_object($requete))
    						$catalogueCategorie->addTraduction(new CatalogueCategorieTraduction(null, new Langue(intval($resultat->langue_id)), $resultat->catalogue_categorie_titre, $resultat->catalogue_categorie_description));
    					return $catalogueCategorie;
    				}
    			return new CatalogueCategorie();
    		}
    		public function getCatalogueCategoriesParClient($client)
    		{
    			$tab = array();
    			$sql = 'SELECT '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id, catalogue_categorie_titre '.
    				'FROM '.MYSQL_PREFIXE.'catalogue_categorie '.
    				'LEFT JOIN '.MYSQL_PREFIXE.'catalogue_categorie_traduction ON '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id = '.MYSQL_PREFIXE.'catalogue_categorie_traduction.catalogue_categorie_id '.
    				'WHERE client_id = '.$client->getId().' '.
    				'GROUP BY '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id '.
    				'ORDER BY catalogue_categorie_titre ASC';
    			if ($requete = mysql_query($sql))
    				while ($resultat = mysql_fetch_object($requete))
    				{
    					$catalogueCategorie = new CatalogueCategorie(intval($resultat->catalogue_categorie_id));
    					$catalogueCategorie->addTraduction(new CatalogueCategorieTraduction(null, null, $resultat->catalogue_categorie_titre));
    					$tab[] = $catalogueCategorie;
    				}
    			return $tab;
    		}
    		public function getCatalogueCategoriesParCataloguesParClient($client)
    		{
    			$tab = array();
    			$sql = 'SELECT '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id, catalogue_categorie_titre, '.MYSQL_PREFIXE.'catalogue.catalogue_id, catalogue_titre, '.MYSQL_PREFIXE.'catalogue_traduction.langue_id AS catalogue_langue_id, '.MYSQL_PREFIXE.'catalogue_categorie_traduction.langue_id AS catalogue_categorie_langue_id '.
    				'FROM '.MYSQL_PREFIXE.'catalogue_produit '.
    				'LEFT JOIN '.MYSQL_PREFIXE.'catalogue_categorie ON '.MYSQL_PREFIXE.'catalogue_produit.catalogue_categorie_id = '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id '.
    					'AND '.MYSQL_PREFIXE.'catalogue_categorie.client_id = '.$client->getId().' '.
    				'LEFT JOIN '.MYSQL_PREFIXE.'catalogue_categorie_traduction ON '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id = '.MYSQL_PREFIXE.'catalogue_categorie_traduction.catalogue_categorie_id '.
    				'INNER JOIN '.MYSQL_PREFIXE.'catalogue ON '.MYSQL_PREFIXE.'catalogue.catalogue_id = '.MYSQL_PREFIXE.'catalogue.catalogue_id '.
    				'LEFT JOIN '.MYSQL_PREFIXE.'catalogue_traduction ON '.MYSQL_PREFIXE.'catalogue.catalogue_id = '.MYSQL_PREFIXE.'catalogue_traduction.catalogue_id '.
    				'WHERE '.MYSQL_PREFIXE.'catalogue.client_id = '.$client->getId().' '.
    				'GROUP BY '.MYSQL_PREFIXE.'catalogue.catalogue_id, '.MYSQL_PREFIXE.'catalogue_categorie.catalogue_categorie_id';
    			if ($requete = mysql_query($sql))
    			{
    				$catalogueId = 0;
    				while ($resultat = mysql_fetch_object($requete))
    				{
    					if ($resultat->catalogue_id != $catalogueId)
    					{
    						$catalogueId = $resultat->catalogue_id;
    						$catalogue = new Catalogue(intval($resultat->catalogue_id));
    						$catalogue->addTraduction(new CatalogueTraduction(null, new Langue(intval($resultat->catalogue_langue_id)), $resultat->catalogue_titre));
    						$tab[] = array($catalogue, array());
    					}
    					$catalogueCategorie = new CatalogueCategorie(intval($resultat->catalogue_categorie_id));
    					$catalogueCategorie->addTraduction(new CatalogueCategorieTraduction(null, new Langue(intval($resultat->catalogue_categorie_langue_id)), $resultat->catalogue_categorie_titre));
    					$tab[count($tab) - 1][1][] = $catalogueCategorie;
    				}
    			}
    			return $tab;
    		}
    	}
     
    	class CatalogueCategorieTraduction
    	{
    		private $catalogueCategorie;
    		private $langue;
    		private $titre;
    		private $description;
     
    		function CatalogueCategorieTraduction($catalogueCategorie = null, $langue = null, $titre = null, $description = null)
    		{
    			$this->catalogueCategorie = $catalogueCategorie;
    			$this->langue = $langue;
    			$this->titre = $titre;
    			$this->description = $description;
    		}
    		public function getLangue() { return $this->langue; }
    		public function getTitre() { return $this->titre; }
    		public function setTitre($titre) { $this->titre = $titre; }
    		public function getDescription() { return $this->description; }
    		public function setDescription($description) { $this->description = $description; }
    	}

    Merci d'avance.

  2. #2
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Points : 91 220
    Points
    91 220
    Billets dans le blog
    20
    Par défaut
    et là.... aucune fonction estImageClassique
    Bah oui, c'est en quelque sorte ce que te dit le message d'erreur :
    Fatal error: Call to undefined method Fichier::estImageClassique() in /home/o102272/public_html/lsl_website/gestion_catalogue_categorie.php on line 37


    Donc tu dois soit ne pas appeler une méthode qui n'existe pas, soit créer une méthode portant ce nom si tu veux l'utiliser.
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  3. #3
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    Autre possibilité : tu veux utiliser la fonction, elle existe bien quelque part, mais le fichier qui la contient n'est pas inclus dans ton script.
    Modératrice PHP
    Aucun navigateur ne propose d'extension boule-de-cristal : postez votre code et vos messages d'erreurs. (Rappel : "ça ne marche pas" n'est pas un message d'erreur)
    Cherchez un peu avant poser votre question : Cours et Tutoriels PHP - FAQ PHP - PDO une soupe et au lit !.

    Affichez votre code en couleurs : [CODE=php][/CODE] (bouton # de l'éditeur) et [C=php][/C]

  4. #4
    Futur Membre du Club
    Homme Profil pro
    formateur
    Inscrit en
    Octobre 2014
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : formateur

    Informations forums :
    Inscription : Octobre 2014
    Messages : 17
    Points : 5
    Points
    5
    Par défaut
    Tout d'abord merci pour vos réponses à tous les deux.

    Citation Envoyé par Celira Voir le message
    elle existe bien quelque part, mais le fichier qui la contient n'est pas inclus dans ton script.
    En effet, mais j'ignore totalement où elle peut bien se trouver. J'utilise Filezilla et je n'ai pas encore trouvé le moyen de faire une recherche dans les fichiers comportant l'expression "estImageClassique". Et sachant qu'il y a quelques centaines de fichiers éparpillés dans pléthore de sous-dossiers c'est un peu coton pour retrouver cette expression, si tant est qu'elle existe.

    Connaissez-vous un FTP gratuit qui permettrait de faire cette recherche à l'intérieur même des fichiers du site ?

    Merci.

  5. #5
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Points : 91 220
    Points
    91 220
    Billets dans le blog
    20
    Par défaut
    Notepad++ sait le faire, via le menu "Recherche > Rechercher dans les sous-dossiers".
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  6. #6
    Futur Membre du Club
    Homme Profil pro
    formateur
    Inscrit en
    Octobre 2014
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : formateur

    Informations forums :
    Inscription : Octobre 2014
    Messages : 17
    Points : 5
    Points
    5
    Par défaut
    Citation Envoyé par Bovino Voir le message
    Notepad++ sait le faire
    Merci.

    Cependant il me semble que les recherches ne peuvent se faire qu'en local. Du coup je vais devoir aspirer la totalité du site sur l'ordi puis faire la recherche à partir de la version aspirée.

    Je vous tiens au courant

  7. #7
    Futur Membre du Club
    Homme Profil pro
    formateur
    Inscrit en
    Octobre 2014
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : formateur

    Informations forums :
    Inscription : Octobre 2014
    Messages : 17
    Points : 5
    Points
    5
    Par défaut
    Je pense avoir trouvé le fichier contenant la fonction estImageClassique (ligne 48).

    Il s'agit du fichier image.php.

    Le voici :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    <?php
    	// v101016
    	// LSL (c) Tous droits réservés
     
    	class Image
    	{
    		private $adresse;
    		private $largeur;
    		private $hauteur;
    		private $type;
     
    		function Image($adresseImage)
    		{
    			$this->adresse = $adresseImage;
    			$dimensions = getimagesize($adresseImage);
    			$this->largeur = $dimensions[0];
    			$this->hauteur = $dimensions[1];
    			$this->type = $dimensions[2];
    		}
     
    		public function getLargeur() { return $this->largeur; }
    		public function getHauteur() { return $this->hauteur; }
     
    		public function transformeEnNiveauDeGris()
    		{
    			$image1 = $this->getImageGD();
    			$image2 = $this->getImageGD();
    			$retour = imagecopymergegray($image1, $image2, 0, 0, 0, 0, $this->largeur, $this->hauteur, 0);
    			imagejpeg($image1, $this->adresse, 90);
    			imagedestroy($image1);
    			imagedestroy($image2);
    			return $retour;
    		}
     
    		private function getImageGD()
    		{
    			switch ($this->type)
    			{
    				case IMAGETYPE_GIF:
    					return imagecreatefromgif($this->adresse);
    				case IMAGETYPE_PNG:
    					return imagecreatefrompng($this->adresse);
    				case IMAGETYPE_JPEG:
    					return imagecreatefromjpeg($this->adresse);
    			}
    			return null;
    		}
    		function estImageClassique($adresse = null)
    		{
    			if ($adresse == null)
    				$adresse = $this->adresse;
    			$extension = strtolower(substr($adresse, strrpos($adresse, '.') + 1));
    			return ($extension == 'jpg' || $extension == 'jpeg' || $extension == 'gif' || $extension == 'png');
    		}
    		function changeTaille($nouvelleLargeur, $nouvelleHauteur, $format_image = 'jpg')
    		{
    			$dimensions = getimagesize($this->adresse);
    			$type = strtolower($dimensions[2]);
    			$image_actuelle = $this->getImageGD();
     
    			//<-- Redimensionnement logique
    				if ($nouvelleLargeur == null)
    					$nouvelleLargeur = $dimensions[0] / $dimensions[1] * $nouvelleHauteur;
    				elseif ($nouvelleHauteur == null)
    					$nouvelleHauteur = $dimensions[1] / $dimensions[0] * $nouvelleLargeur;
    			//-->
     
    			if ($dimensions[0] != $nouvelleLargeur || $dimensions[1] != $nouvelleHauteur)
    			{
    				$image_finale = imagecreatetruecolor($nouvelleLargeur, $nouvelleHauteur);
    				imagecopyresampled($image_finale, $image_actuelle, 0, 0, 0, 0, $nouvelleLargeur, $nouvelleHauteur, $dimensions[0], $dimensions[1]);
    				switch ($format_image)
    				{
    					case 'gif':
    						imagegif($image_finale, $this->adresse);
    						break;
    					case 'png':
    						imagepng($image_finale, $this->adresse);
    						break;
    					default:
    						imagejpeg($image_finale, $this->adresse, 90);
    						break;
    				}
    				imagedestroy($image_finale);
    				$this->largeur = $nouvelleLargeur;
    				$this->hauteur = $nouvelleHauteur;
    			}
    			return true;
    		}
     
    	}

  8. #8
    Modératrice
    Avatar de Celira
    Femme Profil pro
    Développeuse PHP/Java
    Inscrit en
    Avril 2007
    Messages
    8 633
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Développeuse PHP/Java
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2007
    Messages : 8 633
    Points : 16 372
    Points
    16 372
    Par défaut
    yapluka l'inclure dans ton script :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    require_once('./ressources/dependances/image.php');
    if (Image::estImageClassique($_FILES['catalogue_categorie_image_url']['name']))
    Modératrice PHP
    Aucun navigateur ne propose d'extension boule-de-cristal : postez votre code et vos messages d'erreurs. (Rappel : "ça ne marche pas" n'est pas un message d'erreur)
    Cherchez un peu avant poser votre question : Cours et Tutoriels PHP - FAQ PHP - PDO une soupe et au lit !.

    Affichez votre code en couleurs : [CODE=php][/CODE] (bouton # de l'éditeur) et [C=php][/C]

  9. #9
    Futur Membre du Club
    Homme Profil pro
    formateur
    Inscrit en
    Octobre 2014
    Messages
    17
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : formateur

    Informations forums :
    Inscription : Octobre 2014
    Messages : 17
    Points : 5
    Points
    5
    Par défaut
    Merci à toi Celira. Problème enfin résolu grâce à toi !
    :-)

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 12
    Dernier message: 18/05/2015, 15h16
  2. [PHP 5.2] Fatal error: Call to undefined method DateTime::sub()
    Par made_in_france dans le forum Langage
    Réponses: 2
    Dernier message: 31/01/2011, 09h39
  3. Réponses: 0
    Dernier message: 25/02/2008, 17h28
  4. Réponses: 3
    Dernier message: 21/03/2006, 14h21
  5. Réponses: 11
    Dernier message: 08/12/2005, 16h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo