Dotclear

Changeset 1081:862f566d2372


Ignore:
Timestamp:
12/18/12 15:59:40 (13 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Just for fun, Ductile may now use web fonts (from Google, Adobe and similar providers)

Location:
themes/ductile
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • themes/ductile/_config.php

    r1011 r1081  
    4444} 
    4545 
    46  
    47  
    4846$contexts = array( 
    4947     'default' => __('Home (first page)'), 
     
    6765     __('Impact') => 'Impact', 
    6866     __('Monospace') => 'Monospace' 
     67); 
     68 
     69$webfont_apis = array( 
     70     __('none') => '', 
     71     __('javascript (Adobe)') => 'js', 
     72     __('stylesheet (Google)') => 'css' 
    6973); 
    7074 
     
    227231     // CSS 
    228232     'body_font' => null, 
     233     'body_webfont_family' => null, 
     234     'body_webfont_url' => null, 
     235     'body_webfont_api' => null, 
    229236     'alternate_font' => null, 
     237     'alternate_webfont_family' => null, 
     238     'alternate_webfont_url' => null, 
     239     'alternate_webfont_api' => null, 
    230240     'blog_title_w' => null, 
    231241     'blog_title_s' => null, 
     
    368378          if ($conf_tab == 'css') { 
    369379               $ductile_user['body_font'] = $_POST['body_font']; 
     380               $ductile_user['body_webfont_family'] = $_POST['body_webfont_family']; 
     381               $ductile_user['body_webfont_url'] = $_POST['body_webfont_url']; 
     382               $ductile_user['body_webfont_api'] = $_POST['body_webfont_api']; 
     383 
    370384               $ductile_user['alternate_font'] = $_POST['alternate_font']; 
     385               $ductile_user['alternate_webfont_family'] = $_POST['alternate_webfont_family']; 
     386               $ductile_user['alternate_webfont_url'] = $_POST['alternate_webfont_url']; 
     387               $ductile_user['alternate_webfont_api'] = $_POST['alternate_webfont_api']; 
    371388 
    372389               $ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']); 
     
    507524echo '<h3>'.__('General settings').'</h3>'; 
    508525 
    509 echo '<fieldset><legend>'.__('Fonts').'</legend>'. 
     526echo '<fieldset><legend>'.__('Fonts').'</legend>'; 
     527 
     528echo '<div class="two-cols">'; 
     529echo '<div class="col">'; 
     530echo 
    510531'<p class="field"><label for="body_font">'.__('Main:').' '. 
    511532form::combo('body_font',$fonts,$ductile_user['body_font']).'</label>'. 
    512533(!empty($ductile_user['body_font']) ? ' '.fontDef($ductile_user['body_font']) : ''). 
    513534'</p>'. 
    514  
     535'<p class="form-note">'.__('Set main font to default to use webfont below.').'</p> '. 
     536'<p class="field"><label for="body_webfont_family">'.__('Webfont family:').'</label> '. 
     537form::field('body_webfont_family',25,255,$ductile_user['body_webfont_family']).'</p>'. 
     538'<p class="field"><label for="body_webfont_url">'.__('Webfont URL:').'</label> '. 
     539form::field('body_webfont_url',50,255,$ductile_user['body_webfont_url']).'</p>'. 
     540'<p class="field"><label for="body_webfont_url">'.__('Webfont API:').' '. 
     541form::combo('body_webfont_api',$webfont_apis,$ductile_user['body_webfont_api']).'</label>'.'</p>'; 
     542echo '</div>'; 
     543echo '<div class="col">'; 
     544echo 
    515545'<p class="field"><label for="alternate_font">'.__('Secondary:').' '. 
    516546form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label>'. 
    517547(!empty($ductile_user['alternate_font']) ? ' '.fontDef($ductile_user['alternate_font']) : ''). 
    518548'</p>'. 
    519 '</fieldset>'; 
     549'<p class="form-note">'.__('Set secondary font to default to use webfont below.').'</p> '. 
     550'<p class="field"><label for="alternate_webfont_family">'.__('Webfont family:').'</label> '. 
     551form::field('alternate_webfont_family',25,255,$ductile_user['alternate_webfont_family']).'</p>'. 
     552'<p class="field"><label for="alternate_webfont_url">'.__('Webfont URL:').'</label> '. 
     553form::field('alternate_webfont_url',50,255,$ductile_user['alternate_webfont_url']).'</p>'. 
     554'<p class="field"><label for="alternate_webfont_api">'.__('Webfont API:').' '. 
     555form::combo('alternate_webfont_api',$webfont_apis,$ductile_user['alternate_webfont_api']).'</label>'.'</p>'; 
     556echo '</div>'; 
     557echo '</div>'; 
     558echo '</fieldset>'; 
    520559 
    521560echo '<div class="two-cols">'; 
  • themes/ductile/_public.php

    r1045 r1081  
    250250               $core->blog->settings->system->themes_url.'/'.$core->blog->settings->system->theme. 
    251251               '/ductile.js"></script>'."\n"; 
     252 
     253          echo self::ductileWebfontHelper(); 
     254     } 
     255 
     256     public static function ductileWebfontHelper() 
     257     { 
     258          $s = $GLOBALS['core']->blog->settings->themes->get($GLOBALS['core']->blog->settings->system->theme.'_style'); 
     259 
     260          if ($s === null) { 
     261               return; 
     262          } 
     263 
     264          $s = @unserialize($s); 
     265          if (!is_array($s)) { 
     266               return; 
     267          } 
     268 
     269          $ret = ''; 
     270          $css = array(); 
     271          $uri = array(); 
     272          if (!isset($s['body_font']) || ($s['body_font'] == '')) { 
     273               // See if webfont defined for main font 
     274               if (isset($s['body_webfont_api']) && isset($s['body_webfont_family']) && isset($s['body_webfont_url'])) { 
     275                    $uri[] = $s['body_webfont_url']; 
     276                    switch ($s['body_webfont_api']) { 
     277                         case 'js': 
     278                              $ret .= sprintf('<script type="text/javascript" src="%s"></script>',$s['body_webfont_url'])."\n"; 
     279                              break; 
     280                         case 'css': 
     281                              $ret .= sprintf('<link type="text/css" href="%s" rel="stylesheet" />',$s['body_webfont_url'])."\n"; 
     282                              break; 
     283                    } 
     284                    # Main font 
     285                    $selectors = 'body, .supranav li a span, #comments.me, a.comment-number'; 
     286                    self::prop($css,$selectors,'font-family',$s['body_webfont_family']); 
     287               } 
     288          } 
     289          if (!isset($s['alternate_font']) || ($s['alternate_font'] == '')) { 
     290               // See if webfont defined for secondary font 
     291               if (isset($s['alternate_webfont_api']) && isset($s['alternate_webfont_family']) && isset($s['alternate_webfont_url'])) { 
     292                    if (!in_array($s['alternate_webfont_url'], $uri)) { 
     293                         switch ($s['alternate_webfont_api']) { 
     294                              case 'js': 
     295                                   $ret .= sprintf('<script type="text/javascript" src="%s"></script>',$s['alternate_webfont_url'])."\n"; 
     296                                   break; 
     297                              case 'css': 
     298                                   $ret .= sprintf('<link type="text/css" href="%s" rel="stylesheet" />',$s['alternate_webfont_url'])."\n"; 
     299                                   break; 
     300                         } 
     301                    } 
     302                    # Secondary font 
     303                    $selectors = '#blogdesc, .supranav, #content-info, #subcategories, #comments-feed, #sidebar h2, #sidebar h3, #footer'; 
     304                    self::prop($css,$selectors,'font-family',$s['alternate_webfont_family']); 
     305               } 
     306          } 
     307          # Style directives 
     308          $res = ''; 
     309          foreach ($css as $selector => $values) { 
     310               $res .= $selector." {\n"; 
     311               foreach ($values as $k => $v) { 
     312                    $res .= $k.':'.$v.";\n"; 
     313               } 
     314               $res .= "}\n"; 
     315          } 
     316          if ($res != '') { 
     317               $ret .= '<style type="text/css">'."\n".$res.'</style>'."\n"; 
     318          } 
     319 
     320          return $ret; 
    252321     } 
    253322      
  • themes/ductile/locales/fr/admin.po

    r810 r1081  
    110110msgstr "Secondaire :" 
    111111 
     112msgid "none" 
     113msgstr "aucune" 
     114 
     115msgid "javascript (Adobe)" 
     116msgstr "javascript (Adobe)" 
     117 
     118msgid "stylesheet (Google)" 
     119msgstr "feuille de style (Google)" 
     120 
     121msgid "Set main font to default to use webfont below." 
     122msgstr "Mettre la police de caractère principale à Défaut pour utiliser la fonte web ci-dessous." 
     123 
     124msgid "Set secondary font to default to use webfont below." 
     125msgstr "Mettre la police de caractère secondaire à Défaut pour utiliser la fonte web ci-dessous." 
     126 
     127msgid "Webfont family:" 
     128msgstr "Famille" 
     129 
     130msgid "Webfont URL:" 
     131msgstr "URL de la fonte web" 
     132 
     133msgid "Webfont API:" 
     134msgstr "Type d'API" 
     135 
    112136msgid "Ductile primary" 
    113137msgstr "Principale de Ductile" 
Note: See TracChangeset for help on using the changeset viewer.

Sites map