style: Форматирование

This commit is contained in:
origami11@yandex.ru 2024-08-29 11:11:20 +03:00
parent 8941f5f102
commit d692538163
9 changed files with 92 additions and 92 deletions

View file

@ -19,14 +19,14 @@ use ctiso\HttpRequest,
class FakeTemplate {
public $_data = [];
public $_name = '';
function __construct($name) {
$this->_name = $name;
}
function __set($key, $value) {
$this->_data[$key] = $value;
}
}
function execute() {
return json_encode($this->_data);
@ -49,7 +49,7 @@ class Component
public $COMPONENTS_WEB;
public Registry $config;
public Registry $config;
public Database $db;
public Collection $parameter;
@ -79,7 +79,7 @@ class Component
} else {
$action = 'action' . ucfirst($_action);
}
$this->before();
if (method_exists($this, $action)) {
return call_user_func([$this, $action], $crequest);
@ -89,16 +89,16 @@ class Component
}
public function getTemplateName($_registry/*: \ctiso\Settings*/) {
return (isset($_COOKIE['with_template']) && preg_match('/^[\w\d-]{3,20}$/', $_COOKIE['with_template']))
return (isset($_COOKIE['with_template']) && preg_match('/^[\w\d-]{3,20}$/', $_COOKIE['with_template']))
? $_COOKIE['with_template'] : ($_registry ? $_registry->get('site', 'template') : 'modern');
}
}
public function getView($name)
{
if ($this->output == 'json') {
return new FakeTemplate($name);
}
$config/*: Registry*/ = $this->config;
$default = $config->get('site', 'template');
$template = ($this->template) ? $this->template : $this->getTemplateName($config);
@ -113,12 +113,12 @@ class Component
$tpl->setPhpCodeDestination(PHPTAL_PHP_CODE_DESTINATION);
$selected = $index;
break;
}
}
}
if ($selected === null) {
// Последний вариант viewPath, путь к папке компонента
$selected = count($this->viewPath) - 1;
$selected = count($this->viewPath) - 1;
$tpl = new PHPTAL(Path::join($this->viewPath[$selected], 'templates', 'modern', $name));
$tpl->setPhpCodeDestination(PHPTAL_PHP_CODE_DESTINATION);
$template = 'modern';
@ -156,7 +156,7 @@ class Component
return Path::join($this->viewPath[$index], 'templates', $template, $name);
}
}
return Path::join($this->viewPath[count($this->viewPath) - 1], 'templates', 'modern', $name);
}
@ -167,7 +167,7 @@ class Component
/**
* Создает модель
* @param string $name
* @param string $name
* @return mixed
*/
public function getModel($name)
@ -198,7 +198,7 @@ class Component
function findFile($pathList, $name) {
foreach($pathList as $item) {
$filename = Path::join($item, $name);
if (file_exists($filename)) {
if (file_exists($filename)) {
return $filename;
}
}
@ -233,15 +233,14 @@ class Component
static function loadComponent($expression, $site/*: SiteInterface*/)
{
$expression = htmlspecialchars_decode($expression);
$offset = strpos($expression, '?');
$url = parse_url($expression);
$arguments = [];
if ($offset === false) {
$path = $expression;
} else if (is_int($offset)) {
$path = $expression;
if (is_int($offset)) {
$path = substr($expression, 0, $offset);
$query = substr($expression, $offset + 1);
parse_str($query, $arguments);
@ -254,10 +253,10 @@ class Component
$className = implode("\\", ['Components', ucfirst($name), $filename]);
$component/*: Component*/ = null;
if (file_exists($path)) {
// require_once ($path);
$component = new $className();
$component = new $className();
$component->viewPath = [$config->get('site', 'components') . '/' . $name . '/'];
$component->webPath = [$config->get('site', 'components.web') . '/' . $name];
@ -272,30 +271,30 @@ class Component
$config->get('site', 'templates') . '/'. $template . '/_components/' . $name . '/',
$config->get('site', 'components') . '/' . $name . '/',
// Потом в общем хранилище
$config->get('system', 'templates'). '/' . $template . '/_components/' . $name . '/',
$config->get('system', 'components') . '/' . $name . '/',
$config->get('system', 'templates'). '/' . $template . '/_components/' . $name . '/',
$config->get('system', 'components') . '/' . $name . '/',
];
if (defined('COMPONENTS_WEB')) {
$component->webPath = [
// Сначало локально
$config->get('site', 'templates.web') . '/' . $template . '/_components/' . $name,
$config->get('site', 'components.web') . '/' . $name,
// Потом в общем хранилище
// Потом в общем хранилище
$config->get('system', 'templates.web') . '/' . $template . '/_components/' . $name,
$config->get('system', 'components.web') . '/' . $name,
$config->get('system', 'components.web') . '/' . $name,
];
$component->COMPONENTS_WEB = $config->get('system', 'components.web');
} else {
$component->webPath = ['', $config->get('site', 'components.web') . '/' . $name, '', ''];
}
}
}
$db = $site->getDatabase();
$component->db = $db;
$component->config = $site->config;
$component->site = $site;
$stmt = $db->prepareStatement("SELECT * FROM component WHERE code = ?");
$stmt->setString(1, $expression);
$cid = $stmt->executeQuery();
@ -339,7 +338,7 @@ class Component
return null;
}
function raw_query($request/*: ComponentRequest*/)
function raw_query($request/*: ComponentRequest*/)
{
$arr = $request->r->export('get');
@ -362,7 +361,7 @@ class Component
}
function query($request/*: ComponentRequest*/, $list)
function query($request/*: ComponentRequest*/, $list)
{
$arr = $request->r->export('get');