Subversion Repositories Applications.papyrus

Rev

Rev 448 | Blame | Last modification | View Log | RSS feed

<?

/* Fonctions locales de AGORA */

/*
array get_image(&$tableau)

réupère les infos d'une image d'identifant $id ou
choisi au hasard l'une des entrées dans un tableau
(liste de nom de fichiers) si $id vaut NULL

retourne un tableau :

$tableau['id'] id de l'image
$tableau['image'] nom de l'image
$tableau['alt'] infos de l'image

*/

function get_image(&$left_image)
  {
  global $tbl;
  
  if ($left_image['id'] == "") $add_query = "AGO_I_ALLOW = 1";
  else $add_query = "AGO_I_ID = ".$left_image['id'];

  $query = "select * from agora_image where $add_query";
  $result = mysql_query($query) or die("<B>Erreur de requête de récupération des images AGORA...</B> $query");
  $nbquery = mysql_num_rows($result);

  if ($nbquery > 1)
    {
    $i = 0;

    while ($row = mysql_fetch_object($result))
      {
      $tmp_id = $row->AGO_I_ID;
      $tmp_img = $row->AGO_I_IMAGE;
    
      if (($tmp_id != "")&&($tmp_img != ""))
        {
        $tableau[$i]['id'] = $tmp_id;
        $tableau[$i]['image'] = $tmp_img;
        $tableau[$i]['alt'] = $row->AGO_I_ALT;
        }

      $i++;
      }

    $tmp_nb = count($tableau);

    mt_srand((float) microtime()*1000000);
    $aleatoire = mt_rand(1,$tmp_nb);

    $left_image['id'] = $tableau[$aleatoire-1]['id'];
    $left_image['image'] = $tableau[$aleatoire-1]['image'];
    $left_image['alt'] = $tableau[$aleatoire-1]['alt'];
    }

  else if ($nbquery == 1)
    {
    $row = mysql_fetch_object($result);

    $left_image['id'] = $row->AGO_I_ID;
    $left_image['image'] = $row->AGO_I_IMAGE;
    $left_image['alt'] = $row->AGO_I_ALT;
    }

  else
    {
    die ("Arrêt du programme causé par la fonction get_image() de AGORA... NbQuery a une valeur incohérente.");
    }

  if ($left_image['alt'] == "") $left_image['alt'] = $left_image['image'];
  
  mysql_free_result($result);
  }



function afficheBouton ($alignTable, $leLibele1, $laCmd1)
  {
  $StyleFond = "";
  $StyleActif = "tabActive";

  $StyleTxtInnactif = "tabInactiveAnchor";
  $StyleInnactif = "tabInactive";

  $ret = "";

  $ret .= "\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"$alignTable\"><tr>\n";
  $ret .= '<td align="left" valign="bottom" class="tabInactive" colspan="5"><img src="'.PROJET_CHEMIN_IMAGE.'vide.gif" width="1" height="1" border="0" alt="" /></td>'."\n";
  $ret .= "</tr><tr>\n";
  $ret .= "<td align=\"left\" valign=\"bottom\" class=\"tabInactive\"><img src=\"".PROJET_CHEMIN_IMAGE."vide.gif\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" /></td>\n";

  if ($laCmd1 != "NULL")
    {
    $ret .= "<td align=\"left\" valign=\"bottom\" class=\"$StyleActif\"><img src=\"".PROJET_CHEMIN_IMAGE."vide.gif\" width=\"5\" height=\"1\" border=\"0\" alt=\"\" /></td>\n";
    $ret .= "<td align=\"left\" valign=\"bottom\" class=\"$StyleActif\"><a href=\"$laCmd1\" class=\"anchor\">$leLibele1</a></td>\n";
    $ret .= "<td align=\"left\" valign=\"bottom\" class=\"$StyleActif\"><img src=\"".PROJET_CHEMIN_IMAGE."vide.gif\" width=\"5\" height=\"1\" border=\"0\" alt=\"\" /></td>\n";
    }

  else
    {
    $ret .= "<td align=\"left\" valign=\"bottom\" class=\"$StyleInnactif\"><img src=\"".PROJET_CHEMIN_IMAGE."vide.gif\" width=\"5\" height=\"1\" border=\"0\" alt=\"\" /></td>\n";
    $ret .= "<td align=\"left\" valign=\"bottom\" class=\"$StyleInnactif\"><span class=\"$StyleTxtInnactif\">$leLibele1</span></td>\n";
    $ret .= "<td align=\"left\" valign=\"bottom\" class=\"$StyleInnactif\"><img src=\"".PROJET_CHEMIN_IMAGE."vide.gif\" width=\"5\" height=\"1\" border=\"0\" alt=\"\" /></td>\n";
    }

  $ret .= "<td align=\"left\" valign=\"bottom\" class=\"tabInactive\"><img src=\"".PROJET_CHEMIN_IMAGE."vide.gif\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" /></td>\n";

  $ret .= "</tr><tr>\n";

  $ret .= "<td align=\"left\" valign=\"bottom\" class=\"tabInactive\" colspan=\"5\"><img src=\"".PROJET_CHEMIN_IMAGE."vide.gif\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" /></td>\n";
  
  $ret .= "</tr></table>\n\n";

  return $ret;
  }

?>