[ Index ] |
|
Code source de SPIP Agora 1.4 |
1 <?php 2 /***************************************************** 3 * This file is part of Agora, web based content management system. 4 * 5 * Agora is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * 9 * Agora is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details (file "COPYING"). 13 * 14 * Copyright © Arnaud Martin, Antoine Pitrou et Philippe Rivière. 15 * List of authors detailed in "copyright_fr.html" file. 16 * E-mail : agora@sig.premier-ministre.gouv.fr 17 * Web site : http://www.agora.gouv.fr 18 *****************************************************/ 19 // Ce fichier ne sera execute qu'une fois 20 if (defined("_ECRIRE_INC_SONDAGES")) 21 return; 22 23 define("_ECRIRE_INC_SONDAGES", "1"); 24 25 //-------------Ajout fxlacroix@clever-age.net ----------------// 26 require_once (dirname(__FILE__). "/include/bd/inc_sondage_factory.php"); 27 require_once (dirname(__FILE__). "/include/bd/inc_sondage_vote_factory.php"); 28 require_once (dirname(__FILE__). "/include/bd/inc_sondage_reponse_factory.php"); 29 //-------------Fin Ajout fxlacroix@clever-age.net ----------------// 30 31 include_ecrire ("inc_admin.php"); 32 //------------Ajout aangenieux pour intégration Agora 33 //plus necessaire ? require_once (dirname(__FILE__)."/include/bd/inc_metier_factory.php"); 34 //------------Fin ajout 35 36 function afficher_sondage ($id_article, $flag_editable) { 37 global $connect_id_auteur, $connect_statut; 38 global $couleur_claire; 39 global $ajout_reponse, $supp_reponse, $actif, $affichage_public, $reset_sondage; 40 41 //plus necessaire ?$dbMetier = &recuperer_instance_metier(); 42 //plus necessaire ?$db = &$dbMetier->_getDB(); 43 44 if (lire_meta('activer_sondages') != 'non') { 45 // Ajout de nouvelles réponses 46 if (isset($ajout_reponse) && count($ajout_reponse) > 0 && $flag_editable) { 47 $sondage_reponse = &recuperer_instance_sondage_reponse(); 48 // if($sondage_reponse->verificationDoublon($id_article,$ajout_reponse)) 49 $sondage_reponse->selectMaxIdReponse($id_article, $ajout_reponse); 50 unset ($sondage_reponse); 51 } 52 53 // Suppression d'une réponse 54 if (isset($supp_reponse) && $flag_editable) { 55 $sondage_reponse = &recuperer_instance_sondage_reponse(); 56 $sondage_reponse->deleteArticleReponse($id_article, $supp_reponse); 57 unset ($sondage_reponse); 58 } 59 60 // Modification des paramètres 61 if (isset($actif) && $flag_editable) { 62 $sondage = &recuperer_instance_sondage(); 63 $sondage->modifierProfile($actif, $affichage_public, $id_article); 64 unset ($sondage); 65 } 66 67 // Réinitialisation des votes 68 if (isset($reset_sondage) && $reset_sondage == 'oui') { 69 $sondage_vote = &recuperer_instance_sondage_vote(); 70 $sondage_vote->deleteArticleVote($id_article); 71 unset ($sondage_vote); 72 73 $sondage_reponse = &recuperer_instance_sondage_reponse(); 74 $sondage_reponse->modifierVote($id_article, 0); 75 unset ($sondage_reponse); 76 } 77 78 // Y'a t'il déjà des réponses proposées ? 79 $sondage_reponse = &recuperer_instance_sondage_reponse(); 80 $nbReponses = $sondage_reponse->calculNbReponse($id_article); 81 unset ($sondage_reponse); 82 83 // Et des votes alors ? 84 $votes = array('somme' => 0); 85 $sondage_reponse = &recuperer_instance_sondage_reponse(); 86 $votes = $sondage_reponse->calculNbVote($id_article, $votes); 87 unset ($sondage_reponse); 88 89 // Paramètres du sondage 90 $sondage = &recuperer_instance_sondage(); 91 $tab_actif_affiche = $sondage->parametrerSondage($id_article); 92 $actif = $tab_actif_affiche[0]; 93 $affichage_public = $tab_actif_affiche[1]; 94 unset ($sondage); 95 96 // Affichage du cadre 97 echo '<a name="sondage" id="sondage"></a>'; 98 echo debut_cadre_enfonce('sondages-24.gif'); 99 echo '<table border="0" cellspacing="0" cellpadding="3" width="100%"><tr><td bgcolor="#EEEECC">'; 100 echo '<font size="2" face="Georgia,Garamond,Times,serif"><b>'; 101 echo _T('sondage_'.($nbReponses >= 2 ? 'oui' : 'non')); 102 echo '</b></font>'; 103 echo aide ('sondage'); 104 echo '</td></tr></table><br />'; 105 106 $sondage_reponse= &recuperer_instance_sondage_reponse(); 107 $tab_reponse = $sondage_reponse->listerReponse($id_article); 108 unset($sondage_reponse); 109 110 $num = count ($tab_reponse); 111 112 // echo("voici la vaaleur :".$num.var_dump($tab_reponse)); 113 //echo("voici la vaaleur :".$tab_reponse[0][0].$tab_reponse[0][1]); 114 if ($num>0) { 115 $ifond = 0; 116 echo '<font face="Verdana,Arial,Helvetica,sans-serif" size="2"><b>'._T('sondage_reponses_proposees').' </b></font><br />'; 117 echo '<table border="0" cellspacing="0" cellpadding="3" width="100%">'; 118 for($i=0;$i<$num;$i++){ 119 $id_reponse = $tab_reponse[$i][0]; 120 $texte_reponse = $tab_reponse[$i][1]; 121 $ifond = $ifond ^ 1; 122 $couleur = ($ifond) ? '#FFFFFF' : $couleur_claire; 123 echo '<tr bgcolor="'.$couleur.'" width="100%">'; 124 echo '<td class="arial2">'.$texte_reponse.'</td>'; 125 echo '<td class="arial2" align="right">'.(isset($votes[$id_reponse]) ? $votes[$id_reponse] : 0).'</td>'; 126 echo '<td class="arial2" align="right">'.sprintf("%0.2f", ((isset($votes[$id_reponse]) && $votes['somme'] > 0) ? $votes[$id_reponse] * 100 / $votes['somme'] : 0)).' %</td>'; 127 if ($flag_editable && $votes['somme'] == 0) { 128 echo '<td class="arial1" align="right">'; 129 echo '<a href="articles.php?id_article='.$id_article.'&supp_reponse='.$id_reponse.'#sondage">'._T('sondage_supprimer_reponse').'</a>'; 130 echo '</td>'; 131 } 132 echo '</tr>'; 133 } 134 echo '</table>'; 135 } 136 137 138 if ($flag_editable) { 139 if ($votes['somme'] == 0) { 140 // Formulaire d'ajout de réponses 141 echo '<br /><div style="border: 1px dashed #666666; padding: 5px; background-color: #f0f0f0;">'; 142 echo bouton_block_invisible('sondage_ajout'); 143 echo '<font face="Verdana,Arial,Helvetica,sans-serif" size="2"><b>'._T('sondage_ajouter_reponses').' </b></font><br />'; 144 echo debut_block_invisible('sondage_ajout'); 145 echo '<form action="articles.php#sondage" method="post">'; 146 echo '<input type="hidden" name="id_article" value="'.$id_article.'" />'; 147 if ($nbReponses < 2) { 148 echo '<p><font size="2" face="Verdana,Arial,Helvetica,sans-serif">'._T('sondage_activer').'</font></p>'; 149 } 150 echo ' <input type="text" name="ajout_reponse[]" class="fondl" size="40" maxlength="255" /><br />'; 151 echo ' <input type="text" name="ajout_reponse[]" class="fondl" size="40" maxlength="255" /><br />'; 152 echo ' <input type="text" name="ajout_reponse[]" class="fondl" size="40" maxlength="255" />'; 153 echo '<p><input type="submit" name="Ajouter" value="'._T('bouton_ajouter').'" class="fondo" /></p>'; 154 echo '</form>'; 155 echo fin_block(); 156 echo '</div>'; 157 } 158 159 // Formulaire de paramétrage 160 echo '<br /><div style="border: 1px dashed #666666; padding: 5px; background-color: #f0f0f0;">'; 161 echo bouton_block_invisible('sondage_parametres'); 162 echo '<font face="Verdana,Arial,Helvetica,sans-serif" size="2"><b>'._T('sondage_parametres').' </b></font><br />'; 163 echo debut_block_invisible('sondage_parametres'); 164 echo '<form action="articles.php#sondage" method="post">'; 165 echo '<input type="hidden" name="id_article" value="'.$id_article.'" />'; 166 167 // Paramétrage de l'activation du sondage 168 echo '<p><font face="Verdana,Arial,Helvetica,sans-serif" size="2"><b>'._T('sondage_actif').' </b></font><br />'; 169 echo ' <input type="radio" name="actif" value="oui" class="fondl" '.($actif == 'oui' ? 'checked="checked" ' : '').'/> '._T('sondage_actif_oui'); 170 echo ' <input type="radio" name="actif" value="non" class="fondl" '.($actif == 'non' ? 'checked="checked" ' : '').'/> '._T('sondage_actif_non').'</p>'; 171 172 // Paramétrage de l'affichage sur le site public 173 echo '<p><font face="Verdana,Arial,Helvetica,sans-serif" size="2"><b>'._T('sondage_affichage_public').' </b></font><br />'; 174 echo ' <input type="radio" name="affichage_public" value="oui" class="fondl" '.($affichage_public == 'oui' ? 'checked="checked" ' : '').'/> '._T('sondage_affichage_public_oui'); 175 echo ' <input type="radio" name="affichage_public" value="non" class="fondl" '.($affichage_public == 'non' ? 'checked="checked" ' : '').'/> '._T('sondage_affichage_public_non').'</p>'; 176 177 echo ' <input type="submit" name="Valider" value="'._T('bouton_valider').'" class="fondo" />'; 178 echo '</form>'; 179 180 if ($votes['somme'] > 0) { 181 // Réinitialiser les votes 182 echo '<p><a href="articles.php?id_article='.$id_article.'&reset_sondage=oui#sondage">'._T('sondage_reset').'</a></p>'; 183 } 184 echo fin_block(); 185 echo '</div>'; 186 } 187 188 fin_cadre_enfonce(); 189 } 190 } 191 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |