Merge branch 'master' into noglob
This commit is contained in:
commit
7d35a8f3f0
27 changed files with 430 additions and 288 deletions
|
|
@ -1,14 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace ctiso\View;
|
||||
|
||||
use ctiso\View\Composite;
|
||||
|
||||
class Top extends Composite {
|
||||
class Top extends Composite
|
||||
{
|
||||
/**
|
||||
* Общая строка заголовка
|
||||
*/
|
||||
public $mid = 0;
|
||||
public $require = array();
|
||||
public $mid = 0;
|
||||
public $require = array();
|
||||
public $deps = array();
|
||||
|
||||
public function getTitle()
|
||||
|
|
@ -18,8 +20,8 @@ class Top extends Composite {
|
|||
|
||||
private function findGroup($groups, $file)
|
||||
{
|
||||
foreach($groups as $key => $group) {
|
||||
if(in_array($file, $group)) {
|
||||
foreach ($groups as $key => $group) {
|
||||
if (in_array($file, $group)) {
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +30,7 @@ class Top extends Composite {
|
|||
|
||||
private function groupFiles(array $list, $debugMode = true)
|
||||
{
|
||||
$debug = ($debugMode) ? 'debug=1' : '';
|
||||
$debug = ($debugMode) ? 'debug=1' : '';
|
||||
$path = parse_url($this->config->get('system', 'web'), PHP_URL_PATH);
|
||||
|
||||
$groups = array();
|
||||
|
|
@ -37,7 +39,7 @@ class Top extends Composite {
|
|||
$result = array();
|
||||
foreach ($list as $file) {
|
||||
$name = $this->findGroup($groups, $file);
|
||||
if($name) {
|
||||
if ($name) {
|
||||
$use[$name] = 1;
|
||||
} else {
|
||||
$result[] = $file;
|
||||
|
|
@ -52,17 +54,18 @@ class Top extends Composite {
|
|||
}
|
||||
|
||||
|
||||
function getId($pref) {
|
||||
$this->mid++;
|
||||
return $pref.$this->mid;
|
||||
}
|
||||
function getId($pref)
|
||||
{
|
||||
$this->mid++;
|
||||
return $pref . $this->mid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Обработка шаблона
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render()
|
||||
{
|
||||
|
||||
$alias = $this->doTree('alias');
|
||||
|
|
@ -72,51 +75,52 @@ class Top extends Composite {
|
|||
$this->set('scripts', array_unique($this->groupFiles($this->getScripts(), false)));
|
||||
$this->set('stylesheet', array_unique($this->groupFiles($this->getStyleSheet(), false)));
|
||||
|
||||
$this->require = array('admin' => 'ma');
|
||||
$this->deps = array();
|
||||
$this->require = array('admin' => 'ma');
|
||||
$this->deps = array();
|
||||
|
||||
$startup = array();
|
||||
foreach($this->_section as $s) {
|
||||
$startup = array();
|
||||
foreach ($this->_section as $s) {
|
||||
if (is_string($s)) {
|
||||
continue;
|
||||
}
|
||||
$moduleName = explode('_', $s->active_module, 2);
|
||||
$moduleName = explode('_', $s->active_module, 2);
|
||||
if (count($moduleName) < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$module = $moduleName[1];
|
||||
|
||||
$name = mb_strtolower($module);
|
||||
$fname = $name . '/' . $name;
|
||||
$name = mb_strtolower($module);
|
||||
$fname = $name . '/' . $name;
|
||||
|
||||
$current = $this->getId('m');
|
||||
$this->require[$fname] = $current;
|
||||
$current = $this->getId('m');
|
||||
$this->require[$fname] = $current;
|
||||
|
||||
$value = $this->getId('v');
|
||||
$value = $this->getId('v');
|
||||
|
||||
$script = "var " . $value . " = new " . $current . '.' . $module . "();\n";
|
||||
foreach($s->_values as $key => $v) {
|
||||
$script .= $value . "." . $key . " = " . json_encode($v/*, JSON_PRETTY_PRINT*/) . ";\n";
|
||||
}
|
||||
$script = "var " . $value . " = new " . $current . '.' . $module . "();\n";
|
||||
foreach ($s->_values as $key => $v) {
|
||||
$script .= $value . "." . $key . " = " . json_encode($v /*, JSON_PRETTY_PRINT*/) . ";\n";
|
||||
}
|
||||
|
||||
$init = array();
|
||||
foreach($s->_section as $key => $item) {
|
||||
$ss/*: View*/ = $item;
|
||||
$init = array();
|
||||
foreach ($s->_section as $key => $item) {
|
||||
$ss /*: View*/= $item;
|
||||
if ($ss->codeGenerator !== null) {
|
||||
// функцию которая вычисляет а не результат
|
||||
$part = call_user_func($ss->codeGenerator, $this, $key, $value);
|
||||
$init [] = $part;
|
||||
}
|
||||
}
|
||||
// функцию которая вычисляет а не результат
|
||||
$part = call_user_func($ss->codeGenerator, $this, $key, $value);
|
||||
$init[] = $part;
|
||||
}
|
||||
}
|
||||
|
||||
$script .= $value . ".execute('" . $s->module_action . "', " . json_encode($init) .");\n";
|
||||
$startup[] = $script;
|
||||
}
|
||||
$script .= $value . ".execute('" . $s->module_action . "', " . json_encode($init) . ");\n";
|
||||
$startup[] = $script;
|
||||
}
|
||||
|
||||
|
||||
$this->set('startup', implode("", $startup) . $this->getScriptStartup());
|
||||
$this->set('require', implode(",", array_map(function ($x) { return "'$x'";}, array_keys($this->require))));
|
||||
$this->set('require', implode(",", array_map(function ($x) {
|
||||
return "'$x'"; }, array_keys($this->require))));
|
||||
$this->set('deps', implode(",", array_values($this->require)));
|
||||
|
||||
$this->set('title', $this->getTitle());
|
||||
|
|
@ -160,4 +164,4 @@ class Top extends Composite {
|
|||
return $this->doTree('_stylesheet');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue