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); } }
public function performActionAdd() { $sAction = 'add'; $sFormObject = $this->oModule->_oConfig->getObject('form_nav_menu'); $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_nav_menu_add'); 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; $this->fillInSelects($oForm->aInputs); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $sObject = uriGenerate($oForm->getCleanValue('object'), 'sys_objects_menu', 'object', 'object'); BxDolForm::setSubmittedValue('object', $sObject, $oForm->aFormAttrs['method']); if (($iId = (int) $oForm->insert()) != 0) { $aRes = array('grid' => $this->getCode(false), 'blink' => $iId); } else { $aRes = array('msg' => _t('_bx_dev_nav_err_menus_create')); } $this->_echoResultJson($aRes, true); } else { bx_import('BxTemplStudioFunctions'); $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-menu-create-popup', _t('_bx_dev_nav_txt_menus_create_popup'), $this->oModule->_oTemplate->parseHtmlByName('nav_add_menu.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); } }
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); } }
public function performActionAdd() { $sAction = 'add'; $sFormObject = $this->oModule->_oConfig->getObject('form_forms_display'); $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_forms_display_add'); $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate); $this->_fillDisplayForm($oForm, $sAction); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $sName = uriGenerate($oForm->getCleanValue('display_name'), 'sys_form_displays', 'display_name', 'display'); BxDolForm::setSubmittedValue('display_name', $sName, $oForm->aFormAttrs['method']); if (($iId = (int) $oForm->insert()) != 0) { $aRes = array('grid' => $this->getCode(false), 'blink' => $iId); } else { $aRes = array('msg' => _t('_bx_dev_frm_err_displays_create')); } $this->_echoResultJson($aRes, true); } else { $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-frm-display-create-popup', _t('_bx_dev_frm_txt_displays_create_popup'), $this->_oTemplate->parseHtmlByName('form_add_display.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); } }
public function performActionEdit() { $sAction = 'edit'; $aMenu = $this->_getItem('getMenus'); if ($aMenu === false) { $this->_echoResultJson(array()); exit; } $oForm = $this->_getFormObject($sAction, $aMenu); if ($oForm->isSubmitted() && isset($oForm->aInputs['set_name'])) { $this->updateSetFields($oForm); } $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { //--- New Set Creation if ($oForm->getCleanValue('set_name') == $this->sCreateNew) { $sSetTitleValue = $oForm->getCleanValue('set_title'); $sSetName = 'custom_' . $this->getSystemName($sSetTitleValue); $sSetTitleKey = '_adm_nav_txt_set_' . $sSetName; if ($this->oDb->addSet(array('set_name' => $sSetName, 'module' => BX_DOL_STUDIO_MODULE_CUSTOM, 'title' => $sSetTitleKey, 'deletable' => 1))) { bx_import('BxDolStudioLanguagesUtils'); BxDolStudioLanguagesUtils::getInstance()->addLanguageString($sSetTitleKey, $sSetTitleValue); BxDolForm::setSubmittedValue('set_name', $sSetName, $oForm->aFormAttrs['method']); } } unset($oForm->aInputs['set_title']); if ($oForm->update($aMenu['id']) !== false) { $aRes = array('grid' => $this->getCode(false), 'blink' => $aMenu['id']); } else { $aRes = array('msg' => _t('_adm_nav_err_menus_edit')); } $this->_echoResultJson($aRes, true); } else { bx_import('BxTemplStudioFunctions'); $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-nav-menu-edit-popup', _t('_adm_nav_txt_menus_edit_popup', _t($aMenu['title'])), $this->_oTemplate->parseHtmlByName('nav_add_menu.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); } }
public function performActionAdd() { $sAction = 'add'; bx_import('BxDolForm'); $oForm = BxDolForm::getObjectInstance('mod_dev_nav_set', 'mod_dev_nav_set_add'); $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction; $oForm->aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_nav_txt_select_module')), BxDolStudioUtils::getModules()); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $sName = uriGenerate($oForm->getCleanValue('set_name'), 'sys_menu_sets', 'set_name', 'set'); BxDolForm::setSubmittedValue('set_name', $sName, $oForm->aFormAttrs['method']); if ($oForm->insert() !== false) { $aRes = array('grid' => $this->getCode(false), 'blink' => $sName); } else { $aRes = array('msg' => _t('_bx_dev_nav_err_sets_create')); } $this->_echoResultJson($aRes, true); } else { bx_import('BxTemplStudioFunctions'); $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-set-create-popup', _t('_bx_dev_nav_txt_sets_create_popup'), $this->_oTemplate->parseHtmlByName('nav_add_set.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); } }
public function performActionAdd() { $sAction = 'add'; $sFormObject = $this->oModule->_oConfig->getObject('form_forms_prelist'); $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_forms_prelist_add'); $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->initChecker(); if ($oForm->isSubmittedAndValid()) { $sObject = uriGenerate($oForm->getCleanValue('key'), 'sys_form_pre_lists', 'key', 'key'); BxDolForm::setSubmittedValue('key', $sObject, $oForm->aFormAttrs['method']); if (($iId = (int) $oForm->insert()) != 0) { $aRes = array('grid' => $this->getCode(false), 'blink' => $iId); } else { $aRes = array('msg' => _t('_bx_dev_frm_err_prelists_create')); } $this->_echoResultJson($aRes, true); } else { $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-frm-prelist-create-popup', _t('_bx_dev_frm_txt_prelists_create_popup'), $this->oModule->_oTemplate->parseHtmlByName('form_add_list.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); } }
public function performActionEdit($bUpdateGrid = false) { $sAction = 'edit'; $aItem = $this->_getItem('getItems'); if ($aItem === false) { $this->_echoResultJson(array()); exit; } $oForm = $this->_getFormObject($sAction, $aItem); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $bIconImageCur = is_numeric($aItem['icon']) && (int) $aItem['icon'] != 0; $bIconImageNew = !empty($_FILES['icon_image']['tmp_name']); $sIconFont = $oForm->getCleanValue('icon'); $bIconFont = !empty($sIconFont); if ($bIconImageCur && ($bIconImageNew || $bIconFont)) { $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES); if (!$oStorage->deleteFile((int) $aItem['icon'], 0)) { $this->_echoResultJson(array('msg' => _t('_adm_nav_err_items_icon_image_remove')), true); return; } } $sIcon = $sIconFont; if ($bIconImageNew) { $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES); $sIcon = $oStorage->storeFileFromForm($_FILES['icon_image'], false, 0); if ($sIcon === false) { $this->_echoResultJson(array('msg' => _t('_adm_nav_err_items_icon_image') . $oStorage->getErrorString()), true); return; } $oStorage->afterUploadCleanup($sIcon, 0); } else { if ($bIconImageCur && !$bIconFont) { $sIcon = $aItem['icon']; } } BxDolForm::setSubmittedValue('icon', $sIcon, $oForm->aFormAttrs['method']); $sLink = $oForm->getCleanValue('link'); $sLink = BxDolPermalinks::getInstance()->unpermalink($sLink); BxDolForm::setSubmittedValue('link', $sLink, $oForm->aFormAttrs['method']); $sSubmenu = $oForm->getCleanValue('submenu_object'); if (!empty($sSubmenu)) { $sLink = $oForm->getCleanValue('link'); if (empty($sLink)) { BxDolForm::setSubmittedValue('link', 'javascript:void(0)', $oForm->aFormAttrs['method']); } BxDolForm::setSubmittedValue('target', '', $oForm->aFormAttrs['method']); BxDolForm::setSubmittedValue('onclick', 'bx_menu_popup(\'' . $sSubmenu . '\', this);', $oForm->aFormAttrs['method']); } else { $sOnClick = $oForm->getCleanValue('onclick'); if (mb_substr($sOnClick, 0, 13) == 'bx_menu_popup') { BxDolForm::setSubmittedValue('onclick', '', $oForm->aFormAttrs['method']); } } $sTarget = $oForm->getCleanValue('target'); if ($sTarget === false && !in_array($aItem['target'], array('', '_blank'))) { unset($oForm->aInputs['target']); } if ($oForm->update($aItem['id']) !== false) { $aRes = array('grid' => $this->getCode(false), 'blink' => $aItem['id']); } else { $aRes = array('msg' => _t('_adm_nav_err_items_edit')); } $this->_echoResultJson($aRes, true); } else { $sTitle = _t($aItem['title']); $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-nav-item-edit-popup', _t('_adm_nav_txt_items_edit_popup', $sTitle != "" ? '"' . $sTitle . '"' : ''), $this->_oTemplate->parseHtmlByName('nav_add_item.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction))); $aRes = array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))); if ($bUpdateGrid) { $aRes = array_merge($aRes, array('grid' => $this->getCode(false), 'blink' => $aItem['id'])); } $this->_echoResultJson($aRes, true); } }
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']); } }
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']); } }
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); }
public function getFormPost() { $iUserId = $this->getUserId(); bx_import('BxDolForm'); $oForm = BxDolForm::getObjectInstance('mod_tml_post', 'mod_tml_post_add'); $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'post/'; $oForm->aInputs['owner_id']['value'] = $this->_iOwnerId; if (isset($oForm->aInputs['link'])) { $oForm->aInputs['link']['content'] = $this->_oTemplate->getAttachLinkField($iUserId); } if (isset($oForm->aInputs['photo'])) { $aFormNested = array('params' => array('nested_form_template' => 'uploader_nfw.html'), 'inputs' => array()); bx_import('BxDolFormNested'); $oFormNested = new BxDolFormNested('photo', $aFormNested, 'do_submit', $this->_oTemplate); $oForm->aInputs['photo']['storage_object'] = $this->_oConfig->getObject('storage'); $oForm->aInputs['photo']['images_transcoder'] = $this->_oConfig->getObject('transcoder_preview'); $oForm->aInputs['photo']['uploaders'] = $this->_oConfig->getUploaders('image'); $oForm->aInputs['photo']['upload_buttons_titles'] = array('Simple' => 'camera'); $oForm->aInputs['photo']['multiple'] = true; $oForm->aInputs['photo']['ghost_template'] = $oFormNested; } $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { list($sUserName) = $this->getUserInfo($iUserId); $sType = $oForm->getCleanValue('type'); $sType = $this->_oConfig->getPrefix('common_post') . $sType; BxDolForm::setSubmittedValue('type', $sType, $oForm->aFormAttrs['method']); $aContent = array(); //--- Process Text ---// $sText = $oForm->getCleanValue('text'); unset($oForm->aInputs['text']); $aContent['text'] = $this->_prepareTextForSave($sText); //--- Process Link ---// $aLinkIds = $oForm->getCleanValue('link'); unset($oForm->aInputs['link']); //--- Process Photos ---// $aPhotoIds = $oForm->getCleanValue('photo'); unset($oForm->aInputs['photo']); $sTitle = _t('_bx_timeline_txt_user_added_sample', $sUserName, _t('_bx_timeline_txt_sample')); $sDescription = !empty($aContent['text']) ? $aContent['text'] : ''; $iId = $oForm->insert(array('object_id' => $iUserId, 'object_privacy_view' => $this->_oConfig->getPrivacyViewDefault(), 'content' => serialize($aContent), 'title' => $sTitle, 'description' => $sDescription, 'date' => time())); if (!empty($iId)) { if (!empty($aLinkIds) && is_array($aLinkIds)) { foreach ($aLinkIds as $iLinkId) { $this->_oDb->saveLink($iId, $iLinkId); } } if (!empty($aPhotoIds) && is_array($aPhotoIds)) { bx_import('BxDolStorage'); $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage')); foreach ($aPhotoIds as $iPhotoId) { if ($this->_oDb->savePhoto($iId, $iPhotoId)) { $oStorage->afterUploadCleanup($iPhotoId, $iUserId); } } } $this->onPost($iId); return array('id' => $iId); } return array('msg' => _t('_bx_timeline_txt_err_cannot_perform_action')); } return array('form' => $oForm->getCode(), 'form_id' => $oForm->id); }
public function getFormPost() { $iUserId = $this->getUserId(); $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject('form_post'), $this->_oConfig->getObject('form_display_post_add'), $this->_oTemplate); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { list($sUserName) = $this->getUserInfo($iUserId); $sType = $oForm->getCleanValue('type'); $sType = $this->_oConfig->getPrefix('common_post') . $sType; BxDolForm::setSubmittedValue('type', $sType, $oForm->aFormAttrs['method']); $aContent = array(); //--- Process Text ---// $sText = $oForm->getCleanValue('text'); unset($oForm->aInputs['text']); $aContent['text'] = $this->_prepareTextForSave($sText); //--- Process Link ---// $aLinkIds = $oForm->getCleanValue('link'); //--- Process Media ---// $aPhotoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_PHOTO); $aVideoIds = $oForm->getCleanValue(BX_TIMELINE_MEDIA_VIDEO); $sTitle = _t('_bx_timeline_txt_user_added_sample', $sUserName, _t('_bx_timeline_txt_sample')); $sDescription = !empty($aContent['text']) ? $aContent['text'] : ''; $iId = $oForm->insert(array('object_id' => $iUserId, 'object_privacy_view' => $this->_oConfig->getPrivacyViewDefault(), 'content' => serialize($aContent), 'title' => $sTitle, 'description' => $sDescription, 'date' => time())); if (!empty($iId)) { $oMetatags = BxDolMetatags::getObjectInstance($this->_oConfig->getObject('metatags')); $oMetatags->keywordsAdd($iId, $aContent['text']); $oMetatags->locationsAddFromForm($iId, $this->_oConfig->CNF['FIELD_LOCATION_PREFIX']); //--- Process Link ---// if (!empty($aLinkIds) && is_array($aLinkIds)) { foreach ($aLinkIds as $iLinkId) { $this->_oDb->saveLink($iId, $iLinkId); } } //--- Process Media ---// $this->_saveMedia(BX_TIMELINE_MEDIA_PHOTO, $iId, $aPhotoIds); $this->_saveMedia(BX_TIMELINE_MEDIA_VIDEO, $iId, $aVideoIds); $this->onPost($iId); return array('id' => $iId); } return array('msg' => _t('_bx_timeline_txt_err_cannot_perform_action')); } return array('form' => $oForm->getCode(), 'form_id' => $oForm->id); }
protected function processTranslationsKey($sType = 'insert') { $sLanguage = BxDolStudioLanguagesUtils::getInstance()->getCurrentLangName(false); foreach ($this->aInputs as $sName => $aInput) { if (in_array($aInput['type'], array('text_translatable', 'textarea_translatable'))) { $sKey = $this->getTranslationsKey($sType, $sName, $this->getCleanValue($sName)); BxDolForm::setSubmittedValue($sName, $sKey, $this->aFormAttrs['method']); } } }
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]; $aLevel = array(); $iLevel = $this->oDb->getLevels(array('type' => 'by_id', 'value' => $iId), $aLevel); if ($iLevel != 1 || empty($aLevel)) { $this->_echoResultJson(array()); exit; } $oForm = $this->_getFormObject($sAction, $aLevel); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $bIconImageCur = is_numeric($aLevel['icon']) && (int) $aLevel['icon'] != 0; $bIconImageNew = !empty($_FILES['Icon_image']['tmp_name']); $sIconFont = $oForm->getCleanValue('Icon'); $bIconFont = !empty($sIconFont); if ($bIconImageCur && ($bIconImageNew || $bIconFont)) { $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES); if (!$oStorage->deleteFile((int) $aLevel['icon'], 0)) { $this->_echoResultJson(array('msg' => _t('_adm_prm_err_level_icon_image_remove')), true); return; } } $sIcon = $sIconFont; if ($bIconImageNew) { $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES); $sIcon = $oStorage->storeFileFromForm($_FILES['Icon_image'], false, 0); if ($sIcon === false) { $this->_echoResultJson(array('msg' => _t('_adm_prm_err_level_icon_image') . $oStorage->getErrorString()), true); return; } $oStorage->afterUploadCleanup($sIcon, 0); } else { if ($bIconImageCur && !$bIconFont) { $sIcon = $aLevel['icon']; } } BxDolForm::setSubmittedValue('Icon', $sIcon, $oForm->aFormAttrs['method']); $fQuotaSize = round($oForm->getCleanValue('QuotaSize'), 1); BxDolForm::setSubmittedValue('QuotaSize', self::$iBinMB * $fQuotaSize, $oForm->aFormAttrs['method']); $fQuotaMaxFileSize = round($oForm->getCleanValue('QuotaMaxFileSize'), 1); BxDolForm::setSubmittedValue('QuotaMaxFileSize', self::$iBinMB * $fQuotaMaxFileSize, $oForm->aFormAttrs['method']); if ($oForm->update($iId) !== false) { $aRes = array('grid' => $this->getCode(false), 'blink' => $iId); } else { $aRes = array('msg' => _t('_adm_prm_err_level_edit')); } $this->_echoResultJson($aRes, true); } else { $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-prm-level-edit-popup', _t('_adm_prm_txt_level_edit_popup', _t($aLevel['name'])), $this->_oTemplate->parseHtmlByName('prm_add_level.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); } }
protected function onSubmitField(&$oForm) { //--- Process field values. if (isset($oForm->aInputs['values']['db'])) { $sValues = $oForm->getCleanValue('values'); if (is_string($sValues) && strpos($sValues, BX_DATA_LISTS_KEY_PREFIX) === false) { BxDolForm::setSubmittedValue('values', serialize(explode("\n", $sValues)), $oForm->aFormAttrs['method']); } } //--- Process field 'html' flag. if (isset($oForm->aInputs['html'])) { $iHtml = (int) $oForm->getCleanValue('html'); BxDolForm::setSubmittedValue('db_pass', $iHtml == 0 ? 'Xss' : 'XssHtml', $oForm->aFormAttrs['method']); } //--- Process field checker. $aCheckerParams = array(); if (isset($oForm->aInputs['checker_params_length_min'], $oForm->aInputs['checker_params_length_max'])) { $aCheckerParams['min'] = $oForm->getCleanValue('checker_params_length_min'); $aCheckerParams['max'] = $oForm->getCleanValue('checker_params_length_max'); } if (isset($oForm->aInputs['checker_params_preg'])) { $aCheckerParams['preg'] = $oForm->getCleanValue('checker_params_preg'); } unset($oForm->aInputs['checker_params_length_min'], $oForm->aInputs['checker_params_length_max'], $oForm->aInputs['checker_params_preg']); BxDolForm::setSubmittedValue('checker_params', !empty($aCheckerParams) ? serialize($aCheckerParams) : '', $oForm->aFormAttrs['method']); //--- Process field attrs. $aAttrs = array(); if (isset($oForm->aInputs['attrs_min'], $oForm->aInputs['attrs_max'], $oForm->aInputs['attrs_step'])) { $aAttrs['min'] = $oForm->getCleanValue('attrs_min'); $aAttrs['max'] = $oForm->getCleanValue('attrs_max'); $aAttrs['step'] = $oForm->getCleanValue('attrs_step'); } else { if (isset($oForm->aInputs['attrs_src'])) { $aAttrs['src'] = $oForm->getCleanValue('attrs_src'); } } unset($oForm->aInputs['attrs_min'], $oForm->aInputs['attrs_max'], $oForm->aInputs['attrs_step'], $oForm->aInputs['attrs_src']); BxDolForm::setSubmittedValue('attrs', serialize($aAttrs), $oForm->aFormAttrs['method']); }