| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup Developer Developer
- * @ingroup UnaModules
- *
- * @{
- */
- class BxDevPolyglotManage extends BxTemplStudioGrid
- {
- private $sAllUri = 'all';
- private $aActions = array(
- 'restore' => 'eraser',
- 'recompile' => 'sync'
- );
- protected $oModule;
- protected $aLanguage;
- function __construct($aOptions, $oTemplate = false)
- {
- parent::__construct($aOptions, $oTemplate);
- $this->oModule = BxDolModule::getInstance('bx_developer');
- $this->aLanguages = BxDolLanguages::getInstance()->getLanguages();
- $iWidth = floor(100 / (count($this->aLanguages) + 1));
- $this->_aOptions['fields']['title']['width'] = $iWidth;
- foreach($this->aLanguages as $sName => $sTitle)
- $this->_aOptions['fields'][$sName] = array(
- 'title' => $sTitle,
- 'width' => $iWidth,
- 'translatable' => '0',
- 'chars_limit' => '0'
- );
- }
- public function performActionRecompile()
- {
- $aResult = array('msg' => _t(BxDolStudioLanguagesUtils::getInstance()->compileLanguage() ? '_adm_pgt_scs_recompiled' : '_adm_pgt_err_cannot_recompile_lang'));
- echoJson($aResult);
- }
- public function performActionRestore()
- {
- $aResult = array('msg' => _t(BxDolStudioLanguagesUtils::getInstance()->restoreLanguage() ? '_adm_pgt_scs_restored' : '_adm_pgt_err_cannot_restore_lang'));
- echoJson($aResult);
- }
- protected function _getCellDefault($mixedValue, $sKey, $aField, $aRow)
- {
- $sJsObject = $this->oModule->_oConfig->getJsObject('polyglot');
- $aLangNames = array_keys($this->aLanguages);
- if(in_array($sKey, $aLangNames)) {
- $bAll = false;
- $aActions = array('restore');
- $sOnclickMask = "javascript:%s.%s('%s', '%s')";
- if($aRow['uri'] == $this->sAllUri) {
- $bAll = true;
- $aActions[] = 'recompile';
- $sOnclickMask = "javascript:%s.%s('%s')";
- }
- $mixedValue = '';
- foreach($aActions as $sAction) {
- $sIcon = $this->aActions[$sAction];
- $sTitle = _t('_bx_dev_pgt_txt_manage_' . $sAction . '_title' . ($bAll ? '_plur' : '_sing'));
- $mixedValue .= $this->_oTemplate->parseButton($this->_oTemplate->parseIcon($sIcon), array(
- 'class' => 'bx-btn bx-def-margin-sec-left-auto',
- 'title' => sprintf($sTitle, $aField['title'], $aRow['title']),
- 'onclick' => sprintf($sOnclickMask, $sJsObject, $sAction, $sKey, $aRow['uri'])
- ));
- }
- }
- return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
- }
- protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
- {
- $this->_aOptions['source'] .= " AND `name`<>'system'";
- $aData = array(
- array('id' => 0, 'title' => _t('_bx_dev_pgt_txt_manage_modules_all'), 'uri' => $this->sAllUri)
- );
- return array_merge($aData, parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage));
- }
- }
- /** @} */
|