From: vincent@cubedesigners.com Date: Tue, 29 Jan 2013 14:11:46 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=4a7011fb4ba3c2db47da4dd6c055794724dd95e6;p=cubeextranet.git --- diff --git a/inc/ws/Util/class.ws.tools.php b/inc/ws/Util/class.ws.tools.php index e65989989..077d10d5e 100644 --- a/inc/ws/Util/class.ws.tools.php +++ b/inc/ws/Util/class.ws.tools.php @@ -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'); diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index ef256ca6c..69053c42b 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -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) {