コード例 #1
0
ファイル: BxDolStudioForm.php プロジェクト: blas-dmx/trident
 function updateWithVisibility($iId)
 {
     $iVisibleFor = BxDolStudioUtils::getVisibilityValue($this->getCleanValue('visible_for'), $this->getCleanValue('visible_for_levels'));
     BxDolForm::setSubmittedValue('visible_for_levels', $iVisibleFor, $this->aFormAttrs['method']);
     unset($this->aInputs['visible_for']);
     return $this->update($iId);
 }
コード例 #2
0
 protected function onSaveBlock(&$oForm, &$aBlock)
 {
     $iDesignboxId = (int) str_replace($this->sSelectKeyPrefix, '', $oForm->getCleanValue('designbox_id'));
     BxDolForm::setSubmittedValue('designbox_id', $iDesignboxId, $oForm->aFormAttrs['method']);
     $iVisibleFor = BxDolStudioUtils::getVisibilityValue($oForm->getCleanValue('visible_for'), $oForm->getCleanValue('visible_for_levels'));
     BxDolForm::setSubmittedValue('visible_for_levels', $iVisibleFor, $oForm->aFormAttrs['method']);
     unset($oForm->aInputs['visible_for']);
     //--- Process Lang fields
     if ($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_LANG && isset($oForm->aInputs['content'])) {
         bx_import('BxDolStudioLanguagesUtils');
         $oLanguage = BxDolStudioLanguagesUtils::getInstance();
         $sContentKey = '';
         $sContentValue = $oForm->getCleanValue('content');
         if ($aBlock['content'] == '') {
             $sContentKey = '_sys_bpb_content_' . $aBlock['id'];
             $oLanguage->addLanguageString($sContentKey, $sContentValue);
         } else {
             $sContentKey = $aBlock['content'];
             $oLanguage->updateLanguageString($sContentKey, $sContentValue);
         }
         BxDolForm::setSubmittedValue('content', $sContentKey, $oForm->aFormAttrs['method']);
     }
     //--- Process Image fields
     if ($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_IMAGE && isset($oForm->aInputs['image_file'], $oForm->aInputs['image_align'])) {
         $iImageId = 0;
         if ($aBlock['content'] != '') {
             list($iImageId) = explode($this->sParamsDivider, $aBlock['content']);
         }
         $iImageId = $oForm->processImageUploaderSave('image_file', $iImageId);
         if (is_string($iImageId) && !is_numeric($iImageId)) {
             return array('msg' => $iImageId);
         }
         $sImageAlign = $oForm->getCleanValue('image_align');
         unset($oForm->aInputs['image_file'], $oForm->aInputs['image_align']);
         BxDolForm::setSubmittedValue('content', implode($this->sParamsDivider, array($iImageId, $sImageAlign)), $oForm->aFormAttrs['method']);
     }
     //--- Process RSS fields
     if ($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_RSS && isset($oForm->aInputs['rss_url'], $oForm->aInputs['rss_length'])) {
         $aRss = array(trim($oForm->getCleanValue('rss_url')), $oForm->getCleanValue('rss_length'));
         unset($oForm->aInputs['rss_url'], $oForm->aInputs['rss_length']);
         BxDolForm::setSubmittedValue('content', implode($this->sParamsDivider, $aRss), $oForm->aFormAttrs['method']);
     }
 }
コード例 #3
0
 protected function actionPageEdit()
 {
     $sJsObject = $this->getPageJsObject();
     $oTemplate = BxDolStudioTemplate::getInstance();
     $aForm = array('form_attrs' => array('id' => 'adm-bp-page-edit', 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionPageEdit, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_objects_page', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('settings' => array('type' => 'custom', 'name' => 'settings', 'content' => $oTemplate->parseHtmlByName('bp_edit_page_form.html', $this->_getTmplVarsPageSettings($this->aPageRebuild, false)))));
     $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'}($this->aPageRebuild, false));
         }
         $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']);
         if ($oForm->update($this->aPageRebuild['id'])) {
             $iLevelId = $oForm->getCleanValue('layout_id');
             if (!empty($iLevelId) && $iLevelId != $this->aPageRebuild['layout_id']) {
                 $aLayoutOld = array();
                 $this->oDb->getLayouts(array('type' => 'by_id', 'value' => $this->aPageRebuild['layout_id']), $aLayoutOld, false);
                 $aLayoutNew = array();
                 $this->oDb->getLayouts(array('type' => 'by_id', 'value' => $iLevelId), $aLayoutNew, false);
                 if ($aLayoutOld['cells_number'] > $aLayoutNew['cells_number'] && $this->oDb->resetBlocksByPage($this->sPage, $aLayoutNew['cells_number']) === false) {
                     return array('msg' => _t('_adm_bp_err_save'));
                 }
                 return array('eval' => $sJsObject . '.onSaveSettings()');
             }
             return array();
         } else {
             return array('msg' => _t('_adm_bp_err_save'));
         }
     }
     bx_import('BxTemplStudioFunctions');
     $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['edit_popup_id'], _t('_adm_bp_txt_settings_popup'), $oTemplate->parseHtmlByName('bp_edit_page.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true))));
     return array('popup' => $sContent);
 }