-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSettingsStyle.php
executable file
·78 lines (49 loc) · 2.21 KB
/
SettingsStyle.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
<?php
class SettingsStyle extends PluginObject {
public $css;
public $less;
public $admin_view;
public $public_view;
public $view_type;
function __construct( $style ) {
if ( is_object($style) ) {
//I think this is never true, at this point
$info = $this->_create_from_object( $style );
} else {
$info = $this->_create_from_array( $style );
}
$this->css = new Asset( $info["css"]["url"], $info["css"]["path"], $info["css"]["hash"] );
$this->less = new Asset( $info["less"]["url"], $info["less"]["path"] );
}
public function output( $message ) {
$view_type = ($this->public_view == $this->admin_view) ? $this->public_view : "variable";
$this->html = new SettingsHtml( $this->css, $this->less, $view_type, $message );
$this->html->output_page_styles();
$this->html->display();
}
public function become_array() {
$css["url"] = isset($this->css->url) ? $this->css->url : null;
$css["path"] = isset($this->css->path) ? $this->css->relative_path() : null;
$css["hash"] = isset($this->css->hash) ? $this->css->hash : null;
$less["url"] = isset($this->less->url) ? $this->less->url : null;
$less["path"] = isset($this->less->path) ? $this->less->relative_path() : null;
return array( "css" => $css, "less" => $less );
}
private function _create_from_object( $object ) {
$css["url"] = isset($asset->css->url) ? $asset->css->url : null;
$css["path"] = isset($asset->css->path) ? $asset->css->path : null;
$css["hash"] = isset($asset->css->hash) ? $asset->css->hash : null;
$less["url"] = isset($asset->less->url) ? $asset->less->url : null;
$less["path"] = isset($asset->less->path) ? $asset->less->path : null;
return array( "css" => $css, "less" => $less );
}
private function _create_from_array( $array ) {
$css["url"] = isset($array["css"]["url"]) ? $array["css"]["url"] : null;
$css["path"] = isset($array["css"]["path"]) ? $array["css"]["path"] : null;
$css["hash"] = isset($array["css"]["hash"]) ? $array["css"]["hash"] : null;
$less["url"] = isset($array["less"]["url"]) ? $array["less"]["url"] : null;
$less["path"] = isset($array["less"]["path"]) ? $array["less"]["path"] : null;
return array( "css" => $css, "less" => $less );
}
}
?>