image_styles_admin.module 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * @file Hook and callback implementations that must be available at all times.
  4. */
  5. /**
  6. * Implements hook_menu().
  7. */
  8. function image_styles_admin_menu() {
  9. $items = array();
  10. $items['admin/config/media/image-styles/duplicate/%image_style'] = array(
  11. 'title' => 'Duplicate style',
  12. 'description' => 'Make a copy of an image style.',
  13. 'page callback' => 'image_styles_admin_duplicate_page_callback',
  14. 'page arguments' => array(5),
  15. 'access arguments' => array('administer image styles'),
  16. 'file' => 'image_styles_admin.inc',
  17. );
  18. $items['admin/config/media/image-styles/export/%image_style'] = array(
  19. 'title' => 'Export style',
  20. 'description' => 'Export an image style.',
  21. 'page callback' => 'drupal_get_form',
  22. 'page arguments' => array('image_styles_admin_export_form', 5),
  23. 'access arguments' => array('administer image styles'),
  24. 'file' => 'image_styles_admin.inc',
  25. );
  26. $items['admin/config/media/image-styles/import'] = array(
  27. 'title' => 'Import style',
  28. 'description' => 'Import an image style.',
  29. 'page callback' => 'drupal_get_form',
  30. 'page arguments' => array('image_styles_admin_import_form'),
  31. 'access arguments' => array('administer image styles'),
  32. 'type' => MENU_LOCAL_ACTION,
  33. 'weight' => 3,
  34. 'file' => 'image_styles_admin.inc',
  35. );
  36. return $items;
  37. }
  38. /**
  39. * Implements hook_preprocess_HOOK for theme image_style_list.
  40. */
  41. function image_styles_admin_preprocess_image_style_list(&$variables) {
  42. // Tell imagecache_actions_preprocess_image_style_list to preprocess the next
  43. // call to theme_table()
  44. $flag = TRUE;
  45. image_styles_admin_preprocess_table($flag);
  46. }
  47. /**
  48. * Implements hook_preprocess_HOOK for theme table.
  49. */
  50. function image_styles_admin_preprocess_table(&$variables) {
  51. static $is_in_image_style_list = FALSE;
  52. if (is_bool($variables)) {
  53. // Called from imagecache_actions_style_duplicate(): set flag
  54. $is_in_image_style_list = $variables;
  55. }
  56. else if ($is_in_image_style_list) {
  57. // Normal preprocess hook call: only process if theme('table', ...) has been
  58. // called by theme_image_style_list()
  59. $variables['header'][2]['colspan'] = 4;
  60. foreach ($variables['rows'] as &$row) {
  61. array_splice($row, 2, 0, array($row[2], $row[2]));
  62. // Replace edit with duplicate in text and href
  63. $row[3] = str_replace('>' . t('edit') . '<', '>' . t('duplicate') . '<', $row[3]);
  64. $row[3] = preg_replace('/\/edit\/([-a-z0-9_]+)"/', '/duplicate/\1"', $row[3]);
  65. // Replace edit with export in text and href
  66. $row[4] = str_replace('>' . t('edit') . '<', '>' . t('export') . '<', $row[4]);
  67. $row[4] = preg_replace('/\/edit\/([-a-z0-9_]+)"/', '/export/\1"', $row[4]);
  68. }
  69. // Don't preprocess subsequent calls to theme_table().
  70. $is_in_image_style_list = FALSE;
  71. }
  72. }