Changeset 8226


Ignore:
Timestamp:
Dec 22, 2010, 1:01:25 PM (13 years ago)
Author:
mistic100
Message:
  • Corrections de bugs
  • Améliorations mineures
Location:
extensions/PHP_Optimisateur
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • extensions/PHP_Optimisateur/config.xml

    r8195 r8226  
    33        <DIRsource>./in/</DIRsource>
    44        <DIRsortie>./out/</DIRsortie>
    5         <silentORNOT>false</silentORNOT>
    6         <DIRhighORNOT>true</DIRhighORNOT>               
    7         <DIMhdORNOT>true</DIMhdORNOT>           
    8         <renameORNOT>true</renameORNOT>                 
    9         <indexORNOT>true</indexORNOT>           
    10         <prefixe_mini>TN-</prefixe_mini> 
    11         <DIMhd>2560</DIMhd>                             
    12         <DIMnormal>800</DIMnormal>                     
    13         <DIMthumbnail>120</DIMthumbnail>       
     5        <silentORNOT>block</silentORNOT>
     6        <DIRhighORNOT>true</DIRhighORNOT>
     7        <DIMhdORNOT>true</DIMhdORNOT>
     8        <renameORNOT>true</renameORNOT>
     9        <indexORNOT>true</indexORNOT>
     10        <prefixe_mini>TN-</prefixe_mini>
     11        <DIMhd>2560</DIMhd>
     12        <DIMnormal>800</DIMnormal>
     13        <DIMthumbnail>120</DIMthumbnail>
    1414        <Qhd>100</Qhd>
    15         <Qnormal>80</Qnormal>                           
    16         <Qthumbnail>80</Qthumbnail>                     
    17         <DPI>72</DPI>   
    18         <copyright>© 2010</copyright>           
    19         <copyONhd>false</copyONhd>                     
    20         <copyONnormal>false</copyONnormal>             
    21         <copyPOS>bottom-right</copyPOS>         
    22         <copySIZE>0.05</copySIZE>                       
    23         <copyCOLOR>000 000 000</copyCOLOR>             
     15        <Qnormal>80</Qnormal>
     16        <Qthumbnail>80</Qthumbnail>
     17        <DPI>72</DPI>
     18        <copyright>© 2010</copyright>
     19        <copyONhd>false</copyONhd>
     20        <copyONnormal>false</copyONnormal>
     21        <copyPOS>bottom-right</copyPOS>
     22        <copySIZE>0.05</copySIZE>
     23        <copyCOLOR>#000000</copyCOLOR>
    2424        <copyFONT>Arial</copyFONT>
    2525        <PluginsBefore></PluginsBefore>
  • extensions/PHP_Optimisateur/files/display_config.php

    r8195 r8226  
    109109                                        <tr>
    110110                                                <td><b>'.l10n('copyCOLOR').' :</b></td>
    111                                                 <td>rgb('.$copyCOLOR.') <span style="vertical-align:middle;border:1px solid #7f7f7f;width:1.5em;height:0.8em;display:inline-block;background:rgb('.str_replace(' ',',',$copyCOLOR).');">&nbsp;</span></td>
     111                                                <td>'.$copyCOLOR.' <span style="vertical-align:middle;border:1px solid #7f7f7f;width:1.5em;height:0.8em;display:inline-block;background:'.$copyCOLOR.';">&nbsp;</span></td>
    112112                                        </tr>
    113113                                        <tr>
  • extensions/PHP_Optimisateur/files/functions.php

    r8195 r8226  
    55\***************************************/
    66
    7 // Affiche les textes
     7// Affiche les textes localisés
    88function l10n($code){
    99        global $Lang;
     
    2121}
    2222
    23 // Trouve la langue
     23// Trouve la langue, retourne la langue de l'utilisateur et les langues installées
    2424function GetLanguage(){
    2525        // tableau avec les langues installées
     
    6464        } else {
    6565                return true;
    66                
    6766        }
    6867}
     
    7069// Supprime un repertoire non-vide
    7170function rrmdir($dir) {
     71        $dir = rtrim($dir, '/');
    7272        if (is_dir($dir)) {
    7373                $objects = scandir($dir);
     
    159159                        } else if (preg_match('#^([0-9]*)$#', $value)) {
    160160                                settype($array[$key], 'int');           
    161                         } else if (preg_match('#^([0-9]*)(.|,)([0-9]*)$#', $value)) {
     161                        } else if (preg_match('#^([0-9]*)(\.|,)([0-9]*)$#', $value)) {
    162162                                settype($array[$key], 'float');         
    163163                        }
     
    171171function bool_to_string($bool, $just_echo=0) {
    172172        global $Lang;
    173         # $just_echo pour pouvoir afficher un booléen tel quel
     173        # $just_echo pour pouvoir afficher un booléen tel quel (echo true; n'affiche rien)
    174174        if (is_bool($bool)) {
    175175                if ($bool) {
     
    184184        }
    185185}
     186
     187// Converti une chaine de config et tableau associatif
     188function ExplodeString($string, $sep1=';', $sep2=':') {
     189        $result = array();
     190        $a = explode($sep1, $string);
     191        foreach ($a as $s) {
     192           $v = explode($sep2, $s);
     193           $result[$v[0]] = $v[1];
     194        }
     195        return $result;
     196}
     197
     198// Converti une couleur HEX et RGB
     199function hex2RGB($hexStr, $returnAsString = false, $seperator = ',') {
     200        $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // Gets a proper hex string
     201        $rgbArray = array();
     202       
     203        if (strlen($hexStr) == 6) { //If a proper hex code, convert using bitwise operation. No overhead... faster
     204                $colorVal = hexdec($hexStr);
     205                $rgbArray['r'] = 0xFF & ($colorVal >> 0x10);
     206                $rgbArray['g'] = 0xFF & ($colorVal >> 0x8);
     207                $rgbArray['b'] = 0xFF & $colorVal;
     208        } elseif (strlen($hexStr) == 3) { //if shorthand notation, need some string manipulations
     209                $rgbArray['r'] = hexdec(str_repeat(substr($hexStr, 0, 1), 2));
     210                $rgbArray['g'] = hexdec(str_repeat(substr($hexStr, 1, 1), 2));
     211                $rgbArray['b'] = hexdec(str_repeat(substr($hexStr, 2, 1), 2));
     212        } else {
     213                return false; //Invalid hex color code
     214        }
     215       
     216        return $returnAsString ? implode($seperator, $rgbArray) : $rgbArray; // returns the rgb string or the associative array
     217}
    186218?>
  • extensions/PHP_Optimisateur/files/index.php

    r7988 r8226  
    11<?php
    22$url = '../index.php';
    3 header( 'Request-URI: '.$url );
    4 header( 'Content-Location: '.$url );
    5 header( 'Location: '.$url );
     3header('Request-URI: '.$url);
     4header('Content-Location: '.$url);
     5header('Location: '.$url);
    66exit();
    77?>
  • extensions/PHP_Optimisateur/files/style.css

    r8195 r8226  
    6262        font-size:1.2em;
    6363        font-style:italic;
     64        font-family:"Consolas";
    6465}
    6566        a:hover {
  • extensions/PHP_Optimisateur/index.php

    r8195 r8226  
    55\***************************************/
    66
    7 set_time_limit(3600);
     7set_time_limit(7200);
    88$TIME_START = microtime(true);
    99
     
    8989        ### Copyright & Options générales des conversion ###
    9090        $copyright = utf8_decode($copyright);
     91        $copyCOLOR = hex2RGB(substr($copyCOLOR,1), true, ' ');
    9192       
    9293        if ($copyONhd) {
     
    125126                // Découpe le nom de fichier : dossier/fichier
    126127                preg_match('#(.*)/(.*)$#', $FilesSortie[$i], $matches);
    127                 $FileFolder = $matches[1];
    128                 $FileName = $matches[2];
     128                $FileFolder = $matches[1]; // dossier de sortie
     129                $FileName = $matches[2]; // nom+ext fichier
    129130                       
    130131                // Crée les sous-dossiers de sortie & 'pwg_high' & 'thumbnail'
     
    158159                }
    159160                if (!isset($BlockThumbnail)) {
    160                         exec('files\nconvert.exe -q '.$Qthumbnail.' -out jpeg -o "'.$FileFolder.'/thumbnail/'.$prefixe_mini.$FileName.'" -dpi 72 '.$convOptions.'-resize '.$DIMthumbnail.' '.$DIMthumbnail.' -rmeta -rexifthumb         "'.$FilesSource[$i].'"');
     161                        exec('files\nconvert.exe -q '.$Qthumbnail.' -out jpeg -o "'.$FileFolder.'/thumbnail/'.$prefixe_mini.$FileName.'" -dpi 72 '.$convOptions.' -resize '.$DIMthumbnail.' '.$DIMthumbnail.' -rmeta -rexifthumb "'.$FilesSource[$i].'"');
    161162                }
    162163                if (!isset($BlockHigh) AND $DIRhighORNOT) {
  • extensions/PHP_Optimisateur/language/en/en.php

    r8195 r8226  
    66
    77$Lang['ErrorFile'] = "Fatal error : Configuration file missing.";
    8 $Lang['ErrorFolderIn'] = "Fatal error : Source folder empty.";
    9 $Lang['ErrorFolderOut'] = "Fatal error : Exit folder not empty.";
    10 $Lang['ErrorNconvert'] = "The program nconvert.exe is unavailable.";
    11 $Lang['Source files'] = "Files";
     8$Lang['ErrorFolderIn'] = "Fatal error : Input folder empty.";
     9$Lang['ErrorFolderOut'] = "Fatal error : Output folder not empty.";
     10$Lang['ErrorNconvert'] = "The program nconvert.exe is not found.";
     11$Lang['Source files'] = "Handled files";
    1212$Lang['%d files'] = "%d files";
    1313$Lang['Finish %d seconds'] = "Process done : %d seconds.";
     
    1818$Lang['Configuration'] = "Configuration";
    1919$Lang['Folders'] = "Folders";
    20 $Lang['FolderIn'] = "Source folder";
    21 $Lang['FolderOut'] = "Exit folder";
     20$Lang['FolderIn'] = "Input folder";
     21$Lang['FolderOut'] = "Output folder";
    2222$Lang['Options'] = "Options";
    23 $Lang['silentORNOT'] = "If exit folder not empty";
     23$Lang['silentORNOT'] = "If output folder not empty";
    2424$Lang['DIRhighORNOT'] = "Create high-definition folders";
    2525$Lang['DIMhdORNOT'] = "Resize HD pictures";
     
    2929$Lang['Sizes and quality'] = "Sizes and quality";
    3030$Lang['DIMhd'] = "HD pictures max size";
    31 $Lang['DIMnormal'] = "Normal pictures size";
     31$Lang['DIMnormal'] = "Normal pictures max size";
    3232$Lang['DIMthumbnail'] = "Thumbnails size";
    33 $Lang['Qhd'] = "HD pistcures quality";
     33$Lang['Qhd'] = "HD pictures quality";
    3434$Lang['Qnormal'] = "Normal pictures quality";
    3535$Lang['Qthumbnail'] = "Thumbails quality";
     
    5959$Lang['pass'] = "Continue";
    6060$Lang['block'] = "Block";
    61 $Lang['New !'] = " New !";
    62 $Lang['Missing !'] = " Missing !";
     61$Lang['New !'] = "New !";
     62$Lang['Missing !'] = "Missing !";
    6363$Lang['Reset'] = "Reset";
    64 $Lang['Valid'] = "Valid";
     64$Lang['Valid'] = "Validate";
    6565?>
  • extensions/PHP_Optimisateur/language/fr/fr.php

    r8195 r8226  
    99$Lang['ErrorFolderOut'] = "Erreur fatale : Dossier de sortie non vide.";
    1010$Lang['ErrorNconvert'] = "Le programme nconvert.exe est introuvable.";
    11 $Lang['Source files'] = "Fichiers";
     11$Lang['Source files'] = "Fichiers traités";
    1212$Lang['%d files'] = "%d fichiers";
    1313$Lang['Finish %d seconds'] = "Opération terminée : %d secondes.";
     
    5959$Lang['pass'] = "Continuer";
    6060$Lang['block'] = "Bloquer";
    61 $Lang['New !'] = " Nouveau !";
    62 $Lang['Missing !'] = " Manquant !";
     61$Lang['New !'] = "Nouveau !";
     62$Lang['Missing !'] = "Manquant !";
    6363$Lang['Reset'] = "Réinitialiser";
    6464$Lang['Valid'] = "Valider";
  • extensions/PHP_Optimisateur/plugins/convert_pan.xml

    r7991 r8226  
    11<convert_pan>
    22        <mode>PluginsProcess</mode>
    3         <active>true</active>
     3        <active>false</active>
    44        <DIMpanorama>500</DIMpanorama>
    55        <NAMEpanorama>_pan</NAMEpanorama>
  • extensions/PHP_Optimisateur/plugins/create_custom_thumbs.php

    r8195 r8226  
    22/***************************************\
    33|                       PHP OPTIMISATEUR                        |
    4 |         Plugin CreateCustomThumbs 1.1         |
     4|         Plugin CreateCustomThumbs 1.0         |
    55\***************************************/
    66
    7 ## Crée des miniatures de taille fixe
     7## Différents traitements sur les miniatures : taille fixe & cadre (2 couleurs)
    88## Dépend de la valeur de $DIMthumbnail
    99
    1010// CreateCustomThumbs à la priorité sur ConvertPan
    1111if (isset($PluginsProcess['convert_pan']) OR !isset($BlockThumbnail)) {
     12
     13        $FileSource = $FilesSource[$i]; // fichier de travail
    1214        $DIMthumbnailV = $PluginsProcess['create_custom_thumbs']['DIMthumbnailV']; // Hauteur de l'image
    13         $max = max($DIMthumbnail, $DIMthumbnailV);
     15        $FRAMEparams = $PluginsProcess['create_custom_thumbs']['FRAMEparams']; // Paramètres du cadre
     16       
     17        // Miniature de taille personnalisée
     18        if ($DIMthumbnailV != '0') {
     19                $max = max($DIMthumbnail, $DIMthumbnailV);
    1420
    15         // on prend la miniature au milieu de l'image
    16         if ($FileInfos['Height'] >= $FileInfos['Width']) {
    17                 $resize_param = $max.' 0';
    18                 $tmp_x = $max;
    19                 $tmp_y = $max * $FileInfos['Height'] / $FileInfos['Width'];
    20         } else {
    21                 $resize_param = '0 '.$max;
    22                 $tmp_x = $max * $FileInfos['Width'] / $FileInfos['Height'];
    23                 $tmp_y = $max;
     21                // on prend la miniature au milieu de l'image
     22                if ($FileInfos['Height'] >= $FileInfos['Width']) {
     23                        $resize_param = $max.' 0';
     24                        $tmp_x = $max;
     25                        $tmp_y = $max * $FileInfos['Height'] / $FileInfos['Width'];
     26                } else {
     27                        $resize_param = '0 '.$max;
     28                        $tmp_x = $max * $FileInfos['Width'] / $FileInfos['Height'];
     29                        $tmp_y = $max;
     30                }
     31               
     32                $offset_x = ($tmp_x - $DIMthumbnail) / 2;
     33                $offset_y = ($tmp_y - $DIMthumbnailV) / 2;
     34               
     35                exec('files\nconvert.exe -overwrite -q '.$Qthumbnail.' -out jpeg -o "'.$FileFolder.'/thumbnail/'.$prefixe_mini.$FileName.'" -dpi 72 '.$convOptions.' -resize '.$resize_param.' -crop '.$offset_x.' '.$offset_y.' '.$DIMthumbnail.' '.$DIMthumbnailV.' -rmeta -rexifthumb        "'.$FileSource.'"');
     36               
     37                $BlockThumbnail = true;
     38                $FileSource = $FileFolder.'/thumbnail/'.$prefixe_mini.$FileName;
    2439        }
    25        
    26         $offset_x = ($tmp_x - $DIMthumbnail) / 2;
    27         $offset_y = ($tmp_y - $DIMthumbnailV) / 2;
    28        
    29         exec('files\nconvert.exe -overwrite -q '.$Qthumbnail.' -out jpeg -o "'.$FileFolder.'/thumbnail/'.$prefixe_mini.$FileName.'" -dpi 72 '.$convOptions.' -resize '.$resize_param.' -crop '.$offset_x.' '.$offset_y.' '.$DIMthumbnail.' '.$DIMthumbnailV.' -rmeta -rexifthumb        "'.$FilesSource[$i].'"');
    30        
    31         $BlockThumbnail = true;
     40
     41        // Cadre autour de la miniature
     42        if ($FRAMEparams != '0') {
     43                // Si la miniature n'a pas encore été générée il faut le faire
     44                if ($FileSource == $FilesSource[$i]) {
     45                        exec('files\nconvert.exe -q '.$Qthumbnail.' -out jpeg -o "'.$FileFolder.'/thumbnail/'.$prefixe_mini.$FileName.'" -dpi 72 '.$convOptions.' -resize '.$DIMthumbnail.' '.$DIMthumbnail.' -rmeta -rexifthumb        "'.$FilesSource[$i].'"');
     46                        $FileSource = $FileFolder.'/thumbnail/'.$prefixe_mini.$FileName;
     47                }
     48
     49                $FRAMEparams = ExplodeString($FRAMEparams);
     50                $colors['name'] = array_keys($FRAMEparams);
     51                $colors['size'] = array_values($FRAMEparams);
     52               
     53                $img = imagecreatefromjpeg($FileSource);
     54                $x = imagesx($img)-1;
     55                $y = imagesy($img)-1;
     56               
     57                $colors[0] = hex2RGB(substr($colors['name'][0],1));
     58                $colors[1] = hex2RGB(substr($colors['name'][1],1));
     59                $colors[0] = imagecolorallocate($img, $colors[0]['r'], $colors[0]['g'], $colors[0]['b']);
     60                $colors[1] = imagecolorallocate($img, $colors[1]['r'], $colors[1]['g'], $colors[1]['b']);
     61
     62                for ($m=0; $m<$colors['size'][0]; $m++) {
     63                        imagerectangle($img, $m, $m, $x-$m, $y-$m, $colors[0]);
     64                }
     65                for ($m=$colors['size'][0]; $m<$colors['size'][0]+$colors['size'][1]; $m++) {
     66                        imagerectangle($img, $m, $m, $x-$m, $y-$m, $colors[1]);
     67                }
     68               
     69                imagejpeg($img, $FileFolder.'/thumbnail/'.$prefixe_mini.$FileName, $Qthumbnail);
     70                imagedestroy($img);
     71               
     72                $BlockThumbnail = true;
     73                $FileSource = $FileFolder.'/thumbnail/'.$prefixe_mini.$FileName;
     74        }
    3275}
     76
    3377?>
  • extensions/PHP_Optimisateur/plugins/create_custom_thumbs.xml

    r8195 r8226  
    11<create_custom_thumbs>
    22        <mode>PluginsProcess</mode>
    3         <active>true</active>
     3        <active>false</active>
    44        <DIMthumbnailV>120</DIMthumbnailV>
     5        <FRAMEparams>#c8c8c8:1;#0a0a0a:4</FRAMEparams>
    56</create_custom_thumbs>
  • extensions/PHP_Optimisateur/plugins/create_folders_alpha.xml

    r7991 r8226  
    11<create_folders_alpha>
    22        <mode>PluginsBefore</mode>
    3         <active>true</active>
     3        <active>false</active>
    44</create_folders_alpha>
  • extensions/PHP_Optimisateur/plugins/front2back_support.xml

    r7991 r8226  
    11<front2back_support>
    22        <mode>PluginsProcess</mode>
    3         <active>true</active>
     3        <active>false</active>
    44        <NAMEverso>_verso</NAMEverso>
    55        <MOVEverso>true</MOVEverso>
  • extensions/PHP_Optimisateur/plugins/watermark.xml

    r7991 r8226  
    11<watermark>
    22        <mode>PluginsBefore</mode>
    3         <active>true</active>
     3        <active>false</active>
    44        <waterFILE>logo.png</waterFILE>
    55        <waterALPHA>80</waterALPHA>
  • extensions/PHP_Optimisateur/setup.php

    r8195 r8226  
    1111if (isset($_POST['DIRsource'])) {
    1212        // Quelques traitements
    13         $_POST['copyCOLOR'] = implode(' ', $_POST['copyCOLOR']);
    1413        $_POST['copyPOS'] = implode('-', $_POST['copyPOS']);
     14        if (!preg_match('#^\#(.*)#', $_POST['copyCOLOR'])) $_POST['copyCOLOR'] = '#'.$_POST['copyCOLOR'];
    1515       
    1616        // Plugins : ensembles existants même si vides & supprime les plugins manquants
     
    5656                echo '<div class="error">'.l10n($key).'</div>';
    5757        }
    58         echo '<div class="link"><a href="index.php">'.l10n('Back').'</a> <a href="setup.php">'.l10n('Config').'</a></div>';
     58        echo '<div class="link"><a href="index.php">>&raquo; '.l10n('Back').'</a> <a href="setup.php">>&raquo; '.l10n('Config').'</a></div>';
    5959}
    6060
     
    8080                        ${$plugin_mode}[$plugin_name] = $plugin;
    8181                        $NewPlugins[$plugin_name] = true;
    82                 } else if (!file_exists('plugins/'.$plugin_name.'.php')) {
    83                         $MissingPlugins[$plugin_name] = true;
    8482                }
    8583        }
     
    9795
    9896        ### Formulaire ###
    99         $copyCOLOR = explode(' ', $copyCOLOR);
    10097        $copyPOS = explode('-', $copyPOS);
    10198       
     
    247244                                                <tr>
    248245                                                        <td><b>'.l10n('copyCOLOR').' :</b></td>
    249                                                         <td>
    250                                                                 <input type="text" name="copyCOLOR[0]" value="'.$copyCOLOR[0].'" size="3" onFocus="this.select();" onKeyUp="suivant(this,\'copyCOLOR[1]\', 3)"/>
    251                                                                 <input type="text" name="copyCOLOR[1]" value="'.$copyCOLOR[1].'" size="3" onFocus="this.select();" onKeyUp="suivant(this,\'copyCOLOR[2]\', 3)"/>
    252                                                                 <input type="text" name="copyCOLOR[2]" value="'.$copyCOLOR[2].'" size="3" onFocus="this.select();" />
    253                                                         </td>
     246                                                        <td><input type="text" name="copyCOLOR" value="'.$copyCOLOR.'" size="6"/></td>
    254247                                                </tr>
    255248                                                <tr>
     
    265258                        <h2>'.l10n('Plugins').'</h2>
    266259                        <ul>';
     260                       
    267261                                // Affichage des plugins, un bloc par mode
    268262                                foreach (array('PluginsBefore','PluginsProcess','PluginsAfter') as $mode) {
     
    277271                                                                        // Cas spéciaux dans le titre(nouveau, manquant)
    278272                                                                        if (isset($NewPlugins[$name])) {
    279                                                                                 echo '<b class="new">'.l10n('New !').'</b>';
     273                                                                                echo ' <b class="new">'.l10n('New !').'</b>';
    280274                                                                        } else if (isset($MissingPlugins[$name])) {
    281                                                                                 echo '<b class="miss">'.l10n('Missing !').'</b>';
     275                                                                                echo ' <b class="miss">'.l10n('Missing !').'</b>';
    282276                                                                        }
    283277                                                                       
     
    287281                                                                                        echo '<tr>
    288282                                                                                                <td>'.l10n('erase').' :</td>
    289                                                                                                 <td><input type="checkbox" name="'.$mode.'['.$name.'][delete]" value="true" checked="checked"/></td>
     283                                                                                                <td><input type="checkbox" name="'.$mode.'['.$name.'][delete]" value="true" checked/></td>
    290284                                                                                        </tr>';
    291285                                                                                // sinon on affiche sa configuration
    292286                                                                                } else {
    293287                                                                                        foreach ($config as $key => $value) {
     288                                                                                                $value = bool_to_string($value,1);
    294289                                                                                                echo '<tr>
    295290                                                                                                        <td>'.$key.' :</td>
    296                                                                                                         <td><input type="text" name="'.$mode.'['.$name.']['.$key.']" value="'.bool_to_string($value,1).'" size="'.strlen(bool_to_string($value,1)).'"/></td>
     291                                                                                                        <td><input type="text" name="'.$mode.'['.$name.']['.$key.']" value="'.$value.'" size="'.strlen($value).'"/></td>
    297292                                                                                                </tr>';
    298293                                                                                        }
Note: See TracChangeset for help on using the changeset viewer.