| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Administrative page callbaks for imagemenu module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Menu callback which shows an overview page of all the custom imagemenus and their descriptions.
|
| 12 |
*/
|
| 13 |
function imagemenu_overview_page() {
|
| 14 |
$sql = "SELECT mid, title, description FROM {imagemenu} WHERE pid = %d ORDER BY weight, title;";
|
| 15 |
$result = db_query($sql, 0);
|
| 16 |
$content = array();
|
| 17 |
while ($menu = db_fetch_array($result)) {
|
| 18 |
$menu['href'] = 'admin/build/menu/imagemenu-customize/'. $menu['mid'];
|
| 19 |
$menu['localized_options'] = array();
|
| 20 |
$content[] = $menu;
|
| 21 |
}
|
| 22 |
if (empty($content)) {
|
| 23 |
$content[] = array(
|
| 24 |
'description' => t('There are no Imagemenus yet.'),
|
| 25 |
'localized_options' => array()
|
| 26 |
);
|
| 27 |
}
|
| 28 |
return theme('admin_block_content', $content);
|
| 29 |
}
|
| 30 |
|
| 31 |
/**
|
| 32 |
* Form for editing an entire imagemenu tree at once.
|
| 33 |
*
|
| 34 |
* Shows for one menu the imagemenu items and relevant operations.
|
| 35 |
*/
|
| 36 |
function imagemenu_overview_form(&$form_state, $menu) {
|
| 37 |
$tree = imagemenu_tree_data($menu['mid']);
|
| 38 |
$form = _imagemenu_overview_tree_form($tree);
|
| 39 |
$form['#menu'] = $menu;
|
| 40 |
if (element_children($form)) {
|
| 41 |
$form['submit'] = array(
|
| 42 |
'#type' => 'submit',
|
| 43 |
'#value' => t('Save configuration'),
|
| 44 |
);
|
| 45 |
}
|
| 46 |
else {
|
| 47 |
$form['empty_menu'] = array('#value' => t('There are no Imagemenu items yet.'));
|
| 48 |
}
|
| 49 |
return $form;
|
| 50 |
}
|
| 51 |
|
| 52 |
/**
|
| 53 |
* Recursive helper function for imagemenu_overview_form().
|
| 54 |
*/
|
| 55 |
function _imagemenu_overview_tree_form($tree) {
|
| 56 |
static $form = array('#tree' => TRUE);
|
| 57 |
foreach ($tree as $data) {
|
| 58 |
$title = '';
|
| 59 |
$item = $data['link'];
|
| 60 |
if ($item) {
|
| 61 |
$mid = 'mid:'. $item['mid'];
|
| 62 |
$form[$mid]['#item'] = $item;
|
| 63 |
$form[$mid]['#attributes'] = (!$item['enabled']) ? array('class' => 'menu-disabled') : array('class' => 'menu-enabled');
|
| 64 |
$form[$mid]['title']['#value'] = l($item['title'], $item['path']) . (!$item['enabled'] ? ' ('. t('disabled') .')' : '');
|
| 65 |
$form[$mid]['enabled'] = array(
|
| 66 |
'#type' => 'checkbox',
|
| 67 |
'#default_value' => $item['enabled'],
|
| 68 |
);
|
| 69 |
$form[$mid]['type'] = array(
|
| 70 |
'#type' => 'checkbox',
|
| 71 |
'#default_value' => $item['type'],
|
| 72 |
);
|
| 73 |
$form[$mid]['weight'] = array(
|
| 74 |
'#type' => 'weight',
|
| 75 |
'#delta' => 50,
|
| 76 |
'#default_value' => isset($form_state[$mid]['weight']) ? $form_state[$mid]['weight'] : $item['weight'],
|
| 77 |
);
|
| 78 |
$form[$mid]['mid'] = array(
|
| 79 |
'#type' => 'hidden',
|
| 80 |
'#value' => $item['mid'],
|
| 81 |
);
|
| 82 |
$form[$mid]['pid'] = array(
|
| 83 |
'#type' => 'textfield',
|
| 84 |
'#default_value' => isset($form_state[$mid]['pid']) ? $form_state[$mid]['pid'] : $item['pid'],
|
| 85 |
'#size' => 6,
|
| 86 |
);
|
| 87 |
// Build a list of operations.
|
| 88 |
$operations = array();
|
| 89 |
$operations['edit'] = l(t('edit'), 'admin/build/menu/imagemenu/item/'. $item['mid'] .'/edit');
|
| 90 |
$operations['delete'] = l(t('delete'), 'admin/build/menu/imagemenu/item/'. $item['mid'] .'/delete');
|
| 91 |
|
| 92 |
$form[$mid]['operations'] = array();
|
| 93 |
foreach ($operations as $op => $value) {
|
| 94 |
$form[$mid]['operations'][$op] = array('#value' => $value);
|
| 95 |
}
|
| 96 |
}
|
| 97 |
|
| 98 |
if ($data['below']) {
|
| 99 |
_imagemenu_overview_tree_form($data['below']);
|
| 100 |
}
|
| 101 |
}
|
| 102 |
return $form;
|
| 103 |
}
|
| 104 |
|
| 105 |
/**
|
| 106 |
* Submit handler for the menu overview form.
|
| 107 |
*/
|
| 108 |
function imagemenu_overview_form_submit($form, &$form_state) {
|
| 109 |
//
|
| 110 |
|
| 111 |
$order = array_flip(array_keys($form['#post'])); // Get the $_POST order.
|
| 112 |
$form = array_merge($order, $form); // Update our original form with the new order.
|
| 113 |
|
| 114 |
$updated_items = array();
|
| 115 |
$fields = array('enabled', 'type', 'weight', 'pid');
|
| 116 |
foreach (element_children($form) as $mid) {
|
| 117 |
if (isset($form[$mid]['#item'])) {
|
| 118 |
$element = $form[$mid];
|
| 119 |
// Update any fields that have changed in this menu item.
|
| 120 |
foreach ($fields as $field) {
|
| 121 |
if ($element[$field]['#value'] != $element[$field]['#default_value']) {
|
| 122 |
$element['#item'][$field] = $element[$field]['#value'];
|
| 123 |
$updated_items[$mid] = $element['#item'];
|
| 124 |
}
|
| 125 |
}
|
| 126 |
}
|
| 127 |
}
|
| 128 |
|
| 129 |
// Save all our changed items to the database.
|
| 130 |
foreach ($updated_items as $item) {
|
| 131 |
db_query('UPDATE {imagemenu} SET pid = %d, enabled = %d, type = %d, weight = %d WHERE mid = %d',
|
| 132 |
$item['pid'], $item['enabled'], $item['type'], $item['weight'], $item['mid']);
|
| 133 |
}
|
| 134 |
}
|
| 135 |
|
| 136 |
/**
|
| 137 |
* Theme the menu overview form into a table.
|
| 138 |
*/
|
| 139 |
function theme_imagemenu_overview_form($form) {
|
| 140 |
drupal_add_tabledrag('menu-overview', 'match', 'parent', 'menu-pid', 'menu-pid', 'menu-mid', TRUE, MENU_MAX_DEPTH - 1);
|
| 141 |
drupal_add_tabledrag('menu-overview', 'order', 'sibling', 'menu-weight');
|
| 142 |
|
| 143 |
$header = array(
|
| 144 |
t('Menu item'),
|
| 145 |
array('data' => t('Enabled'), 'class' => 'checkbox'),
|
| 146 |
array('data' => t('Expanded'), 'class' => 'checkbox'),
|
| 147 |
t('Weight'),
|
| 148 |
array('data' => t('Operations'), 'colspan' => '3'),
|
| 149 |
);
|
| 150 |
|
| 151 |
$rows = array();
|
| 152 |
foreach (element_children($form) as $mid) {
|
| 153 |
if (isset($form[$mid]['enabled'])) {
|
| 154 |
$element = &$form[$mid];
|
| 155 |
// Build a list of operations.
|
| 156 |
$operations = array();
|
| 157 |
foreach (element_children($element['operations']) as $op) {
|
| 158 |
$operations[] = drupal_render($element['operations'][$op]);
|
| 159 |
}
|
| 160 |
while (count($operations) < 2) {
|
| 161 |
$operations[] = '';
|
| 162 |
}
|
| 163 |
|
| 164 |
// Add special classes to be used for tabledrag.js.
|
| 165 |
$element['pid']['#attributes']['class'] = 'menu-pid';
|
| 166 |
$element['mid']['#attributes']['class'] = 'menu-mid';
|
| 167 |
$element['weight']['#attributes']['class'] = 'menu-weight';
|
| 168 |
|
| 169 |
// Change the parent field to a hidden. This allows any value but hides the field.
|
| 170 |
$element['pid']['#type'] = 'hidden';
|
| 171 |
|
| 172 |
$row = array();
|
| 173 |
$row[] = theme('indentation', $element['#item']['depth']) . drupal_render($element['title']);
|
| 174 |
$row[] = array('data' => drupal_render($element['enabled']), 'class' => 'checkbox');
|
| 175 |
$row[] = array('data' => drupal_render($element['type']), 'class' => 'checkbox');
|
| 176 |
$row[] = drupal_render($element['weight']) . drupal_render($element['pid']) . drupal_render($element['mid']);
|
| 177 |
$row = array_merge($row, $operations);
|
| 178 |
|
| 179 |
$row = array_merge(array('data' => $row), $element['#attributes']);
|
| 180 |
$row['class'] = !empty($row['class']) ? $row['class'] .' draggable' : 'draggable';
|
| 181 |
$rows[] = $row;
|
| 182 |
}
|
| 183 |
}
|
| 184 |
$output = '';
|
| 185 |
if ($rows) {
|
| 186 |
$output .= theme('table', $header, $rows, array('id' => 'menu-overview'));
|
| 187 |
}
|
| 188 |
$output .= drupal_render($form);
|
| 189 |
return $output;
|
| 190 |
}
|
| 191 |
|
| 192 |
/**
|
| 193 |
* Menu callback; Build the form that handles the adding/editing of a custom menu.
|
| 194 |
*/
|
| 195 |
function imagemenu_edit_menu(&$form_state, $type, $menu = array()) {
|
| 196 |
if ($type == 'edit') {
|
| 197 |
$form['mid'] = array('#type' => 'value', '#value' => $menu['mid']);
|
| 198 |
$form['#insert'] = FALSE;
|
| 199 |
$form['delete'] = array(
|
| 200 |
'#type' => 'submit',
|
| 201 |
'#value' => t('Delete'),
|
| 202 |
'#submit' => array('imagemenu_delete_menu_submit'),
|
| 203 |
'#weight' => 10,
|
| 204 |
);
|
| 205 |
}
|
| 206 |
else {
|
| 207 |
$menu = array('title' => '', 'description' => '');
|
| 208 |
$form['#insert'] = TRUE;
|
| 209 |
}
|
| 210 |
$form['#title'] = $menu['title'];
|
| 211 |
$form['title'] = array(
|
| 212 |
'#type' => 'textfield',
|
| 213 |
'#title' => t('Title'),
|
| 214 |
'#default_value' => $menu['title'],
|
| 215 |
'#required' => TRUE,
|
| 216 |
);
|
| 217 |
$form['description'] = array(
|
| 218 |
'#type' => 'textarea',
|
| 219 |
'#title' => t('Description'),
|
| 220 |
'#default_value' => $menu['description'],
|
| 221 |
);
|
| 222 |
$form['submit'] = array(
|
| 223 |
'#type' => 'submit',
|
| 224 |
'#value' => t('Save'),
|
| 225 |
);
|
| 226 |
|
| 227 |
return $form;
|
| 228 |
}
|
| 229 |
|
| 230 |
/**
|
| 231 |
* Submit function for adding or editing a custom menu.
|
| 232 |
*/
|
| 233 |
function imagemenu_edit_menu_submit($form, &$form_state) {
|
| 234 |
$menu = $form_state['values'];
|
| 235 |
$path = 'admin/build/menu/imagemenu-customize/';
|
| 236 |
if ($form['#insert']) {
|
| 237 |
db_query("INSERT INTO {imagemenu} (pid, title, description) VALUES (%d, '%s', '%s')", 0, $menu['title'], $menu['description']);
|
| 238 |
$menu['mid'] = db_last_insert_id('imagemenu', 'mid');
|
| 239 |
}
|
| 240 |
else {
|
| 241 |
db_query("UPDATE {imagemenu} SET title = '%s', description = '%s' WHERE mid = %d", $menu['title'], $menu['description'], $menu['mid']);
|
| 242 |
}
|
| 243 |
$form_state['redirect'] = $path . $menu['mid'];
|
| 244 |
}
|
| 245 |
|
| 246 |
/**
|
| 247 |
* Submit function for the 'Delete' button on the menu editing form.
|
| 248 |
*/
|
| 249 |
function imagemenu_delete_menu_submit($form, &$form_state) {
|
| 250 |
$form_state['redirect'] = 'admin/build/menu/imagemenu-customize/'. $form_state['values']['mid'] .'/delete';
|
| 251 |
}
|
| 252 |
|
| 253 |
/**
|
| 254 |
* Build a confirm form for deletion of a custom menu.
|
| 255 |
*/
|
| 256 |
function imagemenu_delete_menu_confirm(&$form_state, $menu) {
|
| 257 |
$form['#menu'] = $menu;
|
| 258 |
$caption = '<p>'. t('This action cannot be undone.') .'</p>';
|
| 259 |
return confirm_form($form, t('Are you sure you want to delete the imagemenu %title?', array('%title' => $menu['title'])), 'admin/build/menu/imagemenu-customize/'. $menu['mid'], $caption, t('Delete'));
|
| 260 |
}
|
| 261 |
|
| 262 |
/**
|
| 263 |
* Delete a imagemenu and all items in it.
|
| 264 |
*/
|
| 265 |
function imagemenu_delete_menu_confirm_submit($form, &$form_state) {
|
| 266 |
$menu = $form['#menu'];
|
| 267 |
$form_state['redirect'] = 'admin/build/menu/imagemenu';
|
| 268 |
$pid = $menu['mid'];
|
| 269 |
$items = imagemenu_fetch_rows($pid, TRUE);
|
| 270 |
if ($items) {
|
| 271 |
foreach ($items as $item) {
|
| 272 |
db_query('DELETE FROM {imagemenu} WHERE mid = %d', $item['mid']);
|
| 273 |
}
|
| 274 |
}
|
| 275 |
db_query('DELETE FROM {imagemenu} WHERE mid = %d', $pid);
|
| 276 |
|
| 277 |
cache_clear_all();
|
| 278 |
$t_args = array('%title' => $menu['title']);
|
| 279 |
drupal_set_message(t('The menu %title and all its menu items have been deleted.', $t_args));
|
| 280 |
watchdog('imagemenu', 'Deleted menu %title and all its menu items.', $t_args, WATCHDOG_NOTICE);
|
| 281 |
}
|
| 282 |
|
| 283 |
/**
|
| 284 |
* Menu callback; Build the menu link editing form.
|
| 285 |
*/
|
| 286 |
function imagemenu_edit_item(&$form_state, $type, $item, $menu) {
|
| 287 |
$mid = isset($menu['mid']) ? $menu['mid'] : 0;
|
| 288 |
|
| 289 |
$form['menu'] = array(
|
| 290 |
'#type' => 'fieldset',
|
| 291 |
'#title' => t('Menu settings'),
|
| 292 |
'#collapsible' => FALSE,
|
| 293 |
'#tree' => TRUE,
|
| 294 |
'#weight' => -2,
|
| 295 |
'#attributes' => array('class' => 'menu-item-form'),
|
| 296 |
'#item' => $item,
|
| 297 |
);
|
| 298 |
if ($type == 'add' || empty($item)) {
|
| 299 |
// This is an add form, initialize the menu link.
|
| 300 |
$item = array('mid' => 0, 'pid' => $mid, 'title' => '', 'imagepath' => '', 'mouseover' => '', 'path' => '', 'alt' => '', 'enabled' => 1, 'type' => 0, 'weight' => 0);
|
| 301 |
}
|
| 302 |
if ($type == 'edit') {
|
| 303 |
$form['delete'] = array(
|
| 304 |
'#type' => 'submit',
|
| 305 |
'#value' => t('Delete'),
|
| 306 |
'#submit' => array('imagemenu_item_delete_submit'),
|
| 307 |
'#weight' => 10,
|
| 308 |
);
|
| 309 |
}
|
| 310 |
foreach (array('mid', 'pid', 'title', 'imagepath', 'mouseover', 'path', 'alt', 'enabled', 'type', 'weight') as $key) {
|
| 311 |
$form['menu'][$key] = array('#type' => 'value', '#value' => $item[$key]);
|
| 312 |
}
|
| 313 |
|
| 314 |
$form['menu']['title'] = array(
|
| 315 |
'#type' => 'textfield',
|
| 316 |
'#title' => t('Title'),
|
| 317 |
'#default_value' => $item['title'],
|
| 318 |
'#description' => t('The name of the menu item (displayed when hovering over a menu image).'),
|
| 319 |
'#required' => TRUE,
|
| 320 |
'#weight' => -10,
|
| 321 |
);
|
| 322 |
$form['menu']['imagepath'] = array(
|
| 323 |
'#type' => 'textfield',
|
| 324 |
'#title' => t('Image Path'),
|
| 325 |
'#default_value' => $item['imagepath'],
|
| 326 |
'#description' => t('The path to the image.'),
|
| 327 |
'#required' => TRUE,
|
| 328 |
'#weight' => -9,
|
| 329 |
);
|
| 330 |
$form['menu']['mouseover'] = array(
|
| 331 |
'#type' => 'textfield',
|
| 332 |
'#title' => t('Image Path'),
|
| 333 |
'#default_value' => $item['mouseover'],
|
| 334 |
'#description' => t('Optional. The path to an image to display on mouseover.'),
|
| 335 |
'#weight' => -8,
|
| 336 |
);
|
| 337 |
$form['menu']['path'] = array(
|
| 338 |
'#type' => 'textfield',
|
| 339 |
'#title' => t('Path'),
|
| 340 |
'#default_value' => $item['path'],
|
| 341 |
'#description' => t('The path this menu item links to. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org')),
|
| 342 |
'#weight' => -7,
|
| 343 |
);
|
| 344 |
$form['menu']['alt'] = array(
|
| 345 |
'#type' => 'textfield',
|
| 346 |
'#title' => t('Description'),
|
| 347 |
'#default_value' => $item['alt'],
|
| 348 |
'#description' => t('The ALT tag for the image if its not displayed.'),
|
| 349 |
'#weight' => -6,
|
| 350 |
);
|
| 351 |
$form['menu']['enabled'] = array(
|
| 352 |
'#type' => 'checkbox',
|
| 353 |
'#title' => t('Enabled'),
|
| 354 |
'#default_value' => ($item['enabled'] ? 1 : 0),
|
| 355 |
'#description' => t('Menu items that are not enabled will not be listed in any menu.'),
|
| 356 |
'#weight' => -5,
|
| 357 |
);
|
| 358 |
$form['menu']['expanded'] = array(
|
| 359 |
'#type' => 'checkbox',
|
| 360 |
'#title' => t('Expanded'),
|
| 361 |
'#default_value' => ($item['type'] ? 1 : 0),
|
| 362 |
'#description' => t('If selected and this menu item has children, the menu will always appear expanded.'),
|
| 363 |
'#weight' => -4,
|
| 364 |
);
|
| 365 |
$options = imagemenu_parents($mid);
|
| 366 |
$basetitle = isset($menu['title']) ? ('<' . $menu['title'] . '>') : '<base>';
|
| 367 |
if (!$options) $options = array($mid => $basetitle);
|
| 368 |
$form['menu']['pid'] = array(
|
| 369 |
'#type' => 'select',
|
| 370 |
'#title' => t('Parent item'),
|
| 371 |
'#default_value' => $item['pid'],
|
| 372 |
'#options' => $options,
|
| 373 |
'#attributes' => array('class' => 'menu-title-select'),
|
| 374 |
'#weight' => -3,
|
| 375 |
);
|
| 376 |
$form['menu']['weight'] = array(
|
| 377 |
'#type' => 'weight',
|
| 378 |
'#title' => t('Weight'),
|
| 379 |
'#delta' => 50,
|
| 380 |
'#default_value' => $item['weight'],
|
| 381 |
'#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
|
| 382 |
'#weight' => -2,
|
| 383 |
);
|
| 384 |
// We have to find and pass the parent menu for this item to allow
|
| 385 |
// comfortable redirects after adding/editing
|
| 386 |
if ($mid) {
|
| 387 |
$pmid = $mid;
|
| 388 |
}
|
| 389 |
else {
|
| 390 |
$pmid = imagemenu_find_parent($item['mid']);
|
| 391 |
}
|
| 392 |
$form['menu']['pmid'] = array(
|
| 393 |
'#type' => 'hidden',
|
| 394 |
'#value' => $pmid,
|
| 395 |
);
|
| 396 |
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
|
| 397 |
|
| 398 |
return $form;
|
| 399 |
}
|
| 400 |
|
| 401 |
/**
|
| 402 |
* Validate form values for a menu link being added or edited.
|
| 403 |
*/
|
| 404 |
function imagemenu_edit_item_validate($form, &$form_state) {
|
| 405 |
$item = &$form_state['values']['menu'];
|
| 406 |
$check = is_readable($item['imagepath']);
|
| 407 |
if (!$check) form_set_error('imagepath', t('File not found.'));
|
| 408 |
$check = is_readable($item['mouseover']);
|
| 409 |
if (!$check && $item['mouseover']) form_set_error('mouseover', t('File not found.'));
|
| 410 |
}
|
| 411 |
|
| 412 |
/**
|
| 413 |
* Process menu and menu item add/edit form submissions.
|
| 414 |
*/
|
| 415 |
function imagemenu_edit_item_submit($form, &$form_state) {
|
| 416 |
$item = $form_state['values']['menu'];
|
| 417 |
|
| 418 |
if ($item['path'] == 'node') $item['path'] = '<front>';
|
| 419 |
if (!$item['mid']) {
|
| 420 |
db_query("INSERT INTO {imagemenu} (pid, path, imagepath, mouseover, title, alt, weight, type) VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d, %d)", $item['pid'], $item['path'], $item['imagepath'], $item['mouseover'], $item['title'], $item['alt'], $item['weight'], $item['expanded']);
|
| 421 |
drupal_set_message(t('Menu item successfully added.'));
|
| 422 |
$t_args = array('%title' => $item['title']);
|
| 423 |
watchdog('imagemenu', t('Added new Imagemenu menu item %title', $t_args), WATCHDOG_NOTICE);
|
| 424 |
}
|
| 425 |
else {
|
| 426 |
db_query("UPDATE {imagemenu} SET pid = %d, path = '%s', imagepath = '%s', mouseover = '%s', title = '%s', alt = '%s', weight = %d, type = %d, enabled = %d WHERE mid = %d", $item['pid'], $item['path'], $item['imagepath'], $item['mouseover'], $item['title'], $item['alt'], $item['weight'], $item['expanded'], $item['enabled'], $item['mid']);
|
| 427 |
drupal_set_message(t('Menu item successfully updated.'));
|
| 428 |
$t_args = array('%title' => $item['title']);
|
| 429 |
watchdog('imagemenu', t('Updated Imagemenu menu item %title', $t_args), WATCHDOG_NOTICE);
|
| 430 |
}
|
| 431 |
$form_state['redirect'] = 'admin/build/menu/imagemenu-customize/' . $item['pmid'];
|
| 432 |
}
|
| 433 |
|
| 434 |
/**
|
| 435 |
* Submit function for the delete button on the menu item editing form.
|
| 436 |
*/
|
| 437 |
function imagemenu_item_delete_submit($form, &$form_state) {
|
| 438 |
$form_state['redirect'] = 'admin/build/menu/imagemenu/item/'. $form_state['values']['menu']['mid'] .'/delete';
|
| 439 |
}
|
| 440 |
|
| 441 |
/**
|
| 442 |
* Build a confirm form for deletion of a single menu link.
|
| 443 |
*/
|
| 444 |
function imagemenu_item_delete_form(&$form_state, $item) {
|
| 445 |
$form['#item'] = $item;
|
| 446 |
$pmid = imagemenu_find_parent($item['mid']);
|
| 447 |
return confirm_form($form, t('Are you sure you want to delete the imagemenu item %item?', array('%item' => $item['title'])), 'admin/build/menu/imagemenu-customize/'. $pmid);
|
| 448 |
}
|
| 449 |
|
| 450 |
/**
|
| 451 |
* Process menu delete form submissions.
|
| 452 |
*/
|
| 453 |
function imagemenu_item_delete_form_submit($form, &$form_state) {
|
| 454 |
$item = $form['#item'];
|
| 455 |
$pmid = imagemenu_find_parent($item['mid']);
|
| 456 |
db_query('DELETE FROM {imagemenu} WHERE mid = %d', $item['mid']);
|
| 457 |
$t_args = array('%title' => $item['title']);
|
| 458 |
drupal_set_message(t('The imagemenu item %title has been deleted.', $t_args));
|
| 459 |
watchdog('menu', 'Deleted imagemenu item %title.', $t_args, WATCHDOG_NOTICE);
|
| 460 |
$form_state['redirect'] = 'admin/build/menu/imagemenu-customize/'. $pmid;
|
| 461 |
}
|
| 462 |
|
| 463 |
/**
|
| 464 |
* Menu callback; Build the form presenting menu configuration options.
|
| 465 |
*/
|
| 466 |
function imagemenu_configure() {
|
| 467 |
$form['intro'] = array(
|
| 468 |
'#type' => 'item',
|
| 469 |
'#value' => t('Administration Screen Settings:'),
|
| 470 |
);
|
| 471 |
|
| 472 |
/*$menu_options = imagemenu_base_rows();
|
| 473 |
$form['imagemenu_block'] = array(
|
| 474 |
'#type' => 'select',
|
| 475 |
'#title' => t('Default menu for content'),
|
| 476 |
'#default_value' => variable_get('imagemenu_block', '0'),
|
| 477 |
'#options' => $menu_options ? $menu_options : array(0 => t('No menus created')),
|
| 478 |
'#description' => t('Which menu to display in the imagemenu block.'),
|
| 479 |
);*/
|
| 480 |
$form['imagemenu_layout'] = array(
|
| 481 |
'#type' => 'select',
|
| 482 |
'#title' => t('Layout'),
|
| 483 |
'#default_value' => variable_get('imagemenu_layout', 'vertical'),
|
| 484 |
'#options' => array('vertical' => 'vertical', 'horizontal' => 'horizontal'),
|
| 485 |
'#tree' => FALSE,
|
| 486 |
'#description' => t('The orientation of the menu.'),
|
| 487 |
);
|
| 488 |
|
| 489 |
return system_settings_form($form);
|
| 490 |
}
|