Merge branch 'noglob' into php8
This commit is contained in:
commit
3a2b273adc
9 changed files with 76 additions and 42 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Installer
|
|||
// Проверка версии обновления
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
21
src/Validator/Rule/PregMatch.php
Normal file
21
src/Validator/Rule/PregMatch.php
Normal 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));
|
||||
}
|
||||
}
|
||||
|
|
@ -14,20 +14,7 @@ class Validator
|
|||
{
|
||||
protected $chain = array(); // Массив правил
|
||||
protected $errorMsg = array(); // Массив ошибок
|
||||
|
||||
function __construct($rules = array()) {
|
||||
$this->addRuleList($rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавление списка правил в специальном формате
|
||||
* array(array('name' => fieldname, 'validate' => ruletext), ...)
|
||||
* fieldname - Имя переменой для проверки
|
||||
* ruletext - Описание правила см. формат правила ниже
|
||||
*/
|
||||
public function addRuleList(array $input)
|
||||
{
|
||||
$type = array(
|
||||
protected $type = array(
|
||||
'date' => 'ctiso\\Validator\\Rule\\Date',
|
||||
'email' => 'ctiso\\Validator\\Rule\\Email',
|
||||
'emaillist'=> 'ctiso\\Validator\\Rule\\EmailList',
|
||||
|
|
@ -40,9 +27,26 @@ class Validator
|
|||
'filename' => 'ctiso\\Validator\\Rule\\FileName',
|
||||
'count' => 'ctiso\\Validator\\Rule\\Count',
|
||||
'isfile' => 'ctiso\\Validator\\Rule\\IsFile',
|
||||
'code' => 'ctiso\\Validator\\Rule\\Code'
|
||||
'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), ...)
|
||||
* fieldname - Имя переменой для проверки
|
||||
* ruletext - Описание правила см. формат правила ниже
|
||||
*/
|
||||
public function addRuleList(array $input)
|
||||
{
|
||||
// Разбор правила проверки
|
||||
// Формат правила '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);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class View
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue