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)));
     }
 }
Example #2
0
 public function init()
 {
     if (($sAction = bx_get('pgt_action')) === false) {
         return;
     }
     $sAction = bx_process_input($sAction);
     $oLanguages = BxDolStudioLanguagesUtils::getInstance();
     $aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
     switch ($sAction) {
         case 'get-page-by-type':
             $sValue = bx_process_input(bx_get('pgt_value'));
             if (empty($sValue)) {
                 break;
             }
             $this->sPage = $sValue;
             $aResult = array('code' => 0, 'content' => $this->getPageCode());
             break;
             /*
              * Available URL params:
              * pgt_action = recompile - action name
              * pgt_language - ID or name(en, ru, etc) of language.
              */
         /*
          * Available URL params:
          * pgt_action = recompile - action name
          * pgt_language - ID or name(en, ru, etc) of language.
          */
         case 'recompile':
             $sLanguage = bx_process_input(bx_get('pgt_language'));
             if ($oLanguages->compileLanguage($sLanguage)) {
                 $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_recompiled'));
             } else {
                 $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_recompile_lang'));
             }
             break;
             /*
              * Available URL params:
              * pgt_action = restore - action name
              * pgt_language - ID or name(en, ru, etc) of language.
              * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
              */
         /*
          * Available URL params:
          * pgt_action = restore - action name
          * pgt_language - ID or name(en, ru, etc) of language.
          * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
          */
         case 'restore':
             $sLanguage = bx_process_input(bx_get('pgt_language'));
             $sModule = bx_process_input(bx_get('pgt_module'));
             if ($oLanguages->restoreLanguage($sLanguage, $sModule)) {
                 $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_restored'));
             } else {
                 $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_restore_lang'));
             }
             break;
     }
     echo json_encode($aResult);
     exit;
 }
 public function performActionImport()
 {
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aIdsAffected = array();
     foreach ($aIds as $iId) {
         $aItem = array();
         $iItem = $this->oDb->getItems(array('type' => 'by_id', 'value' => (int) $iId), $aItem);
         if ($iItem != 1 || empty($aItem)) {
             continue;
         }
         $mixedIcon = 0;
         if (is_numeric($aItem['icon']) && (int) $aItem['icon'] != 0) {
             bx_import('BxDolStorage');
             $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
             if (($mixedIcon = $oStorage->storeFileFromStorage(array('id' => (int) $aItem['icon']), false, 0)) === false) {
                 $this->_echoResultJson(array('msg' => _t('_adm_nav_err_items_icon_copy') . $oStorage->getErrorString()), true);
                 return;
             }
             $oStorage->afterUploadCleanup($mixedIcon, 0);
         }
         $iIdImported = (int) $aItem['id'];
         $sTitleKey = $aItem['title'];
         unset($aItem['id']);
         $aItem['set_name'] = $this->sSet;
         $aItem['module'] = BX_DOL_STUDIO_MODULE_CUSTOM;
         $aItem['title'] .= '_' . time();
         $aItem['icon'] = $mixedIcon != 0 ? $mixedIcon : '';
         $aItem['active'] = 1;
         $aItem['order'] = $this->oDb->getItemOrderMax($this->sSet) + 1;
         if (($iIdAdded = (int) $this->oDb->addItem($aItem)) == 0) {
             continue;
         }
         bx_import('BxDolStudioLanguagesUtils');
         BxDolStudioLanguagesUtils::getInstance()->addLanguageString($aItem['title'], _t($sTitleKey));
         $aIdsImported[] = $iIdImported;
         $aIdsAdded[] = $iIdAdded;
         $iAffected++;
     }
     $aResult = array('msg' => _t('_adm_nav_err_items_import'));
     if ($iAffected) {
         $oGrid = BxDolGrid::getObjectInstance('sys_studio_nav_items');
         if ($oGrid !== false) {
             $aResult = array('parent_grid' => $oGrid->getCode(false), 'parent_blink' => $aIdsAdded, 'disable' => $aIdsImported, 'eval' => $this->getJsObject() . '.onImport(oData)');
         }
     }
     $this->_echoResultJson($aResult);
 }
 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);
     }
 }
 function deleteByItem(&$aItem)
 {
     if (is_numeric($aItem['icon']) && (int) $aItem['icon'] != 0) {
         if (!BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int) $aItem['icon'], 0)) {
             return false;
         }
     }
     if ((int) $this->_delete($aItem['id']) <= 0) {
         return false;
     }
     $oLanguage = BxDolStudioLanguagesUtils::getInstance();
     $oLanguage->deleteLanguageString($aItem['title_system']);
     $oLanguage->deleteLanguageString($aItem['title']);
     return true;
 }
 protected function edit(&$oForm)
 {
     $iId = $oForm->getCleanValue('id');
     $aLanguages = explode(',', $oForm->getCleanValue('languages'));
     if (empty($iId) || empty($aLanguages)) {
         return _t('_adm_pgt_err_save');
     }
     $aStrings = array();
     foreach ($aLanguages as $iLanguageId) {
         $aStrings[$iLanguageId] = $oForm->getCleanValue('language_' . $iLanguageId);
     }
     if (!BxDolStudioLanguagesUtils::getInstance()->updateLanguageStringById($iId, $aStrings)) {
         return _t('_adm_pgt_err_save');
     }
     return $iId;
 }
 function genInputTranslatable(&$aInput, $sType = 'text')
 {
     $iValueLength = 20;
     $sInputIdPrefix = 'bx-form-input-';
     $aInputMethod = array('text' => 'genInputStandard', 'textarea' => 'genInputTextarea');
     $sInput = '';
     $sInputName = $aInput['name'];
     $aInputAttrs = isset($aInput['attrs']) && is_array($aInput['attrs']) ? $aInput['attrs'] : array();
     bx_import('BxTemplStudioFunctions');
     $oFunctions = BxTemplStudioFunctions::getInstance();
     bx_import('BxDolStudioLanguagesUtils');
     $oLanguage = BxDolStudioLanguagesUtils::getInstance();
     $sLanguage = $oLanguage->getCurrentLangName(false);
     $aLanguages = $oLanguage->getLanguagesInfo();
     $aStrings = $oLanguage->getLanguageString($aInput['value']);
     $aInput['type'] = 'hidden';
     $aInput['attrs'] = array_merge($aInputAttrs, array('id' => $sInputIdPrefix . $aInput['name']));
     $sInput .= $this->genInputStandard($aInput);
     $aTmplVars = array();
     foreach ($aLanguages as $aLanguage) {
         $bLanguage = $aLanguage['name'] == $sLanguage;
         $sValue = '';
         if (($bValue = key_exists($aLanguage['id'], $aStrings)) === true) {
             $sValue = $aStrings[$aLanguage['id']]['string'];
         } else {
             if (isset($aInput['values'][$aLanguage['name']])) {
                 $sValue = $aInput['values'][$aLanguage['name']];
             }
         }
         $aInput['type'] = $sType;
         $aInput['name'] = $sInputName . '-' . $aLanguage['name'];
         $aInput['value'] = $sValue;
         $aInput['attrs'] = array_merge($aInputAttrs, array('id' => $sInputIdPrefix . $aInput['name'], 'style' => !$bLanguage ? 'display:none;' : ''));
         $sInput .= $this->{$aInputMethod}[$sType]($aInput);
         $aTmplVarValue = array('condition' => $bValue, 'content' => array('value' => strmaxtextlen($sValue, $iValueLength)));
         $aTmplVarMissing = array('condition' => !$bValue || empty($sValue), 'content' => array());
         $aTmplVars[] = array('name' => $sInputName, 'lang_name' => $aLanguage['name'], 'lang_flag' => $aLanguage['icon'], 'lang_title' => $aLanguage['title'], 'bx_if:hide_active' => array('condition' => !$bLanguage, 'content' => array()), 'bx_if:act_value' => $aTmplVarValue, 'bx_if:act_missing' => $aTmplVarMissing, 'bx_if:hide_passive' => array('condition' => $bLanguage, 'content' => array()), 'bx_if:pas_value' => $aTmplVarValue, 'bx_if:pas_missing' => $aTmplVarMissing);
     }
     $sPopup = $this->oTemplate->parseHtmlByName('form_view_translator.html', array('bx_repeat:languages' => $aTmplVars));
     $sPopup = $oFunctions->transBox('bx-form-field-translator-popup-' . $sInputName, $sPopup, true);
     $aLanguage = $oLanguage->getLanguageInfo($sLanguage);
     $sControl = $this->oTemplate->parseHtmlByName('form_view_translatable.html', array('flag' => $aLanguage['icon'], 'title' => $aLanguage['title'], 'name' => $sInputName, 'popup' => $sPopup));
     return $sInput . $sControl;
 }
 protected function delete($iId)
 {
     $aLevel = array();
     $iLevel = $this->oDb->getLevels(array('type' => 'by_id', 'value' => (int) $iId), $aLevel);
     if ($iLevel != 1 || empty($aLevel)) {
         return false;
     }
     if ($aLevel['removable'] != 'yes' || $this->oDb->isLevelUsed($aLevel['id'])) {
         return false;
     }
     if (is_numeric($aLevel['icon'])) {
         if (!BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int) $aLevel['icon'], 0)) {
             return false;
         }
     }
     $oLanguage = BxDolStudioLanguagesUtils::getInstance();
     $oLanguage->deleteLanguageString($aLevel['name']);
     $oLanguage->deleteLanguageString($aLevel['description']);
     return $this->oDb->deleteLevel(array('type' => 'by_id', 'value' => $aLevel['id']));
 }
 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']);
     }
 }
Example #10
0
 protected function _updateLanguage($bInstall, $sLanguage, $iCategory = 0, $sPath = '')
 {
     $oLanguages = BxDolStudioLanguagesUtils::getInstance();
     $sPathAbsolute = $this->_sHomePath . 'install/langs/' . $sPath . $sLanguage . '.xml';
     $aLanguageInfo = $oLanguages->readLanguage($sPathAbsolute, 'update');
     if (empty($aLanguageInfo)) {
         return false;
     }
     $iLanguage = $oLanguages->getLangId($sLanguage);
     if (!empty($aLanguageInfo['category'])) {
         $iCategory = $oLanguages->getLanguageCategory($aLanguageInfo['category']);
     }
     //--- Process delete. Note. Deletion is performed for all languages. ---//
     if (isset($aLanguageInfo['strings_del'])) {
         foreach ($aLanguageInfo['strings_del'] as $sKey => $sValue) {
             $oLanguages->deleteLanguageString($sKey, 0, false);
         }
     }
     //--- Process add. Note. Key's category will be updated if it doesn't match. ---//
     if (isset($aLanguageInfo['strings_add'])) {
         foreach ($aLanguageInfo['strings_add'] as $sKey => $sValue) {
             $oLanguages->addLanguageString($sKey, $sValue, $iLanguage, $iCategory, false);
         }
     }
     //--- Process update. Note. Key's category will be updated if it doesn't match. ---//
     if (isset($aLanguageInfo['strings_upd'])) {
         foreach ($aLanguageInfo['strings_upd'] as $sKey => $sValue) {
             $oLanguages->updateLanguageString($sKey, $sValue, $iLanguage, $iCategory, false);
         }
     }
     return true;
 }
 function __construct($sPage = "")
 {
     parent::__construct('polyglot');
     $this->oDb = new BxDolStudioPolyglotQuery();
     $this->sPage = BX_DOL_STUDIO_PGT_TYPE_DEFAULT;
     if (is_string($sPage) && !empty($sPage)) {
         $this->sPage = $sPage;
     }
     //--- Check actions ---//
     if (($sAction = bx_get('pgt_action')) !== false) {
         $sAction = bx_process_input($sAction);
         bx_import('BxDolStudioLanguagesUtils');
         $oLanguages = BxDolStudioLanguagesUtils::getInstance();
         $aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
         switch ($sAction) {
             case 'get-page-by-type':
                 $sValue = bx_process_input(bx_get('pgt_value'));
                 if (empty($sValue)) {
                     break;
                 }
                 $this->sPage = $sValue;
                 $aResult = array('code' => 0, 'content' => $this->getPageCode());
                 break;
                 /*
                  * Available URL params:
                  * pgt_action = recompile - action name
                  * pgt_language - ID or name(en, ru, etc) of language.
                  */
             /*
              * Available URL params:
              * pgt_action = recompile - action name
              * pgt_language - ID or name(en, ru, etc) of language.
              */
             case 'recompile':
                 $sLanguage = bx_process_input(bx_get('pgt_language'));
                 if ($oLanguages->compileLanguage($sLanguage)) {
                     $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_recompiled'));
                 } else {
                     $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_recompile_lang'));
                 }
                 break;
                 /*
                  * Available URL params:
                  * pgt_action = restore - action name
                  * pgt_language - ID or name(en, ru, etc) of language.
                  * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
                  */
             /*
              * Available URL params:
              * pgt_action = restore - action name
              * pgt_language - ID or name(en, ru, etc) of language.
              * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
              */
             case 'restore':
                 $sLanguage = bx_process_input(bx_get('pgt_language'));
                 $sModule = bx_process_input(bx_get('pgt_module'));
                 if ($oLanguages->restoreLanguage($sLanguage, $sModule)) {
                     $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_restored'));
                 } else {
                     $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_restore_lang'));
                 }
                 break;
         }
         echo json_encode($aResult);
         exit;
     }
 }
Example #12
0
 protected function checkLangExists($sLang)
 {
     if (!preg_match('/^[A-Za-z0-9_]+$/', $sLang)) {
         return false;
     }
     $iLangId = $this->oDb->getLanguageId($sLang);
     if (!$iLangId) {
         return false;
     }
     if (file_exists(BX_DIRECTORY_PATH_CACHE . "lang-{$sLang}.php")) {
         return true;
     }
     bx_import('BxDolStudioLanguagesUtils');
     if (BxDolStudioLanguagesUtils::getInstance()->compileLanguage($iLangId)) {
         return true;
     }
     return false;
 }
 public function performActionDelete()
 {
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aIdsAffected = array();
     foreach ($aIds as $iId) {
         if (!BxDolStudioLanguagesUtils::getInstance()->deleteLanguageStringById($iId, 0, false)) {
             continue;
         }
         $aIdsAffected[] = $iId;
         $iAffected++;
     }
     $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_pgt_err_save')));
 }
 protected function onBlockDelete($aBlock)
 {
     bx_import('BxDolStudioLanguagesUtils');
     BxDolStudioLanguagesUtils::getInstance()->deleteLanguageString($aBlock['title']);
     //--- Process Lang block
     if ($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_LANG && $aBlock['content'] != '') {
         BxDolStudioLanguagesUtils::getInstance()->deleteLanguageString($aBlock['content']);
     }
     //--- Process Image block
     if ($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_IMAGE && $aBlock['content'] != '') {
         $iImageId = $sImageAlign = '';
         list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
         if (is_numeric($iImageId) && (int) $iImageId != 0) {
             bx_import('BxDolStorage');
             BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES)->deleteFile((int) $iImageId, 0);
         }
     }
 }
 public function performActionDelete()
 {
     $sAction = 'delete';
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aIdsAffected = array();
     foreach ($aIds as $iId) {
         $aField = array();
         $this->oDb->getInputs(array('type' => 'by_object_id', 'object' => $this->sObject, 'id' => (int) $iId), $aField, false);
         if (empty($aField) || !is_array($aField)) {
             continue;
         }
         if ((int) $aField['deletable'] != 1) {
             continue;
         }
         $sClass = $this->sClass . $this->getClassName($aField['type']);
         $oClass = new $sClass(array('module' => $this->sModule, 'object' => $this->sObject, 'display' => $this->sDisplay));
         if ((int) $this->_delete($iId) <= 0 || !$this->oDb->deleteInputs(array('type' => 'by_id', 'value' => $aField['id'], 'object' => $aField['object'], 'name' => $aField['name']))) {
             continue;
         }
         $oClass->alterRemove($aField['name']);
         bx_import('BxDolStudioLanguagesUtils');
         $oLanguage = BxDolStudioLanguagesUtils::getInstance();
         if (!empty($aField['caption'])) {
             $oLanguage->deleteLanguageString($aField['caption']);
         }
         if (!empty($aField['info'])) {
             $oLanguage->deleteLanguageString($aField['info']);
         }
         if (!empty($aField['checker_error'])) {
             $oLanguage->deleteLanguageString($aField['checker_error']);
         }
         $aIdsAffected[] = $iId;
         $iAffected++;
     }
     $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_from_err_field_delete')));
 }
 public function performActionDelete()
 {
     $sAction = 'delete';
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aIdsAffected = array();
     foreach ($aIds as $iId) {
         $aList = array();
         $this->oDb->getLists(array('type' => 'by_id', 'value' => (int) $iId), $aList, false);
         if (!is_array($aList) || empty($aList)) {
             continue;
         }
         if (!$this->_canDelete($aList)) {
             continue;
         }
         if (!$this->oDb->deleteValues(array('type' => 'by_key', 'value' => $aList['key'])) || (int) $this->_delete($iId) <= 0) {
             continue;
         }
         bx_import('BxDolStudioLanguagesUtils');
         BxDolStudioLanguagesUtils::getInstance()->deleteLanguageString($aList['title']);
         $aIdsAffected[] = $iId;
         $iAffected++;
     }
     $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_from_err_pre_lists_delete')));
 }
Example #17
0
 public function performActionRestore()
 {
     bx_import('BxDolStudioLanguagesUtils');
     $aResult = array('msg' => _t(BxDolStudioLanguagesUtils::getInstance()->restoreLanguage() ? '_adm_pgt_scs_restored' : '_adm_pgt_err_cannot_restore_lang'));
     $this->_echoResultJson($aResult, true);
 }
 protected function _updateLanguage($bInstall, $sLanguage, $iCategoryId = 0)
 {
     $oDb = BxDolDb::getInstance();
     $oLanguages = BxDolStudioLanguagesUtils::getInstance();
     $sPath = $this->_sHomePath . 'install/langs/' . $sLanguage . '.xml';
     $aLanguageInfo = $oLanguages->readLanguage($sPath, 'update');
     if (empty($aLanguageInfo)) {
         return false;
     }
     $iLanguage = $oLanguages->getLangId($sLanguage);
     //--- Process delete ---//
     if (isset($aLanguageInfo['strings_del']) && is_array($aLanguageInfo['strings_del'])) {
         $oLanguages->deleteLanguageKeys($aLanguageInfo['strings_del']);
     }
     //--- Process add ---//
     if (isset($aLanguageInfo['strings_add']) && is_array($aLanguageInfo['strings_add'])) {
         $oLanguages->addLanguageKeys($iLanguage, $iCategoryId, $aLanguageInfo['strings_add']);
     }
     //--- Process update ---//
     if (isset($aLanguageInfo['strings_upd']) && is_array($aLanguageInfo['strings_upd'])) {
         $oLanguages->deleteLanguageKeys($aLanguageInfo['strings_upd']);
         $oLanguages->addLanguageKeys($iLanguage, $iCategoryId, $aLanguageInfo['strings_upd']);
     }
     return true;
 }
Example #19
0
 protected function actionUpdateLanguages($sOperation)
 {
     if (!isset($this->_aConfig['language_category']) || empty($this->_aConfig['language_category'])) {
         return BX_DOL_STUDIO_INSTALLER_FAILED;
     }
     $oLanguages = BxDolStudioLanguagesUtils::getInstance();
     $bResult = true;
     $aResult = array();
     //--- Process Language Category ---//
     if ($sOperation == 'install') {
         $iCategoryId = $oLanguages->addLanguageCategory($this->_aConfig['language_category']);
     }
     //--- Process languages' key=>value pears ---//
     $aModule = array('path' => $this->_aConfig['home_dir'], 'uri' => $this->_aConfig['home_uri'], 'lang_category' => $this->_aConfig['language_category']);
     if ($sOperation == 'install') {
         $bResult = $oLanguages->restoreLanguage(0, $aModule, false);
     } else {
         if ($sOperation == 'uninstall') {
             $bResult = $oLanguages->removeLanguageByModule($aModule, false);
         }
     }
     if ($sOperation == 'uninstall' && $bResult) {
         $oLanguages->deleteLanguageCategory($this->_aConfig['language_category']);
     }
     return $bResult && $oLanguages->compileLanguage(0, true) ? BX_DOL_STUDIO_INSTALLER_SUCCESS : BX_DOL_STUDIO_INSTALLER_FAILED;
 }
 public function performActionDelete()
 {
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     $oGridItems = BxDolGrid::getObjectInstance('sys_studio_nav_items');
     if (!$oGridItems) {
         $this->_echoResultJson(array());
         exit;
     }
     $aIdsAffected = array();
     foreach ($aIds as $sId) {
         $sId = bx_process_input($sId);
         $aSet = array();
         $this->oDb->getSets(array('type' => 'by_name', 'value' => $sId), $aSet, false);
         if (!is_array($aSet) || empty($aSet)) {
             continue;
         }
         $aMenus = array();
         $this->oDb->getMenus(array('type' => 'by_set_name', 'value' => $sId), $aMenus, false);
         if (is_array($aMenus) && count($aMenus) > 0) {
             $this->_echoResultJson(array('msg' => _t('_adm_nav_err_sets_delete_used')));
             exit;
         }
         if ((int) $this->_delete($sId) <= 0) {
             continue;
         }
         $aItems = array();
         $this->oDb->getItems(array('type' => 'by_set_name', 'value' => $aSet['name']), $aItems, false);
         if (is_array($aItems) && !empty($aItems)) {
             foreach ($aItems as $aItem) {
                 $oGridItems->deleteByItem($aItem);
             }
         }
         BxDolStudioLanguagesUtils::getInstance()->deleteLanguageString($aSet['title']);
         $aIdsAffected[] = $sId;
         $iAffected++;
     }
     $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_nav_err_sets_delete')));
 }
 public function performActionDelete()
 {
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aIdsAffected = array();
     foreach ($aIds as $iId) {
         $aMenu = array();
         $iMenu = $this->oDb->getMenus(array('type' => 'by_id', 'value' => (int) $iId), $aMenu);
         if ($iMenu != 1 || empty($aMenu)) {
             continue;
         }
         if ((int) $aMenu['deletable'] != 1) {
             continue;
         }
         if ((int) $this->_delete($iId) <= 0) {
             continue;
         }
         bx_import('BxDolStudioLanguagesUtils');
         BxDolStudioLanguagesUtils::getInstance()->deleteLanguageString($aMenu['title']);
         $aIdsAffected[] = $iId;
         $iAffected++;
     }
     $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_nav_err_menus_delete')));
 }
 public function performActionDelete()
 {
     $sAction = 'delete';
     $iAffected = 0;
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $this->_echoResultJson(array());
         exit;
     }
     $oLanguage = BxDolStudioLanguagesUtils::getInstance();
     $aList = array();
     $this->oDb->getLists(array('type' => 'by_key', 'value' => $this->sList), $aList, false);
     $aIdsAffected = array();
     foreach ($aIds as $iId) {
         $aValue = array();
         $this->oDb->getValues(array('type' => 'by_id', 'value' => (int) $iId), $aValue);
         if (!is_array($aValue) || empty($aValue)) {
             continue;
         }
         if ((int) $this->_delete($iId) <= 0) {
             continue;
         }
         $oLanguage->deleteLanguageString($aValue['lkey']);
         $oLanguage->deleteLanguageString($aValue['lkey2']);
         if ((int) $aList['use_for_sets'] != 1) {
             $bUseInSets = 1;
             $aValues = BxDolForm::getDataItems($this->sList);
             foreach ($aValues as $mixedValue => $sTitle) {
                 if (!$this->canUseForSet($mixedValue)) {
                     $bUseInSets = 0;
                     break;
                 }
             }
             if ($bUseInSets == 1) {
                 $this->oDb->updateList($aList['id'], array('use_for_sets' => $bUseInSets));
             }
         }
         $aIdsAffected[] = $iId;
         $iAffected++;
     }
     $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_form_err_pre_values_delete')));
 }
Example #23
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;
 }