Cheetah
installer.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbInstaller');
9 
11 {
12  protected $sFileName = 'lang-ru.php';
13  protected $sFilePath;
14 
16  {
17  parent::__construct($aConfig);
18  $this->sFilePath = CH_DIRECTORY_PATH_MODULES . $aConfig['home_dir'] . 'data/' . $this->sFileName;
19  }
20 
21  function install($aParams)
22  {
23  $bInclude = @include($this->sFilePath);
24  if (!$bInclude || empty($LANG) || empty($LANG_INFO) || !$this->_addLanguage($LANG, $LANG_INFO))
25  return array(
26  'operation_title' => _t('_adm_txt_modules_operation_install', $this->_aConfig['title']),
27  'message' => 'Language file parse error or such language already exists: ' . $this->sFileName,
28  'result' => false);
29 
30  $iLangId = getLangIdByName($LANG_INFO['Name']);
31  $this->_recompileLanguageForAllModules($iLangId);
32  compileLanguage($iLangId);
33 
34  return parent::install($aParams);
35  }
36 
37  function uninstall($aParams)
38  {
39  $aResult = parent::uninstall($aParams);
40 
41  if ($aResult['result']) {
42  $bInclude = @include($this->sFilePath);
43  if (!$bInclude || empty($LANG) || empty($LANG_INFO) || !$this->_removeLanguage($LANG, $LANG_INFO))
44  return array(
45  'operation_title' => _t('_adm_txt_modules_operation_install', $this->_aConfig['title']),
46  'message' => 'Language file parse error: ' . $this->sFileName,
47  'result' => false);
48 
49  // delete compiled lang file
50  @unlink(CH_DIRECTORY_PATH_ROOT . "langs/lang-{$LANG_INFO['Name']}.php");
51  $GLOBALS['MySQL']->cleanCache('checkLangExists_' . $LANG_INFO['Name']);
52  if (ch_lang_name() == $LANG_INFO['Name']) {
53  getCurrentLangName(true);
54  }
55  }
56 
57  return $aResult;
58  }
59 
60 }
ChRuInstaller\uninstall
uninstall($aParams)
Definition: installer.php:37
getCurrentLangName
if(!defined('CH_SKIP_INSTALL_CHECK')) getCurrentLangName($isSetCookie=true)
Definition: languages.inc.php:36
compileLanguage
compileLanguage($langID=0)
Definition: languages.inc.php:301
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$aResult
$aResult
Definition: index.php:19
php
ChWsbInstaller
Definition: ChWsbInstaller.php:38
ChRuInstaller
Definition: installer.php:11
ChRuInstaller\__construct
__construct($aConfig)
Definition: installer.php:15
ChWsbInstaller\_removeLanguage
_removeLanguage($aLanguage, $aLangInfo)
Definition: ChWsbInstaller.php:764
ChRuInstaller\$sFilePath
$sFilePath
Definition: installer.php:13
ChRuInstaller\$sFileName
$sFileName
Definition: installer.php:12
ChWsbInstaller\_recompileLanguageForAllModules
_recompileLanguageForAllModules($iLangId)
Definition: ChWsbInstaller.php:779
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChRuInstaller\install
install($aParams)
Definition: installer.php:21
$aConfig
$aConfig
Definition: config.php:8
ChWsbInstaller\_addLanguage
_addLanguage($aLanguage, $aLangInfo)
Definition: ChWsbInstaller.php:722
$LANG_INFO
$LANG_INFO
Definition: lang-en.php:8
ch_lang_name
ch_lang_name()
Definition: languages.inc.php:557
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
$LANG
$LANG
Definition: lang-en.php:12
getLangIdByName
getLangIdByName($sLangName)
Definition: languages.inc.php:136