Example #1
0
 function getQueryInsert($sTable, $aItems, $mixedComment = false, $aExclude = array('id'))
 {
     $bFirst = true;
     $sContent = $sComment = "";
     foreach ($aItems as $aItem) {
         foreach ($aExclude as $sKey) {
             if (isset($aItem[$sKey])) {
                 unset($aItem[$sKey]);
             }
         }
         $aKeys = array_keys($aItem);
         $aValues = array_values($aItem);
         $iValues = count($aValues);
         foreach ($aValues as $iKey => $sValue) {
             $aValues[$iKey] = BxDevFunctions::dbAddSlashes($sValue, true);
         }
         if ($bFirst) {
             $sContent .= "INSERT INTO `" . $sTable . "`(`" . implode("`, `", $aKeys) . "`) VALUES \n";
             $bFirst = false;
         }
         $sSql = "(" . implode(", ", array_fill(0, $iValues, "?")) . "),\n";
         $sSql = call_user_func_array(array($this, 'prepare'), array_merge(array($sSql), $aValues));
         $sContent .= $sSql;
     }
     $sContent = substr($sContent, 0, -2) . ";\n\n";
     if ($mixedComment === true || is_string($mixedComment) && $mixedComment != '') {
         $sComment = "--\n-- " . ($mixedComment === true ? "Dumping data for table `" . $sTable . "`" : $mixedComment) . "\n--\n";
     }
     return $sComment . $sContent;
 }
Example #2
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 #3
0
 protected function onSaveBlock(&$oForm, &$aBlock)
 {
     parent::onSaveBlock($oForm, $aBlock);
     if ($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_SERVICE && isset($oForm->aInputs['content'])) {
         $sValue = $oForm->getCleanValue('content');
         $sValue = BxDevFunctions::serializeString($sValue);
         BxDolForm::setSubmittedValue('content', $sValue, $oForm->aFormAttrs['method']);
     }
 }
Example #4
0
 function __construct($aParams = array(), $aField = array())
 {
     parent::__construct($aParams, $aField);
     BxDevFunctions::changeFormField($this->aParams, $this->aForm['inputs'], $this->oDb);
 }