コード例 #1
0
function pl_base_color($mode = '', $difference = '10%')
{
    $base_color = PageLinesThemeSupport::BaseColor();
    if (!$base_color) {
        if (pl_check_color_hash(ploption('contentbg'))) {
            $base = pl_hash_strip(ploption('contentbg'));
        } elseif (pl_check_color_hash(ploption('pagebg'))) {
            $base = pl_hash_strip(ploption('pagebg'));
        } elseif (pl_check_color_hash(ploption('bodybg'))) {
            $base = pl_hash_strip(ploption('bodybg'));
        } else {
            $base = 'FFFFFF';
        }
    } else {
        $base = $base_color;
    }
    if ($mode != '') {
        $adjust_base = new PageLinesColor($base);
        $adjusted = $adjust_base->c($mode, $difference);
        return $adjusted;
    } else {
        return $base;
    }
}
コード例 #2
0
/**
 * Do Color Math
 *
 * @param   $oid
 * @param   $o
 * @param   $val
 * @param   string $format
 *
 * @uses    base_hsl
 * @uses    get_color
 * @uses    get_hsl
 * @uses    load_the_props
 * @uses    set_factory_key
 * @uses    store_set_color
 *
 * @internal uses class PageLinesCSS
 * @internal uses filter 'pl_math_array'
 *
 * @return  string
 * @todo confirm if removing the return after "if( ploption('disable_text_shadow') )" is correct
 */
function do_color_math($oid, $o, $val, $format = 'css')
{
    $default = isset($o['default']) ? $o['default'] : $val;
    $output = '';
    $id = isset($o['id']) ? $o['id'] : null;
    $math_array = isset($o['math']) ? $o['math'] : array();
    $math_array = apply_filters('pl_math_array', $math_array, $oid, $o);
    if (!empty($math_array)) {
        // Set the base.
        // If no option value, use the depends cascade
        foreach ($o['math'] as $key => $k) {
            if (!$val) {
                if (isset($k['depends'])) {
                    foreach ($k['depends'] as $d) {
                        if (isset($d) && !empty($d)) {
                            $base = $d;
                            break;
                        }
                    }
                }
            } else {
                $base = str_replace('#', '', $val);
            }
        }
        // Set the base color
        $base = isset($base) ? $base : $default;
        if (isset($id)) {
            store_set_color($id, $base);
        }
        // Set up the base color for editing
        $math = new PageLinesColor($base, $id);
        // Process math array
        foreach ($o['math'] as $key => $k) {
            $id = isset($k['id']) ? $k['id'] : '';
            $difference = isset($k['diff']) ? $k['diff'] : '10%';
            if ($k['mode'] == 'mix' || $k['mode'] == 'shadow') {
                if (isset($k['mixwith']) && is_array($k['mixwith'])) {
                    foreach ($k['mixwith'] as $mkey => $m) {
                        if (isset($m) && !empty($m)) {
                            $mix_color = $m;
                            break;
                        } else {
                            $mix_color = $base;
                        }
                    }
                } elseif (isset($k['mixwith'])) {
                    $mix_color = $k['mixwith'];
                }
                if ($k['mode'] == 'shadow') {
                    //if( ploption('disable_text_shadow') )
                    /** commented out return as part of if statement */
                    // return;
                    $difference = $math->get_hsl($mix_color, 'lightness') - $math->base_hsl['lightness'];
                    $difference = $difference > 0 ? 0.1 : -0.2;
                    $k['css_prop'] = $difference < 0 ? array('text-shadow-top') : array('text-shadow');
                }
                $color = $math->get_color($k['mode'], $difference, $mix_color, $id);
            } else {
                $color = $math->get_color($k['mode'], $difference, null, $id);
            }
            $css = new PageLinesCSS();
            if (isset($o['selectors']) && $o['selectors'] != '') {
                $output .= $css->load_the_props($k['css_prop'], '#' . $color);
            } else {
                // If using cssgroups
                $cssgroup = $k['cssgroup'];
                if (is_array($cssgroup)) {
                    foreach ($cssgroup as $cgroup) {
                        $css->set_factory_key($cgroup, $css->load_the_props($k['css_prop'], '#' . $color));
                    }
                } else {
                    $css->set_factory_key($cssgroup, $css->load_the_props($k['css_prop'], '#' . $color));
                }
            }
            // Recursion
            if (isset($k['math'])) {
                do_color_math($key, $k, $color, $format);
            }
        }
    }
    return $output;
}