Отступы

This commit is contained in:
Origami11 2021-03-26 16:54:38 +03:00
parent cdf7527c43
commit 085820d78c
5 changed files with 71 additions and 62 deletions

View file

@ -57,6 +57,7 @@ class Controller_Component
public /*.Settings.*/$registry; public /*.Settings.*/$registry;
public /*.Database.*/$db; public /*.Database.*/$db;
public /*.Collection.*/$parameter; public /*.Collection.*/$parameter;
static public $ID;
public $module; public $module;
public $item_module; public $item_module;
@ -246,11 +247,16 @@ class Controller_Component
} }
} }
$stmt = $db->prepareStatement("SELECT * FROM component WHERE code = ?"); // Нужно для отличия компонентов на странице нужно извлекать id для всей страницы сразу?
$stmt->setString(1, $expression); // Просто вести глобальный счетчик для компонентов
$cid = $stmt->executeQuery();
if ($cid->next()) { $component->component_id = self::$ID++;
$component->component_id = $cid->getInt('id_component'); /*
$stmt = $db->prepare("SELECT * FROM component WHERE code = :code");
$stmt->execute(['code' => $expression]);
$cid = $stmt->fetch();
if ($cid) {
$component->component_id = $cid['id_component'];
} else { } else {
$last = $db->getIdGenerator(); $last = $db->getIdGenerator();
if ($last->isBeforeInsert()) { if ($last->isBeforeInsert()) {
@ -269,6 +275,7 @@ class Controller_Component
} }
$component->component_id = $result; $component->component_id = $result;
} }
*/
$params = new Collection(); $params = new Collection();
$params->import(array_merge($_GET, $arguments)); $params->import(array_merge($_GET, $arguments));

View file

@ -100,8 +100,7 @@ class Database extends PDO
return $sth->fetch(PDO::FETCH_ASSOC); return $sth->fetch(PDO::FETCH_ASSOC);
} }
private static function assignQuote($x, $y) function assignQuote($x, $y) {
{
return $x . "=" . $this->quote($y); return $x . "=" . $this->quote($y);
} }

View file

@ -95,6 +95,9 @@ class Database_PDOStatement extends PDOStatement implements IteratorAggregate
function execute($args = null) { function execute($args = null) {
$result = parent::execute($args); $result = parent::execute($args);
if (class_exists('Log')) {
Log::add('execute', [$this->queryString, $args]);
}
return $result; return $result;
} }

View file

@ -143,7 +143,7 @@ class Tools_SQLStatementExtractor {
trigger_error("substring(), Endindex out of bounds must be $startpos<n<".($len-1), E_USER_ERROR); trigger_error("substring(), Endindex out of bounds must be $startpos<n<".($len-1), E_USER_ERROR);
} }
if ($startpos === $endpos) { if ($startpos === $endpos) {
return (string) $string{$startpos}; return (string) $string[$startpos];
} else { } else {
$len = $endpos-$startpos; $len = $endpos-$startpos;
} }

View file

@ -4,53 +4,53 @@ class Tools_String {
// from creole // from creole
static function strToArray($str) { static function strToArray($str) {
$str = substr($str, 1, -1); // remove { } $str = substr($str, 1, -1); // remove { }
$res = array(); $res = array();
$subarr = array(); $subarr = array();
$in_subarr = 0; $in_subarr = 0;
$toks = explode(',', $str); $toks = explode(',', $str);
foreach($toks as $tok) { foreach($toks as $tok) {
if ($in_subarr > 0) { // already in sub-array? if ($in_subarr > 0) { // already in sub-array?
$subarr[$in_subarr][] = $tok; $subarr[$in_subarr][] = $tok;
if ('}' === substr($tok, -1, 1)) { // check to see if we just added last component if ('}' === substr($tok, -1, 1)) { // check to see if we just added last component
$res[] = static::strToArray(implode(',', $subarr[$in_subarr])); $res[] = static::strToArray(implode(',', $subarr[$in_subarr]));
$in_subarr--; $in_subarr--;
} }
} elseif ($tok{0} === '{') { // we're inside a new sub-array } elseif ($tok[0] === '{') { // we're inside a new sub-array
if ('}' !== substr($tok, -1, 1)) { if ('}' !== substr($tok, -1, 1)) {
$in_subarr++; $in_subarr++;
// if sub-array has more than one element // if sub-array has more than one element
$subarr[$in_subarr] = array(); $subarr[$in_subarr] = array();
$subarr[$in_subarr][] = $tok; $subarr[$in_subarr][] = $tok;
} else { } else {
$res[] = static::strToArray($tok); $res[] = static::strToArray($tok);
} }
} else { // not sub-array } else { // not sub-array
$val = trim($tok, '"'); // remove " (surrounding strings) $val = trim($tok, '"'); // remove " (surrounding strings)
// perform type castng here? // perform type castng here?
$res[] = $val; $res[] = $val;
} }
} }
return $res; return $res;
} }
//Нормализация строк на русском //Нормализация строк на русском
static function normalizeRussian($str) { static function normalizeRussian($str) {
$result = preg_replace('/\s+/',' ', $str); $result = preg_replace('/\s+/',' ', $str);
if (is_string($result)) { if (is_string($result)) {
$result = trim($result); //Замена длинных пробелов на одинарные, пробелы по краям $result = trim($result); //Замена длинных пробелов на одинарные, пробелы по краям
$result = mb_strtolower($result); $result = mb_strtolower($result);
$result = preg_replace('/ё/','е', $str); //е на ё $result = preg_replace('/ё/','е', $str); //е на ё
} }
return $result; return $result;
} }
//Проверка равенства двух строк на русском языке. //Проверка равенства двух строк на русском языке.
static function equalRussianCheck($str1,$str2) { static function equalRussianCheck($str1,$str2) {
return self::normalizeRussian($str1) == self::normalizeRussian($str2); return self::normalizeRussian($str1) == self::normalizeRussian($str2);
} }