790b01e199b75709e5f2466646356a64edb0a4de
[project/zen.git] / zen / template.block-editing.inc
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Contains functions only needed if the user has block editing permissions.
7 */
8
9 /**
10 * Add block editing variables into the block templates.
11 *
12 * @param $vars
13 * An array of variables to pass to the theme template.
14 * @param $hook
15 * The name of the template being rendered ("block" in this case.)
16 */
17 function zen_preprocess_block_editing(&$vars, $hook) {
18 $block = $vars['block'];
19
20 // Display 'edit block' for custom blocks.
21 if ($block->module == 'block') {
22 $edit_links[] = l('<span>' . t('edit block') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
23 array(
24 'attributes' => array(
25 'title' => t('edit the content of this block'),
26 'class' => 'block-edit',
27 ),
28 'query' => drupal_get_destination(),
29 'html' => TRUE,
30 )
31 );
32 }
33 // Display 'configure' for other blocks.
34 else {
35 $edit_links[] = l('<span>' . t('configure') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
36 array(
37 'attributes' => array(
38 'title' => t('configure this block'),
39 'class' => 'block-config',
40 ),
41 'query' => drupal_get_destination(),
42 'html' => TRUE,
43 )
44 );
45 }
46
47 // Display 'edit view' for Views blocks.
48 if ($block->module == 'views' && user_access('administer views')) {
49 $edit_links[] = l('<span>' . t('edit view') . '</span>', 'admin/build/views/' . $block->delta . '/edit',
50 array(
51 'attributes' => array(
52 'title' => t('edit the view that defines this block'),
53 'class' => 'block-edit-view',
54 ),
55 'query' => drupal_get_destination(),
56 'fragment' => 'edit-block',
57 'html' => TRUE,
58 )
59 );
60 }
61 // Display 'edit menu' for Menu blocks.
62 elseif (($block->module == 'menu' || ($block->module == 'user' && $block->delta == 1)) && user_access('administer menu')) {
63 $menu_name = ($block->module == 'user') ? 'navigation' : $block->delta;
64 $edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
65 array(
66 'attributes' => array(
67 'title' => t('edit the menu that defines this block'),
68 'class' => 'block-edit-menu',
69 ),
70 'query' => drupal_get_destination(),
71 'html' => TRUE,
72 )
73 );
74 }
75 // Display 'edit menu' for Menu block blocks.
76 elseif ($block->module == 'menu_block' && user_access('administer menu')) {
77 list($menu_name, ) = split(':', variable_get("menu_block_{$block->delta}_parent", 'navigation:0'));
78 $edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
79 array(
80 'attributes' => array(
81 'title' => t('edit the menu that defines this block'),
82 'class' => 'block-edit-menu',
83 ),
84 'query' => drupal_get_destination(),
85 'html' => TRUE,
86 )
87 );
88 }
89
90 $vars['edit_links_array'] = $edit_links;
91 $vars['edit_links'] = '<div class="edit">' . implode(' ', $edit_links) . '</div>';
92 }