-
Notifications
You must be signed in to change notification settings - Fork 937
/
theme.php
143 lines (126 loc) · 2.38 KB
/
theme.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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Theme Plugin
*
* Load partials and access data
*
* @package PyroCMS
* @author PyroCMS Dev Team
* @copyright Copyright (c) 2008 - 2010, PyroCMS
*
*/
class Plugin_Theme extends Plugin
{
/**
* Partial
*
* Loads a theme partial
*
* Usage:
* {pyro:theme:partial file="header"}
*
* @param array
* @return array
*/
function partial()
{
$name = $this->attribute('name');
$name = $this->attribute('file', $name); #deprecated
$data =& $this->load->_ci_cached_vars;
return $this->parser->parse_string($this->load->_ci_load(array(
'_ci_path' => $data['template_views'].'partials/'.$name.'.html',
'_ci_return' => TRUE
)), $data, TRUE, TRUE);
}
function path()
{
$data =& $this->load->_ci_cached_vars;
$path = rtrim($data['template_views'], '/');
return preg_replace('#(\/views(\/web|\/mobile)?)$#', '', $path).'/';
}
/**
* Theme CSS
*
* Insert a CSS tag from the theme
*
* Usage:
*
* {pyro:theme:css file=""}
*
* @param array
* @return array
*/
function css()
{
$this->load->library('asset');
$file = $this->attribute('file');
$attributes = $this->attributes();
unset($attributes['file']);
return $this->asset->css($file, '_theme_', $attributes);
}
/**
* Theme Image
*
* Insert a image tag from the theme
*
* Usage:
*
* {pyro:theme:image file=""}
*
* @param array
* @return array
*/
function image()
{
$this->load->library('asset');
$file = $this->attribute('file');
$attributes = $this->attributes();
unset($attributes['file']);
return $this->asset->image($file, '_theme_', $attributes);
}
/**
* Theme JS
*
* Insert a JS tag from the theme
*
* Usage:
*
* {pyro:theme:css file=""}
*
* @param array
* @return array
*/
function js()
{
$this->load->library('asset');
$file = $this->attribute('file');
return $this->asset->js($file, '_theme_');
}
/**
* Data
*
* Loads a theme partial
*
* Usage:
* {pyro:session:data name="foo"}
*
* @param array
* @return array
*/
public function variables()
{
if ( ! isset($variables))
{
static $variables = array();
}
$name = $this->attribute('name');
$value = $this->attribute('value');
if ($value !== NULL)
{
$variables[$name] = $value;
return;
}
return $variables[$name];
}
}
/* End of file theme.php */