-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from niksamokhvalov/master
Admin helper 2.0.0
- Loading branch information
Showing
39 changed files
with
6,605 additions
and
2,690 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright © 2015 DigitalWand (http://digitalwand.ru/) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,79 +1,136 @@ | ||
<?php | ||
use Bitrix\Main\Loader; | ||
use DigitalWand\AdminHelper\Helper\AdminBaseHelper; | ||
use DigitalWand\AdminHelper\Helper\AdminListHelper; | ||
use DigitalWand\AdminHelper\Helper\AdminEditHelper; | ||
|
||
require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php"); | ||
|
||
function getRequestParams($param) | ||
{ | ||
if (!isset($_REQUEST[$param])) { | ||
return false; | ||
} else { | ||
return htmlspecialcharsbx($_REQUEST[$param]); | ||
} | ||
} | ||
|
||
/*Очищаем переменные сессии, чтобы сортировка восстанавливалась с учетом $table_id */ | ||
/** @global CMain $APPLICATION */ | ||
global $APPLICATION; | ||
$uniq = md5($APPLICATION->GetCurPage()); | ||
if (isset($_SESSION["SESS_SORT_BY"][$uniq])) { | ||
unset($_SESSION["SESS_SORT_BY"][$uniq]); | ||
} | ||
if (isset($_SESSION["SESS_SORT_ORDER"][$uniq])) { | ||
unset($_SESSION["SESS_SORT_ORDER"][$uniq]); | ||
} | ||
|
||
$module = getRequestParams('module'); | ||
$view = getRequestParams('view'); | ||
if (!$module OR !$view OR !Loader::IncludeModule($module)) { | ||
include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; | ||
} | ||
|
||
list($helper, $interface) = AdminBaseHelper::getGlobalInterfaceSettings($module, $view); | ||
|
||
if (!$helper OR !$interface) { | ||
include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; | ||
} | ||
|
||
$isPopup = isset($_REQUEST['popup']) AND $_REQUEST['popup'] == 'Y'; | ||
$fields = isset($interface['FIELDS']) ? $interface['FIELDS'] :array(); | ||
$tabs = isset($interface['TABS']) ? $interface['TABS'] :array(); | ||
$helperType = false; | ||
|
||
|
||
if (is_subclass_of($helper, 'DigitalWand\AdminHelper\Helper\AdminEditHelper')) { | ||
$helperType = 'edit'; | ||
/** @var AdminEditHelper $adminHelper */ | ||
$adminHelper = new $helper($fields, $tabs); | ||
|
||
} else if (is_subclass_of($helper, 'DigitalWand\AdminHelper\Helper\AdminListHelper')) { | ||
$helperType = 'list'; | ||
/** @var AdminListHelper $adminHelper */ | ||
$adminHelper = new $helper($fields, $isPopup); | ||
$adminHelper->getData(array($by => $order)); | ||
|
||
} else { | ||
include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; | ||
exit(); | ||
} | ||
|
||
if ($isPopup) { | ||
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_popup_admin.php"); | ||
} else { | ||
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"); | ||
} | ||
|
||
if ($helperType == 'list') { | ||
$adminHelper->createFilterForm(); | ||
} | ||
$adminHelper->show(); | ||
|
||
if ($isPopup) { | ||
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_popup_admin.php"); | ||
} else { | ||
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php"); | ||
} | ||
|
||
<?php | ||
|
||
use Bitrix\Main\Loader; | ||
use DigitalWand\AdminHelper\Helper\AdminBaseHelper; | ||
use DigitalWand\AdminHelper\Helper\AdminListHelper; | ||
use DigitalWand\AdminHelper\Helper\AdminEditHelper; | ||
use DigitalWand\AdminHelper\Helper\AdminInterface; | ||
|
||
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_admin_before.php'); | ||
|
||
Loader::includeModule('digitalwand.admin_helper'); | ||
|
||
function getRequestParams($param) | ||
{ | ||
if (!isset($_REQUEST[$param])) { | ||
return false; | ||
} | ||
else { | ||
return htmlspecialcharsbx($_REQUEST[$param]); | ||
} | ||
} | ||
|
||
/** | ||
* Очищаем переменные сессии, чтобы сортировка восстанавливалась с учетом $table_id. | ||
* | ||
* @global CMain $APPLICATION | ||
*/ | ||
global $APPLICATION; | ||
$uniq = md5($APPLICATION->GetCurPage()); | ||
|
||
if (isset($_SESSION["SESS_SORT_BY"][$uniq])) { | ||
unset($_SESSION["SESS_SORT_BY"][$uniq]); | ||
} | ||
if (isset($_SESSION["SESS_SORT_ORDER"][$uniq])) { | ||
unset($_SESSION["SESS_SORT_ORDER"][$uniq]); | ||
} | ||
|
||
$module = getRequestParams('module'); | ||
$view = getRequestParams('view'); | ||
|
||
if (!$module OR !$view OR !Loader::IncludeModule($module)) { | ||
include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; | ||
} | ||
|
||
// Собираем имя класса админского интерфейса | ||
$moduleNameParts = explode('.', $module); | ||
$entityNameParts = explode('_', $entity); | ||
$interfaceNameParts = array_merge($moduleNameParts, $entityNameParts); | ||
$interfaceNameClass = null; | ||
$viewParts = explode('_', $view); | ||
|
||
$count = count($viewParts); | ||
for ($i = 0; $i < $count; $i++) { | ||
$interfaceName = implode('', array_map('ucfirst', $viewParts)); | ||
$parts = $interfaceNameParts; | ||
$parts[] = $interfaceName . 'AdminInterface'; | ||
$class = array_map('ucfirst', $parts); | ||
$interfaceNameClass = implode('\\', $class); | ||
|
||
if (class_exists($interfaceNameClass)) { | ||
break; | ||
} | ||
else { | ||
$className = array_pop($parts); | ||
$parts[] = 'AdminInterface'; | ||
$parts[] = $className; | ||
$class = array_map('ucfirst', $parts); | ||
$interfaceNameClass = implode('\\', $class); | ||
if (class_exists($interfaceNameClass)) { | ||
break; | ||
} | ||
} | ||
array_pop($viewParts); | ||
} | ||
|
||
/** | ||
* @var AdminInterface $interfaceNameClass | ||
*/ | ||
|
||
if ($interfaceNameClass && class_exists($interfaceNameClass)) { | ||
$interfaceNameClass::register(); | ||
} | ||
|
||
list($helper, $interface) = AdminBaseHelper::getGlobalInterfaceSettings($module, $view); | ||
|
||
if (!$helper OR !$interface) { | ||
include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; | ||
} | ||
|
||
$isPopup = isset($_REQUEST['popup']) AND $_REQUEST['popup'] == 'Y'; | ||
$fields = isset($interface['FIELDS']) ? $interface['FIELDS'] : array(); | ||
$tabs = isset($interface['TABS']) ? $interface['TABS'] : array(); | ||
$helperType = false; | ||
|
||
if (is_subclass_of($helper, 'DigitalWand\AdminHelper\Helper\AdminEditHelper')) { | ||
$helperType = 'edit'; | ||
/** | ||
* @var AdminEditHelper $adminHelper | ||
*/ | ||
$adminHelper = new $helper($fields, $tabs); | ||
} | ||
elseif (is_subclass_of($helper, 'DigitalWand\AdminHelper\Helper\AdminListHelper')) { | ||
$helperType = 'list'; | ||
/** | ||
* @var AdminListHelper $adminHelper | ||
*/ | ||
$adminHelper = new $helper($fields, $isPopup); | ||
$adminHelper->buildList(array($by => $order)); | ||
} | ||
elseif (is_subclass_of($helper, 'DigitalWand\AdminHelper\Helper\AdminBaseHelper')) { | ||
$adminHelper = new $helper($fields, $tabs); | ||
} | ||
else { | ||
include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; | ||
exit(); | ||
} | ||
|
||
if ($isPopup) { | ||
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_popup_admin.php"); | ||
} | ||
else { | ||
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"); | ||
} | ||
|
||
if ($helperType == 'list') { | ||
$adminHelper->createFilterForm(); | ||
} | ||
|
||
$adminHelper->show(); | ||
|
||
if ($isPopup) { | ||
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_popup_admin.php"); | ||
} | ||
else { | ||
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php"); | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<? | ||
require_once($_SERVER["DOCUMENT_ROOT"]."/local/modules/digitalwand.admin_helper/admin/route.php"); | ||
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/digitalwand.admin_helper/admin/route.php"); | ||
?> |
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,3 +1,4 @@ | ||
<?php | ||
|
||
$MESS['DIGITALWAND_ADMIN_HELPER_GETMODEL_EXCEPTION'] = "Попыка обращение к несуществующему HL-инфоблоку #CLASS#"; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_GETMODEL_EXCEPTION'] = 'Попыка обращение к несуществующему HL-инфоблоку #CLASS#'; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_ACCESS_FORBIDDEN'] = 'Доступ запрещен'; |
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,8 +1,14 @@ | ||
<?php | ||
$MESS['DEFAULT_TAB'] = 'Элемент'; | ||
$MESS['RETURN_TO_LIST'] = 'Список'; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_RETURN_TO_LIST'] = 'Список'; | ||
$MESS['DELETE'] = 'Удалить'; | ||
$MESS['VALIDATION_ERROR'] = "Не заполнены обязательные поля:\n#FIELD_LIST#"; | ||
$MESS['VALIDATION_ERROR_FIELDS'] = "Не заполнены обязательные поля:"; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_NEW_ELEMENT'] = "Новый элемент"; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_EDIT_TITLE'] = "Элемент #ID#"; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_EDIT_DELETE_CONFIRM'] = "Удалить запись?"; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_ACTIONS'] = "Действия"; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_ADD_ELEMENT'] = "Добавить элемент"; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_DELETE_ELEMENT'] = "Удалить элемент"; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_EDIT_DELETE_FORBIDDEN'] = 'Не хватает прав доступа для удаления элемента'; | ||
$MESS['DIGITALWAND_ADMIN_HELPER_EDIT_WRITE_FORBIDDEN'] = 'Не хватает прав доступа для изменения элемента'; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<? | ||
$MESS['CHECKBOX_YES'] = 'Да'; | ||
$MESS['CHECKBOX_NO'] = 'Нет'; | ||
<?php | ||
|
||
$MESS['DIGITALWAND_AH_CHECKBOX_YES'] = 'Да'; | ||
$MESS['DIGITALWAND_AH_CHECKBOX_NO'] = 'Нет'; |
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,2 @@ | ||
<?php | ||
$MESS['COMBO_BOX_LIST_EMPTY'] = 'Не выбрано'; |
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['DIGITALWAND_AH_FAIL_ADD_FILE'] = 'Не удалось добавить файл #FILE_NAME#'; |
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,3 +1,5 @@ | ||
<?php | ||
$MESS['REQUIRED_FIELD_ERROR'] = 'Обязательное поле "#FIELD#" не заполнено'; | ||
$MESS['DUPLICATE_FIELD_ERROR'] = 'Значение поля "#FIELD#" не является уникальным'; | ||
|
||
$MESS['DIGITALWAND_AH_REQUIRED_FIELD_ERROR'] = 'Обязательное поле "#FIELD#" не заполнено'; | ||
$MESS['DIGITALWAND_AH_DUPLICATE_FIELD_ERROR'] = 'Значение поля "#FIELD#" не является уникальным'; | ||
$MESS['DIGITALWAND_AH_MULTI_NOT_SUPPORT'] = 'Поле не поддерживает множественный режим'; |
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,2 @@ | ||
<?php | ||
$MESS['IBLOCK_ELEMENT_NOT_FOUND'] = 'Элемент не найден'; |
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['TITLE_FIELD_NAME'] = 'Элемент не найден'; |
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,2 @@ | ||
<?php | ||
$MESS['PROTOCOL_REQUIRED'] = 'Укажите протокол ссылки "#FIELD#" (например http://)'; |
Oops, something went wrong.