summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfubhy2011-07-24 22:38:42 (GMT)
committer fubhy2011-07-24 22:38:42 (GMT)
commit3ddfc374d33024a0ef8569b2506d23dca4de6b71 (patch)
tree25ff38d32ea789049360966c6e7946216b2fd83d
parentbb612638110a185038c19d4bd41dfc48cd2bd05c (diff)
We are now aggregating all grid information in the new theme container aswell for even better caching.
-rw-r--r--alpha/includes/alpha.inc223
-rw-r--r--alpha/includes/base.inc158
-rw-r--r--alpha/includes/theme-settings-general.inc24
-rw-r--r--alpha/includes/theme-settings-structure.inc2
-rw-r--r--alpha/theme-settings.php33
-rw-r--r--omega/template.php24
6 files changed, 250 insertions, 214 deletions
diff --git a/alpha/includes/alpha.inc b/alpha/includes/alpha.inc
index b9c93c1..bb33cb4 100644
--- a/alpha/includes/alpha.inc
+++ b/alpha/includes/alpha.inc
@@ -230,11 +230,7 @@ function alpha_get_theme() {
$delta = isset($GLOBALS['delta']) ? $GLOBALS['delta']->machine_name : NULL;
$key = $theme . (isset($delta) ? ':' . $delta : '');
- if (!isset($container[$key])) {
- $theme = $GLOBALS['theme_key'];
- $delta = isset($GLOBALS['delta']) ? $GLOBALS['delta']->machine_name : NULL;
- $key = $theme . (isset($delta) ? ':' . $delta : '');
-
+ if (!isset($container[$key])) {
foreach (array_keys(alpha_theme_trail($theme)) as $item) {
if (class_exists($item . '_theme_container')) {
$class = $item . '_theme_container';
@@ -259,8 +255,8 @@ function alpha_grid_include($columns) {
$processed[$columns] = TRUE;
$theme = alpha_get_theme();
- if (!empty($theme->grid['css'])) {
- foreach ($theme->grid['css'] as &$item) {
+ if (!empty($theme->grid)) {
+ foreach ($theme->grid as &$item) {
if (empty($item['processed']) && (empty($item['columns']) || $item['columns'] == $columns)) {
$item['processed'] = TRUE;
@@ -269,33 +265,49 @@ function alpha_grid_include($columns) {
}
}
- if ($theme->settings['debug']['access'] && $theme->settings['debug']['grid'] && isset($theme->grid['layouts'][$theme->grid['primary']])) {
- $layouts = $theme->settings['responsive'] ? $theme->grid['layouts'] : array($theme->grid['primary'] => $theme->grid['layouts'][$theme->grid['primary']]);
- $nonie = $theme->settings['responsive'] ? array('IE' => 'gte IE 9', '!IE' => TRUE) : array('IE' => TRUE, '!IE' => TRUE);
- $ie = array('IE' => '(lt IE 9)&(!IEMobile)', '!IE' => FALSE);
-
- foreach ($layouts as $layout => $info) {
- $file = $theme->grid['path'] . '/' . $info['sanitized'] . '/' . $theme->grid['sanitized'] . '-' . $info['sanitized'] . '-' . $columns . '.png';
- $overlay = '.alpha-grid-debug .container-' . $columns . ' { background-image: ' . (is_file($file) ? 'url(' . file_create_url($file) . ')' : 'none') . '; }';
-
- if ($theme->settings['responsive'] && $layout == $theme->grid['primary']) {
- drupal_add_css($overlay, array(
- 'type' => 'inline',
- 'media' => 'all',
- 'browsers' => $ie,
- 'group' => -2000,
- 'weight' => $info['weight'],
- ));
- }
+ if ($theme->settings['debug']['access'] && $theme->settings['debug']['grid']) {
+ //alpha_grid_debug($theme->theme, $theme->settings['grid'], $theme->settings['responsive'], $columns);
+ }
+ }
+}
+/**
+ * @todo
+ */
+function alpha_grid_debug($theme, $grid, $responsive, $columns) {
+ $grids = alpha_retrieve_grids($theme);
+
+ if (isset($grids[$grid]) && isset($grids[$grid]['columns'][$columns])) {
+ $dashed = str_replace('_', '-', $grid);
+ $primary = alpha_theme_get_setting('alpha_primary_' . $grid, NULL, $theme);
+ $layouts = !$responsive ? (isset($grids[$grid]['layouts'][$primary]) ? array($primary) : array()) : array_keys($grids[$grid]['layouts']);
+ $nonie = $responsive ? array('IE' => 'gte IE 9', '!IE' => TRUE) : array('IE' => TRUE, '!IE' => TRUE);
+ $ie = array('IE' => '(lt IE 9)&(!IEMobile)', '!IE' => FALSE);
+
+ foreach ($layouts as $layout) {
+ $sanitized = str_replace('_', '-', $layout);
+ $media = $responsive ? alpha_theme_get_setting('alpha_layouts_' . $grid . '_' . $name . '_media', 'all', $theme) : 'all';
+ $weight = alpha_theme_get_setting('alpha_layouts_' . $grid . '_' . $layout . '_weight', 0, $theme);
+ $file = $grids[$grid]['path'] . '/' . $sanitized . '/' . $dashed . '-' . $sanitized . '-' . $columns . '.png';
+ $overlay = '.alpha-grid-debug .container-' . $columns . ' { background-image: ' . (is_file($file) ? 'url(' . file_create_url($file) . ')' : 'none') . '; }';
+
+ if ($responsive && $layout == $primary) {
drupal_add_css($overlay, array(
- 'type' => 'inline',
- 'browsers' => $nonie,
- 'group' => -1000,
- 'weight' => $info['weight'],
- 'media' => $info['media'],
+ 'type' => 'inline',
+ 'media' => 'all',
+ 'browsers' => $ie,
+ 'group' => -2000,
+ 'weight' => $weight,
));
}
+
+ drupal_add_css($overlay, array(
+ 'type' => 'inline',
+ 'browsers' => $nonie,
+ 'group' => -1000,
+ 'weight' => $weight,
+ 'media' => $media,
+ ));
}
}
}
@@ -576,7 +588,7 @@ function alpha_cache_clear($theme, $delta = NULL) {
function alpha_cache_set($theme) {
$cache = new stdClass();
- foreach ($theme->cacheable() as $item) {
+ foreach (array_keys($theme->cacheable()) as $item) {
if (isset($theme->$item)) {
$cache->$item = $theme->$item;
}
@@ -804,25 +816,38 @@ function alpha_retrieve_excludes($theme) {
* @todo
*/
function alpha_retrieve_grids($theme) {
- $cache = &drupal_static(__FUNCTION__);
$output = array();
-
- if (!isset($cache[$theme])) {
- foreach (alpha_info_trail('grids', $theme) as $key => $data) {
- foreach ($data as $grid => $info) {
- $cache[$theme][$grid] = array(
- 'theme' => $key,
- 'grid' => $grid,
- 'name' => $info['name'],
- 'layouts' => $info['layouts'],
- 'columns' => $info['columns'],
- 'path' => drupal_get_path('theme', $key) . '/css/grid/' . $grid,
+
+ foreach (alpha_info_trail('grids', $theme) as $key => $data) {
+ foreach ($data as $grid => $info) {
+ $output[$grid] = array(
+ 'theme' => $key,
+ 'grid' => $grid,
+ 'name' => $info['name'],
+ 'layouts' => $info['layouts'],
+ 'columns' => $info['columns'],
+ 'path' => drupal_get_path('theme', $key) . '/css/grid/' . $grid,
+ );
+
+ $output[$grid]['primary'] = alpha_theme_get_setting('alpha_primary_' . $grid, key($info['layouts']), $theme);
+
+ foreach ($output[$grid]['layouts'] as $layout => $title) {
+ $output[$grid]['layouts'][$layout] = array(
+ 'layout' => $layout,
+ 'name' => $title,
+ 'enabled' => alpha_theme_get_setting('alpha_layouts_' . $grid . '_' . $layout . '_responsive', FALSE, $theme),
+ 'media' => alpha_theme_get_setting('alpha_layouts_' . $grid . '_' . $layout . '_media', 'all', $theme),
+ 'weight' => alpha_theme_get_setting('alpha_layouts_' . $grid . '_' . $layout . '_weight', 0, $theme),
);
}
+
+ uasort($output[$grid]['layouts'], 'alpha_sort_layouts');
}
}
+
+ alpha_alter('alpha_grids', $output, $theme);
- return $cache[$theme];
+ return $output;
}
/**
@@ -843,6 +868,8 @@ function alpha_retrieve_css($theme) {
);
}
}
+
+ alpha_alter('alpha_css', $output, $theme);
return $output;
}
@@ -852,7 +879,7 @@ function alpha_retrieve_css($theme) {
*/
function alpha_retrieve_libraries($theme) {
$output = array();
-
+
foreach (alpha_info_trail('libraries', $theme) as $key => $data) {
foreach ($data as $name => $info) {
$output[$name] = array(
@@ -873,6 +900,112 @@ function alpha_retrieve_libraries($theme) {
}
}
}
+
+ alpha_alter('alpha_libraries', $output, $theme);
+
+ return $output;
+}
+
+/**
+ * @todo
+ */
+function alpha_grid_css($theme, $grid, $responsive) {
+ $dashed = str_replace('_', '-', $grid['grid']);
+ $layouts = !$responsive ? (isset($grid['layouts'][$primary]) ? array($grid['primary']) : array()) : array_keys($grid['layouts']);
+ $columns = array_keys($grid['columns']);
+ $output = array();
+
+ if (!empty($layouts)) {
+ $trail = array_keys(alpha_theme_trail($theme));
+ $nonie = $responsive ? array('IE' => 'gte IE 9', '!IE' => TRUE) : array('IE' => TRUE, '!IE' => TRUE);
+ $ie = array('IE' => '(lt IE 9)&(!IEMobile)', '!IE' => FALSE);
+
+ foreach ($layouts as $layout) {
+ $enabled = $grid['layouts'][$layout]['enabled'];
+
+ if (!$responsive || $enabled) {
+ $media = $responsive ? $grid['layouts'][$layout]['media'] : 'all';
+ $weight = $grid['layouts'][$layout]['weight'];
+ $sanitized = str_replace('_', '-', $layout);
+ $attached = array();
+
+ foreach ($trail as $item) {
+ $path = drupal_get_path('theme', $item) . '/css';
+ $file = str_replace('_', '-', $item) . '-' . $dashed;
+
+ if ($item = alpha_find_stylesheet($path, $file)) {
+ $attached[] = $item;
+ }
+
+ if ($item = alpha_find_stylesheet($path, $file . '-' . $sanitized)) {
+ $attached[] = $item;
+ }
+ }
+
+ foreach ($attached as $item) {
+ $basename = $layout . '::' . $item;
+
+ $output[$basename]['processed'] = FALSE;
+ $output[$basename]['item'] = $basename;
+ $output[$basename]['options'] = array(
+ 'group' => 2000,
+ 'weight' => $weight,
+ 'data' => $item,
+ 'basename' => $basename,
+ 'media' => $media,
+ 'browsers' => $nonie,
+ 'aggregate' => TRUE,
+ );
+
+ if ($responsive && $grid['primary'] == $layout) {
+ $basename = 'ie::' . $basename;
+
+ $output[$basename]['processed'] = FALSE;
+ $output[$basename]['item'] = $basename;
+ $output[$basename]['options'] = array(
+ 'group' => 1000,
+ 'weight' => $weight,
+ 'data' => $item,
+ 'basename' => $basename,
+ 'browsers' => $ie,
+ );
+ }
+ }
+
+ $path = $grid['path'] . '/' . $layout . '/' . $dashed . '-' . $sanitized;
+
+ foreach ($columns as $count) {
+ $file = $path . '-' . $count . '.css';
+
+ $output[$file]['processed'] = FALSE;
+ $output[$file]['columns'] = $count;
+ $output[$file]['item'] = $file;
+ $output[$file]['options'] = array(
+ 'group' => 2000,
+ 'weight' => $weight,
+ 'media' => $media,
+ 'browsers' => $nonie,
+ 'aggregate' => TRUE,
+ );
+
+ if ($responsive && $grid['primary'] == $layout) {
+ $basename = 'ie::' . $layout . '::' . $path . '-' . $count . '.css';
+
+ $output[$basename]['processed'] = FALSE;
+ $output[$basename]['columns'] = $count;
+ $output[$basename]['item'] = $basename;
+ $output[$basename]['options'] = array(
+ 'group' => 1000,
+ 'weight' => $weight,
+ 'data' => $file,
+ 'basename' => $basename,
+ 'browsers' => $ie,
+ );
+ }
+ }
+ }
+ }
+ }
return $output;
}
diff --git a/alpha/includes/base.inc b/alpha/includes/base.inc
index 69595ba..e14fd61 100644
--- a/alpha/includes/base.inc
+++ b/alpha/includes/base.inc
@@ -10,6 +10,7 @@ class alpha_theme_container {
var $settings;
var $css;
var $grid;
+ var $grids;
var $libraries;
var $sections;
var $zones;
@@ -27,11 +28,16 @@ class alpha_theme_container {
$this->$key = $item;
}
}
- else {
- $this->init();
-
- alpha_alter('alpha', $this, $theme, $delta);
- alpha_cache_set($this);
+
+ foreach ($this->cacheable() as $item => $required) {
+ if ($required && !isset($this->$item)) {
+ $this->init();
+
+ alpha_alter('alpha', $this, $theme, $delta);
+ alpha_cache_set($this);
+
+ return;
+ }
}
}
@@ -43,6 +49,7 @@ class alpha_theme_container {
$this->sections();
$this->zones();
$this->regions();
+ $this->grids();
$this->grid();
$this->css();
$this->libraries();
@@ -57,7 +64,6 @@ class alpha_theme_container {
$this->settings = array(
'grid' => alpha_theme_get_setting('alpha_grid', 'default', $this->theme),
- 'primary' => alpha_theme_get_setting('alpha_primary', NULL, $this->theme),
'css' => alpha_theme_get_setting('alpha_css', array(), $this->theme),
'libraries' => alpha_theme_get_setting('alpha_libraries', array(), $this->theme),
'exclude' => alpha_theme_get_setting('alpha_exclude', array(), $this->theme),
@@ -98,124 +104,28 @@ class alpha_theme_container {
/**
* @todo
*/
+ function grids() {
+ if (!isset($this->grids)) {
+ $this->settings();
+ $this->grids = alpha_retrieve_grids($this->theme);
+ }
+
+ return $this->grids;
+ }
+
+ /**
+ * @todo
+ */
function grid() {
if (!isset($this->grid)) {
- $this->settings();
- $this->grid = array();
- $grids = alpha_retrieve_grids($this->theme);
+ $this->grids();
- if (isset($grids[$this->settings['grid']])) {
- $grid = $grids[$this->settings['grid']];
- $trail = array_keys(alpha_theme_trail($this->theme));
- $nonie = $this->settings['responsive'] ? array('IE' => 'gte IE 9', '!IE' => TRUE) : array('IE' => TRUE, '!IE' => TRUE);
- $ie = array('IE' => '(lt IE 9)&(!IEMobile)', '!IE' => FALSE);
-
- $this->grid = array(
- 'grid' => $this->settings['grid'],
- 'sanitized' => str_replace('_', '-', $this->settings['grid']),
- 'path' => $grid['path'],
- 'primary' => alpha_theme_get_setting('alpha_primary_' . $this->settings['grid'], NULL, $this->theme),
- 'layouts' => array(),
- 'columns' => $grid['columns'],
- 'css' => array(),
- );
-
- if (!$this->settings['responsive']) {
- $grid['layouts'] = isset($grid['layouts'][$this->grid['primary']]) ? array($this->grid['primary'] => $grid['layouts'][$this->grid['primary']]) : array();
- }
-
- foreach ($grid['layouts'] as $layout => $title) {
- $responsive = alpha_theme_get_setting('alpha_layouts_' . $this->grid['grid'] . '_' . $layout . '_responsive', FALSE, $this->theme);
-
- if (!$this->settings['responsive'] || $responsive) {
- $this->grid['layouts'][$layout] = array(
- 'layout' => $layout,
- 'sanitized' => str_replace('_', '-', $layout),
- 'attached' => array(),
- 'responsive' => $responsive,
- 'media' => $this->settings['responsive'] ? alpha_theme_get_setting('alpha_layouts_' . $this->grid['grid'] . '_' . $layout . '_media', 'all', $this->theme) : 'all',
- 'weight' => alpha_theme_get_setting('alpha_layouts_' . $this->grid['grid'] . '_' . $layout . '_weight', 0, $this->theme),
- );
-
- foreach ($trail as $item) {
- $path = drupal_get_path('theme', $item) . '/css';
- $file = str_replace('_', '-', $item) . '-' . $this->grid['sanitized'];
-
- if ($attached = alpha_find_stylesheet($path, $file)) {
- $this->grid['layouts'][$layout]['attached'][] = $attached;
- }
-
- if ($attached = alpha_find_stylesheet($path, $file . '-' . $this->grid['layouts'][$layout]['sanitized'])) {
- $this->grid['layouts'][$layout]['attached'][] = $attached;
- }
- }
-
- foreach ($this->grid['layouts'][$layout]['attached'] as $attached) {
- $basename = $layout . '::' . $attached;
-
- $this->grid['css'][$basename]['processed'] = FALSE;
- $this->grid['css'][$basename]['item'] = $basename;
- $this->grid['css'][$basename]['options'] = array(
- 'group' => 2000,
- 'weight' => $this->grid['layouts'][$layout]['weight'],
- 'data' => $attached,
- 'basename' => $basename,
- 'media' => $this->grid['layouts'][$layout]['media'],
- 'browsers' => $nonie,
- 'aggregate' => TRUE,
- );
-
- if ($this->settings['responsive'] && $this->grid['primary'] == $layout) {
- $basename = 'ie::' . $basename;
-
- $this->grid['css'][$basename]['processed'] = FALSE;
- $this->grid['css'][$basename]['item'] = $basename;
- $this->grid['css'][$basename]['options'] = array(
- 'group' => 1000,
- 'weight' => $this->grid['layouts'][$layout]['weight'],
- 'data' => $attached,
- 'basename' => $basename,
- 'browsers' => $ie,
- );
- }
- }
-
- $path = $this->grid['path'] . '/' . $layout . '/' . $this->grid['sanitized'] . '-' . $this->grid['layouts'][$layout]['sanitized'];
-
- foreach ($this->grid['columns'] as $columns => $title) {
- $file = $path . '-' . $columns . '.css';
-
- $this->grid['css'][$file]['processed'] = FALSE;
- $this->grid['css'][$file]['columns'] = $columns;
- $this->grid['css'][$file]['item'] = $file;
- $this->grid['css'][$file]['options'] = array(
- 'group' => 2000,
- 'weight' => $this->grid['layouts'][$layout]['weight'],
- 'media' => $this->grid['layouts'][$layout]['media'],
- 'browsers' => $nonie,
- 'aggregate' => TRUE,
- );
-
- if ($this->settings['responsive'] && $this->grid['primary'] == $layout) {
- $basename = 'ie::' . $layout . '::' . $path . '-' . $columns . '.css';
-
- $this->grid['css'][$basename]['processed'] = FALSE;
- $this->grid['css'][$basename]['columns'] = $columns;
- $this->grid['css'][$basename]['item'] = $basename;
- $this->grid['css'][$basename]['options'] = array(
- 'group' => 1000,
- 'weight' => $this->grid['layouts'][$layout]['weight'],
- 'data' => $file,
- 'basename' => $basename,
- 'browsers' => $ie,
- );
- }
- }
- }
- }
- }
-
- alpha_alter('alpha_grid', $this->grid, $this->theme);
+ if (isset($this->grids[$this->settings['grid']])) {
+ $this->grid = alpha_grid_css($this->theme, $this->grids[$this->settings['grid']], $this->settings['responsive']);
+ }
+ else {
+ $this->grid = array();
+ }
}
return $this->grid;
@@ -227,8 +137,6 @@ class alpha_theme_container {
function css() {
if (!isset($this->css)) {
$this->css = alpha_retrieve_css($this->theme);
-
- alpha_alter('alpha_css', $this->css, $this->theme);
}
return $this->css;
@@ -240,8 +148,6 @@ class alpha_theme_container {
function libraries() {
if (!isset($this->libraries)) {
$this->libraries = alpha_retrieve_libraries($this->theme);
-
- alpha_alter('alpha_libraries', $this->libraries, $this->theme);
}
return $this->libraries;
@@ -346,7 +252,7 @@ class alpha_theme_container {
* @todo
*/
function cacheable() {
- $cacheable = array('settings', 'libraries', 'css', 'grid', 'regions', 'zones', 'sections');
+ $cacheable = array_fill_keys(array('settings', 'libraries', 'css', 'grids', 'grid', 'regions', 'zones', 'sections'), TRUE);
alpha_alter('alpha_cacheable', $cacheable, $this->theme);
diff --git a/alpha/includes/theme-settings-general.inc b/alpha/includes/theme-settings-general.inc
index af80533..7fd35bf 100644
--- a/alpha/includes/theme-settings-general.inc
+++ b/alpha/includes/theme-settings-general.inc
@@ -11,8 +11,8 @@
function alpha_theme_settings_general(&$form, &$form_state) {
$theme = alpha_get_theme();
$scales = alpha_scale_options(1, 10, 0.5);
- $optional = alpha_css_options($theme->theme);
- $libraries = alpha_library_options($theme->theme);
+ $optional = alpha_css_options($theme->css);
+ $libraries = alpha_library_options($theme->libraries);
$exclude = alpha_exclude_options($theme->theme);
$toggle = alpha_toggle();
@@ -27,7 +27,7 @@ function alpha_theme_settings_general(&$form, &$form_state) {
'#description' => t('Select the grid system that you want to use for this layout.'),
'#title' => t('Grid system'),
'#default_value' => $theme->settings['grid'],
- '#options' => alpha_grid_options($theme->theme),
+ '#options' => alpha_grid_options($theme->grids),
);
$form['alpha_settings']['layout']['responsive_settings'] = array(
@@ -96,7 +96,7 @@ function alpha_theme_settings_general(&$form, &$form_state) {
'#default_value' => $theme->settings['viewport']['user'],
);
- foreach (alpha_retrieve_grids($theme->theme) as $grid => $info) {
+ foreach ($theme->grids as $grid => $info) {
$form['alpha_settings']['layout']['grid_layouts'][$grid] = array(
'#type' => 'fieldset',
'#title' => t('@grid layout settings', array('@grid' => $info['name'])),
@@ -110,15 +110,15 @@ function alpha_theme_settings_general(&$form, &$form_state) {
$form['alpha_settings']['layout']['grid_layouts'][$grid]['alpha_primary_' . $grid] = array(
'#type' => 'select',
'#title' => t('Primary layout'),
- '#default_value' => alpha_theme_get_setting('alpha_primary_' . $grid, NULL, $theme->theme),
- '#options' => alpha_grid_layouts_options($theme->theme, $grid),
+ '#default_value' => $info['primary'],
+ '#options' => alpha_grid_layouts_options($theme->grids[$grid]),
'#description' => t('The primary layout will be used in case you disable the "responsive grid" option aswell as for older versions of Internet Explorer.'),
);
- foreach ($info['layouts'] as $layout => $title) {
+ foreach ($info['layouts'] as $layout => $data) {
$form['alpha_settings']['layout']['grid_layouts'][$grid][$layout] = array(
'#type' => 'fieldset',
- '#title' => t('@layout layout', array('@layout' => $title)),
+ '#title' => t('@layout layout', array('@layout' => $data['name'])),
'#states' => array(
'visible' => array(
':input[name="alpha_responsive"]' => array('checked' => TRUE),
@@ -129,14 +129,14 @@ function alpha_theme_settings_general(&$form, &$form_state) {
$form['alpha_settings']['layout']['grid_layouts'][$grid][$layout]['alpha_layouts_' . $grid . '_' . $layout . '_responsive'] = array(
'#type' => 'checkbox',
'#title' => t('Use this layout with the responsive grid'),
- '#default_value' => alpha_theme_get_setting('alpha_layouts_' . $grid . '_' . $layout . '_responsive', FALSE, $theme->theme),
+ '#default_value' => $data['enabled'],
);
$form['alpha_settings']['layout']['grid_layouts'][$grid][$layout]['alpha_layouts_' . $grid . '_' . $layout . '_weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#description' => t('The weight of this layout.'),
- '#default_value' => alpha_theme_get_setting('alpha_layouts_' . $grid . '_' . $layout . '_weight', FALSE, $theme->theme),
+ '#default_value' => $data['weight'],
'#states' => array(
'visible' => array(
':input[name="alpha_layouts_' . $grid . '_' . $layout . '_responsive"]' => array('checked' => TRUE),
@@ -147,8 +147,8 @@ function alpha_theme_settings_general(&$form, &$form_state) {
$form['alpha_settings']['layout']['grid_layouts'][$grid][$layout]['alpha_layouts_' . $grid . '_' . $layout . '_media'] = array(
'#type' => 'textfield',
'#title' => t('Media query'),
- '#description' => t('The @media query that the @layout layout should respond to.', array('@layout' => $title)),
- '#default_value' => alpha_theme_get_setting('alpha_layouts_' . $grid . '_' . $layout . '_media', FALSE, $theme->theme),
+ '#description' => t('The @media query that the @layout layout should respond to.', array('@layout' => $data['name'])),
+ '#default_value' => $data['media'],
'#maxlength' => 255,
'#size' => 140,
'#states' => array(
diff --git a/alpha/includes/theme-settings-structure.inc b/alpha/includes/theme-settings-structure.inc
index c7179a5..cae3c3f 100644
--- a/alpha/includes/theme-settings-structure.inc
+++ b/alpha/includes/theme-settings-structure.inc
@@ -10,7 +10,7 @@
*/
function alpha_theme_settings_structure(&$form, &$form_state) {
$theme = alpha_get_theme();
- $containers = alpha_container_options($theme->settings['grid'], $theme->theme);
+ $containers = isset($theme->grids[$theme->settings['grid']]) ? alpha_container_options($theme->grids[$theme->settings['grid']]) : array();
$options = alpha_zone_options($theme->zones);
$columns = $spacing = !empty($containers) ? alpha_column_options(max(array_keys($containers))) : array();
diff --git a/alpha/theme-settings.php b/alpha/theme-settings.php
index 06b95bd..27efa37 100644
--- a/alpha/theme-settings.php
+++ b/alpha/theme-settings.php
@@ -138,9 +138,9 @@ function alpha_scale_options($start, $end, $step) {
* @return
* An array of optional or responsive stylesheet options.
*/
-function alpha_css_options($theme) {
+function alpha_css_options($css) {
$output = array();
- foreach (alpha_retrieve_css($theme) as $key => $info) {
+ foreach ($css as $key => $info) {
$output[$key] = '<strong>' . check_plain($info['name']) . '</strong> (' . (isset($info['options']['media']) ? $info['options']['media'] : 'all') . ') - ' . $info['file'] . '<div class="description">' . $info['description'] . '</div>';
}
@@ -183,9 +183,9 @@ function alpha_exclude_options($theme) {
* @return
* An array of available grids.
*/
-function alpha_grid_options($theme) {
+function alpha_grid_options($grids) {
$output = array();
- foreach (alpha_retrieve_grids($theme) as $key => $info) {
+ foreach ($grids as $key => $info) {
$output[$key] = check_plain($info['name']);
}
@@ -204,13 +204,11 @@ function alpha_grid_options($theme) {
* @return
* An array of available layouts.
*/
-function alpha_grid_layouts_options($theme, $grid) {
- $grids = alpha_retrieve_grids($theme);
-
+function alpha_grid_layouts_options($grid) {
$output = array();
- if (isset($grids[$grid]) && !empty($grids[$grid]['layouts'])) {
- foreach ($grids[$grid]['layouts'] as $key => $title) {
- $output[$key] = check_plain($title);
+ if (!empty($grid['layouts'])) {
+ foreach ($grid['layouts'] as $key => $info) {
+ $output[$key] = check_plain($info['name']);
}
}
@@ -226,9 +224,9 @@ function alpha_grid_layouts_options($theme, $grid) {
* @return
* An array of available libraries.
*/
-function alpha_library_options($theme) {
+function alpha_library_options($libraries) {
$output = array();
- foreach (alpha_retrieve_libraries($theme) as $key => $info) {
+ foreach ($libraries as $key => $info) {
$output[$key] = check_plain($info['name']) . '<div class="description">' . $info['description'] . '</div>';
}
@@ -247,12 +245,10 @@ function alpha_library_options($theme) {
* @return
* An array of available containers.
*/
-function alpha_container_options($grid, $theme) {
- $grids = alpha_retrieve_grids($theme);
-
+function alpha_container_options($grid) {
$output = array();
- if (isset($grids[$grid]) && !empty($grids[$grid]['columns'])) {
- foreach ($grids[$grid]['columns'] as $count => $title) {
+ if (!empty($grid['columns'])) {
+ foreach ($grid['columns'] as $count => $title) {
$output[$count] = t('@count Columns', array('@count' => $count));
}
}
@@ -270,8 +266,7 @@ function alpha_container_options($grid, $theme) {
* An array of available columns counts.
*/
function alpha_column_options($max = NULL) {
- $output = array();
-
+ $output = array();
if (isset($max)) {
foreach (range(0, $max) as $width) {
$output[$width] = t('@width Columns', array('@width' => $width));
diff --git a/omega/template.php b/omega/template.php
index b6aac1f..675d97a 100644
--- a/omega/template.php
+++ b/omega/template.php
@@ -45,19 +45,21 @@ function omega_preprocess_html(&$vars) {
if ($theme->settings['responsive'] && alpha_library_active('omega_mediaqueries')) {
$layouts = array();
- foreach ($theme->grid['layouts'] as $layout) {
- if ($layout['responsive']) {
- $layouts[$layout['layout']] = $layout['media'];
+ if (isset($theme->grids[$theme->settings['grid']])) {
+ foreach ($theme->grids[$theme->settings['grid']]['layouts'] as $layout) {
+ if ($layout['enabled']) {
+ $layouts[$layout['layout']] = $layout['media'];
+ }
}
+
+ drupal_add_js(array('omega' => array(
+ 'layouts' => array(
+ 'primary' => $theme->grids[$theme->settings['grid']]['primary'],
+ 'order' => array_keys($layouts),
+ 'queries' => $layouts,
+ ),
+ )), 'setting');
}
-
- drupal_add_js(array('omega' => array(
- 'layouts' => array(
- 'primary' => $theme->grid['primary'],
- 'order' => array_keys($layouts),
- 'queries' => $layouts,
- ),
- )), 'setting');
}
}