public function performActionEdit()
 {
     $sAction = 'edit';
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $iId = (int) bx_get('id');
         if (!$iId) {
             $this->_echoResultJson(array());
             exit;
         }
         $aIds = array($iId);
     }
     $iId = $aIds[0];
     $aEtemplate = array();
     $this->oDb->getEtemplates(array('type' => 'by_id', 'value' => $iId), $aEtemplate, false);
     if (empty($aEtemplate) || !is_array($aEtemplate)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aForm = array('form_attrs' => array('id' => 'adm-pgt-etemplate-edit', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction, 'method' => BX_DOL_STUDIO_METHOD_DEFAULT), 'params' => array('db' => array('table' => 'sys_email_templates', 'key' => 'ID', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('ID' => array('type' => 'hidden', 'name' => 'id', 'value' => $iId, 'db' => array('pass' => 'Int')), 'NameSystem' => array('type' => 'text_translatable', 'name' => 'NameSystem', 'caption' => _t('_adm_pgt_txt_etemplates_name_system'), 'info' => _t('_adm_pgt_dsc_etemplates_name_system'), 'value' => $aEtemplate['name_system'], 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'LengthTranslatable', 'params' => array(3, 100, 'NameSystem'), 'error' => _t('_adm_pgt_err_etemplates_name_system'))), 'Subject' => array('type' => 'text_translatable', 'name' => 'Subject', 'caption' => _t('_adm_pgt_txt_etemplates_subject'), 'info' => _t('_adm_pgt_dsc_etemplates_subject'), 'value' => $aEtemplate['subject'], 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'AvailTranslatable', 'params' => array('Subject'), 'error' => _t('_adm_pgt_err_etemplates_subject'))), 'Body' => array('type' => 'textarea_translatable', 'name' => 'Body', 'caption' => _t('_adm_pgt_txt_etemplates_body'), 'info' => _t('_adm_pgt_dsc_etemplates_body'), 'value' => $aEtemplate['body'], 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'AvailTranslatable', 'params' => array('Body'), 'error' => _t('_adm_pgt_err_etemplates_body'))), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_pgt_btn_etemplates_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_pgt_btn_etemplates_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->update($iId) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_adm_pgt_err_etemplates_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-pgt-etemplate-edit-popup', _t('_adm_pgt_txt_etemplates_edit_popup', _t($aEtemplate['name_system'])), $this->_oTemplate->parseHtmlByName('pgt_new_etemplate.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
 public function performActionEdit()
 {
     $sAction = 'edit';
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $sId = bx_get('set_name');
         if (!$sId) {
             $this->_echoResultJson(array());
             exit;
         }
         $aIds = array($sId);
     }
     $sId = bx_process_input($aIds[0]);
     $aSet = array();
     $iSet = $this->oDb->getSets(array('type' => 'by_name', 'value' => $sId), $aSet);
     if ($iSet != 1 || empty($aSet)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aForm = array('form_attrs' => array('id' => 'adm-nav-set-edit', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction, 'method' => BX_DOL_STUDIO_METHOD_DEFAULT), 'params' => array('db' => array('table' => 'sys_menu_sets', 'key' => 'set_name', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('set_name' => array('type' => 'hidden', 'name' => 'set_name', 'value' => $sId, 'db' => array('pass' => 'Xss')), 'title' => array('type' => 'text_translatable', 'name' => 'title', 'caption' => _t('_adm_nav_txt_sets_title'), 'info' => _t('_adm_nav_dsc_sets_title'), 'value' => $aSet['title'], 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'LengthTranslatable', 'params' => array(3, 100, 'title'), 'error' => _t('_adm_nav_err_sets_title'))), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_nav_btn_menus_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_nav_btn_menus_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->update($sId) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $sId);
         } else {
             $aRes = array('msg' => _t('_adm_nav_err_sets_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-nav-set-edit-popup', _t('_adm_nav_txt_sets_edit_popup', _t($aSet['title'])), $this->_oTemplate->parseHtmlByName('nav_add_set.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
 public function performActionOptions()
 {
     if ((int) $this->iLevel == 0) {
         $this->iLevel = (int) bx_get('IDLevel');
     }
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $iId = (int) bx_get('IDAction');
         if (!$iId) {
             $this->_echoResultJson(array());
             exit;
         }
         $aIds = array($iId);
     }
     $sAction = 'options';
     $iId = $aIds[0];
     if (strpos($iId, $this->sParamsDivider) !== false) {
         list($this->iLevel, $iId) = explode($this->sParamsDivider, urldecode($iId));
     }
     $aOption = array();
     $iOption = $this->oDb->getOptions(array('type' => 'by_level_action_ids', 'level_id' => $this->iLevel, 'action_id' => $iId), $aOption);
     if ($iOption != 1 || empty($aOption)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aForm = array('form_attrs' => array('id' => 'adm-prm-action-options', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction, 'method' => BX_DOL_STUDIO_METHOD_DEFAULT), 'params' => array('db' => array('table' => 'sys_acl_matrix', 'key' => '', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('IDLevel' => array('type' => 'hidden', 'name' => 'IDLevel', 'value' => $this->iLevel, 'db' => array('pass' => 'Int')), 'IDAction' => array('type' => 'hidden', 'name' => 'IDAction', 'value' => $iId, 'db' => array('pass' => 'Int')), 'AllowedCount' => array('type' => 'text', 'name' => 'AllowedCount', 'caption' => _t('_adm_prm_txt_actions_number'), 'info' => _t('_adm_prm_dsc_actions_number'), 'value' => $aOption['allowed_count'], 'db' => array('pass' => 'Int')), 'AllowedPeriodLen' => array('type' => 'text', 'name' => 'AllowedPeriodLen', 'caption' => _t('_adm_prm_txt_actions_reset'), 'info' => _t('_adm_prm_dsc_actions_reset'), 'value' => $aOption['allowed_period_len'], 'db' => array('pass' => 'Int')), 'AllowedPeriodStart' => array('type' => 'datetime', 'name' => 'AllowedPeriodStart', 'caption' => _t('_adm_prm_txt_actions_avail_start'), 'info' => _t('_adm_prm_dsc_actions_avail'), 'value' => $aOption['allowed_period_start'], 'attrs' => array('allow_input' => 'true'), 'db' => array('pass' => 'Xss')), 'AllowedPeriodEnd' => array('type' => 'datetime', 'name' => 'AllowedPeriodEnd', 'caption' => _t('_adm_prm_txt_actions_avail_end'), 'info' => _t('_adm_prm_dsc_actions_avail'), 'value' => $aOption['allowed_period_end'], 'attrs' => array('allow_input' => 'true'), 'db' => array('pass' => 'Xss')), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_prm_btn_actions_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_prm_btn_actions_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     if ((int) $aOption['action_countable'] != 1) {
         unset($aForm['inputs']['AllowedCount'], $aForm['inputs']['AllowedPeriodLen']);
     }
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $aUpdate = array();
         foreach ($aForm['inputs'] as $sName => $aInput) {
             if (in_array($aInput['type'], array('hidden', 'input_set'))) {
                 continue;
             }
             $aUpdate[$sName] = $oForm->getCleanValue($sName);
             if (empty($aUpdate[$sName])) {
                 $aUpdate[$sName] = null;
             }
         }
         $this->oDb->updateOptions((int) $oForm->getCleanValue('IDLevel'), (int) $oForm->getCleanValue('IDAction'), $aUpdate);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-prm-action-options-popup', _t('_adm_prm_txt_actions_options_popup', _t($aOption['action_title'])), $this->_oTemplate->parseHtmlByName('prm_edit_option.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
 public function performActionEdit()
 {
     $sAction = 'edit';
     $aValue = $this->_getItem('getValues');
     if ($aValue === false) {
         $this->_echoResultJson(array());
         exit;
     }
     $aList = array();
     $this->oDb->getLists(array('type' => 'by_key', 'value' => $this->sList), $aList, false);
     $bUseInSets = (int) $aList['use_for_sets'] == 1;
     bx_import('BxTemplStudioFormView');
     $aForm = array('form_attrs' => array('id' => 'adm-form-list-edit', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&list=' . $this->sList, 'method' => BX_DOL_STUDIO_METHOD_DEFAULT), 'params' => array('db' => array('table' => 'sys_form_pre_values', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('id' => array('type' => 'hidden', 'name' => 'id', 'value' => $aValue['id'], 'db' => array('pass' => 'Int')), 'LKey' => array('type' => 'text_translatable', 'name' => 'LKey', 'caption' => _t('_adm_form_txt_pre_values_lkey'), 'info' => _t('_adm_form_dsc_pre_values_lkey'), 'value' => $aValue['lkey'], 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'LengthTranslatable', 'params' => array(3, 100, 'LKey'), 'error' => _t('_adm_form_err_pre_values_lkey'))), 'Empty' => array('type' => 'checkbox', 'name' => 'Empty', 'caption' => _t('_adm_form_txt_pre_values_empty'), 'info' => _t('_adm_form_dsc_pre_values_empty'), 'value' => 'on', 'checked' => empty($aValue['value']) ? '1' : '0', 'required' => '0'), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_form_btn_pre_lists_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_form_btn_pre_lists_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $aAdd = array();
         $bEmpty = $oForm->getCleanValue('Empty') == 'on';
         if ($bEmpty && !empty($aValue['value'])) {
             $aAdd['Value'] = 0;
         } else {
             if (!$bEmpty && empty($aValue['value'])) {
                 $aAdd['Value'] = $this->_getAvailableSetValue($this->sList);
             }
         }
         if (!empty($aAdd) && $bUseInSets) {
             $mixedValue = $aAdd['Value'];
             if (!$this->canUseForSet($mixedValue)) {
                 if ($this->oDb->isListUsedInSet($this->sList)) {
                     $this->_echoResultJson(array('msg' => _t('_adm_form_err_pre_values_create_forbidden', BX_DOL_STUDIO_FIELD_PRE_VALUE_INT_MAX)), true);
                     return;
                 }
                 $this->oDb->updateList($aList['id'], array('use_for_sets' => '0'));
             }
         }
         if ($oForm->update($aValue['id'], $aAdd) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $aValue['id']);
         } else {
             $aRes = array('msg' => _t('_adm_form_err_pre_values_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-form-pre-value-edit-popup', _t('_adm_form_txt_pre_values_edit_popup', _t($aValue['lkey'])), $this->_oTemplate->parseHtmlByName('form_add_value.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
 public function performActionEdit()
 {
     $sAction = 'edit';
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $iId = (int) bx_get('id');
         if (!$iId) {
             $this->_echoResultJson(array());
             exit;
         }
         $aIds = array($iId);
     }
     $iId = $aIds[0];
     $aPrice = array();
     $iPrice = $this->oDb->getPrices(array('type' => 'by_id', 'value' => $iId), $aPrice);
     if ($iPrice != 1 || empty($aPrice)) {
         $this->_echoResultJson(array());
         exit;
     }
     if ((int) $this->iLevel == 0) {
         $this->iLevel = (int) $aPrice['level_id'];
     }
     $aForm = array('form_attrs' => array('id' => 'adm-prm-price-edit', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction, 'method' => BX_DOL_STUDIO_METHOD_DEFAULT), 'params' => array('db' => array('table' => 'sys_acl_level_prices', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('id' => array('type' => 'hidden', 'name' => 'id', 'value' => $iId, 'db' => array('pass' => 'Int')), 'IDLevel' => array('type' => 'hidden', 'name' => 'IDLevel', 'value' => $aPrice['level_id'], 'db' => array('pass' => 'Int')), 'Days' => array('type' => 'text', 'name' => 'Days', 'caption' => _t('_adm_prm_txt_price_add_days'), 'info' => _t('_adm_prm_dsc_price_add_days'), 'value' => $aPrice['days'], 'db' => array('pass' => 'Int')), 'Price' => array('type' => 'text', 'name' => 'Price', 'caption' => _t('_adm_prm_txt_price_add_price'), 'info' => '', 'value' => round($aPrice['price'], 2), 'db' => array('pass' => 'Float')), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_prm_btn_price_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_prm_btn_price_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $iId = $oForm->getCleanValue('id');
         $aPrice = array();
         $iPrice = $this->oDb->getPrices(array('type' => 'by_level_id_duration', 'level_id' => $oForm->getCleanValue('IDLevel'), 'days' => $oForm->getCleanValue('Days')), $aPrice);
         if ($iPrice != 0 && !empty($aPrice) && $aPrice['id'] != $iId) {
             $this->_echoResultJson(array('msg' => _t('_adm_prm_err_price_duplicate')), true);
             return;
         }
         if ((int) $oForm->update($iId) > 0) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_adm_prm_err_price_update'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-prm-price-edit-popup', _t('_adm_prm_txt_price_edit_popup', $aPrice['days']), $this->_oTemplate->parseHtmlByName('prm_add_price.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
 public function performActionEdit()
 {
     $oTemplate = BxDolStudioTemplate::getInstance();
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $iId = (int) bx_get('id');
         if (!$iId) {
             $this->_echoResultJson(array());
             exit;
         }
         $aIds = array($iId);
     }
     $iId = $aIds[0];
     $sAction = 'edit';
     $aLanguages = array();
     $iLanguages = $this->oDb->getLanguagesBy(array('type' => 'all_key_id'), $aLanguages);
     $aKey = $this->oDb->getKeyFullInfo($iId);
     $aForm = array('form_attrs' => array('id' => 'adm-lang-edit-key-form', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_localization_keys', 'key' => 'ID', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('id' => array('type' => 'hidden', 'name' => 'id', 'value' => $iId, 'db' => array('pass' => 'Int'))));
     foreach ($aLanguages as $aLanguage) {
         $sName = 'language_' . $aLanguage['id'];
         $aForm['inputs'][$sName] = array('type' => 'textarea', 'name' => $sName, 'caption' => $aLanguage['title'], 'value' => isset($aKey['strings'][$aLanguage['name']]) ? $aKey['strings'][$aLanguage['name']]['string'] : '', 'db' => array('pass' => 'XssHtml'));
     }
     $aForm['inputs'] = array_merge($aForm['inputs'], array('languages' => array('type' => 'hidden', 'name' => 'languages', 'value' => implode(',', array_keys($aLanguages)), 'db' => array('pass' => 'Xss')), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_pgt_btn_nkp_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_pgt_btn_nkp_close'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     bx_import('BxTemplStudioFormView');
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $mixedResult = $this->edit($oForm);
         if (is_int($mixedResult)) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $mixedResult);
         } else {
             $aRes = array('msg' => $mixedResult);
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-lang-edit-key-popup', _t('_adm_pgt_txt_nkp_edit_popup', $aKey['key']), $this->_oTemplate->parseHtmlByName('pgt_new_key.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
 public function getPageCode($sCategorySelected = '')
 {
     $oTemplate = BxDolStudioTemplate::getInstance();
     $aCategories = array();
     $iCategories = $this->oDb->getCategories(array('type' => 'by_type_name_key_name', 'type_name' => $this->sType, 'category_name' => $this->sCategory, 'hidden' => 0), $aCategories);
     if ($iCategories > 0) {
         $aCategories = array_keys($aCategories);
     }
     $bWrap = count($aCategories) > 1;
     $aForm = array('form_attrs' => array('id' => 'adm-settings-form', 'name' => 'adm-settings-form', 'action' => BX_DOL_URL_STUDIO . 'settings.php?page=' . $this->sType, 'method' => 'post', 'enctype' => 'multipart/form-data', 'target' => 'adm-settings-iframe'), 'params' => array('db' => array('table' => 'sys_options', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'save')), 'inputs' => array());
     foreach ($aCategories as $sCategory) {
         $aFields = array();
         if (empty($sCategory)) {
             continue;
         }
         $aCategory = array();
         $iCategory = $this->oDb->getCategories(array('type' => 'by_name', 'value' => $sCategory), $aCategory);
         if ($iCategory != 1) {
             continue;
         }
         $aOptions = array();
         $iOptions = $this->oDb->getOptions(array('type' => 'by_category_id', 'value' => $aCategory['id']), $aOptions);
         foreach ($aOptions as $aOption) {
             $aFields[$aOption['name']] = $this->field($aOption);
         }
         if ($bWrap) {
             $aCategory['selected'] = $aCategory['name'] == $sCategorySelected;
             $aFields = $this->header($aCategory, $aFields);
         }
         $aForm['inputs'] = array_merge($aForm['inputs'], $aFields);
     }
     $aForm['inputs'] = array_merge($aForm['inputs'], !$bWrap ? array() : array('header_save' => array('type' => 'block_header')), array('categories' => array('type' => 'hidden', 'name' => 'categories', 'value' => implode(',', $aCategories), 'db' => array('pass' => 'Xss')), 'save' => array('type' => 'submit', 'name' => 'save', 'value' => _t("_adm_btn_settings_save"))));
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         echo $this->saveChanges($oForm);
         exit;
     }
     return $oTemplate->parseHtmlByName('settings.html', array('js_object' => $this->getPageJsObject(), 'form' => $oForm->getCode()));
 }
Esempio n. 8
0
 protected function getIcon()
 {
     $oTemplate = BxDolStudioTemplate::getInstance();
     $sPreview = "";
     $aTmplVars = array('bx_repeat:images' => array());
     if (($iId = (int) getParam('sys_site_icon')) != 0) {
         $aTranscoders = array(BX_DOL_TRANSCODER_OBJ_ICON_APPLE => '_adm_dsg_txt_icon_apple', BX_DOL_TRANSCODER_OBJ_ICON_FACEBOOK => '_adm_dsg_txt_icon_facebook', BX_DOL_TRANSCODER_OBJ_ICON_FAVICON => '_adm_dsg_txt_icon_favicon');
         foreach ($aTranscoders as $sTranscoder => $sTitle) {
             $oTranscoder = BxDolTranscoderImage::getObjectInstance($sTranscoder);
             $sImageUrl = $oTranscoder->getFileUrl($iId);
             if ($sImageUrl === false) {
                 setParam('sys_site_icon', 0);
                 break;
             }
             $aTmplVars['bx_repeat:images'][] = array('caption' => _t($sTitle), 'url' => $sImageUrl);
         }
         $sPreview = $oTemplate->parseHtmlByName('dsr_icon_preview.html', $aTmplVars);
     }
     $aForm = array('form_attrs' => array('id' => $this->sIconFormId, 'name' => $this->sIconFormId, 'action' => BX_DOL_URL_STUDIO . 'designer.php', 'method' => 'post', 'enctype' => 'multipart/form-data', 'target' => $this->sIconIframeId), 'params' => array('db' => array('table' => '', 'key' => '', 'uri' => '', 'uri_title' => '', 'submit_name' => 'save')), 'inputs' => array('page' => array('type' => 'hidden', 'name' => 'page', 'value' => $this->sPage), 'preview' => array('type' => 'custom', 'name' => 'preview', 'content' => $sPreview), 'image' => array('type' => 'file', 'name' => 'image', 'caption' => _t('_adm_dsg_txt_upload_icon')), 'save' => array('type' => 'submit', 'name' => 'save', 'value' => _t('_adm_btn_designer_submit'))));
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         echo $this->submitIcon($oForm);
         exit;
     }
     $aTmplVars = array('js_object' => $this->getPageJsObject(), 'bx_repeat:blocks' => array(array('caption' => '', 'panel_top' => '', 'items' => $oTemplate->parseHtmlByName('dsr_icon.html', array('icon_iframe_id' => $this->sIconIframeId, 'form' => $oForm->getCode())), 'panel_bottom' => '')));
     return $oTemplate->parseHtmlByName('designer.html', $aTmplVars);
 }
 public function performActionShowTo()
 {
     $sAction = 'show_to';
     $aItem = $this->_getItem('getItems');
     if ($aItem === false) {
         $this->_echoResultJson(array());
         exit;
     }
     $aForm = array('form_attrs' => array('id' => 'adm-nav-item-create', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&set=' . $this->sSet, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_menu_items', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('id' => array('type' => 'hidden', 'name' => 'id', 'value' => $aItem['id'], 'db' => array('pass' => 'Int')), 'visible_for' => array('type' => 'select', 'name' => 'visible_for', 'caption' => _t('_adm_nav_txt_items_visible_for'), 'info' => '', 'value' => $aItem['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED, 'values' => array(array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_nav_txt_items_visible_for_all')), array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_nav_txt_items_visible_for_selected'))), 'required' => '0', 'attrs' => array('onchange' => $this->getJsObject() . '.onChangeVisibleFor(this)'), 'db' => array('pass' => 'Xss')), 'visible_for_levels' => array('type' => 'checkbox_set', 'name' => 'visible_for_levels', 'caption' => _t('_adm_nav_txt_items_visible_for_levels'), 'info' => _t('_adm_nav_dsc_items_visible_for_levels'), 'value' => '', 'values' => array(), 'tr_attrs' => array('style' => $aItem['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : ''), 'db' => array('pass' => 'Int')), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_nav_btn_items_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_nav_btn_items_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     BxDolStudioUtils::getVisibilityValues($aItem['visible_for_levels'], $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->updateWithVisibility($aItem['id']) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $aItem['id']);
         } else {
             $aRes = array('msg' => _t('_adm_nav_err_items_show_to'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-nav-item-hide-from-popup', _t('_adm_nav_txt_items_show_to_popup', _t($aItem['title'])), $this->_oTemplate->parseHtmlByName('nav_add_item.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => $sContent), true);
     }
 }
Esempio n. 10
0
 protected function actionBlockEdit()
 {
     $sJsObject = $this->getPageJsObject();
     $oTemplate = BxDolStudioTemplate::getInstance();
     $iId = (int) bx_get('id');
     if (!$iId) {
         return array();
     }
     $aBlock = array();
     $this->oDb->getBlocks(array('type' => 'by_id', 'value' => $iId), $aBlock, false);
     if (empty($aBlock) || !is_array($aBlock)) {
         return array('msg' => _t('_adm_bp_err_block_not_found'));
     }
     $aForm = array('form_attrs' => array('id' => 'adm-bp-block-edit', 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionBlockEdit, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_pages_blocks', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('id' => array('type' => 'hidden', 'name' => 'id', 'value' => $iId, 'db' => array('pass' => 'Int')), 'title' => array('type' => 'text_translatable', 'name' => 'title', 'caption' => _t('_adm_bp_txt_block_title'), 'info' => _t('_adm_bp_dsc_block_title'), 'value' => $aBlock['title'], 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_adm_bp_err_block_title'))), 'designbox_id' => array('type' => 'select', 'name' => 'designbox_id', 'caption' => _t('_adm_bp_txt_block_designbox'), 'info' => '', 'value' => $this->sSelectKeyPrefix . $aBlock['designbox_id'], 'values' => array(array('key' => '', 'value' => _t('_adm_bp_txt_block_designbox_empty'))), 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'avail', 'params' => array(), 'error' => _t('_adm_bp_err_block_designbox'))), 'visible_for' => array('type' => 'select', 'name' => 'visible_for', 'caption' => _t('_adm_bp_txt_block_visible_for'), 'info' => '', 'value' => $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED, 'values' => array(array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_bp_txt_block_visible_for_all')), array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_bp_txt_block_visible_for_selected'))), 'required' => '0', 'attrs' => array('onchange' => $this->getPageJsObject() . '.onChangeVisibleFor(this)'), 'db' => array('pass' => 'Xss')), 'visible_for_levels' => array('type' => 'checkbox_set', 'name' => 'visible_for_levels', 'caption' => _t('_adm_bp_txt_block_visible_for_levels'), 'info' => _t('_adm_bp_dsc_block_visible_for_levels'), 'value' => array(), 'values' => array(), 'tr_attrs' => array('style' => $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : ''), 'db' => array('pass' => 'Int')), 'active' => array('type' => 'switcher', 'name' => 'active', 'caption' => _t('_adm_bp_txt_block_active'), 'info' => '', 'value' => '1', 'checked' => $aBlock['active'] == '1', 'db' => array('pass' => 'Int')), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_bp_btn_block_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_bp_btn_block_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     $aDBoxes = array();
     $this->oDb->getDesignBoxes(array('type' => 'ordered'), $aDBoxes, false);
     foreach ($aDBoxes as $aDBox) {
         $aForm['inputs']['designbox_id']['values'][] = array('key' => $this->sSelectKeyPrefix . $aDBox['id'], 'value' => _t($aDBox['title']));
     }
     BxDolStudioUtils::getVisibilityValues($aBlock['visible_for_levels'], $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
     $aForm['inputs'] = $this->addInArray($aForm['inputs'], 'visible_for_levels', $this->getBlockContent($aBlock));
     if ((int) $aBlock['deletable'] != 0) {
         $aForm['inputs']['controls'][] = array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_bp_btn_block_delete'), 'attrs' => array('onclick' => $this->getPageJsObject() . ".deleteBlock(" . $aBlock['id'] . ")", 'class' => 'bx-def-margin-sec-left'));
     }
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $this->onSaveBlock($oForm, $aBlock);
         if ($oForm->update($iId) !== false) {
             return array('eval' => $sJsObject . '.onEditBlock(oData)');
         } else {
             return array('msg' => _t('_adm_bp_err_block_edit'));
         }
     }
     bx_import('BxTemplStudioFunctions');
     $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['edit_block_popup_id'], _t('_adm_bp_txt_edit_block_popup', _t($aBlock['title'])), $oTemplate->parseHtmlByName('bp_add_block.html', array('action' => 'edit', 'form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true))));
     return array('popup' => $sContent);
 }
Esempio n. 11
0
 public function performActionShowTo()
 {
     $sAction = 'show_to';
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $iId = (int) bx_get('id');
         if (!$iId) {
             $this->_echoResultJson(array());
             exit;
         }
         $aIds = array($iId);
     }
     $iId = $aIds[0];
     $aField = array();
     $this->oDb->getInputs(array('type' => 'by_object_id', 'object' => $this->sObject, 'id' => (int) $iId), $aField, false);
     if (empty($aField) || !is_array($aField)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aForm = array('form_attrs' => array('id' => 'adm-form-field-visibility', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&object=' . $this->sObject . '&display=' . $this->sDisplay, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_form_display_inputs', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('id' => array('type' => 'hidden', 'name' => 'id', 'value' => $iId, 'db' => array('pass' => 'Int')), 'visible_for' => array('type' => 'select', 'name' => 'visible_for', 'caption' => _t('_adm_form_txt_field_visible_for'), 'info' => '', 'value' => $aField['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED, 'values' => array(array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_form_txt_field_visible_for_all')), array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_form_txt_field_visible_for_selected'))), 'required' => '0', 'attrs' => array('onchange' => $this->getJsObject() . '.onChangeVisibleFor(this)'), 'db' => array('pass' => 'Xss')), 'visible_for_levels' => array('type' => 'checkbox_set', 'name' => 'visible_for_levels', 'caption' => _t('_adm_form_txt_field_visible_for_levels'), 'info' => _t('_adm_form_dsc_field_visible_for_levels'), 'value' => '', 'values' => array(), 'tr_attrs' => array('style' => $aField['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : ''), 'db' => array('pass' => 'Int')), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_form_btn_field_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_form_btn_field_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     BxDolStudioUtils::getVisibilityValues($aField['visible_for_levels'], $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
     bx_import('BxTemplStudioFormView');
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->updateWithVisibility($iId) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_adm_form_err_field_show_to'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-form-field-show-to-popup', _t('_adm_form_txt_field_show_to_popup', _t($aField['caption_system'])), $this->_oTemplate->parseHtmlByName('form_add_field.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => $sContent), true);
     }
 }
Esempio n. 12
0
 protected function getCover()
 {
     $oTemplate = BxDolStudioTemplate::getInstance();
     $aForm = array('form_attrs' => array('id' => $this->sCoverFormId, 'name' => $this->sCoverFormId, 'action' => BX_DOL_URL_STUDIO . 'designer.php', 'method' => 'post', 'enctype' => 'multipart/form-data', 'target' => $this->sCoverIframeId), 'params' => array('db' => array('table' => '', 'key' => '', 'uri' => '', 'uri_title' => '', 'submit_name' => 'save')), 'inputs' => array('page' => array('type' => 'hidden', 'name' => 'page', 'value' => $this->sPage), 'enabled' => array('type' => 'checkbox', 'name' => 'enabled', 'caption' => _t('_adm_dsg_txt_cover_enabled'), 'value' => 'on', 'checked' => getParam('sys_site_cover_enabled') == 'on', 'db' => array('pass' => 'Xss')), 'code' => array('type' => 'textarea', 'name' => 'code', 'caption' => '', 'value' => getParam('sys_site_cover_code'), 'db' => array('pass' => 'XssHtml')), 'save' => array('type' => 'submit', 'name' => 'save', 'value' => _t('_adm_btn_designer_submit'))));
     $oForm = new BxTemplStudioFormView($aForm, $oTemplate);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         echo $this->submitCover($oForm);
         exit;
     }
     $oTemplate->addJs(array('codemirror/lib/codemirror.js', 'codemirror/mode/xml/xml.js', 'codemirror/mode/javascript/javascript.js', 'codemirror/mode/css/css.js', 'codemirror/mode/htmlmixed/htmlmixed.js'));
     $oTemplate->addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'codemirror/lib/|codemirror.css');
     return $oTemplate->parseHtmlByName('designer.html', array('js_object' => $this->getPageJsObject(), 'content' => $this->getBlockCode(array('items' => $oTemplate->parseHtmlByName('dsr_cover.html', array('warning' => MsgBox(_t('_adm_dsg_dsc_cover_warning')), 'cover_iframe_id' => $this->sCoverIframeId, 'form' => $oForm->getCode()))))));
 }