Dotclear


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • themes/ductile/_public.php

    r1045 r1096  
    2323$core->tpl->addValue('ductileNbEntryPerPage',array('tplDuctileTheme','ductileNbEntryPerPage')); 
    2424$core->tpl->addValue('ductileLogoSrc',array('tplDuctileTheme','ductileLogoSrc')); 
     25$core->tpl->addBlock('IfPreviewIsNotMandatory',array('tplDuctileTheme','IfPreviewIsNotMandatory')); 
    2526 
    2627class tplDuctileTheme 
     
    175176           
    176177          return $img_url; 
     178     } 
     179 
     180     public static function IfPreviewIsNotMandatory($attr,$content) 
     181     { 
     182          $s = $GLOBALS['core']->blog->settings->themes->get($GLOBALS['core']->blog->settings->system->theme.'_style'); 
     183          if ($s !== null) { 
     184               $s = @unserialize($s); 
     185               if (is_array($s)) { 
     186                    if (isset($s['preview_not_mandatory'])) { 
     187                         if ($s['preview_not_mandatory']) { 
     188                              return $content; 
     189                         } 
     190                    } 
     191               } 
     192          } 
     193          return ''; 
    177194     } 
    178195 
     
    250267               $core->blog->settings->system->themes_url.'/'.$core->blog->settings->system->theme. 
    251268               '/ductile.js"></script>'."\n"; 
     269 
     270          echo self::ductileWebfontHelper(); 
     271     } 
     272 
     273     public static function ductileWebfontHelper() 
     274     { 
     275          $s = $GLOBALS['core']->blog->settings->themes->get($GLOBALS['core']->blog->settings->system->theme.'_style'); 
     276 
     277          if ($s === null) { 
     278               return; 
     279          } 
     280 
     281          $s = @unserialize($s); 
     282          if (!is_array($s)) { 
     283               return; 
     284          } 
     285 
     286          $ret = ''; 
     287          $css = array(); 
     288          $uri = array(); 
     289          if (!isset($s['body_font']) || ($s['body_font'] == '')) { 
     290               // See if webfont defined for main font 
     291               if (isset($s['body_webfont_api']) && isset($s['body_webfont_family']) && isset($s['body_webfont_url'])) { 
     292                    $uri[] = $s['body_webfont_url']; 
     293                    switch ($s['body_webfont_api']) { 
     294                         case 'js': 
     295                              $ret .= sprintf('<script type="text/javascript" src="%s"></script>',$s['body_webfont_url'])."\n"; 
     296                              break; 
     297                         case 'css': 
     298                              $ret .= sprintf('<link type="text/css" href="%s" rel="stylesheet" />',$s['body_webfont_url'])."\n"; 
     299                              break; 
     300                    } 
     301                    # Main font 
     302                    $selectors = 'body, .supranav li a span, #comments.me, a.comment-number'; 
     303                    self::prop($css,$selectors,'font-family',$s['body_webfont_family']); 
     304               } 
     305          } 
     306          if (!isset($s['alternate_font']) || ($s['alternate_font'] == '')) { 
     307               // See if webfont defined for secondary font 
     308               if (isset($s['alternate_webfont_api']) && isset($s['alternate_webfont_family']) && isset($s['alternate_webfont_url'])) { 
     309                    if (!in_array($s['alternate_webfont_url'], $uri)) { 
     310                         switch ($s['alternate_webfont_api']) { 
     311                              case 'js': 
     312                                   $ret .= sprintf('<script type="text/javascript" src="%s"></script>',$s['alternate_webfont_url'])."\n"; 
     313                                   break; 
     314                              case 'css': 
     315                                   $ret .= sprintf('<link type="text/css" href="%s" rel="stylesheet" />',$s['alternate_webfont_url'])."\n"; 
     316                                   break; 
     317                         } 
     318                    } 
     319                    # Secondary font 
     320                    $selectors = '#blogdesc, .supranav, #content-info, #subcategories, #comments-feed, #sidebar h2, #sidebar h3, #footer'; 
     321                    self::prop($css,$selectors,'font-family',$s['alternate_webfont_family']); 
     322               } 
     323          } 
     324          # Style directives 
     325          $res = ''; 
     326          foreach ($css as $selector => $values) { 
     327               $res .= $selector." {\n"; 
     328               foreach ($values as $k => $v) { 
     329                    $res .= $k.':'.$v.";\n"; 
     330               } 
     331               $res .= "}\n"; 
     332          } 
     333          if ($res != '') { 
     334               $ret .= '<style type="text/css">'."\n".$res.'</style>'."\n"; 
     335          } 
     336 
     337          return $ret; 
    252338     } 
    253339      
Note: See TracChangeset for help on using the changeset viewer.

Sites map