Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
demeritcowboy committed Nov 16, 2024
1 parent e679581 commit 36acdb9
Showing 1 changed file with 0 additions and 80 deletions.
80 changes: 0 additions & 80 deletions CRM/Core/CodeGen/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@
*/
class CRM_Core_CodeGen_Schema extends CRM_Core_CodeGen_BaseTask {

public $locales;

/**
* CRM_Core_CodeGen_Schema constructor.
*
* @param \CRM_Core_CodeGen_Main $config
*/
public function __construct($config) {
parent::__construct($config);
$this->locales = $this->findLocales();
}

public function run() {
CRM_Core_CodeGen_Util_File::createDir($this->config->sqlCodePath);

Expand All @@ -40,11 +28,6 @@ public function run() {
echo "Generating sql drop tables file\n";
$put($this->generateDropSql());

foreach ($this->locales as $locale) {
echo "Generating data files for $locale\n";
$put($this->generateLocaleDataSql($locale));
}

// also create the archive tables
// $this->generateCreateSql('civicrm_archive.mysql' );
// $this->generateDropSql('civicrm_archive_drop.mysql');
Expand Down Expand Up @@ -81,44 +64,6 @@ public function generateNavigation() {
return ['civicrm_navigation.mysql' => $template->fetch('civicrm_navigation.tpl')];
}

/**
* @param string $locale
* Ex: en_US, fr_FR
* @return array
*/
public function generateLocaleDataSql($locale) {
$template = new CRM_Core_CodeGen_Util_Template('sql');
CRM_Core_CodeGen_Util_MessageTemplates::assignSmartyVariables($template->getSmarty());
global $tsLocale;
$oldTsLocale = $tsLocale;

try {

$tsLocale = $locale;
$template->assign('locale', $locale);
$template->assign('db_version', $this->config->db_version);

$sections = [
'civicrm_country.tpl',
'civicrm_state_province.tpl',
'civicrm_currency.tpl',
'civicrm_data.tpl',
'civicrm_navigation.tpl',
'civicrm_version_sql.tpl',
];

$ext = ($locale !== 'en_US' ? ".$locale" : '');

return [
"civicrm_data$ext.mysql" => $template->fetchConcat($sections),
"civicrm_acl$ext.mysql" => $template->fetch('civicrm_acl.tpl'),
];
}
finally {
$tsLocale = $oldTsLocale;
}
}

/**
* @return array
* Array(string $fileName => string $fileContent).
Expand All @@ -136,29 +81,4 @@ public function generateSample() {
];
}

/**
* @return array
*/
public function findLocales() {
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton(FALSE);
$locales = [];
$localeDir = CRM_Core_I18n::getResourceDir();
if (file_exists($localeDir)) {
$locales = preg_grep('/^[a-z][a-z]_[A-Z][A-Z]$/', scandir($localeDir));
}

$localesMask = getenv('CIVICRM_LOCALES');
if (!empty($localesMask)) {
$mask = explode(',', $localesMask);
$locales = array_intersect($locales, $mask);
}

if (!in_array('en_US', $locales)) {
array_unshift($locales, 'en_US');
}

return $locales;
}

}

0 comments on commit 36acdb9

Please sign in to comment.