function zenophile_zenophile_alter in Zenophile 7
Same name and namespace in other branches
- 6.2 zenophile.module \zenophile_zenophile_alter()
Implements hook_zenophile_alter().
This is our own implementation of hook_zenophile_alter(). This one should fire first because we're setting the module's weight in the {system} table to -10 in hook_install(). Otherwise, this implementation would probably fire last due to the name of this module, which places it near the end of any alphabetical ordering.
File
- ./
zenophile.module, line 351 - Creates Zen subthemes quickly and easily.
Code
function zenophile_zenophile_alter(&$files, $info) {
$weight = 59990;
// Step 2: Rename the .info file, and replace instances of the parent name
// that of the child name. Also, add the name and description.
// Make an exception for STARTERKIT again… dammit.
$dotinfo = $info['t_name'] . '.info';
$files[$dotinfo] = $files[$info['parent'] . ($info['parent'] === 'STARTERKIT' ? '.info.txt' : '.info')];
$files[$dotinfo]['repl'] = array();
$files[$dotinfo]['repl']["/{$info['parent']}/"] = $info['t_name'];
$files[$dotinfo]['repl']['/^name\\s*=.*/m'] = 'name = ' . $info['form_values']['friendly'];
$files[$dotinfo]['repl']['/^description\\s*=.*/m'] = 'description = ' . $info['form_values']['description'];
// Remove packaging robot stuff
$files[$dotinfo]['repl']['/^; Information added by drupal\\.org packaging script on .+$/m'] = '';
$files[$dotinfo]['repl']['/^(version|core|project|datestamp) = ".+$/m'] = '';
if ($info['parent'] === 'STARTERKIT') {
unset($files['STARTERKIT.info.txt']);
}
else {
unset($files[$info['parent'] . '.info']);
}
// Do we also want to create the the fresh stylesheet?
if ($info['form_values']['fresh']) {
$files['css/fresh.css'] = array(
'from' => '',
'type' => 'file',
'repl' => array(),
'weight' => $weight += 10,
);
// Add it to the .info file
$files[$dotinfo]['repl']['/^; Add conditional stylesheets that are processed by IE\\./m'] = "; Add a blank stylesheet for easy customization.\n\nstylesheets[all][] = css/fresh.css\n\n; Add conditional stylesheets that are processed by IE.";
}
// Copy the liquid or fixed stylesheet, zen.css, print.css and
// html-elements.css from the actual Zen theme (not the parent theme). Steps 3
// through 6. Only do this if the parent is STARTERKIT - otherwise these
// should already be in the subtheme directory, and therefore already in the
// $files array.
if ($info['parent'] === 'STARTERKIT') {
if ($info['form_values']['layout'] === 'fixed') {
unset($files['css/layout-liquid.css']);
unset($files['css/layout-liquid-rtl.css']);
}
else {
unset($files['css/layout-fixed.css']);
unset($files['css/layout-fixed-rtl.css']);
$files[$dotinfo]['repl']['~css/layout-fixed~'] = 'css/layout-liquid';
}
}
// Copy template.php and theme-settings.php and replace the parent theme's
// name. Kind of Step 1 plus Step 7 mixed together. The files should already
// be there in $files, so we'll just tweak their repl arrays.
$files['template.php']['repl']["/{$info['parent']}/"] = $info['t_name'];
$files['theme-settings.php']['repl']["/{$info['parent']}/"] = $info['t_name'];
}