public function generateSample() { $template = new CRM_Core_CodeGen_Util_Template('sql'); $sections = array('civicrm_sample.tpl', 'civicrm_acl.tpl'); $template->runConcat($sections, $this->config->sqlCodePath . 'civicrm_sample.mysql'); $template->run('case_sample.tpl', $this->config->sqlCodePath . 'case_sample.mysql'); }
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 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']); } }
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"); }
function __construct($CoreDAOCodePath, $sqlCodePath, $phpCodePath, $tplCodePath, $smartyPluginDirs, $argCms, $argVersion, $schemaPath, $digestPath) { $this->CoreDAOCodePath = $CoreDAOCodePath; $this->sqlCodePath = $sqlCodePath; $this->phpCodePath = $phpCodePath; $this->tplCodePath = $tplCodePath; $this->digestPath = $digestPath; $this->digest = NULL; // default cms is 'drupal', if not specified $this->cms = isset($argCms) ? strtolower($argCms) : 'drupal'; CRM_Core_CodeGen_Util_Template::$smartyPluginDirs = $smartyPluginDirs; $versionFile = "version.xml"; $versionXML = CRM_Core_CodeGen_Util_Xml::parse($versionFile); $this->db_version = $versionXML->version_no; $this->buildVersion = preg_replace('/^(\\d{1,2}\\.\\d{1,2})\\.(\\d{1,2}|\\w{4,7})$/i', '$1', $this->db_version); if (isset($argVersion)) { // change the version to that explicitly passed, if any $this->db_version = $argVersion; } $this->schemaPath = $schemaPath; }
function generateListAll() { $template = new CRM_Core_CodeGen_Util_Template('php'); $template->assign('tables', $this->tables); $template->run('listAll.tpl', $this->config->CoreDAOCodePath . "AllCoreTables.php"); }