+ zin: support to render content as fragment
This commit is contained in:
@@ -13,7 +13,7 @@ namespace zin;
|
||||
|
||||
require_once 'zin.class.php';
|
||||
|
||||
function render($wgName = '\\zin\\page')
|
||||
function render($wgName = 'page')
|
||||
{
|
||||
$args = array();
|
||||
foreach(zin::$globalRenderList as $item)
|
||||
@@ -22,14 +22,9 @@ function render($wgName = '\\zin\\page')
|
||||
$args[] = $item;
|
||||
}
|
||||
|
||||
if(is_string($wgName))
|
||||
{
|
||||
if(strpos($wgName, '\\zin\\') !== false) $wgName = str_replace('\\zin\\', '', $wgName);
|
||||
if(isset(zin::$globalRenderMap[$wgName])) $wgName = zin::$globalRenderMap[$wgName];
|
||||
}
|
||||
if(is_string($wgName) && isset(zin::$globalRenderMap[$wgName])) $wgName = zin::$globalRenderMap[$wgName];
|
||||
|
||||
$className = "\\zin\\$wgName";
|
||||
$wg = class_exists($className) ? (new $className($args)) : $className($args);
|
||||
$wg = createWg($wgName, $args);
|
||||
|
||||
if(!$wg->displayed) $wg->display();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ function icon() {return createWg('icon', func_get_args());}
|
||||
function btn() {return createWg('btn', func_get_args());}
|
||||
function pagebase() {return createWg('pagebase', func_get_args());}
|
||||
function page() {return createWg('page', func_get_args());}
|
||||
function fragment() {return createWg('fragment', func_get_args());}
|
||||
function btnGroup() {return createWg('btngroup', func_get_args());}
|
||||
function checkbox() {return createWg('checkbox', func_get_args());}
|
||||
function pagemain() {return createWg('pagemain', func_get_args());}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace zin;
|
||||
|
||||
class fragment extends wg
|
||||
{
|
||||
protected function build()
|
||||
{
|
||||
$context = context::current();
|
||||
$css = $context->getCssList();
|
||||
$js = $context->getJsList();
|
||||
$imports = $context->getImportList();
|
||||
|
||||
return array
|
||||
(
|
||||
empty($css) ? NULL : h::css($css),
|
||||
empty($imports) ? NULL : h::import($imports),
|
||||
$this->children(),
|
||||
empty($js) ? NULL : h::js($js)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user