summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnAlbin2008-09-11 11:26:27 (GMT)
committer JohnAlbin2008-09-11 11:26:27 (GMT)
commita0e81398e74f5f6eb345ae86f44a75b756be052b (patch)
treecf1ed17e1e4c4326fff01a08e3af8d5a410d78f0
parent0b1037f466025067c88dde0eb7cc716c1f092881 (diff)
#306856: Optimize code by adding conditional includes; moved block editing code to template.block-editing.inc.
-rw-r--r--zen/template.block-editing.inc92
-rw-r--r--zen/template.php60
2 files changed, 95 insertions, 57 deletions
diff --git a/zen/template.block-editing.inc b/zen/template.block-editing.inc
new file mode 100644
index 0000000..9dc95c5
--- /dev/null
+++ b/zen/template.block-editing.inc
@@ -0,0 +1,92 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Contains functions only needed if the user has block editing permissions.
+ */
+
+/**
+ * Add block editing variables into the block templates.
+ *
+ * @param $vars
+ * An array of variables to pass to the theme template.
+ * @param $hook
+ * The name of the template being rendered ("block" in this case.)
+ */
+function zen_preprocess_block_editing(&$vars, $hook) {
+ $block = $vars['block'];
+
+ // Display 'edit block' for custom blocks.
+ if ($block->module == 'block') {
+ $edit_links[] = l('<span>' . t('edit block') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
+ array(
+ 'attributes' => array(
+ 'title' => t('edit the content of this block'),
+ 'class' => 'block-edit',
+ ),
+ 'query' => drupal_get_destination(),
+ 'html' => TRUE,
+ )
+ );
+ }
+ // Display 'configure' for other blocks.
+ else {
+ $edit_links[] = l('<span>' . t('configure') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
+ array(
+ 'attributes' => array(
+ 'title' => t('configure this block'),
+ 'class' => 'block-config',
+ ),
+ 'query' => drupal_get_destination(),
+ 'html' => TRUE,
+ )
+ );
+ }
+
+ // Display 'edit view' for Views blocks.
+ if ($block->module == 'views' && user_access('administer views')) {
+ $edit_links[] = l('<span>' . t('edit view') . '</span>', 'admin/build/views/' . $block->delta . '/edit',
+ array(
+ 'attributes' => array(
+ 'title' => t('edit the view that defines this block'),
+ 'class' => 'block-edit-view',
+ ),
+ 'query' => drupal_get_destination(),
+ 'fragment' => 'edit-block',
+ 'html' => TRUE,
+ )
+ );
+ }
+ // Display 'edit menu' for Menu blocks.
+ elseif (($block->module == 'menu' || ($block->module == 'user' && $block->delta == 1)) && user_access('administer menu')) {
+ $menu_name = ($block->module == 'user') ? 'navigation' : $block->delta;
+ $edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
+ array(
+ 'attributes' => array(
+ 'title' => t('edit the menu that defines this block'),
+ 'class' => 'block-edit-menu',
+ ),
+ 'query' => drupal_get_destination(),
+ 'html' => TRUE,
+ )
+ );
+ }
+ // Display 'edit menu' for Menu block blocks.
+ elseif ($block->module == 'menu_block' && user_access('administer menu')) {
+ $menu_name = variable_get('menu_block_' . $block->delta . '_menu_name', 'navigation');
+ $edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
+ array(
+ 'attributes' => array(
+ 'title' => t('edit the menu that defines this block'),
+ 'class' => 'block-edit-menu',
+ ),
+ 'query' => drupal_get_destination(),
+ 'html' => TRUE,
+ )
+ );
+ }
+
+ $vars['edit_links_array'] = $edit_links;
+ $vars['edit_links'] = '<div class="edit">' . implode(' ', $edit_links) . '</div>';
+}
diff --git a/zen/template.php b/zen/template.php
index d19da8c..c9821f9 100644
--- a/zen/template.php
+++ b/zen/template.php
@@ -266,65 +266,11 @@ function zen_preprocess_block(&$vars, $hook) {
$block_classes[] = 'count-' . $vars['id'];
$vars['block_classes'] = implode(' ', $block_classes);
+ $vars['edit_links_array'] = array();
$vars['edit_links'] = '';
if (theme_get_setting('zen_block_editing') && user_access('administer blocks')) {
- // Display 'edit block' for custom blocks
- if ($block->module == 'block') {
- $edit_links[] = l('<span>' . t('edit block') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
- array(
- 'attributes' => array(
- 'title' => t('edit the content of this block'),
- 'class' => 'block-edit',
- ),
- 'query' => drupal_get_destination(),
- 'html' => TRUE,
- )
- );
- }
- // Display 'configure' for other blocks
- else {
- $edit_links[] = l('<span>' . t('configure') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
- array(
- 'attributes' => array(
- 'title' => t('configure this block'),
- 'class' => 'block-config',
- ),
- 'query' => drupal_get_destination(),
- 'html' => TRUE,
- )
- );
- }
-
- // Display 'administer views' for views blocks
- if ($block->module == 'views' && user_access('administer views')) {
- $edit_links[] = l('<span>' . t('edit view') . '</span>', 'admin/build/views/' . $block->delta . '/edit',
- array(
- 'attributes' => array(
- 'title' => t('edit the view that defines this block'),
- 'class' => 'block-edit-view',
- ),
- 'query' => drupal_get_destination(),
- 'fragment' => 'edit-block',
- 'html' => TRUE,
- )
- );
- }
- // Display 'edit menu' for menu blocks
- elseif (($block->module == 'menu' || ($block->module == 'user' && $block->delta == 1)) && user_access('administer menu')) {
- $menu_name = ($block->module == 'user') ? 'navigation' : $block->delta;
- $edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
- array(
- 'attributes' => array(
- 'title' => t('edit the menu that defines this block'),
- 'class' => 'block-edit-menu',
- ),
- 'query' => drupal_get_destination(),
- 'html' => TRUE,
- )
- );
- }
- $vars['edit_links_array'] = $edit_links;
- $vars['edit_links'] = '<div class="edit">' . implode(' ', $edit_links) . '</div>';
+ include_once './' . drupal_get_path('theme', 'zen') . '/template.block-editing.inc';
+ zen_preprocess_block_editing($vars, $hook);
}
}