class CModuleOptions { public $arCurOptionValues = array(); private $module_id = ''; private $arTabs = array(); private $arGroups = array(); private $arOptions = array(); private $need_access_tab = false; public function CModuleOptions($module_id, $arTabs, $arGroups, $arOptions, $need_access_tab = false) { $this->module_id = $module_id; $this->arTabs = $arTabs; $this->arGroups = $arGroups; $this->arOptions = $arOptions; $this->need_access_tab = $need_access_tab; if($need_access_tab) $this->arTabs[] = array( 'DIV' => 'edit_access_tab', 'TAB' => 'Права доступа', 'ICON' => '', 'TITLE' => 'Настройка прав доступа' ); if($_REQUEST['update'] == 'Y' && check_bitrix_sessid()) $this->SaveOptions(); $this->GetCurOptionValues(); } private function SaveOptions() { foreach($this->arOptions as $opt => $arOptParams) { if($arOptParams['TYPE'] != 'CUSTOM') { $val = $_REQUEST[$opt]; if($arOptParams['TYPE'] == 'CHECKBOX' && $val != 'Y') $val = 'N'; elseif(is_array($val)) $val = serialize($val); COption::SetOptionString($this->module_id, $opt, $val); } } } private function GetCurOptionValues() { foreach($this->arOptions as $opt => $arOptParams) { if($arOptParams['TYPE'] != 'CUSTOM') { $this->arCurOptionValues[$opt] = COption::GetOptionString($this->module_id, $opt, $arOptParams['DEFAULT']); if(in_array($arOptParams['TYPE'], array('MSELECT'))) $this->arCurOptionValues[$opt] = unserialize($this->arCurOptionValues[$opt]); } } } public function ShowHTML() { global $APPLICATION; $arP = array(); foreach($this->arGroups as $group_id => $group_params) $arP[$group_params['TAB']][$group_id] = array(); if(is_array($this->arOptions)) { foreach($this->arOptions as $option => $arOptParams) { $val = $this->arCurOptionValues[$option]; if($arOptParams['SORT'] < 0 || !isset($arOptParams['SORT'])) $arOptParams['SORT'] = 0; $label = (isset($arOptParams['TITLE']) && $arOptParams['TITLE'] != '') ? $arOptParams['TITLE'] : ''; $opt = htmlspecialchars($option); switch($arOptParams['TYPE']) { case 'CHECKBOX': $input = 'module_id.'\'].submit();"' : '').' />'; break; case 'TEXT': if(!isset($arOptParams['COLS'])) $arOptParams['COLS'] = 25; if(!isset($arOptParams['ROWS'])) $arOptParams['ROWS'] = 5; $input = ''; if($arOptParams['REFRESH'] == 'Y') $input .= ''; break; case 'SELECT': $input = SelectBoxFromArray($opt, $arOptParams['VALUES'], $val, '', '', ($arOptParams['REFRESH'] == 'Y' ? true : false), ($arOptParams['REFRESH'] == 'Y' ? $this->module_id : '')); if($arOptParams['REFRESH'] == 'Y') $input .= ''; break; case 'MSELECT': $input = SelectBoxMFromArray($opt.'[]', $arOptParams['VALUES'], $val); if($arOptParams['REFRESH'] == 'Y') $input .= ''; break; case 'COLORPICKER': if(!isset($arOptParams['FIELD_SIZE'])) $arOptParams['FIELD_SIZE'] = 25; ob_start(); echo ' '; $APPLICATION->IncludeComponent('bitrix:main.colorpicker', '', Array( 'SHOW_BUTTON' => 'Y', 'ID' => $opt, 'NAME' => 'Выбор цвета', 'ONSELECT' => 'onSelect_'.$opt ), false ); $input = ob_get_clean(); if($arOptParams['REFRESH'] == 'Y') $input .= ''; break; case 'FILE': if(!isset($arOptParams['FIELD_SIZE'])) $arOptParams['FIELD_SIZE'] = 25; if(!isset($arOptParams['BUTTON_TEXT'])) $arOptParams['BUTTON_TEXT'] = '...'; CAdminFileDialog::ShowScript(Array( 'event' => 'BX_FD_'.$opt, 'arResultDest' => Array('FUNCTION_NAME' => 'BX_FD_ONRESULT_'.$opt), 'arPath' => Array(), 'select' => 'F', 'operation' => 'O', 'showUploadTab' => true, 'showAddToMenuTab' => false, 'fileFilter' => '', 'allowAllFiles' => true, 'SaveConfig' => true )); $input = ' '; if($arOptParams['REFRESH'] == 'Y') $input .= ''; break; case 'CUSTOM': $input = $arOptParams['VALUE']; break; default: if(!isset($arOptParams['SIZE'])) $arOptParams['SIZE'] = 25; if(!isset($arOptParams['MAXLENGTH'])) $arOptParams['MAXLENGTH'] = 255; $input = ''; if($arOptParams['REFRESH'] == 'Y') $input .= ''; break; } if(isset($arOptParams['NOTES']) && $arOptParams['NOTES'] != '') $input .= '
'.$arOptParams['NOTES'].' | ||