protected function getCodeAdd($sAction, $sObject)
 {
     $aForm = $this->getFormAdd($sAction, $sObject);
     $oForm = new BxTemplStudioFormView($aForm);
     if ($oForm->isSubmitted() && isset($oForm->aInputs['required'])) {
         $this->updateCheckerFields($oForm);
     }
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $sInputObject = $oForm->getCleanValue('object');
         //--- Process field name.
         bx_import('BxDolStudioLanguagesUtils');
         $sLanguage = BxDolStudioLanguagesUtils::getInstance()->getCurrentLangName(false);
         $sCaption = BxDolForm::getSubmittedValue('caption-' . $sLanguage, $aForm['form_attrs']['method']);
         $sName = $this->getFieldName($sInputObject, $sCaption);
         BxDolForm::setSubmittedValue('name', $sName, $oForm->aFormAttrs['method']);
         $this->onSubmitField($oForm);
         if (($iId = $oForm->insert()) === false) {
             return false;
         }
         $this->alterAdd($sName);
         return true;
     } else {
         return BxTemplStudioFunctions::getInstance()->popupBox('adm-form-field-add-' . $this->aParams['display'] . '-popup', _t('_adm_form_txt_field_add_popup'), BxDolStudioTemplate::getInstance()->parseHtmlByName('form_add_field.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $sObject, 'action' => $sAction)));
     }
 }
 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';
     $oForm = $this->_getFormObject($sAction);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         if (!empty($_FILES['icon_image']['tmp_name'])) {
             bx_import('BxDolStorage');
             $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
             $mixedIcon = $oStorage->storeFileFromForm($_FILES['icon_image'], false, 0);
             if ($mixedIcon === false) {
                 $this->_echoResultJson(array('msg' => _t('_adm_nav_err_items_icon_image') . $oStorage->getErrorString()), true);
                 return;
             }
             $oStorage->afterUploadCleanup($mixedIcon, 0);
             BxDolForm::setSubmittedValue('icon', $mixedIcon, $oForm->aFormAttrs['method']);
         }
         bx_import('BxDolPermalinks');
         $oPermalinks = BxDolPermalinks::getInstance();
         $sLink = $oForm->getCleanValue('link');
         $sLink = $oPermalinks->unpermalink($sLink);
         BxDolForm::setSubmittedValue('link', $sLink, $oForm->aFormAttrs['method']);
         $sName = $oPermalinks->getPageNameFromLink($sLink);
         if ($sName == '') {
             bx_import('BxDolStudioLanguagesUtils');
             $sLanguage = BxDolStudioLanguagesUtils::getInstance()->getCurrentLangName(false);
             $sName = BxDolForm::getSubmittedValue('title_system-' . $sLanguage, $oForm->aFormAttrs['method']);
             $sName = uriGenerate($sName, 'sys_menu_items', 'name', 'item');
         }
         $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']);
         }
         $iId = (int) $oForm->insert(array('module' => BX_DOL_STUDIO_MODULE_CUSTOM, 'name' => $sName, 'active' => 1, 'order' => $this->oDb->getItemOrderMax($this->sSet) + 1));
         if ($iId != 0) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_adm_nav_err_items_create'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-nav-item-create-popup', _t('_adm_nav_txt_items_create_popup'), $this->_oTemplate->parseHtmlByName('nav_add_item.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);
     }
 }
示例#4
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);
     }
 }
 public function performActionAdd()
 {
     $sAction = 'add';
     $oForm = $this->_getFormObject($sAction);
     if ($oForm->isSubmitted() && isset($oForm->aInputs['set_name'])) {
         $this->updateSetFields($oForm);
     }
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         bx_import('BxDolStudioLanguagesUtils');
         $oLanguage = BxDolStudioLanguagesUtils::getInstance();
         $sLanguage = $oLanguage->getCurrentLangName(false);
         $sObject = BxDolForm::getSubmittedValue('title-' . $sLanguage, $oForm->aFormAttrs['method']);
         $sObject = uriGenerate($sObject, 'sys_objects_menu', 'object', 'object');
         //--- New Set Creation
         if ($oForm->getCleanValue('set_name') == $this->sCreateNew) {
             $sSetTitleValue = $oForm->getCleanValue('set_title');
             $sSetName = uriGenerate($sSetTitleValue, 'sys_menu_sets', 'set_name', 'set');
             $sSetTitleKey = '_adm_nav_txt_set_' . $sSetName;
             if ($this->oDb->addSet(array('set_name' => $sSetName, 'module' => BX_DOL_STUDIO_MODULE_CUSTOM, 'title' => $sSetTitleKey, 'deletable' => 1))) {
                 $oLanguage->addLanguageString($sSetTitleKey, $sSetTitleValue);
                 BxDolForm::setSubmittedValue('set_name', $sSetName, $oForm->aFormAttrs['method']);
             }
         }
         unset($oForm->aInputs['set_title']);
         $iId = (int) $oForm->insert(array('object' => $sObject, 'module' => BX_DOL_STUDIO_MODULE_CUSTOM, 'deletable' => 1, 'active' => 1));
         if ($iId != 0) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_adm_nav_err_menus_create'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-nav-menu-create-popup', _t('_adm_nav_txt_menus_create_popup'), $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);
     }
 }
示例#6
0
 function get($sName, $sPass = '******', $aParams = array(), $sType = '')
 {
     if (!$sPass) {
         $sPass = '******';
     }
     $this->_oChecker;
     $val = BxDolForm::getSubmittedValue($sName, $this->_sFormMethod);
     $mixedVal = call_user_func_array(array($this->_oChecker, 'pass' . ucfirst($sPass)), $aParams ? array_merge(array($val), $aParams) : array($val));
     if (is_array($mixedVal) && 'select_multiple' == $sType) {
         $mixedVal = serialize($mixedVal);
     }
     return $mixedVal;
 }
 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);
 }
示例#8
0
 function checkLengthTranslatable($sVal, $iLenMin, $iLenMax, $aName, $sMethod = BX_DOL_STUDIO_METHOD_DEFAULT, $bAll = true)
 {
     if (empty($sMethod) || empty($aName)) {
         return false;
     }
     $aLanguages = BxDolStudioLanguagesUtils::getInstance()->getLanguages();
     foreach ($aLanguages as $sLangName => $sLangTitle) {
         $sValue = BxDolForm::getSubmittedValue($aName . '-' . $sLangName, $sMethod);
         $bValue = parent::checkLength($sValue, $iLenMin, $iLenMax);
         if ($bAll && !$bValue) {
             return false;
         }
         if (!$bAll && $bValue) {
             return true;
         }
     }
     return $bAll ? true : false;
 }
示例#9
0
 function get($sName, $sPass = '******', $aParams = array())
 {
     if (!$sPass) {
         $sPass = '******';
     }
     $this->_oChecker;
     $val = BxDolForm::getSubmittedValue($sName, $this->_sFormMethod, $this->_aSpecificValues);
     return call_user_func_array(array($this->_oChecker, 'pass' . ucfirst($sPass)), $aParams ? array_merge(array($val), $aParams) : array($val));
 }