Merge branch 'noglob' into php8

This commit is contained in:
origami11@yandex.ru 2024-01-09 12:03:17 +03:00
commit 3a2b273adc
9 changed files with 76 additions and 42 deletions

View file

@ -78,10 +78,11 @@ class Front extends Action
$module->front = $this;
// Ведение лога
$logger = new ActionLogger($module, $logPath, $this->user);
$logger->before = $this->loadSettings(Path::join($modPath, 'filter', 'logger.php'));
$filename = Path::join($modPath, 'filters', 'logger.json');
$logger->before = $this->loadSettings($filename);
// Управление доступом
$module->access = new ActionAccess($logger, $this->user);
$module->access->access = $this->loadSettings(Path::join($modPath, 'filter', 'access.php'));
$module->access->access = $this->loadSettings(Path::join($modPath, 'filters', 'access.json'));
$module->setUp();

View file

@ -28,14 +28,14 @@ class Installer
return $setup;
}
function getUninstallFile($name){
function getUninstallFile($name) {
return Path::join(call_user_func($this->installPath, $name), "sql", "uninstall.json");
}
// Проверка версии обновления
function isChanged($name) // Информация о модулях
{
$item = $this->_registry->get('system', $name);
$item = $this->_registry->get($name);
if ($item) {
$setup = $this->getSetupFile($name);
if (file_exists($setup) && (filemtime($setup) > $item['time'])) {
@ -78,10 +78,11 @@ class Installer
if (file_exists($setup) && ($this->isChanged($name) || $force)) {
$registry = $this->_registry;
$settings = new Settings($setup);
$settings->read();
$item = $registry->get('system', $name);
$item = $registry->get($name);
$version_new = $settings->get('version');
if ($item) {
@ -106,7 +107,7 @@ class Installer
'version' => $version_new,
'time' => filemtime($setup)
]);
$registry->writeKey([$name], $settings->get('settings'));
// $registry->writeKey([$name], $settings->export());
$registry->write();
}

View file

@ -63,8 +63,10 @@ class JsonInstall {
$table_name = $action["table_name"];
if (isset($refs[$table_name])) {
foreach ($refs[$table_name] as $value) {
$action['fields'][$value['column']]['references'] =
$value['refTable']."(".$value['refColumn'].")";
$action['fields'][$value['column']]['references'] = [
"refTable" => $value['refTable'],
'refColumn' => $value['refColumn']
];
}
}

View file

@ -145,7 +145,7 @@ class Manager
$constraint = isset($data['constraint']) ? " ".$data['constraint'] : "";
$references = "";
if (isset($data['references'])) {
$references = " REFERENCES ".$data['references'];
$references = " REFERENCES " . $data['references']['refTable'] . '(' .$data['references']['refColumn'] . ')';
}
if (isset($data["not_null"]) && $data["not_null"]) {
$constraint .=" NOT NULL";

View file

@ -202,7 +202,7 @@ class Login extends Filter
$module = $request->get('module');
$action = $request->get('action');
$moduleDir = explode('_',$module)[0];
$moduleDir = explode('\\',$module)[0];
$file = Path::join($this->config->get('system', 'path'), 'modules', $moduleDir, 'filters', 'white.json');
if (file_exists($file)) {
$whiteList = json_decode(file_get_contents($file), true);

View file

@ -59,7 +59,7 @@ class Tales {
/**
* Функция подключения компонента
*/
static function phptal_component ($expression) {
static function phptal_component($expression) {
$begin = floatval(microtime(true));
$component/*: Component*/ = null;

View file

@ -0,0 +1,21 @@
<?php
/**
*/
namespace ctiso\Validator\Rule;
use ctiso\Validator\Rule\AbstractRule,
ctiso\Collection;
class PregMatch extends AbstractRule
{
public $pattern;
public function getErrorMsg()
{
return "Поле в неправильном формате";
}
public function isValid(Collection $container, $status = null)
{
return preg_match($this->pattern,$container->get($this->field));
}
}

View file

@ -14,11 +14,31 @@ class Validator
{
protected $chain = array(); // Массив правил
protected $errorMsg = array(); // Массив ошибок
protected $type = array(
'date' => 'ctiso\\Validator\\Rule\\Date',
'email' => 'ctiso\\Validator\\Rule\\Email',
'emaillist'=> 'ctiso\\Validator\\Rule\\EmailList',
'match' => 'ctiso\\Validator\\Rule\\MatchRule',
'time' => 'ctiso\\Validator\\Rule\\Time',
'alpha' => 'ctiso\\Validator\\Rule\\Alpha',
'require' => 'ctiso\\Validator\\Rule\\Notnull',
'numeric' => 'ctiso\\Validator\\Rule\\Numeric',
'unique' => 'ctiso\\Validator\\Rule\\Unique',
'filename' => 'ctiso\\Validator\\Rule\\FileName',
'count' => 'ctiso\\Validator\\Rule\\Count',
'isfile' => 'ctiso\\Validator\\Rule\\IsFile',
'code' => 'ctiso\\Validator\\Rule\\Code',
'reg' => 'ctiso\\Validator\\Rule\\PregMatch',
);
function __construct($rules = array()) {
$this->addRuleList($rules);
}
function addRuleType($name, $className) {
$this->type[$name] = $className;
}
/**
* Добавление списка правил в специальном формате
* array(array('name' => fieldname, 'validate' => ruletext), ...)
@ -27,22 +47,6 @@ class Validator
*/
public function addRuleList(array $input)
{
$type = array(
'date' => 'ctiso\\Validator\\Rule\\Date',
'email' => 'ctiso\\Validator\\Rule\\Email',
'emaillist'=> 'ctiso\\Validator\\Rule\\EmailList',
'match' => 'ctiso\\Validator\\Rule\\MatchRule',
'time' => 'ctiso\\Validator\\Rule\\Time',
'alpha' => 'ctiso\\Validator\\Rule\\Alpha',
'require' => 'ctiso\\Validator\\Rule\\Notnull',
'numeric' => 'ctiso\\Validator\\Rule\\Numeric',
'unique' => 'ctiso\\Validator\\Rule\\Unique',
'filename' => 'ctiso\\Validator\\Rule\\FileName',
'count' => 'ctiso\\Validator\\Rule\\Count',
'isfile' => 'ctiso\\Validator\\Rule\\IsFile',
'code' => 'ctiso\\Validator\\Rule\\Code'
);
// Разбор правила проверки
// Формат правила 'rule1|rule2,param1=value1|rule3,param1=value1,param2=value2'
foreach ($input as $value) {
@ -55,8 +59,8 @@ class Validator
$rule_param = explode(",", $rule);
$name = array_shift($rule_param);
if (isset($type[$name])) {
$constructor = $type[$name];
if (isset($this->type[$name])) {
$constructor = $this->type[$name];
$ruleObj = new $constructor($value['name'], false); // Нужны шаблонные сообщения для правил
if (isset($value['context'])) {
$ruleObj->setContext($value['context']);
@ -74,7 +78,7 @@ class Validator
}
}
public function addRule($rule/*: any*/) {
public function addRule($rule/*:z any*/) {
if (is_array($rule)) {
$this->chain = array_merge($this->chain, $rule);
} else {
@ -82,7 +86,7 @@ class Validator
}
}
public function skip($rule/*: AbstractRule*/, $container/*: Collection*/) // -> Rule_Abstract
public function skip($rule/*z: AbstractRule*/, $container/*: Collection*/) // -> Rule_Abstract
{
if ($rule->skipEmpty()) {
$data = $container->get($rule->field);

View file

@ -15,8 +15,9 @@ class View
protected $_title = null; // Заголовок текущего шаблона
public $active_module;
public $module_action;
public $active_module;
public $module_action;
public $prefix;
public $suggestions; //подсказки
@ -59,7 +60,7 @@ class View
*/
public function addScript($name)
{
$output = $this->resolveName($this->alias, $name);
$output = $this->resolveName($this->alias, $name . '?' . http_build_query($this->prefix));
$this->_script [] = $output;
}
@ -77,6 +78,10 @@ class View
}
}
public function setPrefix($name, $val) {
$this->prefix[$name] = $val;
}
/**
* Добавляет стили к текущему шаблону
*
@ -84,7 +89,7 @@ class View
*/
public function addStyleSheet($name)
{
$output = $this->resolveName($this->alias, $name);
$output = $this->resolveName($this->alias, $name . '?' . http_build_query($this->prefix));
$this->_stylesheet [] = $output;
}