]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 29 Jan 2013 14:11:46 +0000 (14:11 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 29 Jan 2013 14:11:46 +0000 (14:11 +0000)
inc/ws/Util/class.ws.tools.php
inc/ws/Util/html5/class.ws.html5.compiler.php

index e65989989a01df1fa6dbb2b19c0dc5b13623251a..077d10d5e7c936e82adb4cdac025b3ffc62c275b 100644 (file)
@@ -22,27 +22,34 @@ class wsTools {
                $webvideo->execute();
        }
 
-       public static function colorizeAndRasterizeIcon($iconSet, $icon, $color, $dest, $scale, &$w, &$h) {
+       public static function colorizeAndRasterizeIcon($iconSet, $icon, $colors, $dest, $scale, &$w, &$h) {
                // Init directory
-               $color = ltrim($color, '#');
+               if (is_string($colors)) {
+                       $colors = array('colorize' => $colors);
+               }
+               $hash = sha1(json_encode($colors));
+               foreach ($colors as $k => $v) {
+                       $colors[$k] = wsHTML5Compiler::colorToArray($colors[$k]);
+               }
 
                $e = explode('-', $icon);
-               $nav = ($e[0] != 'share');
+               $type = $e[0];
 
-               if ($nav) {
+               if ($type == 'nav') {
                        $svgRef = WS_ICONS . '/' . $iconSet . '/mobile/' . $icon . '.svg';
                        if (!file_exists($svgRef)) {
                                $iconSet = 1;
                                $svgRef = WS_ICONS . '/' . $iconSet . '/mobile/' . $icon . '.svg';
                        }
 
-                       $dirColorized = WS_ICONS . '/' . $iconSet . '/mobile/' . $color . '/';
+                       $dirColorized = WS_ICONS . '/' . $iconSet . '/mobile/colorized/' . $hash . '/';
                        $svgColorized = $dirColorized . '/' . $icon . '.svg';
                } else {
-                       $dirColorized = WS_ICONS . '/share/' . $color;
-                       $svgRef = WS_ICONS . '/share/' . $icon . '.svg';
+                       $dirColorized = WS_ICONS . '/' . $type . '/colorized/' . $hash;
+                       $svgRef = WS_ICONS . '/' . $type . '/' . $icon . '.svg';
                        $svgColorized = $dirColorized . '/' . $icon . '.svg';
                }
+
                if (!file_exists($dirColorized)) {
                        mkdir($dirColorized, 0777, true);
                }
@@ -53,7 +60,13 @@ class wsTools {
                if (!file_exists($svgColorized) || filemtime($svgColorized) <= filemtime($svgRef)) {
                        $svg = file_get_contents($svgRef);
                        // Colorize it
-                       $svg = str_replace('$colorize', '#' . $color, $svg);
+                       foreach ($colors as $k => $v) {
+                               $replace = "#" . $v['hex'];
+                               if ($v['alpha'] < 1) {
+                                       $replace.='" fill-opacity="' . $v['alpha'];
+                               }
+                               $svg = str_replace('$' . $k, $replace, $svg);
+                       }
                        file_put_contents($svgColorized, $svg);
                }
                self::copy($svgColorized, $dest . '/' . $icon . '.svg');
index ef256ca6cdb0aeb5d673f4d4e4a16b8b8e2a155f..69053c42b0a66b454b39cc38eafae316fdf068b7 100644 (file)
@@ -732,31 +732,30 @@ class wsHTML5Compiler {
                $res = array();
                // Get the colors used to colorize graphics
                if ($this->theme->parametres->colorizeIcons) {
-                       $couleurI = '#' . $this->theme->parametres->couleurI;
+                       $couleurI = $this->theme->parametres->couleurI;
                } else {
-                       $couleurI = '#FFFFFF';
+                       $couleurI = 'FFFFFF';
                }
 
                $couleurM = $this->theme->parametres->subTextColor;
-               if (strlen($couleurM) >= 8) {
-                       $couleurM = substr($couleurM, 2, 6);
-               }
 
-               $couleurM = strtoupper('#' . $couleurM);
+               $bookmarksDisabledColors = array('star' => $this->theme->parametres->bookmarkStarDisabledColor, 'bookmark' => $this->theme->parametres->bookmarkBackgroundColor);
+               $bookmarksEnabledColors = array('star' => $this->theme->parametres->bookmarkStarEnabledColor, 'bookmark' => $this->theme->parametres->bookmarkBackgroundColor);
 
-               $arrowsColor = '#' . $this->theme->parametres->arrowsColor;
+               $arrowsColor = $this->theme->parametres->arrowsColor;
                // Set the icon list with the color
                $icons = array('nav-bookmark' => $couleurI, 'nav-friend' => $couleurI, 'nav-help' => $couleurI, 'nav-index' => $couleurI, 'nav-sommaire' => $couleurI,
-                       'next' => $arrowsColor, 'previous' => $arrowsColor, 'search' => $couleurI,
+                       'interface-next' => $arrowsColor, 'interface-previous' => $arrowsColor, 'interface-search' => $couleurI,
                        'help-fingers' => $couleurI, 'help-mouse' => $couleurI, 'nav-home' => $couleurI, 'nav-archives' => $couleurI, 'nav-map' => $couleurI,
                        'nav-tag' => $couleurI, 'nav-print' => $couleurI, 'nav-friend' => $couleurI,
-                       'share-facebook' => $couleurM, 'share-twitter' => $couleurM, 'share-email' => $couleurM, 'share-googleplus' => $couleurM, 'share-linkedin' => $couleurM, 'share-viadeo' => $couleurM);
+                       'share-facebook' => $couleurM, 'share-twitter' => $couleurM, 'share-email' => $couleurM, 'share-googleplus' => $couleurM, 'share-linkedin' => $couleurM, 'share-viadeo' => $couleurM,
+                       'bookmark-left-off' => $bookmarksDisabledColors, 'bookmark-left-on' => $bookmarksEnabledColors,
+                       'bookmark-right-off' => $bookmarksDisabledColors, 'bookmark-right-on' => $bookmarksEnabledColors
+               );
 
                $this->config->iconsDimensions = array();
                foreach ($icons as $icon => $color) {
-
                        wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h);
-
                        $this->config->iconsDimensions[$icon] = array($w, $h);
                }
                return $res;
@@ -872,6 +871,16 @@ class wsHTML5Compiler {
                $shade.='}';
                $res[] = $shade;
 
+               // Search field
+               $search = '#q{';
+               $search.='color:' . self::colorToCSS($this->theme->parametres->couleurS) . ';';
+               $search.='background-color:' . self::colorToCSS($this->theme->parametres->searchFieldColor) . ';';
+               if ($this->theme->parametres->searchShadeAlpha > 0) {
+                       $search.=$this->writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ';') . ';';
+               }
+               $search.='}';
+               $res[] = $search;
+
                // Background
                $body = '#main,.mview.index{';
                $body.='background-color:#' . $this->theme->parametres->backgroundColor . ';';
@@ -1051,6 +1060,23 @@ class wsHTML5Compiler {
                
        }
 
+       public static function colorToArray($color, $forceAlpha = null) {
+               $color = ltrim($color, '#');
+               if (strlen($color) == 6) {
+                       $hex = $color;
+                       $alpha = 1;
+               } else {
+                       $alpha = substr($color, 0, 2) / 255;
+                       $hex = substr($color, 2, 6);
+               }
+
+               if (!is_null($forceAlpha)) {
+                       $alpha = $forceAlpha;
+               }
+
+               return array('hex' => strtoupper($hex), 'opacity' => number_format($alpha, 3, '.', ''));
+       }
+
        public static function colorToCSS($color, $forceAlpha = null) {
                if (!is_null($forceAlpha)) {
                        if ($forceAlpha <= 0) {