-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
192 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "ylab/validation", | ||
"description": "Module wrapper for illuminate/validation (Laravel) library for Bitrix", | ||
"type": "bitrix-d7-module", | ||
"require": { | ||
"php": ">=5.6.4", | ||
"illuminate/validation": ">=5.4", | ||
"composer/installers": "~1.0" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Roman Shvykov", | ||
"email": "roman_shvykov@mail.ru", | ||
"role": "Developer" | ||
} | ||
], | ||
"support": { | ||
"issues": "https://github.com/ylabio/ylab.validation/issues", | ||
"source": "https://github.com/ylabio/ylab.validation" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
$arModuleVersion = [ | ||
'VERSION' => '0.1', | ||
'VERSION_DATE' => '2018-06-14', | ||
'VERSION' => '0.2.0', | ||
'VERSION_DATE' => '2018-11-12', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
$MESS['YLAB_VALIDATION_MODULE_NAME'] = 'YLab Validation'; | ||
$MESS['YLAB_VALIDATION_MODULE_DESCRIPTION'] = 'Module wrapper for illuminate/validation (Laravel) library)'; | ||
$MESS['YLAB_VALIDATION_MODULE_DESCRIPTION'] = 'Module wrapper for illuminate/validation (Laravel) library'; | ||
$MESS['YLAB_VALIDATION_INSTALL_ERROR'] = 'Not found class \Illuminate\Validation\Validator.'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
$MESS['YLAB_VALIDATION_AUTOLOAD'] = 'Автозагрузка модуля (событие OnPageStart)'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace YLab\Validation; | ||
|
||
use Bitrix\Main\Loader; | ||
|
||
/** | ||
* Class Event | ||
* @package YLab\Validation | ||
*/ | ||
class Event | ||
{ | ||
/** | ||
* @return bool | ||
* @throws \Bitrix\Main\LoaderException | ||
*/ | ||
public static function onPageStart() | ||
{ | ||
if (!Loader::includeModule('ylab.validation')) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,4 @@ public static function make(array $arData, array $arRules, $sLang = LANGUAGE_ID, | |
$arCustoms | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
namespace YLab\Validation; | ||
|
||
use Bitrix\Main\IO\Path; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
use Bitrix\Main\Application; | ||
use Bitrix\Main\Localization\Loc; | ||
|
||
/** @global \CMain $APPLICATION */ | ||
global $APPLICATION; | ||
|
||
Loc::loadMessages(__FILE__); | ||
|
||
defined('ADMIN_MODULE_NAME') or define('ADMIN_MODULE_NAME', 'ylab.validation'); | ||
|
||
if (!$USER->isAdmin()) { | ||
$APPLICATION->authForm('Nope'); | ||
} | ||
|
||
try { | ||
$oApp = Application::getInstance(); | ||
$oContext = $oApp->getContext(); | ||
$oRequest = $oContext->getRequest(); | ||
|
||
Loc::loadMessages($oContext->getServer()->getDocumentRoot() . "/bitrix/modules/main/options.php"); | ||
|
||
$arErrors = []; | ||
$arTabs = [ | ||
[ | ||
"DIV" => "edit1", | ||
"TAB" => Loc::getMessage("MAIN_TAB_SET"), | ||
"TITLE" => Loc::getMessage("MAIN_TAB_TITLE_SET"), | ||
'OPTIONS' => [ | ||
[ | ||
'ylab_validation_autoload', | ||
Loc::getMessage('YLAB_VALIDATION_AUTOLOAD'), | ||
'', | ||
['checkbox'] | ||
] | ||
] | ||
], | ||
]; | ||
|
||
$oTabControl = new CAdminTabControl("tabControl", $arTabs); | ||
|
||
if (!empty($save) && $oRequest->isPost() && check_bitrix_sessid()) { | ||
foreach ($arTabs as $arTab) { | ||
foreach ($arTab['OPTIONS'] as $arOption) { | ||
if ($arOption[0] === 'ylab_validation_autoload') { | ||
$sVal = $oRequest->get('ylab_validation_autoload'); | ||
if ($sVal === 'Y') { | ||
\Bitrix\Main\EventManager::getInstance()->registerEventHandler( | ||
'main', | ||
'OnPageStart', | ||
ADMIN_MODULE_NAME, | ||
'\YLab\Validation\Event', | ||
'onPageStart' | ||
); | ||
} else { | ||
\Bitrix\Main\EventManager::getInstance()->unRegisterEventHandler( | ||
'main', | ||
'OnPageStart', | ||
ADMIN_MODULE_NAME, | ||
'\YLab\Validation\Event', | ||
'onPageStart' | ||
); | ||
} | ||
} | ||
|
||
__AdmSettingsSaveOption(ADMIN_MODULE_NAME, $arOption); | ||
} | ||
} | ||
} | ||
|
||
if (count($arErrors) > 0) { | ||
$arMessage = [ | ||
"MESSAGE" => implode("\n", $arErrors), | ||
"HTML" => true, | ||
"TYPE" => "ERROR", | ||
]; | ||
$oCAdminMessage = new \CAdminMessage($arMessage); | ||
$oCAdminMessage->ShowMessage($arMessage); | ||
} | ||
} catch (\Exception $oError) { | ||
ShowError($oError->getMessage()); | ||
} | ||
|
||
$oTabControl->begin(); | ||
?> | ||
|
||
<form method="post" | ||
action="<?= sprintf('%s?mid=%s&lang=%s', $oRequest->getRequestedPage(), urlencode(ADMIN_MODULE_NAME), | ||
LANGUAGE_ID) ?>"> | ||
<?php | ||
foreach ($arTabs as $arTab) { | ||
if ($arTab['OPTIONS']) { | ||
$oTabControl->BeginNextTab(); | ||
__AdmSettingsDrawList(ADMIN_MODULE_NAME, $arTab['OPTIONS']); | ||
} | ||
} | ||
$oTabControl->beginNextTab(); | ||
$oTabControl->buttons(); | ||
?> | ||
<input type="submit" | ||
name="save" | ||
value="<?= Loc::getMessage("MAIN_SAVE") ?>" | ||
title="<?= Loc::getMessage("MAIN_OPT_SAVE_TITLE") ?>" | ||
class="adm-btn-save" | ||
/> | ||
<?php | ||
echo bitrix_sessid_post(); | ||
$oTabControl->end(); | ||
?> | ||
</form> |