thememanager_class.php
2.07 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
 * Tiny - A PHP Framework For Web Artisans
 * @author Tiny <tinylofty@gmail.com>
 * @copyright Copyright(c) 2010-2014 http://www.tinyrise.com All rights reserved
 * @version 1.0
 */
/**
 * 主题管理类
 * 
 * @author Tiny
 * @class ThemeManager
 */
class ThemeManager
{
	const THEMES='themes';
	private static $obj;
	private $theme = 'Theme';
	private $basePath;
	private $baseUrl;
	private function __construct()
	{
	}
	private function __clone()
	{
	}
    /**
     * 取得实例
     * 
     * @access public
     * @return mixed
     */
	public static function getInstance()
	{
		if(!self::$obj instanceof self)
		{
			self::$obj = new self();
		}
		return self::$obj;
	}
    /**
     * 得到主题
     * 
     * @access public
     * @param mixed $name
     * @return mixed
     */
	public function getTheme($name)
	{
		$themePath = $this->getBasePath().DIRECTORY_SEPARATOR.$name;
		$className = $this->theme;
		if(is_dir($themePath)) return new $className($name,$themePath,$this->getBaseUrl().'/'.$name);
		else return null;
	}
    /**
     * 取得所有主题
     * 
     * @access public
     * @return mixed
     */
	public function getThemes()
	{
	}
	/**
	 * 得到主题存在的要目录
	 */
	public function getBasePath()
	{
		if($this->basePath === null) $this->setBasePath(APP_ROOT.DIRECTORY_SEPARATOR.self::THEMES);
		return $this->basePath;
	}
    /**
     * 设定主题路径
     * 
     * @access public
     * @param mixed $path
     * @return mixed
     */
	public function setBasePath($path)
	{
		$this->basePath = realpath($path);
	}
    /**
     * 获得主题路径URL
     * 
     * @access public
     * @return mixed
     */
	public function getBaseUrl()
	{
		if($this->baseUrl === null ) $this->setBaseUrl(APP_URL.self::THEMES);
		return $this->baseUrl;
	}
    /**
     * 设置主题路径URL
     * 
     * @access public
     * @param mixed $baseUrl
     * @return mixed
     */
	public function setBaseUrl($baseUrl)
	{
		$this->baseUrl = $baseUrl;
	}
}