Example #1
0
/**
 * フォント設定を読み込む
 *
 * @return void
 */
function p2_fontconfig_apply_custom()
{
    global $STYLE, $_conf, $skin_en, $skin_uniq;
    if ($_conf['expack.skin.enabled']) {
        if (isset($_conf['expack.am.fontfamily'])) {
            $_conf['expack.am.fontfamily.orig'] = $_conf['expack.am.fontfamily'];
        } else {
            $_conf['expack.am.fontfamily.orig'] = '';
        }
        if (file_exists($_conf['expack.skin.fontconfig_path'])) {
            $fontconfig_data = file_get_contents($_conf['expack.skin.fontconfig_path']);
            $current_fontconfig = unserialize($fontconfig_data);
        }
        if (!is_array($current_fontconfig)) {
            $current_fontconfig = array('enabled' => false, 'custom' => array());
        }
        $type = p2_fontconfig_detect_agent();
        if ($current_fontconfig['enabled'] && is_array($current_fontconfig['custom'][$type])) {
            $skin_uniq = P2_VERSION_ID . sprintf('.%u', crc32($fontconfig_data));
            foreach ($current_fontconfig['custom'][$type] as $key => $value) {
                if ($value === '') {
                    continue;
                } elseif ($key == 'fontfamily_aa') {
                    if ($value == '-') {
                        $_conf['expack.am.fontfamily'] = '';
                    } else {
                        $_conf['expack.am.fontfamily'] = p2_correct_css_fontfamily($value);
                    }
                } else {
                    $STYLE["{$key}.orig"] = isset($STYLE[$key]) ? $STYLE[$key] : '';
                    if (strpos($key, 'fontfamily') !== false) {
                        $STYLE[$key] = p2_correct_css_fontfamily($value);
                    } else {
                        $STYLE[$key] = $value;
                    }
                }
            }
            $skin_en = preg_replace('/&_=[^&]*/', '', $skin_en) . '&_=' . rawurlencode($skin_uniq);
        }
    }
}
Example #2
0
    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();
}
// }}}
// {{{ 携帯・iPhone用変数
// iPhone用HTMLヘッダ要素
if ($_conf['client_type'] == 'i') {
    switch ($_conf['b']) {
        // 強制PCビュー時
        case 'pc':
            $_conf['extra_headers_ht'] .= <<<EOS
<meta name="format-detection" content="telephone=no">
Example #3
0
    }
}
// 保存
$fontconfig_data = serialize($updated_fontconfig);
$fontconfig_new_hath = md5($fontconfig_data);
if (strcmp($fontconfig_hash, $fontconfig_new_hath) != 0) {
    FileCtl::file_write_contents($_conf['expack.skin.fontconfig_path'], $fontconfig_data);
}
// スタイルシートをリセット
unset($STYLE);
include $skin;
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("' . addslashes($V) . '")';
    }
}
if ($updated_fontconfig['enabled']) {
    p2_fontconfig_apply_custom();
} else {
    $skin_en = preg_replace('/&amp;_=[^&]*/', '', $skin_en) . '&amp;_=' . rawurlencode($skin_uniq);
}
$controllerObject->STYLE = $STYLE;
$controllerObject->skin = $skin_en;
$controllerObject->p2vid = P2_VERSION_ID;
// 出力
Example #4
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;
}
Example #5
0
/**
 * @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) . '")';
        }
    }
    //}
}