Ejemplo n.º 1
0
 public function run()
 {
     require_once TL_ROOT . '/system/config/langconfig.php';
     if ($this->Database->tableExists('tl_metafields')) {
         return false;
     }
     if (!is_array($GLOBALS['TL_LANG']['additional_metafields'])) {
         return false;
     }
     if (!array_key_exists('additional_metafields_exts', $GLOBALS['TL_CONFIG'])) {
         return false;
     }
     if (strlen($GLOBALS['TL_CONFIG']['additional_metafields_exts']) === 0) {
         return false;
     }
     $exts = $GLOBALS['TL_CONFIG']['additional_metafields_exts'];
     $dcaExt = new DcaExtractor('tl_metafields');
     $arrSql = $dcaExt->getDbInstallerArray();
     $strSql = "CREATE TABLE `tl_metafields` (" . implode(',', $arrSql["TABLE_FIELDS"]) . ',' . implode(',', $arrSql["TABLE_CREATE_DEFINITIONS"]) . ')' . $arrSql["TABLE_OPTIONS"] . ';';
     $this->Database->execute($strSql);
     foreach ($GLOBALS['TL_LANG']['additional_metafields'] as $alias => $label) {
         $objModel = new MetafieldsModel();
         $objModel->tstamp = time();
         $objModel->alias = $alias;
         $objModel->label = $label;
         $objModel->extensions = $exts;
         $objModel->save();
     }
 }
Ejemplo n.º 2
0
 /**
  * Get the DCA table settings from the DCA cache
  * 
  * @return array An array of DCA table settings
  */
 protected function getFromDca()
 {
     $arrTables = array();
     // Scan the modules
     foreach (scan(TL_ROOT . '/system/modules') as $strModule) {
         $dir = TL_ROOT . '/system/modules/' . $strModule . '/dca';
         if (!is_dir($dir)) {
             continue;
         }
         foreach (scan($dir) as $strTable) {
             if (strncmp($strTable, '.', 1) === 0 || strrchr($strTable, '.') != '.php') {
                 continue;
             }
             if ($strTable == 'tl_settings.php' || $strTable == 'tl_templates.php') {
                 continue;
             }
             $arrTables[] = str_replace('.php', '', $strTable);
         }
     }
     $return = array();
     $arrTables = array_values(array_unique($arrTables));
     foreach ($arrTables as $strTable) {
         $objTable = new \DcaExtractor($strTable);
         $return[$strTable] = $objTable->getDbInstallerArray();
     }
     return $return;
 }
Ejemplo n.º 3
0
 /**
  * Get the DCA table settings from the DCA cache
  *
  * @return array An array of DCA table settings
  */
 public function getFromDca()
 {
     $return = array();
     $included = array();
     // Ignore the internal cache
     $blnBypassCache = \Config::get('bypassCache');
     \Config::set('bypassCache', true);
     // Only check the active modules (see #4541)
     foreach (\ModuleLoader::getActive() as $strModule) {
         $strDir = 'system/modules/' . $strModule . '/dca';
         if (!is_dir(TL_ROOT . '/' . $strDir)) {
             continue;
         }
         foreach (scan(TL_ROOT . '/' . $strDir) as $strFile) {
             // Ignore non PHP files and files which have been included before
             if (substr($strFile, -4) != '.php' || in_array($strFile, $included)) {
                 continue;
             }
             $strTable = substr($strFile, 0, -4);
             $objExtract = new \DcaExtractor($strTable);
             if ($objExtract->isDbTable()) {
                 $return[$strTable] = $objExtract->getDbInstallerArray();
             }
             $included[] = $strFile;
         }
     }
     // Restore the cache settings
     \Config::set('bypassCache', $blnBypassCache);
     // HOOK: allow third-party developers to modify the array (see #6425)
     if (isset($GLOBALS['TL_HOOKS']['sqlGetFromDca']) && is_array($GLOBALS['TL_HOOKS']['sqlGetFromDca'])) {
         foreach ($GLOBALS['TL_HOOKS']['sqlGetFromDca'] as $callback) {
             $this->import($callback[0]);
             $return = $this->{$callback}[0]->{$callback}[1]($return);
         }
     }
     return $return;
 }