Ignore:
Timestamp:
Dec 3, 2010, 11:50:00 PM (13 years ago)
Author:
mistic100
Message:

PHP Optimisateur :
configuration via formulaire
installation semi-automatique des plugins

Location:
extensions/PHP_Optimisateur/files
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/PHP_Optimisateur/files/functions.php

    r7988 r7991  
    22/***************************************\
    33|                       PHP OPTIMISATEUR                        |
    4 |                          Version 1.0                          |
     4|                          Version 1.1                          |
    55\***************************************/
    66
     
    1212        $replace = array ('e','E','a','A','i','I','u','U','o','O','c','C',',n','N','y','Y','_','');
    1313       
    14         if ($renameORNOT) {
    15                 return preg_replace($search, $replace, $string);
    16         } else {
    17                 return $string;
    18         }
     14        return preg_replace($search, $replace, $string);
    1915}
    2016
     
    4945        # si $dirs=true liste les dossiers plutot que les fichiers
    5046        global ${$array}; // Charge la tableau pour la sortie, déclaré à l'exterieur à cause de l'appel recursif de la fonction
    51         $dir = rtrim($dir, '/'); // on vire un eventuel slash mis par l'utilisateur de la fonction a droite du repertoire
     47        $dir = rtrim($dir, '/');
    5248
    5349        if (is_dir($dir)) {
     
    5652                exit;
    5753        }
    58         while (($file = readdir($dh)) !== false ) { //boucle pour parcourir le repertoire
     54        while (($file = readdir($dh)) !== false ) {
    5955                if ($file !== '.' && $file !== '..') {
    6056                        $path = $dir.'/'.$file;
    61                         if (is_dir($path)) { //si on tombe sur un sous-repertoire
     57                        if (is_dir($path)) {
    6258                                if($dirs) ${$array}[] = $path;
    63                                 recursive_readdir($path, $array, $dirs); // appel recursif pour lire a l'interieur de ce sous-repertoire
    64                         } else { // si il s'agit d'un fichier
     59                                recursive_readdir($path, $array, $dirs);
     60                        } else {
    6561                                if(!$dirs) ${$array}[] = $path;
    6662                        }
     
    6965        closedir($dh);
    7066}
     67
     68// Parse le fichier de configuration
     69function XMLParse($xml) {
     70        $content = array();
     71        foreach ($xml as $nom => $elem) {
     72                if (trim($elem) == '') {
     73                        $content[$nom] = XMLParse($elem->children());
     74                } else {
     75                        $content[$nom] = utf8_encode(utf8_decode($elem));
     76                }
     77        }
     78        return $content;
     79}
     80
     81// Crée le fichier de configuration
     82function XMLCreate($array, $level) {
     83        $content = null;
     84        foreach ($array as $nom => $elem) {
     85                if (is_array($elem)) {
     86                        for($i=0;$i<=$level;$i++) $content .= "\t";
     87                        $content .= '<'.$nom.'>'."\n";
     88                        $content .= XMLCreate($elem, $level+1);
     89                        for($i=0;$i<=$level;$i++) $content .= "\t";
     90                        $content .= '</'.$nom.'>'."\n";
     91                } else {
     92                        for($i=0;$i<=$level;$i++) $content .= "\t";
     93                        $content .= '<'.$nom.'>'.$elem.'</'.$nom.'>'."\n";
     94                }
     95        }
     96        return $content;
     97}
     98
     99// Convertit les booléens, entiers et flotants d'un tableau de 'string'
     100function array_settype($array) {
     101        foreach ($array as $key => $value) {
     102                if (is_array($value)) {
     103                        $array[$key] = array_settype($value);
     104                } else {
     105                        if ($value === 'true') {
     106                                $array[$key] = true;           
     107                        } else if ($value === 'false') {
     108                                $array[$key] = false;           
     109                        } else if (preg_match('#^([0-9]*)$#', $value)) {
     110                                settype($array[$key], 'int');           
     111                        } else if (preg_match('#^([0-9]*)(.|,)([0-9]*)$#', $value)) {
     112                                settype($array[$key], 'float');         
     113                        }
     114                }
     115        }
     116               
     117        return $array;
     118}
     119
     120// Booléen vers français ou texte
     121function bool_to_string($bool, $just_echo=0) {
     122        # $just_echo pour pouvoir afficher un booléen tel quel
     123        if (is_bool($bool)) {
     124                if ($bool) {
     125                        if ($just_echo) return 'true';
     126                        else return 'oui';
     127                } else {
     128                        if ($just_echo) return 'false';
     129                        else return 'non';
     130                }
     131        } else {
     132                return $bool;
     133        }
     134}
    71135?>
  • extensions/PHP_Optimisateur/files/style.css

    r7988 r7991  
    66
    77body {
    8         font-size:12px;
    9         font-family:Verdanna;
     8        font-size:13px;
     9        font-family:Calibri,sans-serif;
    1010        background:#eee;
    1111        color:#333;
     12        width:990px;
     13        margin:0 auto;
    1214}
    1315
    1416div {
    15         width:40%;
     17        width:450px;
    1618        margin:10px;
    1719        padding:10px;
    1820        border:1px dotted #333;
    1921        float:left;
     22}
     23
     24a {
     25        color:#EF9700;
     26        text-decoration:none;
     27        padding:0 10px;
     28        float:right;
     29        margin-bottom:1px;
     30}
     31a:hover {
     32        color:#555;
     33        border-bottom:1px dotted #555;
     34        margin-bottom:0;
    2035}
    2136
     
    3449}
    3550
    36 .title {
    37         width:80%;
     51div.title {
     52        float:none;
     53        width:902px;
    3854        padding:10px 30px;
    3955        font-weight:bold;
     
    5975        font-size:1.2em;
    6076}
     77
     78input {
     79        border:1px solid #888;
     80        -moz-border-radius:3px;
     81}
     82
     83b.new:after {
     84        content:' New !';
     85        color:#0ABF00;
     86        font-style:italic;
     87}
     88
     89span.title {
     90        font-weight:bold;
     91        text-decoration:underline;
     92        font-size:1.1em;
     93}
     94
     95td {
     96        width:50%;
     97}
     98tr td:first-child {
     99        text-align:right;
     100        padding-right:5px;
     101}
Note: See TracChangeset for help on using the changeset viewer.