Viewing file: functions.php (4.87 KB) -rw----r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php $langs = array ('fr', 'en'); function rand_string( $length ) { $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $str=""; $size = strlen( $chars ); for( $i = 0; $i < $length; $i++ ) { $str .= $chars[ rand( 0, $size - 1 ) ]; }
return $str; } function paginat($pages){ $thePaginate=''; for($i=1; $i<=$pages; $i++) { $thePaginate .='<a href="#" rel="'.$i.'"> '.$i.' </a> - '; } echo substr($thePaginate, 0, -2);
} function curPageURL($llg,$lang) { $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) == "on") {$pageURL .= "s";} $pageURL .= "://"; if (isset($_SERVER["SERVER_PORT"]) != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } // return $pageURL; // $myString = $pageURL; if ( strpos( $pageURL, '?' ) ) { $pageURL=str_replace("$lang=fr", "", $pageURL); $pageURL=str_replace("$lang=en", "", $pageURL); $pageCurrentLink=str_replace("?", "?lang=".$llg."&", $pageURL); echo str_replace("&&", "&", $pageCurrentLink); } }
function fullyListeChoice($dbField, $nomChamp, $label, $lang){ $db = Database::obtain(); $detectNonApllic=selectParent(TABLE_TYPE, "id", $dbField, 'titre_fr'); if(!empty($dbField) && $detectNonApllic!="Non applicable"){ echo' <label for="'.$nomChamp.'" class="label1">'.$label.'</label> <select name="'.$nomChamp.'" class="default required"> <option value="">'.$label.'</option>'; $array1=explode(",", $dbField); foreach($array1 as $nomChamp){ // echo $nomChamp; $sqlShowRecord = "SELECT titre_".$lang.", lettre, numero from ".TABLE_TYPE." WHERE id='".$nomChamp."'"; $recordShowRecord = $db->query_first($sqlShowRecord); if(!empty($recordShowRecord['lettre'])) $valOption=$recordShowRecord['lettre']; else $valOption=$recordShowRecord['numero']; echo'<option value="'.$valOption.'">'.$recordShowRecord['titre_'.$lang].'</option>'; } echo' </select>'; } else if($detectNonApllic=="Non applicable" || $detectNonApllic=="Autres"){ echo '<input type="hidden" name="'.$nomChamp.'" value="0" />'; } }
function fullyListeColorInput($dbField, $nomChamp, $label, $lang){ $db = Database::obtain(); $detectNonApllic=selectParent(TABLE_TYPE, "id", $dbField, 'titre_fr'); if(!empty($dbField) && $detectNonApllic!="Non applicable"){ $array1=explode(",", $dbField); if (in_array('1000', $array1)){ echo '<label for="'.$nomChamp.'" class="label1">'.$label.'</label> <input type="text" id="'.$nomChamp.'" name="'.$nomChamp.'" class="'.$nomChamp.'" />'; } else{ echo' <label for="'.$nomChamp.'" class="label1">'.$label.'</label> <select name="'.$nomChamp.'" class="default"> <option value="">'.$label.'</option>'; $array1=explode(",", $dbField); foreach($array1 as $nomChamp){ $sqlShowRecord = "SELECT titre_".$lang.", codeCouleur from ".TABLE_TYPE." WHERE id='".$nomChamp."'"; $recordShowRecord = $db->query_first($sqlShowRecord); echo'<option value="'.$recordShowRecord['codeCouleur'].'">'.$recordShowRecord['titre_'.$lang].'</option>'; } echo' </select>'; } } else if($detectNonApllic=="Non applicable" || $detectNonApllic=="Autres"){ echo '<input type="hidden" name="'.$nomChamp.'" value="0" />'; } }
function fullyListeColorScript($dbField, $nomChamp, $label, $lang){ $db = Database::obtain(); if(!empty($dbField)){ $array1=explode(",", $dbField); if (in_array('1000', $array1)){ echo '<script> $(document).ready(function() { $(".'.$nomChamp.'").spectrum({ preferredFormat: "hex", showPaletteOnly: true, showPalette:true, allowEmpty: true, palette: [ ['; $sqlPaletteColor = "SELECT titre_".$lang.", codeCouleur, lettre, id from ".TABLE_TYPE." WHERE typePage='Couleur' and active=1 order By orderid asc"; $rowsPaletteColor = $db->query($sqlPaletteColor); while ($recordsPaletteColor = $db->fetch($rowsPaletteColor)) { if((intval($recordsPaletteColor['lettre'])>2 && intval($recordsPaletteColor['lettre']<100)) && $recordsPaletteColor['codeCouleur']!="#"){ echo "'".$recordsPaletteColor['codeCouleur']."',"; } } echo '] ] }); }); </script>'; }} } //////////////////
function selectParent($theTable, $idTable, $idCurent, $champShow){ $db = Database::obtain(); $sqlShowRecord = "SELECT ".$champShow." from `".$theTable."` WHERE ".$idTable."='".$db->escape($idCurent)."'"; $recordShowRecord = $db->query_first($sqlShowRecord); return stripslashes($recordShowRecord[$champShow]); }
function currentMENU($thispage){ if($thispage == basename($_SERVER['PHP_SELF']) ) echo $cur="active"; else echo $cur=""; }
//FUNCTION MENU ACTIVATION ( CURRENT CLASS CSSĀ° function currentSouMENU($action){ if(isset($_GET['action']) && $action==$_GET['action'] ) echo $cur="this"; else echo $cur=""; } ?>
|