* zin: refactor

This commit is contained in:
Hao Sun
2023-03-29 09:35:43 +08:00
parent ffc1b5aaef
commit 0ed123136f
3 changed files with 34 additions and 13 deletions
+24 -3
View File
@@ -12,6 +12,7 @@
namespace zin;
require_once dirname(__DIR__) . DS . 'utils' . DS . 'dataset.class.php';
require_once dirname(__DIR__) . DS . 'utils' . DS . 'flat.func.php';
require_once 'portal.class.php';
class context extends \zin\utils\dataset
@@ -74,7 +75,8 @@ class context extends \zin\utils\dataset
public function addJSCall()
{
$code = call_user_func_array('h::createJsCallCode', func_get_args());
$code = call_user_func_array('\zin\h::createJsCallCode', func_get_args());
\a(array('code', $code, $this->getJsList()));
return $this->addToList('jsCall', $code);
}
@@ -97,13 +99,32 @@ class context extends \zin\utils\dataset
public static function js(/* string ...$code */)
{
$context = static::current();
call_user_func_array(array($context, 'addJS'), func_get_args());
call_user_func_array(array($context, 'addJS'), \zin\utils\flat(func_get_args()));
}
public static function jsCall(/* string ...$code */)
{
$context = static::current();
call_user_func_array(array($context, 'addJSCall'), func_get_args());
}
public static function jsVar($name, $value)
{
$context = static::current();
$context->addJSVar($name, $value);
}
public static function css(/* string ...$code */)
{
$context = static::current();
call_user_func_array(array($context, 'addCSS'), func_get_args());
call_user_func_array(array($context, 'addCSS'), \zin\utils\flat(func_get_args()));
}
public static function import(/* string ...$files */)
{
$context = static::current();
call_user_func_array(array($context, 'addImport'), func_get_args());
}
/**
+10 -5
View File
@@ -18,22 +18,27 @@ function portal(/* string $name, mixed ...$children */)
call_user_func_array('\zin\context::portal', func_get_args());
}
function pageJS()
function js()
{
call_user_func_array('\zin\context::js', func_get_args());
}
function pageCSS()
function jsCall()
{
call_user_func_array('\zin\context::css', func_get_args());
call_user_func_array('\zin\context::jsCall', func_get_args());
}
function pageJSVar()
function jsVar()
{
call_user_func_array('\zin\context::jsVar', func_get_args());
}
function pageImport()
function css()
{
call_user_func_array('\zin\context::css', func_get_args());
}
function import()
{
call_user_func_array('\zin\context::import', func_get_args());
}
-5
View File
@@ -42,9 +42,4 @@ function li() {return call_user_func_array('\zin\h::li', func_get_args());
function input() {return call_user_func_array('\zin\h::input', func_get_args());}
function textarea() {return call_user_func_array('\zin\h::textarea', func_get_args());}
function js() {return call_user_func_array('\zin\h::js', func_get_args());}
function jsVar() {return call_user_func_array('\zin\h::jsVar', func_get_args());}
function jsCall() {return call_user_func_array('\zin\h::jsCall', func_get_args());}
function jsRaw() {return call_user_func_array('\zin\h::jsRaw', func_get_args());}
function css() {return call_user_func_array('\zin\h::css', func_get_args());}
function import() {return call_user_func_array('\zin\h::import', func_get_args());}