updated i18n, views, imagestyleflush, field_group
patch views_rss_media
This commit is contained in:
@@ -11,6 +11,7 @@ Features
|
||||
|
||||
- Flush all image styles
|
||||
- Flush each individual image style
|
||||
- Integrates with the admin_menu module
|
||||
|
||||
|
||||
Dependencies
|
||||
@@ -29,6 +30,8 @@ Install
|
||||
2) In your Drupal site, enable the module under Administration -> Modules
|
||||
(/admin/modules).
|
||||
|
||||
3) Visit the Administration -> People -> Permissions page to give the
|
||||
appropriate roles access to flush image styles.
|
||||
|
||||
Usage
|
||||
-----
|
||||
@@ -36,6 +39,8 @@ Usage
|
||||
You can flush image styles under Administration -> Configuration -> Media
|
||||
-> Image styles
|
||||
|
||||
Note that this module only flushes images. It does not rebuild them.
|
||||
|
||||
|
||||
Known problems
|
||||
--------------
|
||||
|
@@ -4,9 +4,9 @@ package = Media
|
||||
core = 7.x
|
||||
configure = admin/config/media/image-styles
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-11-07
|
||||
version = "7.x-1.3"
|
||||
; Information added by Drupal.org packaging script on 2017-12-09
|
||||
version = "7.x-1.5"
|
||||
core = "7.x"
|
||||
project = "imagestyleflush"
|
||||
datestamp = "1446884340"
|
||||
datestamp = "1512780486"
|
||||
|
||||
|
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains install and update functions for imagestyleflush.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A new permission has been defined. Give it to all roles that currently
|
||||
* have the 'administer image styles' permission.
|
||||
*/
|
||||
function imagestyleflush_update_7000() {
|
||||
// Since hook_update_N() can run on disabled modules, ensure the module
|
||||
// file is loaded so we can get the list of permissions.
|
||||
module_load_include('module', 'imagestyleflush', 'imagestyleflush');
|
||||
$permissions = array_keys(imagestyleflush_permission());
|
||||
|
||||
// Get existing role_permissions.
|
||||
$rids = db_select('role_permission', 'rp')
|
||||
->fields('rp', array('rid'))
|
||||
->condition('permission', 'administer image styles')
|
||||
->execute()
|
||||
->fetchCol();
|
||||
|
||||
// Add the permissions for each role.
|
||||
foreach ($rids as $rid) {
|
||||
foreach ($permissions as $name) {
|
||||
db_merge('role_permission')
|
||||
->key(array(
|
||||
'rid' => $rid,
|
||||
'permission' => $name,
|
||||
))
|
||||
->fields(array(
|
||||
'module' => 'imagestyleflush',
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,7 +14,7 @@ function imagestyleflush_menu() {
|
||||
'description' => 'Flush all image styles.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('imagestyleflush_form'),
|
||||
'access arguments' => array('administer image styles'),
|
||||
'access arguments' => array('flush image styles'),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
'weight' => 3,
|
||||
);
|
||||
@@ -23,12 +23,24 @@ function imagestyleflush_menu() {
|
||||
'description' => 'Flush an image style.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('imagestyleflush_form', 5),
|
||||
'access arguments' => array('administer image styles'),
|
||||
'access arguments' => array('flush image styles'),
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function imagestyleflush_permission() {
|
||||
return array(
|
||||
'flush image styles' => array(
|
||||
'title' => t('Flush image styles'),
|
||||
'description' => t('Allow users to flush image styles.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_registry_alter().
|
||||
*/
|
||||
@@ -44,7 +56,10 @@ function imagestyleflush_theme_registry_alter(&$theme_registry) {
|
||||
function imagestyleflush_image_style_list($variables) {
|
||||
$styles = $variables['styles'];
|
||||
|
||||
$header = array(t('Style name'), t('Settings'), array('data' => t('Operations'), 'colspan' => 3));
|
||||
// Account for an extra column added by the image_styles_admin submodule of
|
||||
// the imagecache_actions module.
|
||||
$colspan = module_exists('image_styles_admin') ? 4 : 3;
|
||||
$header = array(t('Style name'), t('Settings'), array('data' => t('Operations'), 'colspan' => $colspan));
|
||||
$rows = array();
|
||||
foreach ($styles as $style) {
|
||||
$row = array();
|
||||
@@ -77,7 +92,7 @@ function imagestyleflush_image_style_list($variables) {
|
||||
|
||||
if (empty($rows)) {
|
||||
$rows[] = array(array(
|
||||
'colspan' => 4,
|
||||
'colspan' => $colspan,
|
||||
'data' => t('There are currently no styles. <a href="!url">Add a new one</a>.', array('!url' => url('admin/config/media/image-styles/add'))),
|
||||
));
|
||||
}
|
||||
@@ -105,7 +120,8 @@ function imagestyleflush_form($form, &$form_state, $style = NULL) {
|
||||
),
|
||||
t('Are you sure you want to flush the %style image style?', array('%style' => $style['label'])),
|
||||
'admin/config/media/image-styles',
|
||||
t('This action cannot be undone.'),
|
||||
'<em>' . t('Note: this will only flush the images. It will not rebuild them.')
|
||||
. '</em><br><br>' . t('This action cannot be undone.'),
|
||||
t('Flush'), t('Cancel')
|
||||
);
|
||||
}
|
||||
@@ -114,7 +130,8 @@ function imagestyleflush_form($form, &$form_state, $style = NULL) {
|
||||
NULL,
|
||||
t('Are you sure you want to flush all image styles?'),
|
||||
'admin/config/media/image-styles',
|
||||
t('This action cannot be undone.'),
|
||||
'<em>' . t('Note: this will only flush the images. It will not rebuild them.')
|
||||
. '</em><br><br>' . t('This action cannot be undone.'),
|
||||
t('Flush'), t('Cancel')
|
||||
);
|
||||
}
|
||||
@@ -138,6 +155,12 @@ function imagestyleflush_form_submit($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
|
||||
// Redirect to the destination URL.
|
||||
$destination = drupal_get_destination();
|
||||
if ($destination['destination'] != current_path()) {
|
||||
$operations[] = array('imagestyleflush_batch_destination_redirect', $destination);
|
||||
}
|
||||
|
||||
$batch = array(
|
||||
'operations' => $operations,
|
||||
'finished' => 'imagestyleflush_batch_finished',
|
||||
@@ -146,6 +169,15 @@ function imagestyleflush_form_submit($form, &$form_state) {
|
||||
batch_set($batch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch operation. Redirect the batch operation if it was called from the
|
||||
* admin_menu item.
|
||||
*/
|
||||
function imagestyleflush_batch_destination_redirect($destination, &$context) {
|
||||
// Set the destination redirect.
|
||||
$context['results']['redirect'] = $destination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch message.
|
||||
*/
|
||||
@@ -156,5 +188,51 @@ function imagestyleflush_batch_finished($success, $results, $operations) {
|
||||
else {
|
||||
drupal_set_message(t('An error occurred while flushing the image caches.'), 'error');
|
||||
}
|
||||
drupal_goto('admin/config/media/image-styles');
|
||||
|
||||
if (!empty($results['redirect'])) {
|
||||
drupal_goto($results['redirect']);
|
||||
}
|
||||
else {
|
||||
// Send the user to the right place depending on their access.
|
||||
if (user_access('administer image styles')) {
|
||||
drupal_goto('admin/config/media/image-styles');
|
||||
}
|
||||
else {
|
||||
drupal_goto();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_admin_menu_output_build().
|
||||
*/
|
||||
function imagestyleflush_admin_menu_output_build(&$content) {
|
||||
// Add link to the icon menu to flush image styles.
|
||||
if (isset($content['icon'])) {
|
||||
$styles = image_styles();
|
||||
$access = user_access('flush image styles');
|
||||
$destination = drupal_get_destination();
|
||||
|
||||
$style_links = array();
|
||||
foreach ($styles as $style) {
|
||||
$style_links[$style['name']] = array(
|
||||
'#title' => $style['label'],
|
||||
'#href' => 'admin/config/media/image-styles/flush/' . $style['name'],
|
||||
'#access' => $access,
|
||||
'#options' => array(
|
||||
'query' => $destination,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$content['icon']['icon']['flush-image-styles'] = array(
|
||||
'#title' => t('Flush all image styles'),
|
||||
'#access' => $access,
|
||||
'#href' => 'admin/config/media/image-styles/flush',
|
||||
'#options' => array(
|
||||
'query' => $destination,
|
||||
),
|
||||
'#weight' => 25,
|
||||
) + $style_links;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user