Пример #1
0
 public static function ductileStyleHelper()
 {
     $s = $GLOBALS['core']->blog->settings->themes->get($GLOBALS['core']->blog->settings->system->theme . '_style');
     if ($s === null) {
         return;
     }
     $s = @unserialize($s);
     if (!is_array($s)) {
         return;
     }
     $css = array();
     # Properties
     # Blog description
     $selectors = '#blogdesc';
     if (isset($s['subtitle_hidden'])) {
         dcThemeConfig::prop($css, $selectors, 'display', $s['subtitle_hidden'] ? 'none' : null);
     }
     # Main font
     $selectors = 'body, .supranav li a span, #comments.me, a.comment-number';
     if (isset($s['body_font'])) {
         dcThemeConfig::prop($css, $selectors, 'font-family', self::fontDef($s['body_font']));
     }
     # Secondary font
     $selectors = '#blogdesc, .supranav, #content-info, #subcategories, #comments-feed, #sidebar h2, #sidebar h3, #footer';
     if (isset($s['alternate_font'])) {
         dcThemeConfig::prop($css, $selectors, 'font-family', self::fontDef($s['alternate_font']));
     }
     # Inside posts links font weight
     $selectors = '.post-excerpt a, .post-content a';
     if (isset($s['post_link_w'])) {
         dcThemeConfig::prop($css, $selectors, 'font-weight', $s['post_link_w'] ? 'bold' : 'normal');
     }
     # Inside posts links colors (normal, visited)
     $selectors = '.post-excerpt a:link, .post-excerpt a:visited, .post-content a:link, .post-content a:visited';
     if (isset($s['post_link_v_c'])) {
         dcThemeConfig::prop($css, $selectors, 'color', $s['post_link_v_c']);
     }
     # Inside posts links colors (hover, active, focus)
     $selectors = '.post-excerpt a:hover, .post-excerpt a:active, .post-excerpt a:focus, .post-content a:hover, .post-content a:active, .post-content a:focus';
     if (isset($s['post_link_f_c'])) {
         dcThemeConfig::prop($css, $selectors, 'color', $s['post_link_f_c']);
     }
     # Style directives
     $res = '';
     foreach ($css as $selector => $values) {
         $res .= $selector . " {\n";
         foreach ($values as $k => $v) {
             $res .= $k . ':' . $v . ";\n";
         }
         $res .= "}\n";
     }
     # Large screens
     $css_large = array();
     # Blog title font weight
     $selectors = 'h1, h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
     if (isset($s['blog_title_w'])) {
         dcThemeConfig::prop($css_large, $selectors, 'font-weight', $s['blog_title_w'] ? 'bold' : 'normal');
     }
     # Blog title font size
     $selectors = 'h1';
     if (isset($s['blog_title_s'])) {
         dcThemeConfig::prop($css_large, $selectors, 'font-size', $s['blog_title_s']);
     }
     # Blog title color
     $selectors = 'h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
     if (isset($s['blog_title_c'])) {
         dcThemeConfig::prop($css_large, $selectors, 'color', $s['blog_title_c']);
     }
     # Post title font weight
     $selectors = 'h2.post-title, h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
     if (isset($s['post_title_w'])) {
         dcThemeConfig::prop($css_large, $selectors, 'font-weight', $s['post_title_w'] ? 'bold' : 'normal');
     }
     # Post title font size
     $selectors = 'h2.post-title';
     if (isset($s['post_title_s'])) {
         dcThemeConfig::prop($css_large, $selectors, 'font-size', $s['post_title_s']);
     }
     # Post title color
     $selectors = 'h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
     if (isset($s['post_title_c'])) {
         dcThemeConfig::prop($css_large, $selectors, 'color', $s['post_title_c']);
     }
     # Simple title color (title without link)
     $selectors = '#content-info h2, .post-title, .post h3, .post h4, .post h5, .post h6, .arch-block h3';
     if (isset($s['post_simple_title_c'])) {
         dcThemeConfig::prop($css_large, $selectors, 'color', $s['post_simple_title_c']);
     }
     # Style directives for large screens
     if (count($css_large)) {
         $res .= '@media only screen and (min-width: 481px) {' . "\n";
         foreach ($css_large as $selector => $values) {
             $res .= $selector . " {\n";
             foreach ($values as $k => $v) {
                 $res .= $k . ':' . $v . ";\n";
             }
             $res .= "}\n";
         }
         $res .= "}\n";
     }
     # Small screens
     $css_small = array();
     # Blog title font weight
     $selectors = 'h1, h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
     if (isset($s['blog_title_w_m'])) {
         dcThemeConfig::prop($css_small, $selectors, 'font-weight', $s['blog_title_w_m'] ? 'bold' : 'normal');
     }
     # Blog title font size
     $selectors = 'h1';
     if (isset($s['blog_title_s_m'])) {
         dcThemeConfig::prop($css_small, $selectors, 'font-size', $s['blog_title_s_m']);
     }
     # Blog title color
     $selectors = 'h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
     if (isset($s['blog_title_c_m'])) {
         dcThemeConfig::prop($css_small, $selectors, 'color', $s['blog_title_c_m']);
     }
     # Post title font weight
     $selectors = 'h2.post-title, h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
     if (isset($s['post_title_w_m'])) {
         dcThemeConfig::prop($css_small, $selectors, 'font-weight', $s['post_title_w_m'] ? 'bold' : 'normal');
     }
     # Post title font size
     $selectors = 'h2.post-title';
     if (isset($s['post_title_s_m'])) {
         dcThemeConfig::prop($css_small, $selectors, 'font-size', $s['post_title_s_m']);
     }
     # Post title color
     $selectors = 'h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
     if (isset($s['post_title_c_m'])) {
         dcThemeConfig::prop($css_small, $selectors, 'color', $s['post_title_c_m']);
     }
     # Style directives for small screens
     if (count($css_small)) {
         $res .= '@media only screen and (max-width: 480px) {' . "\n";
         foreach ($css_small as $selector => $values) {
             $res .= $selector . " {\n";
             foreach ($values as $k => $v) {
                 $res .= $k . ':' . $v . ";\n";
             }
             $res .= "}\n";
         }
         $res .= "}\n";
     }
     return $res;
 }
Пример #2
0
 public static function createCss($s)
 {
     global $core;
     if ($s === null) {
         return;
     }
     $css = array();
     /* Sidebar position
     		---------------------------------------------- */
     if ($s['sidebar_position'] == 'left') {
         $css['#wrapper']['background-position'] = '-300px 0';
         $css['#main']['float'] = 'right';
         $css['#sidebar']['float'] = 'left';
     }
     /* Properties
     		---------------------------------------------- */
     dcThemeConfig::prop($css, 'body', 'background-color', $s['body_bg_c']);
     dcThemeConfig::prop($css, 'body', 'color', $s['body_txt_c']);
     dcThemeConfig::prop($css, '.post-tags li a:link, .post-tags li a:visited, .post-info-co a:link, .post-info-co a:visited', 'color', $s['body_txt_c']);
     dcThemeConfig::prop($css, '#page', 'font-size', $s['body_txt_s']);
     dcThemeConfig::prop($css, 'body', 'font-family', self::fontDef($s['body_txt_f']));
     dcThemeConfig::prop($css, '.post-content, .post-excerpt, #comments dd, #pings dd, dd.comment-preview', 'line-height', $s['body_line_height']);
     if (!$s['blog_title_hide']) {
         dcThemeConfig::prop($css, '#top h1 a', 'color', $s['blog_title_c']);
         dcThemeConfig::prop($css, '#top h1', 'font-size', $s['blog_title_s']);
         dcThemeConfig::prop($css, '#top h1', 'font-family', self::fontDef($s['blog_title_f']));
         if ($s['blog_title_a'] == 'right' || $s['blog_title_a'] == 'left') {
             $css['#top h1'][$s['blog_title_a']] = '0px';
             $css['#top h1']['width'] = 'auto';
         }
         if ($s['blog_title_p']) {
             $_p = explode(':', $s['blog_title_p']);
             $css['#top h1']['top'] = $_p[1] . 'px';
             if ($s['blog_title_a'] != 'center') {
                 $_a = $s['blog_title_a'] == 'right' ? 'right' : 'left';
                 $css['#top h1'][$_a] = $_p[0] . 'px';
             }
         }
     } else {
         dcThemeConfig::prop($css, '#top h1 span', 'text-indent', '-5000px');
         dcThemeConfig::prop($css, '#top h1', 'top', '0px');
         $css['#top h1 a'] = array('display' => 'block', 'height' => $s['top_height'] ? $s['top_height'] - 10 . 'px' : '120px', 'width' => '800px');
     }
     dcThemeConfig::prop($css, '#top', 'height', $s['top_height']);
     dcThemeConfig::prop($css, '.day-date', 'color', $s['date_title_c']);
     dcThemeConfig::prop($css, '.day-date', 'font-family', self::fontDef($s['date_title_f']));
     dcThemeConfig::prop($css, '.day-date', 'font-size', $s['date_title_s']);
     dcThemeConfig::prop($css, 'a', 'color', $s['body_link_c']);
     dcThemeConfig::prop($css, 'a:visited', 'color', $s['body_link_v_c']);
     dcThemeConfig::prop($css, 'a:hover, a:focus, a:active', 'color', $s['body_link_f_c']);
     dcThemeConfig::prop($css, '#comment-form input, #comment-form textarea', 'color', $s['body_link_c']);
     dcThemeConfig::prop($css, '#comment-form input.preview', 'color', $s['body_link_c']);
     dcThemeConfig::prop($css, '#comment-form input.preview:hover', 'background', $s['body_link_f_c']);
     dcThemeConfig::prop($css, '#comment-form input.preview:hover', 'border-color', $s['body_link_f_c']);
     dcThemeConfig::prop($css, '#comment-form input.submit', 'color', $s['body_link_c']);
     dcThemeConfig::prop($css, '#comment-form input.submit:hover', 'background', $s['body_link_f_c']);
     dcThemeConfig::prop($css, '#comment-form input.submit:hover', 'border-color', $s['body_link_f_c']);
     dcThemeConfig::prop($css, '#sidebar', 'font-family', self::fontDef($s['sidebar_text_f']));
     dcThemeConfig::prop($css, '#sidebar', 'font-size', $s['sidebar_text_s']);
     dcThemeConfig::prop($css, '#sidebar', 'color', $s['sidebar_text_c']);
     dcThemeConfig::prop($css, '#sidebar h2', 'font-family', self::fontDef($s['sidebar_title_f']));
     dcThemeConfig::prop($css, '#sidebar h2', 'font-size', $s['sidebar_title_s']);
     dcThemeConfig::prop($css, '#sidebar h2', 'color', $s['sidebar_title_c']);
     dcThemeConfig::prop($css, '#sidebar h3', 'font-family', self::fontDef($s['sidebar_title2_f']));
     dcThemeConfig::prop($css, '#sidebar h3', 'font-size', $s['sidebar_title2_s']);
     dcThemeConfig::prop($css, '#sidebar h3', 'color', $s['sidebar_title2_c']);
     dcThemeConfig::prop($css, '#sidebar ul', 'border-top-color', $s['sidebar_line_c']);
     dcThemeConfig::prop($css, '#sidebar li', 'border-bottom-color', $s['sidebar_line_c']);
     dcThemeConfig::prop($css, '#topnav ul', 'border-bottom-color', $s['sidebar_line_c']);
     dcThemeConfig::prop($css, '#sidebar li a', 'color', $s['sidebar_link_c']);
     dcThemeConfig::prop($css, '#sidebar li a:visited', 'color', $s['sidebar_link_v_c']);
     dcThemeConfig::prop($css, '#sidebar li a:hover, #sidebar li a:focus, #sidebar li a:active', 'color', $s['sidebar_link_f_c']);
     dcThemeConfig::prop($css, '#search input', 'color', $s['sidebar_link_c']);
     dcThemeConfig::prop($css, '#search .submit', 'color', $s['sidebar_link_c']);
     dcThemeConfig::prop($css, '#search .submit:hover', 'background', $s['sidebar_link_f_c']);
     dcThemeConfig::prop($css, '#search .submit:hover', 'border-color', $s['sidebar_link_f_c']);
     dcThemeConfig::prop($css, '.post-title', 'color', $s['post_title_c']);
     dcThemeConfig::prop($css, '.post-title a, .post-title a:visited', 'color', $s['post_title_c']);
     dcThemeConfig::prop($css, '.post-title', 'font-family', self::fontDef($s['post_title_f']));
     dcThemeConfig::prop($css, '.post-title', 'font-size', $s['post_title_s']);
     dcThemeConfig::prop($css, '#comments dd', 'background-color', $s['post_comment_bg_c']);
     dcThemeConfig::prop($css, '#comments dd', 'color', $s['post_comment_c']);
     dcThemeConfig::prop($css, '#comments dd.me', 'background-color', $s['post_commentmy_bg_c']);
     dcThemeConfig::prop($css, '#comments dd.me', 'color', $s['post_commentmy_c']);
     dcThemeConfig::prop($css, '#prelude, #prelude a', 'color', $s['prelude_c']);
     dcThemeConfig::prop($css, '#footer p', 'background-color', $s['footer_bg_c']);
     dcThemeConfig::prop($css, '#footer p', 'color', $s['footer_c']);
     dcThemeConfig::prop($css, '#footer p', 'font-size', $s['footer_s']);
     dcThemeConfig::prop($css, '#footer p', 'font-family', self::fontDef($s['footer_f']));
     dcThemeConfig::prop($css, '#footer p a', 'color', $s['footer_l_c']);
     /* Images
     		------------------------------------------------------ */
     self::backgroundImg($css, 'body', $s['body_bg_c'], 'body-bg.png');
     self::backgroundImg($css, 'body', $s['body_bg_g'] != 'light', 'body-bg.png');
     self::backgroundImg($css, 'body', $s['prelude_c'], 'body-bg.png');
     self::backgroundImg($css, '#top', $s['body_bg_c'], 'page-t.png');
     self::backgroundImg($css, '#top', $s['body_bg_g'] != 'light', 'page-t.png');
     self::backgroundImg($css, '#top', $s['uploaded'] || $s['top_image'], 'page-t.png');
     self::backgroundImg($css, '#footer', $s['body_bg_c'], 'page-b.png');
     self::backgroundImg($css, '#comments dt', $s['post_comment_bg_c'], 'comment-t.png');
     self::backgroundImg($css, '#comments dd', $s['post_comment_bg_c'], 'comment-b.png');
     self::backgroundImg($css, '#comments dt.me', $s['post_commentmy_bg_c'], 'commentmy-t.png');
     self::backgroundImg($css, '#comments dd.me', $s['post_commentmy_bg_c'], 'commentmy-b.png');
     $res = '';
     foreach ($css as $selector => $values) {
         $res .= $selector . " {\n";
         foreach ($values as $k => $v) {
             $res .= $k . ':' . $v . ";\n";
         }
         $res .= "}\n";
     }
     $res .= $s['extra_css'];
     if (!self::canWriteCss(true)) {
         throw new Exception(__('Unable to create css file.'));
     }
     # erase old css file
     self::dropCss($core->blog->settings->system->theme);
     # create new css file into public blowup-css subdirectory
     self::writeCss($core->blog->settings->system->theme, $res);
     return $res;
 }