summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.txt5
-rw-r--r--context_layouts/context_layouts.info10
-rw-r--r--context_layouts/context_layouts.module26
-rw-r--r--context_layouts/plugins/context_layouts_reaction_block.inc7
-rw-r--r--context_layouts/plugins/context_layouts_reaction_block.js7
5 files changed, 39 insertions, 16 deletions
diff --git a/README.txt b/README.txt
index 3db5616..c32ac9f 100644
--- a/README.txt
+++ b/README.txt
@@ -13,16 +13,13 @@ version. You will need the latest CTools (as of Sept. 16 2010) from here:
- all conditions except node taxonomy condition
- all reactions
- context UI
+- context layouts
- inline editor (with Admin 2.x for D7)
### Expect API changes
- node taxonomy condition to generic field condition for entities
-### Needs upgrade
-
-- context layouts
-
Context 3.x for Drupal 7.x
--------------------------
diff --git a/context_layouts/context_layouts.info b/context_layouts/context_layouts.info
index df63f1f..1494f5e 100644
--- a/context_layouts/context_layouts.info
+++ b/context_layouts/context_layouts.info
@@ -1,6 +1,6 @@
; $Id$
-name = "Context layouts"
-description = "Allow theme layer to provide multiple region layouts and integrate with context."
-dependencies[] = "context"
-package = "Context"
-core = "6.x"
+name = Context layouts
+description = Allow theme layer to provide multiple region layouts and integrate with context.
+dependencies[] = context
+package = Context
+core = 7.x
diff --git a/context_layouts/context_layouts.module b/context_layouts/context_layouts.module
index 8273236..6dcc8e9 100644
--- a/context_layouts/context_layouts.module
+++ b/context_layouts/context_layouts.module
@@ -39,6 +39,25 @@ function context_layouts_context_registry_alter(&$registry) {
}
/**
+ * Implementation of hook_theme().
+ * Declares each theme's layouts as a page template suggestion.
+ */
+function context_layouts_theme() {
+ $info = array();
+ foreach (list_themes() as $theme) {
+ if (!empty($theme->status) && $layouts = context_layouts_get_layouts($theme->name)) {
+ foreach ($layouts as $layout) {
+ $info["page__context_layouts_{$theme->name}_{$layout['layout']}"] = array(
+ 'template' => $layout['template'],
+ 'path' => drupal_get_path('theme', $theme->name),
+ );
+ }
+ }
+ }
+ return $info;
+}
+
+/**
* Implementation of hook_context_page_reaction().
*/
function context_layouts_context_page_reaction() {
@@ -69,26 +88,27 @@ function context_layouts_get_layouts($theme = NULL, $reset = FALSE) {
$theme = isset($theme) ? $theme : $theme_key;
if (!isset($layouts[$theme])) {
- $info = context_get_info('theme', $theme);
+ $info = system_get_info('theme', $theme);
$themes = array();
// Find all our ancestor themes that use layouts.
if (isset($info['base theme'])) {
while (!empty($info['base theme'])) {
$base_theme = $info['base theme'];
- $info = context_get_info('theme', $base_theme);
+ $info = system_get_info('theme', $base_theme);
$themes[$base_theme] = $info;
}
}
// Assemble in inheritance order and add the theme on.
$themes = array_reverse($themes);
- $themes[$theme] = context_get_info('theme', $theme);
+ $themes[$theme] = system_get_info('theme', $theme);
// Merge layout info into a single array.
foreach ($themes as $key => $info) {
if (!empty($info['layouts'])) {
foreach ($info['layouts'] as $layout => $layout_info) {
+ $layout_info['layout'] = str_replace('-', '_', $layout);
$layout_info['theme'] = $key;
$layouts[$theme][$layout] = $layout_info;
}
diff --git a/context_layouts/plugins/context_layouts_reaction_block.inc b/context_layouts/plugins/context_layouts_reaction_block.inc
index f34bf2a..2d5a38f 100644
--- a/context_layouts/plugins/context_layouts_reaction_block.inc
+++ b/context_layouts/plugins/context_layouts_reaction_block.inc
@@ -41,7 +41,8 @@ class context_layouts_reaction_block extends context_reaction_block {
function add_layout_template(&$vars) {
if ($layout = $this->get_active_layout()) {
if (!empty($layout['template'])) {
- $vars['template_files'][] = $layout['template'];
+ global $theme;
+ $vars['theme_hook_suggestion'] = "page__context_layouts_{$theme}_{$layout['layout']}";
}
}
}
@@ -127,8 +128,8 @@ class context_layouts_reaction_block extends context_reaction_block {
'#options' => $layouts,
'#type' => 'select',
'#weight' => -100,
- '#default_value' => $options['layout'] ? $options['layout'] : NULL,
- '#attributes' => array('class' => 'context-blockform-layout'),
+ '#default_value' => !empty($options['layout']) ? $options['layout'] : NULL,
+ '#attributes' => array('class' => array('context-blockform-layout')),
);
// Add js.
diff --git a/context_layouts/plugins/context_layouts_reaction_block.js b/context_layouts/plugins/context_layouts_reaction_block.js
index 4d31015..392a9a5 100644
--- a/context_layouts/plugins/context_layouts_reaction_block.js
+++ b/context_layouts/plugins/context_layouts_reaction_block.js
@@ -1,6 +1,9 @@
// $Id$
-Drupal.behaviors.contextLayoutsReactionBlock = function(context) {
+(function($) {
+
+Drupal.behaviors.contextLayoutsReactionBlock = {};
+Drupal.behaviors.contextLayoutsReactionBlock.attach = function(context) {
// ContextBlockForm: Init.
$('.context-blockform-layout:not(.contextLayoutsProcessed)').each(function() {
$(this).addClass('contextLayoutsProcessed');
@@ -22,3 +25,5 @@ Drupal.behaviors.contextLayoutsReactionBlock = function(context) {
$(this).change();
});
};
+
+})(jQuery); \ No newline at end of file