первая версия разработана и готова к использованию

This commit is contained in:
Arsen Mirzaev Tatyano-Muradovich 2023-02-22 08:52:25 +10:00
parent 3ddb3ced6a
commit f5fed3c6d5
20 changed files with 839 additions and 135 deletions

View File

@ -23,12 +23,13 @@
},
"require": {
"php": "~8.2",
"ext-sodium": "~8.2",
"mirzaev/minimal": "^2.0.x-dev",
"mirzaev/arangodb": "^1.0.0",
"triagens/arangodb": "~3.9.x-dev",
"twig/twig": "^3.4",
"guzzlehttp/guzzle": "^7.5"
"guzzlehttp/guzzle": "^7.5",
"twig/markdown-extra": "^3.5",
"league/commonmark": "^2.3"
},
"require-dev": {
"phpunit/phpunit": "~9.5"

623
composer.lock generated
View File

@ -4,8 +4,83 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "eb3974d37e16f19a4c1ca43c8ac73a61",
"content-hash": "b258b9722fd93eec6dac0f7fb73cd0fb",
"packages": [
{
"name": "dflydev/dot-access-data",
"version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/dflydev/dflydev-dot-access-data.git",
"reference": "f41715465d65213d644d3141a6a93081be5d3549"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/f41715465d65213d644d3141a6a93081be5d3549",
"reference": "f41715465d65213d644d3141a6a93081be5d3549",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.42",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.3",
"scrutinizer/ocular": "1.6.0",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^4.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Dflydev\\DotAccessData\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Dragonfly Development Inc.",
"email": "info@dflydev.com",
"homepage": "http://dflydev.com"
},
{
"name": "Beau Simensen",
"email": "beau@dflydev.com",
"homepage": "http://beausimensen.com"
},
{
"name": "Carlos Frutos",
"email": "carlos@kiwing.it",
"homepage": "https://github.com/cfrutos"
},
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com"
}
],
"description": "Given a deep data structure, access data by dot notation.",
"homepage": "https://github.com/dflydev/dflydev-dot-access-data",
"keywords": [
"access",
"data",
"dot",
"notation"
],
"support": {
"issues": "https://github.com/dflydev/dflydev-dot-access-data/issues",
"source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.2"
},
"time": "2022-10-27T11:44:00+00:00"
},
{
"name": "guzzlehttp/guzzle",
"version": "7.5.0",
@ -337,6 +412,194 @@
],
"time": "2022-10-26T14:07:24+00:00"
},
{
"name": "league/commonmark",
"version": "2.3.9",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "c1e114f74e518daca2729ea8c4bf1167038fa4b5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/c1e114f74e518daca2729ea8c4bf1167038fa4b5",
"reference": "c1e114f74e518daca2729ea8c4bf1167038fa4b5",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"league/config": "^1.1.1",
"php": "^7.4 || ^8.0",
"psr/event-dispatcher": "^1.0",
"symfony/deprecation-contracts": "^2.1 || ^3.0",
"symfony/polyfill-php80": "^1.16"
},
"require-dev": {
"cebe/markdown": "^1.0",
"commonmark/cmark": "0.30.0",
"commonmark/commonmark.js": "0.30.0",
"composer/package-versions-deprecated": "^1.8",
"embed/embed": "^4.4",
"erusev/parsedown": "^1.0",
"ext-json": "*",
"github/gfm": "0.29.0",
"michelf/php-markdown": "^1.4 || ^2.0",
"nyholm/psr7": "^1.5",
"phpstan/phpstan": "^1.8.2",
"phpunit/phpunit": "^9.5.21",
"scrutinizer/ocular": "^1.8.1",
"symfony/finder": "^5.3 | ^6.0",
"symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0",
"unleashedtech/php-coding-standard": "^3.1.1",
"vimeo/psalm": "^4.24.0 || ^5.0.0"
},
"suggest": {
"symfony/yaml": "v2.3+ required if using the Front Matter extension"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.4-dev"
}
},
"autoload": {
"psr-4": {
"League\\CommonMark\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com",
"role": "Lead Developer"
}
],
"description": "Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)",
"homepage": "https://commonmark.thephpleague.com",
"keywords": [
"commonmark",
"flavored",
"gfm",
"github",
"github-flavored",
"markdown",
"md",
"parser"
],
"support": {
"docs": "https://commonmark.thephpleague.com/",
"forum": "https://github.com/thephpleague/commonmark/discussions",
"issues": "https://github.com/thephpleague/commonmark/issues",
"rss": "https://github.com/thephpleague/commonmark/releases.atom",
"source": "https://github.com/thephpleague/commonmark"
},
"funding": [
{
"url": "https://www.colinodell.com/sponsor",
"type": "custom"
},
{
"url": "https://www.paypal.me/colinpodell/10.00",
"type": "custom"
},
{
"url": "https://github.com/colinodell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/league/commonmark",
"type": "tidelift"
}
],
"time": "2023-02-15T14:07:24+00:00"
},
{
"name": "league/config",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/config.git",
"reference": "754b3604fb2984c71f4af4a9cbe7b57f346ec1f3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/config/zipball/754b3604fb2984c71f4af4a9cbe7b57f346ec1f3",
"reference": "754b3604fb2984c71f4af4a9cbe7b57f346ec1f3",
"shasum": ""
},
"require": {
"dflydev/dot-access-data": "^3.0.1",
"nette/schema": "^1.2",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.8.2",
"phpunit/phpunit": "^9.5.5",
"scrutinizer/ocular": "^1.8.1",
"unleashedtech/php-coding-standard": "^3.1",
"vimeo/psalm": "^4.7.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.2-dev"
}
},
"autoload": {
"psr-4": {
"League\\Config\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com",
"role": "Lead Developer"
}
],
"description": "Define configuration arrays with strict schemas and access values with dot notation",
"homepage": "https://config.thephpleague.com",
"keywords": [
"array",
"config",
"configuration",
"dot",
"dot-access",
"nested",
"schema"
],
"support": {
"docs": "https://config.thephpleague.com/",
"issues": "https://github.com/thephpleague/config/issues",
"rss": "https://github.com/thephpleague/config/releases.atom",
"source": "https://github.com/thephpleague/config"
},
"funding": [
{
"url": "https://www.colinodell.com/sponsor",
"type": "custom"
},
{
"url": "https://www.paypal.me/colinpodell/10.00",
"type": "custom"
},
{
"url": "https://github.com/colinodell",
"type": "github"
}
],
"time": "2022-12-11T20:36:23+00:00"
},
{
"name": "mirzaev/arangodb",
"version": "1.0.2",
@ -432,6 +695,205 @@
},
"time": "2022-11-03T06:09:32+00:00"
},
{
"name": "nette/schema",
"version": "v1.2.3",
"source": {
"type": "git",
"url": "https://github.com/nette/schema.git",
"reference": "abbdbb70e0245d5f3bf77874cea1dfb0c930d06f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/schema/zipball/abbdbb70e0245d5f3bf77874cea1dfb0c930d06f",
"reference": "abbdbb70e0245d5f3bf77874cea1dfb0c930d06f",
"shasum": ""
},
"require": {
"nette/utils": "^2.5.7 || ^3.1.5 || ^4.0",
"php": ">=7.1 <8.3"
},
"require-dev": {
"nette/tester": "^2.3 || ^2.4",
"phpstan/phpstan-nette": "^1.0",
"tracy/tracy": "^2.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0-only",
"GPL-3.0-only"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "📐 Nette Schema: validating data structures against a given Schema.",
"homepage": "https://nette.org",
"keywords": [
"config",
"nette"
],
"support": {
"issues": "https://github.com/nette/schema/issues",
"source": "https://github.com/nette/schema/tree/v1.2.3"
},
"time": "2022-10-13T01:24:26+00:00"
},
{
"name": "nette/utils",
"version": "v4.0.0",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "cacdbf5a91a657ede665c541eda28941d4b09c1e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/cacdbf5a91a657ede665c541eda28941d4b09c1e",
"reference": "cacdbf5a91a657ede665c541eda28941d4b09c1e",
"shasum": ""
},
"require": {
"php": ">=8.0 <8.3"
},
"conflict": {
"nette/finder": "<3",
"nette/schema": "<1.2.2"
},
"require-dev": {
"jetbrains/phpstorm-attributes": "dev-master",
"nette/tester": "^2.4",
"phpstan/phpstan": "^1.0",
"tracy/tracy": "^2.9"
},
"suggest": {
"ext-gd": "to use Image",
"ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()",
"ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()",
"ext-json": "to use Nette\\Utils\\Json",
"ext-mbstring": "to use Strings::lower() etc...",
"ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()",
"ext-xml": "to use Strings::length() etc. when mbstring is not available"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0-only",
"GPL-3.0-only"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
"homepage": "https://nette.org",
"keywords": [
"array",
"core",
"datetime",
"images",
"json",
"nette",
"paginator",
"password",
"slugify",
"string",
"unicode",
"utf-8",
"utility",
"validation"
],
"support": {
"issues": "https://github.com/nette/utils/issues",
"source": "https://github.com/nette/utils/tree/v4.0.0"
},
"time": "2023-02-02T10:41:53+00:00"
},
{
"name": "psr/event-dispatcher",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/event-dispatcher.git",
"reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
"reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
"shasum": ""
},
"require": {
"php": ">=7.2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\EventDispatcher\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Standard interfaces for event handling.",
"keywords": [
"events",
"psr",
"psr-14"
],
"support": {
"issues": "https://github.com/php-fig/event-dispatcher/issues",
"source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0"
},
"time": "2019-01-08T18:20:26+00:00"
},
{
"name": "psr/http-client",
"version": "1.0.1",
@ -868,6 +1330,89 @@
],
"time": "2022-11-03T14:55:06+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.27.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.27-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ion Bazan",
"email": "ion.bazan@gmail.com"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-11-03T14:55:06+00:00"
},
{
"name": "triagens/arangodb",
"version": "3.9.x-dev",
@ -929,6 +1474,79 @@
},
"time": "2022-10-21T15:30:53+00:00"
},
{
"name": "twig/markdown-extra",
"version": "v3.5.1",
"source": {
"type": "git",
"url": "https://github.com/twigphp/markdown-extra.git",
"reference": "9474c89fd2787187a3809e5e964dfce2395ae5f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/markdown-extra/zipball/9474c89fd2787187a3809e5e964dfce2395ae5f0",
"reference": "9474c89fd2787187a3809e5e964dfce2395ae5f0",
"shasum": ""
},
"require": {
"php": ">=7.1.3",
"twig/twig": "^2.7|^3.0"
},
"require-dev": {
"erusev/parsedown": "^1.7",
"league/commonmark": "^1.0|^2.0",
"league/html-to-markdown": "^4.8|^5.0",
"michelf/php-markdown": "^1.8|^2.0",
"symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.5-dev"
}
},
"autoload": {
"psr-4": {
"Twig\\Extra\\Markdown\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
}
],
"description": "A Twig extension for Markdown",
"homepage": "https://twig.symfony.com",
"keywords": [
"html",
"markdown",
"twig"
],
"support": {
"source": "https://github.com/twigphp/markdown-extra/tree/v3.5.1"
},
"funding": [
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
"type": "tidelift"
}
],
"time": "2023-02-08T07:44:55+00:00"
},
{
"name": "twig/twig",
"version": "v3.5.1",
@ -2747,8 +3365,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": "~8.2",
"ext-sodium": "~8.2"
"php": "~8.2"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"

View File

@ -0,0 +1,40 @@
{% extends "core.html" %}
{% use "core.html" with css as core_css, body as core_body, js as core_js, js_init as core_js_init %}
{% use "header.html" with css as header_css, body as header_body, js as header_js, js_init as header_js_init %}
{% block css %}
{{ block('core_css') }}
{{ block('header_css') }}
{% endblock %}
{% block body %}
{{ block('core_body') }}
{{ block('header_body') }}
<main>
{% block main %}
{% include 'search.html' %}
{% if errors is not empty %}<h3>Журнал</h3>{% endif %}
{% for error in errors %}
<ul>
{% for data in error %}
<ol>{{ data.text }}</ol>
{% endfor %}
</ul>
{% endfor %}
{% endblock %}
</main>
{# {% include 'footer.html' %} #}
{% endblock %}
{% block js %}
{{ block('core_js') }}
{{ block('header_js') }}
{% endblock %}
{% block js_init %}
{{ block('core_js_init') }}
{{ block('header_js_init') }}
{% endblock %}

View File

@ -5,7 +5,9 @@ declare(strict_types=1);
namespace mirzaev\site\stdm\registry\controllers;
// Файлы проекта
use mirzaev\site\stdm\registry\controllers\core;
use mirzaev\site\stdm\registry\controllers\core,
mirzaev\site\stdm\registry\models\account_model as account,
mirzaev\site\stdm\registry\models\part_model as part;
/**
* Контроллер основной страницы
@ -15,57 +17,34 @@ use mirzaev\site\stdm\registry\controllers\core;
*/
final class index_controller extends core
{
/**
* Главная страница
*
* @param array $parameters Параметры запроса
*/
public function index(array $parameters = []): ?string
{
// Инициализация загружаемых категорий
$this->variables['include'] = [
'head' => ['self'],
'body' => ['self']
];
/**
* Главная страница
*
* @param array $parameters Параметры запроса
*/
public function index(array $parameters = []): ?string
{
// Инициализация журнала ошибок
$this->variables['errors']['search'] = [];
// Инициализация бегущей строки
$this->variables['hotline'] = [
'id' => $this->variables['request']['id'] ?? 'hotline'
];
if (!empty($parameters['key']) && !empty($parameters['search'])) {
// Получены данные поиска
// Инициализация параметров бегущей строки
$this->variables['hotline']['parameters'] = [
// 'step' => 2
];
if (account::authorization($parameters['key'], $this->variables['errors']['account'])) {
// Авторизован запрос
// Инициализация аттрибутов бегущей строки
$this->variables['hotline']['attributes'] = [
];
// Инициализация элементов бегущей строки
$this->variables['hotline']['elements'] = [
['content' => '1'],
[
'tag' => 'article',
'content' => '2'
],
['content' => '3'],
['content' => '4'],
['content' => '5'],
['content' => '6'],
['content' => '7'],
['content' => '8'],
['content' => '9'],
['content' => '10'],
['content' => '11'],
['content' => '12'],
['content' => '13'],
['content' => '14'],
['content' => '15']
];
// Генерация представления
return $this->view->render(DIRECTORY_SEPARATOR . 'index.html', $this->variables);
// Поиск данных запчасти и запись в переменную
$this->variables['result'] = part::search($parameters['search'], $this->variables['errors']['search'])->body ?? null;
}
}
// Инициализация переменных
$this->variables['key'] = $parameters['key'] ?? '';
$this->variables['search'] = $parameters['search'] ?? '';
/* var_dump($this->variables); die; */
// Генерация представления
return $this->view->render(DIRECTORY_SEPARATOR . 'index.html', $this->variables);
}
}

View File

@ -1,29 +0,0 @@
<?php
declare(strict_types=1);
namespace mirzaev\site\stdm\registry\controllers;
// Файлы проекта
use mirzaev\site\stdm\registry\controllers\core,
mirzaev\site\stdm\registry\models\keys_model as key,
mirzaev\site\stdm\registry\models\account_model as account;
/**
* Контроллер поиска
*
* @package mirzaev\site\stdm\registry\controllers
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class search_controller extends core
{
/**
* Поиск
*
* @param array $parameters Параметры запроса
*/
public function search(array $parameters = []): ?string {
var_dump(account::authorization($parameters['key'], $this->variables['errors']['account']));
return null;
}
}

View File

@ -1,29 +0,0 @@
<?php
declare(strict_types=1);
namespace mirzaev\site\stdm\registry\models;
// Фреймворк ArangoDB
use mirzaev\arangodb\collection,
mirzaev\arangodb\document;
// Библиотека для ArangoDB
use ArangoDBClient\Document as _document;
// Встроенные библиотеки
use exception;
/**
* Модель ключей доступа
*
* @package mirzaev\site\stdm\registry\models
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class keys_model extends core
{
/**
* Коллекция
*/
public const COLLECTION = 'keys';
}

View File

@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
namespace mirzaev\site\stdm\registry\models;
// Фреймворк ArangoDB
use mirzaev\arangodb\collection,
mirzaev\arangodb\document;
// Библиотека для ArangoDB
use ArangoDBClient\Document as _document;
// Встроенные библиотеки
use exception;
/**
* Модель запчастей
*
* @package mirzaev\site\stdm\registry\models
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class part_model extends core
{
/**
* Коллекция
*/
public const COLLECTION = 'part';
/**
* Коллекция представления
*/
public const COLLECTION_VIEW = 'search_part';
/**
* Поиск
*
* @param string $text Текст поиска
* @param array &$errors Журнал ошибок
*
* @return ?_document Инстанция запчасти, если найдена
*/
public static function search(string $text, array &$errors = []): ?_document {
try {
if (collection::init(static::$db->session, self::COLLECTION)) {
// Инициализированы коллекции
if ($part = collection::search(static::$db->session, sprintf(
<<<AQL
FOR document in %s
SEARCH ANALYZER(
LEVENSHTEIN_MATCH(
document.body,
'%s',
3,
true
),
'text_en'
)
LIMIT 1
SORT BM25(document) DESC
return document
AQL,
static::COLLECTION_VIEW,
$text
))) {
// Найдена запчасть
return $part;
} else throw new exception('Не удалось найти запчасть');
} else throw new exception('Не удалось инициализировать коллекцию');
} catch (exception $e) {
// Запись в журнал ошибок
$errors[] = [
'text' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'stack' => $e->getTrace()
];
}
return null;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -141,22 +141,25 @@ main>form#panel>label>svg * {
color: var(--text-dark);
}
main>form#panel>section#result.inactive {
main>form#panel>section#result:has(> svg) {
cursor: not-allowed;
}
main>h3 {
text-align: center;
margin: 30px 0 20px 0;
}
main>ol {
margin: 50px 100px;
font-size: 1.2rem;
margin: 0px;
}
main>ol:last-of-type {
margin-bottom: 15px;
}
main>ol>li {
padding-left: 40px;
margin-bottom: 8px;
}
main>ol>li::marker {
/* font-size: 1.3rem; */
padding-left: 10px;
}
footer {

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -23,7 +23,6 @@ $router = new router;
// Запись маршрутов
$router->write('/', 'index', 'index');
$router->write('/search', 'search', 'search', 'POST');
// Инициализация ядра
$core = new core(namespace: __NAMESPACE__, router: $router);

View File

@ -0,0 +1 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}

View File

@ -2,6 +2,11 @@
<title>{% if head.title != empty %}{{head.title}}{% else %}Реестр запчастей{% endif %}</title>
{% endblock %}
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
{% block meta %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

View File

@ -15,6 +15,14 @@
<main>
{% block main %}
{% include 'search.html' %}
{% if errors.account is not empty or errors.search is not empty %}<h3>Журнал</h3>{% endif %}
{% for error in errors %}
<ol>
{% for data in error %}
<li>{{ data.text }}</li>
{% endfor %}
</ol>
{% endfor %}
{% endblock %}
</main>

View File

@ -4,22 +4,41 @@ declare(strict_types=1);
namespace mirzaev\site\stdm\registry\views;
// Файлы проекта
use mirzaev\minimal\controller;
use Twig\Loader\FilesystemLoader;
use Twig\Environment as view;
// Препроцессор для HTML
use Twig\Loader\FilesystemLoader,
Twig\Environment as view,
Twig\Extra\Markdown\MarkdownExtension,
Twig\Extra\Markdown\DefaultMarkdown,
Twig\Extra\Markdown\MarkdownRuntime,
Twig\RuntimeLoader\RuntimeLoaderInterface;
/**
* Менеджер представлений
*
* @package mirzaev\site\stdm\registry\controllers
* @package mirzaev\stdm\registry\virus\controllers
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class manager extends controller
{
public function render(string $file, array $vars = []): ?string
{
// Генерация представления
return (new view(new FilesystemLoader(VIEWS)))->render($file, $vars);
}
public function render(string $file, array $vars = []): ?string
{
// Инициализация ядра
$view = new view(new FilesystemLoader(VIEWS));
// Инициализация модулей
$view->addExtension(new MarkdownExtension);
$view->addRuntimeLoader(new class implements RuntimeLoaderInterface {
public function load($class) {
if (MarkdownRuntime::class === $class) {
return new MarkdownRuntime(new DefaultMarkdown());
}
}
});
// Генерация представления
return $view->render($file, $vars);
}
}

View File

@ -1,4 +1,4 @@
<form id="panel" action="/search" method="POST">
<form id="panel" action="/" method="GET">
<label>
<svg
id="icon_key"
@ -15,7 +15,7 @@
fill="currentColor"
/>
</svg>
<input type="text" name="key" id="key" placeholder="Ключ аутентификации">
<input type="text" name="key" id="key" placeholder="Ключ аутентификации" value="{{ key }}">
</label>
<label>
<svg
@ -33,10 +33,14 @@
fill="currentColor"
/>
</svg>
<input type="text" name="search" id="search" placeholder="Артикул">
<input type="text" name="search" id="search" placeholder="Артикул" value="{{ search }}">
<button type="submit">Поиск</button>
</label>
<section id="result" class="inactive">
<section id="result">
{% if result is not empty %}
{{ result|markdown_to_html }}
{% else %}
{{ result }}
<svg
id="icon_result"
width="80"
@ -69,6 +73,7 @@
d="M7.7572 17.6569L11.9998 13.4142L16.2425 17.6569L11.9998 21.8995L7.7572 17.6569ZM10.5856 17.6569L11.9998 16.2427L13.4141 17.6569L11.9998 19.0711L10.5856 17.6569Z"
fill="currentColor"
/>
{% endif %}
</svg>
</section>
</form>