public function performActionAdd() { $sAction = 'add'; $aForm = array('form_attrs' => array('id' => 'adm-form-pre-list-create', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction, 'method' => BX_DOL_STUDIO_METHOD_DEFAULT), 'params' => array('db' => array('table' => 'sys_form_pre_lists', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('module' => array('type' => 'hidden', 'name' => 'module', 'value' => BX_DOL_STUDIO_MODULE_CUSTOM, 'db' => array('pass' => 'Xss')), 'use_for_sets' => array('type' => 'hidden', 'name' => 'use_for_sets', 'value' => 1, 'db' => array('pass' => 'Int')), 'title' => array('type' => 'text_translatable', 'name' => 'title', 'caption' => _t('_adm_form_txt_pre_lists_title'), 'info' => _t('_adm_form_dsc_pre_lists_title'), 'value' => '_adm_form_txt_pre_lists', 'required' => '1', 'db' => array('pass' => 'Xss'), 'checker' => array('func' => 'LengthTranslatable', 'params' => array(3, 100, 'title'), 'error' => _t('_adm_form_err_pre_lists_title'))), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_form_btn_pre_lists_add')), 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()) { bx_import('BxDolStudioLanguagesUtils'); $oLanguage = BxDolStudioLanguagesUtils::getInstance(); $sLanguage = $oLanguage->getCurrentLangName(false); $sKey = BxDolForm::getSubmittedValue('title-' . $sLanguage, $aForm['form_attrs']['method']); $sKey = uriGenerate($sKey, 'sys_form_pre_lists', 'key', 'key'); $iId = (int) $oForm->insert(array('key' => $sKey)); if ($iId != 0) { $aRes = array('grid' => $this->getCode(false), 'blink' => $iId); } else { $aRes = array('msg' => _t('_adm_form_err_pre_lists_create')); } $this->_echoResultJson($aRes, true); } else { bx_import('BxTemplStudioFunctions'); $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-form-pre-list-create-popup', _t('_adm_form_txt_pre_lists_create_popup'), $this->_oTemplate->parseHtmlByName('form_add_list.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 performActionAdd() { $sAction = 'add'; $sFilter = bx_get('filter'); if (strpos($sFilter, $this->sParamsDivider) !== false) { list($this->iLevel, $sFilter) = explode($this->sParamsDivider, $sFilter); } if ((int) $this->iLevel == 0) { $this->iLevel = (int) bx_get('IDLevel'); } $aForm = array('form_attrs' => array('id' => 'adm-prm-price-add', '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('IDLevel' => array('type' => 'hidden', 'name' => 'IDLevel', 'value' => $this->iLevel, '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' => '', 'db' => array('pass' => 'Int')), 'Price' => array('type' => 'text', 'name' => 'Price', 'caption' => _t('_adm_prm_txt_price_add_price'), 'info' => '', 'value' => '', 'db' => array('pass' => 'Float')), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_prm_btn_price_add')), 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()) { $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) { $this->_echoResultJson(array('msg' => _t('_adm_prm_err_price_duplicate')), true); return; } $iId = (int) $oForm->insert(array('Order' => $this->oDb->getPriceOrderMax($this->iLevel) + 1)); if ($iId != 0) { $this->oDb->updateLevels($this->iLevel, array('Purchasable' => 'yes')); $aRes = array('grid' => $this->getCode(false), 'blink' => $iId); } else { $aRes = array('msg' => _t('_adm_prm_err_price_create')); } $this->_echoResultJson($aRes, true); } else { bx_import('BxTemplStudioFunctions'); $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-prm-price-add-popup', _t('_adm_prm_txt_price_add_popup'), $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 performActionAdd() { $sAction = 'add'; $aList = array(); $this->oDb->getLists(array('type' => 'by_key', 'value' => $this->sList), $aList, false); $bUseInSets = (int) $aList['use_for_sets'] == 1; $aForm = array('form_attrs' => array('id' => 'adm-form-pre-value-create', '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('Key' => array('type' => 'hidden', 'name' => 'Key', 'value' => $this->sList, 'db' => array('pass' => 'Xss')), 'Value' => array('type' => 'hidden', 'name' => 'Value', 'value' => $this->_getAvailableSetValue($this->sList), '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' => '_adm_form_txt_pre_value', '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', 'required' => '0'), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_form_btn_pre_values_add')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_form_btn_pre_values_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->getCleanValue('Empty') == 'on') { BxDolForm::setSubmittedValue('Value', '', $oForm->aFormAttrs['method']); } if ($bUseInSets) { $mixedValue = $oForm->getCleanValue('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')); } } $iId = (int) $oForm->insert(array('LKey2' => '', 'Order' => $this->oDb->getValuesOrderMax($this->sList) + 1)); if ($iId != 0) { $aRes = array('grid' => $this->getCode(false), 'blink' => $iId); } else { $aRes = array('msg' => _t('_adm_form_err_pre_values_create')); } $this->_echoResultJson($aRes, true); } else { $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-form-pre-value-create-popup', _t('_adm_form_txt_pre_values_create_popup'), $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); } }
protected function actionPageCreate() { $oTemplate = BxDolStudioTemplate::getInstance(); $sModule = BX_DOL_STUDIO_MODULE_CUSTOM; $aForm = array('form_attrs' => array('id' => 'adm-bp-page-create', 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionPageCreate, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_objects_page', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('module' => array('type' => 'hidden', 'name' => 'module', 'value' => $sModule, 'db' => array('pass' => 'Xss')), 'deletable' => array('type' => 'hidden', 'name' => 'deletable', 'value' => 1, 'db' => array('pass' => 'Int')), 'settings' => array('type' => 'custom', 'name' => 'settings', 'content' => $oTemplate->parseHtmlByName('bp_edit_page_form.html', $this->_getTmplVarsPageSettings())))); $oForm = new BxTemplStudioFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { unset($oForm->aInputs['settings']); foreach ($this->aPageSettings as $aSetting) { $oForm->aInputs = array_merge($oForm->aInputs, $this->{'getSettings' . $this->getClassName($aSetting['name']) . 'Fields'}()); } bx_import('BxDolStudioLanguagesUtils'); $sLanguage = BxDolStudioLanguagesUtils::getInstance()->getCurrentLangName(false); $sObject = BxDolForm::getSubmittedValue('title-' . $sLanguage, $aForm['form_attrs']['method']); $sObject = uriGenerate($sObject, 'sys_objects_page', 'object', 'object'); $sUri = $oForm->getCleanValue('uri'); $iVisibleFor = BxDolStudioUtils::getVisibilityValue($oForm->getCleanValue('visible_for'), $oForm->getCleanValue('visible_for_levels')); BxDolForm::setSubmittedValue('visible_for_levels', $iVisibleFor, $aForm['form_attrs']['method']); unset($oForm->aInputs['visible_for']); $iId = (int) $oForm->insert(array('object' => $sObject, 'url' => $this->sPageBaseUrl . $sUri)); if ($iId != 0) { return array('eval' => $this->getPageJsObject() . '.onCreatePage(\'' . $sModule . '\', \'' . $sObject . '\')'); } else { return array('msg' => _t('_adm_bp_err_page_create')); } } bx_import('BxTemplStudioFunctions'); $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['add_popup_id'], _t('_adm_bp_txt_create_popup'), $oTemplate->parseHtmlByName('bp_add_page.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true)))); return array('popup' => $sContent); }