/** * 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; }
/** * * @TODO document * */ function _get_color_picker($oid, $o, $per_row = 3, $last = false) { // Color Picker Template $the_id = $o['input_id']; $gen = do_color_math($the_id, $o, $o['val'], 'palette'); $picker = sprintf('<div id="%s" class="colorSelector"><div></div></div> %s', $the_id . '_picker', $this->input_text($the_id, $o['input_name'], $o['val'], 'colorpickerclass')); $pick_contain = sprintf('<div class="pick_contain">%s</div>', $picker); printf('<div class="the_picker picker_row_%s %s"><div class="picker_panel"><div class="the_picker_pad">%s %s</div></div></div>', $per_row, $last ? 'p_end' : '', $this->input_label($the_id, $o['inputlabel']), $pick_contain); printf('<script type="text/javascript">setColorPicker("%s", "%s");</script>', $the_id, $o['val']); }
/** * * @TODO document * */ function render_css_colors($oid, $o, $cssgroup = null, $css_prop = null) { $v = $o['val']; if (!$v && isset($o['flag'])) { $v = $o['flag'] == 'blank_default' ? false : ($o['default'] = false); } do_color_math($oid, $o, $v, 'css'); if ($v && isset($css_prop)) { $this->set_factory_key($cssgroup, $this->load_the_props($css_prop, $v)); } elseif ($v) { $this->set_factory_key($cssgroup, $this->get_the_rule('color', $v)); } }