function omega_tools_subtheme_create in Omega Tools 7.3
@todo
2 calls to omega_tools_subtheme_create()
- drush_omega_tools_omega_subtheme in includes/
omega_tools.drush.inc - Implements of drush_hook_COMMAND().
- omega_tools_subtheme_add_submit in includes/
omega_tools.admin.inc - @todo
File
- ./
omega_tools.module, line 379
Code
function omega_tools_subtheme_create(&$subtheme) {
if (is_dir($subtheme->path)) {
file_unmanaged_delete_recursive($subtheme->path);
}
if (!file_prepare_directory($subtheme->path, FILE_CREATE_DIRECTORY)) {
drupal_set_message(t('Omega Tools could not create the directory %dir.', array(
'%dir' => $subtheme->path,
)), 'error');
watchdog('Omega Tools', t('Omega Tools could not create the directory %dir.', array(
'%dir' => $subtheme->path,
)), array(), WATCHDOG_ERROR);
return FALSE;
}
if ($subtheme->starterkit) {
if (!omega_tools_copy_recursive(drupal_get_path('theme', $subtheme->starterkit), $subtheme->path)) {
$themes = list_themes();
drupal_set_message(t('Omega Tools could not copy the starterkit %starterkit.', array(
'%starterkit' => $themes[$subtheme->starterkit]->info['name'],
)), 'error');
watchdog('Omega Tools', t('Omega Tools could not copy the starterkit %starterkit.', array(
'%starterkit' => $themes[$subtheme->starterkit]->info['name'],
)), array(), WATCHDOG_ERROR);
return FALSE;
}
$subtheme->info = drupal_parse_info_file($subtheme->path . '/' . $subtheme->starterkit . '.info');
file_unmanaged_delete($subtheme->path . '/' . $subtheme->starterkit . '.info');
}
else {
if (!omega_tools_copy_recursive(drupal_get_path('module', 'omega_tools') . '/default', $subtheme->path)) {
drupal_set_message(t('Omega Tools could not copy the default pattern.'), 'error');
watchdog('Omega Tools', t('Omega Tools could not copy the default pattern.'), array(), WATCHDOG_ERROR);
return FALSE;
}
$base = drupal_parse_info_file(drupal_get_path('theme', $subtheme->base) . '/' . $subtheme->base . '.info');
$subtheme->info = drupal_parse_info_file($subtheme->path . '/default.pattern');
$subtheme->info['regions'] = isset($base['regions']) ? $base['regions'] : array();
$subtheme->info['zones'] = isset($base['zones']) ? $base['zones'] : array();
$subtheme->info['settings'] = isset($base['settings']) ? $base['settings'] : array();
file_unmanaged_delete($subtheme->path . '/default.pattern');
}
unset($subtheme->info['starterkit'], $subtheme->info['hidden'], $subtheme->info['locked'], $subtheme->info['project'], $subtheme->info['datestamp']);
$subtheme->info['name'] = $subtheme->name;
$subtheme->info['description'] = '';
$subtheme->info['base theme'] = $subtheme->base;
$subtheme->info['engine'] = 'phptemplate';
$subtheme->info['core'] = DRUPAL_CORE_COMPATIBILITY;
$subtheme->info['version'] = '1.x';
$subtheme->info['screenshot'] = 'screenshot.png';
$subtheme->info['regions'] = array_merge(_omega_tools_core_regions(), $subtheme->info['regions']);
$subtheme->info['zones'] = array_merge(_omega_tools_default_zones(), $subtheme->info['zones']);
omega_tools_write_info_file($subtheme->machine_name, $subtheme->info, $subtheme->path);
omega_tools_rewrite_recursive($subtheme->path, 'YOURTHEME', $subtheme->machine_name, str_replace('_', '-', $subtheme->machine_name));
drupal_set_message(t('You have successfully created the theme %name.', array(
'%name' => $subtheme->name,
)));
return TRUE;
}