1
+ <?php if ( ! defined ('BASEPATH ' )) exit ('No direct script access allowed ' );
2
+
3
+ class Neat
4
+ {
5
+
6
+ private $ config ;
7
+ private $ layout ;
8
+ private $ data = array ();
9
+ private $ ci_instance ;
10
+ private $ elements_folder ;
11
+ private $ html_webroot ;
12
+ public $ css_output = array ();
13
+ public $ js_output = array ();
14
+ public $ metatags = array ();
15
+
16
+ public function __construct () {
17
+
18
+ include_once (APPPATH .'config/custome/neat.php ' );
19
+
20
+ $ this ->config = $ neat_lm ;
21
+
22
+ $ this ->layout = 'layouts/ ' .$ this ->config ['default_layout ' ];
23
+ $ this ->elements_folder = $ this ->config ['elements_folder ' ];
24
+
25
+ $ this ->html_webroot = $ this ->config ['HTML_WEBROOT ' ];
26
+
27
+ $ this ->ci_instance =& get_instance ();
28
+
29
+ }
30
+
31
+ function setLayout ($ name ) {
32
+
33
+ $ this ->layout = 'layouts/ ' .$ name ;
34
+
35
+ }
36
+
37
+ function render ($ view , $ data = null , $ return = false ) {
38
+
39
+ if ($ data != null && is_array ($ data )) {
40
+
41
+ $ this ->data = array_merge ($ this ->data , $ data );
42
+
43
+ }
44
+
45
+ $ content_layout = array ();
46
+
47
+ $ content_layout ['content_for_layout ' ] = $ this ->ci_instance ->load ->view ($ view , $ this ->data , true );
48
+
49
+ if ($ return ) {
50
+
51
+ $ output = $ this ->ci_instance ->load ->view ($ this ->layout , $ content_layout , true );
52
+ return $ output ;
53
+
54
+ } else {
55
+
56
+ $ this ->ci_instance ->load ->view ($ this ->layout , $ content_layout , false );
57
+
58
+ }
59
+
60
+ }
61
+
62
+ function get_elements ($ name ) {
63
+
64
+ $ output = $ this ->ci_instance ->load ->view ($ this ->elements_folder .'/ ' .$ name , $ this ->data , false ) ;
65
+ return $ output ;
66
+
67
+ }
68
+
69
+ // Must be called before render method so data applies to view
70
+ public function bind_data ($ key , $ value ) {
71
+
72
+ $ this ->data [$ key ] = $ value ;
73
+ return $ this ;
74
+
75
+ }
76
+
77
+ public function css ($ href = '' , $ rel = 'stylesheet ' , $ type = 'text/css ' , $ title = '' , $ media = '' , $ index_page = FALSE ) {
78
+
79
+ $ css_output = '' ;
80
+
81
+ if (strpos ($ href , '// ' ) !== false ) {
82
+
83
+ $ this ->css_output [] = link_tag ($ href , $ rel , $ type , $ title , $ media , $ index_page = FALSE );
84
+
85
+ }else {
86
+
87
+ $ this ->css_output [] = link_tag ($ this ->html_webroot .$ href , $ rel , $ type , $ title , $ media , $ index_page = FALSE );
88
+
89
+ }
90
+
91
+
92
+ }
93
+
94
+ public function js ($ src = '' , $ language = 'javascript ' , $ type = 'text/javascript ' ) {
95
+
96
+ if (strpos ($ src , '// ' ) !== false ) {
97
+
98
+ $ this ->js_output [] = '<script type=" ' .$ type .'" src=" ' .$ src .'"></script> ' ;
99
+
100
+ }else {
101
+
102
+ $ this ->js_output [] = '<script type=" ' .$ type .'" src=" ' .$ this ->html_webroot .$ src .'"></script> ' ;
103
+
104
+ }
105
+
106
+ }
107
+
108
+ public function meta_tag_link ($ name = "" , $ content = "" , $ type = 'name ' ) {
109
+
110
+ $ this ->metatags []=meta ($ name ,$ content ,$ type );
111
+
112
+ }
113
+
114
+
115
+ }
0 commit comments