Skip to content

Leave only .info and .module files #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
339 changes: 0 additions & 339 deletions www/sites/all/modules/block_class/LICENSE.txt

This file was deleted.

38 changes: 0 additions & 38 deletions www/sites/all/modules/block_class/README.txt

This file was deleted.

151 changes: 0 additions & 151 deletions www/sites/all/modules/block_class/block_class.install

This file was deleted.

116 changes: 0 additions & 116 deletions www/sites/all/modules/block_class/block_class.module
Original file line number Diff line number Diff line change
@@ -1,116 +0,0 @@
<?php

/**
* @file
* Enhanced control over the CSS Classes of any Block.
*
* Block Class allows users to add classes to any block through the block's
* configuration interface. This implementation is based on an alteration of
* the Core block database table to leverage the Core Block API functions,
* objects and structure.
*/

/**
* Implements hook_permission().
*/
function block_class_permission() {
return array(
'administer block classes' => array(
'title' => t('Administer block classes'),
'description' => t('Set CSS classes for blocks.'),
),
);
}

/**
* Implements theme_preprocess_block().
*
* Extend block's classes with any user defined classes.
*/
function block_class_preprocess_block(&$vars) {
$block = $vars['block'];
if (!empty($block->css_class)) {
$classes_array = explode(' ', $block->css_class);
foreach ($classes_array as $class) {
$vars['classes_array'][] = drupal_clean_css_identifier($class, array());
}
}
}

/**
* Implements hook_preprocess_HOOK().
*
* Extend panel block's classes with any user defined classes.
*/
function block_class_preprocess_panels_pane(&$vars) {
if ($vars['pane']->type != 'block') {
return;
}
// Infer the block's $module and $delta from the pane subtype.
$block_parts = explode('-', $vars['pane']->subtype);
// Load the block based on the block parts.
$block = block_load($block_parts[0], $block_parts[1]);
// Add a generic 'module type' pane class.
$vars['classes_array'][] = drupal_html_class('pane-' . $block->module);
// Add $css_class to the $classes_array.
if (!empty($block->css_class)) {
$classes_array = explode(' ', $block->css_class);
foreach ($classes_array as $class) {
$vars['classes_array'][] = drupal_clean_css_identifier($class, array());
}
}
}

/**
* Implements hook_form_alter().
*
* Alter block edit form to add configuration field.
*/
function block_class_form_alter(&$form, &$form_state, $form_id) {
// Form ids of modules with block creation pages also need to be checked.
if (user_access('administer block classes') && (in_array($form_id, array(
'block_admin_configure',
'block_add_block_form',
'menu_block_add_block_form',
)))) {
// Load statically cached block object used to display the form.
$block = block_load($form['module']['#value'], $form['delta']['#value']);

$form['settings']['css_class'] = array(
'#type' => 'textfield',
'#title' => t('CSS class(es)'),
'#default_value' => isset($block->css_class) ? $block->css_class : '',
'#description' => t('Customize the styling of this block by adding CSS classes. Separate multiple classes by spaces.'),
'#maxlength' => 255,
);

$form['#submit'][] = 'block_class_form_submit';
}
}

/**
* Helper function: additional submit callback for block configuration pages.
*
* Save supplied CSS classes.
*/
function block_class_form_submit($form, &$form_state) {
// Form ids of modules with block creation pages also need to be checked.
if (in_array($form_state['values']['form_id'], array(
'block_admin_configure',
'block_add_block_form',
'menu_block_add_block_form',
))) {
// Only save if value has changed.
if (isset($form_state['values']['css_class']) && $form['settings']['css_class']['#default_value'] != $form_state['values']['css_class'] && user_access('administer blocks')) {
db_update('block')
->fields(array('css_class' => $form_state['values']['css_class']))
->condition('module', $form_state['values']['module'])
->condition('delta', $form_state['values']['delta'])
->execute();
// Flush all context module cache to use the updated css_class.
if (module_exists('context')) {
cache_clear_all('context', 'cache', TRUE);
}
}
}
}
Loading