예제 #1
0
/**
 *スタイルシートの値を展開する
 *
 * @param   array   $style
 * @param   bool    $important
 */
function mystyle_extract($style, $important = false)
{
    $css = "\n";
    foreach ($style as $selector => $properties) {
        if (is_int($selector)) {
            $styles = is_array($properties) ? $properties : array($properties);
            foreach ($styles as $style) {
                $css .= $styles . "\n";
            }
        } elseif ($selector == '@import') {
            $urls = is_array($properties) ? $properties : array($properties);
            foreach ($urls as $url) {
                if (strpos($value, 'url(' === 0)) {
                    $css .= "@import {$url};\n";
                } else {
                    if (strpos($url, 'http://') === false && strpos($url, 'https://') === false && strpos($url, '?') === false) {
                        $url .= '?' . $GLOBALS['_conf']['p2_version_id'];
                    }
                    $css .= "@import url('" . p2_escape_css_url($url) . "');\n";
                }
            }
        } else {
            $suffix = $important ? " !important;\n" : ";\n";
            $selector = mystyle_selector($selector);
            $css .= $selector . " {\n";
            foreach ($properties as $property => $value) {
                if ($property == 'font-family') {
                    $value = '"' . p2_correct_css_fontfamily($value) . '"';
                } elseif ($property == 'background-image' && strpos($value, 'url(') !== 0) {
                    $value = "url('" . p2_escape_css_url($value) . "')";
                }
                $css .= $property . ': ' . $value . $suffix;
            }
            $css .= "}\n";
        }
    }
    return $css;
}
예제 #2
0
파일: bootstrap.php 프로젝트: unpush/p2-php
// スキンで上書き
if ($skin != P2_CONF_DIR . '/conf_user_style.inc.php') {
    include $skin;
}
// }}}
// {{{ デザイン設定の調整処理
$skin_uniq = P2_VERSION_ID;
foreach ($STYLE as $K => $V) {
    if ($V === null || $V === '') {
        // pass
    } elseif (strpos($K, 'fontfamily') !== false) {
        $STYLE[$K] = p2_correct_css_fontfamily($V);
    } elseif (strpos($K, 'color') !== false) {
        $STYLE[$K] = p2_correct_css_color($V);
    } elseif (strpos($K, 'background') !== false) {
        $STYLE[$K] = "url('" . p2_escape_css_url($V) . "')";
    }
}
if (!$_conf['ktai']) {
    if (!function_exists('p2_fontconfig_apply_custom')) {
        include P2_LIB_DIR . '/fontconfig.inc.php';
    }
    if ($_conf['expack.am.enabled']) {
        $_conf['expack.am.fontfamily'] = p2_correct_css_fontfamily($_conf['expack.am.fontfamily']);
        if ($STYLE['fontfamily']) {
            $_conf['expack.am.fontfamily'] .= '","' . $STYLE['fontfamily'];
        }
    }
    p2_fontconfig_apply_custom();
}
// }}}
예제 #3
0
파일: conf.inc.php 프로젝트: poppen/p2
/**
 * @return  void
 */
function _setStyle()
{
    global $_conf, $STYLE, $MYSTYLE;
    // デフォルトCSS設定($STYLE, $MYSTYLE)を読み込む
    include_once $_conf['conf_user_style_inc_php'];
    if ($_conf['skin'] = P2Util::getSkinSetting()) {
        // スキンで$STYLEを上書き
        $skinfile = P2Util::getSkinFilePathBySkinName($_conf['skin']);
        if (file_exists($skinfile)) {
            include_once $skinfile;
        }
    }
    // $STYLE設定の調整処理
    //if ($_SERVER['SCRIPT_NAME'] == 'css.php') {
    foreach ($STYLE as $k => $v) {
        if (empty($v)) {
            $STYLE[$k] = '';
        } elseif (strpos($k, 'fontfamily') !== false) {
            $STYLE[$k] = p2_correct_css_fontfamily($v);
        } elseif (strpos($k, 'color') !== false) {
            $STYLE[$k] = p2_correct_css_color($v);
        } elseif (strpos($k, 'background') !== false) {
            $STYLE[$k] = 'url("' . p2_escape_css_url($v) . '")';
        }
    }
    //}
}