updated context, metatag, imagestyleflush, browscap

This commit is contained in:
Bachir Soussi Chiadmi
2016-11-05 16:43:45 +01:00
parent 7aeabebddf
commit 3413d81bb8
187 changed files with 14704 additions and 1871 deletions

View File

@@ -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 2015-01-06
version = "7.x-3.6"
; Information added by Drupal.org packaging script on 2016-05-18
version = "7.x-3.7"
core = "7.x"
project = "context"
datestamp = "1420573188"
datestamp = "1463605446"

View File

@@ -103,7 +103,7 @@ function context_update_7000() {
}
}
if (empty($updated)) {
$ret = t('No contexts requiring migration detected');
$ret = t('No contexts requiring migration detected.');
}
else {
$ret = t('The following contexts had theme reaction data migrated: @names', array('@names' => join(', ', $updated)));

View File

@@ -192,11 +192,61 @@ function context_init() {
* theme('menu_link') for the menu rendering to html.
*/
function context_preprocess_menu_link(&$variables) {
if($contexts = context_active_contexts()){
foreach($contexts as $context){
if((isset($context->reactions['menu']))){
if ($variables['element']['#href'] == $context->reactions['menu']) {
$variables['element']['#localized_options']['attributes']['class'][] = "active";
if ($contexts = context_active_contexts()) {
foreach ($contexts as $context) {
if (isset($context->reactions['menu'])) {
// In context module < v3.2 the url was a string. In version 3.3+ this is
// an array of urls. Implement interims BC layer.
//
// Examples:
// - OLD < v3.2 context reaction structure:
// array('menu' => 'taxonomy/term/1')
//
// - NEW 3.3+ context reaction structure:
// array(
// 'menu' => array(
// 0 => 'navigation:taxonomy/term/1'
// 1 => 'foo-menu:taxonomy/term/1'
// )
// )
$reactions_menu = is_array($context->reactions['menu']) ? array_values($context->reactions['menu']) : array($context->reactions['menu']);
// Get everything after the first ':' character (if found) as the url to
// match against element '#href'.
$urls = array();
foreach ($reactions_menu as $url) {
if (strpos($url, ':') !== FALSE) {
// Get unique menu name 'navigation' from 'navigation:taxonomy/term/1'
$reaction_menu = explode(':', $url);
$path = $reaction_menu[1];
$urls[$path] = $reaction_menu[0];
}
else {
// BC layer for menu contexts that have not re-saved. This is for
// urls like 'taxonomy/term/1'. We need to add a fake menu key
// 'bc-context-menu-layer' or the BC link get's removed by
// array_intersect below.
//
// @TODO: Remove BC layer in 4.x
$urls[$url] = 'context-reaction-menu-bc-layer';
}
}
// Filter urls by the menu name of the current link. The link reaction
// can be configured per menu link in specific menus and the contect
// reaction should not applied to other menus with the same menu link.
$menu_name = $variables['element']['#original_link']['menu_name'];
$menu_paths = array_intersect($urls, array($menu_name, 'context-reaction-menu-bc-layer'));
$reaction_menu_paths = array_keys($menu_paths);
// - If menu href and context reaction menu url match, add the 'active'
// css class to the link of this menu.
// - Do not add class twice on current page.
if (in_array($variables['element']['#href'], $reaction_menu_paths) && $variables['element']['#href'] != $_GET['q']) {
// Do not add the 'active' class twice in views tabs.
if (!in_array('active', $variables['element']['#localized_options']['attributes']['class'])) {
$variables['element']['#localized_options']['attributes']['class'][] = 'active';
}
}
}
}

View File

@@ -37,7 +37,7 @@ function _context_context_registry() {
'plugin' => 'context_condition_path',
),
'query_string' => array(
'title' => t('Query String'),
'title' => t('Query string'),
'description' => t('Set this context when any of the query strings above match the page query string. Put each query string on a separate line. You can use the "*" character as a wildcard and <code>~</code> to exclude one or more query strings.'),
'plugin' => 'context_condition_query_string',
),
@@ -119,7 +119,7 @@ function _context_context_registry() {
'plugin' => 'context_reaction_template_suggestions',
),
'theme' => array(
'title' => t('Theme Page'),
'title' => t('Theme page'),
'description' => t('Control page theme variables using context.'),
'plugin' => 'context_reaction_theme',
),

View File

@@ -6,9 +6,9 @@ core = 7.x
files[] = plugins/context_layouts_reaction_block.inc
; Information added by Drupal.org packaging script on 2015-01-06
version = "7.x-3.6"
; Information added by Drupal.org packaging script on 2016-05-18
version = "7.x-3.7"
core = "7.x"
project = "context"
datestamp = "1420573188"
datestamp = "1463605446"

View File

@@ -8,9 +8,9 @@ configure = admin/structure/context
files[] = context.module
files[] = tests/context_ui.test
; Information added by Drupal.org packaging script on 2015-01-06
version = "7.x-3.6"
; Information added by Drupal.org packaging script on 2016-05-18
version = "7.x-3.7"
core = "7.x"
project = "context"
datestamp = "1420573188"
datestamp = "1463605446"

View File

@@ -12,11 +12,11 @@ function DrupalContextPlugins(form) {
$('.context-plugin-list > li', this.form).each(function() {
var plugin = $(this).attr('class').split('context-plugin-')[1].split(' ')[0];
if ($(this).is('.disabled')) {
$('.context-plugin-selector select option[value='+plugin+']', this.form).show();
$('.context-plugin-selector select option[value="'+plugin+'"]', this.form).show();
}
else {
state.push(plugin);
$('.context-plugin-selector select option[value='+plugin+']', this.form).hide();
$('.context-plugin-selector select option[value="'+plugin+'"]', this.form).hide();
}
});
// Set the hidden plugin list state.

View File

@@ -81,7 +81,7 @@ function context_ui_permission() {
'description' => 'Associate menus, views, blocks, etc. with different contexts to structure your site.'
);
$permissions['context ajax block access'] = array(
'title' => t('Access All Blocks'),
'title' => t('Access all blocks'),
'description' => t('Allows users to access all rendered blocks via an AJAX callback. If you have some blocks that should not be rendered for some users but need those users to be able to use context UI, then implement hook_context_allow_ajax_block_access with the necessary logic.'),
);
return $permissions;
@@ -143,7 +143,7 @@ function context_ui_editor($form, &$form_state, $contexts) {
$form['title'] = array(
'#prefix' => '<h2 class="context-editor-title">',
'#markup' => t('Select the Context/Layer to Edit'),
'#markup' => t('Select the context/layer to edit'),
'#suffix' => '</h2>',
'#weight' => -2,
);
@@ -151,10 +151,7 @@ function context_ui_editor($form, &$form_state, $contexts) {
//add some help text to the top of the form
$form['help'] = array (
'#prefix' => '<p class="context-help help">',
'#markup' => t('Select which context, or layer of blocks, to edit.
Each context is configured to appear on different sets of pages so read the description carefully.
When you are done editing click Done and save your changes.
You may use the Stop Editing Layout link to close the editor.'),
'#markup' => t('Select which context, or layer of blocks, to edit. Each context is configured to appear on different sets of pages so read the description carefully. When you are done editing click Done and save your changes. You may use the Stop Editing Layout link to close the editor.'),
'#suffix' => '</p>',
'#weight' => -1,
);
@@ -166,10 +163,9 @@ function context_ui_editor($form, &$form_state, $contexts) {
$edit = l(t('Edit'), $_GET['q'], array('fragment' => $context->name, 'attributes' => array('class' => array('edit'))));
$done = l(t('Done'), $_GET['q'], array('fragment' => $context->name, 'attributes' => array('class' => array('done'))));
$readable_name = ucwords(str_replace('_', ' ', $context->name));
$description = empty($context->description) ? '' :
"<br/><div class='label bottom'>".check_plain($context->description)."</div>";
$description = empty($context->description) ? '' : '<br/><div class="label bottom">' . check_plain($context->description) . '</div>';
$items[] = array(
'data' => "<div class='label top'>" . $readable_name. "</div><div class='links'>{$edit} {$done}</div>" . $description,
'data' => '<div class="label top">' . $readable_name. "</div><div class='links'>{$edit} {$done}</div>" . $description,
'class' => array('context-editable clearfix'),
'id' => "context-editable-trigger-{$context->name}",
);
@@ -306,9 +302,9 @@ function context_ui_settings($form, &$form_state) {
}
$form['context_ui_dialog_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Use Context Editor Dialog'),
'#title' => t('Use context editor dialog'),
'#default_value' => context_ui_dialog_is_enabled(),
'#description' => t('When enabled all contextual links will have a Edit Layout link that will refresh the page with the context editor in a dialog box.'),
'#description' => t('When enabled all contextual links will have a <em>Edit layout</em> link that will refresh the page with the context editor in a dialog box.'),
);
$form = system_settings_form($form);
$form['#submit'][] = 'context_ui_settings_submit';
@@ -374,7 +370,7 @@ function context_ui_menu_contextual_links_alter(&$links, $router_item, $root_pat
!context_isset('context_ui', 'context_ui_editor_present') && user_access('administer contexts')) {
$links['layout'] = array(
'href' => 'context-ui/activate',
'title' => t('Configure Layout'),
'title' => t('Configure layout'),
'localized_options' => array(
'query' => array('destination'=> $_GET['q']),
'options' => array('html' => FALSE, 'attributes' => array()),

View File

@@ -9,11 +9,11 @@
selector.detach();
$('#page').prepend(selector);
var labelOpen = Drupal.t('Select Context');
var labelOpen = Drupal.t('Select context');
var labelClose = Drupal.t('Hide');
// Create a tab to show/hide our edit area
var tab = $('<a href="javascript:" class="context-ui-dialog-open" title="Show Context Selector">'+labelClose+'</a>');
var tab = $('<a href="javascript:" class="context-ui-dialog-open" title="' + Drupal.t('Show context selector') + '">'+labelClose+'</a>');
selector.append(tab);
selector.toggled = false;

View File

@@ -22,7 +22,7 @@ class context_export_ui extends ctools_export_ui {
function list_render(&$form_state) {
$table = array(
'header' => $this->list_table_header(),
'rows' => $this->rows,
'rows' => $this->rows,
'attributes' => array(
'class' => array('context-admin'),
'id' => 'ctools-export-ui-list-items',
@@ -104,17 +104,17 @@ class context_export_ui extends ctools_export_ui {
* @param $form_state
* Form state array
*/
function context_ui_form(&$form, &$form_state) {
function context_ui_form(&$form, &$form_state) {
$conditions = array_keys(context_conditions());
sort($conditions);
$reactions = array_keys(context_reactions());
sort($reactions);
$context = $form_state['item'];
if (!empty($form_state['input'])) {
$context = _context_ui_rebuild_from_input($context, $form_state['input'], $conditions, $reactions);
}
$form['#base'] = 'context_ui_form';
$form['#theme'] = 'context_ui_form';
@@ -131,7 +131,7 @@ function context_ui_form(&$form, &$form_state) {
'#required' => FALSE,
'#maxlength' => 255,
'#default_value' => isset($context->tag) ? $context->tag : '',
'#description' => t('Example: <code>theme</code>') .'<br/>'. t('A tag to group this context with others.'),
'#description' => t('Example: <code>theme</code>') . '<br/>' . t('A tag to group this context with others.'),
);
$form['info']['description'] = array(
@@ -155,11 +155,11 @@ function context_ui_form(&$form, &$form_state) {
$form['conditions'] = array(
'#theme' => 'context_ui_plugins',
'#title' => t('Conditions'),
'#description' => t('Trigger the activation of this context'),
'#description' => t('Trigger the activation of this context.'),
'#tree' => TRUE,
'selector' => array(
'#type' => 'select',
'#options' => array(0 => '<'. t('Add a condition') .'>'),
'#options' => array(0 => '<' . t('Add a condition') . '>'),
'#default_value' => 0,
),
'state' => array(
@@ -185,11 +185,11 @@ function context_ui_form(&$form, &$form_state) {
$form['reactions'] = array(
'#theme' => 'context_ui_plugins',
'#title' => t('Reactions'),
'#description' => t('Actions to take when this context is active'),
'#description' => t('Actions to take when this context is active.'),
'#tree' => TRUE,
'selector' => array(
'#type' => 'select',
'#options' => array(0 => '<'. t('Add a reaction') .'>'),
'#options' => array(0 => '<' . t('Add a reaction') . '>'),
'#default_value' => 0,
),
'state' => array(
@@ -225,7 +225,7 @@ function context_ui_form(&$form, &$form_state) {
* A context object
*/
function _context_ui_rebuild_from_input($context, $input, $conditions, $reactions) {
$condition_defaults = array();
$condition_defaults = array();
foreach ($conditions as $condition) {
if ($plugin = context_get_plugin('condition', $condition)) {
$condition_defaults[$condition] = array(
@@ -235,7 +235,7 @@ function _context_ui_rebuild_from_input($context, $input, $conditions, $reaction
}
}
$input['conditions']['plugins'] = array_merge($condition_defaults, $input['conditions']['plugins']);
$reaction_defaults = array();
foreach ($reactions as $reaction) {
if ($plugin = context_get_plugin('reaction', $reaction)) {

View File

@@ -48,7 +48,7 @@ class ContextUiTestCase extends DrupalWebTestCase {
'description' => $context->description,
'tag' => $context->tag,
'conditions[plugins][node][values][blog]' => 'blog',
'reactions[plugins][menu]' => 'node/add/blog',
'reactions[plugins][menu][]' => 'navigation:node/add/blog',
);
$this->drupalPost('admin/structure/context/add', $edit, 'Save');
$this->assertText($context->name . ' has been created.', 'Context saved.');

View File

@@ -8,7 +8,7 @@ class context_condition_bookroot extends context_condition_node {
if ($this->condition_used() && !empty($node->book['bid'])) {
$type = db_select('node')
->fields('node', array('type'))
->condition('nid', $node->book['nid'])
->condition('nid', $node->book['bid'])
->execute()
->fetchField();
$book = new stdClass();

View File

@@ -14,7 +14,7 @@ class context_condition_menu extends context_condition {
foreach ($menus as $key => $name) {
$id = explode(':', $key);
if ($id[1] == '0') {
$root_menus[$id[0]] = check_plain($name);
$root_menus[$id[0]] = $name;
}
else {
$link = menu_link_load($id[1]);

View File

@@ -45,24 +45,28 @@ class context_condition_node_taxonomy extends context_condition_node {
$check_fields = array();
foreach ($instance_fields as $key => $field_info) {
if ($fields[$key]['type'] == 'taxonomy_term_reference') {
$check_fields[] = $key;
$check_fields[$key] = 'tid';
}
else if ($fields[$key]['type'] == 'entityreference' &&
$fields[$key]['settings']['target_type'] == 'taxonomy_term') {
$check_fields[$key] = 'target_id';
}
}
if ($this->condition_used() && !empty($check_fields)) {
foreach ($check_fields as $field) {
foreach ($check_fields as $field => $term_id_key) {
if ($terms = field_get_items('node', $node, $field)) {
foreach ($terms as $term) {
foreach ($this->get_contexts($term['tid']) as $context) {
foreach ($this->get_contexts($term[$term_id_key]) as $context) {
// Check the node form option.
if ($op === 'form') {
$options = $this->fetch_from_context($context, 'options');
if (!empty($options['node_form'])) {
$this->condition_met($context, $term['tid']);
$this->condition_met($context, $term[$term_id_key]);
}
}
else {
$this->condition_met($context, $term['tid']);
$this->condition_met($context, $term[$term_id_key]);
}
}
}

View File

@@ -69,7 +69,7 @@ DrupalContextBlockForm = function(blockForm) {
// Hide enabled blocks from selector that are used
$('table.context-blockform-region tr').each(function() {
var bid = $(this).attr('id');
$('div.context-blockform-selector input[value='+bid+']').parents('div.form-item').eq(0).hide();
$('div.context-blockform-selector input[value="'+bid+'"]').parents('div.form-item').eq(0).hide();
});
// Show blocks in selector that are unused
$('div.context-blockform-selector input').each(function() {
@@ -159,7 +159,7 @@ DrupalContextBlockForm = function(blockForm) {
$(this).removeAttr('checked');
});
if (weight_warn) {
alert(Drupal.t('Desired block weight exceeds available weight options, please check weights for blocks before saving'));
alert(Drupal.t('Desired block weight exceeds available weight options, please check weights for blocks before saving.'));
}
}
return false;
@@ -426,9 +426,8 @@ DrupalContextBlockEditor.prototype = {
$('.editing-context-label').remove();
var label = $('#context-editable-trigger-'+context+' .label').text();
label = Drupal.t('Now Editing: ') + label;
editor.parent().parent()
.prepend('<div class="editing-context-label">'+ label + '</div>');
label = Drupal.t('Now editing: @label', {'@label': label});
editor.parent().parent().prepend('<div class="editing-context-label">' + label + '</div>');
// First pass, enable sortables on all regions.
$(this.regions).each(function() {

View File

@@ -8,6 +8,7 @@ class context_reaction_breadcrumb extends context_reaction_menu {
* Overrides set_active_trail_from_link to set the breadcrumb instead of the menu path.
*/
function set_active_trail_from_link($item) {
$breadcrumb = array(l(t('Home'), '<front>'));
$result = db_select('menu_links')
->fields('menu_links', array('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8'))
->condition('hidden', 0)

View File

@@ -22,19 +22,21 @@ class context_reaction_menu extends context_reaction {
$link = menu_link_load($mlid);
$identifier = $link['link_path'];
$root_menu = $menu_names[$menu_name];
while (isset($options[$root_menu][$identifier])) {
while (isset($options[$root_menu][$menu_name . ':' . $identifier])) {
$identifier .= "'";
}
$options[$root_menu][$menu_name . ':' . $identifier] = $title;
}
}
}
$menu_count = count($options, COUNT_RECURSIVE);
return array(
'#title' => $this->title,
'#description' => $this->description,
'#options' => $options,
'#type' => 'select',
'#multiple' => TRUE,
'#size' => $menu_count > 20 ? 20 : $menu_count,
'#default_value' => $this->fetch_from_context($context),
);
}

View File

@@ -14,7 +14,7 @@ class context_reaction_template_suggestions extends context_reaction {
return array(
'#title' => t('Template suggestions'),
'#type' => 'textarea',
'#description' => t('Enter template suggestions such as "page__front", one per line, in order of preference (using underscores instead of hyphens). For more information, please visit ') . l(t('Drupal 7 Template (Theme Hook) Suggestions'), 'http://drupal.org/node/1089656', array(array('target' => '_blank'), 'html' => TRUE,)) . '.',
'#description' => t('Enter template suggestions such as "page__front", one per line, in order of preference (using underscores instead of hyphens). For more information, please visit <a href="@template-suggestions">Drupal 7 Template (Theme Hook) Suggestions</a>.', array('@template-suggestions' => 'http://drupal.org/node/1089656')),
'#default_value' => is_string($default_value) ? $default_value : '',
);
}

View File

@@ -36,13 +36,6 @@ class ContextConditionUserTest extends DrupalWebTestCase {
$this->assertTrue($saved, "Context 'testcontext' saved.");
}
function tearDown() {
parent::tearDown();
context_delete($this->context);
user_delete($this->user1->uid);
user_delete($this->user2->uid);
}
function test() {
// User 1 triggers the context.
$this->drupalLogin($this->user1);
@@ -82,14 +75,6 @@ class ContextConditionUserPageTest extends DrupalWebTestCase {
$this->assertTrue($saved, "Context 'testcontext' saved.");
}
function tearDown() {
parent::tearDown();
context_delete($this->context);
$edit = array();
user_delete($this->user1->uid);
user_delete($this->user2->uid);
}
function test() {
// Viewing any user profile triggers context.
$this->drupalLogin($this->user1);
@@ -157,13 +142,6 @@ class ContextConditionNodeTaxonomyTest extends DrupalWebTestCase {
$this->assertTrue($saved, "Context 'testcontext' saved.");
}
function tearDown() {
parent::tearDown();
context_delete($this->context);
taxonomy_term_delete($this->terms['apples']->tid);
taxonomy_term_delete($this->terms['oranges']->tid);
}
function test() {
// Apples does trigger the context.
$edit = array(

View File

@@ -52,7 +52,7 @@ function theme_context_block_regions_form($vars) {
$output .= "<div class='label context-blockform-regionlabel-{$region}'>";
$output .= l(t('+') . ' ' . t('Add'), $_GET['q'], array('fragment' => $region, 'attributes' => array('class' => array('add-block'))));
$output .= $form[$region]['#title'];
$output .= "</div>";
$output .= '</div>';
$output .= theme('table', array('rows' => $rows, 'attributes' => $attr));
}
return $output;
@@ -100,14 +100,13 @@ function template_preprocess_context_block_browser(&$vars) {
//add help text to tell people how to use the block browser
$help_text = array(
'#prefix' => '<div class="context_ui-help-text">',
'#markup' => t('To add a block to the current region, simply click on the block. You may use the category filter to filter by
block type or the search filter to find the block that you wish to add.'),
'#markup' => t('To add a block to the current region, simply click on the block. You may use the category filter to filter by block type or the search filter to find the block that you wish to add.'),
'#suffix' => '</div>',
);
$filter_label = array(
'#prefix' => '<div class="filter-label">',
'#markup' => t('Search Filter'),
'#markup' => t('Search filter'),
'#suffix' => '</div>',
);