* zin: output page data to client
This commit is contained in:
@@ -105,7 +105,7 @@ class props extends \zin\utils\dataset
|
||||
|
||||
public function addChildren($items)
|
||||
{
|
||||
$this->addBlock('default', $items);
|
||||
$this->addBlock('children', $items);
|
||||
}
|
||||
|
||||
public function getBlock($name)
|
||||
@@ -116,7 +116,7 @@ class props extends \zin\utils\dataset
|
||||
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->getBlock('default');
|
||||
return $this->getBlock('children');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,7 +197,7 @@ class props extends \zin\utils\dataset
|
||||
{
|
||||
$data = $this->data;
|
||||
$data['style'] = $this->style->data;
|
||||
$data['class'] = $this->class->list;
|
||||
$data['class'] = $this->class->toStr();
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
+17
-4
@@ -243,13 +243,26 @@ class wg
|
||||
}
|
||||
}
|
||||
|
||||
protected function created()
|
||||
{
|
||||
}
|
||||
protected function created() {}
|
||||
|
||||
protected function toJsonData()
|
||||
{
|
||||
|
||||
$data = $this->props->toJsonData();
|
||||
foreach($data as $key => $value)
|
||||
{
|
||||
if($key[0] !== '#') continue;
|
||||
foreach($value as $index => $child)
|
||||
{
|
||||
if($child instanceof wg || (is_object($child) && method_exists($child, 'toJsonData')))
|
||||
{
|
||||
$value[$index] = $child->toJsonData();
|
||||
}
|
||||
}
|
||||
$data[$key] = $value;
|
||||
}
|
||||
$data['$type'] = get_called_class();
|
||||
if(strpos($data['$type'], 'zin\\') === 0) $data['$type'] = substr($data['$type'], 4);
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected static function getDefaultProps()
|
||||
|
||||
@@ -42,7 +42,7 @@ class pagebase extends wg
|
||||
(
|
||||
set($this->prop('bodyProps')),
|
||||
parent::build(),
|
||||
$config->debug ? h::js('window.zin = ' . json_encode($this->props->toJsonData()) . ';console.log("page", window.zin)') : null // TODO: support to export page data to client
|
||||
$config->debug ? h::js('window.zin = ' . json_encode($this->toJsonData()) . ';console.log("page", window.zin)') : null
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user