forked from Felli/Doragon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skin.php
84 lines (84 loc) · 3.04 KB
/
skin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
// Copyright 2011 Toby Zerner, Simon Zerner
// This file is part of esoTalk. Please see the included license file for usage information.
if (!defined("IN_ESOTALK")) exit;
/**
* Default skin file.
*
* @package esoTalk
*/
ET::$skinInfo["Doragon"] = array(
"name" => "Doragon",
"description" => "A flat theme skin that is based on Flatty.",
"version" => "v0.3",
"author" => "Felli",
"authorEmail" => "felli-sama@asia.com",
"authorURL" => "http://yuriqueen.ga/blog/",
"license" => "GPLv2"
);
class ETSkin_Doragon extends ETSkin {
/**
* Initialize the skin.
*
* @param ETController $sender The page controller.
* @return void
*/
public function handler_init($sender)
{
$sender->addToHead("<link rel='shortcut icon' href='".getWebPath($this->resource("favicon.ico"))."'>");
$sender->addCSSFile((C("esoTalk.https") ? "https" : "http")."://fonts.googleapis.com/css?family=Open+Sans:400,600|Roboto|TitilliumWeb");
$sender->addCSSFile("core/skin/base.css", true);
$sender->addCSSFile("core/skin/font-awesome.css", true);
$sender->addCSSFile($this->resource("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->resource("mobile.css"), true);
$sender->masterView = "mobile.master";
$sender->addToHead("<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0'>");
}
$sender->addCSSFile("config/colors.css", true);
if (!C("skin.Doragon.primaryColor")) $this->writeColors("#364159");
}
/**
* 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);
}
/**
* Construct and process the settings form for this skin, and return the path to the view that should be
* rendered.
*
* @param ETController $sender The page controller.
* @return string The path to the settings view to render.
*/
public function settings($sender)
{
// Set up the settings form.
$form = ETFactory::make("form");
$form->action = URL("admin/appearance");
$form->setValue("primaryColor", C("skin.Doragon.primaryColor"));
// If the form was submitted...
if ($form->validPostBack("save")) {
$this->writeColors($form->getValue("primaryColor"));
$sender->message(T("message.changesSaved"), "success autoDismiss");
$sender->redirect(URL("admin/appearance"));
}
$sender->data("skinSettingsForm", $form);
$sender->addJSFile("core/js/lib/farbtastic.js");
return $this->view("settings");
}
}