@@ -58,6 +58,8 @@ class View {
58
58
59
59
private $ componentContent ;
60
60
61
+ private $ html ;
62
+
61
63
private $ useComponent ;
62
64
63
65
private $ isEditor = false ;
@@ -80,18 +82,23 @@ function __construct() {
80
82
$ this ->theme = config (APP . '.theme ' , 'default ' );
81
83
}
82
84
85
+ if (isEditor ()) {
86
+ $ this ->isEditor = true ;
87
+ }
88
+
83
89
$ domain = $ this ->theme . '-domain ' ;
84
90
addTranslationDomain ($ domain );
85
91
86
92
$ this ->htmlPath = DIR_THEME . $ this ->theme . DS ;
87
93
$ this ->templatePath = DIR_THEME . $ this ->theme . DS ; //\Vvveb\config(APP . '.theme', 'default') . DS;
88
94
89
- if (isset ($ _REQUEST ['_component_ajax ' ])) {
95
+ if (isset ($ _REQUEST ['_component_ajax ' ]) && $ this -> isEditor ) {
90
96
$ this ->component = \Vvveb \filter ('/[a-z\-]*/ ' , $ _REQUEST ['_component_ajax ' ], 15 );
91
97
$ this ->componentCount = \Vvveb \filter ('/\d+/ ' , $ _REQUEST ['_component_id ' ], 2 );
92
98
//$this->componentCount = 0;
93
99
//if (isset($_REQUEST['_server_template'])) {
94
100
$ this ->componentContent = $ _POST ['_component_content ' ] ?? '' ;
101
+ $ this ->html = $ _POST ['html ' ] ?? '' ;
95
102
//}
96
103
}
97
104
@@ -109,7 +116,7 @@ function __construct() {
109
116
$ template ->addTemplatePath ($ this ->htmlPath . 'template ' . DS );
110
117
$ template ->setHtmlPath ($ this ->htmlPath );
111
118
112
- if (isEditor () ) {
119
+ if ($ this -> isEditor ) {
113
120
$ this ->isEditor = true ;
114
121
$ template ->removeVattrs (false );
115
122
}
@@ -257,13 +264,24 @@ private function compile($filename, $file, $service = false) {
257
264
if ($ this ->useComponent && ! defined ('CLI ' )) {
258
265
//regenerate components cache
259
266
if (! $ service ) {
260
- $ service = Component::getInstance ($ this , true , $ this ->componentContent );
267
+ if ($ this ->html ) {
268
+ $ html = $ this ->html ;
269
+ } else {
270
+ $ html = $ this ->componentContent ;
271
+ }
272
+
273
+ $ service = Component::getInstance ($ this , true , $ html );
261
274
}
262
275
}
263
276
264
277
list ($ this ->template , $ filename , $ this ->tplFile ) =
265
278
Event :: trigger (__CLASS__ ,__FUNCTION__ , $ this ->template , $ filename , $ this ->tplFile , $ this ->templateEngine , $ this );
266
- $ errors = $ this ->templateEngine ->loadHtmlTemplate ($ filename );
279
+
280
+ if ($ this ->html ) {
281
+ $ errors = $ this ->templateEngine ->loadHtml ($ this ->html );
282
+ } else {
283
+ $ errors = $ this ->templateEngine ->loadHtmlTemplate ($ filename );
284
+ }
267
285
268
286
//if no template defined use the default
269
287
if ($ this ->tplFile [0 ] == '/ ' ) {
0 commit comments