Listing du fichier std.php
00001 <?php
00002
00003 # # (gH) -_- std.php ; TimeStamp (unix) : 30 Mars 2017 vers 11:56
00004
00005 error_reporting(E_ALL | E_NOTICE | E_STRICT ) ;
00006
00007 require_once("strfun.php") ; # <== fonctions usuelles pour chaines de caractères
00008
00009 # std.php version 3.41
00010
00011 ###########################################################
00012 ###########################################################
00013 ## ##
00014 ## fonctions standard pour pages web ##
00015 ## ##
00016 ###########################################################
00017
00018 ###########################################################
00019
00020 # 3.27 : fonctions pour svg
00021 # 3.25 : volontairement non détaillé
00022 # 3.23 : ajouts de fonctions pour mysql
00023 # 3.21 : reprise de pre_fichier, option utf et input_option
00024
00025 # 3.19 : ajout de bouton et finbouton
00026 # 3.17 : ajout d'un id pour debutSection()
00027 # 3.15 : modification de ul() et ol()
00028 # 3.13 : modification de dd et dt pour avoir des dl compactes (pas de <dl compact="compact"> en strict
00029 # 3.11 : ajout de tableauDar, reprise de tdm (table des matières)
00030 # 3.09 : ajout de label et legende, reprise de th
00031 # 3.07 : ajout de $xtra pour ancre et td, modification de js dans debutPage
00032 # 3.05 : reprise de cmt, ajout de sdl
00033 # 3.03 : reprise de input_radio
00034 # 3.01 : reprise de input_radio
00035 # 2.99 : modification de textarea
00036 # 2.97 : reprise de pre_fichier
00037 # 2.95 : ajout de debutPageMinimale() et finPageMinimale()
00038 # 2.93 : ajout de comptageSqlSimple (pour mysql) et de pct
00039 # 2.91 : reprise de debutPage et finPage pour éviter d'avoir à recopier les gif, jpg et css
00040 # à titre d'exemple seulement ==> debutPageGeneral et finPageGeneral
00041 # 2.89 : modification de la fonction hr ; ajout de l'objet tdm
00042 # 2.87 : ajout des fonctions debutPageMinimal et finPageMinimal ; modification de fieldset
00043 # 2.85 : ajout de la fonction pre_fichier
00044 # 2.79 : amélioration de certaines fonctions (ajout du paramètre $cla)
00045 # 2.77 : ajout des fonctions span, finspan, tdvide, snbsp
00046 # 2.75 : ajout des fonctions img, ahref, href, aname
00047 # 2.73 : ajout des fonctions b pour <b>... et em pour <em>...
00048 # 2.71 : ajouts des fonctions jsf et js pour automatiser <script...
00049 # 2.69 : ajouts de $js dans debutPage
00050 # 2.67 : ajouts mineurs de petites fonctions (formulaire)
00051 # 2.65 : ajout d'un paramètre facultatif pour feuille de style dans debutPage
00052 # 2.63 : ajout d'un paramètre facultatif pour DTD "strict" dans debutPage
00053 # 2.61 : ajout de fonctions pour formulaire
00054
00055 #######################################################################################
00056
00057 function debutPageMinimal($titre="",$styl="",$classFond="") {
00058
00059 #######################################################################################
00060
00061 echo "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" ;
00062 echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n" ;
00063 echo "<html xmlns='http://www.w3.org/1999/xhtml' lang='fr' xml:lang='fr'>\n" ;
00064
00065 echo "<head>\n" ;
00066 echo "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' /> \n" ;
00067
00068 # chargement de style(s) personnalisé(s)
00069
00070 if ($styl!="") {
00071 $tstyl = preg_split("/\s+/",trim($styl)) ;
00072 foreach ($tstyl as $fstyl) {
00073 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$fstyl\" title=\"gh\" /> \n" ;
00074 } ; # fin pour
00075 } ; # fin de si
00076
00077 echo "<title> \n" ;
00078 echo "$titre \n" ;
00079 echo "</title> \n" ;
00080 echo "</head> \n" ;
00081
00082 if ($classFond=="") {
00083 echo "<body> \n" ;
00084 } else {
00085 echo "<body class='$classFond'> \n" ;
00086 } ; # fin si
00087
00088 } # fin de fonction debutPageMinimal
00089
00090 #######################################################################################
00091
00092 function finPageMinimal() {
00093
00094 #######################################################################################
00095
00096 echo "</body>\n" ;
00097 echo "</html>\n" ;
00098
00099 } # fin de fonction finPageMinimal
00100
00101 ###########################################################
00102
00103 function debutPage($titre="",$grm="std",$styl="",$js="",$favicon="",$mathjax="off") {
00104
00105 ###########################################################
00106
00107 if ($grm=="svg") { header("Content-type: image/svg+xml") ; } ;
00108 #if ($grm!="html5") { echo "<"."?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?".">\n" ; } ;
00109
00110 if ($grm=="std") {
00111 echo "<!DOCTYPE html \n" ;
00112 echo " PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \n" ;
00113 echo " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> \n" ;
00114 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\"> \n" ;
00115 } elseif ($grm=="svg") {
00116 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n" ;
00117 #echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">'."\n" ;
00118 echo '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg">'."\n" ;
00119 } elseif ($grm=="html5") {
00120 echo "<!doctype html>\n" ;
00121 echo "<html>\n" ;
00122 } else {
00123 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n" ;
00124 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\">\n\n" ;
00125 } ; # fin de si
00126
00127 echo "<head> \n" ;
00128 echo " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n" ;
00129
00130 # chargement éventuel de mathajx
00131
00132 if ($mathjax=="on") {
00133
00134 echo " <script type='text/x-mathjax-config'>\n" ;
00135 #echo " MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }) ; \n" ;
00136 echo " MathJax.Hub.Config({ tex2jax: {inlineMath: [['$','$']] } }) ; \n" ;
00137 echo " </script>\n" ;
00138 echo ' <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/1.1-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full"></script>'."\n" ;
00139
00140 } ; # fin si
00141
00142 # chargement d'un ou plusieurs fichiers javascript
00143
00144 if ($js!="") {
00145 $tjs = preg_split("/\s+/",trim($js)) ;
00146 foreach($tjs as $fjs) {
00147 echo " <script type='text/javascript' src='$fjs'></script>\n" ;
00148 } ; # fin pour
00149 } ; # fin de si
00150
00151 if ($favicon!="") {
00152 echo " <link rel='icon' type='image/png' href='$favicon' />\n" ;
00153 } ; # fin de si
00154
00155 # chargement du style standard
00156
00157 echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"std.css\" title=\"gh\" />\n" ;
00158
00159 # chargement de style(s) personnalisé(s)
00160
00161 if ($styl!="") {
00162 $tstyl = preg_split("/\s+/",trim($styl)) ;
00163 foreach ($tstyl as $fstyl) {
00164 echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"$fstyl\" title=\"gh\" /> \n" ;
00165 } ; # fin pour
00166 } ; # fin de si
00167
00168 echo " <title> $titre </title>\n" ;
00169 echo "</head>\n\n" ;
00170
00171 #if ($grm=="std") {
00172 echo "<body class=\"beige_jpg\">\n\n" ;
00173 #} ; # fin de si
00174
00175 echo "<blockquote>\n" ;
00176 echo "<p> </p>\n" ;
00177 if ($grm=="std") {
00178 echo "<p align=\"right\">\n" ;
00179 } else {
00180 echo "<p class='align_right'>\n" ;
00181 } ; # fin de si
00182
00183 echo "<a href=\"http://validator.w3.org/check?uri=referer\">" ;
00184 echo "<img src=\"valid.png\" height=\"31\" width=\"88\" alt=\"Valid XHTML\" />" ;
00185 echo "</a>\n" ;
00186
00187 echo " " ;
00188 $std = "http://forge.info.univ-angers.fr/~gh/std.css" ;
00189 echo "<a href='http://jigsaw.w3.org/css-validator/validator?uri=".urlencode($std)."'>" ;
00190 echo "<img src=\"css.gif\" height=\"31\" width=\"88\" alt=\"Valid CSS2\" />" ;
00191 echo "</a>\n" ;
00192 echo " " ;
00193 echo "</p>\n" ;
00194
00195 } # fin de fonction debutPage
00196
00197 #######################################################################################
00198
00199 function debutPageGeneral($titre="",$grm="std",$styl="",$js="") {
00200
00201 ###########################################################
00202
00203 if ($grm=="svg") { header("Content-type: image/svg+xml") ; } ;
00204 echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n" ;
00205
00206 if ($grm=="std") {
00207 echo "<!DOCTYPE html \n" ;
00208 echo " PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \n" ;
00209 echo " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> \n" ;
00210 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\"> \n" ;
00211 } elseif ($grm=="svg") {
00212 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">'."\n" ;
00213 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" >\n" ;
00214 } else {
00215 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n" ;
00216 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\"> \n" ;
00217 } ; # fin de si
00218
00219 echo "<head> \n" ;
00220 echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" /> \n" ;
00221
00222 # chargement d'un ou plusieurs fichiers javascript
00223
00224 if ($js!="") {
00225 $tjs = preg_split("/\s+/",trim($js)) ;
00226 foreach($tjs as $fjs) {
00227 echo "<script type='text/javascript' src='$fjs'></script>\n" ;
00228 } ; # fin pour
00229 } ; # fin de si
00230
00231
00232 # chargement du style standard
00233
00234 if (@fopen("http://forge.info.univ-angers.fr/~gh/std.css","r")) {
00235 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://forge.info.univ-angers.fr/~gh/std.css\" title=\"gh\" /> \n" ;
00236 } else {
00237 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"std.css\" title=\"gh\" /> \n" ;
00238 } ; # fin de si
00239
00240 # chargement de style personnalisé
00241
00242 if ($styl!="") {
00243 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$styl\" title=\"gh\" /> \n" ;
00244 } ; # fin de si
00245
00246 echo "<title> \n" ;
00247 echo "$titre \n" ;
00248 echo "</title> \n" ;
00249 echo "</head> \n" ;
00250
00251 if ($grm=="std") {
00252 if (@fopen("http://forge.info.univ-angers.fr/~gh/","r")) {
00253 echo "<body background=\"http://forge.info.univ-angers.fr/~gh/beige.jpg\"> \n" ;
00254 } else {
00255 echo "<body background=\"beige.jpg\"> \n" ;
00256 } ; # fin si
00257 } else {
00258 echo "<body class=\"beige_jpg\"> \n" ;
00259 } ; # fin de si
00260
00261 echo "<blockquote> \n" ;
00262 echo "<p> </p> \n" ;
00263 if ($grm=="std") {
00264 echo "<p align=\"right\"> \n" ;
00265 } else {
00266 echo "<p class='align_right'> \n" ;
00267 } ; # fin de si
00268
00269 echo "<a href=\"http://validator.w3.org/check?uri=referer\"> \n" ;
00270 if (@fopen("http://forge.info.univ-angers.fr/~gh/valid.png","r")) {
00271 echo "<img src=\"http://forge.info.univ-angers.fr/~gh/valid.png\" height=\"31\" width=\"88\" alt=\"Valid XHTML\" /> \n" ;
00272 } else {
00273 echo "<img src=\"valid.png\" height=\"31\" width=\"88\" alt=\"Valid XHTML\" /> \n" ;
00274 } ; # fin si
00275 echo "</a>\n" ;
00276
00277 echo " " ;
00278 $std = "http://forge.info.univ-angers.fr/~gh/std.css" ;
00279 echo "<a href='http://jigsaw.w3.org/css-validator/validator?uri=".urlencode($std)."'>\n" ;
00280
00281 if (@fopen("http://forge.info.univ-angers.fr/~gh/css.gif","r")) {
00282 echo "<img src=\"http://forge.info.univ-angers.fr/~gh/css.gif\" height=\"31\" width=\"88\" alt=\"Valid CSS2\" />\n" ;
00283 } else {
00284 echo "<img src=\"css.gif\" height=\"31\" width=\"88\" alt=\"Valid CSS2\" />\n" ;
00285 } ; # fin si
00286 echo "</a>\n" ;
00287 echo " " ;
00288 echo "</p>\n" ;
00289
00290 } # fin de fonction debutPageGeneral
00291
00292 #######################################################################################
00293 #######################################################################################
00294
00295 function finPage() {
00296
00297 #######################################################################################
00298
00299 echo "<!-- fin de page standard (gH) -->\n" ;
00300 echo "<p> </p><p>\n" ;
00301
00302 echo "<a href=\"http://www.info.univ-angers.fr/~gh/\"> \n" ;
00303 echo "<img src=\"return.gif\" alt=\"retour gH\" /></a> \n" ;
00304
00305 echo " Retour à la page principale de \n" ;
00306 echo "<span class='coulGH'>(gH)</span>\n" ;
00307 echo "</p>\n" ;
00308 echo "<p> </p> \n" ;
00309 echo "</blockquote> \n" ;
00310 echo "</body> \n" ;
00311 echo "</html> \n" ;
00312
00313 } # fin de fonction finPage
00314
00315 #######################################################################################
00316
00317 function finPageGeneral() {
00318
00319 #######################################################################################
00320
00321 echo "<!-- fin de page standard (gH) -->\n" ;
00322 echo "<p> </p><p>\n" ;
00323
00324 echo "<a href=\"http://www.info.univ-angers.fr/~gh/\"> \n" ;
00325 if (@fopen("http://forge.info.univ-angers.fr/~gh/return.gif","r")) {
00326 echo "<img src=\"http://forge.info.univ-angers.fr/~gh/return.gif\" alt=\"retour gH\" /></a> \n" ;
00327 } else {
00328 echo "<img src=\"return.gif\" alt=\"retour gH\" /></a> \n" ;
00329 } ; # fin si
00330
00331 echo " Retour à la page principale de \n" ;
00332 echo "<span class='coulGH'>(gH)</span>\n" ;
00333 echo "</p>\n" ;
00334 echo "<p> </p> \n" ;
00335 echo "</blockquote> \n" ;
00336 echo "</body> \n" ;
00337 echo "</html> \n" ;
00338
00339 } # fin de fonction finPageGeneral
00340
00341 #######################################################################################
00342
00343 function debutPageMinimale($tit=" ") {
00344
00345 #######################################################################################
00346
00347 echo "<html> \n" ;
00348 echo "<head> \n" ;
00349 echo "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' /> \n" ;
00350 echo "<title>" ;
00351 echo " $tit " ;
00352 echo "</title> \n" ;
00353 echo "</head> \n" ;
00354 echo "<body> \n" ;
00355 echo "<!-- début de page minimale (gH) -->\n" ;
00356
00357 } # fin de fonction debutPageMinimale
00358
00359 #######################################################################################
00360
00361 function finPageMinimale() {
00362
00363 #######################################################################################
00364
00365 echo "<!-- fin de page minimale (gH) -->\n" ;
00366 echo "<p> </p>\n" ;
00367 echo "</body> \n" ;
00368 echo "</html> \n" ;
00369
00370 } # fin de fonction finPageMinimale
00371
00372 ###########################################################
00373
00374 function debutPageRedir($titre,$temps="",$newUrl="http://www.google.fr/search") {
00375
00376 ###########################################################
00377
00378 echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n" ;
00379 echo "<!DOCTYPE html \n" ;
00380 echo " PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \n" ;
00381 echo " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> \n" ;
00382 echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\"> \n" ;
00383 echo "<head> \n" ;
00384 echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" /> \n" ;
00385 echo "<meta http-equiv=\"Refresh\" content=\"$temps; URL=$newUrl\">" ;
00386 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://www.info.univ-angers.fr/~gh/std.css\" title=\"standard (gH)\" /> \n" ;
00387 echo "<title> \n" ;
00388 echo "$titre \n" ;
00389 echo "</title> \n" ;
00390 echo "</head> \n" ;
00391 echo "<body background=\"beige.jpg\"> \n" ;
00392 echo "<blockquote> \n" ;
00393 echo "<p> </p> \n" ;
00394 echo "<h1>redirection vers ".s_span($newUrl,"grouge")."</h1>\n" ;
00395 echo "<p align=\"right\"> \n" ;
00396 echo "<a href=\"http://validator.w3.org/check/referer\"> \n" ;
00397 echo "<img src=\"valid.png\" height=\"31\" width=\"88\" alt=\"Valid XHTML 1.0!\" /> \n" ;
00398 echo "</a>\n" ;
00399 echo " " ;
00400 echo "</p>\n" ;
00401
00402 } # fin de fonction debutPageRedir
00403
00404 #######################################################################################
00405 #######################################################################################
00406
00407 function debutSection($wi="100%",$ids="") {
00408
00409 #######################################################################################
00410
00411 echo "<!-- debut de section (gH) -->\n" ;
00412 if ($ids=="") {
00413 echo "<table cellpadding='50' class='bgcolor_white' width='".$wi."' summary='cadre général'><tr><td class='bgcolor_white'>\n" ;
00414 } else {
00415 echo "<table cellpadding='50' id='$ids' class='bgcolor_white' width='".$wi."' summary='cadre général'><tr><td class='bgcolor_white'>\n" ;
00416 } ; # # finsi
00417
00418 } # fin de fonction debutSection
00419
00420 #######################################################################################
00421 #######################################################################################
00422
00423 function finSection() {
00424
00425 #######################################################################################
00426
00427 echo "<!-- fin de section (gH) -->\n" ;
00428 echo "</td></tr></table> \n" ;
00429 echo "<p> </p> \n" ;
00430
00431 } # fin de fonction finSection
00432
00433 #######################################################################################
00434 #######################################################################################
00435
00436 # passage en gras
00437
00438 function b($chen=" ") {
00439 return "<strong>$chen</strong>" ;
00440 } # fin de fonction b
00441
00442 # em comme "emphase"
00443
00444 function em($chen=" ") {
00445 return "<em>$chen</em>" ;
00446 } # fin de fonction em
00447
00448 # passage en mode clavier (keyboard ==> kbd)
00449
00450 function kbd($chen=" ") {
00451 return "<kbd>$chen</kbd>" ;
00452 } # fin de fonction kbd
00453
00454 # fonction générique pour titre de niveau i
00455
00456 function h($nivi=1,$chen=" ",$cla="",$id="") {
00457 $attr = "" ;
00458 if (!$cla=="") {
00459 $attr .= " class='$cla'" ;
00460 } ; # fin de si
00461 if (!$id=="") {
00462 $attr .= " id='$id'" ;
00463 } ; # fin de si
00464 sdl() ;
00465 echo "<h$nivi$attr>$chen</h$nivi>\n" ;
00466 sdl() ;
00467 } # fin de fonction h
00468
00469 # titre de niveau 1
00470
00471 function h1($chen=" ",$cla="",$id="") {
00472 h("1",$chen,$cla,$id) ;
00473 } # fin de fonction h1
00474
00475 # titre de niveau 2
00476
00477 function h2($chen=" ",$cla="",$id="") {
00478 h("2",$chen,$cla,$id) ;
00479 } # fin de fonction h2
00480
00481 # titre de niveau 3
00482
00483 function h3($chen=" ",$cla="",$id="") {
00484 h("3",$chen,$cla,$id) ;
00485 } # fin de fonction h3
00486
00487 function h4($chen=" ",$cla="",$id="") {
00488 h("4",$chen,$cla,$id) ;
00489 } # fin de fonction h4
00490
00491 # ancien titre de niveau 1
00492
00493 function hh1($chen=" ",$cla="") {
00494 if ($cla=="") {
00495 echo "<h1> $chen </h1>\n" ;
00496 } else {
00497 echo "<h1 class='$cla'> $chen </h1>\n" ;
00498 } ; # fin de si
00499 } # fin de fonction hh1
00500
00501 # ancien titre de niveau 2
00502
00503 function hh2($chen=" ") {
00504 echo "<h2> $chen</h2>\n" ;
00505 } # fin de fonction hh2
00506
00507 # ancien titre de niveau 3
00508
00509 function hh3($chen=" ") {
00510 echo "<h3> $chen</h3>\n" ;
00511 } # fin de fonction hh3
00512
00513 function cmt($chen=" ") {
00514 return "<!-- $chen -->\n" ;
00515 } # fin de fonction cmt
00516
00517 function sdl($nbl=1) {
00518 echo copies("\n",$nbl) ;
00519 } # fin de fonction sdl
00520
00521 function sub($chen=" ") { # indice
00522 return "<sub>$chen</sub>" ;
00523 } # fin de fonction sub
00524
00525 function sup($chen=" ") { # expsant
00526 return "<sup>$chen</sup>" ;
00527 } # fin de fonction sup
00528
00529 #######################################################################################
00530
00531 function ul($xtra="") {
00532 if ($xtra=="") {
00533 echo "<ul>\n" ;
00534 } else {
00535 echo "<ul $xtra>\n" ;
00536 } ; # fin de si
00537 } # fin de fonction ul
00538
00539 function finul() {
00540 echo "</ul>\n" ;
00541 } # fin de fonction finul
00542
00543 function bouton($id="",$xtra="",$type="",$value="") {
00544 echo "<button" ;
00545 if ($id!="") {
00546 echo " id='$id'" ;
00547 } # fin de si
00548 if ($type!="") {
00549 echo " type='".$type."'" ;
00550 } # fin de si
00551 if ($xtra!="") {
00552 echo " $xtra" ;
00553 } # fin de si
00554 echo ">" ;
00555 if ($value != ""){
00556 echo "$value";
00557 }
00558 echo "</button>\n" ;
00559 }# fin de fonction bouton
00560
00561 function finbouton() {
00562 echo "</button>\n" ;
00563 } # fin de fonction finbouton
00564
00565 function ol($xtra="") {
00566 if ($xtra=="") {
00567 echo "<ol>\n" ;
00568 } else {
00569 echo "<ol $xtra>\n" ;
00570 } ; # fin de si
00571 } # fin de fonction ol
00572
00573 function finol() {
00574 echo "</ol>\n" ;
00575 } # fin de fonction finol
00576
00577 function li($cntli="") {
00578 echo "<li>$cntli</li>\n" ;
00579 } # fin de fonction finli
00580
00581 function debutli($cntli="",$xtra="") {
00582 echo "<li $xtra>$cntli" ;
00583 } # fin de fonction debutli
00584
00585 function finli() {
00586 echo "</li>\n" ;
00587 } # fin de fonction finli
00588
00589 function dt($cntli="",$cla="") {
00590 if ($cla=="") {
00591 echo "<dt>$cntli</dt>\n" ;
00592 } else {
00593 echo "<dt class='$cla'>$cntli</dt>\n" ;
00594 } ; # fin de si
00595 } # fin de fonction dt
00596
00597 function dd($cntli="",$cla="") {
00598 if ($cla=="") {
00599 echo "<dd>$cntli</dd>\n" ;
00600 } else {
00601 echo "<dd class='$cla'>$cntli</dd>\n" ;
00602 } ; # fin de si
00603 } # fin de fonction dd
00604
00605 function debutdd($cntli="") {
00606 echo "<dd>$cntli" ;
00607 } # fin de fonction debutdd
00608
00609 function findd() {
00610 echo "</dd>\n" ;
00611 } # fin de fonction findd
00612
00613 function debutdt($cntli="") {
00614 echo "<dt>$cntli" ;
00615 } # fin de fonction debutdt
00616
00617 function findt() {
00618 echo "</dt>\n" ;
00619 } # fin de fonction findt
00620
00621 function debutdl($cntli="",$xtra="") {
00622 echo "<dl $xtra>$cntli" ;
00623 } # fin de fonction debutdl
00624
00625 function findl() {
00626 echo "</dl>\n" ;
00627 } # fin de fonction findl
00628
00629
00630 #######################################################################################
00631
00632 # quelques span
00633
00634 function s_span($chen,$cla,$id="",$xtra="") {
00635 $attr = "" ;
00636 if (!$cla=="") {
00637 $attr .= " class='$cla'" ;
00638 } ; # fin de si
00639 if (!$id=="") {
00640 $attr .= " id='$id'" ;
00641 } ; # fin de si
00642 if ($xtra!="") { $attr .= " $xtra" ; } ;
00643 return("<span $attr>$chen</span>") ;
00644 } # fin de fonction s_span
00645
00646 function span($cla="",$id="",$xtra="") {
00647 $chen = "<span" ;
00648 if ($cla!="") { $chen .= " class='$cla'" ; } ;
00649 if ($id!="") { $chen .= " id='$id'" ; } ;
00650 if ($xtra!="") { $chen .= " $xtra" ; } ;
00651 $chen .= ">" ;
00652 echo $chen ;
00653 } # fin de fonction span
00654
00655 function finspan() {
00656 echo "</span>" ;
00657 } # fin de fonction finspan
00658
00659 function grouge($chen=" ") {
00660 echo "<span class='grouge'>$chen</span>" ;
00661 } # fin de fonction grouge
00662
00663 function gbleu($chen=" ") {
00664 echo "<span class='gbleu'>$chen</span>" ;
00665 } # fin de fonction gbleu
00666
00667 function s_gbleu($chen=" ") {
00668 return("<span class='gbleu'>$chen</span>") ;
00669 } # fin de fonction gbleu
00670
00671 function gbleuf($chen=" ") {
00672 echo "<span class='gbleuf'>$chen</span>" ;
00673 } # fin de fonction gbleuf
00674
00675 function gvert($chen=" ") {
00676 echo "<span class='gvert'>$chen</span>" ;
00677 } # fin de fonction gvert
00678
00679 function gvertf($chen=" ") {
00680 echo "<span class='gvertf'>$chen</span>" ;
00681 } # fin de fonction gvert
00682
00683 # pre, blockquote et les autres
00684
00685 function finform() {
00686 echo "</form>" ;
00687 } # fin de fonction finform
00688
00689 function p($cla="",$id="") {
00690 $attr = "" ;
00691 if (!$cla=="") {
00692 $attr .= " class='$cla'" ;
00693 } ; # fin de si
00694 if (!$id=="") {
00695 $attr .= " id='$id'" ;
00696 } ; # fin de si
00697 sdl() ;
00698 echo "<p$attr>\n" ;
00699 } # fin de fonction p
00700
00701 function pre($cla="",$id="") {
00702 $attr = "" ;
00703 if (!$cla=="") {
00704 $attr .= " class='$cla'" ;
00705 } ; # fin de si
00706 if (!$id=="") {
00707 $attr .= " id='$id'" ;
00708 } ; # fin de si
00709 echo "<pre $attr>\n" ;
00710 } # fin de fonction pre
00711
00712 function finpre() {
00713 echo "</pre>\n" ;
00714 } # fin de fonction finpre
00715
00716 function pre_fichier($nomfic,$cla="",$nbesp=0,$utf=0) {
00717 pre($cla) ;
00718 if (!file_exists($nomfic)) {
00719 print " fichier $nomfic non vu\n" ;
00720 } else {
00721 $deblig = "" ;
00722 if ($nbesp>0) { $deblig = copies(" ",$nbesp) ; } ;
00723 cmt("deblig avec $nbesp espaces : *$deblig*") ;
00724 $fh = fopen($nomfic,"r") ;
00725 echo"\n" ;
00726 while (!feof ($fh)) {
00727 $lig = fgets($fh, 4096) ;
00728 $lig = preg_replace("/\n/","",$lig);
00729 $ligs = " " ;
00730 $lng = strlen($lig) ;
00731 $idc = 0 ;
00732 while ($idc<$lng) {
00733 $cc = substr($lig,$idc,1) ;
00734 if ($cc=="<") { $cc = "<" ; } ;
00735 if ($cc==">") { $cc = ">" ; } ;
00736 if ($cc=="&") { $cc = "&" ; } ;
00737 $ligs .= $cc ;
00738 $idc++ ;
00739 } ; # fintant que
00740 echo $deblig ;
00741 if ($utf==0) {
00742 echo $ligs ;
00743 } else {
00744 echo utf8_decode($ligs) ;
00745 } ; # fin si
00746 echo"\n" ;
00747 } ; # fin tant que
00748 fclose($fh) ;
00749 } ; # fin si le fichier existe
00750
00751 finpre() ;
00752 } # fin de fonction pre_fichier
00753
00754 function code($cla="") {
00755 if ($cla=="") {
00756 echo "<code>\n" ;
00757 } else {
00758 echo "<code class='$cla'>\n" ;
00759 } ; # fin de si
00760 } # fin de fonction code
00761
00762 function fincode() {
00763 echo "</code>\n" ;
00764 } # fin de fonction fincode
00765
00766 function br() {
00767 echo "<br />\n" ;
00768 } # fin de fonction br
00769
00770 function sbr() {
00771 return("<br />\n") ;
00772 } # fin de fonction br
00773
00774 function nbsp($rep=1) {
00775 echo copies(" ",$rep) ;
00776 } # fin de fonction nbsp
00777
00778 function snbsp($rep=1) {
00779 return(copies(" ",$rep)) ;
00780 } # fin de fonction snbsp
00781
00782 function s_nbsp($rep=1) {
00783 return(copies(" ",$rep)) ;
00784 } # fin de fonction s_nbsp
00785
00786 function ptexte() {
00787 echo "<p class='texte'>\n" ;
00788 } # fin de fonction p
00789
00790 function pj() {
00791 echo "<p class='texte'>\n" ;
00792 } # fin de fonction pj
00793
00794 function finp() {
00795 sdl() ;
00796 echo "</p>\n" ;
00797 sdl() ;
00798 } # fin de fonction finp
00799
00800 function pvide() {
00801 echo "<p> </p>\n" ;
00802 } # fin de fonction pvide
00803
00804 function center() {
00805 echo "<center>\n" ;
00806 } # fin de fonction center
00807
00808 function fincenter() {
00809 echo "</center>\n" ;
00810 } # fin de fonction ficenter
00811
00812 function blockquote($id="") {
00813 echo "<blockquote>" ;
00814 if ($id!="") { echo " <!-- $id --> " ; } ;
00815 echo "\n" ;
00816 } # fin de fonction blockquote
00817
00818 function finblockquote($id="") {
00819 echo "</blockquote>" ;
00820 if ($id!="") { echo " <!-- $id --> " ; } ;
00821 echo "\n" ;
00822 } # fin de fonction finblockquote
00823
00824 function table($bord=0,$pad=0,$cla="",$resum="?",$xtra="") {
00825 sdl() ;
00826 $defcla = "" ;
00827 if (strlen($cla)>0) { $defcla = "class='$cla'" ; } ;
00828 echo "<table border=\"$bord\" cellpadding=\"$pad\" $defcla summary=\"$resum\" $xtra>\n" ;
00829 } # fin de fonction table
00830
00831 function fintable() {
00832 echo "</table>\n" ;
00833 sdl() ;
00834 } # fin de fonction fintable
00835
00836 function entetesTableau($chaineEntetes,$cla="") {
00837 $lesEntetes = preg_split("/\s+/",$chaineEntetes) ;
00838 tr($cla) ;
00839 foreach( $lesEntetes as $col) {
00840 th() ; echo preg_replace("/__/"," ",$col) ; finth() ;
00841 } # fin pour chaque
00842 fintr() ;
00843 } # fin de fonction entetesTableau
00844
00845 function tr($cla="",$xtra="",$sdl=1) {
00846 $defcla = "" ;
00847 if (strlen($cla)>0) { $defcla = "class='$cla'" ; } ;
00848 echo "<tr" ;
00849 if ($defcla!="") {
00850 echo " $defcla" ;
00851 } ; # fin si
00852 if ($xtra!="") {
00853 echo " $xtra" ;
00854 } ; # fin si
00855 echo ">" ;
00856 if ($sdl==1) { echo "\n" ; } ;
00857 } # fin de fonction tr
00858
00859 function fintr() {
00860 echo "</tr>\n" ;
00861 } # fin de fonction fintr
00862
00863 function td($aligne="L",$cla="",$colspan="",$xtra="",$sdl=0) {
00864 $defcla = "" ;
00865 if (strlen($cla)>0) { $defcla = " class='$cla'" ; } ;
00866 if (strlen($colspan)>0) { $defcla .= " colspan='$colspan'" ; } ;
00867 if (strtoupper($aligne)=="R") {
00868 echo "<td align='right'" ;
00869 } elseif (strtoupper($aligne)=="C") {
00870 echo "<td align='center'" ;
00871 } else {
00872 echo "<td align='left'" ;
00873 } ; # fin si
00874 if ($defcla!="") {
00875 echo " $defcla" ;
00876 } ; # fin si
00877 if ($xtra!="") {
00878 echo " $xtra" ;
00879 } ; # fin si
00880 echo ">" ;
00881 if ($sdl==1) { echo "\n" ; } ;
00882 } # fin de fonction td
00883
00884 function th($aligne="C",$cla="",$colspan="",$xtra="",$sdl=1) {
00885 $defcla = "" ;
00886 if (strlen($cla)>0) { $defcla = " class='$cla'" ; } ;
00887 if (strlen($colspan)>0) { $defcla .= " colspan='$colspan'" ; } ;
00888 if (strtoupper($aligne)=="R") {
00889 echo "<th align='right'" ;
00890 } elseif (strtoupper($aligne)=="C") {
00891 echo "<th align='center'" ;
00892 } else {
00893 echo "<th align='left'" ;
00894 } ; # fin si
00895 if ($defcla!="") {
00896 echo " $defcla" ;
00897 } ; # fin si
00898 if ($xtra!="") {
00899 echo " $xtra" ;
00900 } ; # fin si
00901 echo ">" ;
00902 if ($sdl==1) { echo "\n" ; } ;
00903 } # fin de fonction th
00904
00905 function fintd() {
00906 echo "</td>\n" ;
00907 } # fin de fonction fintd
00908
00909 function tdvide() {
00910 echo "<td> </td>\n" ;
00911 } # fin de fonction tdvide
00912
00913 function finth() {
00914 echo "</th>\n" ;
00915 } # fin de fonction finth
00916
00917 function tdk($aligne) {
00918 if (strtoupper($aligne)=="R") {
00919 echo "<td align='right'>\n<kbd>" ;
00920 } else {
00921 echo "<td><kbd>" ;
00922 } ; # fin si
00923 } # fin de fonction tdk
00924
00925 function fintdk() {
00926 echo "</kbd>\n</td>\n" ;
00927 } # fin de fonction fintdk
00928
00929 function div($cla="",$id="",$xtra="") {
00930 $attr = "" ;
00931 if (!$cla=="") {
00932 $attr .= " class='$cla'" ;
00933 } ; # fin de si
00934 if (!$id=="") {
00935 $attr .= " id='$id'" ;
00936 } ; # fin de si
00937 if (!$xtra=="") {
00938 $attr .= " $xtra" ;
00939 } ; # fin de si
00940 echo "<div$attr>\n" ;
00941 } # fin de fonction div
00942
00943 function findiv() {
00944 echo "</div>\n" ;
00945 } # fin de fonction findiv
00946
00947 function hr($cla="",$xtra="") {
00948 if (strlen($cla)==0) {
00949 echo "<hr $xtra/>\n" ;
00950 } else {
00951 echo "<hr class='$cla' $xtra/>\n" ;
00952 } ; # fin si
00953 } # fin de fonction hr
00954
00955 #######################################################################################
00956
00957 function form($action=".",$method="get",$xtra="") {
00958 echo "<form action='$action' method='$method' $xtra>\n" ; ;
00959 } # fin de fonction form
00960
00961 function fieldset($cla="") {
00962 if (strlen($cla)>0) {
00963 echo "<fieldset class='$cla'>\n" ;
00964 } else {
00965 echo "<fieldset>\n" ;
00966 } ; # fin si
00967 } # fin de fonction fieldset
00968
00969 function finfieldset() {
00970 echo "</fieldset>\n" ;
00971 } # fin de fonction finfieldset
00972
00973 function label($texte,$for,$id) {
00974 echo "<label for='$for' id='$id'>$texte" ;
00975 echo "</label>\n" ;
00976 } # fin de fonction label
00977
00978 function legende($lngd,$cla="") {
00979 if (strlen($cla)>0) {
00980 echo "<legend class='$cla'>\n" ;
00981 } else {
00982 echo "<legend>\n" ;
00983 } ; # fin si
00984 echo "$lngd\n" ;
00985 echo "</legend>\n" ;
00986 } # fin de fonction legende
00987
00988 function input_hidden($name,$value=0,$id="") {
00989 if ($id=="") { $id = $name ; } ;
00990 echo "<input type='hidden' name='$name' value='$value' id='$id' />\n" ;
00991 } # fin de fonction input_hidden
00992
00993 function input_text($name,$value=0,$size="",$cla="") {
00994 $defcla = "" ;
00995 if (strlen($size)==0) { $size = "10" ; } ;
00996 if (strlen($cla)>0) { $defcla = "class='$cla'" ; } ;
00997 echo "<input type='text' id='$name' name='$name' value='$value' size='$size' $defcla />\n" ;
00998 } # fin de fonction input_text
00999
01000 function input_textNoId($name,$value=0,$size="",$cla="") {
01001 $defcla = "" ;
01002 if (strlen($size)==0) { $size = "10" ; } ;
01003 if (strlen($cla)>0) { $defcla = "class='$cla'" ; } ;
01004 echo "<input type='text' name='$name' value='$value' size='$size' $defcla />\n" ;
01005 } # fin de fonction input_textNoId
01006
01007 function input_password($name,$value="",$size=15,$cla="") {
01008 $defcla = "" ;
01009 if (strlen($cla)>0) { $defcla = "class='$cla'" ; } ;
01010 echo "<input type='password' id='$name' name='$name' value='$value' size='$size' $defcla />\n" ;
01011 } # fin de fonction input_password
01012
01013 function input_checkbox($value,$display="",$cla="",$chk="") {
01014 if ($display=="") { $display = $value ; } ;
01015 $vchk = "" ;
01016 if (!$chk== "") { $vchk=" checked='checked' " ; } ;
01017 if (!$cla=="") { $display = "<span class='$cla'>$display</span>" ; } ;
01018 echo "<input type='checkbox' id='$value' name=\"$value\" $vchk /> $display" ;
01019 } # fin de fonction input_checkbox
01020
01021 function input_checkboxOnClick($name, $value, $id="", $chk="", $cla="",$onClick="", $display="") {
01022 $attr = "" ;
01023 if (!$name== "") { $attr .= " name='$name' " ; } ;
01024 if (!$value=="") { $attr .= " value='$value' " ; } ;
01025 if (!$id== "") { $attr .= " id='$id' "; } ;
01026 if (!$chk== "") { $attr .= " checked='checked' "; } ;
01027 if (!$onClick== "") { $attr .= " onclick='$onClick' "; } ;
01028 if (!$cla=="") { $display = "<span class='$cla'>$display</span>" ; } ;
01029 echo "<input type='checkbox' $attr /> $display\n" ;
01030 } # fin de fonction input_checkboxOnClick
01031
01032 function input_radio($name,$value,$display="",$cla="",$chk="",$id="",$xtra="") {
01033 $attr = "" ;
01034 if (!$name== "") { $attr .= " name='$name' " ; } ;
01035 if (!$id== "") { $attr .= " id='$id' " ; } ;
01036 if (!$value=="") { $attr .= " value='$value' " ; } ;
01037 if (!$chk== "") { $attr .= " checked='checked' " ; } ;
01038 if (!$cla=="") { $display = "<span class='$cla'>$display</span>" ; } ;
01039 if (!$xtra=="") { $attr .= " $xtra" ; } ;
01040 echo "<input type='radio' $attr /> $display\n" ;
01041 } # fin de fonction input_radio
01042
01043
01044 function input_submit($value,$name="",$clas="",$xtra="") {
01045 echo "<input type='submit' " ;
01046 if (!$value=="") { echo " value='$value'" ; } ;
01047 if (!$name=="") { echo " name='$name'" ; } ;
01048 if (!$clas=="") { echo " class='$clas'" ; } ;
01049 if (!$xtra=="") { echo " $xtra" ; } ;
01050 echo " />\n" ;
01051 } # fin de fonction input_submit
01052
01053 function input_reset($value,$name="",$clas="",$xtra="") {
01054 echo "<input type='reset' " ;
01055 if (!$value=="") { echo " value='$value'" ; } ;
01056 if (!$name=="") { echo " name='$name'" ; } ;
01057 if (!$clas=="") { echo " class='$clas'" ; } ;
01058 if (!$xtra=="") { echo " $xtra" ; } ;
01059 echo "/>\n" ;
01060 } # fin de fonction input_reset
01061
01062 function input_file($name, $maxlength=123456,$extra="") {
01063 echo '<input type="file" id="'.$name.'" name="'.$name.'" maxlength="'.$maxlength.'" '.$extra.' />'."\n" ;
01064 } # fin de fonction input_file
01065
01066
01067 function textarea($name,$class="",$rows=8,$cols=40,$id="") {
01068 $attr = "" ;
01069 if ($name!="") {
01070 $attr .= " name='$name'" ;
01071 } ; # fin de si
01072 if ($class!="") {
01073 $attr .= " class='$class'" ;
01074 } ; # fin de si
01075 if ($id!="") {
01076 $attr .= " id='$id'" ;
01077 } ; # fin de si
01078 if ($rows=="") { $rows=8 ; } ;
01079 if ($cols=="") { $cols=40 ; } ;
01080 $attr .= " rows='$rows' cols='$cols'" ;
01081 echo "<textarea $attr>\n" ;
01082 } # fin de fonction textarea
01083
01084 function textarea_fichier($name,$class="",$rows=8,$cols=40,$id="",$fichier,$deb=" ") {
01085 $attr = "" ;
01086 if (!$name=="") {
01087 $attr .= " name='$name'" ;
01088 } ; # fin de si
01089 if (!$class=="") {
01090 $attr .= " class='$class'" ;
01091 } ; # fin de si
01092 if (!$id=="") {
01093 $attr .= " id='$id'" ;
01094 } ; # fin de si
01095 $attr .= " rows='$rows' cols='$cols'" ;
01096 echo "<textarea $attr>\n" ;
01097 if (!file_exists($fichier)) {
01098 print " fichier $fichier non vu\n" ;
01099 } else {
01100 $fh = fopen($fichier,"r") ;
01101 echo"\n" ;
01102 while (!feof ($fh)) {
01103 $lig = fgets($fh, 4096) ;
01104 $lig = preg_replace("/\n/","",$lig);
01105 $ligs = $deb ;
01106 $lng = strlen($lig) ;
01107 $idc = 0 ;
01108 while ($idc<$lng) {
01109 $cc = substr($lig,$idc,1) ;
01110 if ($cc=="<") { $cc = "<" ; } ;
01111 if ($cc==">") { $cc = ">" ; } ;
01112 if ($cc=="&") { $cc = "&" ; } ;
01113 $ligs .= $cc ;
01114 $idc++ ;
01115 } ; # fintant que
01116 echo $ligs ;
01117 echo"\n" ;
01118 } ; # fin tant que
01119 fclose($fh) ;
01120 } ; # fin de si
01121 echo "</textarea>\n" ;
01122
01123 } # fin de fonction textarea_fichier
01124
01125 #######################################################################################
01126
01127 function input_select($name,$xtra="") {
01128 echo "<select id='$name' name='$name' $xtra>\n" ;
01129 } # fin de fonction input_select
01130
01131 function input_select_fin() {
01132 echo "</select>\n" ;
01133 } # fin de fonction input_select_fin
01134
01135 function finselect() {
01136 echo "</select>\n" ;
01137 } # fin de fonction finselect
01138
01139 function input_option($value,$display="",$sel="",$id="",$xtra="") {
01140 if ($display=="") { $display = $value ; } ;
01141 $attr = " value='$value'" ;
01142 if (strlen($sel)>0) { $attr .= " selected='selected'" ; } ;
01143 if (strlen($id)>0) { $attr .= " id='$id'" ; } ;
01144 if (strlen($xtra)>0) { $attr .= " $xtra" ; } ;
01145 echo "<option$attr> $display </option>\n" ;
01146 } # fin de fonction input_option
01147
01148 function listeSelectFromTxt($name,$lstValues,$numSel=1,$xtra="",$underscore=0) {
01149 input_select($name,$xtra) ;
01150 $tabValues = preg_split("/\s+/",(trim($lstValues))) ;
01151 $nbe = 0 ;
01152 foreach ($tabValues as $elt) {
01153 $nbe++;
01154 $esel = "" ;
01155 if ($nbe==$numSel) { $esel = "selected" ; } ;
01156 if ($underscore==1) { $elt = preg_replace("/_/"," ",$elt) ; } ;
01157 echo " " ;
01158 input_option($elt,$elt,$esel) ;
01159 } ; # fin pourchaque
01160 finselect() ;
01161 } # fin de fonction listeSelectFromTxt
01162
01163 function listeSelectFromChampMySql($champ,$table,$name,$numSel=1,$xtra="",$underscore=0) {
01164 $que = "SELECT distinct $champ FROM $table ORDER BY $champ " ;
01165 $res = mysql_query($que) ;
01166 $lstValues = "" ;
01167 while ($ldr=mysql_fetch_array($res)) {
01168 $lstValues .= $ldr[$champ]." " ;
01169 } ; # fintant que
01170 listeSelectFromTxt($name,$lstValues,$numSel=1,$xtra="",$underscore=0) ;
01171 } # fin de fonction listeSelectFromChampMySql
01172
01173 #######################################################################################
01174
01175 function fintextarea() {
01176 echo "</textarea>\n" ;
01177 } # fin de fonction fintextarea
01178
01179 function noscript() {
01180 echo "<noscript>\n" ;
01181 } # fin de fonction noscript
01182
01183 function finnoscript() {
01184 echo "</noscript>\n" ;
01185 } # fin de fonction finnoscript
01186
01187 function abbr($bulle) {
01188 echo "<abbr title='$bulle'>" ;
01189 } # fin de fonction abbr
01190
01191 function finabbr() {
01192 echo "</abbr>" ;
01193 } # fin de fonction finabbr
01194
01195 #######################################################################################
01196 #######################################################################################
01197
01198 # on passe la chaine en rouge foncé (gras)
01199
01200 function ghRouge($chen) {
01201 return("<span class=\"grouge\">$chen</span>") ;
01202 } # fin de fonction ghRouge
01203
01204 # on passe la chaine en bleu foncé (gras)
01205
01206 function ghBleu($chen) {
01207 return("<span class=\"gbleu\">$chen</span>") ;
01208 } # fin de fonction ghBleu
01209
01210 function ghVert($chen) {
01211 return("<span class=\"gvertf\">$chen</span>") ;
01212 } # fin de fonction ghVert
01213
01214 #######################################################################################
01215 #######################################################################################
01216
01217 function img( $src , $alt="",$wi="",$id="",$cla="",$tit='') {
01218
01219 #######################################################################################
01220
01221 #echo "<!-- img src='$src' alt='$alt' -->\n" ;
01222
01223 if ($alt=="") { $alt = "non su" ; } ;
01224 $attr = "src='$src'" ;
01225 $attr .= " alt='$alt'" ;
01226 if (!$wi=="") { $attr .= " width='$wi'" ; } ;
01227 if (!$id=="") { $attr .= " id='$id'" ; } ;
01228 if (!$cla=="") { $attr .= " class='$cla'" ; } ;
01229 if (!$tit=="") { $attr .= " title='$tit'" ; } ;
01230
01231 return("<img $attr />") ;
01232
01233 } # fin de fonction img
01234
01235 #######################################################################################
01236
01237 function imgh( $src , $alt="",$he="") {
01238 if ($alt=="") { $alt="non su" ; } ;
01239 if ($he=="") { $hei="" ; } else { $hei = "height=\"$he\"" ; } ;
01240 echo "<!-- img src='$src' alt='$alt' -->\n" ;
01241 return "<img src='$src' alt='$alt' $hei />" ;
01242 } # fin de fonction imgh
01243
01244 #######################################################################################
01245
01246 function ancre( $href , $nomh="",$cla="",$id="",$xtra="") {
01247
01248 #######################################################################################
01249
01250 $attr = "" ;
01251 if ($nomh=="") { $nomh=$href ; } ;
01252 if (!$href=="") { $attr .= " href='$href'" ; } ;
01253 if (!$cla=="") { $attr .= " class='$cla'" ; } ;
01254 if (!$id=="") { $attr .= " id='$id'" ; } ;
01255 if (!$xtra=="") { $attr .= " $xtra" ; } ;
01256 return("<a $attr>$nomh</a>") ;
01257
01258 } # fin de fonction ancre
01259
01260 #######################################################################################
01261
01262 function ahref( $href , $nomh="",$cla="",$id="",$xtra="") {
01263 return ancre($href , $nomh,$cla,$id,$xtra) ;
01264 } # fin de fonction ahref
01265
01266 #######################################################################################
01267
01268 function href( $href , $nomh="",$cla="",$id="",$xtra="") {
01269 return ancre($href , $nomh,$cla,$id,$xtra) ;
01270 } # fin de fonction href
01271
01272 #######################################################################################
01273
01274 function aname($chen , $ref) {
01275 return "<a name=\"$ref\">$chen</a>" ;
01276 } # fin de fonction aname
01277
01278 #######################################################################################
01279
01280 function showurlcmtbr($chen,$cmt) {
01281
01282 # affiche un lien suivi de br
01283
01284 echo "<a href=\"$chen\">$cmt</a><br />" ;
01285
01286 } # fin de fonction showurlcmtbr
01287
01288 #######################################################################################
01289
01290 function showurlcmt($chen,$cmt) {
01291
01292 # affiche un lien
01293
01294 echo "<a href=\"$chen\">$cmt</a>" ;
01295
01296 } # fin de fonction showurlcmt
01297
01298 #######################################################################################
01299
01300 # affiche une url en "href" et en "cmt
01301
01302 function showurl($chen) {
01303 showurlcmt($chen,$chen) ;
01304 } # fin de fonction showurl
01305
01306 #######################################################################################
01307
01308 # affiche une url en "href" et en "cmt" suivi de br
01309
01310 function showurlbr($chen) {
01311 showurlcmtbr($chen,$chen) ;
01312 } # fin de fonction showurlbr
01313
01314 #######################################################################################
01315
01316 function js($instr_js="") {
01317
01318 echo "<script type='text/javascript'>" ;
01319 if (!$instr_js=="") { echo $instr_js ; } ;
01320 echo "</script>\n" ;
01321
01322 } # fin de fonction js
01323
01324 #######################################################################################
01325
01326 function jsf($fic_js="",$instr_js="",$charset="") {
01327
01328 #######################################################################################
01329
01330 $chrs = "" ; # exemple : jsf("D3node_leapdb/d3.js","","utf-8") ;
01331
01332 if ($charset!="") { $chrs = " charset='$charset'" ; } ;
01333
01334 if ($fic_js=="") {
01335 echo "<script type='text/javascript'$chrs>" ;
01336 } else {
01337 echo "<script type='text/javascript' src='$fic_js'$chrs>" ;
01338 } ; # fin de si
01339 if (!$instr_js=="") { echo $instr_js ; } ;
01340 echo "</script>\n" ;
01341
01342 } # fin de fonction jsf
01343
01344 #######################################################################################
01345 #######################################################################################
01346
01347 function anonymousConnect($base="test") {
01348
01349 #######################################################################################
01350
01351 mysql_connect("localhost","anonymous","anonymous") or die("probleme connexion mysql\n") ;
01352 mysql_query("use $base") or die("probleme mysql, base $base\n") ;
01353
01354 } # fin de fonction anonymousConnect
01355
01356 #######################################################################################
01357
01358 function comptageSqlSimple($champ,$table,$condition="",$dbgReq=0) {
01359
01360 #######################################################################################
01361
01362 $esc = "COUNT($champ)";
01363 $req = " SELECT $esc FROM $table " ;
01364 if (strlen(trim($condition))>0) { $req .= " WHERE $condition " ; } ;
01365 if ($dbgReq>0) { echo "\n$req\n" ; } ;
01366 $res = mysql_query($req) ;
01367 $tdr = mysql_fetch_array($res) ;
01368 # print_r($tdr) ;
01369 return( $tdr[$esc] ) ;
01370
01371 } # fin de fonction comptageSqlSimple
01372
01373 #######################################################################################
01374
01375 function fonctionSqlSimple($fonction,$champ,$table,$condition="",$dbgReq=0) {
01376
01377 #######################################################################################
01378
01379 $esc = "$fonction($champ)";
01380 $req = " SELECT $esc FROM $table " ;
01381 if (strlen(trim($condition))>0) { $req .= " WHERE $condition " ; } ;
01382 if ($dbgReq>0) { echo "\n$req\n" ; } ;
01383 $res = mysql_query($req) ;
01384 $tdr = mysql_fetch_array($res) ;
01385 # print_r($tdr) ;
01386 return( $tdr[$esc] ) ;
01387
01388 } # fin de fonction fonctionSqlSimple
01389
01390 #######################################################################################
01391 #######################################################################################
01392
01393 function pct($nb,$tot,$nbdec=0) {
01394
01395 #######################################################################################
01396
01397 $pct = 100*$nb/$tot ;
01398 $fmt = "%5.".$nbdec."f" ;
01399 $f_pct = sprintf($fmt, $pct) ;
01400 return($f_pct) ;
01401
01402 } # fin de fonction pct
01403
01404 #######################################################################################
01405 #######################################################################################
01406
01407 # Quelques objets sous le coude...
01408
01409 #######################################################################################
01410 #######################################################################################
01411
01412 class tdm { # une table des matières cliquable
01413
01414 ################################################################################
01415
01416 # Voir http://forge.info.univ-angers.fr/~gh/internet/montresource.php?nomfic=demotdmobj.php
01417 # pour l'utilisation de cette classe
01418
01419 var $rubriques = array() ; # contient les rubriques
01420 var $numcrub ; # numéro de rubrique courante
01421
01422 public function __construct($rubs) {
01423 $this->rubriques = $rubs ;
01424 $this->numcrub = 1 ;
01425 } # fin de fonction tdm
01426
01427 public function titre($tit="Table des matières cliquable") {
01428 h2($tit) ;
01429 } # fin de fonction titre
01430
01431 public function menu($optB="",$optN="",$cla="") {
01432 # le premier paramètre, si non vide, produit un "blockquote"
01433 # le deuxième paramètre, si non vide, numérote les rubriques
01434 if (strlen($optB)>0) { blockquote() ; } ;
01435 $nbr = count($this->rubriques) ;
01436 for ($idr=1;$idr<=$nbr;$idr++) {
01437 p() ;
01438 $jdr = $idr ;
01439 if ($idr<10) { $jdr = " $idr" ; } ;
01440 if (strlen($optN)>0) { echo $jdr.". " ; } ;
01441 if ($cla=="") {
01442 echo href("#tdm$idr",$this->rubriques[$idr]) ;
01443 } else {
01444 echo href("#tdm$idr",$this->rubriques[$idr],$cla) ;
01445 } # fin si
01446 finp() ;
01447 } # fin pour idr
01448 if (strlen($optB)>0) { finblockquote() ; } ;
01449 } # fin de fonction menu
01450
01451 public function rubriqueParNumero($idrub) {
01452 h2(aname($this->rubriques[$idrub],"tdm$idrub")) ;
01453 } # fin de fonction rubriqueParNumero
01454
01455 public function afficheRubrique($optN="") {
01456 $laRub = "" ;
01457 if (strlen($optN)>0) { $laRub .= $this->numcrub.". " ; } ;
01458 $laRub .= aname($this->rubriques[$this->numcrub],"tdm$this->numcrub") ;
01459 h2($laRub) ;
01460 $this->numcrub++ ;
01461 } # fin de fonction afficheRubrique
01462
01463 public function setNumcrub($numero) {
01464 $this->numcrub = $numero ;
01465 } # fin de fonction setNumcrub
01466
01467 } # fin de classe tdm
01468
01469 #######################################################################################
01470
01471 function tableauDar($fn,$dec="") {
01472
01473 #######################################################################################
01474
01475 #
01476 # cette fonction affiche sous forme de tableau HTML un fichier .dar
01477 # le paramètre $dec contient un codage pour chacune des colonnes :
01478 # L pour justification à gauche
01479 # C pour justification centrée
01480 # x (numérique) pour justification à droite avec x décimales
01481
01482 if (!file_exists($fn)) {
01483 h3(" Fichier ".s_span($fn,"grouge")." non vu") ;
01484 } else {
01485 $fh = fopen($fn,"r") ;
01486 table(1,10,"collapse") ;
01487 echo"\n" ;
01488 $nbl = 0 ;
01489 while (!feof ($fh)) {
01490 $lig = fgets($fh, 4096) ;
01491 if (strlen(trim($lig))>0) {
01492 $nbl++ ;
01493 tr() ;
01494 if ($nbl==1) {
01495 $entete = preg_split("/\s+/",(trim($lig))) ;
01496 foreach ($entete as $idc) {
01497 th() ;
01498 echo $idc ;
01499 finth() ;
01500 } ; # fin pour chaque
01501 } else {
01502 $lignorm = preg_split("/\s+/",(trim($lig))) ;
01503 $jdc = -1 ;
01504 foreach ($lignorm as $idc) {
01505 $jdc++ ;
01506 $cdf = substr($dec,$jdc,1) ;
01507 $mef = $cdf ;
01508 $vdc = $idc ;
01509 if (is_numeric($cdf)) {
01510 $mef = "R" ;
01511 $vdc = sprintf("%0.".$cdf."f",$idc) ;
01512 } ; # fin si
01513 cmt($mef) ;
01514 td($mef) ;
01515 echo $vdc ;
01516 fintd() ;
01517 } ; # fin pour chaque
01518 } ; # fin si
01519 fintr() ;
01520 } ; # fin si
01521 } ; # fin tant que
01522 fintable() ;
01523 } ; # fin si
01524
01525 } # fin de fonction tableauDar
01526
01527 #######################################################################################
01528
01529 function wikifr($mot="") {
01530
01531 #######################################################################################
01532
01533 $url = "http://fr.wikipedia.org/wiki/".urlencode($mot) ;
01534 return($url) ;
01535
01536 } # fin de fonction wikifr
01537
01538 #######################################################################################
01539
01540 function wikien($mot="") {
01541
01542 #######################################################################################
01543
01544 $url = "http://en.wikipedia.org/wiki/$mot" ;
01545 return($url) ;
01546
01547 } # fin de fonction wikien
01548
01549 #######################################################################################
01550
01551 function objet($id="",$data="",$type="",$xtra="") {
01552
01553 #######################################################################################
01554
01555 echo "<object" ;
01556 if ($id!="") { echo ' id="'.$id.'"' ; } ;
01557 if ($data!="") { echo ' data="'.$data.'"' ; } ;
01558 if ($type!="") { echo ' type="'.$type.'"' ; } ;
01559 if ($xtra!="") { echo ' '.$xtra ; } ;
01560 echo " />\n" ;
01561
01562 } # fin de fonction objet
01563
01564 #######################################################################################
01565
01566 function debutobjet($id="",$data="",$type="",$xtra="") {
01567
01568 #######################################################################################
01569
01570 echo "<object" ;
01571 if ($id!="") { echo ' id="'.$id.'"' ; } ;
01572 if ($data!="") { echo ' data="'.$data.'"' ; } ;
01573 if ($type!="") { echo ' type="'.$type.'"' ; } ;
01574 if ($xtra!="") { echo ' '.$xtra ; } ;
01575 echo ">\n" ;
01576
01577 } # fin de fonction debutobjet
01578
01579 #######################################################################################
01580
01581 function finobjet() {
01582
01583 #######################################################################################
01584
01585 echo "</object>\n" ;
01586
01587 } # fin de fonction finobjet
01588
01589 #######################################################################################
01590
01591 function svg($encoding="latin",$width=500,$height=500) {
01592
01593 #######################################################################################
01594
01595 if ($encoding=="") { $encoding = "latin1" ; } ;
01596 header("Content-type: image/svg+xml") ;
01597 #echo '<'.'?xml version="1.0" encoding="'.$encoding.'" ?'.'>'."\n" ;
01598 echo '<svg xmlns="http://www.w3.org/2000/svg" width="'.$width.'" height="'.$height.'" >'."\n" ;
01599
01600 } # fin de fonction svg
01601
01602 #######################################################################################
01603
01604 function finsvg() {
01605
01606 #######################################################################################
01607
01608 echo "</svg>\n" ;
01609
01610 } # fin de fonction finsvg
01611
01612 #######################################################################################
01613
01614 function rect($x=0,$y=0,$width=100,$height=100,$fill="white",$stroke="black",$stroke_width=5) {
01615
01616 #######################################################################################
01617
01618 echo '<rect x="'.$x.'" y="'.$y.'" width="'.$width.'" height="'.$height.'" fill="'.$fill.'"' ;
01619 echo ' stroke="'.$stroke.'" stroke-width="'.$stroke_width.'" />'."\n" ;
01620
01621 } # fin de fonction rect
01622
01623 #######################################################################################
01624 ?>
La coloration syntaxique est réalisée par un enrobage de la function php nommée highlight_file
mais si vous préférez, vous pouvez utiliser celle de SyntaxHighlighter ou même celle de geshi.
Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.
Retour à la page principale de (gH)