* zin: support to use raw content from buffer.
This commit is contained in:
@@ -1011,14 +1011,10 @@ class baseControl
|
||||
*/
|
||||
extract(\zin\zin::$data);
|
||||
|
||||
include $viewFile;
|
||||
/*
|
||||
extract((array)$this->view);
|
||||
ob_start();
|
||||
if(isset($hookFiles)) foreach($hookFiles as $hookFile) if(file_exists($hookFile)) include $hookFile;
|
||||
$this->output .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
*/
|
||||
include $viewFile;
|
||||
ob_end_flush();
|
||||
echo $output;
|
||||
|
||||
/**
|
||||
* 渲染完毕后,再切换回之前的路径。
|
||||
|
||||
@@ -156,6 +156,10 @@ class wg
|
||||
if(isset($app->zinErrors)) $zinDebug['errors'] = $app->zinErrors;
|
||||
}
|
||||
|
||||
$rawContent = ob_get_contents();
|
||||
if(!is_string($rawContent)) $rawContent = '';
|
||||
ob_end_clean();
|
||||
|
||||
if(is_object($result))
|
||||
{
|
||||
if($zinDebug && isset($result['zinDebug'])) $result['zinDebug'] = $zinDebug;
|
||||
@@ -167,8 +171,10 @@ class wg
|
||||
{
|
||||
if(!isset($item['type']) || $item['type'] !== 'html') continue;
|
||||
|
||||
$item['data'] = str_replace('/*{{ZIN_PAGE_CSS}}*/', $css, $item['data']);
|
||||
$item['data'] = str_replace('/*{{ZIN_PAGE_JS}}*/', $js, $item['data']);
|
||||
$item['data'] = str_replace('/*{{ZIN_PAGE_CSS}}*/', $css, $item['data']);
|
||||
$item['data'] = str_replace('/*{{ZIN_PAGE_JS}}*/', $js, $item['data']);
|
||||
$item['data'] = str_replace('<!-- {{RAW_CONTENT}} -->', $rawContent, $item['data']);
|
||||
|
||||
$result[$name]['data'] = $item['data'];
|
||||
}
|
||||
if($zinDebug && isset($result['zinDebug'])) $result['zinDebug'] = $zinDebug;
|
||||
@@ -179,6 +185,7 @@ class wg
|
||||
if($zinDebug) $js .= h::createJsVarCode('window.zinDebug', $zinDebug);
|
||||
$result = str_replace('/*{{ZIN_PAGE_CSS}}*/', $css, $result);
|
||||
$result = str_replace('/*{{ZIN_PAGE_JS}}*/', $js, $result);
|
||||
$result = str_replace('<!-- {{RAW_CONTENT}} -->', $rawContent, $result);
|
||||
}
|
||||
|
||||
echo $result;
|
||||
|
||||
@@ -280,3 +280,13 @@ function groupWgInList(wg|array $items, string|array $types): array
|
||||
$groups[] = $restList;
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create raw content placeholder.
|
||||
*
|
||||
* @return directive
|
||||
*/
|
||||
function rawContent(): directive
|
||||
{
|
||||
return h::comment('{{RAW_CONTENT}}');
|
||||
}
|
||||
|
||||
@@ -3,15 +3,22 @@ namespace zin;
|
||||
|
||||
class fragment extends wg
|
||||
{
|
||||
static $defineProps = array
|
||||
(
|
||||
'rawContent?: bool=true'
|
||||
);
|
||||
|
||||
protected function build()
|
||||
{
|
||||
$css = array(data('pageCSS'), '/*{{ZIN_PAGE_CSS}}*/');
|
||||
$js = array('/*{{ZIN_PAGE_JS}}*/', data('pageJS'));
|
||||
$css = array(data('pageCSS'), '/*{{ZIN_PAGE_CSS}}*/');
|
||||
$js = array('/*{{ZIN_PAGE_JS}}*/', data('pageJS'));
|
||||
$rawContent = $this->prop('rawContent');
|
||||
|
||||
return array
|
||||
(
|
||||
h::css($css, setClass('zin-page-css')),
|
||||
$this->children(),
|
||||
$rawContent ? rawContent() : null,
|
||||
h::js($js, setClass('zin-page-js'))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ class modalDialog extends wg
|
||||
'footerActions?: array',
|
||||
'footerClass?: string',
|
||||
'footerProps?: array',
|
||||
'rawContent?: bool=true'
|
||||
);
|
||||
|
||||
static $defineBlocks = array(
|
||||
@@ -81,10 +82,12 @@ class modalDialog extends wg
|
||||
|
||||
protected function buildBody()
|
||||
{
|
||||
$rawContent = $this->prop('rawContent');
|
||||
return div
|
||||
(
|
||||
setClass('modal-body'),
|
||||
$this->children()
|
||||
$this->children(),
|
||||
$rawContent ? rawContent() : null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,7 +96,7 @@ class modalDialog extends wg
|
||||
return div
|
||||
(
|
||||
setClass('modal-dialog'),
|
||||
set($this->props->skip(array_keys(static::getDefinedProps()))),
|
||||
set($this->getRestProps()),
|
||||
div
|
||||
(
|
||||
setClass('modal-content'),
|
||||
|
||||
+13
-10
@@ -13,7 +13,8 @@ class pageBase extends wg
|
||||
'bodyClass?: array|string',
|
||||
'zui?: bool',
|
||||
'lang?: string',
|
||||
'display?: bool'
|
||||
'display?: bool',
|
||||
'rawContent?: bool=true'
|
||||
);
|
||||
|
||||
static $defaultProps = array
|
||||
@@ -48,15 +49,16 @@ class pageBase extends wg
|
||||
$head = $this->buildHead();
|
||||
$body = $this->buildBody();
|
||||
|
||||
$jsConfig = \js::getJSConfigVars();
|
||||
$bodyProps = $this->prop('bodyProps');
|
||||
$bodyClass = $this->prop('bodyClass');
|
||||
$metas = $this->prop('metas');
|
||||
$title = $this->props->get('title', data('title')) . " - $lang->zentaoPMS";
|
||||
$attrs = $this->props->skip(array_keys(static::getDefinedProps()));
|
||||
$css = array(data('pageCSS'), '/*{{ZIN_PAGE_CSS}}*/');
|
||||
$js = array('/*{{ZIN_PAGE_JS}}*/', data('pageJS'));
|
||||
$imports = context::current()->getImportList();
|
||||
$jsConfig = \js::getJSConfigVars();
|
||||
$bodyProps = $this->prop('bodyProps');
|
||||
$bodyClass = $this->prop('bodyClass');
|
||||
$metas = $this->prop('metas');
|
||||
$rawContent = $this->prop('rawContent');
|
||||
$title = $this->props->get('title', data('title')) . " - $lang->zentaoPMS";
|
||||
$attrs = $this->props->skip(array_keys(static::getDefinedProps()));
|
||||
$css = array(data('pageCSS'), '/*{{ZIN_PAGE_CSS}}*/');
|
||||
$js = array('/*{{ZIN_PAGE_JS}}*/', data('pageJS'));
|
||||
$imports = context::current()->getImportList();
|
||||
|
||||
$jsConfig->zin = true;
|
||||
if($config->debug)
|
||||
@@ -95,6 +97,7 @@ class pageBase extends wg
|
||||
empty($imports) ? null : h::import($imports),
|
||||
h::css($css, setClass('zin-page-css')),
|
||||
$body,
|
||||
$rawContent ? rawContent() : null,
|
||||
h::js($js, setClass('zin-page-js'))
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user