示例#1
0
文件: template.php 项目: rasjones/csa
/**
 * Implementation of theme_blocks().
 *
 * Print dividers after each second, third or fourth block. These can be used
 * to 'clear' them. This makes it easy te make rows of two, three or four blocks.
 */
function csa_base_blocks($region)
{
    $output = '';
    $block_list = block_list($region);
    $block_count = count($block_list);
    if ($block_count) {
        $i = 1;
        foreach ($block_list as $key => $block) {
            $classes = array();
            $output .= theme('block', $block);
            if ($i % 5 == 0) {
                $classes[] = 'after-fifth-block';
            }
            if ($i % 4 == 0) {
                $classes[] = 'after-fourth-block';
            }
            if ($i % 3 == 0) {
                $classes[] = 'after-third-block';
            }
            if ($i % 2 == 0) {
                $classes[] = 'after-second-block';
            }
            if ($i == $block_count) {
                $classes[] = 'after-last-block';
            }
            if (count($classes) > 0) {
                $output .= '<div class="' . implode(' ', $classes) . '"></div>' . "\n";
            }
            $i++;
        }
    }
    // Add any content assigned to this region through drupal_set_content() calls.
    $output .= drupal_get_content($region);
    return $output;
}
示例#2
0
/**
* Determines if the region has at least one block for this user
*
* @param $region
* A string containing the region name
*
* @return
* TRUE if the region has at least one block. FALSE if it doesn't.
*/
function aut_region_has_block($region)
{
    $number_of_blocks = count(block_list($region));
    if ($number_of_blocks > 0) {
        return TRUE;
    } else {
        return FALSE;
    }
}
示例#3
0
/**
 * Returns a list of blocks.
 *
 * Uses Drupal block interface and appends any blocks 
 * assigned by the Context module.
 * Taken from Fusion Core.
 */
function _bootstrap_barrio_block_list($region)
{
    $drupal_list = array();
    if (module_exists('block')) {
        $drupal_list = block_list($region);
    }
    if (module_exists('context') && ($context = context_get_plugin('reaction', 'block'))) {
        $context_list = $context->block_list($region);
        $drupal_list = array_merge($context_list, $drupal_list);
    }
    return $drupal_list;
}
示例#4
0
function wspine_test_preprocess_block(&$vars, $hook)
{
    // Add a striping class.
    $vars['classes_array'][] = 'block-' . $vars['block_zebra'];
    // Add first/last block classes
    $first_last = "";
    // If block id (count) is 1, it's first in region.
    if ($vars['block_id'] == '1') {
        $first_last = "first";
        $vars['classes_array'][] = $first_last;
    }
    // Count amount of blocks about to be rendered in that region.
    $block_count = count(block_list($vars['elements']['#block']->region));
    if ($vars['block_id'] == $block_count) {
        $first_last = "last";
        $vars['classes_array'][] = $first_last;
    }
}
示例#5
0
/**
 * Implementation of theme_block
 *
 * @see theme_block()
 *
 * Added first and last class to all blocks for styling.
 */
function eepotts_blocks($region)
{
    $output = '';
    if ($list = block_list($region)) {
        $counter = 1;
        foreach ($list as $key => $block) {
            $block->firstlast = '';
            if ($counter == 1) {
                $block->firstlast .= ' first';
            }
            if ($counter == count($list)) {
                $block->firstlast .= ' last';
            }
            $output .= theme('block', $block);
            $counter++;
        }
        //$block->count = count($list);
    }
    $output .= drupal_get_content($region);
    return $output;
}
示例#6
0
/**
 * Override or insert 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(&$vars, $hook)
{
    $block = $vars['block'];
    // Drupal 7 uses a $content variable instead of $block->content.
    $vars['content'] = $block->content;
    // Drupal 7 should use a $title variable instead of $block->subject.
    $vars['title'] = $block->subject;
    // Special classes for blocks.
    $vars['classes_array'][] = 'block-' . $block->module;
    // Classes describing the position of the block within the region.
    if ($vars['block_id'] == 1) {
        $vars['classes_array'][] = 'first';
    }
    if (!function_exists('context_blocks') && count(block_list($vars['block']->region)) == $vars['block_id']) {
        $vars['classes_array'][] = 'last';
    }
    $vars['classes_array'][] = 'region-' . $vars['block_zebra'];
    $vars['classes_array'][] = $vars['zebra'];
    $vars['classes_array'][] = 'region-count-' . $vars['block_id'];
    $vars['classes_array'][] = 'count-' . $vars['id'];
    // Create the block ID.
    $vars['block_html_id'] = 'block-' . $block->module . '-' . $block->delta;
    $vars['edit_links_array'] = array();
    if (theme_get_setting('zen_block_editing') && user_access('administer blocks')) {
        include_once './' . _zen_path() . '/zen-internals/template.block-editing.inc';
        zen_preprocess_block_editing($vars, $hook);
        $vars['classes_array'][] = 'with-block-editing';
    }
}
示例#7
0
文件: page.tpl.php 项目: rodin/mcskb
        print '</li>';
    }
    ?>
  </div>
  <?php 
}
?>
    </div>
  </div>
  <div id="footer" class="footer">
    <div class="doc">
  <?php 
if ($footer_message) {
    print '<span id="footer_message">' . $footer_message . '</span>';
}
foreach (block_list('footer') as $block) {
    print $block->content;
}
?>
    </div>
  </div>
<?php 
if ($node->type == 'kbarticle') {
    ?>
<script type="text/javascript">

function showfor_start() {
    var os = 'windows';
    var browser = 'firefox3.6';
    var detect_os = true;
    var detect_browser = true;  
示例#8
0
/**
 * Return a set of blocks available for the current user.
 *
 * @param $region
 *   Which set of blocks to retrieve.
 * @param $show_blocks
 *   A boolean to determine whether to render sidebar regions or not. Should be
 *   the same value as passed to theme_page.
 * @return
 *   A string containing the themed blocks for this region.
 *
 * @see zen_show_blocks_discovery()
 */
function zen_blocks($region, $show_blocks = NULL)
{
    // Since Drupal 6 doesn't pass $show_blocks to theme_blocks, we manually call
    // theme('blocks', NULL, $show_blocks) so that this function can remember the
    // value on later calls.
    static $render_sidebars = TRUE;
    if (!is_null($show_blocks)) {
        $render_sidebars = $show_blocks;
    }
    // If zen_blocks was called with a NULL region, its likely we were just
    // setting the $render_sidebars static variable.
    if ($region) {
        $output = '';
        // If $renders_sidebars is FALSE, don't render any region whose name begins
        // with "sidebar_".
        if (($render_sidebars || strpos($region, 'sidebar_') !== 0) && ($list = block_list($region))) {
            foreach ($list as $key => $block) {
                // $key == module_delta
                $output .= theme('block', $block);
            }
        }
        // Add any content assigned to this region through drupal_set_content() calls.
        $output .= drupal_get_content($region);
        $elements['#children'] = $output;
        $elements['#region'] = $region;
        return $output ? theme('region', $elements) : '';
    }
}
示例#9
0
/**
 * This function create the EDIT LINKS for blocks and menus blocks.
 * When overing a block (except in IE6), some links appear to edit
 * or configure the block. You can then edit the block, and once you are
 * done, brought back to the first page.
 *
 * @param $vars
 *  A sequential array of variables to pass to the theme template.
 * @param $hook
 *  The name of the theme function being called ("block" in this case.)
 */
function dolphin_preprocess_block(&$vars, $hook)
{
    $block = $vars['block'];
    // special block classes
    $classes = array('block');
    $classes[] = dolphin_id_safe('block-' . $vars['block']->module);
    $classes[] = dolphin_id_safe('block-' . $vars['block']->region);
    $classes[] = dolphin_id_safe('block-id-' . $vars['block']->bid);
    $classes[] = 'clearfix';
    // support for Skinr Module
    if (module_exists('skinr')) {
        $classes[] = $vars['skinr'];
    }
    $vars['block_classes'] = implode(' ', $classes);
    // Concatenate with spaces
    if (theme_get_setting('dolphin_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));
        } 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 menu' for Menu blocks.
        if (($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));
        } elseif ($block->module == 'menu_block' && user_access('administer menu')) {
            list($menu_name, ) = split(':', variable_get("menu_block_{$block->delta}_parent", 'navigation:0'));
            $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>';
    }
    // Add first/last block classes
    $first_last = "";
    // If block id (count) is 1, it's first in region.
    if ($vars['block_id'] == '1') {
        $first_last = " first";
        $vars['block_classes'] .= $first_last;
    }
    // Count amount of blocks about to be rendered in that region.
    $block_count = count(block_list($vars['block']->region));
    if ($vars['block_id'] == $block_count) {
        $first_last = " last";
        $vars['block_classes'] .= $first_last;
    }
}
示例#10
0
function open_framework_is_in_nav_menu($element)
{
    // #theme holds one or more suggestions for theming function names for the link
    // simplify things by casting into an array
    $link_theming_functions = isset($element['#theme']) ? (array) $element['#theme'] : array();
    // Avoid calculating this more than once
    $nav_theming_functions =& drupal_static(__FUNCTION__);
    // if not done yet, calculate the names of the theming function for all the blocks
    // in the navigation region
    if (!isset($nav_theming_functions)) {
        // get all blocks in the navigation region
        $blocks = block_list('navigation');
        // Blocks placed using the context module don't show up using Drupal's block_list
        // If context is enabled, see if it has placed any blocks in the navigation area
        // See: http://drupal.org/node/785350
        $context_blocks = array();
        if (module_exists('context')) {
            $reaction_block_plugin = context_get_plugin('reaction', 'block');
            $context_blocks = $reaction_block_plugin->block_list('navigation');
        }
        $blocks = array_merge($blocks, $context_blocks);
        // extract just their IDs (<module>_<delta>)
        $ids = array_keys($blocks);
        // translate the ids into function names for comparison purposes
        $nav_theming_functions = array_map('open_framework_block_id_to_function_name', $ids);
    }
    // if there is nothing in the navigation section, the main menu is added automatically, so
    // we watch for that.
    // 'menu_link__main_menu' is the theming function name for the main-menu
    if (empty($nav_theming_functions) && in_array('menu_link__main_menu', $link_theming_functions)) {
        return TRUE;
    }
    // Find out if any of the theming functions for the blocks are the same
    // as the theming functions for the link.
    $intersect = array_intersect($nav_theming_functions, $link_theming_functions);
    if (!empty($intersect)) {
        return TRUE;
    } else {
        return FALSE;
    }
}
示例#11
0
function urbanmediaspace_blocks($region, $show_blocks = NULL)
{
    if (module_exists("context")) {
        // Since Drupal 6 doesn't pass $show_blocks to theme_blocks, we manually call
        // theme('blocks', NULL, $show_blocks) so that this function can remember the
        // value on later calls.
        static $render_sidebars = TRUE;
        if (!is_null($show_blocks)) {
            $render_sidebars = $show_blocks;
        }
        // Is the Context module enabled? If so make sure that the blocks Context wants to display get displayed
        if ($region) {
            $output = '';
            if (module_exists("context")) {
                // Get the Context plugin needed to get the blocks that needs to be displayed for this region
                $plugin = context_get_plugin('reaction', 'block');
                // Let's get the blocks that should be displayed from Context.
                if (is_object($plugin)) {
                    $output .= $plugin->execute($region);
                }
            } else {
                // If $renders_sidebars is FALSE, don't render any region whose name begins
                // with "sidebar_".
                if (($render_sidebars || strpos($region, 'sidebar_') !== 0) && ($list = block_list($region))) {
                    foreach ($list as $key => $block) {
                        // $key == module_delta
                        $output .= theme('block', $block);
                    }
                }
                // Add any content assigned to this region through drupal_set_content() calls.
                $output .= drupal_get_content($region);
            }
            $elements['#children'] = $output;
            $elements['#region'] = $region;
            return $output ? theme('region', $elements) : '';
        }
    } else {
        return zen_blocks($region, $show_blocks);
    }
}
示例#12
0
/**
 * Returns a list of blocks.  
 * Uses Drupal block interface and appends any blocks assigned by the Context module.
 */
function fusion_core_block_list($region) {
  $drupal_list = block_list($region);
  if (module_exists('context')) {
    $context = context_get_plugin('reaction', 'block');
    $context_list = $context->block_list($region);
    $drupal_list = array_merge($context_list, $drupal_list);
  }
  return $drupal_list;
}
示例#13
0
/**
 * Override or insert variables into the block templates.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 */
function jbase_preprocess_block(&$vars)
{
    $block = $vars['block'];
    // First/last block position
    $vars['position'] = $vars['block_id'] == 1 ? 'first' : '';
    if ($vars['block_id'] == count(block_list($block->region))) {
        $vars['position'] = $vars['position'] ? '' : 'last';
    }
}
示例#14
0
/**
 * Override or insert variables into the block templates.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 */
function cms_base_preprocess_block(&$vars)
{
    $block = $vars['block'];
    // Special classes for blocks.Allows advanced theming based on context.
    $classes = array();
    $classes[] = 'block-' . $block->module;
    $classes[] = 'region-' . $vars['block_zebra'];
    $classes[] = $vars['zebra'];
    $classes[] = 'region-count-' . $vars['block_id'];
    $classes[] = 'count-' . $vars['id'];
    $vars['edit_links_array'] = array();
    $vars['edit_links'] = '';
    if (theme_get_setting('block_editing_link') && user_access('administer blocks')) {
        $classes[] = 'with-block-editing';
        $vars['block_edit_links_array'] = _cms_base_block_editing_links($vars['block']);
        foreach ($vars['block_edit_links_array'] as $edit_link) {
            $links[] = l('<span>' . $edit_link['title'] . '</span>', $edit_link['url'], array('attributes' => $edit_link['attributes'], 'query' => $edit_link['query'], 'fragment' => $edit_link['fragment'], 'html' => TRUE));
        }
        $vars['block_edit_links'] = '<div class="block-edit">' . implode(' ', $links) . '</div>';
    }
    // Grid class on basis of block count like 'grid_4 if there are for blocks in region (listed in array)
    $dynamic_regions = array('content_top1', 'content_top4', 'content_bottom2', 'content_bottom3', 'footer', 'footer2');
    if (in_array($vars['block']->region, $dynamic_regions)) {
        $block_total_count = count(block_list($vars['block']->region));
        $block_total_count = $block_total_count >= 4 ? 4 : $block_total_count;
        $block_count = 12 / $block_total_count;
        $classes[] = ' grid_' . $block_count;
    }
    // Render block classes.
    $vars['classes'] = implode(' ', $classes);
}
示例#15
0
/**
 * Override block variables to add a variable with "first" and "last" classes to blocks per region
 * Again, most of the variables here are Drupals default.
 * I added $block_region_placement to pass the first/last string to the tpl.
 *  
 * @param $variables
 * A list of block variables
 */
function tendu_preprocess_block(&$variables)
{
    $block_region_placement = array();
    static $block_counter = array();
    // All blocks get an independent counter for each region.
    if (!isset($block_counter[$variables['block']->region])) {
        $block_counter[$variables['block']->region] = 1;
    }
    //Get a list of all blocks in this block's region
    $list = block_list($variables['block']->region);
    //Set class "first" to the first block
    if ($block_counter[$variables['block']->region] == 1) {
        $block_region_placement[] = 'block-first';
    }
    //Set class "last" to the last block
    if ($block_counter[$variables['block']->region] == count($list)) {
        $block_region_placement[] = 'block-last';
    }
    $block_region_placement = array_filter($block_region_placement);
    // Remove empty elements
    $variables['block_region_placement'] = implode(' ', $block_region_placement);
    // Create class list separated by spaces
    // Continue with Drupal default variables
    $variables['block_zebra'] = $block_counter[$variables['block']->region] % 2 ? 'odd' : 'even';
    $variables['block_id'] = $block_counter[$variables['block']->region]++;
    $variables['template_files'][] = 'block-' . $variables['block']->region;
    $variables['template_files'][] = 'block-' . $variables['block']->module;
    $variables['template_files'][] = 'block-' . $variables['block']->module . '-' . $variables['block']->delta;
}
* - $is_admin: Flags true when the current user is an administrator.
*
* Field variables: for each field instance attached to the node a corresponding
* variable is defined; for example, $node->body becomes $body. When needing to
* access a field's raw values, developers/themers are strongly encouraged to
* use these variables. Otherwise they will have to explicitly specify the
* desired field language; for example, $node->body['en'], thus overriding any
* language negotiation rule that was previously applied.
*
* @see template_preprocess()
* @see template_preprocess_node()
* @see template_process()
*
* @ingroup themeable
*/
$has_sidebar = count(block_list('right_sidebar')) > 0;
?>
<div id="node-<?php 
print $node->nid;
?>
" class="product-content <?php 
print $classes;
?>
 clearfix"<?php 
print $attributes;
?>
>
    <div class='row'>
        
        <div class="shop-left col-lg-4 col-md-4 col-sm-12">
            <?php 
示例#17
0
/**
 * Override of theme_blocks().
 * Allows additional theme functions to be defined per region to
 * control block display on a per-region basis. Falls back to default
 * block region handling if no region-specific overrides are found.
 */
function tao_blocks($region)
{
    static $list;
    $output = '';
    $list = module_exists('context') && function_exists('context_block_list') ? context_block_list($region) : block_list($region);
    // Allow theme functions some additional control over regions
    if ($list) {
        $registry = theme_get_registry();
        if (isset($registry['blocks_' . $region])) {
            $output .= theme('blocks_' . $region, $list);
        } else {
            foreach ($list as $key => $block) {
                $output .= theme("block", $block);
            }
            $output .= drupal_get_content($region);
        }
        return $output;
    }
    return '';
}
示例#18
0
/**
 * Returns a list of blocks.
 * Uses Drupal block interface and appends any blocks assigned by the Context module.
 */
function webpro_core_block_list($region)
{
    $drupal_list = array();
    if (module_exists('context') && ($context = context_get_plugin('reaction', 'region'))) {
        // Region reaction might be disabling this region. If it
        // does, an empty array should be returned.
        $dummy_page = array($region => 1);
        $context->execute($dummy_page);
        if (!isset($dummy_page[$region])) {
            return array();
        }
    }
    if (module_exists('block')) {
        $drupal_list = block_list($region);
    }
    if (module_exists('context') && ($context = context_get_plugin('reaction', 'block'))) {
        $context_list = $context->block_list($region);
        $drupal_list = array_merge($context_list, $drupal_list);
    }
    return $drupal_list;
}
示例#19
0
     } else {
         header('Location:index.php?ac=1&f=' . urlencode('index.php?b=' . $blog_serial . '&c=' . $category_name));
         exit;
     }
     break;
 case '12':
     // settings form
     if (admin_check()) {
         if (isset($_GET['e'])) {
             $has_error = true;
         } else {
             $has_error = false;
         }
         $tpls = tpl_list();
         $langs = lang_list();
         $avail_blocks = block_list();
         $avail_blocks_str = '';
         if ($avail_blocks) {
             for ($i = 0, $size = count($avail_blocks); $i < $size; $i++) {
                 $avail_blocks_str .= ',' . $avail_blocks[$i];
             }
             $avail_blocks_str = substr($avail_blocks_str, 1);
         }
         $block_str = '';
         if (sizeof($blocks) > 0) {
             for ($i = 0, $size = count($blocks); $i < $size; $i++) {
                 $block_str .= ',' . $blocks[$i];
             }
             $block_str = substr($block_str, 1);
         }
         $page_title = $lang['general_settings'];
示例#20
0
/**
 * Block region grid info function
 * Defaults match grid_row widths set in preprocess_page()
 */
function fusion_core_set_regions($grid_width, $sidebar_first_width, $sidebar_last_width)
{
    $sidebar_total = $sidebar_first_width + $sidebar_last_width;
    $regions = array('header_top' => array('width' => $grid_width, 'total' => count(block_list('header_top')), 'count' => 0), 'header' => array('width' => $grid_width, 'total' => count(block_list('header')), 'count' => 0), 'preface_top' => array('width' => $grid_width, 'total' => count(block_list('preface_top')), 'count' => 0), 'preface_bottom' => array('width' => $grid_width - $sidebar_first_width, 'total' => count(block_list('preface_bottom')), 'count' => 0), 'sidebar_first' => array('width' => $sidebar_first_width, 'total' => count(block_list('sidebar_first')), 'count' => 0), 'content_top' => array('width' => $grid_width - $sidebar_total, 'total' => count(block_list('content_top')), 'count' => 0), 'content' => array('width' => $grid_width - $sidebar_total, 'total' => count(block_list('content')), 'count' => 0), 'node_top' => array('width' => $grid_width - $sidebar_total, 'total' => count(block_list('node_top')), 'count' => 0), 'node_bottom' => array('width' => $grid_width - $sidebar_total, 'total' => count(block_list('node_bottom')), 'count' => 0), 'content_bottom' => array('width' => $grid_width - $sidebar_total, 'total' => count(block_list('content_bottom')), 'count' => 0), 'sidebar_last' => array('width' => $sidebar_last_width, 'total' => count(block_list('sidebar_last')), 'count' => 0), 'postscript_top' => array('width' => $grid_width - $sidebar_first_width, 'total' => count(block_list('postscript_top')), 'count' => 0), 'postscript_bottom' => array('width' => $grid_width, 'total' => count(block_list('postscript_bottom')), 'count' => 0), 'footer' => array('width' => $grid_width, 'total' => count(block_list('footer')), 'count' => 0));
    return $regions;
}
示例#21
0
/**
 * Override of theme_blocks().
 * Allows additional theme functions to be defined per region to
 * control block display on a per-region basis. Falls back to default
 * block region handling if no region-specific overrides are found.
 */
function tao_blocks($region)
{
    // Bail if this region has been disabled through context.
    if (module_exists('context')) {
        $disabled_regions = context_active_values('theme_regiontoggle');
        if (!empty($disabled_regions) && in_array($region, $disabled_regions)) {
            return '';
        }
    }
    $output = '';
    $list = module_exists('context') && function_exists('context_block_list') ? context_block_list($region) : block_list($region);
    if (!empty($list)) {
        // Allow theme functions some additional control over regions
        $registry = theme_get_registry();
        if (isset($registry['blocks_' . $region])) {
            return theme('blocks_' . $region, $list);
        }
        // Otherwise, flow through regular stack
        foreach ($list as $key => $block) {
            $output .= theme("block", $block);
        }
    }
    return $output . drupal_get_content($region);
}