Changeset 121585 in spip-zone


Ignore:
Timestamp:
Feb 4, 2020, 4:54:55 PM (3 weeks ago)
Author:
Cerdic
Message:

un filtre pour calculer et afficher la progress bar

Location:
_galaxie_/trad.spip.net/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • _galaxie_/trad.spip.net/trunk

    • Property subgit:lock:8bed23b54dbc69d48565e991d014c6ae6ad03cb2 deleted
    • Property subgit:lock:8682d2bd5a6dcfc8ff513cca4d161030d80aa987 set to 2020-02-04T17:54:59.595
  • _galaxie_/trad.spip.net/trunk/squelettes/inclure/tradlang_bilan_module.html

    r120921 r121585  
    6767                                <abbr title="<:tradlang:info_nb_items_module_new{module=#NOM_MOD,nb=#GET{total_new},lang=#CLE,langue_longue=#GET{langue_longue}}|attribut_html:>">][(#GET{total_new})]</abbr>
    6868                        </td><//B_new_langue>
    69                         <td>[(#SET{percent_ok,[(#GET{total_ok}|div{#GET{total_mere}}|mult{100}|floor)]})][
    70                                 (#SET{percent_relire,[(#GET{total_relire}|div{#GET{total_mere}}|mult{100}|floor)]})][
    71                                 (#SET{percent_modif,[(#GET{total_modif}|div{#GET{total_mere}}|mult{100}|floor)]})][
     69                        <td>[(#SET{percent_ok,[(#GET{total_ok}|div{#GET{total_mere}}|mult{100}|round{1})]})][
     70                                (#SET{percent_relire,[(#GET{total_relire}|div{#GET{total_mere}}|mult{100}|round{1})]})][
     71                                (#SET{percent_modif,[(#GET{total_modif}|div{#GET{total_mere}}|mult{100}|round{1})]})][
    7272                                (#SET{percent_new,[(#VAL{100}|moins{#GET{percent_ok}}|moins{#GET{percent_relire}}|moins{#GET{percent_modif}})]})][
    7373                                (#SET{total_ok_full,[(#GET{total_ok_full}|plus{#GET{percent_ok}})]})][
     
    7575                                (#SET{total_modif_full,[(#GET{total_modif_full}|plus{#GET{percent_modif}})]})][
    7676                                (#SET{total_new_full,[(#GET{total_new_full}|plus{#GET{percent_new}})]})
    77                                 ]<div class="progress" title="<:tradlang:info_module_traduit_pc_lang{pc=#GET{percent_ok},module=#NOM_MOD,lang=#CLE,langue_longue=#GET{langue_longue}}|attribut_html:>">
    78                                   <div class="progress-bar bg-[(#VAL{ok}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_ok}%" aria-valuenow="#GET{percent_ok}" aria-valuemin="0" aria-valuemax="100">[(#GET{percent_ok})%]</div>
    79                                   <div class="progress-bar bg-[(#VAL{relire}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_relire}%" aria-valuenow="#GET{percent_relire}" aria-valuemin="0" aria-valuemax="100"></div>
    80                                   <div class="progress-bar bg-[(#VAL{modif}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_modif}%" aria-valuenow="#GET{percent_modif}" aria-valuemin="0" aria-valuemax="100"></div>
    81                                   <div class="progress-bar bg-[(#VAL{new}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_new}%" aria-valuenow="#GET{percent_new}" aria-valuemin="0" aria-valuemax="100"></div>
    82                                 </div>
     77                                ][(#SET{title,<:tradlang:info_module_traduit_pc_lang{pc=#GET{percent_ok},module=#NOM_MOD,lang=#CLE,langue_longue=#GET{langue_longue}}:>})
     78                                ][(#GET{total_ok}|tradlang_affiche_progressbar{#GET{total_relire},#GET{total_modif},#GET{total_new},first,#GET{title}})]
    8379                        </td>
    8480                        <td>[(#CLE|=={#LANG_MERE}|non)
     
    9894                                <td>[(#SET{percent_new_full,[(#GET{total_new_full}|div{#TOTAL_BOUCLE}|floor)]})][(#GET{percent_new_full})%]</td>
    9995                                <td>
    100                                         <div class="progress">
    101                                           <div class="progress-bar bg-[(#VAL{ok}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_ok_full}%" aria-valuenow="#GET{percent_ok_full}" aria-valuemin="0" aria-valuemax="100">#GET{percent_ok_full}%</div>
    102                                           <div class="progress-bar bg-[(#VAL{relire}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_relire_full}%" aria-valuenow="#GET{percent_relire_full}" aria-valuemin="0" aria-valuemax="100"></div>
    103                                           <div class="progress-bar bg-[(#VAL{modif}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_modif_full}%" aria-valuenow="#GET{percent_modif_full}" aria-valuemin="0" aria-valuemax="100"></div>
    104                                           <div class="progress-bar bg-[(#VAL{new}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_new_full}%" aria-valuenow="#GET{percent_new_full}" aria-valuemin="0" aria-valuemax="100"></div>
    105                                         </div>
     96                                        [(#GET{total_ok_full}|tradlang_affiche_progressbar{#GET{total_relire_full},#GET{total_modif_full},#GET{total_new_full},first,#GET{title}})]
    10697                                </td>
    10798                                <td></td>
  • _galaxie_/trad.spip.net/trunk/squelettes/mes_fonctions.php

    r120921 r121585  
    2121        }
    2222}
     23
     24function tradlang_affiche_progressbar($total_ok, $total_relire, $total_modif, $total_new, $etiquettes = false, $title='') {
     25
     26        $total = $total_ok + $total_relire + $total_modif + $total_new;
     27        $percent = array();
     28        $percent_round = array();
     29        $percent['modif'] = round(100 * $total_modif / $total,1);
     30        $percent_round['modif'] = round($percent['modif']);
     31        $percent['relire'] = round(100 * $total_relire / $total,1);
     32        $percent_round['relire'] = round($percent['relire']);
     33        if ($total_ok > $total_new) {
     34                $percent['new'] = round(100 * $total_new / $total, 1);
     35                $percent_round['new'] = round($percent['new']);
     36                $percent['ok'] = 100 - array_sum($percent);
     37                $percent_round['ok'] = 100 - array_sum($percent_round);
     38        }
     39        else {
     40                $percent['ok'] = round(100 * $total_ok / $total,1);
     41                $percent_round['ok'] = round($percent['ok']);
     42                $percent['new'] = 100 - array_sum($percent);
     43                $percent_round['new'] = 100 - array_sum($percent_round);
     44        }
     45
     46        if (!$title) {
     47                $title = _T('tradlang:info_module_traduit_pc', array('pc' => $percent['ok']));
     48        }
     49
     50        $progress = "<div class=\"progress\" title=\"" . attribut_html($title) . "\">";
     51        foreach(['ok', 'relire', 'modif', 'new'] as $s) {
     52                $v = $percent[$s];
     53                $progress .= '<div class="progress-bar bg-' . statut_to_variant($s) . '" role="progressbar" style="width:'.$v.'%" aria-valuenow="'.$v.'" aria-valuemin="0" aria-valuemax="100">';
     54                if ($etiquettes==='all' or ($etiquettes and $s==='ok')) {
     55                        $progress .= $percent_round[$s] . "%";
     56                }
     57                $progress .= '</div>';
     58        }
     59        $progress .= '</div>';
     60        return $progress;
     61}
  • _galaxie_/trad.spip.net/trunk/squelettes/noisettes/infos/tradlang_infos_module.html

    r121560 r121585  
    3434                                        <BOUCLE_total_item(TRADLANGS){id_tradlang_module}{lang=#LANG}>[(#SET{str_cible,#GET{str_cible}|push{#ID}})] </BOUCLE_total_item>
    3535                                        </B_total_item>
    36                                         [(#SET{percent_ok,[(#CHAINES_OK|div{#GET{total_mere}}|mult{100}|floor)]})][(#SET{percent_relire,[(#CHAINES_RELIRE|div{#GET{total_mere}}|mult{100}|floor)]})][(#SET{percent_modif,[(#CHAINES_MODIF|div{#GET{total_mere}}|mult{100}|floor)]})][(#SET{percent_new,[(#VAL{100}|moins{#GET{percent_ok}}|moins{#GET{percent_relire}}|moins{#GET{percent_modif}})]})]
     36                                        [(#SET{percent_ok,[(#CHAINES_OK|div{#GET{total_mere}}|mult{100}|round)]})]
    3737                                        <span class="valeur_traduit">[(#GET{percent_ok})%]</span>
    3838                                </div>
    3939                                <div class="col-8">
    40                                         <div class="progress" title="<:tradlang:info_module_traduit_pc{pc=#GET{percent_ok}}|attribut_html:>">
    41                                           <div class="progress-bar bg-success" role="progressbar" style="width: #GET{percent_ok}%" aria-valuenow="#GET{percent_ok}" aria-valuemin="0" aria-valuemax="100"></div>
    42                                           <div class="progress-bar bg-warning" role="progressbar" style="width: #GET{percent_relire}%" aria-valuenow="#GET{percent_relire}" aria-valuemin="0" aria-valuemax="100"></div>
    43                                           <div class="progress-bar bg-info" role="progressbar" style="width: #GET{percent_modif}%" aria-valuenow="#GET{percent_modif}" aria-valuemin="0" aria-valuemax="100"></div>
    44                                           <div class="progress-bar bg-danger" role="progressbar" style="width: #GET{percent_new}%" aria-valuenow="#GET{percent_new}" aria-valuemin="0" aria-valuemax="100"></div>
    45                                         </div>
     40                                        [(#CHAINES_OK|tradlang_affiche_progressbar{#CHAINES_RELIRE,#CHAINES_MODIF,#GET{total_mere}|moins{#CHAINES_OK}|moins{#CHAINES_RELIRE}|moins{#CHAINES_MODIF}})]
    4641                                </div>
    4742                        </div>
  • _galaxie_/trad.spip.net/trunk/squelettes/noisettes/listes/tradlang_liste_tous.html

    r121560 r121585  
    4444[(#SET{total_modif,0})]
    4545<//B_total_item_lang>
    46 [(#SET{percent_ok,#GET{total_ok}|div{#GET{total_mere}}|mult{100}|floor})]
    47 [(#SET{percent_relire,#GET{total_relire}|div{#GET{total_mere}}|mult{100}|floor})]
    48 [(#SET{percent_modif,#GET{total_modif}|div{#GET{total_mere}}|mult{100}|floor})]
     46[(#SET{percent_ok,#GET{total_ok}|div{#GET{total_mere}}|mult{100}|round{1}})]
     47[(#SET{percent_relire,#GET{total_relire}|div{#GET{total_mere}}|mult{100}|round{1}})]
     48[(#SET{percent_modif,#GET{total_modif}|div{#GET{total_mere}}|mult{100}|round{1}})]
    4949[(#SET{percent_new,#VAL{100}|moins{#GET{percent_ok}}|moins{#GET{percent_relire}}|moins{#GET{percent_modif}}})]
    5050[(#SET{statuts_texte,#VAL{tradlang}|objet_info{statut_textes_instituer}})]
     
    6969                                ]
    7070                </p>
    71                 <div class="progress" title="<:tradlang:info_module_traduit_pc{pc=#GET{percent_ok}}|attribut_html:>">
    72                   <div class="progress-bar bg-[(#VAL{ok}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_ok}%" aria-valuenow="#GET{percent_ok}" aria-valuemin="0" aria-valuemax="100">#GET{percent_ok}%</div>
    73                   <div class="progress-bar bg-[(#VAL{relire}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_relire}%" aria-valuenow="#GET{percent_relire}" aria-valuemin="0" aria-valuemax="100">#GET{percent_relire}%</div>
    74                   <div class="progress-bar bg-[(#VAL{modif}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_modif}%" aria-valuenow="#GET{percent_modif}" aria-valuemin="0" aria-valuemax="100">#GET{percent_modif}%</div>
    75                   <div class="progress-bar bg-[(#VAL{new}|statut_to_variant)]" role="progressbar" style="width: #GET{percent_new}%" aria-valuenow="#GET{percent_new}" aria-valuemin="0" aria-valuemax="100">#GET{percent_new}%</div>
    76                 </div>
     71                [(#GET{total_ok}|tradlang_affiche_progressbar{#GET{total_relire},#GET{total_modif},#GET{total_new},all})]
    7772        </div>
    7873        ]
     
    10297        [(#ENV{edit}|=={1}|oui)
    10398        <a href="[(#SELF|parametre_url{edit,2})]" class="ajax btn btn-info">#ICON{backwards} <:tradlang:lien_retour_module{module=#NOM_MOD}:></a>]
    104         [(#ENV{edit}|=={1}|non|et{#GET{module_existant,non}|=={oui}|oui}|et{#GET{percent_ok}|!={100}|oui}|oui)
     99        [(#ENV{edit}|=={1}|non|et{#GET{module_existant,non}|=={oui}|oui}|et{#GET{total_ok}|!={#GET{total_mere}}|oui}|oui)
    105100        <a href="[(#SELF|parametre_url{edit,1})]" class="ajax btn btn-primary">#ICON{edit} <:tradlang:lien_editer_tous:></a>]
    106101        [(#BOUTON_ACTION{[#ICON{upload} (#GET{texte_bouton_upload})],[(#SELF|parametre_url{vue,upload})],btn btn-secondary})]
Note: See TracChangeset for help on using the changeset viewer.