function zenophile_sidebars_zenophile_alter in Zenophile 6.2
Same name and namespace in other branches
- 7 zenophile_sidebars/zenophile_sidebars.module \zenophile_sidebars_zenophile_alter()
Implementation of hook_zenophile_alter() (a Zenophile hook).
File
- zenophile_sidebars/
zenophile_sidebars.module, line 70 - Adds controls to adjust the width and placement of the sidebars and page in themes created with Zenophile.
Code
function zenophile_sidebars_zenophile_alter(&$files, $info) {
if ($info['form_values']['sidebars_on']) {
$z2 = $info['form_values']['zen_info']['vers_float'] >= 2;
$sb_fname = $z2 ? 'css/sidebars.css' : 'sidebars.css';
// Which sidebars.css template are we going to copy?
$files[$sb_fname] = array(
// Dictating a file name like this would normally be hella insecure, but
// FAPI will limit the available choices to those that were in the form we
// created.
'from' => drupal_get_path('module', 'zenophile_sidebars') . ($z2 ? '/css_z2' : '/css_z1') . "/sidebars-{$info['form_values']['sidebar-pos']}-{$info['form_values']['layout']}.css",
'type' => 'file',
'weight' => 61000,
);
$page = intval($info['form_values']['page']);
$ls = intval($info['form_values']['sidebar-left']);
$rs = intval($info['form_values']['sidebar-right']);
$ls_content_width = $page - $ls;
$rs_content_width = $page - $rs;
$both_sidebars_width = $ls + $rs;
$both_content_width = $page - $both_sidebars_width;
$files[$sb_fname]['repl'] = array(
'/PAGE/' => $page,
'/LSB-SB/' => $ls,
'/RSB-SB/' => $rs,
'/BOTHSB-SB/' => $both_sidebars_width,
'/LSB-CONTENT/' => $ls_content_width,
'/RSB-CONTENT/' => $rs_content_width,
'/BOTHSB-CONTENT/' => $both_content_width,
);
// Add sidebars.css to the .info file's list
// Note we're using tildes in the regex in the key because a key using
// slashes may have been set in zenophile.module when the option to add a
// fresh stylesheet is chosen, and we don't want to clobber that.
$files[$info['t_name'] . '.info']['repl']['~^ ; Set the conditional stylesheets that are processed by IE\\.$~m'] = "\n ; Customized sidebar/content widths and positions\nstylesheets[all][] = {$sb_fname}\n\n ; Set the conditional stylesheets that are processed by IE.\n";
}
}