This commit is contained in:
Bellord
2026-07-07 17:09:04 +03:00
commit 19eaeb4f4e
33 changed files with 792 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
.env
src/config.php
*_config.php
!default_config.php
src/Defines.php
src/*Defines.php
src/*Facade.php
!*.example
!.example
_utils
+9
View File
@@ -0,0 +1,9 @@
{
"id": "ixrs.catalog",
"prefix": "ixrs_catalog",
"namespace": "Ixrs\\Catalog",
"gitUrl": "https://bitbucket.org/bellord13/ixrs.catalog/",
"version": "1.0.0",
"date": "2026-07-07 00:00:00",
"deps": ["wt.core"]
}
+23
View File
@@ -0,0 +1,23 @@
<?php
IncludeModuleLangFile(__FILE__);
return [
'MAIN' => [
'TITLE' => GetMessage('MAIN_OPTIONS_PARAMETERS'),
'THEME' => 'Y',
'OPTIONS' => [
],
],
'TEST' => [
'TITLE' => 'test',
'OPTIONS' => [
'TEST' => [
'TITLE' => 'test_setting',
'TYPE' => 'text',
'DEFAULT' => '',
],
],
],
];
+9
View File
@@ -0,0 +1,9 @@
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_before.php');
require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_after.php');
$adminPage = new \Wt\Core\Admin\SiteSettingsAdminPage('ixrs.catalog', 'main');
$adminPage->render();
require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin.php');
+2
View File
@@ -0,0 +1,2 @@
<?php
$MESS['MAIN_OPTIONS_PARAMETERS'] = 'Общие';
+11
View File
@@ -0,0 +1,11 @@
<?php
use \Bitrix\Main\Localization\Loc;
use Wt\Core\Admin\GlobalMenuItem;
Loc::loadMessages(__FILE__);
return (new GlobalMenuItem())
->setSort(10)
->setTitle('Catalog Main');
+43
View File
@@ -0,0 +1,43 @@
<?php
use Wt\Core\Admin\SiteSettingsAdminPage;
IncludeModuleLangFile(__FILE__);
/**
* @var SiteSettingsAdminPage $this
*/
return [
'MAIN' => [
'TITLE' => 'Общие сведения',
'OPTIONS' => [
//'ENABLE' => [
// 'TITLE' => 'Enable module',
// 'TYPE' => 'checkbox',
// 'DEFAULT' => 'N',
// 'HINT' => '',
//],
'CONFIG' => [
'TITLE' => 'Конфигурационные данные',
'HINT' => '',
'TYPE' => 'content',
'INCLUDEFILE' => \Wt\Core\Tools::removeDocRoot(__DIR__ . '/include/config.php'),
'SHOW_EDIT_BUTTON' => 'N',
'DEFAULT' => '',
],
],
],
'DOCS' => [
'TITLE' => 'Docs',
'OPTIONS' => [
'DOCUMENTATION' => [
'TITLE' => 'Documentation',
'TYPE' => 'content',
'INCLUDEFILE' => \Wt\Core\Tools::removeDocRoot(__DIR__ . '/include/documentation.php'),
'SHOW_EDIT_BUTTON' => 'N',
'DEFAULT' => '',
],
],
],
];
@@ -0,0 +1,49 @@
<?php
/**
* @var Wt\Core\Admin\Templater $this
*/
$moduleId = $this->getAdminPage()->getModuleId();
$app = app()::getInstance($moduleId);
$data = [];
$data['env'] = $app->env();
?>
<table cellpadding="5" border="1" style="border-collapse: collapse; width: 100%">
<?php
foreach ($data as $key => $value) {
?><tr><td><?= $key ?></td><td><?= $value ?></td></tr><?php
}
?></table>
<br><?php
?><table cellpadding="5" border="1" style="border-collapse: collapse; width: 100%">
<tr>
<?php
$initPhpSrc = getLocalPath('php_interface/init.php', BX_PERSONAL_ROOT);
$src = $app->module()->getSrc();
$html = "<div style=\"font-family: monospace; font-size: 0.9em; white-space: pre; color: grey;\">if(file_exists(\$_SERVER['DOCUMENT_ROOT'] . '$src/init.php'))
include_once \$_SERVER['DOCUMENT_ROOT'] . '$src/init.php';</div>";
?>
<td>
<?=$this->getCheckTemplate($app->isIncludeFileToInitPhp())?>
</td>
<td>
Модуль подключен в init.php
</td>
<td width="50%">
<?php
if($initPhpSrc){
?><a target="_blank" href="/bitrix/admin/fileman_file_edit.php?path=<?=urlencode($initPhpSrc)?>&full_src=Y">
<?=$initPhpSrc?>
</a><?php
} else {
?>init.php отсутствует<?php
}
?>
<br>
<?=$html?>
</td>
</tr>
</table>
<br>
@@ -0,0 +1 @@
Документация
+9
View File
@@ -0,0 +1,9 @@
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_before.php');
require($_SERVER['DOCUMENT_ROOT']. '/bitrix/modules/main/include/prolog_admin_after.php');
$adminPage = new \Wt\Core\Admin\SiteSettingsAdminPage('ixrs.catalog', 'main.settings');
$adminPage->render();
require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin.php');
@@ -0,0 +1,2 @@
<?php
$MESS['CONTEXT_PROFILE_DELETE_CONFIRM'] = 'Удалить %s?';
+11
View File
@@ -0,0 +1,11 @@
<?php
use Bitrix\Main\Localization\Loc;
use Wt\Core\Admin\GlobalMenuItem;
Loc::loadMessages(__FILE__);
return (new GlobalMenuItem())
->setSort(5)
->setTitle('Settings')
->setUrl();
+21
View File
@@ -0,0 +1,21 @@
<?php
return [
'MainAbstractFactory' => [
'Ixrs\Catalog\Factory\CatalogFactory' => ['cache' => ['hit'], 'is_collection_query' => true],
],
'events' => [
'main:OnPageStart' => [
['Ixrs\Catalog\Handlers\Autoloader', 'onPageStart'],
],
'main:OnProlog' => [
['Ixrs\Catalog\Handlers\Autoloader', 'onProlog'],
],
'main:OnEpilog' => [
['Ixrs\Catalog\Handlers\Autoloader', 'onEpilog'],
],
'main:OnBeforeProlog' => [
['Ixrs\Catalog\Handlers\Autoloader', 'onBeforeProlog'],
],
],
];
+11
View File
@@ -0,0 +1,11 @@
<?php
use Ixrs\Catalog\App\App;
/**
* @return App
* @throws null
*/
function catalog_base_app() {
return App::getInstance('ixrs.catalog');
}
+9
View File
@@ -0,0 +1,9 @@
<?php
if(!\Bitrix\Main\Loader::includeModule('wt.core')){
throw new Exception('Module wt.core not include!');
}
include 'functions/app.php';
\Wt\Core\App\AppLoader::load(\Wt\Core\App\App::make(__getModuleEntity(__DIR__), app()->container()));
+117
View File
@@ -0,0 +1,117 @@
<?php
use Bitrix\Main\EventManager;
use Bitrix\Main\Loader;
IncludeModuleLangFile(__FILE__);
class ixrs_catalog extends \CModule
{
public $module = [];
public $MODULE_GROUP_RIGHTS = 'Y';
public function __construct()
{
$module = [];
if (file_exists(__DIR__ . '/../.module.json')) {
$module = json_decode(file_get_contents(__DIR__ . '/../.module.json'), true);
}
$this->module = $module;
$this->MODULE_ID = $module['id'];
$this->MODULE_VERSION = $module['version'];
$this->MODULE_VERSION_DATE = $module['date'];
$langPrefix = $module['prefix'];
$this->PARTNER_NAME = GetMessage("{$langPrefix}_partner_name");
$this->PARTNER_URI = GetMessage("{$langPrefix}_partner_uri");
$this->MODULE_NAME = GetMessage("{$langPrefix}_module_name");
$this->MODULE_DESCRIPTION = GetMessage("{$langPrefix}_module_description");
}
public function DoInstall()
{
global $APPLICATION;
if (is_array($this->module['deps'])) {
foreach ($this->module['deps'] as $moduleId) {
if (!Loader::includeModule($moduleId)) {
$APPLICATION->ThrowException("Module {$moduleId} not installed!");
return false;
}
}
}
if (!(version_compare(PHP_VERSION, '8.0.0') >= 0)) {
$APPLICATION->ThrowException('Php version required more 8.0.0');
return false;
}
RegisterModule($this->MODULE_ID);
RegisterModuleDependences('main', 'OnPageStart', $this->MODULE_ID);
$this->InstallEvents();
$this->InstallCatalogExport();
return true;
}
public function DoUninstall()
{
global $APPLICATION;
UnRegisterModule($this->MODULE_ID);
UnRegisterModuleDependences('main', 'OnPageStart', $this->MODULE_ID, '', '');
$this->UnInstallEvents();
$this->UnInstallCatalogExport();
return true;
}
public function InstallCatalogExport()
{
if (is_dir(__DIR__ . '/catalog_export') && Loader::includeModule('catalog')) {
CopyDirFiles(__DIR__ . '/catalog_export', $_SERVER['DOCUMENT_ROOT'] . CATALOG_PATH2EXPORTS, true, true);
}
return true;
}
public function UnInstallCatalogExport()
{
return true;
}
public function InstallEvents()
{
if (class_exists('\Bitrix\Main\EventManager')) {
$eventManager = EventManager::getInstance();
// $eventManager->registerEventHandler(
// 'main',
// 'OnPageStart',
// $this->MODULE_ID,
// 'Ixrs\Catalog\Handler\Handler',
// 'exec',
// 100
// );
}
return true;
}
public function UnInstallEvents()
{
if (class_exists('\Bitrix\Main\EventManager')) {
$eventManager = \Bitrix\Main\EventManager::getInstance();
// $eventManager->unRegisterEventHandler(
// 'main',
// 'OnPageStart',
// $this->MODULE_ID,
// 'Ixrs\Catalog\Handler\Handler',
// 'exec'
// );
}
return true;
}
}
+5
View File
@@ -0,0 +1,5 @@
<?php
$MESS ['ixrs_catalog_partner_name'] = 'CoreLion';
$MESS ['ixrs_catalog_partner_uri'] = 'https://corelion.ru/';
$MESS ['ixrs_catalog_module_name'] = 'Ixrs: Catalog';
$MESS ['ixrs_catalog_module_description'] = 'Catalog module';
@@ -0,0 +1,11 @@
<?php
namespace Ixrs\Catalog\AbstractFactory;
use Wt\Core\AbstractFactory\AAbstractFactory;
use Ixrs\Catalog\Factory\CatalogFactory;
class MainAbstractFactory extends AAbstractFactory
{
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace Ixrs\Catalog\App;
use Ixrs\Catalog\Facade\DefaultDefines;
use Ixrs\Catalog\Facade\Defines;
use Ixrs\Catalog\Facade\DefaultServiceFacade;
use Ixrs\Catalog\Facade\ServiceFacade;
use Ixrs\Catalog\Facade\DefaultFactoryFacade;
use Ixrs\Catalog\Facade\FactoryFacade;
class App extends \Wt\Core\App\App
{
protected $includeFileToInitPhp;
/**
* @param string $factoryName
* @return FactoryFacade | DefaultFactoryFacade
*/
public function factory($factoryName = '')
{
return parent::factory($factoryName);
}
/**
* @param string $serviceName
* @param array $args
* @return ServiceFacade | DefaultServiceFacade
*/
public function service($serviceName = '', $args = [])
{
return parent::service($serviceName, $args);
}
/**
* @return Defines|DefaultDefines
*/
public function defines()
{
return parent::defines();
}
public function isIncludeFileToInitPhp($value = null)
{
if(is_null($value)){
return $this->includeFileToInitPhp;
}
$this->includeFileToInitPhp = $value;
return $this;
}
}
+78
View File
@@ -0,0 +1,78 @@
<?php
namespace Ixrs\Catalog\Collection;
use Wt\Core\Collection\AEntityCollection;
use Ixrs\Catalog\Entity\CatalogEntity;
class CatalogCollection extends AEntityCollection
{
/**
* @param $xmlId
* @return CatalogEntity
* @deprecated
*/
public function &getByXmlId($xmlId)
{
return parent::getByXmlId($xmlId);
}
/**
* @param $id
* @param null $default
* @return CatalogEntity|null
*/
public function &get($id, $default = null)
{
return parent::get($id, $default); // TODO: Change the autogenerated stub
}
/**
* @return CatalogEntity
*/
public function &first(callable $callback = null, $default = null)
{
return parent::first($callback, $default); // TODO: Change the autogenerated stub
}
/**
* @return CatalogEntity
*/
public function &last()
{
return parent::last(); // TODO: Change the autogenerated stub
}
/**
* @return CatalogEntity
*/
public function shift()
{
return parent::shift(); // TODO: Change the autogenerated stub
}
/**
* @return CatalogEntity
*/
public function pop()
{
return parent::pop(); // TODO: Change the autogenerated stub
}
/**
* @return CatalogCollection|CatalogEntity[]
*/
public function filter($callback = null)
{
return parent::filter($callback); // TODO: Change the autogenerated stub
}
/**
* @return CatalogEntity[]
*/
public function all()
{
return parent::all(); // TODO: Change the autogenerated stub
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace Ixrs\Catalog\Entity;
use Ixrs\Catalog\IFields\CatalogFields;
use Ixrs\Catalog\Factory\CatalogFactory;
use Wt\Core\Entity\AEntity;
class CatalogEntity extends AEntity
{
/**
* @return CatalogFactory
*/
public function getFactory()
{
return parent::getFactory(); // TODO: Change the autogenerated stub
}
/**
* @return CatalogFields
*/
public function fields()
{
return parent::fields();
}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace Ixrs\Catalog\Facade;
use Wt\Core\App\ADefines;
class DefaultDefines extends ADefines
{
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace Ixrs\Catalog\Facade;
use Ixrs\Catalog\AbstractFactory\MainAbstractFactory;
use Wt\Core\Facade\AFacade;
class DefaultFactoryFacade extends AFacade
{
/**
* @return MainAbstractFactory
*/
public function main()
{
return $this->app->container()->make($this->app->module()->getId().':mainAbstractFactory');
}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace Ixrs\Catalog\Facade;
use Wt\Core\Facade\AFacade;
class DefaultServiceFacade extends AFacade
{
}
+75
View File
@@ -0,0 +1,75 @@
<?php
namespace Ixrs\Catalog\Factory;
use Ixrs\Catalog\Collection\CatalogCollection;
use Ixrs\Catalog\Entity\CatalogEntity;
use Ixrs\Catalog\ORM\CatalogTable;
use Wt\Core\Factory\AFactory;
use Wt\Core\Factory\AORMFactory;
class CatalogFactory extends AORMFactory
{
/**
* @return string|CatalogTable
*/
protected function __getDataManagerClass()
{
return CatalogTable::class;
}
public function __getEntityClass()
{
return CatalogEntity::class;
}
public function __getCachePrefix()
{
return 'ixrs_catalog';
}
public function __getCollectionClass()
{
return CatalogCollection::class;
}
/**
* @param $id
* @return CatalogEntity
*/
public function getEntityById($id)
{
return parent::getEntityById($id);
}
/**
* @param array $filter
* @param array $order
* @param array $select
* @param null $limit
* @param null $offset
* @return CatalogCollection|CatalogEntity[]
*/
public function getCollection($filter = [], $order = [], $select = [], $limit = null, $offset = null)
{
return parent::getCollection($filter, $order, $select, $limit, $offset); // TODO: Change the autogenerated stub
}
/**
* @param array $arIds
* @return CatalogCollection|CatalogEntity[]
*/
public function getEntityByIds(array $arIds)
{
return parent::getEntityByIds($arIds); // TODO: Change the autogenerated stub
}
/**
* @return CatalogTable
*/
public function getDataManager()
{
return parent::getDataManager();
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace Ixrs\Catalog\Handlers;
class Autoloader
{
public static function onPageStart(){}
public static function onBeforeProlog(){}
public static function onProlog(){}
public static function onEpilog(){}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace Ixrs\Catalog\IFields;
use Wt\Core\Interfaces\IFields;
class CatalogFields implements IFields
{
}
+8
View File
@@ -0,0 +1,8 @@
<?php
namespace Ixrs\Catalog\Interfaces;
class ITest
{
}
+92
View File
@@ -0,0 +1,92 @@
<?php
namespace Ixrs\Catalog\ORM;
use Bitrix\Main\ORM\Fields\DatetimeField;
use Bitrix\Main\Type\DateTime;
use Exception;
use Wt\Core\ORM\ADataManager;
class CatalogTable extends ADataManager
{
public static function getTitle()
{
return 'Catalog Title';
}
public static function getRowTitle()
{
return 'Catalog Row Title';
}
public static function getRowDescription()
{
return 'Catalog Row Description';
}
public static function getTableName()
{
return 'ixrs_catalog_table';
}
public static function getMap()
{
return [
'ID' => new \Bitrix\Main\Entity\IntegerField('ID', [
'primary' => true,
'autocomplete' => true,
'title' => 'Id',
]),
'CREATED_AT' => new \Bitrix\Main\Entity\DatetimeField('CREATED_AT', [
'title' => 'CreatedAt',
'user_edit' => false,
]),
'UPDATED_AT' => new \Bitrix\Main\Entity\DatetimeField('UPDATED_AT', [
'title' => 'UpdatedAt',
'user_edit' => false,
]),
];
}
/**
* @param $primary
* @param array $data
* @return \Bitrix\Main\ORM\Data\UpdateResult
* @throws \Bitrix\Main\ObjectException
* @throws Exception
*/
public static function update($primary, array $data)
{
foreach (static::getEntity()->getFields() as $field){
if(is_a($field, DatetimeField::class)){
if(isset($data[$field->getName()]) && !is_a($data[$field->getName()], DateTime::class)) {
$data[$field->getName()] = new \Bitrix\Main\Type\DateTime($data[$field->getName()]);
}
}
}
$data = array_merge($data, [
'UPDATED_AT' => new \Bitrix\Main\Type\DateTime(), // date(CDatabase::DateFormatToPHP(FORMAT_DATETIME))
]);
unset($data['CREATED_AT']);
return parent::update($primary, $data);
}
/**
* @param array $fields
* @return \Bitrix\Main\ORM\Data\AddResult
* @throws \Bitrix\Main\ObjectException
* @throws Exception
*/
public static function add(array $fields)
{
$fields = array_merge($fields, [
'CREATED_AT' => new \Bitrix\Main\Type\DateTime(),
'UPDATED_AT' => new \Bitrix\Main\Type\DateTime(),
]);
return parent::add($fields);
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace Ixrs\Catalog\Providers;
use Ixrs\Catalog\AbstractFactory\MainAbstractFactory;
use Wt\Core\Interfaces\IApp;
use Wt\Core\Interfaces\IServiceProvider;
class DefaultFactoryProvider implements IServiceProvider
{
public function register(IApp $app)
{
$config = $app->config();
$serviceContainer = $app->container();
/**
* @var MainAbstractFactory $mainAbstractFactory
*/
$mainAbstractFactory = $serviceContainer->make(MainAbstractFactory::class, [$config->get('MainAbstractFactory', [])]);
$serviceContainer->singleton($app->module()->getId().':mainAbstractFactory', $mainAbstractFactory);
}
}
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace Ixrs\Catalog\Providers;
use Wt\Core\Interfaces\IApp;
use Wt\Core\Providers\ADefaultServiceProvider;
class DefaultServiceProvider extends ADefaultServiceProvider
{
public function register(IApp $app)
{
parent::register($app);
$container = $this->app->container();
$config = $this->app->config();
}
}
+1
View File
@@ -0,0 +1 @@
local
+7
View File
@@ -0,0 +1,7 @@
<?php
/**
* @var array $config
*/
return [
'providers' => [],
];