PMA\libraries\Theme::getCssGradient PHP Метод

getCssGradient() публичный Метод

Generates code for CSS gradient using various browser extensions.
public getCssGradient ( string $start_color, string $end_color ) : string
$start_color string Color of gradient start, hex value without #
$end_color string Color of gradient end, hex value without #
Результат string CSS code.
    function getCssGradient($start_color, $end_color)
    {
        $result = array();
        // Opera 9.5+, IE 9
        $result[] = 'background-image: url(./themes/svg_gradient.php?from=' . $start_color . '&to=' . $end_color . ');';
        $result[] = 'background-size: 100% 100%;';
        // Safari 4-5, Chrome 1-9
        $result[] = 'background: ' . '-webkit-gradient(linear, left top, left bottom, from(#' . $start_color . '), to(#' . $end_color . '));';
        // Safari 5.1, Chrome 10+
        $result[] = 'background: -webkit-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
        // Firefox 3.6+
        $result[] = 'background: -moz-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
        // IE 10
        $result[] = 'background: -ms-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
        // Opera 11.10
        $result[] = 'background: -o-linear-gradient(top, #' . $start_color . ', #' . $end_color . ');';
        return implode("\n", $result);
    }

Usage Example

Пример #1
0
 /**
  * Test for getCssGradient
  *
  * @return void
  */
 public function testgetCssGradient()
 {
     $this->assertEquals($this->object->getCssGradient('12345', '54321'), 'background-image: url(./themes/svg_gradient.php?from=12345&to=54321);' . "\n" . 'background-size: 100% 100%;' . "\n" . 'background: -webkit-gradient(linear, left top, left bottom, ' . 'from(#12345), to(#54321));' . "\n" . 'background: -webkit-linear-gradient(top, #12345, #54321);' . "\n" . 'background: -moz-linear-gradient(top, #12345, #54321);' . "\n" . 'background: -ms-linear-gradient(top, #12345, #54321);' . "\n" . 'background: -o-linear-gradient(top, #12345, #54321);');
 }