示例#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 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");
 }
示例#4
0
 /**
  * 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;
 }
示例#5
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']);
     }
 }
示例#6
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");
 }
示例#7
0
 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");
 }