Valid XHTML    Valid CSS2    

Listing du fichier diaporama_gen.php

 

00001     <?php
00002     
00003     
# (gH) -_- diaporama_gen.php ; TimeStamp (unix) : 19 Mai 2010 vers 10:15
00004     
00005     ###########################################################################################
00006     #
00007     # production automatique de diaporamas (gH)
00008     #
00009     # il y a deux modes :
00010     #
00011     # 1. liste d'URL dans un fichier-texte
00012     # 2. URL construite par numéro
00013     #
00014     # Remarque : le menu de navigation est géré par javascript (si activé).
00015     # on peut ne pas l'afficher à l'aide du dernier paramètre de la fonction diaporama.
00016     #
00017     ###########################################################################################
00018     #
00019     # Exemples :
00020     #
00021     # DIAPORAMA mode Liste
00022     #
00023     # # (gH) -_- ghdatasets.php ; TimeStamp (unix) : 13 Mai 2010 vers 17:02
00024     #
00025     # error_reporting(E_ALL | E_NOTICE ) ;
00026     #
00027     # include("diaporama_gen.php") ;
00028     #
00029     # $titre = "Dossier (gH) " ;
00030     # $liste = "ghdatasets.txt" ;
00031     # $base = "ghdatasets.php" ;
00032     # $temps = 5 ;
00033     # $nav = "NON" ;
00034     #
00035     # diaporamaListe($titre,$liste,$base,$temps,$nav) ;
00036     #
00037     # DIAPORAMA mode Url par construction (fonction urlsite)
00038     #
00039     # # (gH) -_- zencssframes.php ; TimeStamp (unix) : 12 Mai 2010 vers 17:47
00040     #
00041     # error_reporting(E_ALL | E_NOTICE ) ;
00042     #
00043     # include("diaporama_gen.php") ;
00044     #
00045     # $titre = "CSS Zen garden " ;
00046     # $nbviews = 215 ; # "à la main" le 10 mai 2010 ;
00047     # $basefra = "zencssframes.php" ;
00048     # $temps = 3 ;
00049     # $nav = "OUI" ;
00050     #
00051     # ###########################################################################################
00052     #
00053     # function urlsite($numero) {
00054     #
00055     # ###########################################################################################
00056     #
00057     # $chen = "http://www.csszengarden.com/?cssfile=".sprintf("%03d",$numero)."/".sprintf("%03d",$numero).".css" ;
00058     #
00059     # return($chen) ;
00060     #
00061     # } ; # fin de fonction urlsite
00062     #
00063     # ###########################################################################################
00064     #
00065     # diaporamaSite($titre,$basefra,$nbviews,$temps,$nav) ;
00066     #
00067     #
00068     #
00069     ###########################################################################################
00070     ###########################################################################################
00071     
00072     # le programme commence ici
00073     
00074     ###########################################################################################
00075     
00076     
function diaporamaListe($leTitre,$laListe,$baseFrame,$duree=10,$js="NON") {
00077     
00078     
# on appelle la fonction diaporama avec un nombre de diapos vide
00079      # car il sera déterminé par le nombre de lignes dans le fichier-liste
00080     
00081     
diaporama
($leTitre,$laListe,$baseFrame,0,$duree,$js) ;
00082     
00083     } ;
# fin de fonction diaporamaListe
00084     
00085     
00086     ###########################################################################################
00087     
00088     
function
diaporamaSite($leTitre,$baseFrame,$nbViews=10,$duree=10,$js="NON") {
00089     
00090     
# on appelle la fonction diaporama avec une liste vide
00091     
00092     
diaporama
($leTitre,"",$baseFrame,$nbViews,$duree,$js) ;
00093     
00094     } ;
# fin de fonction diaporamaSite
00095     
00096     ###########################################################################################
00097     
00098     
function
diaporama($leTitre,$laListe,$baseFrame,$nbViews=10,$duree=10,$js="OUI") {
00099     
00100     
###########################################################################################
00101     
00102     # cadre = 0 : c'est l'encadrement ;
00103     # cadre = 1 : page du haut
00104     # cadre = 2 : ligne du bas ;
00105     
00106     # gestion des paramètres
00107     
00108     
if (!isset(
$cadre)) {
00109     
$cadre
= 0 ;
00110      if (isset(
$_GET
["cadre"])) { $cadre = $_GET["cadre"] ; } ;
00111     } ;
# fin si
00112     
00113     
if (isset(
$_GET["duree"])) { $duree = $_GET["duree"] ; } ;
00114     if (
$duree
=="undefined") { $duree = 35 ; } ;
00115     
00116     
# lecture de la liste des fichiers
00117     
00118     
if (
strlen($laListe)>0) {
00119     
00120     
$lstdf = array() ;
00121     
$ntotf
= 0 ;
00122      if (!
file_exists
($laListe)) {
00123      echo
"<h1>Fichier
$laListe non vu</h1>\n" ;
00124     
$nbViews
= 0 ;
00125      } else {
00126     
$fh
= fopen($laListe,"r") ;
00127      while (!
feof
($fh)) {
00128     
$lig
= fgets($fh, 4096) ;
00129     
#print($lig) ;
00130     
if (
strlen($lig)>0) {
00131     
$ntotf++ ;
00132     
$lig
= str_replace("\n","",$lig) ;
00133     
$lstdf
[$ntotf] = $lig ;
00134      } ;
# fin si
00135     
} ; # fin tant que
00136     
fclose
($fh) ;
00137     
$nbViews
= $ntotf ;
00138      } ;
# fin si
00139     
} ; # fin si
00140     
00141     #echo "Liste des liens : \n" ;
00142     #print_r($lstdf) ;
00143     
00144     # préparation des indices pour la diapo numéro idp
00145     
00146     
$idp
= 1 ;
00147     if (isset(
$_GET
["diapo"])) { $idp = $_GET["diapo"] ; } ;
00148     if (
$idp
=="") { $idp=1 ; } ;
00149     if (
$idp
==0) { $idp=1 ; } ;
00150     
00151     echo
'<?xml version="1.0" encoding="ISO-8859-1" ?>' ;
00152     
00153     
# gestion des cadres
00154     
00155     
if (
$cadre==0) { # conteneur
00156     
00157      # cadre principal
00158     
00159     
if (
$idp>$nbViews) { $idp = 1 ; } ;
00160     
00161      echo
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">' ;
00162      echo
"<html xmlns='http://www.w3.org/1999/xhtml' lang='fr' xml:lang='fr'> \n" ;
00163      echo
"<head>\n" ;
00164      echo
"<title>\n" ;
00165      echo
"
$leTitre numéro $idp\n" ;
00166      echo
"</title>\n" ;
00167     
00168     
$jdp
= $idp + 1 ;
00169     
$url0
= frameUrl($baseFrame,$jdp,0,$duree) ;
00170     
$url1
= frameUrl($baseFrame,$idp,1,$duree) ;
00171     
$url2
= frameUrl($baseFrame,$idp,2,$duree) ;
00172     
00173      echo
"<meta http-equiv='refresh' content=\"
$duree; url=".$url0."&amp;duree=$duree"."\" />\n" ; # content = \"50 pour ralentir
00174     
echo
"<script type='text/javascript' src='diaporama_gen.js'></script>\n" ;
00175      echo
"</head>\n" ;
00176      echo
" <frameset rows=\"93%,7%\">" ;
00177      echo
" <frame src='
$url1' />\n" ;
00178      echo
" <frame src='
$url2' />\n" ;
00179      echo
" </frameset> \n" ;
00180     
00181     } else {
00182     
00183      echo
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ;
00184      echo
'<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">' ;
00185      echo
'<head>' ;
00186      echo
'<link rel="stylesheet" type="text/css" href="std.css" title="gh" />' ;
00187      echo
'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />' ;
00188      echo
"<script type='text/javascript' src='diaporama_gen.js'></script>\n" ;
00189     
00190     
# définition de l'URL via la liste ou par fonction
00191     
00192     
if (
strlen($laListe)>0) {
00193     
$url
= $lstdf[$idp] ;
00194      } else {
00195     
$url
= urlsite($idp) ;
00196      } ;
# fin si
00197     
00198     
if (
$cadre==1) { # cadre du haut
00199     
echo
"<meta http-equiv=\"refresh\" content=\"0; url=".$url."\" />\n" ;
00200      } ;
# fin si cadre 1
00201     
00202      # partie commune aux cadres
00203     
00204     
echo
'<title>' ;
00205      echo
$leTitre ;
00206      echo
'</title>' ;
00207      echo
'</head>'
."\n" ;
00208      echo
'<body background="beige.jpg" onload="navigation()">'
."\n" ;
00209     
00210      if (
$cadre
==1) { # cadre du haut
00211     
00212     
echo
'<p>' ;
00213      echo
"
$leTitre $idp en chargement..." ;
00214      echo
'</p>' ;
00215     
00216      } else {
# cadre du bas
00217     
00218     
echo
"<table summary='formatage' border='0'><tr>\n" ;
00219      echo
"<td>
$leTitre numéro $idp sur $nbViews : " ;
00220      echo
"<a href=\"
$url\" class='bleuf'>$url</a>" ;
00221      echo
"<noscript>&nbsp;&nbsp;[Javascript est désactivé.]&nbsp;</noscript>" ;
00222      echo
"</td>" ;
00223      echo
"<td id='td1' class='invisible noir'>" ;
00224     
00225      if (
$js
=="OUI") {
00226     
00227      echo
" &nbsp;&nbsp;&nbsp; Durée : " ;
00228     
00229     
$attr
= "" ;
00230     
$attr
.= " type='text'" ;
00231     
$attr
.= " id='duree' " ;
00232     
$attr
.= " name='duree' " ;
00233     
$attr
.= " value='$duree' " ;
00234     
$attr
.= " size='3' " ;
00235     
$attr
.= " onchange='forceDuree(this.value) ; return false ' " ;
00236     
00237      echo
"<input
$attr />" ;
00238      echo
"<input type='hidden' id='nbv' value='
$nbViews' />" ;
00239      echo
" sec. &nbsp;&nbsp;" ;
00240     
00241     
$attr
= "" ;
00242     
$attr
.= "type='submit' " ;
00243     
$attr
.= "value='forcer' " ;
00244     
$attr
.= "onclick='forceDuree(document.getElementById(\"duree\").value) ; return false' " ;
00245     
00246      echo
"<input
$attr />" ;
00247     
00248      echo
" &nbsp;&nbsp;&nbsp; Navigation &nbsp;&nbsp;&nbsp;" ;
00249      echo
"</td><td id='td2'>\n" ;
00250     
00251     
navigation
($baseFrame) ;
00252     
00253      } ;
# fin si sur js
00254     
00255     
echo
"</td></tr></table>" ;
00256     
00257      } ;
# fin si sur cadre 1
00258     
00259     
echo
"</body>\n" ;
00260     
00261     } ;
# fin si sur cadre 0
00262     
00263     
echo
"</html>\n" ;
00264     
00265     } ;
# fin de fonction diaporama
00266     
00267     ###########################################################################################
00268     
00269     
function
frameUrl($url,$idf,$cadre,$duree) {
00270     
00271     
###########################################################################################
00272     
00273     
$chen
= $url."?diapo=".$idf ;
00274     if (
$cadre
>0) { $chen .= "&amp;cadre=".$cadre ; } ;
00275     
00276     return(
$chen) ;
00277     
00278     } ;
# fin de fonction frameUrl
00279     
00280     ###########################################################################################
00281     
00282     
function
navigation($baseFrame="#") {
00283     
00284     
###########################################################################################
00285     
00286     
$bn
= array() ; $tn = array() ;
00287     
$bn
["d"] = "&#9666;&#9666;" ; $tn["d"] = "première" ;
00288     
$bn
["p"] = "&#9666;" ; $tn["p"] = "précédente" ;
00289     
$bn
["="] = "=" ; $tn["="] = "stop" ;
00290     
$bn
["s"] = "&#9656;" ; $tn["s"] = "suivante" ;
00291     
$bn
["f"] = "&#9656;&#9656;" ; $tn["f"] = "dernière" ;
00292     
00293     
$attr
= "";
00294     
$attr
.= "border='1' ";
00295     
$attr
.= "style='border-collapse:collapse ; border-color : black ; background-color : white' ";
00296     
$attr
.= "summary='boutons' " ;
00297     
$attr
.= "class='jenetevoispas' " ;
00298     
$attr
.= "id='tnav'" ;
00299      echo
"<table
$attr>\n<tr>\n" ;
00300     
00301      foreach(
preg_split
("/ /","d p = s f") as $sy) {
00302      echo
"<td><a href='
$baseFrame' onclick='changeDiapo(\"$sy\") ; return false ' title='$tn[$sy]' class='nou noir'>" ;
00303      echo
"&nbsp;"
.$bn[$sy]."&nbsp;</a></td>\n" ;
00304      } ;
# fin si
00305     
echo
"</tr>\n</table>\n" ;
00306     
00307     } ;
# fin de fonction navigation
00308     
00309     ###########################################################################################
00310     
00311     
?>

Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.

 

 

retour gH    Retour à la page principale de   (gH)