Пример #1
0
 function query_parsed_init()
 {
     global $gantry;
     $browser = $gantry->browser;
     // Colors
     $linkColor = new Color($gantry->get('linkcolor'));
     $css = 'a, ul.menu li .separator {color:' . $gantry->get('linkcolor') . ';}';
     $css .= '.button, .readon, .readmore, button.validate, #member-profile a, #member-registration a, .formelm-buttons button, .btn-primary {border-color:' . $linkColor->darken('20%') . ';}';
     // Gradients
     $css .= '.button, .readon, .readmore, button.validate, #member-profile a, #member-registration a, .formelm-buttons button, .btn-primary {background-color: ' . $linkColor->lighten('4%') . '; ' . $this->_createGradient('top', $linkColor->lighten('4%'), '1', '0%', $linkColor->darken('9%'), '1', '100%') . '}' . "\n";
     $css .= '.button:hover, .readon:hover, .readmore:hover, button.validate:hover, #member-profile a:hover, #member-registration a:hover, .formelm-buttons button:hover, .btn-primary:hover {background-color: ' . $linkColor->lighten('10%') . '; ' . $this->_createGradient('top', $linkColor->lighten('10%'), '1', '0%', $linkColor->darken('3%'), '1', '100%') . '}' . "\n";
     $css .= '.button:active, .readon:active, .readmore:active, button.validate:active, #member-profile a:active, #member-registration a:active, .formelm-buttons button:active, .btn-primary:active {background-color: ' . $linkColor->darken('2%') . '; ' . $this->_createGradient('top', $linkColor->darken('2%'), '1', '0%', $linkColor->lighten('8%'), '1', '100%') . '}' . "\n";
     // Logo
     $css .= $this->buildLogo();
     $this->_disableRokBoxForiPhone();
     $gantry->addInlineStyle($css);
     if ($gantry->get('layout-mode') == "responsive") {
         $gantry->addLess('mediaqueries.less', 'mediaqueries.css', 9);
     }
     if ($gantry->get('layout-mode') == "960fixed") {
         $gantry->addLess('960fixed.less');
     }
     if ($gantry->get('layout-mode') == "1200fixed") {
         $gantry->addLess('1200fixed.less');
     }
     // add inline css from the Custom CSS field
     $gantry->addInlineStyle($gantry->get('customcss'));
 }
Пример #2
0
 protected function get_button_style()
 {
     if ('custom' != $this->atts['color_mode'] || !$this->atts['color']) {
         return '';
     }
     if (in_array($this->atts['style'], array('light', 'link'))) {
         $style = ' style="color: ' . $this->atts['color'] . ';"';
     } else {
         if ('3d' == $this->config->get('buttons.style')) {
             if (false !== strpos($this->atts['color'], 'rgb')) {
                 $color = new Color(Color::rgbToHex($this->atts['color']));
             } else {
                 $color = new Color($this->atts['color']);
             }
             $style = ' style="background: ' . $this->atts['color'] . '; border-bottom-color: #' . $color->darken(18) . ';"';
         } else {
             $style = ' style="background: ' . $this->atts['color'] . ';"';
         }
     }
     return $style;
 }
 /**
  * Set the (inline) css for the widget rendering.
  *
  * @param    array  $instance   An array containing settings for the widget.
  * @param    string  $uid   Identifiant of the widget.
  * @param    boolean  $flat_design   Enabling flat design mode.
  * @since    2.0.0
  */
 public function css($instance, $uid, $flat_design)
 {
     require_once LWS_INCLUDES_DIR . 'phpcolors/Color.php';
     try {
         $maxwidth = round($instance['width']);
     } catch (Exception $ex) {
         $maxwidth = 0;
     }
     $txt_color = $instance['txt_color'];
     $color = new Color($instance['bg_color']);
     $opacity = (11 - $instance['bg_opacity']) / 11;
     if ($opacity < 0.1) {
         $opacity = 0;
     }
     if ($color->isDark()) {
         $gradient = $color->makeGradient(20);
     } else {
         $gradient = $color->makeGradient(15);
     }
     $border = new Color($gradient['light']);
     $icon = new Color($txt_color);
     if ($border->isDark()) {
         $ico_color = '#' . $icon->darken(1);
         $unit_color = '#' . $icon->lighten(1);
     } else {
         $ico_color = '#' . $icon->lighten(1);
         $unit_color = '#' . $icon->darken(1);
     }
     if ($color->isDark()) {
         if ($icon->isDark()) {
             $bcc = $icon->darken(4);
         } else {
             $bcc = $icon->darken(30);
         }
     } else {
         if ($icon->isDark()) {
             $bcc = $icon->lighten(4);
         } else {
             $bcc = $icon->lighten(20);
         }
     }
     if ($flat_design) {
         $gradient_dark = Color::hexToRgbString($instance['bg_color'], $opacity);
         $gradient_light = Color::hexToRgbString($instance['bg_color'], $opacity);
         $border_color1 = '#' . $bcc;
         $border_color2 = '#' . $bcc;
     } else {
         $gradient_dark = Color::hexToRgbString('#' . $gradient['dark'], $opacity);
         $gradient_light = Color::hexToRgbString('#' . $gradient['light'], $opacity);
         $border_color1 = '#' . $border->darken();
         $border_color2 = '#' . $border->darken(16);
     }
     $id = $uid;
     $shadows = !$flat_design;
     $borders = $instance['show_borders'];
     include LWS_PUBLIC_DIR . 'partials/live-weather-station-widget-ephemeris-display-css.php';
 }
Пример #4
0
        //$menu_background_hover_color = "#628394";
    }
}
if (!$nav_icon_hover_color) {
    $nihc = new Color($nav_bg);
    if ($nihc->isLight()) {
        $nav_icon_hover_color = '#' . $nihc->darken(10);
    } else {
        $nav_icon_hover_color = '#' . $nihc->lighten(10);
    }
}
if (!$link_hover_color) {
    $lhc = new Color($link_color);
    $lcolor = $lhc->getHex();
    if ($lhc->isLight($lcolor, 75)) {
        $link_hover_color = '#' . $lhc->darken(5);
    } else {
        $link_hover_color = '#' . $lhc->lighten(5);
    }
}
// Convert $bg_image_options into css
switch ($bg_image_option) {
    case "stretch":
        $background_size_img = "100%";
        break;
    case "cover":
        $background_size_img = "cover";
        break;
    case "repeat":
        $background_size_img = "auto";
        break;
Пример #5
0
function bsh_shortcode_style($property, $value, $type = 'default')
{
    global $shortcode_style;
    if (!empty($value)) {
        if ($type === 'color' or $type === 'gradient' or $type === 'border-darken') {
            $value = bsh_determine_color($value);
        }
        if ($type === 'text-shadow') {
            if ($value == 'primary') {
                $shortcode_style .= 'text-shadow: -1px -1px 0 rgba(0,0,0,0.1);';
            } else {
                $color = new Color($value);
                $shortcode_style .= 'text-shadow: -1px -1px 0 #' . $color->darken(10) . ';';
            }
        }
        if ($type === 'gradient') {
            $color = new Color($value);
            $gradient = $color->makeGradient(10);
            $shortcode_style .= "\n\t\t\t\tbackground: #" . $gradient['light'] . ";\n\t\t\t\tbackground: -moz-linear-gradient(top,  #" . $gradient['light'] . " 0%, #" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#" . $gradient['light'] . "), color-stop(100%,#" . $gradient['dark'] . "));\n\t\t\t\tbackground: -webkit-linear-gradient(top,  #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: -o-linear-gradient(top,  #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: -ms-linear-gradient(top,  #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tbackground: linear-gradient(to bottom,  #" . $gradient['light'] . " 0%,#" . $gradient['dark'] . " 100%);\n\t\t\t\tfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='" . $gradient['light'] . "', endColorstr='" . $gradient['dark'] . "',GradientType=0 );\n\t\t\t";
        } elseif ($type === 'border-darken') {
            $color = new Color($value);
            $shortcode_style .= $property . ': #' . $color->darken(10) . ';';
        } elseif ($type === 'radius') {
            $shortcode_style .= '
				-moz-border-radius: ' . $value . ';
				-khtml-border-radius: ' . $value . ';
				-ie-border-radius: ' . $value . ';
				-o-border-radius: ' . $value . ';
				border-radius: ' . $value . ';
			';
        } else {
            $css = $property . ': ' . $value;
            $shortcode_style .= $css . ';';
        }
    }
}
Пример #6
0
 public function testShouldDarnenColor()
 {
     $color = new Color('fff');
     $this->assertEquals(new Color('ddd'), $color->darken(34));
     $this->assertEquals(new Color('000'), $color->darken(300));
 }
Пример #7
0
 public function prepareList()
 {
     $result = ['series_names' => [], 'series_data' => []];
     date_default_timezone_set('UTC');
     $start_datetime = strtotime($this->date_from . ' ' . $this->time_from);
     $end_datetime = strtotime($this->date_to . ' ' . $this->time_to);
     $series_names = array();
     $series_data = array();
     if (!$this->hasErrors() && $this->station_id) {
         $stationResult = Station::model()->getStationsWithSensorsFeatures($this->station_id);
         foreach ($this->sensor_feature_code as $group_code => $group) {
             if (!empty($group)) {
                 $i = 0;
                 foreach ($stationResult as $station) {
                     $colorWalker = new Color($station->color);
                     foreach ($group as $sensor_feature_code) {
                         //sensors data
                         foreach ($station->sensors as $sensor) {
                             foreach ($sensor->features as $sensorFeature) {
                                 if ($sensor_feature_code == $sensorFeature->feature_code) {
                                     $series_names[$i]['name'] = $station->station_id_code . ', ' . $sensor->sensor_id_code . ' ' . $this->getGroupSensorsFeaturesList()[$sensor->handler->handler_id_code]['sensor_features'][$sensorFeature->feature_code];
                                     $series_names[$i]['params']['color'] = '#' . $colorWalker->getHex();
                                     //                                        $colorWalker->mix('888888');
                                     $colorWalker->darken();
                                     $qb = new CDbCriteria();
                                     $qb->select = 't.sensor_feature_normalized_value, t.sensor_feature_value, t.measuring_timestamp';
                                     $qb->addCondition('t.sensor_feature_id = :sensor_feature_id');
                                     $qb->addBetweenCondition('t.measuring_timestamp', date('Y-m-d H:i:s', $start_datetime), date('Y-m-d H:i:s', $end_datetime));
                                     $qb->order = 't.measuring_timestamp ASC';
                                     $qb->params[':sensor_feature_id'] = $sensorFeature->sensor_feature_id;
                                     $found_data = SensorData::model()->long()->findAll($qb);
                                     $tmp = array();
                                     if ($this->accumulation_period != 0) {
                                         foreach ($found_data as $data) {
                                             $period = $start_datetime + (intval((strtotime($data->measuring_timestamp) - $start_datetime) / ($this->accumulation_period * 60)) + 1) * $this->accumulation_period * 60;
                                             $period = $period > $end_datetime ? $end_datetime : $period;
                                             $period *= 1000;
                                             $tmp[$period] = ['x' => $period, 'y' => $tmp[$period] ? $tmp[$period]['y'] : 0 + floatval($data->sensor_feature_value)];
                                         }
                                     } else {
                                         foreach ($found_data as $data) {
                                             $period = strtotime($data->measuring_timestamp) * 1000;
                                             $tmp[$period] = ['x' => $period, 'y' => floatval($data->sensor_feature_value)];
                                         }
                                     }
                                     $series_data[$i] = array_values($tmp);
                                     $i++;
                                 }
                             }
                         }
                         //calculation data
                         foreach ($station->station_calculation as $stationCalculation) {
                             if ($stationCalculation->handler_id == $this->calc_handlers[$sensor_feature_code]) {
                                 $colorWalker = new Color($station->color);
                                 $series_names[$i]['name'] = $station->station_id_code . ', ' . $stationCalculation->handler->display_name;
                                 $series_names[$i]['params']['color'] = '#' . $colorWalker->darken();
                                 $start_datetime = strtotime($this->date_from . ' ' . $this->time_from);
                                 $end_datetime = strtotime($this->date_to . ' ' . $this->time_to);
                                 $qb = new CDbCriteria();
                                 $qb->with = ['ListenerLog' => ['select' => 'ListenerLog.measuring_timestamp', 'condition' => "ListenerLog.measuring_timestamp BETWEEN '" . date('Y-m-d H:i:s', $start_datetime) . "' AND '" . date('Y-m-d H:i:s', $end_datetime) . "'"]];
                                 $qb->select = 't.calculation_id, t.value';
                                 $qb->order = 'ListenerLog.measuring_timestamp ASC';
                                 $qb->condition = 't.calculation_id = ?';
                                 $qb->params = [$stationCalculation->calculation_id];
                                 $found_data = StationCalculationData::model()->long()->findAll($qb);
                                 $tmp = array();
                                 foreach ($found_data as $data) {
                                     $tmp[] = ['x' => strtotime($data->ListenerLog->measuring_timestamp) * 1000, 'y' => floatval($data->value)];
                                 }
                                 $series_data[$i] = $tmp;
                             }
                         }
                         //custom_wind_rose
                         if (in_array($sensor_feature_code, array_keys($this->custom_sensor_features))) {
                             switch ($sensor_feature_code) {
                                 case 'custom_wind_rose':
                                     return $this->prepareCustomWindRose();
                                 default:
                                     return array();
                             }
                         }
                     }
                     $i++;
                 }
             }
         }
     }
     $result['series_names'] = array_values($series_names);
     $result['series_data'] = array_values($series_data);
     /**
      * depracated
      */
     if (!$this->hasErrors() && $this->station_id && true == false) {
         foreach ($this->sensor_feature_code as $group_code => $group) {
             if (!empty($group)) {
                 foreach ($group as $sensor_feature_code) {
                     if (in_array($sensor_feature_code, array_keys($this->calc_handlers))) {
                         $data = $this->prepareCalculationList($this->calc_handlers[$sensor_feature_code]);
                     } elseif (in_array($sensor_feature_code, array_keys($this->custom_sensor_features))) {
                         switch ($sensor_feature_code) {
                             case 'custom_wind_rose':
                                 return $this->prepareCustomWindRose();
                             default:
                                 return array();
                         }
                     } else {
                         $data = $this->prepareSensorList($sensor_feature_code, $group_code);
                     }
                     $result['series_names'] = array_merge($result['series_names'], $data['series_names']);
                     $result['series_data'] = array_merge($result['series_data'], $data['series_data']);
                 }
             }
         }
     }
     if (empty($result['series_names'])) {
         return array();
     }
     return $result;
 }
 public static function generate_css_color($selector, $style, $mod_name, $color_offset = 0, $opacity = 1, $before = '', $after = '')
 {
     $mod = get_theme_mod($mod_name);
     if (!empty($mod)) {
         $value = $mod;
         if (substr($value, 0, 1) != '#') {
             $value = '#' . $value;
         }
         $color = new Color($value);
         if ($color_offset > 0) {
             $value = '#' . $color->lighten(abs($color_offset));
         } elseif ($color_offset < 0) {
             $value = '#' . $color->darken(abs($color_offset));
         }
         if (abs($opacity) < 1) {
             $rgb = new Color($value);
             $rgb = $rgb->getRgb();
             $value = 'rgba( ' . $rgb['R'] . ', ' . $rgb['G'] . ', ' . $rgb['B'] . ', ' . $opacity . ' )';
         }
         echo $selector . '{ ' . $style . ': ' . $before . ' ' . $value . ' ' . $after . ' }';
     }
 }
Пример #9
0
 protected function darken_color($color = '', $amount = 18)
 {
     if ($color) {
         if (false !== strpos($color, 'rgb')) {
             $color_obj = new Color(Color::rgbToHex($color));
         } else {
             $color_obj = new Color($color);
         }
         return '#' . $color_obj->darken($amount);
     }
     return '';
 }