theme_class.php
1.38 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
<?php
class Theme
{
private $name;
private $basePath;
private $baseUrl;
private $configInfo;
public function __construct($name, $basePath, $baseUrl)
{
$this->name = $name;
$this->basePath = $basePath;
$this->baseUrl = $baseUrl;
}
public function getName()
{
return $this->name;
}
public function getBaseUrl()
{
return $this->baseUrl;
}
public function getBasePath()
{
return $this->basePath;
}
public function getViewPath()
{
return $this->getBasePath().DIRECTORY_SEPARATOR.'views';
}
public function getSkinPath()
{
return $this->getViewPath().DIRECTORY_SEPARATOR.'skins';
}
/**
*获得视图文件
*/
public function getViewFile($controller,$viewName)
{
return $this->getViewPath().'/'.$controller->getId().'/'.$viewName;
}
/**
*获得布展文件
*/
public function getLayoutFile($controller,$layoutName)
{
return $this->getViewPath().'/layouts/'.$layoutName;
}
/**
* 取得主题配制文件信息
* @return Array
*/
public function getConfigInfo()
{
if($this->configInfo!=null) return $this->configInfo;
$theme_path = $this->getBasePath().DIRECTORY_SEPARATOR.'info.php';
if(file_exists($theme_path)){
$this->configInfo = include_once($theme_path);
}else{
$this->configInfo = null;
}
return $this->configInfo;
}
}
?>