Example #1
0
 public function performActionEdit()
 {
     $sAction = 'edit';
     $sFormObject = $this->oModule->_oConfig->getObject('form_forms_form');
     $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_forms_form_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];
     $aForm = array();
     $this->oDb->getForms(array('type' => 'by_id', 'value' => $iId), $aForm, false);
     if (empty($aForm) || !is_array($aForm)) {
         $this->_echoResultJson(array());
         exit;
     }
     bx_import('BxDolForm');
     $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
     $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
     $oForm->aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_frm_txt_select_module')), BxDolStudioUtils::getModules());
     $oForm->aInputs['controls'][0]['value'] = _t('_bx_dev_frm_btn_forms_save');
     $aForm['form_attrs'] = BxDevFunctions::unserializeString($aForm['form_attrs']);
     $aForm['params'] = BxDevFunctions::unserializeString($aForm['params']);
     $oForm->initChecker($aForm);
     if ($oForm->isSubmittedAndValid()) {
         $sValue = BxDolForm::getSubmittedValue('form_attrs', $oForm->aFormAttrs['method']);
         $sValue = BxDevFunctions::serializeString($sValue);
         BxDolForm::setSubmittedValue('form_attrs', $sValue, $oForm->aFormAttrs['method']);
         $sValue = BxDolForm::getSubmittedValue('params', $oForm->aFormAttrs['method']);
         $sValue = BxDevFunctions::serializeString($sValue);
         BxDolForm::setSubmittedValue('params', $sValue, $oForm->aFormAttrs['method']);
         if ($oForm->update($iId) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_bx_dev_frm_err_forms_edit'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-frm-form-edit-popup', _t('_bx_dev_frm_txt_forms_edit_popup', _t($aForm['title'])), $this->oModule->_oTemplate->parseHtmlByName('form_add_form.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true);
     }
 }
Example #2
0
 protected function onLoadBlock(&$oForm, &$aBlock)
 {
     $oForm->aFormAttrs['action'] = sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionBlockEdit;
     $oForm->aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_bp_txt_select_module')), BxDolStudioUtils::getModules());
     $aDBoxes = array();
     $this->oDb->getDesignBoxes(array('type' => 'ordered'), $aDBoxes, false);
     foreach ($aDBoxes as $aDBox) {
         $oForm->aInputs['designbox_id']['values'][] = array('key' => $this->sSelectKeyPrefix . $aDBox['id'], 'value' => _t($aDBox['title']));
     }
     $oForm->aInputs['visible_for']['value'] = $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED;
     $oForm->aInputs['visible_for']['values'] = array(array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_bx_dev_bp_txt_block_visible_for_all')), array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_bx_dev_bp_txt_block_visible_for_selected')));
     $oForm->aInputs['visible_for']['attrs']['onchange'] = $this->getPageJsObject() . '.onChangeVisibleFor(this)';
     $oForm->aInputs['visible_for_levels']['tr_attrs']['style'] = $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : '';
     BxDolStudioUtils::getVisibilityValues($aBlock['visible_for_levels'], $oForm->aInputs['visible_for_levels']['values'], $oForm->aInputs['visible_for_levels']['value']);
     $aBlock['visible_for_levels'] = $oForm->aInputs['visible_for_levels']['value'];
     $oForm->aInputs = $this->addInArray($oForm->aInputs, 'visible_for_levels', $this->getBlockContent($aBlock));
     $oForm->aInputs['controls'][0]['value'] = _t('_bx_dev_bp_btn_block_save');
     $oForm->aInputs['controls'][2]['attrs']['onclick'] = $this->getPageJsObject() . ".deleteBlock(" . $aBlock['id'] . ")";
     if ($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_SERVICE) {
         $aBlock['content'] = BxDevFunctions::unserializeString($aBlock['content']);
     }
     if ((int) $aBlock['designbox_id'] != 0) {
         $aBlock['designbox_id'] = $this->sSelectKeyPrefix . $aBlock['designbox_id'];
     }
 }