Project

General

Profile

Revision ecb492a9

Added by Assos Assos over 5 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/block_class/README.txt
1
=====
2
Block Class
3
http://drupal.org/project/block_class
4
-----
5
Block Class was developed and is maintained by Four Kitchens
6
<http://fourkitchens.com>.
1
INTRODUCTION
2
============
7 3

  
4
Block Class allows users to add classes to any block through the block's
5
configuration interface. By adding a very short snippet of PHP to a theme's
6
block.tpl.php file, classes can be added to the parent <div class="block ...">
7
element of a block. Hooray for more powerful block theming!
8
 
9
REQUIREMENTS
10
============
8 11

  
9
=====
10
Installation
11
-----
12
This module requires the following modules:
13
 *Block (https://www.drupal.org/project/block)
12 14

  
13
1. Enable the module
14
2. To add a class to a block, simply visit that block's configuration page at
15
Administration > Structure > Blocks
15
INSTALLATION
16
============
17
 
18
 Install as you would normally install a contributed Drupal module:
19
   *https://www.drupal.org/project/block_class
20
   Also See:
21
     *(https://drupal.org/documentation/install/modules-themes/modules-7)for
22
further information.
23

  
24
CONFIGURATION
25
=============
26

  
27
* To add a class to a block, simply visit that block's configuration page at
28
Administration >> Structure >> Blocks
29

  
30

  
31
MAINTAINERS
32
===========
33

  
34
Current maintainers:
35
 * David Suissa (DYdave) - https://www.drupal.org/u/dydave
36
 * berenddeboer - https://www.drupal.org/u/berenddeboer
37
 * Todd Nienkerk - https://www.drupal.org/u/todd-nienkerk
38
 * elliotttf - https://www.drupal.org/u/elliotttf
drupal7/sites/all/modules/block_class/block_class.info
6 6
files[] = block_class.test
7 7
test_dependencies[] = context
8 8
test_dependencies[] = features (2.x)
9
test_dependencies[] = features_extra
9
test_dependencies[] = features_extra:fe_block
10
test_dependencies[] = menu_block
11
test_dependencies[] = views
10 12

  
11
; Information added by Drupal.org packaging script on 2015-12-18
12
version = "7.x-2.3"
13
; Information added by Drupal.org packaging script on 2018-07-27
14
version = "7.x-2.4"
13 15
core = "7.x"
14 16
project = "block_class"
15
datestamp = "1450415951"
16

  
17
datestamp = "1532735885"
drupal7/sites/all/modules/block_class/block_class.module
67 67
 * Alter block edit form to add configuration field.
68 68
 */
69 69
function block_class_form_alter(&$form, &$form_state, $form_id) {
70
  if (user_access('administer block classes') && ($form_id == 'block_admin_configure' || $form_id == 'block_add_block_form')) {
70
  // Form ids of modules with block creation pages also need to be checked.
71
  if (user_access('administer block classes') && (in_array($form_id, array(
72
    'block_admin_configure',
73
    'block_add_block_form',
74
    'menu_block_add_block_form',
75
  )))) {
71 76
    // Load statically cached block object used to display the form.
72 77
    $block = block_load($form['module']['#value'], $form['delta']['#value']);
73 78

  
......
89 94
 * Save supplied CSS classes.
90 95
 */
91 96
function block_class_form_submit($form, &$form_state) {
92
  if ($form_state['values']['form_id'] == 'block_admin_configure' || $form_state['values']['form_id'] == 'block_add_block_form') {
97
  // Form ids of modules with block creation pages also need to be checked.
98
  if (in_array($form_state['values']['form_id'], array(
99
    'block_admin_configure',
100
    'block_add_block_form',
101
    'menu_block_add_block_form',
102
  ))) {
93 103
    // Only save if value has changed.
94 104
    if (isset($form_state['values']['css_class']) && $form['settings']['css_class']['#default_value'] != $form_state['values']['css_class'] && user_access('administer blocks')) {
95 105
      db_update('block')
drupal7/sites/all/modules/block_class/block_class.test
11 11
class BlockClassTestCase extends DrupalWebTestCase {
12 12

  
13 13
  /**
14
   * User object to perform site browsing
14
   * User object to perform site browsing.
15
   *
15 16
   * @var object
16 17
   */
17 18
  protected $privilegedUser;
18 19

  
19 20
  /**
20 21
   * Machine name of the module providing the block coupled with delta.
22
   *
21 23
   * @var string
22 24
   */
23 25
  protected $module = 'system';
24 26

  
25 27
  /**
26 28
   * Block delta as provided by its module.
29
   *
27 30
   * @var string
28 31
   */
29 32
  protected $delta = 'main';
30 33

  
31 34
  /**
32 35
   * Permissions required by the user to perform the tests.
36
   *
33 37
   * @var array
34 38
   */
35 39
  protected $permissions = array(
......
86 90
    $this->drupalPost("admin/structure/block/manage/$module/$delta/configure", array('css_class' => $css_classes), t('Save block'));
87 91
    // Check Block configuration was saved successfully.
88 92
    $this->assertText(t('The block configuration has been saved.'));
89
    // Browse to the homepage.
90
    $this->drupalGet('');
91 93
    // Log out if the test is for anonymous user.
92 94
    if ($anon) {
93 95
      $this->drupalLogout();
94
      // Browse back to the homepage.
95
      $this->drupalGet('');
96 96
    }
97
    // Browse to the homepage.
98
    $this->drupalGet('');
97 99
    // Check if the Block CSS classes could be found.
98 100
    $this->assertPattern('/class=\"(.*?)' . $css_classes . '(.*?)\"/', format_string('The CSS classes were found: @css_classes', array('@css_classes' => $css_classes)));
99
    // Login again after testing with the anonumous user.
101
    // Login again after testing with the anonymous user.
100 102
    if ($anon) {
101 103
      $this->drupalLogin($this->privilegedUser);
102 104
    }
103 105
  }
106

  
104 107
}
105 108

  
106 109
/**
......
123 126
   * Update and display a Block multiple times to ensure CSS class is found.
124 127
   *
125 128
   * A Block is updated and displayed several times and with logged in or
126
   * anonymous user, with Block cache turned enabled or disabled.
129
   * anonymous user, with Block cache enabled or disabled.
127 130
   */
128 131
  public function testUpdateDisplayClass() {
129 132
    // Edit the block, change the class and check if the CSS classes are found.
......
140 143
    // Edit the block, change the class and check with the anonymous user.
141 144
    $this->assertUpdateBlockClass(TRUE);
142 145
  }
146

  
143 147
}
144 148

  
145 149
/**
......
180 184
    // If the field is not found, it can't be submitted through drupalPost.
181 185
    $this->assertNoFieldById('css_class', 'The Css classes field was not found on the page.');
182 186
  }
187

  
183 188
}
184 189

  
185 190
/**
......
252 257
    // Save the context.
253 258
    context_save($context);
254 259
  }
260

  
255 261
}
256 262

  
257 263
/**
......
280 286
    $this->module = 'user';
281 287
    $this->delta = 'online';
282 288
    // Include all Features related modules and Test Helper feature.
283
	parent::setUp('block_class_fe_block_test');
289
    parent::setUp('block_class_fe_block_test');
284 290
  }
285 291

  
286 292
  /**
......
307 313
    // Run a standard Update/Display Test check with Anon.
308 314
    $this->assertUpdateBlockClass(TRUE);
309 315

  
310
    // Ensure Feature's state is overriden for 'fe_block_settings' component.
316
    // Ensure Feature's state is overridden for 'fe_block_settings' component.
311 317
    module_load_include('inc', 'features', 'features.export');
312 318
    $test_feature_state = features_get_storage($test_feature);
313 319
    $this->assertFalse(empty($test_feature_state), 'The state of the <em>Block Class FE Block Integration Test Helper</em> feature is <strong>Overridden</strong>.');
......
326 332
    $this->drupalGet("admin/structure/block/manage/{$this->module}/{$this->delta}/configure");
327 333
    $this->assertFieldByName('css_class', $test_classes, format_string('After reverting the feature, the CSS classes from exported feature were found for the field <em>css_class</em> in the Block\'s configuration page: @css_classes', array('@css_classes' => $test_classes)));
328 334
  }
335

  
336
}
337

  
338
/**
339
 * Test Block Class integration with Menu Block.
340
 */
341
class BlockClassMenuBlockTestCase extends BlockClassTestCase {
342

  
343
  /**
344
   * Implements DrupalWebTestCase::getInfo().
345
   */
346
  public static function getInfo() {
347
    return array(
348
      'name' => 'Integration with Menu Block',
349
      'description' => 'Test the integration of Block Class with the Menu Block module and the update/display of a Menu Block CSS class.',
350
      // We could use Menu Block's API to import a block from code. But part of
351
      // this test is about the creation process of a Menu Block.
352
      'dependencies' => array('menu_block'),
353
      'group' => 'Block Class',
354
    );
355
  }
356

  
357
  /**
358
   * Enable modules and create user with specific permissions.
359
   */
360
  public function setUp() {
361
    // Override default parameters to test with the first Menu Block created.
362
    $this->module = 'menu_block';
363
    $this->delta = 1;
364
    // Add permission required by Menu Block to browse the add menu block page.
365
    $this->permissions[] = 'administer menu';
366
    // Include the Menu Block module and its dependencies to be loaded.
367
    parent::setUp('menu_block');
368
  }
369

  
370
  /**
371
   * Create, update and display a Menu Block to ensure CSS class is found.
372
   *
373
   * A Menu Block is added through the user interface. It is then updated and
374
   * displayed several times with logged in or anonymous user.
375
   */
376
  public function testMenuBlockDisplayClass() {
377
    // Test with three random class names.
378
    $css_classes = implode(' ', array(
379
      $this->randomName(8),
380
      $this->randomName(8),
381
      $this->randomName(8),
382
    ));
383
    // Start with the creation of a new Menu Block.
384
    $this->drupalPost("admin/structure/block/add-menu-block", array(
385
      'css_class' => $css_classes,
386
      'menu_name' => 'navigation',
387
      'regions[bartik]' => 'content',
388
    ), t('Save block'));
389
    // Check if the Block was successfully created.
390
    $this->assertText(t('The block has been created.'));
391
    // Browse to the homepage.
392
    $this->drupalGet('');
393
    // Check if the Block CSS classes could be found.
394
    $this->assertPattern('/class=\"(.*?)' . $css_classes . '(.*?)\"/', format_string('The CSS classes were found: @css_classes', array('@css_classes' => $css_classes)));
395
    // Run the standard tests on the existing Menu Block created above.
396
    // Edit the block, change the class and check with the anonymous user.
397
    $this->assertUpdateBlockClass(TRUE);
398
  }
399

  
400
}
401

  
402
/**
403
 * Test Block Class integration with Views block.
404
 */
405
class BlockClassViewsTestCase extends BlockClassUpdateDisplayTestCase {
406

  
407
  /**
408
   * Implements DrupalWebTestCase::getInfo().
409
   */
410
  public static function getInfo() {
411
    return array(
412
      'name' => 'Integration with Views block',
413
      'description' => 'Test the integration of Block Class with Views blocks and the update/display of a CSS class.',
414
      'dependencies' => array('views'),
415
      'group' => 'Block Class',
416
    );
417
  }
418

  
419
  /**
420
   * Enable modules and create the data necessary to run the tests.
421
   */
422
  public function setUp() {
423
    // Override default parameters to test with the Views: Archive block.
424
    $this->module = 'views';
425
    $this->delta = 'archive-block';
426
    // Include the Views module and its dependencies to be loaded.
427
    parent::setUp('views');
428

  
429
    // Programmatically enable the default Archive View, based on #820110-1.
430
    $status = variable_get('views_defaults', array());
431
    $status['archive'] = FALSE;
432
    variable_set('views_defaults', $status);
433

  
434
    // Note that the Views Archive block is not visible on the Block admin page
435
    // unless the registry is rebuilt with: registry_rebuild().
436
    // Directly publish the Views Archive Block to the content region.
437
    $this->drupalPost("admin/structure/block/manage/{$this->module}/{$this->delta}/configure", array('regions[bartik]' => 'content'), t('Save block'));
438

  
439
    // Create a sample node to have some data to display in Views: Archive.
440
    $this->drupalCreateNode(array(
441
      'type' => 'page',
442
      'status' => 1,
443
      'uid' => $this->privilegedUser->uid,
444
    ));
445
  }
446

  
329 447
}
drupal7/sites/all/modules/block_class/tests/block_class_fe_block_test.features.fe_block_settings.inc
1 1
<?php
2

  
2 3
/**
3 4
 * @file
4 5
 * block_class_fe_block_test.features.fe_block_settings.inc
drupal7/sites/all/modules/block_class/tests/block_class_fe_block_test.info
7 7
features[features_api][] = api:2
8 8
hidden = TRUE
9 9

  
10
; Information added by Drupal.org packaging script on 2015-12-18
11
version = "7.x-2.3"
10
; Information added by Drupal.org packaging script on 2018-07-27
11
version = "7.x-2.4"
12 12
core = "7.x"
13 13
project = "block_class"
14
datestamp = "1450415951"
15

  
14
datestamp = "1532735885"
drupal7/sites/all/modules/block_class/tests/block_class_fe_block_test.module
1 1
<?php
2

  
2 3
/**
3 4
 * @file
4 5
 * Drupal needs this blank file.

Also available in: Unified diff