| 1 |
<?php
|
| 2 |
// $Id: imagecache_ui.module,v 1.31 2009/05/03 16:14:24 drewish Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Administrative interface to imagecache.
|
| 6 |
*
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_help().
|
| 11 |
*/
|
| 12 |
function imagecache_ui_help($path, $arg) {
|
| 13 |
switch($path) {
|
| 14 |
case 'admin/build/imagecache':
|
| 15 |
return t('Manage ImageCache presets.');
|
| 16 |
case 'admin/build/imagecache/%/export':
|
| 17 |
return t('Place the following snippet in your module as part of <code>hook_imagecache_default_presets()</code>.');
|
| 18 |
}
|
| 19 |
}
|
| 20 |
|
| 21 |
/**
|
| 22 |
* Implementation of hook_menu().
|
| 23 |
*/
|
| 24 |
function imagecache_ui_menu() {
|
| 25 |
$items = array();
|
| 26 |
$items['admin/build/imagecache'] = array(
|
| 27 |
'title' => 'ImageCache',
|
| 28 |
'file' => 'imagecache_ui.pages.inc',
|
| 29 |
'description' => 'Administer imagecache presets and actions.',
|
| 30 |
'page callback' => 'imagecache_ui_preset_overview',
|
| 31 |
'access arguments' => array('administer imagecache'),
|
| 32 |
);
|
| 33 |
$items['admin/build/imagecache/list'] = array(
|
| 34 |
'title' => 'List',
|
| 35 |
'type' => MENU_DEFAULT_LOCAL_TASK,
|
| 36 |
'weight' => -10,
|
| 37 |
);
|
| 38 |
|
| 39 |
$items['admin/build/imagecache/add'] = array(
|
| 40 |
'title' => 'Add new preset',
|
| 41 |
'file' => 'imagecache_ui.pages.inc',
|
| 42 |
'page callback' => 'drupal_get_form',
|
| 43 |
'page arguments' => array('imagecache_ui_preset_form'),
|
| 44 |
'access arguments' => array('administer imagecache'),
|
| 45 |
'type' => MENU_LOCAL_TASK,
|
| 46 |
);
|
| 47 |
|
| 48 |
$items['admin/build/imagecache/%imagecache_ui_preset'] = array(
|
| 49 |
'title callback' => 'imagecache_preset_title_callback',
|
| 50 |
'title arguments' => array('Edit preset: !presetname', 3),
|
| 51 |
'file' => 'imagecache_ui.pages.inc',
|
| 52 |
'page callback' => 'drupal_get_form',
|
| 53 |
'page arguments' => array('imagecache_ui_preset_form', 3),
|
| 54 |
'access arguments' => array('administer imagecache'),
|
| 55 |
'type' => MENU_CALLBACK,
|
| 56 |
);
|
| 57 |
$items['admin/build/imagecache/%imagecache_ui_preset/delete'] = array(
|
| 58 |
'title callback' => 'imagecache_preset_title_callback',
|
| 59 |
'title arguments' => array('Delete preset: !presetname', 3),
|
| 60 |
'file' => 'imagecache_ui.pages.inc',
|
| 61 |
'page callback' => 'drupal_get_form',
|
| 62 |
'page arguments' => array('imagecache_ui_preset_delete_form', 3),
|
| 63 |
'access arguments' => array('administer imagecache'),
|
| 64 |
'type' => MENU_CALLBACK,
|
| 65 |
);
|
| 66 |
$items['admin/build/imagecache/%imagecache_ui_preset/flush'] = array(
|
| 67 |
'title callback' => 'imagecache_preset_title_callback',
|
| 68 |
'title arguments' => array('Flush preset: !presetname', 3),
|
| 69 |
'file' => 'imagecache_ui.pages.inc',
|
| 70 |
'page callback' => 'drupal_get_form',
|
| 71 |
'page arguments' => array('imagecache_ui_preset_flush_form', 3),
|
| 72 |
'access arguments' => array('flush imagecache'),
|
| 73 |
'type' => MENU_CALLBACK,
|
| 74 |
);
|
| 75 |
$items['admin/build/imagecache/%imagecache_ui_preset/export'] = array(
|
| 76 |
'title callback' => 'imagecache_preset_title_callback',
|
| 77 |
'title arguments' => array('Export preset: !presetname', 3),
|
| 78 |
'file' => 'imagecache_ui.pages.inc',
|
| 79 |
'page callback' => 'drupal_get_form',
|
| 80 |
'page arguments' => array('imagecache_ui_preset_export_form', 3),
|
| 81 |
'access arguments' => array('administer imagecache'),
|
| 82 |
'type' => MENU_CALLBACK,
|
| 83 |
);
|
| 84 |
$items['admin/build/imagecache/%imagecache_ui_preset/override'] = array(
|
| 85 |
'title callback' => 'imagecache_preset_title_callback',
|
| 86 |
'title arguments' => array('Override preset: !presetname', 3),
|
| 87 |
'file' => 'imagecache_ui.pages.inc',
|
| 88 |
'page callback' => 'drupal_get_form',
|
| 89 |
'page arguments' => array('imagecache_ui_preset_form', 3, TRUE),
|
| 90 |
'access arguments' => array('administer imagecache'),
|
| 91 |
'type' => MENU_CALLBACK,
|
| 92 |
);
|
| 93 |
|
| 94 |
$items['admin/build/imagecache/%imagecache_ui_preset/add/%'] = array(
|
| 95 |
'title callback' => 'imagecache_preset_title_callback',
|
| 96 |
'title arguments' => array('Add !actionname to !presetname', 3, 5),
|
| 97 |
'file' => 'imagecache_ui.pages.inc',
|
| 98 |
'page callback' => 'imagecache_ui_action_add_page',
|
| 99 |
'page arguments' => array(3, 5),
|
| 100 |
'access arguments' => array('administer imagecache'),
|
| 101 |
'type' => MENU_CALLBACK,
|
| 102 |
);
|
| 103 |
|
| 104 |
$items['admin/build/imagecache/%imagecache_ui_preset/%imagecache_action'] = array(
|
| 105 |
'title callback' => 'imagecache_preset_title_callback',
|
| 106 |
'title arguments' => array('!action for preset !presetname', 3, 4),
|
| 107 |
'file' => 'imagecache_ui.pages.inc',
|
| 108 |
'page callback' => 'drupal_get_form',
|
| 109 |
'page arguments' => array('imagecache_ui_action_form', 3, 4),
|
| 110 |
'access arguments' => array('administer imagecache'),
|
| 111 |
'type' => MENU_CALLBACK,
|
| 112 |
);
|
| 113 |
|
| 114 |
$items['admin/build/imagecache/%imagecache_ui_preset/%imagecache_action/delete'] = array(
|
| 115 |
'title callback' => 'imagecache_preset_title_callback',
|
| 116 |
'title arguments' => array('Delete !action for preset !presetname', 3, 4),
|
| 117 |
'file' => 'imagecache_ui.pages.inc',
|
| 118 |
'page callback' => 'drupal_get_form',
|
| 119 |
'page arguments' => array('imagecache_ui_action_delete_form', 3, 4),
|
| 120 |
'access arguments' => array('administer imagecache'),
|
| 121 |
'type' => MENU_CALLBACK,
|
| 122 |
);
|
| 123 |
return $items;
|
| 124 |
}
|
| 125 |
|
| 126 |
/**
|
| 127 |
* Menu wildcard loader.
|
| 128 |
*/
|
| 129 |
function imagecache_ui_preset_load($preset_id) {
|
| 130 |
return imagecache_preset($preset_id, TRUE);
|
| 131 |
}
|
| 132 |
|
| 133 |
function imagecache_preset_title_callback($title, $preset = array(), $action = array()) {
|
| 134 |
$replacements = array();
|
| 135 |
if (!empty($preset)) {
|
| 136 |
$replacements['!presetname'] = $preset['presetname'];
|
| 137 |
$replacements['!presetid'] = $preset['presetid'];
|
| 138 |
}
|
| 139 |
if (!empty($action) && !is_array($action)) {
|
| 140 |
$replacements['!actionname'] = $action;
|
| 141 |
}
|
| 142 |
elseif (!empty($action)) {
|
| 143 |
$replacements['!action'] = $action['action'];
|
| 144 |
}
|
| 145 |
return t($title, $replacements);
|
| 146 |
}
|
| 147 |
|
| 148 |
/**
|
| 149 |
* Implementation of hook_theme().
|
| 150 |
*/
|
| 151 |
function imagecache_ui_theme() {
|
| 152 |
return array(
|
| 153 |
'imagecache_ui_preset_actions' => array(
|
| 154 |
'arguments' => array(
|
| 155 |
'form' => NULL,
|
| 156 |
),
|
| 157 |
'file' => 'imagecache_ui.pages.inc',
|
| 158 |
),
|
| 159 |
);
|
| 160 |
}
|
| 161 |
|