public function generateSchemaStructure() { echo "Generating CRM_Core_I18n_SchemaStructure...\n"; $columns = array(); $indices = array(); $widgets = array(); foreach ($this->tables as $table) { if ($table['localizable']) { $columns[$table['name']] = array(); $widgets[$table['name']] = array(); } else { continue; } foreach ($table['fields'] as $field) { if ($field['localizable']) { $columns[$table['name']][$field['name']] = $field['sqlType']; $widgets[$table['name']][$field['name']] = $field['widget']; } } if (isset($table['index'])) { foreach ($table['index'] as $index) { if ($index['localizable']) { $indices[$table['name']][$index['name']] = $index; } } } } $template = new CRM_Core_CodeGen_Util_Template('php'); $template->assign('columns', $columns); $template->assign('indices', $indices); $template->assign('widgets', $widgets); $template->run('schema_structure.tpl', $this->config->phpCodePath . "/CRM/Core/I18n/SchemaStructure.php"); }
public function run() { echo "Generating civicrm-version file\n"; file_put_contents($this->config->tplCodePath . "/CRM/common/version.tpl", $this->config->db_version); $template = new CRM_Core_CodeGen_Util_Template('php'); $template->assign('db_version', $this->config->db_version); $template->assign('cms', ucwords($this->config->cms)); $template->run('civicrm_version.tpl', $this->config->phpCodePath . "civicrm-version.php"); }
/** * Generate the raw PHP code for the data file. * * @return string */ public function getRaw() { if (!$this->raw) { $template = new CRM_Core_CodeGen_Util_Template('php'); $template->assign('tables', $this->tables); $template->assign('genCodeChecksum', 'NEW'); $this->raw = $template->fetch('listAll.tpl'); } return $this->raw; }
public function generateLocaleDataSql() { $template = new CRM_Core_CodeGen_Util_Template('sql'); global $tsLocale; $oldTsLocale = $tsLocale; foreach ($this->locales as $locale) { echo "Generating data files for {$locale}\n"; $tsLocale = $locale; $template->assign('locale', $locale); $template->assign('db_version', $this->config->db_version); $sections = array('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}" : ''; // write the initialize base-data sql script $template->runConcat($sections, $this->config->sqlCodePath . "civicrm_data{$ext}.mysql"); // write the acl sql script $template->run('civicrm_acl.tpl', $this->config->sqlCodePath . "civicrm_acl{$ext}.mysql"); } $tsLocale = $oldTsLocale; }
public function setupCms() { if (!in_array($this->config->cms, array('backdrop', 'drupal', 'drupal8', 'joomla', 'wordpress'))) { echo "Config file for '{$this->config->cms}' not known."; exit; } elseif ($this->config->cms !== 'joomla') { $configTemplate = $this->findConfigTemplate($this->config->cms); if ($configTemplate) { echo "Generating civicrm.config.php\n"; copy($configTemplate, '../civicrm.config.php'); } else { throw new Exception("Failed to locate template for civicrm.config.php"); } } echo "Generating civicrm-version file\n"; $template = new CRM_Core_CodeGen_Util_Template('php'); $template->assign('db_version', $this->config->db_version); $template->assign('cms', ucwords($this->config->cms)); $template->run('civicrm_version.tpl', $this->config->phpCodePath . "civicrm-version.php"); }
public function generateDAOs() { foreach (array_keys($this->tables) as $name) { echo "Generating {$name} as " . $this->tables[$name]['fileName'] . "\n"; if (empty($this->tables[$name]['base'])) { echo "No base defined for {$name}, skipping output generation\n"; continue; } $template = new CRM_Core_CodeGen_Util_Template('php'); $template->assign('table', $this->tables[$name]); $directory = $this->config->phpCodePath . $this->tables[$name]['base']; CRM_Core_CodeGen_Util_File::createDir($directory); $template->run('dao.tpl', $directory . $this->tables[$name]['fileName']); } }
function generateListAll() { $template = new CRM_Core_CodeGen_Util_Template('php'); $template->assign('tables', $this->tables); $template->run('listAll.tpl', $this->config->CoreDAOCodePath . "AllCoreTables.php"); }