Skip to content

Commit

Permalink
Merge pull request Unallocated#246 from nhepner1/245-services
Browse files Browse the repository at this point in the history
245 services
  • Loading branch information
nhepner1 committed Nov 9, 2014
2 parents d104df4 + 3f02199 commit bb5355d
Show file tree
Hide file tree
Showing 249 changed files with 33,241 additions and 3,526 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ function context_context_page_condition() {
if ($plugin = context_get_plugin('condition', 'menu')) {
$plugin->execute();
}
if ($plugin = context_get_plugin('condition', 'default')) {
$plugin->execute(1);
}
if ($plugin = context_get_plugin('condition', 'context')) {
$plugin->execute();
}
Expand All @@ -331,9 +334,6 @@ function context_context_page_condition() {
* Implementation of hook_context_page_reaction().
*/
function context_context_page_reaction() {
if ($plugin = context_get_plugin('reaction', 'breadcrumb')) {
$plugin->execute();
}
if ($plugin = context_get_plugin('reaction', 'css_injector')) {
$plugin->execute();
}
Expand All @@ -346,10 +346,10 @@ function context_context_page_reaction() {
* Implementation of hook_preprocess_page().
*/
function context_preprocess_page(&$vars) {
if ($plugin = context_get_plugin('reaction', 'menu')) {
if ($plugin = context_get_plugin('reaction', 'theme')) {
$plugin->execute($vars);
}
if ($plugin = context_get_plugin('reaction', 'theme')) {
if ($plugin = context_get_plugin('reaction', 'template_suggestions')) {
$plugin->execute($vars);
}
/*
Expand All @@ -362,6 +362,19 @@ function context_preprocess_page(&$vars) {
*/
}

/**
* Implementation of hook_delivery_callback_alter().
* Based on menu_position's and menu_trail_by_path's implementations.
*/
function context_page_delivery_callback_alter() {
if ($plugin = context_get_plugin('reaction', 'menu')) {
$plugin->execute();
}
if ($plugin = context_get_plugin('reaction', 'breadcrumb')) {
$plugin->execute();
}
}

/**
* Implementation of hook_preprocess_html().
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ files[] = tests/context.test
files[] = tests/context.conditions.test
files[] = tests/context.reactions.test

; Information added by Drupal.org packaging script on 2014-01-28
version = "7.x-3.2"
; Information added by Drupal.org packaging script on 2014-09-30
version = "7.x-3.3"
core = "7.x"
project = "context"
datestamp = "1390931314"
datestamp = "1412114935"

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ function _context_context_registry() {
'description' => t('Should this context always be set? If <strong>true</strong>, this context will be active across your entire site.'),
'plugin' => 'context_condition_sitewide',
),
'default' => array(
'title' => t('Default context'),
'description' => t('This context will be set if no other context is active except sitewide contexts.'),
'plugin' => 'context_condition_default',
),
'path' => array(
'title' => t('Path'),
'description' => t('Set this context when any of the paths above match the page path. Put each path on a separate line. You can use the <code>*</code> character (asterisk) as a wildcard and the <code>~</code> character (tilde) to exclude one or more paths. Use &lt;front&gt; for the site front page.'),
Expand Down Expand Up @@ -108,6 +113,11 @@ function _context_context_registry() {
'description' => t('Set the breadcrumb trail to the selected menu item.'),
'plugin' => 'context_reaction_breadcrumb',
),
'template_suggestions' => array(
'title' => t('Template suggestions'),
'description' => t('Add template suggestions using context.'),
'plugin' => 'context_reaction_template_suggestions',
),
'theme' => array(
'title' => t('Theme Page'),
'description' => t('Control page theme variables using context.'),
Expand Down Expand Up @@ -189,6 +199,14 @@ function _context_context_plugins() {
'parent' => 'context_condition',
),
);
$plugins['context_condition_default'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') . '/plugins',
'file' => 'context_condition_default.inc',
'class' => 'context_condition_default',
'parent' => 'context_condition',
),
);
$plugins['context_condition_path'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') . '/plugins',
Expand Down Expand Up @@ -320,6 +338,14 @@ function _context_context_plugins() {
'parent' => 'context_reaction_menu',
),
);
$plugins['context_reaction_template_suggestions'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') . '/plugins',
'file' => 'context_reaction_template_suggestions.inc',
'class' => 'context_reaction_template_suggestions',
'parent' => 'context_reaction',
),
);
$plugins['context_reaction_menu'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') . '/plugins',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ core = 7.x

files[] = plugins/context_layouts_reaction_block.inc

; Information added by Drupal.org packaging script on 2014-01-28
version = "7.x-3.2"
; Information added by Drupal.org packaging script on 2014-09-30
version = "7.x-3.3"
core = "7.x"
project = "context"
datestamp = "1390931314"
datestamp = "1412114935"

Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ configure = admin/structure/context
files[] = context.module
files[] = tests/context_ui.test

; Information added by Drupal.org packaging script on 2014-01-28
version = "7.x-3.2"
; Information added by Drupal.org packaging script on 2014-09-30
version = "7.x-3.3"
core = "7.x"
project = "context"
datestamp = "1390931314"
datestamp = "1412114935"

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ContextUiTestCase extends DrupalWebTestCase {
$admin_user = $this->drupalCreateUser(array(
'access administration pages',
'administer site configuration',
'administer contexts',
'access content',
'create blog content'
));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/**
* Simple condition that sets context active if no other non-default and non
* sitewide context is active.
*/
class context_condition_default extends context_condition {
function condition_values() {
return array('context_condition_default' => t('Default context'));
}

function editor_form($context = NULL) {
$form = parent::editor_form($context);
$form[1]['#title'] = t('Default context');
$form['#weight'] = -10;
return $form;
}

function execute() {
if ($this->condition_used()) {
$active_contexts = context_active_contexts();

foreach ($active_contexts as $name => $context) {
foreach (array_keys($context->conditions) as $cond) {
if (!in_array($cond, array('default', 'sitewide'))) {
return;
}
}
}
foreach ($this->get_contexts('context_condition_default') as $context) {
$this->condition_met($context, 'context_condition_default');
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,17 @@ class context_reaction_block extends context_reaction {
$this->is_editable_check($context_blocks);
global $theme;
$active_regions = $this->system_region_list($theme);

// Make context renders regions in the same order as core.
$_context_blocks = array();
foreach ($active_regions as $r => $name) {
if (isset($context_blocks[$r])) {
$_context_blocks[$r] = $context_blocks[$r];
}
}
$context_blocks = $_context_blocks;
unset($_context_blocks);

foreach ($context_blocks as $r => $blocks) {
//only render blocks in an active region
if (array_key_exists($r, $active_regions)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,29 @@
*/
class context_reaction_breadcrumb extends context_reaction_menu {
/**
* Override of execute().
* Overrides set_active_trail_from_link to set the breadcrumb instead of the menu path.
*/
function execute(&$vars = NULL) {
if ($active_paths = $this->get_active_paths()) {
$breadcrumb = array(l(t('Home'), '<front>', array('purl' => array('disabled' => TRUE))));
foreach ($active_paths as $path) {
$result = db_select('menu_links')
->fields('menu_links', array('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8'))
->condition('hidden', 0)
->condition('link_path', $path)
->execute();
while ($parents = $result->fetchAssoc()) {
$set = FALSE;
foreach (array_filter($parents) as $plid) {
$parent = menu_link_load($plid);
if ($parent && $parent['access'] && empty($parent['hidden']) && !empty($parent['title'])) {
$set = TRUE;
$breadcrumb[] = l($this->get_link_title($parent), $parent['href']);
}
}
// Only set the breadcrumb if one or more links were added to the
// trail. If not, continue iterating through possible menu links.
if ($set) {
drupal_set_breadcrumb($breadcrumb);
break;
}
function set_active_trail_from_link($item) {
$result = db_select('menu_links')
->fields('menu_links', array('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8'))
->condition('hidden', 0)
->condition('link_path', $item['link_path'])
->execute();
while ($parents = $result->fetchAssoc()) {
$set = FALSE;
foreach (array_filter($parents) as $plid) {
$parent = menu_link_load($plid);
if ($parent && $parent['access'] && empty($parent['hidden']) && !empty($parent['title'])) {
$set = TRUE;
$breadcrumb[] = l($parent['title'], $parent['href']);
}
}
// Only set the breadcrumb if one or more links were added to the
// trail. If not, continue iterating through possible menu links.
if ($set) {
drupal_set_breadcrumb($breadcrumb);
break;
}
}
}
/**
Expand Down
Loading

0 comments on commit bb5355d

Please sign in to comment.