Dotclear

Changeset 2799:b62c278ef730


Ignore:
Timestamp:
11/18/14 13:57:12 (11 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add an option to not leave date alone in media title

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • admin/blog_pref.php

    r2797 r2799  
    243243          $blog_settings->system->put('media_img_title_pattern',$_POST['media_img_title_pattern']); 
    244244          $blog_settings->system->put('media_img_use_dto_first',!empty($_POST['media_img_use_dto_first'])); 
     245          $blog_settings->system->put('media_img_no_date_alone',!empty($_POST['media_img_no_date_alone'])); 
    245246          $blog_settings->system->put('media_img_default_size',$_POST['media_img_default_size']); 
    246247          $blog_settings->system->put('media_img_default_alignment',$_POST['media_img_default_alignment']); 
     
    570571     '<h5>'.__('Default image insertion attributes').'</h5>'. 
    571572     '<p class="vertical-separator"><label for="media_img_title_pattern">'.__('Inserted image title').'</label>'. 
    572      form::combo('media_img_title_pattern',$img_title_combo,html::escapeHTML($blog_settings->system->media_img_title_pattern)).' '. 
    573      '<label for="media_img_use_dto_first" class="classic">'. 
     573     form::combo('media_img_title_pattern',$img_title_combo,html::escapeHTML($blog_settings->system->media_img_title_pattern)).'</p>'. 
     574     '<p><label for="media_img_use_dto_first" class="classic">'. 
    574575     form::checkbox('media_img_use_dto_first','1',$blog_settings->system->media_img_use_dto_first). 
    575576     __('Use original media date if possible').'</label></p>'. 
     577     '<p><label for="media_img_no_date_alone" class="classic">'. 
     578     form::checkbox('media_img_no_date_alone','1',$blog_settings->system->media_img_no_date_alone). 
     579     __('Do not display date if alone in title').'</label></p>'. 
    576580     '<p class="form-note info">'.__('It is retrieved from the picture\'s metadata.').'</p>'. 
    577581 
  • admin/media_item.php

    r2768 r2799  
    169169 
    170170# Function to get image title based on meta 
    171 function dcGetImageTitle($file,$pattern,$dto_first=false) 
     171function dcGetImageTitle($file,$pattern,$dto_first=false,$no_date_alone=false) 
    172172{ 
    173173     $res = array(); 
    174174     $pattern = preg_split('/\s*;;\s*/',$pattern); 
    175175     $sep = ', '; 
     176     $dates = 0; 
     177     $items = 0; 
    176178 
    177179     foreach ($pattern as $v) { 
     
    180182                    $res[] = $file->media_title; 
    181183               } 
     184               $items++; 
    182185          } elseif ($file->media_meta->{$v}) { 
    183186               if ((string) $file->media_meta->{$v} != '') { 
    184187                    $res[] = (string) $file->media_meta->{$v}; 
    185188               } 
     189               $items++; 
    186190          } elseif (preg_match('/^Date\((.+?)\)$/u',$v,$m)) { 
    187191               if ($dto_first && ($file->media_meta->DateTimeOriginal != 0)) { 
     
    190194                    $res[] = dt::str($m[1],$file->media_dt); 
    191195               } 
     196               $items++; 
     197               $dates++; 
    192198          } elseif (preg_match('/^DateTimeOriginal\((.+?)\)$/u',$v,$m) && $file->media_meta->DateTimeOriginal) { 
    193199               $res[] = dt::dt2str($m[1],(string) $file->media_meta->DateTimeOriginal); 
     200               $items++; 
     201               $dates++; 
    194202          } elseif (preg_match('/^separator\((.*?)\)$/u',$v,$m)) { 
    195203               $sep = $m[1]; 
    196204          } 
     205     } 
     206     if ($no_date_alone && $dates == count($res) && $dates < $items) { 
     207          // On ne laisse pas les dates seules, sauf si ce sont les seuls items du pattern (hors séparateur) 
     208          return ''; 
    197209     } 
    198210     return implode($sep,$res); 
     
    276288          $media_desc = dcGetImageTitle($file, 
    277289               $core->blog->settings->system->media_img_title_pattern, 
    278                $core->blog->settings->system->media_img_use_dto_first); 
     290               $core->blog->settings->system->media_img_use_dto_first, 
     291               $core->blog->settings->system->media_img_no_date_alone); 
    279292          if ($media_desc == $file->basename) { 
    280293               $media_desc = ''; 
  • locales/fr/main.po

    r2797 r2799  
    36823682msgstr "Protéger le blog des détournements de clic ou Clickjacking (voir <a href=\"https://fr.wikipedia.org/wiki/Clickjacking\">Wikipedia</a>)" 
    36833683 
     3684msgid "Do not display date if alone in title" 
     3685msgstr "Ne pas afficher la date si elle est seule dans le titre" 
     3686 
    36843687#~ msgid "You don't have permissions to deactivate this plugin." 
    36853688#~ msgstr "Vous n'avez pas les permissions pour désactiver ce plugin." 
Note: See TracChangeset for help on using the changeset viewer.

Sites map