示例#1
0
 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');
 }
示例#2
0
 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");
 }
示例#3
0
 public function run()
 {
     echo "Generating table list\n";
     $template = new CRM_Core_CodeGen_Util_Template('php');
     $template->assign('tables', $this->tables);
     $template->assign('genCodeChecksum', $this->getSchemaChecksum());
     $template->run('listAll.tpl', $this->getAbsFileName());
 }
示例#4
0
 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");
 }
示例#5
0
 public function run()
 {
     echo "Generating {$this->name} as " . $this->getRelFileName() . "\n";
     if (empty($this->tables[$this->name]['base'])) {
         echo "No base defined for {$this->name}, skipping output generation\n";
         return;
     }
     $template = new CRM_Core_CodeGen_Util_Template('php');
     $template->assign('table', $this->tables[$this->name]);
     $template->assign('genCodeChecksum', $this->getTableChecksum());
     $template->run('dao.tpl', $this->getAbsFileName());
 }
示例#6
0
 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']);
     }
 }
示例#7
0
 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;
 }
示例#8
0
 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 generateListAll()
 {
     $template = new CRM_Core_CodeGen_Util_Template('php');
     $template->assign('tables', $this->tables);
     $template->run('listAll.tpl', $this->config->CoreDAOCodePath . "AllCoreTables.php");
 }