Beispiel #1
0
 /**
  * Write the skin's color configuration and CSS.
  * 
  * @param string $primary The primary color.
  * @return void
  */
 protected function writeColors($primary)
 {
     ET::writeConfig(array("skin.Doragon.primaryColor" => $primary));
     $rgb = colorUnpack($primary, true);
     $hsl = rgb2hsl($rgb);
     $primary = colorPack(hsl2rgb($hsl), true);
     $hsl[1] = max(0, $hsl[1] - 0.3);
     $secondary = colorPack(hsl2rgb(array(2 => 0.6) + $hsl), true);
     $tertiary = colorPack(hsl2rgb(array(2 => 0.92) + $hsl), true);
     $css = file_get_contents($this->resource("colors.css"));
     $css = str_replace(array("{primary}", "{secondary}", "{tertiary}"), array($primary, $secondary, $tertiary), $css);
     file_put_contents(PATH_CONFIG . "/colors.css", $css);
 }
Beispiel #2
0
 /**
  * Initialize the skin.
  * 
  * @param ETController $sender The page controller.
  * @return void
  */
 public function handler_init($sender)
 {
     $sender->addCSSFile((C("esoTalk.https") ? "https" : "http") . "://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700");
     $sender->addCSSFile("core/skin/base.css", true);
     $sender->addCSSFile($this->getResource("styles.css"), true);
     // If we're viewing from a mobile browser, add the mobile CSS and change the master view.
     if ($isMobile = isMobileBrowser()) {
         $sender->addCSSFile($this->getResource("mobile.css"), true);
         $sender->masterView = "mobile.master";
         $sender->addToHead("<meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;'>");
     }
     // If custom colors have been set in this skin's settings, add some CSS to the page.
     $styles = array();
     // If a custom header color has been set...
     if ($c = C("skin.Default.headerColor")) {
         $styles[] = "#hdr {background-color:{$c}}";
         // If the header color is in the top half of the lightness spectrum, add the "lightHdr" class to the body.
         $rgb = colorUnpack($c, true);
         $hsl = rgb2hsl($rgb);
         if ($hsl[2] >= 0.5) {
             $sender->bodyClass .= " lightHdr";
         }
     }
     // If a custom body color has been set...
     if ($c = C("skin.Default.bodyColor")) {
         $styles[] = "body, .scrubberMore {background-color:{$c} !important}";
         // If the body color is in the bottom half of the lightness spectrum, add the "darkBody" class to the body.
         $rgb = colorUnpack($c, true);
         $hsl = rgb2hsl($rgb);
         if ($hsl[2] < 0.5) {
             $sender->bodyClass .= " darkBody";
         }
         // Slightly darken the body color and set it as the border color for the body content area.
         $hsl[2] = max(0, $hsl[2] - 0.1);
         $hsl[1] = min($hsl[1], 0.5);
         $b = colorPack(hsl2rgb($hsl), true);
         $styles[] = "#body-content {border-color:{$b}}";
     }
     // If a custom body background image has been set...
     if ($img = C("skin.Default.bodyImage") and !$isMobile) {
         $styles[] = "body {background-image:url(" . getWebPath($img) . "); background-position:top center; background-attachment:fixed}";
     }
     // Do we want this background image to not repeat?
     if ($img and C("skin.Default.noRepeat")) {
         $styles[] = "body {background-repeat:no-repeat}";
     }
     // If we have any custom styles at all, add them to the page head.
     if (count($styles)) {
         $sender->addToHead("<style type='text/css'>\n" . implode("\n", $styles) . "\n</style>");
     }
 }